Fix CSS bug, dont' run HMR code on server

Former-commit-id: 541084b7238d54d77cb13402274718311f2030b4
This commit is contained in:
Jarred Sumner
2021-08-17 12:26:06 -07:00
parent d7151f07bf
commit afcbcd231c
8 changed files with 13 additions and 147 deletions

View File

@@ -1,74 +0,0 @@
#include "DefaultGlobal.h"
#include "root.h"
#include <wtf/text/AtomStringImpl.h>
#include <JavaScriptCore/APICast.h>
#include <JavaScriptCore/CallFrameInlines.h>
#include <JavaScriptCore/CatchScope.h>
#include <JavaScriptCore/Completion.h>
#include <JavaScriptCore/Error.h>
#include <JavaScriptCore/Exception.h>
#include <JavaScriptCore/JSContextInternal.h>
#include <JavaScriptCore/JSInternalPromise.h>
#include <JavaScriptCore/JSModuleLoader.h>
#include <JavaScriptCore/JSNativeStdFunction.h>
#include <JavaScriptCore/JSPromise.h>
#include <JavaScriptCore/JSSourceCode.h>
#include <JavaScriptCore/JSValueInternal.h>
#include <JavaScriptCore/JSVirtualMachineInternal.h>
#include <JavaScriptCore/JavaScriptCore.h>
#include <JavaScriptCore/ObjectConstructor.h>
#include <JavaScriptCore/SourceOrigin.h>
#include <wtf/URL.h>
#include "JSCInlines.h"
class Script;
namespace JSC {
class Identifier;
class JSObject;
class JSString;
} // namespace JSC
namespace Bun {
// const ClassInfo DefaultGlobal::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr,
// CREATE_METHOD_TABLE(DefaultGlobal) }; const GlobalObjectMethodTable
// DefaultGlobal::s_globalObjectMethodTable = {
// &supportsRichSourceInfo,
// &shouldInterruptScript,
// &javaScriptRuntimeFlags,
// nullptr, // queueTaskToEventLoop
// &shouldInterruptScriptBeforeTimeout,
// &moduleLoaderImportModule, // moduleLoaderImportModule
// &moduleLoaderResolve, // moduleLoaderResolve
// &moduleLoaderFetch, // moduleLoaderFetch
// &moduleLoaderCreateImportMetaProperties, // moduleLoaderCreateImportMetaProperties
// &moduleLoaderEvaluate, // moduleLoaderEvaluate
// nullptr, // promiseRejectionTracker
// &reportUncaughtExceptionAtEventLoop,
// &currentScriptExecutionOwner,
// &scriptExecutionStatus,
// nullptr, // defaultLanguage
// nullptr, // compileStreaming
// nullptr, // instantiateStreaming
// };
// void DefaultGlobal::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject, Exception*
// exception) {} JSC::Identifier DefaultGlobal::moduleLoaderResolve(JSGlobalObject* globalObject,
// JSModuleLoader* loader, JSValue key, JSValue referrer, JSValue val) { JSInternalPromise*
// DefaultGlobal::moduleLoaderImportModule(JSGlobalObject* globalObject, JSModuleLoader*, JSString*
// specifierValue, JSValue, const SourceOrigin& sourceOrigin) { JSInternalPromise*
// DefaultGlobal::moduleLoaderFetch(JSGlobalObject* globalObject, JSModuleLoader*, JSValue key,
// JSValue, JSValue) { JSC::JSObject*
// DefaultGlobal::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject,
// JSModuleLoader*loader, JSValue key, JSModuleRecord* record, JSValue value) { JSValue
// DefaultGlobal::moduleLoaderEvaluate(JSGlobalObject* globalObject, JSModuleLoader* moduleLoader,
// JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue
// resumeMode) {
// using namespace JSC;
}; // namespace Bun

View File

@@ -1,64 +0,0 @@
#pragma once
namespace JSC {
class Structure;
class Identifier;
} // namespace JSC
#include "JSCInlines.h"
#include "root.h"
#include <JavaScriptCore/JSGlobalObject.h>
using namespace JSC;
namespace Bun {
class Script;
class DefaultGlobal final : public JSC::JSGlobalObject {
public:
using Base = JSC::JSGlobalObject;
DECLARE_EXPORT_INFO;
static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable;
static constexpr bool needsDestruction = true;
template <typename CellType, SubspaceAccess mode>
static JSC::IsoSubspace *subspaceFor(JSC::VM &vm) {
return vm.apiGlobalObjectSpace<mode>();
}
static DefaultGlobal *create(JSC::VM &vm, JSC::Structure *structure) {
auto *object = new (NotNull, allocateCell<DefaultGlobal>(vm.heap)) DefaultGlobal(vm, structure);
object->finishCreation(vm);
return object;
}
static Structure *createStructure(JSC::VM &vm, JSC::JSValue prototype) {
auto *result =
Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info());
result->setTransitionWatchpointIsLikelyToBeFired(true);
return result;
}
static void reportUncaughtExceptionAtEventLoop(JSGlobalObject *, Exception *);
static JSInternalPromise *moduleLoaderImportModule(JSGlobalObject *, JSModuleLoader *,
JSC::JSString *moduleNameValue,
JSValue parameters, const SourceOrigin &);
static JSC::Identifier moduleLoaderResolve(JSGlobalObject *, JSModuleLoader *, JSValue keyValue,
JSValue referrerValue, JSValue);
static JSInternalPromise *moduleLoaderFetch(JSGlobalObject *, JSModuleLoader *, JSValue, JSValue,
JSValue);
static JSC::JSObject *moduleLoaderCreateImportMetaProperties(JSGlobalObject *, JSModuleLoader *,
JSValue, JSModuleRecord *, JSValue);
static JSValue moduleLoaderEvaluate(JSGlobalObject *, JSModuleLoader *, JSValue, JSValue, JSValue,
JSValue, JSValue);
private:
DefaultGlobal(JSC::VM &vm, JSC::Structure *structure)
: Base(vm, structure, &s_globalObjectMethodTable) {}
};
} // namespace Bun

View File

@@ -348,7 +348,7 @@ JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject *globalObject,
for (size_t i = 0; i < arg2; ++i) {
array->initializeIndexWithoutBarrier(initializationScope, i,
JSC::jsString(vm, Zig::toString(arg1[i])));
JSC::jsString(vm, Zig::toStringCopy(arg1[i])));
}
}
}

View File

@@ -76,6 +76,12 @@ static const WTF::String toString(ZigString str) {
return WTF::String(WTF::StringImpl::createWithoutCopying(str.ptr, str.len));
}
static const WTF::String toStringCopy(ZigString str) {
if (str.len == 0 || str.ptr == nullptr) { return WTF::String(); }
return WTF::String(WTF::StringImpl::create(str.ptr, str.len));
}
static WTF::String toStringNotConst(ZigString str) {
if (str.len == 0 || str.ptr == nullptr) { return WTF::String(); }