mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
wip!
This commit is contained in:
@@ -65,6 +65,10 @@ pub const Brotli = struct {
|
||||
}
|
||||
|
||||
// chunkSize <integer> Default: 16 * 1024
|
||||
var chunkSize_value = 16 * 1024;
|
||||
if (try value.getOptional(globalObject, "chunkSize", u32)) |chunkSizey| {
|
||||
chunkSize_value = chunkSizey;
|
||||
}
|
||||
|
||||
// params <Object> Key-value object containing indexed Brotli parameters.
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <JavaScriptCore/WeakMapImplInlines.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/DateInstance.h>
|
||||
#include <JavaScriptCore/JSInternalFieldObjectImplInlines.h>
|
||||
|
||||
namespace Bun {
|
||||
|
||||
@@ -1437,19 +1438,3 @@ JSC_DEFINE_HOST_FUNCTION(jsMockFunctionWithImplementation, (JSC::JSGlobalObject
|
||||
return JSC::JSValue::encode(jsUndefined());
|
||||
}
|
||||
} // namespace Bun
|
||||
|
||||
namespace JSC {
|
||||
|
||||
template<unsigned passedNumberOfInternalFields>
|
||||
template<typename Visitor>
|
||||
void JSInternalFieldObjectImpl<passedNumberOfInternalFields>::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
auto* thisObject = jsCast<JSInternalFieldObjectImpl*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
Base::visitChildren(thisObject, visitor);
|
||||
visitor.appendValues(thisObject->m_internalFields, numberOfInternalFields);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN_WITH_MODIFIER(template<unsigned passedNumberOfInternalFields>, JSInternalFieldObjectImpl<passedNumberOfInternalFields>);
|
||||
|
||||
} // namespace JSC
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
296
src/bun.js/bindings/JSSink.h
generated
296
src/bun.js/bindings/JSSink.h
generated
@@ -1,6 +1,6 @@
|
||||
|
||||
// AUTO-GENERATED FILE. DO NOT EDIT.
|
||||
// Generated by 'make generate-sink' at 2023-07-09T17:58:51.558Z
|
||||
// Generated by 'make generate-sink' at 2023-07-18T03:21:16.950Z
|
||||
//
|
||||
#pragma once
|
||||
|
||||
@@ -605,6 +605,300 @@ public:
|
||||
|
||||
JSC_DECLARE_CUSTOM_GETTER(functionHTTPSResponseSink__getter);
|
||||
|
||||
class JSBrotliDecompressorSinkConstructor final : public JSC::InternalFunction {
|
||||
public:
|
||||
using Base = JSC::InternalFunction;
|
||||
static JSBrotliDecompressorSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype);
|
||||
static constexpr SinkID Sink = SinkID::BrotliDecompressorSink;
|
||||
|
||||
static constexpr unsigned StructureFlags = Base::StructureFlags;
|
||||
static constexpr bool needsDestruction = false;
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSBrotliDecompressorSinkConstructor, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
|
||||
}
|
||||
void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
|
||||
|
||||
// Must be defined for each specialization class.
|
||||
static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
|
||||
private:
|
||||
JSBrotliDecompressorSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
|
||||
: Base(vm, structure, nativeFunction, nativeFunction)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
|
||||
};
|
||||
|
||||
class JSBrotliDecompressorSink final : public JSC::JSDestructibleObject {
|
||||
public:
|
||||
using Base = JSC::JSDestructibleObject;
|
||||
static JSBrotliDecompressorSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
|
||||
static constexpr SinkID Sink = SinkID::BrotliDecompressorSink;
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSBrotliDecompressorSink, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForJSSink.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
static void destroy(JSC::JSCell*);
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
|
||||
}
|
||||
|
||||
static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
|
||||
|
||||
~JSBrotliDecompressorSink();
|
||||
|
||||
void* wrapped() const { return m_sinkPtr; }
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
|
||||
void detach()
|
||||
{
|
||||
m_sinkPtr = nullptr;
|
||||
}
|
||||
|
||||
static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
|
||||
|
||||
void ref();
|
||||
void unref();
|
||||
|
||||
void* m_sinkPtr;
|
||||
int m_refCount { 1 };
|
||||
|
||||
JSBrotliDecompressorSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
m_sinkPtr = sinkPtr;
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&);
|
||||
};
|
||||
|
||||
class JSReadableBrotliDecompressorSinkController final : public JSC::JSDestructibleObject {
|
||||
public:
|
||||
using Base = JSC::JSDestructibleObject;
|
||||
static JSReadableBrotliDecompressorSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
|
||||
static constexpr SinkID Sink = SinkID::BrotliDecompressorSink;
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSReadableBrotliDecompressorSinkController, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
static void destroy(JSC::JSCell*);
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
|
||||
}
|
||||
static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
|
||||
|
||||
~JSReadableBrotliDecompressorSinkController();
|
||||
|
||||
void* wrapped() const { return m_sinkPtr; }
|
||||
void detach();
|
||||
|
||||
void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose);
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
|
||||
static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
|
||||
|
||||
void* m_sinkPtr;
|
||||
mutable WriteBarrier<JSC::JSFunction> m_onPull;
|
||||
mutable WriteBarrier<JSC::JSFunction> m_onClose;
|
||||
mutable JSC::Weak<JSObject> m_weakReadableStream;
|
||||
|
||||
JSReadableBrotliDecompressorSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
m_sinkPtr = sinkPtr;
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&);
|
||||
};
|
||||
|
||||
JSC_DECLARE_CUSTOM_GETTER(functionBrotliDecompressorSink__getter);
|
||||
|
||||
class JSBrotliCompressorSinkConstructor final : public JSC::InternalFunction {
|
||||
public:
|
||||
using Base = JSC::InternalFunction;
|
||||
static JSBrotliCompressorSinkConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSC::JSObject* prototype);
|
||||
static constexpr SinkID Sink = SinkID::BrotliCompressorSink;
|
||||
|
||||
static constexpr unsigned StructureFlags = Base::StructureFlags;
|
||||
static constexpr bool needsDestruction = false;
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSBrotliCompressorSinkConstructor, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForJSSinkConstructor.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkConstructor = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForJSSinkConstructor.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkConstructor = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
|
||||
}
|
||||
void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
|
||||
|
||||
// Must be defined for each specialization class.
|
||||
static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
|
||||
private:
|
||||
JSBrotliCompressorSinkConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
|
||||
: Base(vm, structure, nativeFunction, nativeFunction)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSC::JSObject* prototype);
|
||||
};
|
||||
|
||||
class JSBrotliCompressorSink final : public JSC::JSDestructibleObject {
|
||||
public:
|
||||
using Base = JSC::JSDestructibleObject;
|
||||
static JSBrotliCompressorSink* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
|
||||
static constexpr SinkID Sink = SinkID::BrotliCompressorSink;
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSBrotliCompressorSink, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForJSSink.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSink = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForJSSink.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForJSSink = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
static void destroy(JSC::JSCell*);
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
|
||||
}
|
||||
|
||||
static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
|
||||
|
||||
~JSBrotliCompressorSink();
|
||||
|
||||
void* wrapped() const { return m_sinkPtr; }
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
|
||||
void detach()
|
||||
{
|
||||
m_sinkPtr = nullptr;
|
||||
}
|
||||
|
||||
static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
|
||||
|
||||
void ref();
|
||||
void unref();
|
||||
|
||||
void* m_sinkPtr;
|
||||
int m_refCount { 1 };
|
||||
|
||||
JSBrotliCompressorSink(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
m_sinkPtr = sinkPtr;
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&);
|
||||
};
|
||||
|
||||
class JSReadableBrotliCompressorSinkController final : public JSC::JSDestructibleObject {
|
||||
public:
|
||||
using Base = JSC::JSDestructibleObject;
|
||||
static JSReadableBrotliCompressorSinkController* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* sinkPtr);
|
||||
static constexpr SinkID Sink = SinkID::BrotliCompressorSink;
|
||||
|
||||
DECLARE_EXPORT_INFO;
|
||||
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<JSReadableBrotliCompressorSinkController, WebCore::UseCustomHeapCellType::No>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForJSSinkController.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForJSSinkController = std::forward<decltype(space)>(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForJSSinkController.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForJSSinkController = std::forward<decltype(space)>(space); });
|
||||
}
|
||||
|
||||
static void destroy(JSC::JSCell*);
|
||||
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
{
|
||||
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
|
||||
}
|
||||
static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject);
|
||||
|
||||
~JSReadableBrotliCompressorSinkController();
|
||||
|
||||
void* wrapped() const { return m_sinkPtr; }
|
||||
void detach();
|
||||
|
||||
void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose);
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
|
||||
static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
|
||||
|
||||
void* m_sinkPtr;
|
||||
mutable WriteBarrier<JSC::JSFunction> m_onPull;
|
||||
mutable WriteBarrier<JSC::JSFunction> m_onClose;
|
||||
mutable JSC::Weak<JSObject> m_weakReadableStream;
|
||||
|
||||
JSReadableBrotliCompressorSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
m_sinkPtr = sinkPtr;
|
||||
}
|
||||
|
||||
void finishCreation(JSC::VM&);
|
||||
};
|
||||
|
||||
JSC_DECLARE_CUSTOM_GETTER(functionBrotliCompressorSink__getter);
|
||||
|
||||
JSObject* createJSSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID);
|
||||
JSObject* createJSSinkControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID);
|
||||
Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WebCore::SinkID sinkID);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Automatically generated from src/bun.js/bindings/JSSink.cpp using /Users/ashcon/Desktop/code/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT!
|
||||
// Automatically generated from src/bun.js/bindings/JSSink.cpp using /Users/jarred/Code/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT!
|
||||
|
||||
|
||||
|
||||
@@ -319,3 +319,163 @@ static const struct HashTable JSReadableHTTPSResponseSinkControllerPrototypeTabl
|
||||
{ 5, 15, false, nullptr, JSReadableHTTPSResponseSinkControllerPrototypeTableValues, JSReadableHTTPSResponseSinkControllerPrototypeTableIndex };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const struct CompactHashIndex JSBrotliDecompressorSinkPrototypeTableIndex[19] = {
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 6, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 0, 16 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 5, -1 },
|
||||
{ 4, -1 },
|
||||
{ 1, 17 },
|
||||
{ 2, 18 },
|
||||
{ 3, -1 },
|
||||
};
|
||||
|
||||
static const struct HashTableValue JSBrotliDecompressorSinkPrototypeTableValues[7] = {
|
||||
{ "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__doClose, 0 } },
|
||||
{ "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__flush, 1 } },
|
||||
{ "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__end, 0 } },
|
||||
{ "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__start, 1 } },
|
||||
{ "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__write, 1 } },
|
||||
{ "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__ref, 0 } },
|
||||
{ "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__unref, 0 } },
|
||||
};
|
||||
|
||||
static const struct HashTable JSBrotliDecompressorSinkPrototypeTable =
|
||||
{ 7, 15, false, nullptr, JSBrotliDecompressorSinkPrototypeTableValues, JSBrotliDecompressorSinkPrototypeTableIndex };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const struct CompactHashIndex JSReadableBrotliDecompressorSinkControllerPrototypeTableIndex[19] = {
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 0, 16 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 4, -1 },
|
||||
{ 1, 17 },
|
||||
{ 2, 18 },
|
||||
{ 3, -1 },
|
||||
};
|
||||
|
||||
static const struct HashTableValue JSReadableBrotliDecompressorSinkControllerPrototypeTableValues[5] = {
|
||||
{ "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableBrotliDecompressorSinkController__close, 0 } },
|
||||
{ "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__flush, 1 } },
|
||||
{ "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableBrotliDecompressorSinkController__end, 0 } },
|
||||
{ "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__start, 1 } },
|
||||
{ "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliDecompressorSink__write, 1 } },
|
||||
};
|
||||
|
||||
static const struct HashTable JSReadableBrotliDecompressorSinkControllerPrototypeTable =
|
||||
{ 5, 15, false, nullptr, JSReadableBrotliDecompressorSinkControllerPrototypeTableValues, JSReadableBrotliDecompressorSinkControllerPrototypeTableIndex };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const struct CompactHashIndex JSBrotliCompressorSinkPrototypeTableIndex[19] = {
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 6, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 0, 16 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 5, -1 },
|
||||
{ 4, -1 },
|
||||
{ 1, 17 },
|
||||
{ 2, 18 },
|
||||
{ 3, -1 },
|
||||
};
|
||||
|
||||
static const struct HashTableValue JSBrotliCompressorSinkPrototypeTableValues[7] = {
|
||||
{ "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__doClose, 0 } },
|
||||
{ "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__flush, 1 } },
|
||||
{ "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__end, 0 } },
|
||||
{ "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__start, 1 } },
|
||||
{ "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__write, 1 } },
|
||||
{ "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__ref, 0 } },
|
||||
{ "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__unref, 0 } },
|
||||
};
|
||||
|
||||
static const struct HashTable JSBrotliCompressorSinkPrototypeTable =
|
||||
{ 7, 15, false, nullptr, JSBrotliCompressorSinkPrototypeTableValues, JSBrotliCompressorSinkPrototypeTableIndex };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const struct CompactHashIndex JSReadableBrotliCompressorSinkControllerPrototypeTableIndex[19] = {
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 0, 16 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ -1, -1 },
|
||||
{ 4, -1 },
|
||||
{ 1, 17 },
|
||||
{ 2, 18 },
|
||||
{ 3, -1 },
|
||||
};
|
||||
|
||||
static const struct HashTableValue JSReadableBrotliCompressorSinkControllerPrototypeTableValues[5] = {
|
||||
{ "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableBrotliCompressorSinkController__close, 0 } },
|
||||
{ "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__flush, 1 } },
|
||||
{ "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableBrotliCompressorSinkController__end, 0 } },
|
||||
{ "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__start, 1 } },
|
||||
{ "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, BrotliCompressorSink__write, 1 } },
|
||||
};
|
||||
|
||||
static const struct HashTable JSReadableBrotliCompressorSinkControllerPrototypeTable =
|
||||
{ 5, 15, false, nullptr, JSReadableBrotliCompressorSinkControllerPrototypeTableValues, JSReadableBrotliCompressorSinkControllerPrototypeTableIndex };
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "JavaScriptCore/JSNativeStdFunction.h"
|
||||
#include "JavaScriptCore/JSCJSValueInlines.h"
|
||||
#include "JavaScriptCore/JSInternalPromise.h"
|
||||
#include "JavaScriptCore/JSInternalFieldObjectImpl.h"
|
||||
|
||||
#include "ZigSourceProvider.h"
|
||||
|
||||
@@ -36,11 +35,12 @@
|
||||
#include "../modules/TTYModule.h"
|
||||
#include "node_util_types.h"
|
||||
#include "CommonJSModuleRecord.h"
|
||||
#include <JavaScriptCore/JSModuleLoader.h>
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include <JavaScriptCore/JSModuleNamespaceObject.h>
|
||||
#include <JavaScriptCore/JSMap.h>
|
||||
#include <JavaScriptCore/JSMapInlines.h>
|
||||
#include "JavaScriptCore/JSModuleLoader.h"
|
||||
#include "JavaScriptCore/Completion.h"
|
||||
#include "JavaScriptCore/JSModuleNamespaceObject.h"
|
||||
#include "JavaScriptCore/JSMap.h"
|
||||
#include "JavaScriptCore/JSMapInlines.h"
|
||||
#include "JavaScriptCore/JSInternalFieldObjectImplInlines.h"
|
||||
|
||||
namespace Bun {
|
||||
using namespace Zig;
|
||||
@@ -690,18 +690,3 @@ JSValue fetchSourceCodeAsync(
|
||||
return fetchSourceCode<true>(globalObject, res, specifier, referrer);
|
||||
}
|
||||
}
|
||||
namespace JSC {
|
||||
|
||||
template<unsigned passedNumberOfInternalFields>
|
||||
template<typename Visitor>
|
||||
void JSInternalFieldObjectImpl<passedNumberOfInternalFields>::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
auto* thisObject = jsCast<JSInternalFieldObjectImpl*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
Base::visitChildren(thisObject, visitor);
|
||||
visitor.appendValues(thisObject->m_internalFields, numberOfInternalFields);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN_WITH_MODIFIER(template<unsigned passedNumberOfInternalFields>, JSInternalFieldObjectImpl<passedNumberOfInternalFields>);
|
||||
|
||||
} // namespace JSC
|
||||
|
||||
@@ -9,9 +9,11 @@ enum SinkID : uint8_t {
|
||||
HTMLRewriterSink = 3,
|
||||
HTTPResponseSink = 4,
|
||||
HTTPSResponseSink = 5,
|
||||
BrotliDecompressorSink = 6,
|
||||
BrotliCompressorSink = 7,
|
||||
|
||||
};
|
||||
static constexpr unsigned numberOfSinkIDs
|
||||
= 6;
|
||||
= 8;
|
||||
|
||||
}
|
||||
@@ -3292,6 +3292,26 @@ void GlobalObject::finishCreation(VM& vm)
|
||||
init.setConstructor(constructor);
|
||||
});
|
||||
|
||||
m_JSBrotliDecompressorSinkClassStructure.initLater(
|
||||
[](LazyClassStructure::Initializer& init) {
|
||||
auto* prototype = createJSSinkPrototype(init.vm, init.global, WebCore::SinkID::BrotliDecompressorSink);
|
||||
auto* structure = JSBrotliDecompressorSink::createStructure(init.vm, init.global, prototype);
|
||||
auto* constructor = JSBrotliDecompressorSinkConstructor::create(init.vm, init.global, JSBrotliDecompressorSinkConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<JSObject*>(prototype));
|
||||
init.setPrototype(prototype);
|
||||
init.setStructure(structure);
|
||||
init.setConstructor(constructor);
|
||||
});
|
||||
|
||||
m_JSBrotliCompressorSinkClassStructure.initLater(
|
||||
[](LazyClassStructure::Initializer& init) {
|
||||
auto* prototype = createJSSinkPrototype(init.vm, init.global, WebCore::SinkID::BrotliCompressorSink);
|
||||
auto* structure = JSBrotliCompressorSink::createStructure(init.vm, init.global, prototype);
|
||||
auto* constructor = JSBrotliCompressorSinkConstructor::create(init.vm, init.global, JSBrotliCompressorSinkConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), jsCast<JSObject*>(prototype));
|
||||
init.setPrototype(prototype);
|
||||
init.setStructure(structure);
|
||||
init.setConstructor(constructor);
|
||||
});
|
||||
|
||||
m_JSArrayBufferSinkClassStructure.initLater(
|
||||
[](LazyClassStructure::Initializer& init) {
|
||||
auto* prototype = createJSSinkPrototype(init.vm, init.global, WebCore::SinkID::ArrayBufferSink);
|
||||
@@ -4215,6 +4235,19 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
}
|
||||
|
||||
{
|
||||
JSC::Identifier identifier = JSC::Identifier::fromString(vm, "BrotliDecompressorSink"_s);
|
||||
object->putDirectCustomAccessor(vm, identifier, JSC::CustomGetterSetter::create(vm, functionBrotliDecompressorSink__getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
JSC::Identifier identifier = JSC::Identifier::fromString(vm, "BrotliCompressorSink"_s);
|
||||
object->putDirectCustomAccessor(vm, identifier, JSC::CustomGetterSetter::create(vm, functionBrotliCompressorSink__getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
}
|
||||
|
||||
{
|
||||
JSC::Identifier identifier = JSC::Identifier::fromString(vm, "nanoseconds"_s);
|
||||
object->putDirectNativeFunction(vm, this, identifier, 1, functionBunNanoseconds, ImplementationVisibility::Public, NoIntrinsic,
|
||||
@@ -4415,6 +4448,8 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
thisObject->m_JSFileSinkClassStructure.visit(visitor);
|
||||
thisObject->m_JSHTTPResponseSinkClassStructure.visit(visitor);
|
||||
thisObject->m_JSHTTPSResponseSinkClassStructure.visit(visitor);
|
||||
thisObject->m_JSBrotliDecompressorSinkClassStructure.visit(visitor);
|
||||
thisObject->m_JSBrotliCompressorSinkClassStructure.visit(visitor);
|
||||
thisObject->m_JSReadableStateClassStructure.visit(visitor);
|
||||
thisObject->m_JSStringDecoderClassStructure.visit(visitor);
|
||||
thisObject->m_NapiClassStructure.visit(visitor);
|
||||
@@ -4430,6 +4465,8 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
thisObject->m_JSArrayBufferControllerPrototype.visit(visitor);
|
||||
thisObject->m_JSFileSinkControllerPrototype.visit(visitor);
|
||||
thisObject->m_JSHTTPSResponseControllerPrototype.visit(visitor);
|
||||
thisObject->m_JSBrotliDecompressorSinkControllerPrototype.visit(visitor);
|
||||
thisObject->m_JSBrotliCompressorSinkControllerPrototype.visit(visitor);
|
||||
thisObject->m_navigatorObject.visit(visitor);
|
||||
thisObject->m_nativeMicrotaskTrampoline.visit(visitor);
|
||||
thisObject->m_performanceObject.visit(visitor);
|
||||
|
||||
@@ -205,6 +205,16 @@ public:
|
||||
JSC::Structure* FFIFunctionStructure() { return m_JSFFIFunctionStructure.getInitializedOnMainThread(this); }
|
||||
JSC::Structure* NapiClassStructure() { return m_NapiClassStructure.getInitializedOnMainThread(this); }
|
||||
|
||||
JSC::Structure* BrotliDecompressorSinkStructure() { return m_JSBrotliDecompressorSinkClassStructure.getInitializedOnMainThread(this); }
|
||||
JSC::JSObject* BrotliDecompressorSink() { return m_JSBrotliDecompressorSinkClassStructure.constructorInitializedOnMainThread(this); }
|
||||
JSC::JSValue BrotliDecompressorSinkPrototype() { return m_JSBrotliDecompressorSinkClassStructure.prototypeInitializedOnMainThread(this); }
|
||||
JSC::JSValue JSReadableBrotliDecompressorSinkControllerPrototype() { return m_JSBrotliDecompressorSinkControllerPrototype.getInitializedOnMainThread(this); }
|
||||
|
||||
JSC::Structure* BrotliCompressorSinkStructure() { return m_JSBrotliCompressorSinkClassStructure.getInitializedOnMainThread(this); }
|
||||
JSC::JSObject* BrotliCompressorSink() { return m_JSBrotliCompressorSinkClassStructure.constructorInitializedOnMainThread(this); }
|
||||
JSC::JSValue BrotliCompressorSinkPrototype() { return m_JSBrotliCompressorSinkClassStructure.prototypeInitializedOnMainThread(this); }
|
||||
JSC::JSValue JSReadableBrotliCompressorSinkControllerPrototype() { return m_JSBrotliCompressorSinkControllerPrototype.getInitializedOnMainThread(this); }
|
||||
|
||||
JSC::Structure* FileSinkStructure() { return m_JSFileSinkClassStructure.getInitializedOnMainThread(this); }
|
||||
JSC::JSObject* FileSink() { return m_JSFileSinkClassStructure.constructorInitializedOnMainThread(this); }
|
||||
JSC::JSValue FileSinkPrototype() { return m_JSFileSinkClassStructure.prototypeInitializedOnMainThread(this); }
|
||||
@@ -470,6 +480,8 @@ private:
|
||||
LazyClassStructure m_JSFileSinkClassStructure;
|
||||
LazyClassStructure m_JSHTTPResponseSinkClassStructure;
|
||||
LazyClassStructure m_JSHTTPSResponseSinkClassStructure;
|
||||
LazyClassStructure m_JSBrotliDecompressorSinkClassStructure;
|
||||
LazyClassStructure m_JSBrotliCompressorSinkClassStructure;
|
||||
LazyClassStructure m_JSReadableStateClassStructure;
|
||||
LazyClassStructure m_JSStringDecoderClassStructure;
|
||||
LazyClassStructure m_NapiClassStructure;
|
||||
@@ -498,6 +510,8 @@ private:
|
||||
LazyProperty<JSGlobalObject, JSObject> m_JSArrayBufferControllerPrototype;
|
||||
LazyProperty<JSGlobalObject, JSObject> m_JSFileSinkControllerPrototype;
|
||||
LazyProperty<JSGlobalObject, JSObject> m_JSHTTPSResponseControllerPrototype;
|
||||
LazyProperty<JSGlobalObject, JSObject> m_JSBrotliCompressorSinkControllerPrototype;
|
||||
LazyProperty<JSGlobalObject, JSObject> m_JSBrotliDecompressorSinkControllerPrototype;
|
||||
LazyProperty<JSGlobalObject, JSObject> m_navigatorObject;
|
||||
LazyProperty<JSGlobalObject, JSObject> m_performanceObject;
|
||||
LazyProperty<JSGlobalObject, JSObject> m_primordialsObject;
|
||||
|
||||
@@ -163,6 +163,8 @@ pub const JSArrayBufferSink = JSC.WebCore.ArrayBufferSink.JSSink;
|
||||
pub const JSHTTPSResponseSink = JSC.WebCore.HTTPSResponseSink.JSSink;
|
||||
pub const JSHTTPResponseSink = JSC.WebCore.HTTPResponseSink.JSSink;
|
||||
pub const JSFileSink = JSC.WebCore.FileSink.JSSink;
|
||||
pub const JSBrotliDecompressorSink = JSC.WebCore.BrotliDecompressorSink.JSSink;
|
||||
pub const JSBrotliCompressorSink = JSC.WebCore.BrotliCompressorSink.JSSink;
|
||||
|
||||
// WebSocket
|
||||
pub const WebSocketHTTPClient = @import("../../http/websocket_http_client.zig").WebSocketHTTPClient;
|
||||
@@ -3404,6 +3406,8 @@ comptime {
|
||||
JSReadableStreamBlob.shim.ref();
|
||||
JSArrayBufferSink.shim.ref();
|
||||
JSHTTPResponseSink.shim.ref();
|
||||
JSBrotliDecompressorSink.shim.ref();
|
||||
JSBrotliCompressorSink.shim.ref();
|
||||
JSHTTPSResponseSink.shim.ref();
|
||||
JSFileSink.shim.ref();
|
||||
JSReadableStreamBytes.shim.ref();
|
||||
|
||||
@@ -182,8 +182,8 @@ extern "C" const size_t Zig__ConsoleClient_object_align_ = alignof(Zig::ConsoleC
|
||||
extern "C" const size_t Bun__Timer_object_size_ = sizeof(Bun__Timer);
|
||||
extern "C" const size_t Bun__Timer_object_align_ = alignof(Bun__Timer);
|
||||
|
||||
const size_t sizes[41] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::DOMFormData), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(JSC::JSModuleLoader), sizeof(WebCore::AbortSignal), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(JSC::JSMap), sizeof(JSC::JSValue), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(FFI__ptr), sizeof(Reader__u8), sizeof(Reader__u16), sizeof(Reader__u32), sizeof(Reader__ptr), sizeof(Reader__i8), sizeof(Reader__i16), sizeof(Reader__i32), sizeof(Reader__f32), sizeof(Reader__f64), sizeof(Reader__i64), sizeof(Reader__u64), sizeof(Reader__intptr), sizeof(Crypto__getRandomValues), sizeof(Crypto__randomUUID), sizeof(Crypto__timingSafeEqual), sizeof(Zig::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink), sizeof(FileSink)};
|
||||
const size_t sizes[43] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::DOMFormData), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(JSC::JSModuleLoader), sizeof(WebCore::AbortSignal), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(JSC::JSMap), sizeof(JSC::JSValue), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(FFI__ptr), sizeof(Reader__u8), sizeof(Reader__u16), sizeof(Reader__u32), sizeof(Reader__ptr), sizeof(Reader__i8), sizeof(Reader__i16), sizeof(Reader__i32), sizeof(Reader__f32), sizeof(Reader__f64), sizeof(Reader__i64), sizeof(Reader__u64), sizeof(Reader__intptr), sizeof(Crypto__getRandomValues), sizeof(Crypto__randomUUID), sizeof(Crypto__timingSafeEqual), sizeof(Zig::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink), sizeof(FileSink), sizeof(BrotliDecompressorSink), sizeof(BrotliCompressorSink)};
|
||||
|
||||
const char* names[41] = {"JSC__JSObject", "WebCore__DOMURL", "WebCore__DOMFormData", "WebCore__FetchHeaders", "SystemError", "JSC__JSCell", "JSC__JSString", "JSC__JSModuleLoader", "WebCore__AbortSignal", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__JSFunction", "JSC__JSGlobalObject", "JSC__JSMap", "JSC__JSValue", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "FFI__ptr", "Reader__u8", "Reader__u16", "Reader__u32", "Reader__ptr", "Reader__i8", "Reader__i16", "Reader__i32", "Reader__f32", "Reader__f64", "Reader__i64", "Reader__u64", "Reader__intptr", "Crypto__getRandomValues", "Crypto__randomUUID", "Crypto__timingSafeEqual", "Zig__GlobalObject", "Bun__Path", "ArrayBufferSink", "HTTPSResponseSink", "HTTPResponseSink", "FileSink"};
|
||||
const char* names[43] = {"JSC__JSObject", "WebCore__DOMURL", "WebCore__DOMFormData", "WebCore__FetchHeaders", "SystemError", "JSC__JSCell", "JSC__JSString", "JSC__JSModuleLoader", "WebCore__AbortSignal", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__JSFunction", "JSC__JSGlobalObject", "JSC__JSMap", "JSC__JSValue", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "FFI__ptr", "Reader__u8", "Reader__u16", "Reader__u32", "Reader__ptr", "Reader__i8", "Reader__i16", "Reader__i32", "Reader__f32", "Reader__f64", "Reader__i64", "Reader__u64", "Reader__intptr", "Crypto__getRandomValues", "Crypto__randomUUID", "Crypto__timingSafeEqual", "Zig__GlobalObject", "Bun__Path", "ArrayBufferSink", "HTTPSResponseSink", "HTTPResponseSink", "FileSink", "BrotliDecompressorSink", "BrotliCompressorSink"};
|
||||
|
||||
const size_t aligns[41] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::DOMFormData), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(JSC::JSModuleLoader), alignof(WebCore::AbortSignal), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(JSC::JSMap), alignof(JSC::JSValue), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(FFI__ptr), alignof(Reader__u8), alignof(Reader__u16), alignof(Reader__u32), alignof(Reader__ptr), alignof(Reader__i8), alignof(Reader__i16), alignof(Reader__i32), alignof(Reader__f32), alignof(Reader__f64), alignof(Reader__i64), alignof(Reader__u64), alignof(Reader__intptr), alignof(Crypto__getRandomValues), alignof(Crypto__randomUUID), alignof(Crypto__timingSafeEqual), alignof(Zig::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink), alignof(FileSink)};
|
||||
const size_t aligns[43] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::DOMFormData), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(JSC::JSModuleLoader), alignof(WebCore::AbortSignal), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(JSC::JSMap), alignof(JSC::JSValue), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(FFI__ptr), alignof(Reader__u8), alignof(Reader__u16), alignof(Reader__u32), alignof(Reader__ptr), alignof(Reader__i8), alignof(Reader__i16), alignof(Reader__i32), alignof(Reader__f32), alignof(Reader__f64), alignof(Reader__i64), alignof(Reader__u64), alignof(Reader__intptr), alignof(Crypto__getRandomValues), alignof(Crypto__randomUUID), alignof(Crypto__timingSafeEqual), alignof(Zig::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink), alignof(FileSink), alignof(BrotliDecompressorSink), alignof(BrotliCompressorSink)};
|
||||
|
||||
12
src/bun.js/bindings/headers.zig
generated
12
src/bun.js/bindings/headers.zig
generated
@@ -378,4 +378,16 @@ pub extern fn FileSink__detachPtr(JSValue0: JSC__JSValue) void;
|
||||
pub extern fn FileSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
|
||||
pub extern fn FileSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
|
||||
pub extern fn FileSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
|
||||
pub extern fn BrotliDecompressorSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
|
||||
pub extern fn BrotliDecompressorSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
|
||||
pub extern fn BrotliDecompressorSink__detachPtr(JSValue0: JSC__JSValue) void;
|
||||
pub extern fn BrotliDecompressorSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
|
||||
pub extern fn BrotliDecompressorSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
|
||||
pub extern fn BrotliDecompressorSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
|
||||
pub extern fn BrotliCompressorSink__assignToStream(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, arg2: ?*anyopaque, arg3: [*c]*anyopaque) JSC__JSValue;
|
||||
pub extern fn BrotliCompressorSink__createObject(arg0: *bindings.JSGlobalObject, arg1: ?*anyopaque) JSC__JSValue;
|
||||
pub extern fn BrotliCompressorSink__detachPtr(JSValue0: JSC__JSValue) void;
|
||||
pub extern fn BrotliCompressorSink__fromJS(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue) ?*anyopaque;
|
||||
pub extern fn BrotliCompressorSink__onClose(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) void;
|
||||
pub extern fn BrotliCompressorSink__onReady(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue) void;
|
||||
pub extern fn ZigException__fromException(arg0: [*c]bindings.Exception) ZigException;
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { resolve } from "path";
|
||||
|
||||
const classes = ["ArrayBufferSink", "FileSink", "HTTPResponseSink", "HTTPSResponseSink"];
|
||||
const SINK_COUNT = 5;
|
||||
const classes = [
|
||||
"ArrayBufferSink",
|
||||
"FileSink",
|
||||
"HTTPResponseSink",
|
||||
"HTTPSResponseSink",
|
||||
"BrotliDecompressorSink",
|
||||
"BrotliCompressorSink",
|
||||
];
|
||||
|
||||
function names(name) {
|
||||
return {
|
||||
|
||||
@@ -1896,12 +1896,222 @@ pub const ArrayBufferSink = struct {
|
||||
pub const JSSink = NewJSSink(@This(), "ArrayBufferSink");
|
||||
};
|
||||
|
||||
pub const BrotliCompressorSink = struct {
|
||||
state: ?*bun.brotli.BrotliEncoderState = null,
|
||||
allocator: std.mem.Allocator,
|
||||
done: bool = false,
|
||||
signal: Signal = .{},
|
||||
next: ?Sink = null,
|
||||
output_buffer: bun.ByteList = bun.ByteList{},
|
||||
chunk_size: u32 = 16 * 1024,
|
||||
|
||||
pub fn connect(this: *BrotliCompressorSink, signal: Signal) void {
|
||||
std.debug.assert(this.reader == null);
|
||||
this.signal = signal;
|
||||
}
|
||||
|
||||
pub fn start(this: *BrotliCompressorSink, _: StreamStart) JSC.Node.Maybe(void) {
|
||||
this.output_buffer.len = 0;
|
||||
|
||||
if (this.state == null) {
|
||||
this.state = bun.brotli.BrotliEncoderState.init();
|
||||
}
|
||||
|
||||
// switch (stream_start) {
|
||||
// .BrotliCompressorSink => |config| {
|
||||
// if (config.chunk_size > 0) {
|
||||
// list.ensureTotalCapacityPrecise(config.chunk_size) catch return .{ .err = Syscall.Error.oom };
|
||||
// this.bytes.update(list);
|
||||
// }
|
||||
|
||||
// this.as_uint8array = config.as_uint8array;
|
||||
// this.streaming = config.stream;
|
||||
// },
|
||||
// else => {},
|
||||
// }
|
||||
|
||||
this.done = false;
|
||||
|
||||
this.signal.start();
|
||||
return .{ .result = {} };
|
||||
}
|
||||
|
||||
pub fn flush(this: *BrotliCompressorSink) JSC.Node.Maybe(void) {
|
||||
_ = this;
|
||||
return .{ .result = {} };
|
||||
}
|
||||
|
||||
pub fn flushFromJS(this: *BrotliCompressorSink, globalThis: *JSGlobalObject, wait: bool) JSC.Node.Maybe(JSValue) {
|
||||
_ = wait;
|
||||
|
||||
if (this.output_buffer.len > 0) {
|
||||
if (this.next) |*next| {
|
||||
var list = this.output_buffer;
|
||||
this.output_buffer = bun.ByteList.init("");
|
||||
return .{ .result = next.writeBytes(.{ .owned = list }).toJS(globalThis) };
|
||||
}
|
||||
|
||||
return .{ .result = JSC.JSValue.jsNumber(this.output_buffer.len) };
|
||||
}
|
||||
|
||||
return .{ .result = JSC.JSValue.jsNumber(0) };
|
||||
}
|
||||
|
||||
pub fn finalize(this: *BrotliCompressorSink) void {
|
||||
if (this.state) |state| {
|
||||
state.deinit();
|
||||
}
|
||||
this.output_buffer.deinitWithAllocator(bun.default_allocator);
|
||||
this.allocator.destroy(this);
|
||||
}
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator, next: ?Sink) !*BrotliCompressorSink {
|
||||
var this = try allocator.create(BrotliCompressorSink);
|
||||
this.* = BrotliCompressorSink{
|
||||
.bytes = bun.ByteList.init(&.{}),
|
||||
.allocator = allocator,
|
||||
.next = next,
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
pub fn construct(
|
||||
this: *BrotliCompressorSink,
|
||||
allocator: std.mem.Allocator,
|
||||
) void {
|
||||
this.* = BrotliCompressorSink{
|
||||
.allocator = allocator,
|
||||
.next = null,
|
||||
.state = null,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn write(this: *@This(), data: StreamResult) StreamResult.Writable {
|
||||
var state = this.state orelse return .{ .done = {} };
|
||||
var initial_slice = data.slice();
|
||||
var slice = initial_slice;
|
||||
if (this.output_buffer.cap == 0) {
|
||||
this.output_buffer.ensureUnusedCapacity(bun.default_allocator, this.chunk_size) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
}
|
||||
var output_slice = this.output_buffer.ptr[this.output_buffer.len..this.output_buffer.cap];
|
||||
|
||||
while (slice.len > 0) {
|
||||
if (this.output_buffer.cap - this.output_buffer.len < 512) {
|
||||
this.output_buffer.ensureUnusedCapacity(bun.default_allocator, this.chunk_size) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
output_slice = this.output_buffer.ptr[this.output_buffer.len..this.output_buffer.cap];
|
||||
}
|
||||
const max = output_slice.len;
|
||||
const res = state.write(&slice, &output_slice);
|
||||
this.output_buffer.len += @truncate(u32, max - output_slice.len);
|
||||
|
||||
if (res) {
|
||||
if (this.output_buffer.len > 0) {
|
||||
if (this.next) |*next| {
|
||||
var output_buffer = this.output_buffer;
|
||||
|
||||
if (data.isDone()) {
|
||||
this.output_buffer = .{};
|
||||
return next.writeBytes(.{ .owned_and_done = output_buffer });
|
||||
}
|
||||
}
|
||||
|
||||
if (data.isDone()) {
|
||||
return .{ .owned_and_done = @truncate(Blob.SizeType, initial_slice.len - slice.len) };
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@panic("Unhandled brotli error");
|
||||
}
|
||||
}
|
||||
|
||||
return .{ .owned = @truncate(Blob.SizeType, initial_slice.len - slice.len) };
|
||||
}
|
||||
pub const writeBytes = write;
|
||||
pub fn writeLatin1(this: *@This(), data: StreamResult) StreamResult.Writable {
|
||||
if (strings.isAllASCII(data.slice())) {
|
||||
return this.write(data);
|
||||
}
|
||||
|
||||
var allocated = strings.allocateLatin1IntoUTF8(bun.default_allocator, []const u8, data.slice()) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
defer bun.default_allocator.free(allocated);
|
||||
return this.write(.{ .temporary = bun.ByteList.init(allocated) });
|
||||
}
|
||||
pub fn writeUTF16(this: *@This(), data: StreamResult) StreamResult.Writable {
|
||||
if (this.next) |*next| {
|
||||
return next.writeUTF16(data);
|
||||
}
|
||||
var bytes = strings.toUTF8Alloc(bun.default_allocator, @ptrCast([*]const u16, @alignCast(@alignOf(u16), data.slice().ptr))[0..std.mem.bytesAsSlice(u16, data.slice()).len]) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
defer bun.default_allocator.free(bytes);
|
||||
return this.write(.{ .temporary = bun.ByteList.init(bytes) });
|
||||
}
|
||||
|
||||
pub fn end(this: *BrotliCompressorSink, err: ?Syscall.Error) JSC.Node.Maybe(void) {
|
||||
if (this.next) |*next| {
|
||||
return next.end(err);
|
||||
}
|
||||
this.signal.close(err);
|
||||
return .{ .result = {} };
|
||||
}
|
||||
|
||||
pub fn toJS(this: *BrotliCompressorSink, globalThis: *JSGlobalObject) JSValue {
|
||||
return JSSink.createObject(globalThis, this);
|
||||
}
|
||||
|
||||
pub fn endFromJS(this: *@This(), globalThis: *JSGlobalObject) JSC.Node.Maybe(JSValue) {
|
||||
var state = this.state orelse return .{ .result = JSC.JSValue.jsUndefined() };
|
||||
var input: []const u8 = "";
|
||||
if (this.output_buffer.cap == 0) {
|
||||
this.output_buffer.ensureUnusedCapacity(bun.default_allocator, this.chunk_size) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
}
|
||||
|
||||
while (state.hasMoreOutput()) : (this.output_buffer.ensureUnusedCapacity(bun.default_allocator, this.chunk_size) catch @panic("OOM")) {
|
||||
var output_slice = this.output_buffer.ptr[this.output_buffer.len..this.output_buffer.cap];
|
||||
const initial_len = output_slice.len;
|
||||
|
||||
if (!state.finish(&input, &output_slice)) {
|
||||
@panic("Unhandled brotli error");
|
||||
}
|
||||
|
||||
this.output_buffer.len += @truncate(u32, initial_len - output_slice.len);
|
||||
}
|
||||
|
||||
state.deinit();
|
||||
this.state = null;
|
||||
|
||||
std.debug.assert(this.next == null);
|
||||
var list = this.output_buffer.listManaged(this.allocator);
|
||||
this.output_buffer = bun.ByteList.init("");
|
||||
this.done = true;
|
||||
this.signal.close(null);
|
||||
return .{ .result = JSC.JSValue.createBuffer(globalThis, list.items, bun.default_allocator) };
|
||||
}
|
||||
|
||||
pub fn sink(this: *BrotliCompressorSink) Sink {
|
||||
return Sink.init(this);
|
||||
}
|
||||
|
||||
pub const JSSink = NewJSSink(@This(), "BrotliCompressorSink");
|
||||
};
|
||||
|
||||
pub const BrotliDecompressorSink = struct {
|
||||
state: ?*bun.brotli.BrotliDecoderState = null,
|
||||
allocator: std.mem.Allocator,
|
||||
done: bool = false,
|
||||
signal: Signal = .{},
|
||||
streaming: bool = false,
|
||||
next: ?Sink = null,
|
||||
output_buffer: bun.ByteList = bun.ByteList{},
|
||||
chunk_size: u32 = 16 * 1024,
|
||||
|
||||
pub fn connect(this: *BrotliDecompressorSink, signal: Signal) void {
|
||||
std.debug.assert(this.reader == null);
|
||||
@@ -1909,7 +2119,7 @@ pub const BrotliDecompressorSink = struct {
|
||||
}
|
||||
|
||||
pub fn start(this: *BrotliDecompressorSink, _: StreamStart) JSC.Node.Maybe(void) {
|
||||
this.bytes.len = 0;
|
||||
this.output_buffer.len = 0;
|
||||
|
||||
if (this.state) |existing| {
|
||||
if (existing.isUsed()) {
|
||||
@@ -1948,16 +2158,25 @@ pub const BrotliDecompressorSink = struct {
|
||||
|
||||
pub fn flushFromJS(this: *BrotliDecompressorSink, globalThis: *JSGlobalObject, wait: bool) JSC.Node.Maybe(JSValue) {
|
||||
_ = wait;
|
||||
_ = globalThis;
|
||||
_ = this;
|
||||
|
||||
return .{ .result = JSValue.jsNumber(0) };
|
||||
if (this.output_buffer.len > 0) {
|
||||
if (this.next) |*next| {
|
||||
var list = this.output_buffer;
|
||||
this.output_buffer = bun.ByteList.init("");
|
||||
return .{ .result = next.writeBytes(.{ .owned = list }).toJS(globalThis) };
|
||||
}
|
||||
|
||||
return .{ .result = JSC.JSValue.jsNumber(this.output_buffer.len) };
|
||||
}
|
||||
|
||||
return .{ .result = JSC.JSValue.jsNumber(0) };
|
||||
}
|
||||
|
||||
pub fn finalize(this: *BrotliDecompressorSink) void {
|
||||
if (this.state) |state| {
|
||||
state.deinit();
|
||||
}
|
||||
this.output_buffer.deinitWithAllocator(bun.default_allocator);
|
||||
this.allocator.destroy(this);
|
||||
}
|
||||
|
||||
@@ -1984,30 +2203,75 @@ pub const BrotliDecompressorSink = struct {
|
||||
|
||||
pub fn write(this: *@This(), data: StreamResult) StreamResult.Writable {
|
||||
var state = this.state orelse return .{ .done = {} };
|
||||
const initial_slice = data.slice();
|
||||
var initial_slice = data.slice();
|
||||
var slice = initial_slice;
|
||||
state.write(&slice);
|
||||
if (this.output_buffer.cap == 0) {
|
||||
this.output_buffer.ensureUnusedCapacity(bun.default_allocator, this.chunk_size) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
}
|
||||
var output_slice = this.output_buffer.ptr[this.output_buffer.len..this.output_buffer.cap];
|
||||
|
||||
while (true) {
|
||||
if (this.output_buffer.cap - this.output_buffer.len < 512) {
|
||||
this.output_buffer.ensureUnusedCapacity(bun.default_allocator, this.chunk_size) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
output_slice = this.output_buffer.ptr[this.output_buffer.len..this.output_buffer.cap];
|
||||
}
|
||||
const max = output_slice.len;
|
||||
const res = state.write(&slice, &output_slice);
|
||||
this.output_buffer.len += @truncate(u32, max - output_slice.len);
|
||||
|
||||
switch (res) {
|
||||
.success => {
|
||||
if (this.next) |*next| {
|
||||
var output_buffer = this.output_buffer;
|
||||
this.output_buffer = .{};
|
||||
return next.writeBytes(.{ .owned_and_done = output_buffer });
|
||||
}
|
||||
this.signal.ready(null, null);
|
||||
return .{ .owned_and_done = @truncate(Blob.SizeType, initial_slice.len - slice.len) };
|
||||
},
|
||||
.@"error" => {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
},
|
||||
.needs_more_input => {
|
||||
this.signal.ready(null, null);
|
||||
return .{ .owned = @truncate(Blob.SizeType, initial_slice.len - slice.len) };
|
||||
},
|
||||
|
||||
.needs_more_output => {
|
||||
if (this.next) |*next| {
|
||||
var output_buffer = this.output_buffer;
|
||||
this.output_buffer = .{};
|
||||
return next.writeBytes(.{ .owned = output_buffer });
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
pub const writeBytes = write;
|
||||
pub fn writeLatin1(this: *@This(), data: StreamResult) StreamResult.Writable {
|
||||
if (this.next) |*next| {
|
||||
return next.writeLatin1(data);
|
||||
if (strings.isAllASCII(data.slice())) {
|
||||
return this.write(data);
|
||||
}
|
||||
const len = this.bytes.writeLatin1(this.allocator, data.slice()) catch {
|
||||
|
||||
var allocated = strings.allocateLatin1IntoUTF8(bun.default_allocator, []const u8, data.slice()) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
this.signal.ready(null, null);
|
||||
return .{ .owned = len };
|
||||
defer bun.default_allocator.free(allocated);
|
||||
return this.write(.{ .temporary = bun.ByteList.init(allocated) });
|
||||
}
|
||||
pub fn writeUTF16(this: *@This(), data: StreamResult) StreamResult.Writable {
|
||||
if (this.next) |*next| {
|
||||
return next.writeUTF16(data);
|
||||
}
|
||||
const len = this.bytes.writeUTF16(this.allocator, @ptrCast([*]const u16, @alignCast(@alignOf(u16), data.slice().ptr))[0..std.mem.bytesAsSlice(u16, data.slice()).len]) catch {
|
||||
var bytes = strings.toUTF8Alloc(bun.default_allocator, @ptrCast([*]const u16, @alignCast(@alignOf(u16), data.slice().ptr))[0..std.mem.bytesAsSlice(u16, data.slice()).len]) catch {
|
||||
return .{ .err = Syscall.Error.oom };
|
||||
};
|
||||
this.signal.ready(null, null);
|
||||
return .{ .owned = len };
|
||||
defer bun.default_allocator.free(bytes);
|
||||
return this.write(.{ .temporary = bun.ByteList.init(bytes) });
|
||||
}
|
||||
|
||||
pub fn end(this: *BrotliDecompressorSink, err: ?Syscall.Error) JSC.Node.Maybe(void) {
|
||||
@@ -2018,44 +2282,22 @@ pub const BrotliDecompressorSink = struct {
|
||||
return .{ .result = {} };
|
||||
}
|
||||
|
||||
pub fn toJS(this: *BrotliDecompressorSink, globalThis: *JSGlobalObject, as_uint8array: bool) JSValue {
|
||||
if (this.streaming) {
|
||||
const value: JSValue = switch (as_uint8array) {
|
||||
true => JSC.ArrayBuffer.create(globalThis, this.bytes.slice(), .Uint8Array),
|
||||
false => JSC.ArrayBuffer.create(globalThis, this.bytes.slice(), .ArrayBuffer),
|
||||
};
|
||||
this.bytes.len = 0;
|
||||
return value;
|
||||
}
|
||||
|
||||
var list = this.bytes.listManaged(this.allocator);
|
||||
this.bytes = bun.ByteList.init("");
|
||||
return ArrayBuffer.fromBytes(
|
||||
try list.toOwnedSlice(),
|
||||
if (as_uint8array)
|
||||
.Uint8Array
|
||||
else
|
||||
.ArrayBuffer,
|
||||
).toJS(globalThis, null);
|
||||
pub fn toJS(this: *BrotliDecompressorSink, globalThis: *JSGlobalObject) JSValue {
|
||||
return JSSink.createObject(globalThis, this);
|
||||
}
|
||||
|
||||
pub fn endFromJS(this: *BrotliDecompressorSink, _: *JSGlobalObject) JSC.Node.Maybe(ArrayBuffer) {
|
||||
if (this.done) {
|
||||
return .{ .result = ArrayBuffer.fromBytes(&[_]u8{}, .ArrayBuffer) };
|
||||
pub fn endFromJS(this: *@This(), globalThis: *JSGlobalObject) JSC.Node.Maybe(JSValue) {
|
||||
if (this.state) |state| {
|
||||
state.deinit();
|
||||
this.state = null;
|
||||
}
|
||||
|
||||
std.debug.assert(this.next == null);
|
||||
var list = this.bytes.listManaged(this.allocator);
|
||||
this.bytes = bun.ByteList.init("");
|
||||
var list = this.output_buffer.listManaged(this.allocator);
|
||||
this.output_buffer = bun.ByteList.init("");
|
||||
this.done = true;
|
||||
this.signal.close(null);
|
||||
return .{ .result = ArrayBuffer.fromBytes(
|
||||
list.toOwnedSlice() catch @panic("TODO"),
|
||||
if (this.as_uint8array)
|
||||
.Uint8Array
|
||||
else
|
||||
.ArrayBuffer,
|
||||
) };
|
||||
return .{ .result = JSC.JSValue.createBuffer(globalThis, list.items, bun.default_allocator) };
|
||||
}
|
||||
|
||||
pub fn sink(this: *BrotliDecompressorSink) Sink {
|
||||
|
||||
@@ -54,6 +54,98 @@ pub const BrotliDecoderState = opaque {
|
||||
return BrotliDecoderGetErrorCode(self);
|
||||
}
|
||||
};
|
||||
|
||||
pub const BrotliEncoderState = opaque {
|
||||
pub fn init() *BrotliEncoderState {
|
||||
return BrotliEncoderCreateInstance(default_brotli_alloc_fn, default_brotli_free_fn, null);
|
||||
}
|
||||
|
||||
pub fn deinit(self: *BrotliEncoderState) void {
|
||||
BrotliEncoderDestroyInstance(self);
|
||||
}
|
||||
|
||||
pub fn setParameter(self: *BrotliEncoderState, param: BrotliEncoderParameter, value: u32) bool {
|
||||
return BrotliEncoderSetParameter(self, param, value) == BROTLI_TRUE;
|
||||
}
|
||||
|
||||
pub fn isFinished(self: *BrotliEncoderState) bool {
|
||||
return BrotliEncoderIsFinished(self) == BROTLI_TRUE;
|
||||
}
|
||||
|
||||
pub fn hasMoreOutput(self: *BrotliEncoderState) bool {
|
||||
return BrotliEncoderHasMoreOutput(self) == BROTLI_TRUE;
|
||||
}
|
||||
|
||||
/// Compresses input stream to output stream.
|
||||
///
|
||||
/// The values *available_in and *available_out must specify the number of
|
||||
/// bytes addressable at *next_in and *next_out respectively. When
|
||||
/// *available_out is 0, next_out is allowed to be NULL.
|
||||
///
|
||||
/// After each call, *available_in will be decremented by the amount of
|
||||
/// input bytes consumed, and the *next_in pointer will be incremented by that
|
||||
/// amount. Similarly, *available_out will be decremented by the amount of
|
||||
/// output bytes written, and the *next_out pointer will be incremented by
|
||||
/// that amount.
|
||||
///
|
||||
/// total_out, if it is not a null-pointer, will be set to the number of
|
||||
/// bytes decompressed since the last state initialization.
|
||||
///
|
||||
/// Internally workflow consists of 3 tasks:
|
||||
///
|
||||
/// (optionally) copy input data to internal buffer / actually compress data
|
||||
/// and (optionally) store it to internal buffer / (optionally) copy
|
||||
/// compressed bytes from internal buffer to output stream / Whenever all 3
|
||||
/// tasks can't move forward anymore, or error occurs, this method returns the
|
||||
/// control flow to caller.
|
||||
///
|
||||
/// op is used to perform flush, finish the stream, or inject metadata
|
||||
/// block. See BrotliEncoderOperation for more information.
|
||||
///
|
||||
/// Flushing the stream means forcing encoding of all input passed to /
|
||||
/// encoder and completing the current output block, so it could be fully /
|
||||
/// decoded by stream decoder. To perform flush set op to /
|
||||
/// BROTLI_OPERATION_FLUSH. Under some circumstances (e.g. lack of output /
|
||||
/// stream capacity) this operation would require several calls to /
|
||||
/// BrotliEncoderCompressStream. The method must be called again until both /
|
||||
/// input stream is depleted and encoder has no more output (see /
|
||||
/// BrotliEncoderHasMoreOutput) after the method is called.
|
||||
///
|
||||
/// Finishing the stream means encoding of all input passed to encoder and /
|
||||
/// adding specific "final" marks, so stream decoder could determine that /
|
||||
/// stream is complete. To perform finish set op to BROTLI_OPERATION_FINISH. /
|
||||
/// Under some circumstances (e.g. lack of output stream capacity) this /
|
||||
/// operation would require several calls to BrotliEncoderCompressStream. The
|
||||
/// method must be called again until both input stream is depleted and /
|
||||
/// encoder has no more output (see BrotliEncoderHasMoreOutput) after the /
|
||||
/// method is called.
|
||||
///
|
||||
/// Warning
|
||||
/// When flushing and finishing, op should not change until operation is complete; input stream should not be swapped, reduced or extended as well.
|
||||
pub fn compress(self: *BrotliEncoderState, op: BrotliEncoderOperation, input: *[]const u8, output: *[]u8, encoded_size: ?*usize) bool {
|
||||
var out: ?[*]u8 = output.ptr;
|
||||
var len = output.len;
|
||||
defer {
|
||||
output.len = len;
|
||||
if (out != null)
|
||||
output.ptr = out.?;
|
||||
}
|
||||
return BrotliEncoderCompressStream(self, op, &input.len, &input.ptr, &len, &out, encoded_size) == BROTLI_TRUE;
|
||||
}
|
||||
|
||||
pub fn write(self: *BrotliEncoderState, input: *[]const u8, output: *[]u8) bool {
|
||||
return compress(self, .process, input, output, null);
|
||||
}
|
||||
|
||||
pub fn flush(self: *BrotliEncoderState, input: *[]const u8, output: *[]u8) bool {
|
||||
return compress(self, .flush, input, output, null);
|
||||
}
|
||||
|
||||
pub fn finish(self: *BrotliEncoderState, input: *[]const u8, output: *[]u8) bool {
|
||||
return compress(self, .finish, input, output, null);
|
||||
}
|
||||
};
|
||||
|
||||
pub const BROTLI_DECODER_RESULT_ERROR: u32 = 0;
|
||||
pub const BROTLI_DECODER_RESULT_SUCCESS: u32 = 1;
|
||||
pub const BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: u32 = 2;
|
||||
@@ -134,7 +226,7 @@ pub const BrotliDecoderParameter = enum(u32) {
|
||||
};
|
||||
pub extern fn BrotliDecoderSetParameter(state: ?*BrotliDecoderState, param: BrotliEncoderParameter, value: u32) c_int;
|
||||
pub extern fn BrotliDecoderAttachDictionary(state: ?*BrotliDecoderState, @"type": BrotliSharedDictionaryType, data_size: usize, data: [*c]const u8) c_int;
|
||||
pub extern fn BrotliDecoderCreateInstance(alloc_func: brotli_alloc_func, free_func: brotli_free_func, @"opaque": ?*anyopaque) ?*BrotliDecoderState;
|
||||
pub extern fn BrotliDecoderCreateInstance(alloc_func: brotli_alloc_func, free_func: brotli_free_func, @"opaque": ?*anyopaque) *BrotliDecoderState;
|
||||
pub extern fn BrotliDecoderDestroyInstance(state: ?*BrotliDecoderState) void;
|
||||
pub extern fn BrotliDecoderDecompress(encoded_size: usize, encoded_buffer: [*]const u8, decoded_size: *usize, decoded_buffer: [*]u8) BrotliDecoderResult;
|
||||
pub extern fn BrotliDecoderDecompressStream(state: *BrotliDecoderState, available_in: *usize, next_in: *[*]const u8, available_out: *usize, next_out: *[*]u8, total_out: ?*usize) BrotliDecoderResult;
|
||||
@@ -202,10 +294,9 @@ pub const BrotliEncoderParameter = enum(u32) {
|
||||
stream_offset = BROTLI_PARAM_STREAM_OFFSET,
|
||||
_,
|
||||
};
|
||||
pub const struct_BrotliEncoderStateStruct = opaque {};
|
||||
pub const BrotliEncoderState = struct_BrotliEncoderStateStruct;
|
||||
|
||||
pub extern fn BrotliEncoderSetParameter(state: ?*BrotliEncoderState, param: BrotliEncoderParameter, value: u32) c_int;
|
||||
pub extern fn BrotliEncoderCreateInstance(alloc_func: brotli_alloc_func, free_func: brotli_free_func, ctx: ?*anyopaque) ?*BrotliEncoderState;
|
||||
pub extern fn BrotliEncoderCreateInstance(alloc_func: brotli_alloc_func, free_func: brotli_free_func, ctx: ?*anyopaque) *BrotliEncoderState;
|
||||
pub extern fn BrotliEncoderDestroyInstance(state: ?*BrotliEncoderState) void;
|
||||
pub const struct_BrotliEncoderPreparedDictionaryStruct = opaque {};
|
||||
pub const BrotliEncoderPreparedDictionary = struct_BrotliEncoderPreparedDictionaryStruct;
|
||||
@@ -214,10 +305,10 @@ pub extern fn BrotliEncoderDestroyPreparedDictionary(dictionary: ?*BrotliEncoder
|
||||
pub extern fn BrotliEncoderAttachPreparedDictionary(state: ?*BrotliEncoderState, dictionary: ?*const BrotliEncoderPreparedDictionary) c_int;
|
||||
pub extern fn BrotliEncoderMaxCompressedSize(input_size: usize) usize;
|
||||
pub extern fn BrotliEncoderCompress(quality: c_int, lgwin: c_int, mode: BrotliEncoderMode, input_size: usize, input_buffer: [*]const u8, encoded_size: *usize, encoded_buffer: [*]u8) c_int;
|
||||
pub extern fn BrotliEncoderCompressStream(state: *BrotliEncoderState, op: BrotliEncoderOperation, available_in: *usize, next_in: *[*]const u8, available_out: *usize, next_out: *?[*]u8, total_out: *usize) c_int;
|
||||
pub extern fn BrotliEncoderCompressStream(state: *BrotliEncoderState, op: BrotliEncoderOperation, available_in: *usize, next_in: *[*]const u8, available_out: *usize, next_out: *?[*]u8, total_out: ?*usize) c_int;
|
||||
pub extern fn BrotliEncoderIsFinished(state: *BrotliEncoderState) c_int;
|
||||
pub extern fn BrotliEncoderHasMoreOutput(state: *BrotliEncoderState) c_int;
|
||||
pub extern fn BrotliEncoderTakeOutput(state: *BrotliEncoderState, size: [*c]usize) [*c]const u8;
|
||||
pub extern fn BrotliEncoderTakeOutput(state: *BrotliEncoderState, size: *usize) ?[*]const u8;
|
||||
pub extern fn BrotliEncoderEstimatePeakMemoryUsage(quality: c_int, lgwin: c_int, input_size: usize) usize;
|
||||
pub extern fn BrotliEncoderGetPreparedDictionarySize(dictionary: ?*const BrotliEncoderPreparedDictionary) usize;
|
||||
pub extern fn BrotliEncoderVersion() u32;
|
||||
@@ -232,5 +323,4 @@ pub const BROTLI_MAX_QUALITY = @as(c_int, 11);
|
||||
pub const BROTLI_DEFAULT_QUALITY = @as(c_int, 11);
|
||||
pub const BROTLI_DEFAULT_WINDOW = @as(c_int, 22);
|
||||
pub const BROTLI_DEFAULT_MODE = BROTLI_MODE_GENERIC;
|
||||
pub const BrotliEncoderStateStruct = struct_BrotliEncoderStateStruct;
|
||||
pub const BrotliEncoderPreparedDictionaryStruct = struct_BrotliEncoderPreparedDictionaryStruct;
|
||||
|
||||
Reference in New Issue
Block a user