Automate NPM package releases (#1119)

This commit is contained in:
Justin Halsall
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 19be06d936
commit 27caffecff
43 changed files with 1300 additions and 392 deletions

View File

@@ -36,15 +36,16 @@ export class RRWindow {
export class RRDocument
extends BaseRRDocumentImpl(RRNode)
implements IRRDocument {
implements IRRDocument
{
readonly nodeName: '#document' = '#document';
private _nwsapi: NWSAPI;
get nwsapi() {
if (!this._nwsapi) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
this._nwsapi = nwsapi({
document: (this as unknown) as Document,
DOMException: (null as unknown) as new (
document: this as unknown as Document,
DOMException: null as unknown as new (
message?: string,
name?: string,
) => DOMException,
@@ -97,7 +98,7 @@ export class RRDocument
}
querySelectorAll(selectors: string): RRNode[] {
return (this.nwsapi.select(selectors) as unknown) as RRNode[];
return this.nwsapi.select(selectors) as unknown as RRNode[];
}
getElementsByTagName(tagName: string): RRElement[] {
@@ -220,7 +221,7 @@ export class RRElement extends BaseRRElementImpl(RRNode) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
get style() {
return (this._style as unknown) as CSSStyleDeclaration;
return this._style as unknown as CSSStyleDeclaration;
}
attachShadow(_init: ShadowRootInit): RRElement {
@@ -268,14 +269,14 @@ export class RRElement extends BaseRRElementImpl(RRNode) {
querySelectorAll(selectors: string): RRNode[] {
const result: RRElement[] = [];
if (this.ownerDocument !== null) {
((this.ownerDocument as RRDocument).nwsapi.select(
(this.ownerDocument as RRDocument).nwsapi.select(
selectors,
(this as unknown) as Element,
this as unknown as Element,
(element) => {
if (((element as unknown) as RRElement) !== this)
result.push((element as unknown) as RRElement);
if ((element as unknown as RRElement) !== this)
result.push(element as unknown as RRElement);
},
) as unknown) as RRNode[];
) as unknown as RRNode[];
}
return result;
}
@@ -393,6 +394,5 @@ interface RRElementTagNameMap {
video: RRMediaElement;
}
type RRElementType<
K extends keyof HTMLElementTagNameMap
> = K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement;
type RRElementType<K extends keyof HTMLElementTagNameMap> =
K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement;

View File

@@ -51,10 +51,10 @@ export function polyfillRAF() {
}
}
(global as Window &
typeof globalThis).requestAnimationFrame = requestAnimationFrame;
(global as Window &
typeof globalThis).cancelAnimationFrame = cancelAnimationFrame;
(global as Window & typeof globalThis).requestAnimationFrame =
requestAnimationFrame;
(global as Window & typeof globalThis).cancelAnimationFrame =
cancelAnimationFrame;
}
/**
@@ -88,5 +88,5 @@ export function polyfillDocument() {
rrdom.documentElement!.appendChild(rrdom.createElement('head'));
rrdom.documentElement!.appendChild(rrdom.createElement('body'));
})();
global.document = (rrdom as unknown) as Document;
global.document = rrdom as unknown as Document;
}

View File

@@ -26,7 +26,7 @@ describe('polyfill for nodejs', () => {
polyfillPerformance();
expect(global.performance).toBe(originalPerformance);
}
const fakePerformance = (jest.fn() as unknown) as Performance;
const fakePerformance = jest.fn() as unknown as Performance;
global.performance = fakePerformance;
polyfillPerformance();
expect(global.performance).toEqual(fakePerformance);
@@ -72,9 +72,11 @@ describe('polyfill for nodejs', () => {
});
it('should not polyfill requestAnimationFrame if it already exists', () => {
const fakeRequestAnimationFrame = (jest.fn() as unknown) as typeof global.requestAnimationFrame;
const fakeRequestAnimationFrame =
jest.fn() as unknown as typeof global.requestAnimationFrame;
global.requestAnimationFrame = fakeRequestAnimationFrame;
const fakeCancelAnimationFrame = (jest.fn() as unknown) as typeof global.cancelAnimationFrame;
const fakeCancelAnimationFrame =
jest.fn() as unknown as typeof global.cancelAnimationFrame;
global.cancelAnimationFrame = fakeCancelAnimationFrame;
polyfillRAF();
expect(global.requestAnimationFrame).toBe(fakeRequestAnimationFrame);
@@ -91,7 +93,7 @@ describe('polyfill for nodejs', () => {
});
it('should not polyfill Event type if it already exists', () => {
const fakeEvent = (jest.fn() as unknown) as typeof global.Event;
const fakeEvent = jest.fn() as unknown as typeof global.Event;
global.Event = fakeEvent;
polyfillEvent();
expect(global.Event).toBe(fakeEvent);
@@ -106,7 +108,7 @@ describe('polyfill for nodejs', () => {
});
it('should not polyfill Node type if it already exists', () => {
const fakeNode = (jest.fn() as unknown) as typeof global.Node;
const fakeNode = jest.fn() as unknown as typeof global.Node;
global.Node = fakeNode;
polyfillNode();
expect(global.Node).toBe(fakeNode);
@@ -121,7 +123,7 @@ describe('polyfill for nodejs', () => {
});
it('should not polyfill document object if it already exists', () => {
const fakeDocument = (jest.fn() as unknown) as typeof global.document;
const fakeDocument = jest.fn() as unknown as typeof global.document;
global.document = fakeDocument;
polyfillDocument();
expect(global.document).toBe(fakeDocument);