Skip to content

Commit

Permalink
typescript 5.7.2
Browse files Browse the repository at this point in the history
I need this PR: microsoft/TypeScript#57681
because currently tsconfig has to use DOM types to keep ts from
emitting references to the dom in the .d.ts files, but that does
something equally bad: it defines all the DOM types inside of
dropflow (e.g. `navigator` is considered available)
  • Loading branch information
chearon committed Dec 31, 2024
1 parent a4d915f commit fb4906f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 28 deletions.
10 changes: 5 additions & 5 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@ddietr/codemirror-themes": "^1.4.2",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/mocha": "^8.0.3",
"@types/node": "^20.8.10",
"@types/node": "^20.17.10",
"canvas": "^3.0.0",
"chai": "^4.2.0",
"codemirror": "^6.0.1",
Expand All @@ -18,7 +18,7 @@
"mocha": "^10.0.0",
"peggy": "^2.0.1",
"punycode": "^2.1.1",
"typescript": "^5.2.2",
"typescript": "^5.7.2",
"vite": "^6.0.3",
},
},
Expand Down Expand Up @@ -154,7 +154,7 @@

"@types/mocha": ["@types/mocha@8.2.3", "", {}, "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw=="],

"@types/node": ["@types/node@20.8.10", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-TlgT8JntpcbmKUFzjhsyhGfP2fsiz1Mv56im6enJ905xG1DAYesxJaeSbGqQmAw8OWPdhyJGhGSQGKRNJ45u9w=="],
"@types/node": ["@types/node@20.17.10", "", { "dependencies": { "undici-types": "~6.19.2" } }, "sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA=="],

"@types/resolve": ["@types/resolve@1.20.2", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="],

Expand Down Expand Up @@ -450,9 +450,9 @@

"type-detect": ["type-detect@4.0.8", "", {}, "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g=="],

"typescript": ["typescript@5.2.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w=="],
"typescript": ["typescript@5.7.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg=="],

"undici-types": ["undici-types@5.26.5", "", {}, "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="],
"undici-types": ["undici-types@6.19.8", "", {}, "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="],

"untildify": ["untildify@4.0.0", "", {}, "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw=="],

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@ddietr/codemirror-themes": "^1.4.2",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/mocha": "^8.0.3",
"@types/node": "^20.8.10",
"@types/node": "^20.17.10",
"canvas": "^3.0.0",
"chai": "^4.2.0",
"codemirror": "^6.0.1",
Expand All @@ -15,7 +15,7 @@
"mocha": "^10.0.0",
"peggy": "^2.0.1",
"punycode": "^2.1.1",
"typescript": "^5.2.2",
"typescript": "^5.7.2",
"vite": "^6.0.3"
},
"name": "dropflow",
Expand Down
4 changes: 2 additions & 2 deletions src/layout-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ export class BlockContainer extends Box {
};
}

getLastBaseline() {
getLastBaseline(): number | undefined {
const stack: {block: BlockContainer, offset: number}[] = [{block: this, offset: 0}];

while (stack.length) {
Expand Down Expand Up @@ -974,7 +974,7 @@ export class BlockContainer extends Box {
return Boolean(this.children.length && this.children[0].isIfcInline());
}

canCollapseThrough() {
canCollapseThrough(): boolean {
const blockSize = this.style.getBlockSize(this);

if (blockSize !== 'auto' && blockSize !== 0) return false;
Expand Down
7 changes: 3 additions & 4 deletions src/paint-canvas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {firstCascadeItem} from './text-font.js';
import {
prevCluster,
nextCluster,
Expand Down Expand Up @@ -125,7 +124,7 @@ export default class CanvasPaintBackend implements PaintBackend {
strokeColor: Color;
lineWidth: number;
direction: 'ltr' | 'rtl';
font: FaceMatch;
font: FaceMatch | undefined;
fontSize: number;
ctx: CanvasRenderingContext2D;

Expand All @@ -134,7 +133,7 @@ export default class CanvasPaintBackend implements PaintBackend {
this.strokeColor = {r: 0, g: 0, b: 0, a: 0};
this.lineWidth = 0;
this.direction = 'ltr';
this.font = firstCascadeItem();
this.font = undefined;
this.fontSize = 8;
this.ctx = ctx;
}
Expand Down Expand Up @@ -168,7 +167,7 @@ export default class CanvasPaintBackend implements PaintBackend {
if ('textDrawingMode' in this.ctx) {
this.ctx.textDrawingMode = 'glyph';
}
this.ctx.font = this.font.toFontString(this.fontSize);
this.ctx.font = this.font?.toFontString(this.fontSize) || '';
this.ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`;
this.ctx.fillText(text, x, y);
this.ctx.restore();
Expand Down
7 changes: 3 additions & 4 deletions src/paint-html.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {getMetrics, ShapedItem} from './layout-text.js';
import {firstCascadeItem} from './text-font.js';

import type {Color} from './style.js';
import type {PaintBackend} from './paint.js';
Expand All @@ -21,7 +20,7 @@ export default class HtmlPaintBackend implements PaintBackend {
strokeColor: Color;
lineWidth: number;
direction: 'ltr' | 'rtl';
font: FaceMatch;
font: FaceMatch | undefined;
fontSize: number;

constructor() {
Expand All @@ -30,7 +29,7 @@ export default class HtmlPaintBackend implements PaintBackend {
this.strokeColor = {r: 0, g: 0, b: 0, a: 0};
this.lineWidth = 0;
this.direction = 'ltr';
this.font = firstCascadeItem();
this.font = undefined;
this.fontSize = 0;
}

Expand Down Expand Up @@ -71,7 +70,7 @@ export default class HtmlPaintBackend implements PaintBackend {
left: '0',
top: '0',
transform: `translate(${x}px, ${y - (ascenderBox - (ascenderBox + descenderBox)/2)}px)`,
font: this.font.toFontString(this.fontSize),
font: this.font?.toFontString(this.fontSize) || "",
lineHeight: '0',
whiteSpace: 'pre',
direction: this.direction,
Expand Down
7 changes: 3 additions & 4 deletions src/paint-svg.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {ShapedItem} from './layout-text.js';
import {firstCascadeItem} from './text-font.js';

import type {Color} from './style.js';
import type {PaintBackend} from './paint.js';
Expand Down Expand Up @@ -52,7 +51,7 @@ export default class HtmlPaintBackend implements PaintBackend {
strokeColor: Color;
lineWidth: number;
direction: 'ltr' | 'rtl';
font: FaceMatch;
font: FaceMatch | undefined;
fontSize: number;
usedFonts: Map<string, FaceMatch>;

Expand All @@ -64,7 +63,7 @@ export default class HtmlPaintBackend implements PaintBackend {
this.strokeColor = {r: 0, g: 0, b: 0, a: 0};
this.lineWidth = 0;
this.direction = 'ltr';
this.font = firstCascadeItem();
this.font = undefined;
this.fontSize = 0;
this.usedFonts = new Map();
}
Expand Down Expand Up @@ -92,7 +91,7 @@ export default class HtmlPaintBackend implements PaintBackend {
const {r, g, b, a} = this.fillColor;
const color = `rgba(${r}, ${g}, ${b}, ${a})`;
const style = this.style({
font: this.font.toFontString(this.fontSize),
font: this.font?.toFontString(this.fontSize) ?? '',
whiteSpace: 'pre',
direction: this.direction,
unicodeBidi: 'bidi-override'
Expand Down
2 changes: 1 addition & 1 deletion src/paint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface PaintBackend {
strokeColor: Color;
lineWidth: number;
direction: 'ltr' | 'rtl';
font: FaceMatch;
font: FaceMatch | undefined;
fontSize: number;
edge(x: number, y: number, length: number, side: 'top' | 'right' | 'bottom' | 'left'): void;
text(x: number, y: number, item: ShapedItem, textStart: number, textEnd: number, isColorBoundary?: boolean): void;
Expand Down
8 changes: 2 additions & 6 deletions src/text-font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ export interface RegisterFontOptions {
}

export async function registerFont(url: URL, options?: RegisterFontOptions): Promise<void>;
export async function registerFont(buffer: ArrayBuffer, url: URL, options?: RegisterFontOptions): Promise<void>;
export async function registerFont(buffer: ArrayBufferLike, url: URL, options?: RegisterFontOptions): Promise<void>;
export async function registerFont(
arg1: URL | ArrayBuffer,
arg1: URL | ArrayBufferLike,
arg2?: RegisterFontOptions | URL,
arg3?: RegisterFontOptions
) {
Expand Down Expand Up @@ -759,10 +759,6 @@ export function eachRegisteredFont(cb: (family: FaceMatch) => void) {
}
}

export function firstCascadeItem(): FaceMatch {
return registeredFonts.values().next().value; // TODO Why is this any?
}

const systemFontTrie = new UnicodeTrie(wasm.instance.exports.system_font_trie.value);

export function getFontUrls(root: HTMLElement) {
Expand Down

0 comments on commit fb4906f

Please sign in to comment.