Skip to content

Commit fb4906f

Browse files
committed
typescript 5.7.2
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)
1 parent a4d915f commit fb4906f

8 files changed

+21
-28
lines changed

bun.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@ddietr/codemirror-themes": "^1.4.2",
99
"@rollup/plugin-node-resolve": "^15.2.3",
1010
"@types/mocha": "^8.0.3",
11-
"@types/node": "^20.8.10",
11+
"@types/node": "^20.17.10",
1212
"canvas": "^3.0.0",
1313
"chai": "^4.2.0",
1414
"codemirror": "^6.0.1",
@@ -18,7 +18,7 @@
1818
"mocha": "^10.0.0",
1919
"peggy": "^2.0.1",
2020
"punycode": "^2.1.1",
21-
"typescript": "^5.2.2",
21+
"typescript": "^5.7.2",
2222
"vite": "^6.0.3",
2323
},
2424
},
@@ -154,7 +154,7 @@
154154

155155
"@types/mocha": ["@types/[email protected]", "", {}, "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw=="],
156156

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

159159
"@types/resolve": ["@types/[email protected]", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="],
160160

@@ -450,9 +450,9 @@
450450

451451
"type-detect": ["[email protected]", "", {}, "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g=="],
452452

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

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

457457
"untildify": ["[email protected]", "", {}, "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw=="],
458458

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"@ddietr/codemirror-themes": "^1.4.2",
66
"@rollup/plugin-node-resolve": "^15.2.3",
77
"@types/mocha": "^8.0.3",
8-
"@types/node": "^20.8.10",
8+
"@types/node": "^20.17.10",
99
"canvas": "^3.0.0",
1010
"chai": "^4.2.0",
1111
"codemirror": "^6.0.1",
@@ -15,7 +15,7 @@
1515
"mocha": "^10.0.0",
1616
"peggy": "^2.0.1",
1717
"punycode": "^2.1.1",
18-
"typescript": "^5.2.2",
18+
"typescript": "^5.7.2",
1919
"vite": "^6.0.3"
2020
},
2121
"name": "dropflow",

src/layout-flow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ export class BlockContainer extends Box {
901901
};
902902
}
903903

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

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

977-
canCollapseThrough() {
977+
canCollapseThrough(): boolean {
978978
const blockSize = this.style.getBlockSize(this);
979979

980980
if (blockSize !== 'auto' && blockSize !== 0) return false;

src/paint-canvas.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {firstCascadeItem} from './text-font.js';
21
import {
32
prevCluster,
43
nextCluster,
@@ -125,7 +124,7 @@ export default class CanvasPaintBackend implements PaintBackend {
125124
strokeColor: Color;
126125
lineWidth: number;
127126
direction: 'ltr' | 'rtl';
128-
font: FaceMatch;
127+
font: FaceMatch | undefined;
129128
fontSize: number;
130129
ctx: CanvasRenderingContext2D;
131130

@@ -134,7 +133,7 @@ export default class CanvasPaintBackend implements PaintBackend {
134133
this.strokeColor = {r: 0, g: 0, b: 0, a: 0};
135134
this.lineWidth = 0;
136135
this.direction = 'ltr';
137-
this.font = firstCascadeItem();
136+
this.font = undefined;
138137
this.fontSize = 8;
139138
this.ctx = ctx;
140139
}
@@ -168,7 +167,7 @@ export default class CanvasPaintBackend implements PaintBackend {
168167
if ('textDrawingMode' in this.ctx) {
169168
this.ctx.textDrawingMode = 'glyph';
170169
}
171-
this.ctx.font = this.font.toFontString(this.fontSize);
170+
this.ctx.font = this.font?.toFontString(this.fontSize) || '';
172171
this.ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`;
173172
this.ctx.fillText(text, x, y);
174173
this.ctx.restore();

src/paint-html.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {getMetrics, ShapedItem} from './layout-text.js';
2-
import {firstCascadeItem} from './text-font.js';
32

43
import type {Color} from './style.js';
54
import type {PaintBackend} from './paint.js';
@@ -21,7 +20,7 @@ export default class HtmlPaintBackend implements PaintBackend {
2120
strokeColor: Color;
2221
lineWidth: number;
2322
direction: 'ltr' | 'rtl';
24-
font: FaceMatch;
23+
font: FaceMatch | undefined;
2524
fontSize: number;
2625

2726
constructor() {
@@ -30,7 +29,7 @@ export default class HtmlPaintBackend implements PaintBackend {
3029
this.strokeColor = {r: 0, g: 0, b: 0, a: 0};
3130
this.lineWidth = 0;
3231
this.direction = 'ltr';
33-
this.font = firstCascadeItem();
32+
this.font = undefined;
3433
this.fontSize = 0;
3534
}
3635

@@ -71,7 +70,7 @@ export default class HtmlPaintBackend implements PaintBackend {
7170
left: '0',
7271
top: '0',
7372
transform: `translate(${x}px, ${y - (ascenderBox - (ascenderBox + descenderBox)/2)}px)`,
74-
font: this.font.toFontString(this.fontSize),
73+
font: this.font?.toFontString(this.fontSize) || "",
7574
lineHeight: '0',
7675
whiteSpace: 'pre',
7776
direction: this.direction,

src/paint-svg.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {ShapedItem} from './layout-text.js';
2-
import {firstCascadeItem} from './text-font.js';
32

43
import type {Color} from './style.js';
54
import type {PaintBackend} from './paint.js';
@@ -52,7 +51,7 @@ export default class HtmlPaintBackend implements PaintBackend {
5251
strokeColor: Color;
5352
lineWidth: number;
5453
direction: 'ltr' | 'rtl';
55-
font: FaceMatch;
54+
font: FaceMatch | undefined;
5655
fontSize: number;
5756
usedFonts: Map<string, FaceMatch>;
5857

@@ -64,7 +63,7 @@ export default class HtmlPaintBackend implements PaintBackend {
6463
this.strokeColor = {r: 0, g: 0, b: 0, a: 0};
6564
this.lineWidth = 0;
6665
this.direction = 'ltr';
67-
this.font = firstCascadeItem();
66+
this.font = undefined;
6867
this.fontSize = 0;
6968
this.usedFonts = new Map();
7069
}
@@ -92,7 +91,7 @@ export default class HtmlPaintBackend implements PaintBackend {
9291
const {r, g, b, a} = this.fillColor;
9392
const color = `rgba(${r}, ${g}, ${b}, ${a})`;
9493
const style = this.style({
95-
font: this.font.toFontString(this.fontSize),
94+
font: this.font?.toFontString(this.fontSize) ?? '',
9695
whiteSpace: 'pre',
9796
direction: this.direction,
9897
unicodeBidi: 'bidi-override'

src/paint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface PaintBackend {
1111
strokeColor: Color;
1212
lineWidth: number;
1313
direction: 'ltr' | 'rtl';
14-
font: FaceMatch;
14+
font: FaceMatch | undefined;
1515
fontSize: number;
1616
edge(x: number, y: number, length: number, side: 'top' | 'right' | 'bottom' | 'left'): void;
1717
text(x: number, y: number, item: ShapedItem, textStart: number, textEnd: number, isColorBoundary?: boolean): void;

src/text-font.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,9 @@ export interface RegisterFontOptions {
473473
}
474474

475475
export async function registerFont(url: URL, options?: RegisterFontOptions): Promise<void>;
476-
export async function registerFont(buffer: ArrayBuffer, url: URL, options?: RegisterFontOptions): Promise<void>;
476+
export async function registerFont(buffer: ArrayBufferLike, url: URL, options?: RegisterFontOptions): Promise<void>;
477477
export async function registerFont(
478-
arg1: URL | ArrayBuffer,
478+
arg1: URL | ArrayBufferLike,
479479
arg2?: RegisterFontOptions | URL,
480480
arg3?: RegisterFontOptions
481481
) {
@@ -759,10 +759,6 @@ export function eachRegisteredFont(cb: (family: FaceMatch) => void) {
759759
}
760760
}
761761

762-
export function firstCascadeItem(): FaceMatch {
763-
return registeredFonts.values().next().value; // TODO Why is this any?
764-
}
765-
766762
const systemFontTrie = new UnicodeTrie(wasm.instance.exports.system_font_trie.value);
767763

768764
export function getFontUrls(root: HTMLElement) {

0 commit comments

Comments
 (0)