Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ temp

build
dist

.turbo
4 changes: 4 additions & 0 deletions .vscode/rrweb-monorepo.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"name": "rrdom (package)",
"path": "../packages/rrdom"
},
{
"name": "rrdom-nodejs (package)",
"path": "../packages/rrdom-nodejs"
},
{
"name": "rrweb (package)",
"path": "../packages/rrweb"
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/dive-into-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ source -> IncrementalSource.Font
data -> fontData
```

enum IncrementalSource's definition can be found in this [list](https://github.com/rrweb-io/rrweb/blob/master/src/types.ts#L64).
enum IncrementalSource's definition can be found in this [list](https://github.com/rrweb-io/rrweb/blob/master/packages/rrweb/typings/types.d.ts#L62).
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
"private": true,
"homepage": "https://github.com/rrweb-io/rrweb#readme",
"workspaces": [
"packages/rrweb",
"packages/rrweb-snapshot",
"packages/rrweb-player",
"packages/rrdom"
"packages/*"
],
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.25.0",
Expand All @@ -29,17 +26,18 @@
"lerna": "^4.0.0",
"markdownlint": "^0.25.1",
"markdownlint-cli": "^0.31.1",
"typescript": "^4.6.4"
"turbo": "^1.2.4",
"typescript": "^4.7.3"
},
"scripts": {
"lerna": "lerna",
"build:all": "yarn lerna run prepublish",
"test": "yarn lerna run test",
"test:watch": "yarn lerna run test:watch --parallel",
"dev": "yarn lerna run dev --parallel",
"build:all": "yarn turbo run prepublish",
"test": "yarn turbo run test",
"test:watch": "yarn turbo run test:watch",
"dev": "yarn turbo run dev",
"repl": "cd packages/rrweb && npm run repl",
"lint": "yarn run concurrently --success=all -r -m=1 'yarn run markdownlint docs' 'yarn eslint packages/*/src --ext .ts,.tsx,.js,.jsx,.svelte'",
"clean": "rm -rf dist node_modules packages/**/build packages/**/es packages/**/dist packages/**/lib packages/**/node_modules"
"clean": "rm -rf dist node_modules packages/**/.turbo packages/**/build packages/**/es packages/**/dist packages/**/lib packages/**/node_modules"
},
"resolutions": {
"**/jsdom/cssom": "^0.5.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/rrdom-nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
es
lib
typings
3 changes: 3 additions & 0 deletions packages/rrdom-nodejs/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["orta.vscode-jest"]
}
15 changes: 15 additions & 0 deletions packages/rrdom-nodejs/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"cwd": "${workspaceFolder}",
"runtimeExecutable": "yarn",
"args": ["test", "--runInBand", "--watchAll=false"]
}
]
}
3 changes: 3 additions & 0 deletions packages/rrdom-nodejs/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"jest.jestCommandLine": "yarn test"
}
5 changes: 5 additions & 0 deletions packages/rrdom-nodejs/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
55 changes: 55 additions & 0 deletions packages/rrdom-nodejs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "@highlight-run/rrdom-nodejs",
"version": "0.1.2",
"scripts": {
"dev": "rollup -c -w",
"bundle": "rollup --config",
"bundle:es-only": "cross-env ES_ONLY=true rollup --config",
"check-types": "tsc -noEmit",
"test": "jest",
"prepublish": "npm run bundle",
"lint": "yarn eslint src/**/*.ts"
},
"keywords": [
"rrweb",
"rrdom-nodejs"
],
"license": "MIT",
"main": "lib/rrdom-nodejs.js",
"module": "es/rrdom-nodejs.js",
"typings": "es",
"files": [
"dist",
"lib",
"es",
"typings"
],
"devDependencies": {
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@types/cssom": "^0.4.1",
"@types/cssstyle": "^2.2.1",
"@types/jest": "^27.4.1",
"@types/nwsapi": "^2.2.2",
"@types/puppeteer": "^5.4.4",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"compare-versions": "^4.1.3",
"eslint": "^8.15.0",
"jest": "^27.5.1",
"puppeteer": "^9.1.1",
"rollup": "^2.56.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"ts-jest": "^27.1.3",
"typescript": "^4.7.3"
},
"dependencies": {
"cssom": "^0.5.0",
"cssstyle": "^2.3.0",
"nwsapi": "^2.2.0",
"@highlight-run/rrweb-snapshot": ">=1.1.15",
"@highlight-run/rrdom": ">=0.1.12"
}
}
84 changes: 84 additions & 0 deletions packages/rrdom-nodejs/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import pkg from './package.json';

function toMinPath(path) {
return path.replace(/\.js$/, '.min.js');
}

const basePlugins = [
resolve({ browser: true }),
commonjs(),

// supports bundling `web-worker:..filename` from rrweb
webWorkerLoader(),

typescript({
tsconfigOverride: { compilerOptions: { module: 'ESNext' } },
}),
];

const baseConfigs = [
{
input: './src/index.ts',
name: pkg.name,
path: pkg.name,
},
{
input: './src/document-nodejs.ts',
name: 'RRDocument',
path: 'document-nodejs',
},
];

let configs = [];
let extraConfigs = [];
for (let config of baseConfigs) {
configs.push(
// ES module
{
input: config.input,
plugins: basePlugins,
output: [
{
format: 'esm',
file: pkg.module.replace(pkg.name, config.path),
},
],
},
);
extraConfigs.push(
// CommonJS
{
input: config.input,
plugins: basePlugins,
output: [
{
format: 'cjs',
file: pkg.main.replace(pkg.name, config.path),
},
],
},
// ES module (packed)
{
input: config.input,
plugins: basePlugins.concat(terser()),
output: [
{
format: 'esm',
file: toMinPath(pkg.module).replace(pkg.name, config.path),
sourcemap: true,
},
],
},
);
}

if (!process.env.ES_ONLY) {
configs.push(...extraConfigs);
}

export default configs;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ClassList,
IRRDocument,
CSSStyleDeclaration,
} from './document';
} from '@highlight-run/rrdom';
const nwsapi = require('nwsapi');
const cssom = require('cssom');
const cssstyle = require('cssstyle');
Expand Down Expand Up @@ -53,22 +53,27 @@ export class RRDocument
return this._nwsapi;
}

// @ts-ignore
get documentElement(): RRElement | null {
return super.documentElement as RRElement | null;
}

// @ts-ignore
get body(): RRElement | null {
return super.body as RRElement | null;
}

// @ts-ignore
get head() {
return super.head as RRElement | null;
}

// @ts-ignore
get implementation(): RRDocument {
return this;
}

// @ts-ignore
get firstElementChild(): RRElement | null {
return this.documentElement;
}
Expand Down Expand Up @@ -198,6 +203,7 @@ export class RRElement extends BaseRRElementImpl(RRNode) {
});
}

// @ts-ignore
get style() {
return (this._style as unknown) as CSSStyleDeclaration;
}
Expand Down
13 changes: 13 additions & 0 deletions packages/rrdom-nodejs/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
polyfillPerformance,
polyfillRAF,
polyfillEvent,
polyfillNode,
polyfillDocument,
} from './polyfill';
polyfillPerformance();
polyfillRAF();
polyfillEvent();
polyfillNode();
polyfillDocument();
export * from './document-nodejs';
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
RRStyleElement,
RRText,
} from '../src/document-nodejs';
import { buildFromDom } from '../src/virtual-dom';
import { buildFromDom } from '@highlight-run/rrdom';

describe('RRDocument for nodejs environment', () => {
describe('RRDocument API', () => {
Expand Down Expand Up @@ -542,6 +542,6 @@ describe('RRDocument for nodejs environment', () => {
});

function getHtml(fileName: string) {
const filePath = path.resolve(__dirname, `./html/${fileName}`);
const filePath = path.resolve(__dirname, `../../rrdom/test/html/${fileName}`);
return fs.readFileSync(filePath, 'utf8');
}
20 changes: 20 additions & 0 deletions packages/rrdom-nodejs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"noImplicitAny": true,
"strictNullChecks": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"rootDir": "src",
"outDir": "build",
"lib": ["es6", "dom"],
"skipLibCheck": true,
"declaration": true,
"importsNotUsedAsValues": "error"
},
"compileOnSave": true,
"exclude": ["test"],
"include": ["src", "test.d.ts", "../rrweb/src/record/workers/workers.d.ts"]
}
Loading