[gjs: 22/25] js: Remove jsapi-wrapper.h



commit d783d40c8162ed94254bdb3762592cdbece6e5ba
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Nov 23 23:07:21 2019 -0800

    js: Remove jsapi-wrapper.h
    
    With SpiderMonkey 68, it's no longer necessary to mark SpiderMonkey
    header files as system headers, and it's also no longer necessary to
    include <js-config.h> before any other header files, as SpiderMonkey
    has sorted that out internally.
    
    We remove jsapi-wrapper.h and define DEBUG directly in config.h instead
    of indirectly in jsapi-wrapper.h via HAVE_SPIDERMONKEY_DEBUG.
    
    This should reduce compile time, on average, because in most .h files
    we now only need to include <js/TypeDecls.h>.

 doc/CPP_Style_Guide.md            | 21 +++++++++-------
 gi/arg.cpp                        | 14 ++++++++++-
 gi/arg.h                          |  4 +++-
 gi/boxed.cpp                      | 14 +++++++++--
 gi/boxed.h                        | 18 ++++++++++++--
 gi/closure.cpp                    |  6 ++++-
 gi/closure.h                      |  8 ++++++-
 gi/enumeration.cpp                |  6 ++++-
 gi/enumeration.h                  |  4 +++-
 gi/foreign.cpp                    |  4 +++-
 gi/foreign.h                      |  4 +++-
 gi/function.cpp                   | 18 +++++++++++---
 gi/function.h                     |  8 ++++++-
 gi/fundamental.cpp                | 15 ++++++++++--
 gi/fundamental.h                  | 10 +++++++-
 gi/gerror.cpp                     | 13 ++++++++--
 gi/gerror.h                       |  8 ++++++-
 gi/gobject.cpp                    |  7 +++++-
 gi/gtype.cpp                      | 14 +++++++++--
 gi/gtype.h                        |  4 +++-
 gi/interface.cpp                  |  5 +++-
 gi/interface.h                    |  6 ++++-
 gi/ns.cpp                         | 11 ++++++++-
 gi/object.cpp                     | 18 +++++++++++++-
 gi/object.h                       | 17 +++++++++++--
 gi/param.cpp                      | 10 +++++++-
 gi/param.h                        |  4 +++-
 gi/private.cpp                    |  9 ++++++-
 gi/private.h                      |  4 +++-
 gi/repo.cpp                       | 16 +++++++++++--
 gi/repo.h                         |  4 +++-
 gi/union.cpp                      | 11 +++++++--
 gi/union.h                        |  8 ++++++-
 gi/value.cpp                      | 13 ++++++++--
 gi/value.h                        |  4 +++-
 gi/wrapperutils.cpp               |  6 ++++-
 gi/wrapperutils.h                 | 14 +++++++++--
 gjs/atoms.cpp                     |  7 +++++-
 gjs/atoms.h                       |  6 ++++-
 gjs/byteArray.cpp                 | 13 ++++++++--
 gjs/byteArray.h                   |  4 +++-
 gjs/context-private.h             | 11 ++++++---
 gjs/context.cpp                   | 25 ++++++++++++++++----
 gjs/coverage.cpp                  | 10 +++++++-
 gjs/debugger.cpp                  |  8 ++++++-
 gjs/deprecation.cpp               | 11 ++++++++-
 gjs/engine.cpp                    | 19 +++++++++------
 gjs/engine.h                      |  3 +--
 gjs/global.cpp                    | 22 ++++++++++++++---
 gjs/global.h                      |  4 +++-
 gjs/importer.cpp                  | 20 ++++++++++++++--
 gjs/importer.h                    |  4 +++-
 gjs/jsapi-class.h                 |  4 +++-
 gjs/jsapi-dynamic-class.cpp       | 14 ++++++++++-
 gjs/jsapi-util-args.h             |  6 ++++-
 gjs/jsapi-util-error.cpp          | 10 +++++++-
 gjs/jsapi-util-root.h             |  5 +++-
 gjs/jsapi-util-string.cpp         | 17 ++++++++++++-
 gjs/jsapi-util.cpp                | 14 ++++++++++-
 gjs/jsapi-util.h                  | 12 +++++++++-
 gjs/jsapi-wrapper.h               | 50 ---------------------------------------
 gjs/module.cpp                    | 14 ++++++++---
 gjs/module.h                      |  4 +++-
 gjs/native.cpp                    |  5 +++-
 gjs/native.h                      |  4 +++-
 gjs/profiler.cpp                  |  4 ++--
 gjs/stack.cpp                     |  5 +++-
 meson.build                       |  8 +++----
 modules/cairo-context.cpp         | 12 +++++++++-
 modules/cairo-gradient.cpp        |  8 ++++++-
 modules/cairo-image-surface.cpp   |  9 ++++++-
 modules/cairo-linear-gradient.cpp |  8 ++++++-
 modules/cairo-module.h            |  4 +++-
 modules/cairo-path.cpp            |  8 ++++++-
 modules/cairo-pattern.cpp         |  9 ++++++-
 modules/cairo-pdf-surface.cpp     |  9 ++++++-
 modules/cairo-private.h           |  4 +++-
 modules/cairo-ps-surface.cpp      |  9 ++++++-
 modules/cairo-radial-gradient.cpp |  8 ++++++-
 modules/cairo-region.cpp          | 11 ++++++++-
 modules/cairo-solid-pattern.cpp   |  9 ++++++-
 modules/cairo-surface-pattern.cpp |  9 ++++++-
 modules/cairo-surface.cpp         | 10 +++++++-
 modules/cairo-svg-surface.cpp     |  9 ++++++-
 modules/cairo.cpp                 |  6 ++++-
 modules/console.cpp               | 21 +++++++++++-----
 modules/console.h                 |  4 +++-
 modules/system.cpp                | 11 +++++++--
 modules/system.h                  |  4 +++-
 test/gjs-test-call-args.cpp       | 18 +++++++++++---
 test/gjs-test-common.cpp          |  8 ++++++-
 test/gjs-test-rooting.cpp         |  9 ++++++-
 test/gjs-test-utils.cpp           |  6 ++++-
 test/gjs-test-utils.h             |  7 +++---
 test/gjs-tests.cpp                |  9 ++++++-
 tools/gjs-private-iwyu.imp        | 30 -----------------------
 96 files changed, 744 insertions(+), 228 deletions(-)
---
diff --git a/doc/CPP_Style_Guide.md b/doc/CPP_Style_Guide.md
index 0fb3be79..5d75c420 100644
--- a/doc/CPP_Style_Guide.md
+++ b/doc/CPP_Style_Guide.md
@@ -410,6 +410,12 @@ about later.
 The tool [IWYU][iwyu] can help with this, but it generates a lot of
 false positives, so we don't automate it.
 
+In many cases, header files with SpiderMonkey types will only need to
+include one SpiderMonkey header, `<js/TypeDecls.h>`, unless they have
+inline functions or SpiderMonkey member types.
+This header file contains a number of forward declarations and nothing
+else.
+
 [iwyu]: https://include-what-you-use.org/
 
 #### Header inclusion order ####
@@ -425,13 +431,10 @@ Headers should be included in the following order:
 
 Each of these groups must be separated by blank lines.
 Within each group, all the headers should be alphabetized.
-The first four groups should use angle brackets for the includes.
+The first five groups should use angle brackets for the includes.
 
-SpiderMonkey headers should in theory also all use angle brackets, but
-currently due to a bug in SpiderMonkey, the GJS header
-`"gjs/jsapi-wrapper.h"` must be included instead of `<jsapi.h>` and
-`<jsfriendapi.h>`, and before any other SpiderMonkey headers.
-So the SpiderMonkey headers should use quotes for the includes.
+Note that the header `<config.h>` must be included before any
+SpiderMonkey headers.
 
 GJS headers should use quotes, _except_ in public header files (any
 header file included from `<gjs/gjs.h>`.)
@@ -463,9 +466,9 @@ Here is an example of all of the above rules together:
 #include <girepository.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/GCHashTable.h"  // for GCHashMap
-#include "mozilla/Unused.h"
+#include <js/GCHashTable.h>  // for GCHashMap
+#include <jsapi.h>           // for JS_New, JSAutoRealm, JS_GetProperty
+#include <mozilla/Unused.h>
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 8919764c..3ccf731b 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <string.h>  // for strcmp, strlen, memcpy
 
 #include <cmath>   // for std::abs
@@ -31,7 +33,17 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CharacterEncoding.h>
+#include <js/Conversions.h>
+#include <js/GCVector.h>            // for RootedVector, MutableWrappedPtrOp...
+#include <js/PropertyDescriptor.h>  // for JSPROP_ENUMERATE
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>        // for JS_ReportOutOfMemory, JS_GetElement
+#include <jsfriendapi.h>  // for JS_IsUint8Array, JS_GetObjectFunc...
+#include <mozilla/Vector.h>
 
 #include "gi/arg.h"
 #include "gi/boxed.h"
diff --git a/gi/arg.h b/gi/arg.h
index e09d440f..ec09d6fd 100644
--- a/gi/arg.h
+++ b/gi/arg.h
@@ -24,13 +24,15 @@
 #ifndef GI_ARG_H_
 #define GI_ARG_H_
 
+#include <config.h>
+
 #include <stddef.h>  // for size_t
 #include <stdint.h>
 
 #include <girepository.h>
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 909cf549..5630e626 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdint.h>
 #include <string.h>  // for memcpy, size_t, strcmp
 
@@ -31,8 +33,16 @@
 #include <girepository.h>
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/GCHashTable.h"  // for GCHashMap
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/GCHashTable.h>  // for GCHashMap
+#include <js/GCVector.h>     // for MutableWrappedPtrOperations
+#include <js/TracingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <jsapi.h>  // for IdVector, JS_AtomizeAndPinJSString
+#include <mozilla/HashTable.h>
+#include <mozilla/Vector.h>
 
 #include "gi/arg.h"
 #include "gi/boxed.h"
diff --git a/gi/boxed.h b/gi/boxed.h
index 5aed8644..9e1312ec 100644
--- a/gi/boxed.h
+++ b/gi/boxed.h
@@ -24,14 +24,18 @@
 #ifndef GI_BOXED_H_
 #define GI_BOXED_H_
 
+#include <config.h>
+
 #include <stdint.h>
 
 #include <girepository.h>
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/GCHashTable.h"  // for GCHashMap
+#include <js/GCHashTable.h>  // for GCHashMap
+#include <js/Id.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
 
 #include "gi/wrapperutils.h"
 #include "gjs/jsapi-util.h"
@@ -40,6 +44,16 @@
 
 class BoxedPrototype;
 class BoxedInstance;
+namespace JS {
+class CallArgs;
+}
+namespace js {
+class SystemAllocPolicy;
+}
+namespace mozilla {
+template <class Key>
+struct DefaultHasher;
+}
 
 /* To conserve memory, we have two different kinds of private data for GBoxed
  * JS wrappers: BoxedInstance, and BoxedPrototype. Both inherit from BoxedBase
diff --git a/gi/closure.cpp b/gi/closure.cpp
index 76f127db..f0793c6b 100644
--- a/gi/closure.cpp
+++ b/gi/closure.cpp
@@ -21,11 +21,15 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <glib.h>
 
 #include <new>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_IsExceptionPending, Call, JS_Get...
 
 #include "gi/closure.h"
 #include "gjs/context-private.h"
diff --git a/gi/closure.h b/gi/closure.h
index fb8a1455..df5fdc9e 100644
--- a/gi/closure.h
+++ b/gi/closure.h
@@ -24,12 +24,18 @@
 #ifndef GI_CLOSURE_H_
 #define GI_CLOSURE_H_
 
+#include <config.h>
+
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
+namespace JS {
+class HandleValueArray;
+}
+
 GJS_USE
 GClosure* gjs_closure_new(JSContext* cx, JSFunction* callable,
                           const char* description, bool root_function);
diff --git a/gi/enumeration.cpp b/gi/enumeration.cpp
index de2a3be4..13b194c1 100644
--- a/gi/enumeration.cpp
+++ b/gi/enumeration.cpp
@@ -21,11 +21,15 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_DefineProperty, JS_NewPlainObject
 
 #include "gi/enumeration.h"
 #include "gi/wrapperutils.h"
diff --git a/gi/enumeration.h b/gi/enumeration.h
index 0115c3eb..4764aed8 100644
--- a/gi/enumeration.h
+++ b/gi/enumeration.h
@@ -24,9 +24,11 @@
 #ifndef GI_ENUMERATION_H_
 #define GI_ENUMERATION_H_
 
+#include <config.h>
+
 #include <girepository.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gi/foreign.cpp b/gi/foreign.cpp
index cb8da5d8..2b7b8041 100644
--- a/gi/foreign.cpp
+++ b/gi/foreign.cpp
@@ -21,12 +21,14 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <string.h>  // for strcmp
 
 #include <girepository.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gi/arg.h"
 #include "gi/foreign.h"
diff --git a/gi/foreign.h b/gi/foreign.h
index fbf6111a..14054310 100644
--- a/gi/foreign.h
+++ b/gi/foreign.h
@@ -24,9 +24,11 @@
 #ifndef GI_FOREIGN_H_
 #define GI_FOREIGN_H_
 
+#include <config.h>
+
 #include <girepository.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gi/arg.h"
 #include "gjs/macros.h"
diff --git a/gi/function.cpp b/gi/function.cpp
index 4b70b71b..340792b1 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdint.h>
 #include <stdlib.h>  // for exit
 #include <string.h>  // for strcmp, memset, size_t
@@ -33,9 +35,19 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/Warnings.h"
-#include "mozilla/Maybe.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/GCVector.h>
+#include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT
+#include <js/PropertySpec.h>
+#include <js/Realm.h>  // for GetRealmFunctionPrototype
+#include <js/RootingAPI.h>
+#include <js/Value.h>
+#include <js/Warnings.h>
+#include <jsapi.h>        // for HandleValueArray, JS_GetElement
+#include <jsfriendapi.h>  // for JS_GetObjectFunction
+#include <jspubtd.h>      // for JSProto_TypeError, JSTYPE_FUNCTION
+#include <mozilla/Maybe.h>
 
 #include "gi/arg.h"
 #include "gi/boxed.h"
diff --git a/gi/function.h b/gi/function.h
index f9b14254..1038f5fb 100644
--- a/gi/function.h
+++ b/gi/function.h
@@ -24,14 +24,20 @@
 #ifndef GI_FUNCTION_H_
 #define GI_FUNCTION_H_
 
+#include <config.h>
+
 #include <ffi.h>
 #include <girepository.h>
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
+namespace JS {
+class HandleValueArray;
+}
+
 typedef enum {
     PARAM_NORMAL,
     PARAM_SKIPPED,
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index 42568498..d667d938 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -22,11 +22,18 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/GCHashTable.h"  // for WeakCache
+#include <js/AllocPolicy.h>  // for SystemAllocPolicy
+#include <js/Class.h>
+#include <js/GCHashTable.h>  // for WeakCache
+#include <js/TracingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for InformalValueTypeName, JS_GetClass
+#include <mozilla/HashTable.h>
 
 #include "gi/arg.h"
 #include "gi/function.h"
@@ -39,6 +46,10 @@
 #include "gjs/mem-private.h"
 #include "util/log.h"
 
+namespace JS {
+class CallArgs;
+}
+
 FundamentalInstance::FundamentalInstance(JSContext* cx, JS::HandleObject obj)
     : GIWrapperInstance(cx, obj) {
     GJS_INC_COUNTER(fundamental_instance);
diff --git a/gi/fundamental.h b/gi/fundamental.h
index 9756aaf2..00c38225 100644
--- a/gi/fundamental.h
+++ b/gi/fundamental.h
@@ -25,10 +25,14 @@
 #ifndef GI_FUNDAMENTAL_H_
 #define GI_FUNDAMENTAL_H_
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/Id.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
 
 #include "gi/wrapperutils.h"
 #include "gjs/macros.h"
@@ -36,6 +40,10 @@
 
 class FundamentalPrototype;
 class FundamentalInstance;
+namespace JS {
+class CallArgs;
+class HandleValueArray;
+}  // namespace JS
 
 /* To conserve memory, we have two different kinds of private data for JS
  * wrappers for fundamental types: FundamentalInstance, and
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index d538d45d..66341b7d 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -21,13 +21,22 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdint.h>
 
 #include <girepository.h>
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/SavedFrameAPI.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/PropertyDescriptor.h>  // for JSPROP_ENUMERATE
+#include <js/RootingAPI.h>
+#include <js/SavedFrameAPI.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>    // for JS_DefinePropertyById, JS_GetProp...
+#include <jspubtd.h>  // for JSProtoKey, JSProto_Error, JSProt...
 
 #include "gi/boxed.h"
 #include "gi/enumeration.h"
diff --git a/gi/gerror.h b/gi/gerror.h
index 730f864a..4f616c5a 100644
--- a/gi/gerror.h
+++ b/gi/gerror.h
@@ -24,11 +24,14 @@
 #ifndef GI_GERROR_H_
 #define GI_GERROR_H_
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/PropertySpec.h>
+#include <js/TypeDecls.h>
 
 #include "gi/wrapperutils.h"
 #include "gjs/macros.h"
@@ -36,6 +39,9 @@
 
 class ErrorPrototype;
 class ErrorInstance;
+namespace JS {
+class CallArgs;
+}
 
 /* To conserve memory, we have two different kinds of private data for GError
  * JS wrappers: ErrorInstance, and ErrorPrototype. Both inherit from ErrorBase
diff --git a/gi/gobject.cpp b/gi/gobject.cpp
index 9f82b30c..bc51662d 100644
--- a/gi/gobject.cpp
+++ b/gi/gobject.cpp
@@ -21,13 +21,18 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <unordered_map>
 #include <utility>  // for move, pair
 
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <jsapi.h>  // for JS_New, JSAutoRealm, JS_GetProperty
 
 #include "gi/gobject.h"
 #include "gi/object.h"
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index 948f2505..e9649559 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -22,11 +22,21 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/GCHashTable.h"  // for WeakCache
+#include <js/AllocPolicy.h>  // for SystemAllocPolicy
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/GCHashTable.h>         // for WeakCache
+#include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_GetPropertyById, JS_AtomizeString
+#include <mozilla/HashTable.h>
 
 #include "gi/gtype.h"
 #include "gjs/atoms.h"
diff --git a/gi/gtype.h b/gi/gtype.h
index cbe6278d..ceb1b94b 100644
--- a/gi/gtype.h
+++ b/gi/gtype.h
@@ -25,9 +25,11 @@
 #ifndef GI_GTYPE_H_
 #define GI_GTYPE_H_
 
+#include <config.h>
+
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gi/interface.cpp b/gi/interface.cpp
index 57a0537b..7ad150ec 100644
--- a/gi/interface.cpp
+++ b/gi/interface.cpp
@@ -22,9 +22,12 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <girepository.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/Class.h>
+#include <js/TypeDecls.h>
 
 #include "gi/function.h"
 #include "gi/interface.h"
diff --git a/gi/interface.h b/gi/interface.h
index c67dcc3a..a5993666 100644
--- a/gi/interface.h
+++ b/gi/interface.h
@@ -25,11 +25,15 @@
 #ifndef GI_INTERFACE_H_
 #define GI_INTERFACE_H_
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/PropertySpec.h>
+#include <js/TypeDecls.h>
 
 #include "gi/wrapperutils.h"
 #include "gjs/jsapi-util.h"
diff --git a/gi/ns.cpp b/gi/ns.cpp
index bb4aea71..7b692a57 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -21,10 +21,19 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/Id.h>  // for JSID_IS_STRING
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <jsapi.h>       // for JS_GetPrivate, JS_NewObjectWithGivenProto
 
 #include "gi/ns.h"
 #include "gi/repo.h"
diff --git a/gi/object.cpp b/gi/object.cpp
index 7e5c5ce2..7e49d269 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -22,6 +22,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <string.h>  // for memset, strcmp
 
 #include <algorithm>   // for move, find
@@ -36,7 +38,21 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/CharacterEncoding.h>
+#include <js/Class.h>
+#include <js/GCAPI.h>               // for JS_AddWeakPointerCompartmentCallback
+#include <js/GCVector.h>            // for MutableWrappedPtrOperations
+#include <js/MemoryFunctions.h>     // for AddAssociatedMemory, RemoveAssoci...
+#include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT, JSPROP_READONLY
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <js/Warnings.h>
+#include <jsapi.h>        // for JS_ReportOutOfMemory, IsCallable
+#include <jsfriendapi.h>  // for JS_GetObjectFunction, IsFunctionO...
+#include <mozilla/HashTable.h>
+#include <mozilla/Vector.h>
 
 #include "gi/arg.h"
 #include "gi/closure.h"
diff --git a/gi/object.h b/gi/object.h
index 3108a3bb..80b4c083 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -24,6 +24,8 @@
 #ifndef GI_OBJECT_H_
 #define GI_OBJECT_H_
 
+#include <config.h>
+
 #include <stddef.h>  // for size_t
 
 #include <forward_list>
@@ -34,8 +36,9 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/GCHashTable.h"  // for GCHashMap
+#include <js/GCHashTable.h>  // for GCHashMap
+#include <js/PropertySpec.h>
+#include <js/TypeDecls.h>
 
 #include "gi/wrapperutils.h"
 #include "gjs/jsapi-util-root.h"
@@ -44,6 +47,16 @@
 #include "util/log.h"
 
 class GjsAtoms;
+namespace JS {
+class CallArgs;
+}
+namespace js {
+class SystemAllocPolicy;
+}
+namespace mozilla {
+template <class Key>
+struct DefaultHasher;
+}
 class ObjectInstance;
 class ObjectPrototype;
 
diff --git a/gi/param.cpp b/gi/param.cpp
index ccf66039..b00bbbbf 100644
--- a/gi/param.cpp
+++ b/gi/param.cpp
@@ -21,10 +21,18 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <jsapi.h>       // for JS_GetClass, JS_GetPropertyById
+#include <jspubtd.h>     // for JSProto_TypeError
 
 #include "gi/function.h"
 #include "gi/param.h"
diff --git a/gi/param.h b/gi/param.h
index b2e205e2..4ee2df85 100644
--- a/gi/param.h
+++ b/gi/param.h
@@ -24,9 +24,11 @@
 #ifndef GI_PARAM_H_
 #define GI_PARAM_H_
 
+#include <config.h>
+
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gi/private.cpp b/gi/private.cpp
index 4e0c38f3..c5ce908d 100644
--- a/gi/private.cpp
+++ b/gi/private.cpp
@@ -22,12 +22,19 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdint.h>
 
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Id.h>  // for JSID_TO_SYMBOL
+#include <js/PropertySpec.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <jsapi.h>       // for JS_GetArrayLength, JS_GetElement
 
 #include "gi/gobject.h"
 #include "gi/gtype.h"
diff --git a/gi/private.h b/gi/private.h
index 26cbadd6..edc0e359 100644
--- a/gi/private.h
+++ b/gi/private.h
@@ -24,7 +24,9 @@
 #ifndef GI_PRIVATE_H_
 #define GI_PRIVATE_H_
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 4c83e926..08df95e1 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdint.h>
 #include <string.h>  // for strlen
 
@@ -28,8 +30,15 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/Warnings.h"
+#include <js/Class.h>
+#include <js/Id.h>                  // for JSID_IS_STRING, JSID_VOID
+#include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT, JSPROP_RESOLVING
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <js/Warnings.h>
+#include <jsapi.h>  // for JS_DefinePropertyById, JS_GetProp...
 
 #include "gi/arg.h"
 #include "gi/boxed.h"
@@ -51,6 +60,9 @@
 #include "gjs/mem-private.h"
 #include "util/log.h"
 
+struct JSFunctionSpec;
+struct JSPropertySpec;
+
 typedef struct {
     void *dummy;
 
diff --git a/gi/repo.h b/gi/repo.h
index b4a09da0..409f2778 100644
--- a/gi/repo.h
+++ b/gi/repo.h
@@ -24,9 +24,11 @@
 #ifndef GI_REPO_H_
 #define GI_REPO_H_
 
+#include <config.h>
+
 #include <girepository.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 #include "util/log.h"
diff --git a/gi/union.cpp b/gi/union.cpp
index 3e8ab58e..a58e90e9 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -21,10 +21,17 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <girepository.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/Warnings.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <js/Warnings.h>
+#include <jsapi.h>  // for HandleValueArray
 
 #include "gi/function.h"
 #include "gi/repo.h"
diff --git a/gi/union.h b/gi/union.h
index ed97d819..3d2249f2 100644
--- a/gi/union.h
+++ b/gi/union.h
@@ -24,15 +24,21 @@
 #ifndef GI_UNION_H_
 #define GI_UNION_H_
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gi/wrapperutils.h"
 #include "gjs/macros.h"
 #include "util/log.h"
 
+namespace JS {
+class CallArgs;
+}
+struct JSClassOps;
 class UnionPrototype;
 class UnionInstance;
 
diff --git a/gi/value.cpp b/gi/value.cpp
index e680d36a..8059d0b6 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <limits.h>  // for SCHAR_MAX, SCHAR_MIN, UCHAR_MAX
 #include <stdint.h>
 #include <string.h>  // for memset
@@ -29,8 +31,15 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "mozilla/Unused.h"
+#include <js/CharacterEncoding.h>
+#include <js/Conversions.h>
+#include <js/GCVector.h>  // for RootedVector
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>  // for InformalValueTypeName, JS_ClearPendingException
+#include <mozilla/Unused.h>
 
 #include "gi/arg.h"
 #include "gi/boxed.h"
diff --git a/gi/value.h b/gi/value.h
index d929c9e3..4c39184c 100644
--- a/gi/value.h
+++ b/gi/value.h
@@ -24,9 +24,11 @@
 #ifndef GI_VALUE_H_
 #define GI_VALUE_H_
 
+#include <config.h>
+
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gi/wrapperutils.cpp b/gi/wrapperutils.cpp
index b5428c17..50238fef 100644
--- a/gi/wrapperutils.cpp
+++ b/gi/wrapperutils.cpp
@@ -21,10 +21,14 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <girepository.h>
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_DefinePropertyById
 
 #include "gi/function.h"
 #include "gi/gtype.h"
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index 67bb576f..1c3252ef 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -25,6 +25,8 @@
 #ifndef GI_WRAPPERUTILS_H_
 #define GI_WRAPPERUTILS_H_
 
+#include <config.h>
+
 #include <stdint.h>
 
 #include <new>
@@ -34,8 +36,13 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/MemoryFunctions.h"
+#include <js/CallArgs.h>
+#include <js/MemoryFunctions.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <jsapi.h>       // for JS_GetPrivate, JS_SetPrivate, JS_Ge...
+#include <jspubtd.h>     // for JSProto_TypeError
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
@@ -44,6 +51,9 @@
 #include "gjs/macros.h"
 #include "util/log.h"
 
+struct JSFunctionSpec;
+struct JSPropertySpec;
+
 GJS_JSAPI_RETURN_CONVENTION
 bool gjs_wrapper_to_string_func(JSContext* cx, JSObject* this_obj,
                                 const char* objtype, GIBaseInfo* info,
diff --git a/gjs/atoms.cpp b/gjs/atoms.cpp
index 699a8908..b63a1343 100644
--- a/gjs/atoms.cpp
+++ b/gjs/atoms.cpp
@@ -24,7 +24,12 @@
 
 #define GJS_USE_ATOM_FOREACH
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/Symbol.h>
+#include <js/TracingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_AtomizeAndPinString
 
 #include "gjs/atoms.h"
 
diff --git a/gjs/atoms.h b/gjs/atoms.h
index 77cc6226..2395e4af 100644
--- a/gjs/atoms.h
+++ b/gjs/atoms.h
@@ -25,7 +25,11 @@
 #ifndef GJS_ATOMS_H_
 #define GJS_ATOMS_H_
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/Id.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 0df16999..0d0240b7 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdint.h>
 #include <string.h>  // for strcmp, memchr, strlen
 
@@ -28,8 +30,15 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/ArrayBuffer.h"
+#include <js/ArrayBuffer.h>
+#include <js/CallArgs.h>
+#include <js/GCAPI.h>  // for AutoCheckCannotGC
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>   // for UniqueChars
+#include <jsapi.h>        // for JS_DefineFunctionById, JS_DefineFun...
+#include <jsfriendapi.h>  // for JS_NewUint8ArrayWithBuffer, GetUint...
 
 #include "gi/boxed.h"
 #include "gjs/atoms.h"
diff --git a/gjs/byteArray.h b/gjs/byteArray.h
index e9899748..407cd4fd 100644
--- a/gjs/byteArray.h
+++ b/gjs/byteArray.h
@@ -24,11 +24,13 @@
 #ifndef GJS_BYTEARRAY_H_
 #define GJS_BYTEARRAY_H_
 
+#include <config.h>
+
 #include <stddef.h>  // for size_t
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gjs/context-private.h b/gjs/context-private.h
index 5cbf3ade..f9c8bd30 100644
--- a/gjs/context-private.h
+++ b/gjs/context-private.h
@@ -24,6 +24,8 @@
 #ifndef GJS_CONTEXT_PRIVATE_H_
 #define GJS_CONTEXT_PRIVATE_H_
 
+#include <config.h>
+
 #include <stdint.h>
 #include <sys/types.h>  // for ssize_t
 
@@ -33,9 +35,12 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/GCHashTable.h"
-#include "js/Promise.h"
+#include <js/GCHashTable.h>
+#include <js/GCVector.h>
+#include <js/Promise.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>        // for JS_GetContextPrivate
+#include <jsfriendapi.h>  // for ScriptEnvironmentPreparer
 
 #include "gjs/atoms.h"
 #include "gjs/context.h"
diff --git a/gjs/context.cpp b/gjs/context.cpp
index b5bdd157..32dfb81c 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -50,11 +50,26 @@
 #include <windows.h>
 #endif
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/CompilationAndEvaluation.h"
-#include "js/GCHashTable.h"  // for WeakCache
-#include "js/SourceText.h"
-#include "js/experimental/SourceHook.h"
+#include <js/AllocPolicy.h>  // for SystemAllocPolicy
+#include <js/CallArgs.h>     // for UndefinedHandleValue
+#include <js/CompilationAndEvaluation.h>
+#include <js/CompileOptions.h>
+#include <js/GCAPI.h>               // for JS_GC, JS_AddExtraGCRootsTr...
+#include <js/GCHashTable.h>         // for WeakCache
+#include <js/GCVector.h>            // for RootedVector
+#include <js/Promise.h>             // for JobQueue::SavedJobQueue
+#include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT, JSPROP_RE...
+#include <js/RootingAPI.h>
+#include <js/SourceText.h>
+#include <js/TracingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/UniquePtr.h>
+#include <js/Utility.h>  // for DeletePolicy
+#include <js/Value.h>
+#include <jsapi.h>        // for JS_IsExceptionPending, ...
+#include <jsfriendapi.h>  // for DumpHeap, IgnoreNurseryObjects
+#include <mozilla/UniquePtr.h>
+#include <mozilla/Vector.h>
 
 #include "gi/object.h"
 #include "gi/private.h"
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index f1e93781..cbeeafcb 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -23,6 +23,8 @@
  * Authored By: Sam Spilsbury <sam endlessm com>
  */
 
+#include <config.h>
+
 #include <stdlib.h>  // for free, size_t
 #include <string.h>  // for strcmp, strlen
 
@@ -31,7 +33,13 @@
 #include <gio/gio.h>
 #include <glib-object.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/GCAPI.h>  // for JS_AddExtraGCRootsTracer, JS_Remove...
+#include <js/RootingAPI.h>
+#include <js/TracingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <jsapi.h>        // for JSAutoRealm, JS_SetPropertyById
+#include <jsfriendapi.h>  // for GetCodeCoverageSummary
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
diff --git a/gjs/debugger.cpp b/gjs/debugger.cpp
index 66478a73..682ce73d 100644
--- a/gjs/debugger.cpp
+++ b/gjs/debugger.cpp
@@ -43,7 +43,13 @@
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>  // for JS_DefineFunctions, JS_NewStringCopyZ
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
diff --git a/gjs/deprecation.cpp b/gjs/deprecation.cpp
index d2a5caef..4798d6d3 100644
--- a/gjs/deprecation.cpp
+++ b/gjs/deprecation.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cstddef>        // for size_t
 #include <string>         // for string
 #include <unordered_set>  // for unordered_set
@@ -28,7 +30,14 @@
 
 #include <glib.h>  // for g_warning
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CharacterEncoding.h>
+#include <js/Conversions.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>        // for MaxFrames, CaptureCurrentStack
+#include <jsfriendapi.h>  // for FormatStackDump
 
 #include "gjs/deprecation.h"
 #include "gjs/macros.h"
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index bf7dab73..9592b2c5 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdint.h>
 
 #ifdef _WIN32
@@ -33,13 +35,16 @@
 #include <gio/gio.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/ContextOptions.h"
-#include "js/Initialization.h"  // for JS_Init, JS_ShutDown
-#include "js/Promise.h"
-#include "js/Warnings.h"
-#include "js/experimental/SourceHook.h"
-#include "mozilla/UniquePtr.h"
+#include <js/ContextOptions.h>
+#include <js/GCAPI.h>           // for JS_SetGCParameter, JS_AddFin...
+#include <js/Initialization.h>  // for JS_Init, JS_ShutDown
+#include <js/Promise.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Warnings.h>
+#include <js/experimental/SourceHook.h>
+#include <jsapi.h>  // for InitSelfHostedCode, JS_Destr...
+#include <mozilla/UniquePtr.h>
 
 #include "gi/object.h"
 #include "gjs/context-private.h"
diff --git a/gjs/engine.h b/gjs/engine.h
index c6ec5794..953dbab0 100644
--- a/gjs/engine.h
+++ b/gjs/engine.h
@@ -26,9 +26,8 @@
 
 #include <stddef.h>  // for size_t
 
-#include "gjs/jsapi-wrapper.h"
-
 class GjsContextPrivate;
+struct JSContext;
 
 JSContext* gjs_create_js_context(GjsContextPrivate* uninitialized_gjs);
 
diff --git a/gjs/global.cpp b/gjs/global.cpp
index 8415612a..8b4a80cd 100644
--- a/gjs/global.cpp
+++ b/gjs/global.cpp
@@ -23,13 +23,25 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stddef.h>  // for size_t
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/CompilationAndEvaluation.h"
-#include "js/SourceText.h"
+#include <js/CallArgs.h>
+#include <js/CharacterEncoding.h>
+#include <js/Class.h>
+#include <js/CompilationAndEvaluation.h>
+#include <js/CompileOptions.h>
+#include <js/Conversions.h>
+#include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT, JSPROP_RE...
+#include <js/PropertySpec.h>
+#include <js/RealmOptions.h>
+#include <js/SourceText.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <jsapi.h>       // for AutoSaveExceptionState, ...
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
@@ -37,6 +49,10 @@
 #include "gjs/global.h"
 #include "gjs/jsapi-util.h"
 
+namespace mozilla {
+union Utf8Unit;
+}
+
 GJS_JSAPI_RETURN_CONVENTION
 static bool
 run_bootstrap(JSContext       *cx,
diff --git a/gjs/global.h b/gjs/global.h
index 287d0290..29f528df 100644
--- a/gjs/global.h
+++ b/gjs/global.h
@@ -24,7 +24,9 @@
 #ifndef GJS_GLOBAL_H_
 #define GJS_GLOBAL_H_
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 5d39636f..802e22d3 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <string.h>  // for size_t, strcmp, strlen
 
 #ifdef _WIN32
@@ -36,8 +38,22 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "mozilla/UniquePtr.h"
+#include <js/CallArgs.h>
+#include <js/CharacterEncoding.h>
+#include <js/Class.h>
+#include <js/GCVector.h>  // for MutableWrappedPtrOperations
+#include <js/Id.h>        // for PropertyKey, JSID_IS_STRING
+#include <js/PropertyDescriptor.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/Symbol.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>    // for JS_DefinePropertyById, JS_DefineP...
+#include <jspubtd.h>  // for JSProto_Error
+#include <mozilla/UniquePtr.h>
+#include <mozilla/Vector.h>
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
diff --git a/gjs/importer.h b/gjs/importer.h
index c178bb83..a0ce8f48 100644
--- a/gjs/importer.h
+++ b/gjs/importer.h
@@ -24,7 +24,9 @@
 #ifndef GJS_IMPORTER_H_
 #define GJS_IMPORTER_H_
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gjs/jsapi-class.h b/gjs/jsapi-class.h
index a752cefe..17ab8fbb 100644
--- a/gjs/jsapi-class.h
+++ b/gjs/jsapi-class.h
@@ -24,10 +24,12 @@
 #ifndef GJS_JSAPI_CLASS_H_
 #define GJS_JSAPI_CLASS_H_
 
+#include <config.h>
+
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gi/wrapperutils.h"  // IWYU pragma: keep
 #include "gjs/global.h"       // IWYU pragma: keep
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index 59addd14..87a9fbb6 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -22,11 +22,23 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <string.h>  // for strlen
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>  // for JSNative
+#include <js/Class.h>
+#include <js/PropertyDescriptor.h>  // for JSPROP_RESOLVING, JSPROP_GETTER
+#include <js/PropertySpec.h>
+#include <js/Realm.h>  // for GetRealmObjectPrototype
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <jsapi.h>        // for JS_DefineFunctions, JS_DefineProp...
+#include <jsfriendapi.h>  // for GetFunctionNativeReserved, NewFun...
+#include <jspubtd.h>      // for JSProto_TypeError
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
diff --git a/gjs/jsapi-util-args.h b/gjs/jsapi-util-args.h
index f659d119..33bcfef6 100644
--- a/gjs/jsapi-util-args.h
+++ b/gjs/jsapi-util-args.h
@@ -26,6 +26,8 @@
 #ifndef GJS_JSAPI_UTIL_ARGS_H_
 #define GJS_JSAPI_UTIL_ARGS_H_
 
+#include <config.h>
+
 #include <stdint.h>
 
 #include <type_traits>  // for enable_if, is_enum, is_same
@@ -33,7 +35,9 @@
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Conversions.h>
+#include <js/TypeDecls.h>
 
 #include "gjs/jsapi-util.h"
 #include "gjs/macros.h"
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index 55d9f466..509e3c92 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -21,11 +21,19 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdarg.h>
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CharacterEncoding.h>
+#include <js/ErrorReport.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <jsapi.h>       // for JS_ReportErrorUTF8, BuildStackString
+#include <jspubtd.h>     // for JSProtoKey, JSProto_Error, JSProto...
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index ccb05600..fb08d012 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -25,6 +25,8 @@
 #ifndef GJS_JSAPI_UTIL_ROOT_H_
 #define GJS_JSAPI_UTIL_ROOT_H_
 
+#include <config.h>
+
 #include <stdint.h>  // for uintptr_t
 
 #include <cstddef>  // for nullptr_t
@@ -35,7 +37,8 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TracingAPI.h>
+#include <js/TypeDecls.h>
 
 #include "gjs/context-private.h"
 #include "gjs/context.h"
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index 70967b04..5c6d9e56 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdint.h>
 #include <string.h>     // for size_t, strlen
 #include <sys/types.h>  // for ssize_t
@@ -32,11 +34,24 @@
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CharacterEncoding.h>
+#include <js/Class.h>
+#include <js/GCAPI.h>  // for AutoCheckCannotGC
+#include <js/Id.h>     // for JSID_IS_STRING, INTERNED_STRING_TO...
+#include <js/RootingAPI.h>
+#include <js/Symbol.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>        // for JSID_TO_FLAT_STRING, JS_GetTwoByte...
+#include <jsfriendapi.h>  // for FlatStringToLinearString, GetLatin...
 
 #include "gjs/jsapi-util.h"
 #include "gjs/macros.h"
 
+class JSFlatString;
+class JSLinearString;
+
 char* gjs_hyphen_to_underscore(const char* str) {
     char *s = g_strdup(str);
     char *retval = s;
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 161ee4a3..c270dd71 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -22,6 +22,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stdio.h>   // for sscanf
 #include <string.h>  // for strlen
 
@@ -34,7 +36,17 @@
 #include <locale>   // for wstring_convert
 #include <utility>  // for move
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/CharacterEncoding.h>
+#include <js/Class.h>
+#include <js/Conversions.h>
+#include <js/GCAPI.h>     // for JS_MaybeGC, NonIncrementalGC, GCRe...
+#include <js/GCVector.h>  // for RootedVector
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <jsapi.h>        // for JS_GetPropertyById, JS_ClearPendin...
+#include <jsfriendapi.h>  // for ProtoKeyToClass
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
diff --git a/gjs/jsapi-util.h b/gjs/jsapi-util.h
index 45d0c945..65d71e73 100644
--- a/gjs/jsapi-util.h
+++ b/gjs/jsapi-util.h
@@ -24,6 +24,8 @@
 #ifndef GJS_JSAPI_UTIL_H_
 #define GJS_JSAPI_UTIL_H_
 
+#include <config.h>
+
 #include <stddef.h>  // for size_t
 #include <stdint.h>
 #include <sys/types.h>  // for ssize_t
@@ -35,10 +37,18 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/GCPolicyAPI.h>  // for IgnoreGCPolicy
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <jspubtd.h>     // for JSProtoKey
 
 #include "gjs/macros.h"
 
+class JSErrorReport;
+namespace JS {
+class CallArgs;
+}
+
 struct GjsAutoTakeOwnership {};
 
 template <typename T, typename F,
diff --git a/gjs/module.cpp b/gjs/module.cpp
index 58b51df3..88aff86c 100644
--- a/gjs/module.cpp
+++ b/gjs/module.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <stddef.h>     // for size_t
 #include <sys/types.h>  // for ssize_t
 
@@ -29,9 +31,15 @@
 #include <gio/gio.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/CompilationAndEvaluation.h"
-#include "js/SourceText.h"
+#include <js/Class.h>
+#include <js/CompilationAndEvaluation.h>
+#include <js/CompileOptions.h>
+#include <js/GCVector.h>  // for RootedVector
+#include <js/PropertyDescriptor.h>
+#include <js/RootingAPI.h>
+#include <js/SourceText.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_DefinePropertyById, ...
 
 #include "gjs/context-private.h"
 #include "gjs/jsapi-util.h"
diff --git a/gjs/module.h b/gjs/module.h
index 7952fead..c63d6852 100644
--- a/gjs/module.h
+++ b/gjs/module.h
@@ -24,9 +24,11 @@
 #ifndef GJS_MODULE_H_
 #define GJS_MODULE_H_
 
+#include <config.h>
+
 #include <gio/gio.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gjs/native.cpp b/gjs/native.cpp
index d42e2480..c0fd1a35 100644
--- a/gjs/native.cpp
+++ b/gjs/native.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <string>
 #include <tuple>  // for tie
 #include <unordered_map>
@@ -28,7 +30,8 @@
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
 
 #include "gjs/jsapi-util.h"
 #include "gjs/native.h"
diff --git a/gjs/native.h b/gjs/native.h
index f1c68227..cfc0974b 100644
--- a/gjs/native.h
+++ b/gjs/native.h
@@ -24,7 +24,9 @@
 #ifndef GJS_NATIVE_H_
 #define GJS_NATIVE_H_
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp
index f3661dd2..a0e645be 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -53,8 +53,8 @@
 #    include <sysprof-capture.h>
 #endif
 
-#include "gjs/jsapi-wrapper.h"  // IWYU pragma: keep
-#include "js/ProfilingStack.h"  // for EnableContextProfilingStack, ...
+#include <js/ProfilingStack.h>  // for EnableContextProfilingStack, ...
+#include <js/TypeDecls.h>
 
 #include "gjs/context.h"
 #include "gjs/jsapi-util.h"
diff --git a/gjs/stack.cpp b/gjs/stack.cpp
index b9684930..c3137411 100644
--- a/gjs/stack.cpp
+++ b/gjs/stack.cpp
@@ -40,12 +40,15 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include <config.h>
+
 #include <stdio.h>  // for stderr
 
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
+#include <jsfriendapi.h>  // for DumpBacktrace
 
 #include "gjs/context.h"
 
diff --git a/meson.build b/meson.build
index faac0174..f6e6b6bd 100644
--- a/meson.build
+++ b/meson.build
@@ -201,8 +201,7 @@ nondebug_spidermonkey = cxx.compiles('''
     name: 'SpiderMonkey is a non-debug build')
 
 if not nondebug_spidermonkey
-    debug_arg = ['-DDEBUG=1']  # for compile tests
-    add_project_arguments('-DDEBUG=1', language: 'cpp')
+    debug_arg = ['-DDEBUG']  # for compile tests
 endif
 
 if get_option('buildtype').startswith('release') and not nondebug_spidermonkey
@@ -270,7 +269,9 @@ header_conf.set('ENABLE_CAIRO', build_cairo,
     description: 'Build with Cairo support')
 header_conf.set('ENABLE_PROFILER', build_profiler,
     description: 'Build the profiler')
-header_conf.set('HAVE_DEBUG_SPIDERMONKEY', not nondebug_spidermonkey,
+# COMPAT: SpiderMonkey headers in some places use DEBUG instead of JS_DEBUG
+# https://bugzilla.mozilla.org/show_bug.cgi?id=1261161 */
+header_conf.set('DEBUG', not nondebug_spidermonkey,
     description: 'SpiderMonkey was compiled with --enable-debug')
 header_conf.set('HAVE_DTRACE', get_option('dtrace'),
     description: 'Using dtrace probes')
@@ -405,7 +406,6 @@ libgjs_jsapi_sources = [
     'gjs/jsapi-util-root.h',
     'gjs/jsapi-util-string.cpp',
     'gjs/jsapi-util.cpp', 'gjs/jsapi-util.h',
-    'gjs/jsapi-wrapper.h',
     'util/log.cpp', 'util/log.h',
     'util/misc.cpp', 'util/misc.h',
 ]
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index 4a8008cf..f82acc9f 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -20,6 +20,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <vector>
 
 #include <cairo-gobject.h>
@@ -27,7 +29,15 @@
 #include <girepository.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/Conversions.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>  // for JS_SetElement, JS_NewArrayObject
 
 #include "gi/arg.h"
 #include "gi/foreign.h"
diff --git a/modules/cairo-gradient.cpp b/modules/cairo-gradient.cpp
index 05c086d5..183725ff 100644
--- a/modules/cairo-gradient.cpp
+++ b/modules/cairo-gradient.cpp
@@ -20,9 +20,15 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
diff --git a/modules/cairo-image-surface.cpp b/modules/cairo-image-surface.cpp
index 590f2df9..da7655aa 100644
--- a/modules/cairo-image-surface.cpp
+++ b/modules/cairo-image-surface.cpp
@@ -20,10 +20,17 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_NewObjectWithGivenProto
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
diff --git a/modules/cairo-linear-gradient.cpp b/modules/cairo-linear-gradient.cpp
index 2fca7e3f..3bb62ade 100644
--- a/modules/cairo-linear-gradient.cpp
+++ b/modules/cairo-linear-gradient.cpp
@@ -20,10 +20,16 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_NewObjectWithGivenProto
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
diff --git a/modules/cairo-module.h b/modules/cairo-module.h
index 36944a0e..eecbd94b 100644
--- a/modules/cairo-module.h
+++ b/modules/cairo-module.h
@@ -23,7 +23,9 @@
 #ifndef MODULES_CAIRO_MODULE_H_
 #define MODULES_CAIRO_MODULE_H_
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/modules/cairo-path.cpp b/modules/cairo-path.cpp
index 13079c1e..5329d219 100644
--- a/modules/cairo-path.cpp
+++ b/modules/cairo-path.cpp
@@ -20,10 +20,16 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_GetClass, JS_GetInstancePrivate
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util.h"
diff --git a/modules/cairo-pattern.cpp b/modules/cairo-pattern.cpp
index 14e93ef8..84ffe184 100644
--- a/modules/cairo-pattern.cpp
+++ b/modules/cairo-pattern.cpp
@@ -20,11 +20,18 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo-gobject.h>
 #include <cairo.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_GetPrivate, JS_GetClass, ...
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util.h"
diff --git a/modules/cairo-pdf-surface.cpp b/modules/cairo-pdf-surface.cpp
index d1862f0a..683391a8 100644
--- a/modules/cairo-pdf-surface.cpp
+++ b/modules/cairo-pdf-surface.cpp
@@ -20,10 +20,12 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo-features.h>  // for CAIRO_HAS_PDF_SURFACE
 #include <cairo.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/jsapi-util.h"
 
@@ -31,6 +33,11 @@
 #    include <cairo-pdf.h>
 #    include <glib.h>
 
+#    include <js/Class.h>
+#    include <js/PropertySpec.h>
+#    include <js/RootingAPI.h>
+#    include <jsapi.h>  // for JS_NewObjectWithGivenProto
+
 #    include "gjs/jsapi-class.h"
 #    include "gjs/jsapi-util-args.h"
 #    include "gjs/macros.h"
diff --git a/modules/cairo-private.h b/modules/cairo-private.h
index 29083901..98850e1a 100644
--- a/modules/cairo-private.h
+++ b/modules/cairo-private.h
@@ -23,10 +23,12 @@
 #ifndef MODULES_CAIRO_PRIVATE_H_
 #define MODULES_CAIRO_PRIVATE_H_
 
+#include <config.h>
+
 #include <cairo-features.h>  // for CAIRO_HAS_PDF_SURFACE, CAIRO_HAS_PS_SURFACE
 #include <cairo.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/modules/cairo-ps-surface.cpp b/modules/cairo-ps-surface.cpp
index 2d6186fc..6eb3a502 100644
--- a/modules/cairo-ps-surface.cpp
+++ b/modules/cairo-ps-surface.cpp
@@ -20,10 +20,12 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo-features.h>  // for CAIRO_HAS_PS_SURFACE
 #include <cairo.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/jsapi-util.h"
 
@@ -31,6 +33,11 @@
 #    include <cairo-ps.h>
 #    include <glib.h>
 
+#    include <js/Class.h>
+#    include <js/PropertySpec.h>
+#    include <js/RootingAPI.h>
+#    include <jsapi.h>  // for JS_NewObjectWithGivenProto
+
 #    include "gjs/jsapi-class.h"
 #    include "gjs/jsapi-util-args.h"
 #    include "gjs/macros.h"
diff --git a/modules/cairo-radial-gradient.cpp b/modules/cairo-radial-gradient.cpp
index 289508cf..328302de 100644
--- a/modules/cairo-radial-gradient.cpp
+++ b/modules/cairo-radial-gradient.cpp
@@ -20,10 +20,16 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_NewObjectWithGivenProto
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
diff --git a/modules/cairo-region.cpp b/modules/cairo-region.cpp
index 723c0ef0..feec8a0f 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -20,12 +20,21 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo-gobject.h>
 #include <cairo.h>
 #include <girepository.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/Conversions.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <jsapi.h>  // for JS_GetPropertyById, JS_SetPropert...
 
 #include "gi/arg.h"
 #include "gi/foreign.h"
diff --git a/modules/cairo-solid-pattern.cpp b/modules/cairo-solid-pattern.cpp
index 4d3ec524..a9856431 100644
--- a/modules/cairo-solid-pattern.cpp
+++ b/modules/cairo-solid-pattern.cpp
@@ -20,10 +20,17 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_NewObjectWithGivenProto
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
diff --git a/modules/cairo-surface-pattern.cpp b/modules/cairo-surface-pattern.cpp
index d8dc7e2f..35a1d119 100644
--- a/modules/cairo-surface-pattern.cpp
+++ b/modules/cairo-surface-pattern.cpp
@@ -20,10 +20,17 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_NewObjectWithGivenProto
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
diff --git a/modules/cairo-surface.cpp b/modules/cairo-surface.cpp
index 4d39c74c..1a7e14bf 100644
--- a/modules/cairo-surface.cpp
+++ b/modules/cairo-surface.cpp
@@ -20,12 +20,20 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo-gobject.h>
 #include <cairo.h>
 #include <girepository.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CallArgs.h>
+#include <js/Class.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <jsapi.h>  // for JS_GetPrivate, JS_GetClass, ...
 
 #include "gi/arg.h"
 #include "gi/foreign.h"
diff --git a/modules/cairo-svg-surface.cpp b/modules/cairo-svg-surface.cpp
index 80937faf..0c6b2538 100644
--- a/modules/cairo-svg-surface.cpp
+++ b/modules/cairo-svg-surface.cpp
@@ -20,10 +20,12 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo-features.h>  // for CAIRO_HAS_SVG_SURFACE
 #include <cairo.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/TypeDecls.h>
 
 #include "gjs/jsapi-util.h"
 
@@ -31,6 +33,11 @@
 #    include <cairo-svg.h>
 #    include <glib.h>
 
+#    include <js/Class.h>
+#    include <js/PropertySpec.h>
+#    include <js/RootingAPI.h>
+#    include <jsapi.h>  // for JS_NewObjectWithGivenProto
+
 #    include "gjs/jsapi-class.h"
 #    include "gjs/jsapi-util-args.h"
 #    include "gjs/macros.h"
diff --git a/modules/cairo.cpp b/modules/cairo.cpp
index 279b2566..06593d2d 100644
--- a/modules/cairo.cpp
+++ b/modules/cairo.cpp
@@ -20,10 +20,14 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <cairo-features.h>  // for CAIRO_HAS_PDF_SURFACE, CAIRO_HAS_PS_SURFA...
 #include <cairo.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>  // for JS_NewPlainObject
 
 #include "gjs/jsapi-util.h"
 #include "modules/cairo-module.h"  // IWYU pragma: keep
diff --git a/modules/console.cpp b/modules/console.cpp
index 2abf72a0..aad5ddea 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -51,18 +51,27 @@
 #include <glib.h>
 #include <glib/gprintf.h>  // for g_fprintf
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/CompilationAndEvaluation.h"
-#include "js/SourceText.h"
-#include "js/Warnings.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/Unused.h"
+#include <js/CallArgs.h>
+#include <js/CompilationAndEvaluation.h>
+#include <js/CompileOptions.h>
+#include <js/ErrorReport.h>
+#include <js/RootingAPI.h>
+#include <js/SourceText.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Warnings.h>
+#include <jsapi.h>  // for JS_IsExceptionPending, Exce...
+#include <mozilla/UniquePtr.h>
+#include <mozilla/Unused.h>
 
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
 #include "gjs/jsapi-util.h"
 #include "modules/console.h"
 
+namespace mozilla {
+union Utf8Unit;
+}
+
 enum class PrintErrorKind { Error, Warning, StrictWarning, Note };
 
 template <typename T>
diff --git a/modules/console.h b/modules/console.h
index 59b144a0..07db3c8a 100644
--- a/modules/console.h
+++ b/modules/console.h
@@ -24,7 +24,9 @@
 #ifndef MODULES_CONSOLE_H_
 #define MODULES_CONSOLE_H_
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/modules/system.cpp b/modules/system.cpp
index 638b5379..9ebf0c73 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -32,8 +32,15 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/Date.h"  // for ResetTimeZone
+#include <js/CallArgs.h>
+#include <js/Date.h>                // for ResetTimeZone
+#include <js/GCAPI.h>               // for JS_GC
+#include <js/PropertyDescriptor.h>  // for JSPROP_READONLY
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>        // for JS_DefinePropertyById, JS_DefineF...
+#include <jsfriendapi.h>  // for DumpHeap, IgnoreNurseryObjects
 
 #include "gi/object.h"
 #include "gjs/atoms.h"
diff --git a/modules/system.h b/modules/system.h
index ed0e3e12..26365cc4 100644
--- a/modules/system.h
+++ b/modules/system.h
@@ -25,7 +25,9 @@
 #ifndef MODULES_SYSTEM_H_
 #define MODULES_SYSTEM_H_
 
-#include "gjs/jsapi-wrapper.h"
+#include <config.h>
+
+#include <js/TypeDecls.h>
 
 #include "gjs/macros.h"
 
diff --git a/test/gjs-test-call-args.cpp b/test/gjs-test-call-args.cpp
index 3c5c3219..beb1716f 100644
--- a/test/gjs-test-call-args.cpp
+++ b/test/gjs-test-call-args.cpp
@@ -1,17 +1,29 @@
+#include <config.h>
+
 #include <stdint.h>
 #include <string.h>  // for strlen, strstr
 
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
-#include "js/CompilationAndEvaluation.h"
-#include "js/SourceText.h"
+#include <js/CallArgs.h>
+#include <js/CompilationAndEvaluation.h>
+#include <js/CompileOptions.h>
+#include <js/PropertySpec.h>
+#include <js/RootingAPI.h>
+#include <js/SourceText.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <jsapi.h>       // for JS_DefineFunctions
 
 #include "gjs/jsapi-util-args.h"
 #include "gjs/jsapi-util.h"
 #include "test/gjs-test-common.h"
 #include "test/gjs-test-utils.h"
 
+namespace mozilla {
+union Utf8Unit;
+}
+
 #define assert_match(str, pattern)                                            \
     G_STMT_START {                                                            \
         const char *__s1 = (str), *__s2 = (pattern);                          \
diff --git a/test/gjs-test-common.cpp b/test/gjs-test-common.cpp
index 1535d457..e74c01f1 100644
--- a/test/gjs-test-common.cpp
+++ b/test/gjs-test-common.cpp
@@ -21,9 +21,15 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CharacterEncoding.h>
+#include <js/ErrorReport.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>
 
 #include "test/gjs-test-common.h"
 
diff --git a/test/gjs-test-rooting.cpp b/test/gjs-test-rooting.cpp
index d37f8820..3241a314 100644
--- a/test/gjs-test-rooting.cpp
+++ b/test/gjs-test-rooting.cpp
@@ -1,6 +1,13 @@
+#include <config.h>
+
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/Class.h>
+#include <js/GCAPI.h>  // for JS_GC, JS_SetGCCallback, JSGCStatus
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Value.h>
+#include <jsapi.h>  // for JS_GetPrivate, JS_NewObject, JS_Set...
 
 #include "gjs/jsapi-util-root.h"
 #include "test/gjs-test-utils.h"
diff --git a/test/gjs-test-utils.cpp b/test/gjs-test-utils.cpp
index 3c83a247..1ef0cdf2 100644
--- a/test/gjs-test-utils.cpp
+++ b/test/gjs-test-utils.cpp
@@ -22,10 +22,14 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <jsapi.h>
 
 #include "gjs/context.h"
 #include "gjs/jsapi-util.h"
diff --git a/test/gjs-test-utils.h b/test/gjs-test-utils.h
index 94519253..b0e38e53 100644
--- a/test/gjs-test-utils.h
+++ b/test/gjs-test-utils.h
@@ -26,12 +26,11 @@
 #ifndef TEST_GJS_TEST_UTILS_H_
 #define TEST_GJS_TEST_UTILS_H_
 
+#include <config.h>
+
 #include "gjs/context.h"
 
-struct JSContext;
-namespace JS {
-class Realm;
-};
+#include <js/TypeDecls.h>
 
 typedef struct _GjsUnitTestFixture GjsUnitTestFixture;
 struct _GjsUnitTestFixture {
diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp
index 3151629e..e5922e8d 100644
--- a/test/gjs-tests.cpp
+++ b/test/gjs-tests.cpp
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <config.h>
+
 #include <string.h>  // for size_t, strlen
 
 #include <string>  // for u16string, u32string
@@ -28,7 +30,12 @@
 #include <glib-object.h>
 #include <glib.h>
 
-#include "gjs/jsapi-wrapper.h"
+#include <js/CharacterEncoding.h>
+#include <js/RootingAPI.h>
+#include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
+#include <js/Value.h>
+#include <jsapi.h>
 
 #include "gjs/context.h"
 #include "gjs/error-types.h"
diff --git a/tools/gjs-private-iwyu.imp b/tools/gjs-private-iwyu.imp
index 19ffbcbd..2607d15e 100644
--- a/tools/gjs-private-iwyu.imp
+++ b/tools/gjs-private-iwyu.imp
@@ -21,36 +21,6 @@
   {"include": ["@<sysprof-capture-.*>", "private", "<sysprof-capture.h>", "public"]},
   {"include": ["<X11/Xlib.h>", "private", "<cairo-xlib.h>", "public"]},
 
-  # Remove when it is no longer necessary to include jsapi-wrapper.h
-  {"include": ["\"js/AllocPolicy.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/CallArgs.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/CharacterEncoding.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/Class.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/Conversions.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/GCAPI.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/GCPolicyAPI.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/GCVector.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/HashTable.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/HeapAPI.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/Id.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/RootingAPI.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/TracingAPI.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/TypeDecls.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/Utility.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"js/Value.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"jspubtd.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"include": ["\"jstypes.h\"", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JS::GCPolicy<T>", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JS::Symbol", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JS::Value", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JS::WeakCache<T>", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JSContext", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JSFlatString", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JSFunction", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JSLinearString", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JSObject", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-  {"symbol": ["JSString", "private", "\"gjs/jsapi-wrapper.h\"", "public"]},
-
   {"symbol": ["GJS_GLOBAL_SLOT_PROTOTYPE_gtype", "private", "\"gjs/jsapi-class.h\"", "public"]},
   {"symbol": ["GJS_GLOBAL_SLOT_PROTOTYPE_function", "private", "\"gjs/jsapi-class.h\"", "public"]},
   {"symbol": ["GJS_GLOBAL_SLOT_PROTOTYPE_ns", "private", "\"gjs/jsapi-class.h\"", "public"]},


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]