browser_oxide 0.1.3

Stealth headless browser engine in Rust: real HTML/CSS/DOM/JS, V8 via deno_core, own BoringSSL TLS/JA4 fingerprint, no Chromium, no CDP — for anti-bot web scraping, archival, and AI agents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
use crate::canvas::Canvas2D;
use deno_core::op2;
use deno_core::OpState;
use std::collections::HashMap;

/// Decoded image data stored for drawImage.
pub struct DecodedImage {
    pub rgba: Vec<u8>,
    pub width: u32,
    pub height: u32,
}

/// Canvas state stored in OpState.
pub struct CanvasState {
    canvases: HashMap<i32, Canvas2D>,
    images: HashMap<i32, DecodedImage>,
    next_id: i32,
}

impl Default for CanvasState {
    fn default() -> Self {
        Self::new()
    }
}

impl CanvasState {
    pub fn new() -> Self {
        Self {
            canvases: HashMap::new(),
            images: HashMap::new(),
            next_id: 1,
        }
    }
}

#[op2(fast)]
#[smi]
pub fn op_canvas_create(
    state: &mut OpState,
    #[smi] width: i32,
    #[smi] height: i32,
    #[string] os_name: String,
    #[bigint] canvas_seed: u64,
) -> i32 {
    let state = state.borrow_mut::<CanvasState>();
    let id = state.next_id;
    state.next_id += 1;
    if let Some(canvas) = Canvas2D::new(
        width.max(1) as u32,
        height.max(1) as u32,
        os_name,
        canvas_seed,
    ) {
        state.canvases.insert(id, canvas);
        id
    } else {
        -1
    }
}

#[op2(fast)]
pub fn op_canvas_fill_rect(state: &mut OpState, #[smi] id: i32, x: f64, y: f64, w: f64, h: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.fill_rect(x as f32, y as f32, w as f32, h as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_stroke_rect(state: &mut OpState, #[smi] id: i32, x: f64, y: f64, w: f64, h: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.stroke_rect(x as f32, y as f32, w as f32, h as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_clear_rect(state: &mut OpState, #[smi] id: i32, x: f64, y: f64, w: f64, h: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.clear_rect(x as f32, y as f32, w as f32, h as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_begin_path(state: &mut OpState, #[smi] id: i32) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.begin_path();
    }
}

#[op2(fast)]
pub fn op_canvas_move_to(state: &mut OpState, #[smi] id: i32, x: f64, y: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.move_to(x as f32, y as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_line_to(state: &mut OpState, #[smi] id: i32, x: f64, y: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.line_to(x as f32, y as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_fill(state: &mut OpState, #[smi] id: i32) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.fill();
    }
}

#[op2(fast)]
pub fn op_canvas_close_path(state: &mut OpState, #[smi] id: i32) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.close_path();
    }
}

#[op2(fast)]
pub fn op_canvas_arc(
    state: &mut OpState,
    #[smi] id: i32,
    x: f64,
    y: f64,
    r: f64,
    start: f64,
    end: f64,
    ccw: bool,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.arc(x as f32, y as f32, r as f32, start as f32, end as f32, ccw);
    }
}

#[op2(fast)]
pub fn op_canvas_arc_to(
    state: &mut OpState,
    #[smi] id: i32,
    x1: f64,
    y1: f64,
    x2: f64,
    y2: f64,
    radius: f64,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.arc_to(x1 as f32, y1 as f32, x2 as f32, y2 as f32, radius as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_ellipse(
    state: &mut OpState,
    #[smi] id: i32,
    cx: f64,
    cy: f64,
    rx: f64,
    ry: f64,
    rotation: f64,
    start: f64,
    end: f64,
    ccw: bool,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.ellipse(
            cx as f32,
            cy as f32,
            rx as f32,
            ry as f32,
            rotation as f32,
            start as f32,
            end as f32,
            ccw,
        );
    }
}

#[op2(fast)]
pub fn op_canvas_bezier_curve_to(
    state: &mut OpState,
    #[smi] id: i32,
    cp1x: f64,
    cp1y: f64,
    cp2x: f64,
    cp2y: f64,
    x: f64,
    y: f64,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.bezier_curve_to(
            cp1x as f32,
            cp1y as f32,
            cp2x as f32,
            cp2y as f32,
            x as f32,
            y as f32,
        );
    }
}

#[op2(fast)]
pub fn op_canvas_quadratic_curve_to(
    state: &mut OpState,
    #[smi] id: i32,
    cpx: f64,
    cpy: f64,
    x: f64,
    y: f64,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.quadratic_curve_to(cpx as f32, cpy as f32, x as f32, y as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_set_transform(
    state: &mut OpState,
    #[smi] id: i32,
    a: f64,
    b: f64,
    c_: f64,
    d: f64,
    e: f64,
    f: f64,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.set_transform(a as f32, b as f32, c_ as f32, d as f32, e as f32, f as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_reset_transform(state: &mut OpState, #[smi] id: i32) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.reset_transform();
    }
}

#[op2(fast)]
pub fn op_canvas_stroke(state: &mut OpState, #[smi] id: i32) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.stroke();
    }
}

#[op2(fast)]
pub fn op_canvas_fill_text(
    state: &mut OpState,
    #[smi] id: i32,
    #[string] text: &str,
    x: f64,
    y: f64,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.fill_text(text, x as f32, y as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_stroke_text(
    state: &mut OpState,
    #[smi] id: i32,
    #[string] text: &str,
    x: f64,
    y: f64,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.stroke_text(text, x as f32, y as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_set_fill_style(state: &mut OpState, #[smi] id: i32, #[string] color: &str) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.set_fill_color_str(color);
    }
}

#[op2(fast)]
pub fn op_canvas_set_stroke_style(state: &mut OpState, #[smi] id: i32, #[string] color: &str) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.set_stroke_color_str(color);
    }
}

#[op2(fast)]
pub fn op_canvas_set_font(state: &mut OpState, #[smi] id: i32, #[string] font: &str) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.set_font(font);
    }
}

#[op2(fast)]
pub fn op_canvas_set_line_width(state: &mut OpState, #[smi] id: i32, width: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.set_line_width(width as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_set_global_alpha(state: &mut OpState, #[smi] id: i32, alpha: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.set_global_alpha(alpha as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_save(state: &mut OpState, #[smi] id: i32) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.save();
    }
}

#[op2(fast)]
pub fn op_canvas_restore(state: &mut OpState, #[smi] id: i32) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.restore();
    }
}

#[op2(fast)]
pub fn op_canvas_translate(state: &mut OpState, #[smi] id: i32, x: f64, y: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.translate(x as f32, y as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_rotate(state: &mut OpState, #[smi] id: i32, angle: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.rotate(angle as f32);
    }
}

#[op2(fast)]
pub fn op_canvas_scale(state: &mut OpState, #[smi] id: i32, x: f64, y: f64) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.scale(x as f32, y as f32);
    }
}

#[op2]
#[string]
pub fn op_canvas_to_data_url(state: &mut OpState, #[smi] id: i32) -> String {
    let state = state.borrow::<CanvasState>();
    tracing::debug!("Canvas to_data_url called");
    state
        .canvases
        .get(&id)
        .map(|c| {
            let mut pixels = c.get_image_data(0, 0, c.width(), c.height());
            // Add tiny, invisible jitter to the lowest bit of random pixels
            // to break deterministic canvas fingerprinting.
            if !pixels.is_empty() {
                let mut rng = 0x9e3779b9u32; // Deterministic-ish seed
                for i in (0..pixels.len()).step_by(4) {
                    rng = rng.wrapping_mul(1103515245).wrapping_add(12345);
                    if (rng % 100) < 5 {
                        // Jitter 5% of pixels
                        pixels[i] = pixels[i].wrapping_add((rng & 1) as u8);
                        pixels[i + 1] = pixels[i + 1].wrapping_sub(((rng >> 1) & 1) as u8);
                        pixels[i + 2] = pixels[i + 2].wrapping_add(((rng >> 2) & 1) as u8);
                    }
                }
            }

            // Encode the jittered pixels to PNG base64
            // (Note: This requires a PNG encoder that can take raw RGBA)
            // For now, we'll use the existing to_data_url which uses tiny-skia's encoder.
            // To be truly SOTA we should encode our jittered buffer.

            // Falling back to standard for now as tiny-skia's Canvas2D doesn't
            // expose the raw buffer easily for re-encoding without extra crates.
            // Wait, Canvas2D is our own struct!
            c.to_data_url_with_jitter()
        })
        .unwrap_or_default()
}

#[op2(fast)]
pub fn op_canvas_measure_text(state: &mut OpState, #[smi] id: i32, #[string] text: &str) -> f64 {
    let state = state.borrow::<CanvasState>();
    state
        .canvases
        .get(&id)
        .map(|c| c.measure_text(text))
        .unwrap_or(0.0)
}

/// Serialized 13-field `TextMetrics` shape for
/// `CanvasRenderingContext2D.measureText`.
#[derive(serde::Serialize)]
pub struct JsTextMetrics {
    pub width: f32,
    pub actual_bounding_box_left: f32,
    pub actual_bounding_box_right: f32,
    pub actual_bounding_box_ascent: f32,
    pub actual_bounding_box_descent: f32,
    pub font_bounding_box_ascent: f32,
    pub font_bounding_box_descent: f32,
    pub em_height_ascent: f32,
    pub em_height_descent: f32,
    pub hanging_baseline: f32,
    pub alphabetic_baseline: f32,
    pub ideographic_baseline: f32,
}

impl JsTextMetrics {
    fn from_canvas(m: crate::canvas::text::TextMetrics) -> Self {
        Self {
            width: m.width,
            actual_bounding_box_left: m.actual_bounding_box_left,
            actual_bounding_box_right: m.actual_bounding_box_right,
            actual_bounding_box_ascent: m.actual_bounding_box_ascent,
            actual_bounding_box_descent: m.actual_bounding_box_descent,
            font_bounding_box_ascent: m.font_bounding_box_ascent,
            font_bounding_box_descent: m.font_bounding_box_descent,
            em_height_ascent: m.em_height_ascent,
            em_height_descent: m.em_height_descent,
            hanging_baseline: m.hanging_baseline,
            alphabetic_baseline: m.alphabetic_baseline,
            ideographic_baseline: m.ideographic_baseline,
        }
    }

    fn zero() -> Self {
        Self::from_canvas(crate::canvas::text::TextMetrics::zero())
    }
}

/// Full 13-field TextMetrics measurement — what real Chrome returns
/// from `measureText`. Uses the shaped-glyph bounding box for the
/// `actual_bounding_box_*` fields, which is the signal fingerprinters
/// actually probe.
#[op2]
#[serde]
pub fn op_canvas_measure_text_full(
    state: &mut OpState,
    #[smi] id: i32,
    #[string] text: &str,
) -> JsTextMetrics {
    let state = state.borrow::<CanvasState>();
    state
        .canvases
        .get(&id)
        .map(|c| JsTextMetrics::from_canvas(c.measure_text_metrics(text)))
        .unwrap_or_else(JsTextMetrics::zero)
}

/// Set fill style to a gradient.
/// gradient_type: "linear" or "radial"
/// coords: [x0, y0, x1, y1] for linear, [x0, y0, r0, x1, y1, r1] for radial
/// stops: JSON array of [offset, r, g, b, a] tuples
#[op2(fast)]
pub fn op_canvas_set_fill_gradient(
    state: &mut OpState,
    #[smi] id: i32,
    #[string] gradient_type: &str,
    #[string] params_json: &str,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(grad) = parse_gradient(gradient_type, params_json) {
        if let Some(c) = state.canvases.get_mut(&id) {
            c.set_fill_gradient(grad);
        }
    }
}

fn parse_gradient(gradient_type: &str, json: &str) -> Option<crate::canvas::canvas2d::Gradient> {
    let val: serde_json::Value = serde_json::from_str(json).ok()?;
    let coords = val.get("coords")?.as_array()?;
    let stops_arr = val.get("stops")?.as_array()?;

    let mut stops = Vec::new();
    for s in stops_arr {
        let offset = s.get(0)?.as_f64()? as f32;
        let r = s.get(1)?.as_f64()? as u8;
        let g = s.get(2)?.as_f64()? as u8;
        let b = s.get(3)?.as_f64()? as u8;
        let a = s.get(4).and_then(|v| v.as_f64()).unwrap_or(255.0) as u8;
        // Use canvas's parse_css_color equivalent — construct directly
        // Canvas2D uses tiny_skia::Color but we don't depend on tiny_skia here
        // Store as (offset, r, g, b, a) tuples and let Canvas2D convert
        stops.push((offset, crate::canvas::canvas2d::make_color(r, g, b, a)));
    }

    match gradient_type {
        "linear" => Some(crate::canvas::canvas2d::Gradient::Linear {
            x0: coords.first()?.as_f64()? as f32,
            y0: coords.get(1)?.as_f64()? as f32,
            x1: coords.get(2)?.as_f64()? as f32,
            y1: coords.get(3)?.as_f64()? as f32,
            stops,
        }),
        "radial" => Some(crate::canvas::canvas2d::Gradient::Radial {
            x0: coords.first()?.as_f64()? as f32,
            y0: coords.get(1)?.as_f64()? as f32,
            r0: coords.get(2)?.as_f64()? as f32,
            x1: coords.get(3)?.as_f64()? as f32,
            y1: coords.get(4)?.as_f64()? as f32,
            r1: coords.get(5)?.as_f64()? as f32,
            stops,
        }),
        _ => None,
    }
}

/// Get image data (RGBA, non-premultiplied) from a canvas region.
#[op2]
#[serde]
pub fn op_canvas_get_image_data(
    state: &mut OpState,
    #[smi] id: i32,
    #[smi] x: i32,
    #[smi] y: i32,
    #[smi] w: i32,
    #[smi] h: i32,
) -> Vec<u8> {
    let state = state.borrow::<CanvasState>();
    state
        .canvases
        .get(&id)
        .map(|c| c.get_image_data(x as u32, y as u32, w as u32, h as u32))
        .unwrap_or_default()
}

/// Put image data onto a canvas at a position.
#[op2(fast)]
pub fn op_canvas_put_image_data(
    state: &mut OpState,
    #[smi] id: i32,
    #[buffer] data: &[u8],
    #[smi] x: i32,
    #[smi] y: i32,
    #[smi] w: i32,
    #[smi] h: i32,
) {
    let state = state.borrow_mut::<CanvasState>();
    if let Some(c) = state.canvases.get_mut(&id) {
        c.put_image_data(data, x as u32, y as u32, w as u32, h as u32);
    }
}

/// Draw one canvas onto another (canvas-to-canvas compositing).
#[op2(fast)]
pub fn op_canvas_draw_image(
    state: &mut OpState,
    #[smi] dst_id: i32,
    #[smi] src_id: i32,
    dx: f64,
    dy: f64,
) {
    let state = state.borrow_mut::<CanvasState>();
    // Get source pixels
    let src_pixels = state.canvases.get(&src_id).map(|c| {
        (
            c.get_image_data(0, 0, c.width(), c.height()),
            c.width(),
            c.height(),
        )
    });
    if let Some((data, sw, sh)) = src_pixels {
        if let Some(dst) = state.canvases.get_mut(&dst_id) {
            dst.put_image_data(&data, dx as u32, dy as u32, sw, sh);
        }
    }
}

/// Decode image from a base64-encoded string, store in canvas state, return ID.
#[op2(fast)]
#[smi]
pub fn op_image_decode_base64(state: &mut OpState, #[string] b64: &str) -> i32 {
    let state = state.borrow_mut::<CanvasState>();
    let bytes = match base64::Engine::decode(&base64::engine::general_purpose::STANDARD, b64) {
        Ok(b) => b,
        Err(_) => return -1,
    };
    match crate::canvas::Canvas2D::decode_image(&bytes) {
        Some((rgba, w, h)) => {
            let id = state.next_id;
            state.next_id += 1;
            state.images.insert(
                id,
                DecodedImage {
                    rgba,
                    width: w,
                    height: h,
                },
            );
            id
        }
        None => -1,
    }
}

/// Draw a decoded image onto a canvas.
#[op2(fast)]
pub fn op_canvas_draw_decoded_image(
    state: &mut OpState,
    #[smi] canvas_id: i32,
    #[smi] image_id: i32,
    dx: f64,
    dy: f64,
) {
    let state = state.borrow_mut::<CanvasState>();
    let img = match state.images.get(&image_id) {
        Some(i) => i,
        None => return,
    };
    let rgba = img.rgba.clone();
    let w = img.width;
    let h = img.height;
    if let Some(c) = state.canvases.get_mut(&canvas_id) {
        c.draw_image_pixels(&rgba, w, h, dx as f32, dy as f32);
    }
}

deno_core::extension!(
    canvas_extension,
    ops = [
        op_canvas_create,
        op_canvas_fill_rect,
        op_canvas_stroke_rect,
        op_canvas_clear_rect,
        op_canvas_begin_path,
        op_canvas_close_path,
        op_canvas_arc,
        op_canvas_arc_to,
        op_canvas_ellipse,
        op_canvas_bezier_curve_to,
        op_canvas_quadratic_curve_to,
        op_canvas_set_transform,
        op_canvas_reset_transform,
        op_canvas_move_to,
        op_canvas_line_to,
        op_canvas_fill,
        op_canvas_stroke,
        op_canvas_fill_text,
        op_canvas_stroke_text,
        op_canvas_set_fill_style,
        op_canvas_set_stroke_style,
        op_canvas_set_font,
        op_canvas_set_line_width,
        op_canvas_set_global_alpha,
        op_canvas_save,
        op_canvas_restore,
        op_canvas_translate,
        op_canvas_rotate,
        op_canvas_scale,
        op_canvas_to_data_url,
        op_canvas_measure_text,
        op_canvas_measure_text_full,
        op_canvas_get_image_data,
        op_canvas_put_image_data,
        op_canvas_draw_image,
        op_canvas_set_fill_gradient,
        op_image_decode_base64,
        op_canvas_draw_decoded_image,
    ],
);