Skip to content

Commit

Permalink
Merge pull request #1 from rrweb-io/releases
Browse files Browse the repository at this point in the history
Releases via GitHub Actions
  • Loading branch information
Juice10 authored Feb 9, 2023
2 parents 174b9ac + 8265299 commit f6cd29b
Show file tree
Hide file tree
Showing 42 changed files with 1,285 additions and 391 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
push:
branches:
- master

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js lts/*
uses: actions/setup-node@v3
with:
node-version: lts/*

- name: Install Dependencies
run: yarn

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: yarn build:all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Send a Slack notification if a publish happens
# if: steps.changesets.outputs.published == 'true'
# # You can do something when a publish happens.
# run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"packages/*"
],
"devDependencies": {
"@changesets/cli": "^2.26.0",
"@monorepo-utils/workspaces-to-typescript-project-references": "^2.8.2",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
Expand Down
26 changes: 13 additions & 13 deletions packages/rrdom-nodejs/src/document-nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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[] {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
10 changes: 5 additions & 5 deletions packages/rrdom-nodejs/src/polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}
14 changes: 8 additions & 6 deletions packages/rrdom-nodejs/test/polyfill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions packages/rrdom/src/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,9 @@ function diffAfterUpdatingChildren(
oldTree.textContent !==
(newTree as IRRText | IRRComment | IRRCDATASection).data
)
oldTree.textContent = (newTree as
| IRRText
| IRRComment
| IRRCDATASection).data;
oldTree.textContent = (
newTree as IRRText | IRRComment | IRRCDATASection
).data;
break;
}
}
Expand Down
24 changes: 13 additions & 11 deletions packages/rrdom/src/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class BaseRRNode implements IRRNode {
}

export function BaseRRDocumentImpl<
RRNode extends ConstrainedConstructor<IRRNode>
RRNode extends ConstrainedConstructor<IRRNode>,
>(RRNodeClass: RRNode) {
return class BaseRRDocument extends RRNodeClass implements IRRDocument {
public readonly nodeType: number = NodeType.DOCUMENT_NODE;
Expand Down Expand Up @@ -401,13 +401,14 @@ export function BaseRRDocumentImpl<
}

export function BaseRRDocumentTypeImpl<
RRNode extends ConstrainedConstructor<IRRNode>
RRNode extends ConstrainedConstructor<IRRNode>,
>(RRNodeClass: RRNode) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return class BaseRRDocumentType
extends RRNodeClass
implements IRRDocumentType {
implements IRRDocumentType
{
public readonly nodeType: number = NodeType.DOCUMENT_TYPE_NODE;
public readonly RRNodeType = RRNodeType.DocumentType;
public readonly nodeName: string;
Expand All @@ -431,7 +432,7 @@ export function BaseRRDocumentTypeImpl<
}

export function BaseRRElementImpl<
RRNode extends ConstrainedConstructor<IRRNode>
RRNode extends ConstrainedConstructor<IRRNode>,
>(RRNodeClass: RRNode) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down Expand Up @@ -479,9 +480,9 @@ export function BaseRRElementImpl<
}

public get style() {
const style = (this.attributes.style
? parseCSSText(this.attributes.style)
: {}) as CSSStyleDeclaration;
const style = (
this.attributes.style ? parseCSSText(this.attributes.style) : {}
) as CSSStyleDeclaration;
const hyphenateRE = /\B([A-Z])/g;
style.setProperty = (
name: string,
Expand Down Expand Up @@ -583,7 +584,7 @@ export function BaseRRElementImpl<
}

export function BaseRRMediaElementImpl<
RRElement extends ConstrainedConstructor<IRRElement>
RRElement extends ConstrainedConstructor<IRRElement>,
>(RRElementClass: RRElement) {
return class BaseRRMediaElement extends RRElementClass {
public currentTime?: number;
Expand Down Expand Up @@ -637,7 +638,7 @@ export function BaseRRTextImpl<RRNode extends ConstrainedConstructor<IRRNode>>(
}

export function BaseRRCommentImpl<
RRNode extends ConstrainedConstructor<IRRNode>
RRNode extends ConstrainedConstructor<IRRNode>,
>(RRNodeClass: RRNode) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down Expand Up @@ -667,13 +668,14 @@ export function BaseRRCommentImpl<
}

export function BaseRRCDATASectionImpl<
RRNode extends ConstrainedConstructor<IRRNode>
RRNode extends ConstrainedConstructor<IRRNode>,
>(RRNodeClass: RRNode) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return class BaseRRCDATASection
extends RRNodeClass
implements IRRCDATASection {
implements IRRCDATASection
{
public readonly nodeName: '#cdata-section' = '#cdata-section';
public readonly nodeType: number = NodeType.CDATA_SECTION_NODE;
public readonly RRNodeType = RRNodeType.CDATA;
Expand Down
5 changes: 2 additions & 3 deletions packages/rrdom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ 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;

function getValidTagName(element: HTMLElement): string {
// https://github.com/rrweb-io/rrweb-snapshot/issues/56
Expand Down
Loading

0 comments on commit f6cd29b

Please sign in to comment.