This commit is contained in:
2025-05-09 05:30:08 +02:00
parent 7bb10e7df4
commit 73367bad9e
5322 changed files with 1266973 additions and 313 deletions

View File

@@ -0,0 +1 @@
module.exports={C:{"34":0.00443,"37":0.00886,"48":0.02216,"52":0.01772,"66":0.00443,"78":0.02216,"88":0.00443,"102":0.01329,"113":0.00443,"115":0.12407,"125":0.00443,"127":0.00886,"128":0.04874,"131":0.00443,"132":0.00443,"133":0.01772,"134":0.02216,"135":0.39879,"136":1.42235,"137":0.00886,_:"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 35 36 38 39 40 41 42 43 44 45 46 47 49 50 51 53 54 55 56 57 58 59 60 61 62 63 64 65 67 68 69 70 71 72 73 74 75 76 77 79 80 81 82 83 84 85 86 87 89 90 91 92 93 94 95 96 97 98 99 100 101 103 104 105 106 107 108 109 110 111 112 114 116 117 118 119 120 121 122 123 124 126 129 130 138 139 140 3.5 3.6"},D:{"34":0.00443,"38":0.04431,"39":0.0709,"40":0.0709,"41":0.0709,"42":0.0709,"43":0.0709,"44":0.0709,"45":0.0709,"46":0.0709,"47":0.0709,"48":0.0709,"49":0.18167,"50":0.0709,"51":0.0709,"52":0.06647,"53":0.0709,"54":0.0709,"55":0.0709,"56":0.0709,"57":0.0709,"58":0.0709,"59":0.0709,"60":0.0709,"61":0.00443,"65":0.00443,"71":0.00443,"72":0.00443,"76":0.00443,"78":0.00443,"79":0.03545,"83":0.00443,"86":0.00443,"87":0.02659,"88":0.00443,"90":0.15952,"93":0.02216,"94":0.01772,"95":0.00443,"96":0.00443,"97":0.00886,"99":0.00443,"101":0.00443,"102":0.00443,"103":0.15065,"104":0.00443,"105":0.00443,"106":0.00443,"107":0.00443,"108":0.03545,"109":0.42981,"110":0.00886,"111":0.01772,"112":0.01329,"113":0.03102,"114":0.04874,"115":0.00443,"116":0.15952,"117":0.00443,"118":0.00443,"119":0.03102,"120":0.04874,"121":0.03545,"122":0.10191,"123":0.03545,"124":0.07533,"125":0.0576,"126":0.11078,"127":0.03988,"128":0.15509,"129":0.0709,"130":0.11964,"131":0.53172,"132":0.70453,"133":8.44992,"134":13.45252,"135":0.02659,"136":0.01772,_:"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 35 36 37 62 63 64 66 67 68 69 70 73 74 75 77 80 81 84 85 89 91 92 98 100 137 138"},F:{"45":0.00443,"46":0.01772,"87":0.00886,"88":0.00443,"95":0.01772,"114":0.00443,"115":0.00886,"116":0.20826,"117":0.55831,_:"9 11 12 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 47 48 49 50 51 52 53 54 55 56 57 58 60 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 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"18":0.00886,"92":0.00443,"105":0.00443,"109":0.02659,"111":0.00443,"113":0.00443,"114":0.00443,"117":0.00443,"119":0.00443,"120":0.00443,"121":0.00443,"122":0.00443,"123":0.00443,"124":0.00443,"125":0.00886,"126":0.00443,"127":0.01329,"128":0.00886,"129":0.00443,"130":0.02659,"131":0.05317,"132":0.09305,"133":1.85659,"134":4.27148,_:"12 13 14 15 16 17 79 80 81 83 84 85 86 87 88 89 90 91 93 94 95 96 97 98 99 100 101 102 103 104 106 107 108 110 112 115 116 118"},E:{"13":0.01329,"14":0.02659,"15":0.00886,_:"0 4 5 6 7 8 9 10 11 12 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1","12.1":0.00886,"13.1":0.06647,"14.1":0.09305,"15.1":0.00886,"15.2-15.3":0.01772,"15.4":0.01329,"15.5":0.02659,"15.6":0.40765,"16.0":0.06203,"16.1":0.0709,"16.2":0.03988,"16.3":0.08862,"16.4":0.01772,"16.5":0.03988,"16.6":0.51843,"17.0":0.02216,"17.1":0.35005,"17.2":0.04431,"17.3":0.03988,"17.4":0.06203,"17.5":0.16395,"17.6":0.61148,"18.0":0.03545,"18.1":0.23484,"18.2":0.08419,"18.3":2.76051,"18.4":0.01772},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00266,"5.0-5.1":0,"6.0-6.1":0.00798,"7.0-7.1":0.00532,"8.1-8.4":0,"9.0-9.2":0.00399,"9.3":0.01861,"10.0-10.2":0.00133,"10.3":0.03058,"11.0-11.2":0.14094,"11.3-11.4":0.00931,"12.0-12.1":0.00532,"12.2-12.5":0.13163,"13.0-13.1":0.00266,"13.2":0.00399,"13.3":0.00532,"13.4-13.7":0.01861,"14.0-14.4":0.04654,"14.5-14.8":0.05584,"15.0-15.1":0.03058,"15.2-15.3":0.03058,"15.4":0.03723,"15.5":0.04255,"15.6-15.8":0.52388,"16.0":0.07446,"16.1":0.15291,"16.2":0.07978,"16.3":0.13828,"16.4":0.03058,"16.5":0.05717,"16.6-16.7":0.62094,"17.0":0.03723,"17.1":0.06648,"17.2":0.05053,"17.3":0.07047,"17.4":0.14094,"17.5":0.31379,"17.6-17.7":0.9108,"18.0":0.25529,"18.1":0.83501,"18.2":0.37363,"18.3":7.80897,"18.4":0.11568},P:{"4":0.09527,"21":0.02117,"22":0.02117,"23":0.02117,"24":0.02117,"25":0.03176,"26":0.05293,"27":2.36063,_:"20 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 16.0 17.0 18.0 19.0","5.0-5.4":0.01059,"6.2-6.4":0.01059,"7.2-7.4":0.02117,"15.0":0.01059},I:{"0":0.01667,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00002},K:{"0":0.17818,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.10634,_:"6 7 8 9 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.66816},Q:{"14.9":0.02784},O:{"0":0.06125},H:{"0":0},L:{"0":39.03633}};

View File

@@ -0,0 +1,5 @@
/// <reference path="./importMeta.d.ts" />
// https://github.com/microsoft/TypeScript/issues/45096
// TypeScript has a bug that makes <reference types="vite/types/importMeta" />
// not possible in userland. This file provides a workaround for now.

View File

@@ -0,0 +1,70 @@
# Authors
#### Ordered by first contribution.
- Romain Beauxis (toots@rastageeks.org)
- Tobias Koppers (tobias.koppers@googlemail.com)
- Janus (ysangkok@gmail.com)
- Rainer Dreyer (rdrey1@gmail.com)
- Tõnis Tiigi (tonistiigi@gmail.com)
- James Halliday (mail@substack.net)
- Michael Williamson (mike@zwobble.org)
- elliottcable (github@elliottcable.name)
- rafael (rvalle@livelens.net)
- Andrew Kelley (superjoe30@gmail.com)
- Andreas Madsen (amwebdk@gmail.com)
- Mike Brevoort (mike.brevoort@pearson.com)
- Brian White (mscdex@mscdex.net)
- Feross Aboukhadijeh (feross@feross.org)
- Ruben Verborgh (ruben@verborgh.org)
- eliang (eliang.cs@gmail.com)
- Jesse Tane (jesse.tane@gmail.com)
- Alfonso Boza (alfonso@cloud.com)
- Mathias Buus (mathiasbuus@gmail.com)
- Devon Govett (devongovett@gmail.com)
- Daniel Cousens (github@dcousens.com)
- Joseph Dykstra (josephdykstra@gmail.com)
- Parsha Pourkhomami (parshap+git@gmail.com)
- Damjan Košir (damjan.kosir@gmail.com)
- daverayment (dave.rayment@gmail.com)
- kawanet (u-suke@kawa.net)
- Linus Unnebäck (linus@folkdatorn.se)
- Nolan Lawson (nolan.lawson@gmail.com)
- Calvin Metcalf (calvin.metcalf@gmail.com)
- Koki Takahashi (hakatasiloving@gmail.com)
- Guy Bedford (guybedford@gmail.com)
- Jan Schär (jscissr@gmail.com)
- RaulTsc (tomescu.raul@gmail.com)
- Matthieu Monsch (monsch@alum.mit.edu)
- Dan Ehrenberg (littledan@chromium.org)
- Kirill Fomichev (fanatid@ya.ru)
- Yusuke Kawasaki (u-suke@kawa.net)
- DC (dcposch@dcpos.ch)
- John-David Dalton (john.david.dalton@gmail.com)
- adventure-yunfei (adventure030@gmail.com)
- Emil Bay (github@tixz.dk)
- Sam Sudar (sudar.sam@gmail.com)
- Volker Mische (volker.mische@gmail.com)
- David Walton (support@geekstocks.com)
- Сковорода Никита Андреевич (chalkerx@gmail.com)
- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com)
- ukstv (sergey.ukustov@machinomy.com)
- Renée Kooi (renee@kooi.me)
- ranbochen (ranbochen@qq.com)
- Vladimir Borovik (bobahbdb@gmail.com)
- greenkeeper[bot] (23040076+greenkeeper[bot]@users.noreply.github.com)
- kumavis (aaron@kumavis.me)
- Sergey Ukustov (sergey.ukustov@machinomy.com)
- Fei Liu (liu.feiwood@gmail.com)
- Blaine Bublitz (blaine.bublitz@gmail.com)
- clement (clement@seald.io)
- Koushik Dutta (koushd@gmail.com)
- Jordan Harband (ljharb@gmail.com)
- Niklas Mischkulnig (mischnic@users.noreply.github.com)
- Nikolai Vavilov (vvnicholas@gmail.com)
- Fedor Nezhivoi (gyzerok@users.noreply.github.com)
- Peter Newman (peternewman@users.noreply.github.com)
- mathmakgakpak (44949126+mathmakgakpak@users.noreply.github.com)
- jkkang (jkkang@smartauth.kr)
#### Generated by bin/update-authors.sh.

View File

@@ -0,0 +1,42 @@
const fs = require('fs');
const path = require('path');
const flatted = require('flatted');
function tryParse(filePath, defaultValue) {
let result;
try {
result = readJSON(filePath);
} catch (ex) {
result = defaultValue;
}
return result;
}
/**
* Read json file synchronously using flatted
*
* @param {String} filePath Json filepath
* @returns {*} parse result
*/
function readJSON(filePath) {
return flatted.parse(
fs.readFileSync(filePath, {
encoding: 'utf8',
})
);
}
/**
* Write json file synchronously using circular-json
*
* @param {String} filePath Json filepath
* @param {*} data Object to serialize
*/
function writeJSON(filePath, data) {
fs.mkdirSync(path.dirname(filePath), {
recursive: true,
});
fs.writeFileSync(filePath, flatted.stringify(data));
}
module.exports = { tryParse, readJSON, writeJSON };

View File

@@ -0,0 +1 @@
{"version":3,"names":["_arrayWithoutHoles","require","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","_toConsumableArray","arr","arrayWithoutHoles","iterableToArray","unsupportedIterableToArray","nonIterableSpread"],"sources":["../../src/helpers/toConsumableArray.ts"],"sourcesContent":["/* @minVersion 7.0.0-beta.0 */\n\nimport arrayWithoutHoles from \"./arrayWithoutHoles.ts\";\nimport iterableToArray from \"./iterableToArray.ts\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.ts\";\n// @ts-expect-error nonIterableSpread is still being converted to TS.\nimport nonIterableSpread from \"./nonIterableSpread.ts\";\n\nexport default function _toConsumableArray<T>(arr: any): T[] {\n return (\n arrayWithoutHoles<T>(arr) ||\n iterableToArray<T>(arr) ||\n unsupportedIterableToArray<T>(arr) ||\n nonIterableSpread()\n );\n}\n"],"mappings":";;;;;;AAEA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,2BAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,GAAAH,OAAA;AAEe,SAASI,kBAAkBA,CAAIC,GAAQ,EAAO;EAC3D,OACE,IAAAC,0BAAiB,EAAID,GAAG,CAAC,IACzB,IAAAE,wBAAe,EAAIF,GAAG,CAAC,IACvB,IAAAG,mCAA0B,EAAIH,GAAG,CAAC,IAClC,IAAAI,0BAAiB,EAAC,CAAC;AAEvB","ignoreList":[]}

View File

@@ -0,0 +1,21 @@
'use strict'
const tape = require('tape')
const { BufferList, BufferListStream } = require('../')
const { Buffer } = require('buffer')
tape('convert from BufferList to BufferListStream', (t) => {
const data = Buffer.from(`TEST-${Date.now()}`)
const bl = new BufferList(data)
const bls = new BufferListStream(bl)
t.ok(bl.slice().equals(bls.slice()))
t.end()
})
tape('convert from BufferListStream to BufferList', (t) => {
const data = Buffer.from(`TEST-${Date.now()}`)
const bls = new BufferListStream(data)
const bl = new BufferList(bls)
t.ok(bl.slice().equals(bls.slice()))
t.end()
})

View File

@@ -0,0 +1,9 @@
import { useContext } from 'react';
import DocumentContext from '../../DocumentContext.js';
import type { DocumentContextType } from '../types.js';
export default function useDocumentContext(): DocumentContextType {
return useContext(DocumentContext);
}

View File

@@ -0,0 +1,232 @@
// Copyright (c) 2010 LearnBoost <tj@learnboost.com>
#pragma once
#include "cairo.h"
#include "Canvas.h"
#include "color.h"
#include "napi.h"
#include <pango/pangocairo.h>
#include <stack>
/*
* State struct.
*
* Used in conjunction with Save() / Restore() since
* cairo's gstate maintains only a single source pattern at a time.
*/
struct canvas_state_t {
rgba_t fill = { 0, 0, 0, 1 };
rgba_t stroke = { 0, 0, 0, 1 };
rgba_t shadow = { 0, 0, 0, 0 };
double shadowOffsetX = 0.;
double shadowOffsetY = 0.;
cairo_pattern_t* fillPattern = nullptr;
cairo_pattern_t* strokePattern = nullptr;
cairo_pattern_t* fillGradient = nullptr;
cairo_pattern_t* strokeGradient = nullptr;
PangoFontDescription* fontDescription = nullptr;
std::string font = "10px sans-serif";
cairo_filter_t patternQuality = CAIRO_FILTER_GOOD;
float globalAlpha = 1.f;
int shadowBlur = 0;
text_align_t textAlignment = TEXT_ALIGNMENT_START;
text_baseline_t textBaseline = TEXT_BASELINE_ALPHABETIC;
canvas_draw_mode_t textDrawingMode = TEXT_DRAW_PATHS;
bool imageSmoothingEnabled = true;
std::string direction = "ltr";
canvas_state_t() {
fontDescription = pango_font_description_from_string("sans");
pango_font_description_set_absolute_size(fontDescription, 10 * PANGO_SCALE);
}
canvas_state_t(const canvas_state_t& other) {
fill = other.fill;
stroke = other.stroke;
patternQuality = other.patternQuality;
fillPattern = other.fillPattern;
strokePattern = other.strokePattern;
fillGradient = other.fillGradient;
strokeGradient = other.strokeGradient;
globalAlpha = other.globalAlpha;
textAlignment = other.textAlignment;
textBaseline = other.textBaseline;
shadow = other.shadow;
shadowBlur = other.shadowBlur;
shadowOffsetX = other.shadowOffsetX;
shadowOffsetY = other.shadowOffsetY;
textDrawingMode = other.textDrawingMode;
fontDescription = pango_font_description_copy(other.fontDescription);
font = other.font;
imageSmoothingEnabled = other.imageSmoothingEnabled;
}
~canvas_state_t() {
pango_font_description_free(fontDescription);
}
};
/*
* Equivalent to a PangoRectangle but holds floats instead of ints
* (software pixels are stored here instead of pango units)
*
* Should be compatible with PANGO_ASCENT, PANGO_LBEARING, etc.
*/
typedef struct {
float x;
float y;
float width;
float height;
} float_rectangle;
class Context2d : public Napi::ObjectWrap<Context2d> {
public:
std::stack<canvas_state_t> states;
canvas_state_t *state;
Context2d(const Napi::CallbackInfo& info);
static void Initialize(Napi::Env& env, Napi::Object& target);
void DrawImage(const Napi::CallbackInfo& info);
void PutImageData(const Napi::CallbackInfo& info);
void Save(const Napi::CallbackInfo& info);
void Restore(const Napi::CallbackInfo& info);
void Rotate(const Napi::CallbackInfo& info);
void Translate(const Napi::CallbackInfo& info);
void Scale(const Napi::CallbackInfo& info);
void Transform(const Napi::CallbackInfo& info);
Napi::Value GetTransform(const Napi::CallbackInfo& info);
void ResetTransform(const Napi::CallbackInfo& info);
void SetTransform(const Napi::CallbackInfo& info);
Napi::Value IsPointInPath(const Napi::CallbackInfo& info);
void BeginPath(const Napi::CallbackInfo& info);
void ClosePath(const Napi::CallbackInfo& info);
void AddPage(const Napi::CallbackInfo& info);
void Clip(const Napi::CallbackInfo& info);
void Fill(const Napi::CallbackInfo& info);
void Stroke(const Napi::CallbackInfo& info);
void FillText(const Napi::CallbackInfo& info);
void StrokeText(const Napi::CallbackInfo& info);
static Napi::Value SetFont(const Napi::CallbackInfo& info);
static Napi::Value SetFillColor(const Napi::CallbackInfo& info);
static Napi::Value SetStrokeColor(const Napi::CallbackInfo& info);
static Napi::Value SetStrokePattern(const Napi::CallbackInfo& info);
static Napi::Value SetTextAlignment(const Napi::CallbackInfo& info);
void SetLineDash(const Napi::CallbackInfo& info);
Napi::Value GetLineDash(const Napi::CallbackInfo& info);
Napi::Value MeasureText(const Napi::CallbackInfo& info);
void BezierCurveTo(const Napi::CallbackInfo& info);
void QuadraticCurveTo(const Napi::CallbackInfo& info);
void LineTo(const Napi::CallbackInfo& info);
void MoveTo(const Napi::CallbackInfo& info);
void FillRect(const Napi::CallbackInfo& info);
void StrokeRect(const Napi::CallbackInfo& info);
void ClearRect(const Napi::CallbackInfo& info);
void Rect(const Napi::CallbackInfo& info);
void RoundRect(const Napi::CallbackInfo& info);
void Arc(const Napi::CallbackInfo& info);
void ArcTo(const Napi::CallbackInfo& info);
void Ellipse(const Napi::CallbackInfo& info);
Napi::Value GetImageData(const Napi::CallbackInfo& info);
Napi::Value CreateImageData(const Napi::CallbackInfo& info);
static Napi::Value GetStrokeColor(const Napi::CallbackInfo& info);
Napi::Value CreatePattern(const Napi::CallbackInfo& info);
Napi::Value CreateLinearGradient(const Napi::CallbackInfo& info);
Napi::Value CreateRadialGradient(const Napi::CallbackInfo& info);
Napi::Value GetFormat(const Napi::CallbackInfo& info);
Napi::Value GetPatternQuality(const Napi::CallbackInfo& info);
Napi::Value GetImageSmoothingEnabled(const Napi::CallbackInfo& info);
Napi::Value GetGlobalCompositeOperation(const Napi::CallbackInfo& info);
Napi::Value GetGlobalAlpha(const Napi::CallbackInfo& info);
Napi::Value GetShadowColor(const Napi::CallbackInfo& info);
Napi::Value GetMiterLimit(const Napi::CallbackInfo& info);
Napi::Value GetLineCap(const Napi::CallbackInfo& info);
Napi::Value GetLineJoin(const Napi::CallbackInfo& info);
Napi::Value GetLineWidth(const Napi::CallbackInfo& info);
Napi::Value GetLineDashOffset(const Napi::CallbackInfo& info);
Napi::Value GetShadowOffsetX(const Napi::CallbackInfo& info);
Napi::Value GetShadowOffsetY(const Napi::CallbackInfo& info);
Napi::Value GetShadowBlur(const Napi::CallbackInfo& info);
Napi::Value GetAntiAlias(const Napi::CallbackInfo& info);
Napi::Value GetTextDrawingMode(const Napi::CallbackInfo& info);
Napi::Value GetQuality(const Napi::CallbackInfo& info);
Napi::Value GetCurrentTransform(const Napi::CallbackInfo& info);
Napi::Value GetFillStyle(const Napi::CallbackInfo& info);
Napi::Value GetStrokeStyle(const Napi::CallbackInfo& info);
Napi::Value GetFont(const Napi::CallbackInfo& info);
Napi::Value GetTextBaseline(const Napi::CallbackInfo& info);
Napi::Value GetTextAlign(const Napi::CallbackInfo& info);
void SetPatternQuality(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetImageSmoothingEnabled(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetGlobalCompositeOperation(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetGlobalAlpha(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetShadowColor(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetMiterLimit(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetLineCap(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetLineJoin(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetLineWidth(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetLineDashOffset(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetShadowOffsetX(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetShadowOffsetY(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetShadowBlur(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetAntiAlias(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetTextDrawingMode(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetQuality(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetCurrentTransform(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetFillStyle(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetStrokeStyle(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetFont(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetTextBaseline(const Napi::CallbackInfo& info, const Napi::Value& value);
void SetTextAlign(const Napi::CallbackInfo& info, const Napi::Value& value);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 16, 0)
void BeginTag(const Napi::CallbackInfo& info);
void EndTag(const Napi::CallbackInfo& info);
#endif
Napi::Value GetDirection(const Napi::CallbackInfo& info);
void SetDirection(const Napi::CallbackInfo& info, const Napi::Value& value);
inline void setContext(cairo_t *ctx) { _context = ctx; }
inline cairo_t *context(){ return _context; }
inline Canvas *canvas(){ return _canvas; }
inline bool hasShadow();
void inline setSourceRGBA(rgba_t color);
void inline setSourceRGBA(cairo_t *ctx, rgba_t color);
void setTextPath(double x, double y);
void blur(cairo_surface_t *surface, int radius);
void shadow(void (fn)(cairo_t *cr));
void shadowStart();
void shadowApply();
void savePath();
void restorePath();
void saveState();
void restoreState();
void inline setFillRule(Napi::Value value);
void fill(bool preserve = false);
void stroke(bool preserve = false);
void save();
void restore();
void setFontFromState();
void resetState();
inline PangoLayout *layout(){ return _layout; }
~Context2d();
Napi::Env env;
private:
void _resetPersistentHandles();
Napi::Value _getFillColor();
Napi::Value _getStrokeColor();
Napi::Value get_current_transform();
void _setFillColor(Napi::Value arg);
void _setFillPattern(Napi::Value arg);
void _setStrokeColor(Napi::Value arg);
void _setStrokePattern(Napi::Value arg);
void checkFonts();
void paintText(const Napi::CallbackInfo&, bool);
Napi::Reference<Napi::Value> _fillStyle;
Napi::Reference<Napi::Value> _strokeStyle;
Canvas *_canvas;
cairo_t *_context = nullptr;
cairo_path_t *_path;
PangoLayout *_layout = nullptr;
int fontSerial = 1;
};

View File

@@ -0,0 +1,360 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { render } from '@testing-library/react';
import { pdfjs } from '../index.test.js';
import AnnotationLayer from './AnnotationLayer.js';
import LinkService from '../LinkService.js';
import failingPage from '../../../../__mocks__/_failing_page.js';
import { loadPDF, makeAsyncCallback, muteConsole, restoreConsole } from '../../../../test-utils.js';
import DocumentContext from '../DocumentContext.js';
import PageContext from '../PageContext.js';
import type { RenderResult } from '@testing-library/react';
import type { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist';
import type { Annotations, DocumentContextType, PageContextType } from '../shared/types.js';
const pdfFile = loadPDF('./../../__mocks__/_pdf.pdf');
const annotatedPdfFile = loadPDF('./../../__mocks__/_pdf3.pdf');
function renderWithContext(
children: React.ReactNode,
documentContext: Partial<DocumentContextType>,
pageContext: Partial<PageContextType>,
) {
const { rerender, ...otherResult } = render(
<DocumentContext.Provider value={documentContext as DocumentContextType}>
<PageContext.Provider value={pageContext as PageContextType}>{children}</PageContext.Provider>
</DocumentContext.Provider>,
);
const customRerender = (
nextChildren: React.ReactNode,
nextDocumentContext: Partial<DocumentContextType> = documentContext,
nextPageContext: Partial<PageContextType> = pageContext,
) =>
rerender(
<DocumentContext.Provider value={nextDocumentContext as DocumentContextType}>
<PageContext.Provider value={nextPageContext as PageContextType}>
{nextChildren}
</PageContext.Provider>
</DocumentContext.Provider>,
);
return {
...otherResult,
rerender: customRerender,
} as RenderResult & { rerender: typeof customRerender };
}
describe('AnnotationLayer', () => {
const linkService = new LinkService();
// Loaded PDF file
let pdf: PDFDocumentProxy;
// Loaded page
let page: PDFPageProxy;
let page2: PDFPageProxy;
// Loaded page text items
let desiredAnnotations: Annotations;
let desiredAnnotations2: Annotations;
beforeAll(async () => {
pdf = await pdfjs.getDocument({ data: pdfFile.arrayBuffer }).promise;
page = await pdf.getPage(1);
desiredAnnotations = await page.getAnnotations();
page2 = await pdf.getPage(2);
desiredAnnotations2 = await page2.getAnnotations();
});
describe('loading', () => {
it('loads annotations and calls onGetAnnotationsSuccess callback properly', async () => {
const { func: onGetAnnotationsSuccess, promise: onGetAnnotationsSuccessPromise } =
makeAsyncCallback();
renderWithContext(
<AnnotationLayer />,
{
linkService,
pdf,
},
{
onGetAnnotationsSuccess,
page,
},
);
expect.assertions(1);
await expect(onGetAnnotationsSuccessPromise).resolves.toMatchObject([desiredAnnotations]);
});
it('calls onGetAnnotationsError when failed to load annotations', async () => {
const { func: onGetAnnotationsError, promise: onGetAnnotationsErrorPromise } =
makeAsyncCallback();
muteConsole();
renderWithContext(
<AnnotationLayer />,
{
linkService,
pdf,
},
{
onGetAnnotationsError,
page: failingPage,
},
);
expect.assertions(1);
await expect(onGetAnnotationsErrorPromise).resolves.toMatchObject([expect.any(Error)]);
restoreConsole();
});
it('replaces annotations properly when page is changed', async () => {
const { func: onGetAnnotationsSuccess, promise: onGetAnnotationsSuccessPromise } =
makeAsyncCallback();
const { rerender } = renderWithContext(
<AnnotationLayer />,
{
linkService,
pdf,
},
{
onGetAnnotationsSuccess,
page,
},
);
expect.assertions(2);
await expect(onGetAnnotationsSuccessPromise).resolves.toMatchObject([desiredAnnotations]);
const { func: onGetAnnotationsSuccess2, promise: onGetAnnotationsSuccessPromise2 } =
makeAsyncCallback();
rerender(
<AnnotationLayer />,
{
linkService,
pdf,
},
{
onGetAnnotationsSuccess: onGetAnnotationsSuccess2,
page: page2,
},
);
await expect(onGetAnnotationsSuccessPromise2).resolves.toMatchObject([desiredAnnotations2]);
});
it('throws an error when placed outside Page', () => {
muteConsole();
expect(() => render(<AnnotationLayer />)).toThrow();
restoreConsole();
});
});
describe('rendering', () => {
it('renders annotations properly', async () => {
const {
func: onRenderAnnotationLayerSuccess,
promise: onRenderAnnotationLayerSuccessPromise,
} = makeAsyncCallback();
const { container } = renderWithContext(
<AnnotationLayer />,
{
linkService,
pdf,
},
{
onRenderAnnotationLayerSuccess,
page,
},
);
expect.assertions(1);
await onRenderAnnotationLayerSuccessPromise;
const wrapper = container.firstElementChild as HTMLDivElement;
const annotationItems = Array.from(wrapper.children);
expect(annotationItems).toHaveLength(desiredAnnotations.length);
});
it.each`
externalLinkTarget | target
${null} | ${''}
${'_self'} | ${'_self'}
${'_blank'} | ${'_blank'}
${'_parent'} | ${'_parent'}
${'_top'} | ${'_top'}
`(
'renders all links with target $target given externalLinkTarget = $externalLinkTarget',
async ({ externalLinkTarget, target }) => {
const {
func: onRenderAnnotationLayerSuccess,
promise: onRenderAnnotationLayerSuccessPromise,
} = makeAsyncCallback();
const customLinkService = new LinkService();
if (externalLinkTarget) {
customLinkService.setExternalLinkTarget(externalLinkTarget);
}
const { container } = renderWithContext(
<AnnotationLayer />,
{
linkService: customLinkService,
pdf,
},
{
onRenderAnnotationLayerSuccess,
page,
},
);
expect.assertions(desiredAnnotations.length);
await onRenderAnnotationLayerSuccessPromise;
const wrapper = container.firstElementChild as HTMLDivElement;
const annotationItems = Array.from(wrapper.children);
const annotationLinkItems = annotationItems
.map((item) => item.firstChild as HTMLElement)
.filter((item) => item.tagName === 'A');
for (const link of annotationLinkItems) {
expect(link.getAttribute('target')).toBe(target);
}
},
);
it.each`
externalLinkRel | rel
${null} | ${'noopener noreferrer nofollow'}
${'noopener'} | ${'noopener'}
`(
'renders all links with rel $rel given externalLinkRel = $externalLinkRel',
async ({ externalLinkRel, rel }) => {
const {
func: onRenderAnnotationLayerSuccess,
promise: onRenderAnnotationLayerSuccessPromise,
} = makeAsyncCallback();
const customLinkService = new LinkService();
if (externalLinkRel) {
customLinkService.setExternalLinkRel(externalLinkRel);
}
const { container } = renderWithContext(
<AnnotationLayer />,
{
linkService: customLinkService,
pdf,
},
{
onRenderAnnotationLayerSuccess,
page,
},
);
expect.assertions(desiredAnnotations.length);
await onRenderAnnotationLayerSuccessPromise;
const wrapper = container.firstElementChild as HTMLDivElement;
const annotationItems = Array.from(wrapper.children);
const annotationLinkItems = annotationItems
.map((item) => item.firstChild as HTMLElement)
.filter((item) => item.tagName === 'A');
for (const link of annotationLinkItems) {
expect(link.getAttribute('rel')).toBe(rel);
}
},
);
it('renders annotations with the default imageResourcesPath given no imageResourcesPath', async () => {
const pdf = await pdfjs.getDocument({ data: annotatedPdfFile.arrayBuffer }).promise;
const annotatedPage = await pdf.getPage(1);
const {
func: onRenderAnnotationLayerSuccess,
promise: onRenderAnnotationLayerSuccessPromise,
} = makeAsyncCallback();
const imageResourcesPath = '';
const desiredImageTagRegExp = new RegExp(
`<img[^>]+src="${imageResourcesPath}annotation-note.svg"`,
);
const { container } = renderWithContext(
<AnnotationLayer />,
{
linkService,
pdf,
},
{
onRenderAnnotationLayerSuccess,
page: annotatedPage,
},
);
expect.assertions(1);
await onRenderAnnotationLayerSuccessPromise;
const stringifiedAnnotationLayerNode = container.outerHTML;
expect(stringifiedAnnotationLayerNode).toMatch(desiredImageTagRegExp);
});
it('renders annotations with the specified imageResourcesPath given imageResourcesPath', async () => {
const pdf = await pdfjs.getDocument({ data: annotatedPdfFile.arrayBuffer }).promise;
const annotatedPage = await pdf.getPage(1);
const {
func: onRenderAnnotationLayerSuccess,
promise: onRenderAnnotationLayerSuccessPromise,
} = makeAsyncCallback();
const imageResourcesPath = '/public/images/';
const desiredImageTagRegExp = new RegExp(
`<img[^>]+src="${imageResourcesPath}annotation-note.svg"`,
);
const { container } = renderWithContext(
<AnnotationLayer />,
{
imageResourcesPath,
linkService,
pdf,
},
{
onRenderAnnotationLayerSuccess,
page: annotatedPage,
},
);
expect.assertions(1);
await onRenderAnnotationLayerSuccessPromise;
const stringifiedAnnotationLayerNode = container.outerHTML;
expect(stringifiedAnnotationLayerNode).toMatch(desiredImageTagRegExp);
});
});
});

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P"},C:{"1":"0 9 mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB qC rC"},D:{"1":"0 9 xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB","194":"pB qB rB sB tB uB vB MC wB NC"},E:{"1":"A B C L M G TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F sC SC tC uC vC wC"},F:{"1":"0 pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB 4C 5C 6C 7C FC kC 8C GC","194":"cB dB eB fB gB hB iB jB kB lB mB nB oB"},G:{"1":"GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 gD hD TC iD jD kD lD mD IC JC KC nD","2":"J","194":"dD eD fD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"rD","2":"qD"}},B:4,C:"#rrggbbaa hex color notation",D:true};

View File

@@ -0,0 +1 @@
module.exports={C:{"17":0.00328,"52":0.00328,"109":0.00328,"112":0.00328,"113":0.01966,"114":0.00983,"115":0.12125,"123":0.00328,"125":0.00328,"126":0.00328,"127":0.01311,"128":0.02294,"129":0.00328,"130":0.00328,"131":0.00655,"132":0.00983,"133":0.01311,"134":0.01966,"135":0.43912,"136":1.35012,"137":0.01311,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 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 110 111 116 117 118 119 120 121 122 124 138 139 140 3.5 3.6"},D:{"25":0.00328,"49":0.00328,"52":0.00328,"79":0.00328,"80":0.00328,"81":0.00328,"87":0.00655,"89":0.00328,"91":0.00328,"92":0.00328,"94":0.00328,"95":0.00328,"98":0.00328,"100":0.00655,"102":0.00328,"103":0.01639,"104":0.01639,"105":0.00328,"106":0.00655,"107":0.00655,"108":0.00983,"109":0.69472,"110":0.00328,"111":0.03277,"112":0.00655,"113":0.00655,"114":0.01639,"115":0.00655,"116":0.07209,"117":0.00655,"118":0.01639,"119":0.01639,"120":0.02294,"121":0.06554,"122":0.05571,"123":0.02949,"124":0.05899,"125":0.03277,"126":0.06554,"127":0.03605,"128":0.10486,"129":0.03932,"130":0.05899,"131":0.25233,"132":0.30148,"133":8.31047,"134":13.6356,"135":0.00655,"136":0.00328,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 50 51 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 83 84 85 86 88 90 93 96 97 99 101 137 138"},F:{"87":0.01311,"88":0.00328,"95":0.00983,"116":0.04588,"117":0.26871,_:"9 11 12 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 60 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 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"18":0.00328,"92":0.00655,"109":0.00983,"114":0.01311,"122":0.00328,"126":0.00328,"127":0.00328,"128":0.00328,"129":0.00328,"130":0.00328,"131":0.02294,"132":0.02294,"133":1.10435,"134":2.30701,_:"12 13 14 15 16 17 79 80 81 83 84 85 86 87 88 89 90 91 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 110 111 112 113 115 116 117 118 119 120 121 123 124 125"},E:{"14":0.00328,_:"0 4 5 6 7 8 9 10 11 12 13 15 3.1 3.2 6.1 7.1 9.1 10.1 11.1 12.1","5.1":0.00328,"13.1":0.00655,"14.1":0.01966,"15.1":0.00655,"15.2-15.3":0.00328,"15.4":0.00655,"15.5":0.00655,"15.6":0.04588,"16.0":0.00328,"16.1":0.01639,"16.2":0.00655,"16.3":0.01639,"16.4":0.00983,"16.5":0.02294,"16.6":0.05899,"17.0":0.00983,"17.1":0.01639,"17.2":0.01966,"17.3":0.01639,"17.4":0.03277,"17.5":0.05899,"17.6":0.09831,"18.0":0.03605,"18.1":0.05899,"18.2":0.03605,"18.3":0.33425,"18.4":0.00328},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00116,"5.0-5.1":0,"6.0-6.1":0.00349,"7.0-7.1":0.00233,"8.1-8.4":0,"9.0-9.2":0.00174,"9.3":0.00814,"10.0-10.2":0.00058,"10.3":0.01338,"11.0-11.2":0.06164,"11.3-11.4":0.00407,"12.0-12.1":0.00233,"12.2-12.5":0.05757,"13.0-13.1":0.00116,"13.2":0.00174,"13.3":0.00233,"13.4-13.7":0.00814,"14.0-14.4":0.02035,"14.5-14.8":0.02442,"15.0-15.1":0.01338,"15.2-15.3":0.01338,"15.4":0.01628,"15.5":0.01861,"15.6-15.8":0.22913,"16.0":0.03257,"16.1":0.06688,"16.2":0.03489,"16.3":0.06048,"16.4":0.01338,"16.5":0.02501,"16.6-16.7":0.27158,"17.0":0.01628,"17.1":0.02908,"17.2":0.0221,"17.3":0.03082,"17.4":0.06164,"17.5":0.13724,"17.6-17.7":0.39835,"18.0":0.11166,"18.1":0.36521,"18.2":0.16341,"18.3":3.41538,"18.4":0.05059},P:{"4":0.0104,"21":0.0104,"22":0.02079,"23":0.03119,"24":0.02079,"25":0.03119,"26":0.05198,"27":0.81092,_:"20 5.0-5.4 6.2-6.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 18.0 19.0","7.2-7.4":0.0104,"17.0":0.0104},I:{"0":0.0738,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00002,"4.4":0,"4.4.3-4.4.4":0.00008},K:{"0":0.57818,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.21628,_:"6 7 8 9 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.06723},Q:{"14.9":0.00672},O:{"0":0.57818},H:{"0":0},L:{"0":60.19259}};

View File

@@ -0,0 +1,37 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const Hook = require("./Hook");
const HookCodeFactory = require("./HookCodeFactory");
class AsyncSeriesLoopHookCodeFactory extends HookCodeFactory {
content({ onError, onDone }) {
return this.callTapsLooping({
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
onDone
});
}
}
const factory = new AsyncSeriesLoopHookCodeFactory();
const COMPILE = function(options) {
factory.setup(this, options);
return factory.create(options);
};
function AsyncSeriesLoopHook(args = [], name = undefined) {
const hook = new Hook(args, name);
hook.constructor = AsyncSeriesLoopHook;
hook.compile = COMPILE;
hook._call = undefined;
hook.call = undefined;
return hook;
}
AsyncSeriesLoopHook.prototype = null;
module.exports = AsyncSeriesLoopHook;

View File

@@ -0,0 +1,364 @@
/**
* @license React
* scheduler.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
"use strict";
"production" !== process.env.NODE_ENV &&
(function () {
function performWorkUntilDeadline() {
needsPaint = !1;
if (isMessageLoopRunning) {
var currentTime = exports.unstable_now();
startTime = currentTime;
var hasMoreWork = !0;
try {
a: {
isHostCallbackScheduled = !1;
isHostTimeoutScheduled &&
((isHostTimeoutScheduled = !1),
localClearTimeout(taskTimeoutID),
(taskTimeoutID = -1));
isPerformingWork = !0;
var previousPriorityLevel = currentPriorityLevel;
try {
b: {
advanceTimers(currentTime);
for (
currentTask = peek(taskQueue);
null !== currentTask &&
!(
currentTask.expirationTime > currentTime &&
shouldYieldToHost()
);
) {
var callback = currentTask.callback;
if ("function" === typeof callback) {
currentTask.callback = null;
currentPriorityLevel = currentTask.priorityLevel;
var continuationCallback = callback(
currentTask.expirationTime <= currentTime
);
currentTime = exports.unstable_now();
if ("function" === typeof continuationCallback) {
currentTask.callback = continuationCallback;
advanceTimers(currentTime);
hasMoreWork = !0;
break b;
}
currentTask === peek(taskQueue) && pop(taskQueue);
advanceTimers(currentTime);
} else pop(taskQueue);
currentTask = peek(taskQueue);
}
if (null !== currentTask) hasMoreWork = !0;
else {
var firstTimer = peek(timerQueue);
null !== firstTimer &&
requestHostTimeout(
handleTimeout,
firstTimer.startTime - currentTime
);
hasMoreWork = !1;
}
}
break a;
} finally {
(currentTask = null),
(currentPriorityLevel = previousPriorityLevel),
(isPerformingWork = !1);
}
hasMoreWork = void 0;
}
} finally {
hasMoreWork
? schedulePerformWorkUntilDeadline()
: (isMessageLoopRunning = !1);
}
}
}
function push(heap, node) {
var index = heap.length;
heap.push(node);
a: for (; 0 < index; ) {
var parentIndex = (index - 1) >>> 1,
parent = heap[parentIndex];
if (0 < compare(parent, node))
(heap[parentIndex] = node),
(heap[index] = parent),
(index = parentIndex);
else break a;
}
}
function peek(heap) {
return 0 === heap.length ? null : heap[0];
}
function pop(heap) {
if (0 === heap.length) return null;
var first = heap[0],
last = heap.pop();
if (last !== first) {
heap[0] = last;
a: for (
var index = 0, length = heap.length, halfLength = length >>> 1;
index < halfLength;
) {
var leftIndex = 2 * (index + 1) - 1,
left = heap[leftIndex],
rightIndex = leftIndex + 1,
right = heap[rightIndex];
if (0 > compare(left, last))
rightIndex < length && 0 > compare(right, left)
? ((heap[index] = right),
(heap[rightIndex] = last),
(index = rightIndex))
: ((heap[index] = left),
(heap[leftIndex] = last),
(index = leftIndex));
else if (rightIndex < length && 0 > compare(right, last))
(heap[index] = right),
(heap[rightIndex] = last),
(index = rightIndex);
else break a;
}
}
return first;
}
function compare(a, b) {
var diff = a.sortIndex - b.sortIndex;
return 0 !== diff ? diff : a.id - b.id;
}
function advanceTimers(currentTime) {
for (var timer = peek(timerQueue); null !== timer; ) {
if (null === timer.callback) pop(timerQueue);
else if (timer.startTime <= currentTime)
pop(timerQueue),
(timer.sortIndex = timer.expirationTime),
push(taskQueue, timer);
else break;
timer = peek(timerQueue);
}
}
function handleTimeout(currentTime) {
isHostTimeoutScheduled = !1;
advanceTimers(currentTime);
if (!isHostCallbackScheduled)
if (null !== peek(taskQueue))
(isHostCallbackScheduled = !0),
isMessageLoopRunning ||
((isMessageLoopRunning = !0), schedulePerformWorkUntilDeadline());
else {
var firstTimer = peek(timerQueue);
null !== firstTimer &&
requestHostTimeout(
handleTimeout,
firstTimer.startTime - currentTime
);
}
}
function shouldYieldToHost() {
return needsPaint
? !0
: exports.unstable_now() - startTime < frameInterval
? !1
: !0;
}
function requestHostTimeout(callback, ms) {
taskTimeoutID = localSetTimeout(function () {
callback(exports.unstable_now());
}, ms);
}
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
exports.unstable_now = void 0;
if (
"object" === typeof performance &&
"function" === typeof performance.now
) {
var localPerformance = performance;
exports.unstable_now = function () {
return localPerformance.now();
};
} else {
var localDate = Date,
initialTime = localDate.now();
exports.unstable_now = function () {
return localDate.now() - initialTime;
};
}
var taskQueue = [],
timerQueue = [],
taskIdCounter = 1,
currentTask = null,
currentPriorityLevel = 3,
isPerformingWork = !1,
isHostCallbackScheduled = !1,
isHostTimeoutScheduled = !1,
needsPaint = !1,
localSetTimeout = "function" === typeof setTimeout ? setTimeout : null,
localClearTimeout =
"function" === typeof clearTimeout ? clearTimeout : null,
localSetImmediate =
"undefined" !== typeof setImmediate ? setImmediate : null,
isMessageLoopRunning = !1,
taskTimeoutID = -1,
frameInterval = 5,
startTime = -1;
if ("function" === typeof localSetImmediate)
var schedulePerformWorkUntilDeadline = function () {
localSetImmediate(performWorkUntilDeadline);
};
else if ("undefined" !== typeof MessageChannel) {
var channel = new MessageChannel(),
port = channel.port2;
channel.port1.onmessage = performWorkUntilDeadline;
schedulePerformWorkUntilDeadline = function () {
port.postMessage(null);
};
} else
schedulePerformWorkUntilDeadline = function () {
localSetTimeout(performWorkUntilDeadline, 0);
};
exports.unstable_IdlePriority = 5;
exports.unstable_ImmediatePriority = 1;
exports.unstable_LowPriority = 4;
exports.unstable_NormalPriority = 3;
exports.unstable_Profiling = null;
exports.unstable_UserBlockingPriority = 2;
exports.unstable_cancelCallback = function (task) {
task.callback = null;
};
exports.unstable_forceFrameRate = function (fps) {
0 > fps || 125 < fps
? console.error(
"forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"
)
: (frameInterval = 0 < fps ? Math.floor(1e3 / fps) : 5);
};
exports.unstable_getCurrentPriorityLevel = function () {
return currentPriorityLevel;
};
exports.unstable_next = function (eventHandler) {
switch (currentPriorityLevel) {
case 1:
case 2:
case 3:
var priorityLevel = 3;
break;
default:
priorityLevel = currentPriorityLevel;
}
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = priorityLevel;
try {
return eventHandler();
} finally {
currentPriorityLevel = previousPriorityLevel;
}
};
exports.unstable_requestPaint = function () {
needsPaint = !0;
};
exports.unstable_runWithPriority = function (priorityLevel, eventHandler) {
switch (priorityLevel) {
case 1:
case 2:
case 3:
case 4:
case 5:
break;
default:
priorityLevel = 3;
}
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = priorityLevel;
try {
return eventHandler();
} finally {
currentPriorityLevel = previousPriorityLevel;
}
};
exports.unstable_scheduleCallback = function (
priorityLevel,
callback,
options
) {
var currentTime = exports.unstable_now();
"object" === typeof options && null !== options
? ((options = options.delay),
(options =
"number" === typeof options && 0 < options
? currentTime + options
: currentTime))
: (options = currentTime);
switch (priorityLevel) {
case 1:
var timeout = -1;
break;
case 2:
timeout = 250;
break;
case 5:
timeout = 1073741823;
break;
case 4:
timeout = 1e4;
break;
default:
timeout = 5e3;
}
timeout = options + timeout;
priorityLevel = {
id: taskIdCounter++,
callback: callback,
priorityLevel: priorityLevel,
startTime: options,
expirationTime: timeout,
sortIndex: -1
};
options > currentTime
? ((priorityLevel.sortIndex = options),
push(timerQueue, priorityLevel),
null === peek(taskQueue) &&
priorityLevel === peek(timerQueue) &&
(isHostTimeoutScheduled
? (localClearTimeout(taskTimeoutID), (taskTimeoutID = -1))
: (isHostTimeoutScheduled = !0),
requestHostTimeout(handleTimeout, options - currentTime)))
: ((priorityLevel.sortIndex = timeout),
push(taskQueue, priorityLevel),
isHostCallbackScheduled ||
isPerformingWork ||
((isHostCallbackScheduled = !0),
isMessageLoopRunning ||
((isMessageLoopRunning = !0),
schedulePerformWorkUntilDeadline())));
return priorityLevel;
};
exports.unstable_shouldYield = shouldYieldToHost;
exports.unstable_wrapCallback = function (callback) {
var parentPriorityLevel = currentPriorityLevel;
return function () {
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = parentPriorityLevel;
try {
return callback.apply(this, arguments);
} finally {
currentPriorityLevel = previousPriorityLevel;
}
};
};
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
})();

View File

@@ -0,0 +1 @@
(function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.base64js=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c<g.length;c++)a(g[c]);return a}return b}()({"/":[function(a,b,c){'use strict';function d(a){var b=a.length;if(0<b%4)throw new Error("Invalid string. Length must be a multiple of 4");var c=a.indexOf("=");-1===c&&(c=b);var d=c===b?0:4-c%4;return[c,d]}function e(a,b,c){return 3*(b+c)/4-c}function f(a){var b,c,f=d(a),g=f[0],h=f[1],j=new m(e(a,g,h)),k=0,n=0<h?g-4:g;for(c=0;c<n;c+=4)b=l[a.charCodeAt(c)]<<18|l[a.charCodeAt(c+1)]<<12|l[a.charCodeAt(c+2)]<<6|l[a.charCodeAt(c+3)],j[k++]=255&b>>16,j[k++]=255&b>>8,j[k++]=255&b;return 2===h&&(b=l[a.charCodeAt(c)]<<2|l[a.charCodeAt(c+1)]>>4,j[k++]=255&b),1===h&&(b=l[a.charCodeAt(c)]<<10|l[a.charCodeAt(c+1)]<<4|l[a.charCodeAt(c+2)]>>2,j[k++]=255&b>>8,j[k++]=255&b),j}function g(a){return k[63&a>>18]+k[63&a>>12]+k[63&a>>6]+k[63&a]}function h(a,b,c){for(var d,e=[],f=b;f<c;f+=3)d=(16711680&a[f]<<16)+(65280&a[f+1]<<8)+(255&a[f+2]),e.push(g(d));return e.join("")}function j(a){for(var b,c=a.length,d=c%3,e=[],f=16383,g=0,j=c-d;g<j;g+=f)e.push(h(a,g,g+f>j?j:g+f));return 1===d?(b=a[c-1],e.push(k[b>>2]+k[63&b<<4]+"==")):2===d&&(b=(a[c-2]<<8)+a[c-1],e.push(k[b>>10]+k[63&b>>4]+k[63&b<<2]+"=")),e.join("")}c.byteLength=function(a){var b=d(a),c=b[0],e=b[1];return 3*(c+e)/4-e},c.toByteArray=f,c.fromByteArray=j;for(var k=[],l=[],m="undefined"==typeof Uint8Array?Array:Uint8Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,p=n.length;o<p;++o)k[o]=n[o],l[n.charCodeAt(o)]=o;l[45]=62,l[95]=63},{}]},{},[])("/")});

View File

@@ -0,0 +1,5 @@
declare const PasswordResponses: {
readonly NEED_PASSWORD: 1;
readonly INCORRECT_PASSWORD: 2;
};
export default PasswordResponses;

View File

@@ -0,0 +1 @@
{"version":3,"names":["STATEMENT_OR_BLOCK_KEYS","exports","FLATTENABLE_KEYS","FOR_INIT_KEYS","COMMENT_KEYS","LOGICAL_OPERATORS","UPDATE_OPERATORS","BOOLEAN_NUMBER_BINARY_OPERATORS","EQUALITY_BINARY_OPERATORS","COMPARISON_BINARY_OPERATORS","BOOLEAN_BINARY_OPERATORS","NUMBER_BINARY_OPERATORS","BINARY_OPERATORS","ASSIGNMENT_OPERATORS","map","op","BOOLEAN_UNARY_OPERATORS","NUMBER_UNARY_OPERATORS","STRING_UNARY_OPERATORS","UNARY_OPERATORS","INHERIT_KEYS","optional","force","BLOCK_SCOPED_SYMBOL","Symbol","for","NOT_LOCAL_BINDING"],"sources":["../../src/constants/index.ts"],"sourcesContent":["export const STATEMENT_OR_BLOCK_KEYS = [\"consequent\", \"body\", \"alternate\"];\nexport const FLATTENABLE_KEYS = [\"body\", \"expressions\"];\nexport const FOR_INIT_KEYS = [\"left\", \"init\"];\nexport const COMMENT_KEYS = [\n \"leadingComments\",\n \"trailingComments\",\n \"innerComments\",\n] as const;\n\nexport const LOGICAL_OPERATORS = [\"||\", \"&&\", \"??\"];\nexport const UPDATE_OPERATORS = [\"++\", \"--\"];\n\nexport const BOOLEAN_NUMBER_BINARY_OPERATORS = [\">\", \"<\", \">=\", \"<=\"];\nexport const EQUALITY_BINARY_OPERATORS = [\"==\", \"===\", \"!=\", \"!==\"];\nexport const COMPARISON_BINARY_OPERATORS = [\n ...EQUALITY_BINARY_OPERATORS,\n \"in\",\n \"instanceof\",\n];\nexport const BOOLEAN_BINARY_OPERATORS = [\n ...COMPARISON_BINARY_OPERATORS,\n ...BOOLEAN_NUMBER_BINARY_OPERATORS,\n];\nexport const NUMBER_BINARY_OPERATORS = [\n \"-\",\n \"/\",\n \"%\",\n \"*\",\n \"**\",\n \"&\",\n \"|\",\n \">>\",\n \">>>\",\n \"<<\",\n \"^\",\n];\nexport const BINARY_OPERATORS = [\n \"+\",\n ...NUMBER_BINARY_OPERATORS,\n ...BOOLEAN_BINARY_OPERATORS,\n \"|>\",\n];\n\nexport const ASSIGNMENT_OPERATORS = [\n \"=\",\n \"+=\",\n ...NUMBER_BINARY_OPERATORS.map(op => op + \"=\"),\n ...LOGICAL_OPERATORS.map(op => op + \"=\"),\n];\n\nexport const BOOLEAN_UNARY_OPERATORS = [\"delete\", \"!\"];\nexport const NUMBER_UNARY_OPERATORS = [\"+\", \"-\", \"~\"];\nexport const STRING_UNARY_OPERATORS = [\"typeof\"];\nexport const UNARY_OPERATORS = [\n \"void\",\n \"throw\",\n ...BOOLEAN_UNARY_OPERATORS,\n ...NUMBER_UNARY_OPERATORS,\n ...STRING_UNARY_OPERATORS,\n];\n\nexport const INHERIT_KEYS = {\n optional: [\"typeAnnotation\", \"typeParameters\", \"returnType\"],\n force: [\"start\", \"loc\", \"end\"],\n} as const;\n\nif (!process.env.BABEL_8_BREAKING && !USE_ESM) {\n // eslint-disable-next-line no-restricted-globals\n exports.BLOCK_SCOPED_SYMBOL = Symbol.for(\"var used to be block scoped\");\n // eslint-disable-next-line no-restricted-globals\n exports.NOT_LOCAL_BINDING = Symbol.for(\n \"should not be considered a local binding\",\n );\n}\n"],"mappings":";;;;;;AAAO,MAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC;AACnE,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;AAChD,MAAMC,aAAa,GAAAF,OAAA,CAAAE,aAAA,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AACtC,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,CAC1B,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,CACP;AAEH,MAAMC,iBAAiB,GAAAJ,OAAA,CAAAI,iBAAA,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;AAC5C,MAAMC,gBAAgB,GAAAL,OAAA,CAAAK,gBAAA,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;AAErC,MAAMC,+BAA+B,GAAAN,OAAA,CAAAM,+BAAA,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;AAC9D,MAAMC,yBAAyB,GAAAP,OAAA,CAAAO,yBAAA,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;AAC5D,MAAMC,2BAA2B,GAAAR,OAAA,CAAAQ,2BAAA,GAAG,CACzC,GAAGD,yBAAyB,EAC5B,IAAI,EACJ,YAAY,CACb;AACM,MAAME,wBAAwB,GAAAT,OAAA,CAAAS,wBAAA,GAAG,CACtC,GAAGD,2BAA2B,EAC9B,GAAGF,+BAA+B,CACnC;AACM,MAAMI,uBAAuB,GAAAV,OAAA,CAAAU,uBAAA,GAAG,CACrC,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,GAAG,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,GAAG,CACJ;AACM,MAAMC,gBAAgB,GAAAX,OAAA,CAAAW,gBAAA,GAAG,CAC9B,GAAG,EACH,GAAGD,uBAAuB,EAC1B,GAAGD,wBAAwB,EAC3B,IAAI,CACL;AAEM,MAAMG,oBAAoB,GAAAZ,OAAA,CAAAY,oBAAA,GAAG,CAClC,GAAG,EACH,IAAI,EACJ,GAAGF,uBAAuB,CAACG,GAAG,CAACC,EAAE,IAAIA,EAAE,GAAG,GAAG,CAAC,EAC9C,GAAGV,iBAAiB,CAACS,GAAG,CAACC,EAAE,IAAIA,EAAE,GAAG,GAAG,CAAC,CACzC;AAEM,MAAMC,uBAAuB,GAAAf,OAAA,CAAAe,uBAAA,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC;AAC/C,MAAMC,sBAAsB,GAAAhB,OAAA,CAAAgB,sBAAA,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC9C,MAAMC,sBAAsB,GAAAjB,OAAA,CAAAiB,sBAAA,GAAG,CAAC,QAAQ,CAAC;AACzC,MAAMC,eAAe,GAAAlB,OAAA,CAAAkB,eAAA,GAAG,CAC7B,MAAM,EACN,OAAO,EACP,GAAGH,uBAAuB,EAC1B,GAAGC,sBAAsB,EACzB,GAAGC,sBAAsB,CAC1B;AAEM,MAAME,YAAY,GAAAnB,OAAA,CAAAmB,YAAA,GAAG;EAC1BC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,CAAC;EAC5DC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK;AAC/B,CAAU;AAEqC;EAE7CrB,OAAO,CAACsB,mBAAmB,GAAGC,MAAM,CAACC,GAAG,CAAC,6BAA6B,CAAC;EAEvExB,OAAO,CAACyB,iBAAiB,GAAGF,MAAM,CAACC,GAAG,CACpC,0CACF,CAAC;AACH","ignoreList":[]}