move createTypedArray to Local

This commit is contained in:
Halil Durak
2026-02-19 10:03:04 +03:00
parent 95920bf207
commit abab10b2cc
3 changed files with 7 additions and 8 deletions

View File

@@ -1045,13 +1045,6 @@ pub const FinalizerCallback = struct {
}
};
/// Creates a new typed array. Memory is owned by JS context.
/// If storing the type in a Zig type is desired, prefer `.global` state to persist.
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Typed_arrays
pub fn createTypedArray(self: *const Context, comptime array_type: js.ArrayType, size: usize) js.ArrayBufferRef(array_type) {
return .init(self.local.?, size);
}
// == Profiler ==
pub fn startCpuProfiler(self: *Context) void {
if (comptime !IS_DEBUG) {

View File

@@ -75,6 +75,12 @@ pub fn newArray(self: *const Local, len: u32) js.Array {
};
}
/// Creates a new typed array. Memory is owned by JS context.
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Typed_arrays
pub fn createTypedArray(self: *const Local, comptime array_type: js.ArrayType, size: usize) js.ArrayBufferRef(array_type) {
return .init(self, size);
}
pub fn runMicrotasks(self: *const Local) void {
self.isolate.performMicrotasksCheckpoint();
}

View File

@@ -74,7 +74,7 @@ pub fn constructor(
return page._factory.create(ImageData{
._width = width,
._height = height,
._data = try page.js.createTypedArray(.uint8_clamped, size).persist(),
._data = try page.js.local.?.createTypedArray(.uint8_clamped, size).persist(),
});
}