@createiq/htmldiff 1.0.2 → 1.0.4-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +15 -0
- package/.gitlab-ci.yml +5 -5
- package/CLAUDE.md +51 -0
- package/biome.json +3 -0
- package/dist/HtmlDiff.cjs +803 -810
- package/dist/HtmlDiff.cjs.map +1 -1
- package/dist/HtmlDiff.d.cts +149 -104
- package/dist/HtmlDiff.d.mts +152 -0
- package/dist/HtmlDiff.mjs +843 -0
- package/dist/HtmlDiff.mjs.map +1 -0
- package/mise.toml +2 -0
- package/package.json +21 -14
- package/src/HtmlDiff.ts +199 -13
- package/test/HtmlDiff.spec.ts +67 -27
- package/test/structural1.html +366 -0
- package/test/structural2.html +366 -0
- package/{tsup.config.ts → tsdown.config.ts} +1 -3
- package/vitest.config.mts +1 -1
- package/.node-version +0 -1
- package/dist/HtmlDiff.d.ts +0 -106
- package/dist/HtmlDiff.js +0 -827
- package/dist/HtmlDiff.js.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(diff -u test/input1.html test/input2.html)",
|
|
5
|
+
"Bash(npm test -- test/Bug.spec.tsx)",
|
|
6
|
+
"Bash(timeout 30s npm run test:ci -- test/Bug.spec.tsx)",
|
|
7
|
+
"Bash(npm run build)",
|
|
8
|
+
"Bash(timeout 10s npm run test:ci -- test/Bug.spec.tsx)",
|
|
9
|
+
"Bash(npm run lint)",
|
|
10
|
+
"Bash(npm run test:ci)",
|
|
11
|
+
"Bash(npm run bench:ci)"
|
|
12
|
+
],
|
|
13
|
+
"deny": []
|
|
14
|
+
}
|
|
15
|
+
}
|
package/.gitlab-ci.yml
CHANGED
|
@@ -8,7 +8,7 @@ default:
|
|
|
8
8
|
|
|
9
9
|
"Run unit tests":
|
|
10
10
|
stage: test
|
|
11
|
-
image: ${ACR_HOSTNAME}/infra/baseimages/node:
|
|
11
|
+
image: ${ACR_HOSTNAME}/infra/baseimages/node:24-alpine
|
|
12
12
|
before_script:
|
|
13
13
|
- npm ci --prefer-offline --no-audit
|
|
14
14
|
script:
|
|
@@ -32,7 +32,7 @@ default:
|
|
|
32
32
|
|
|
33
33
|
"Lint":
|
|
34
34
|
stage: test
|
|
35
|
-
image: ${ACR_HOSTNAME}/infra/baseimages/node:
|
|
35
|
+
image: ${ACR_HOSTNAME}/infra/baseimages/node:24-alpine
|
|
36
36
|
before_script:
|
|
37
37
|
- npm ci --prefer-offline --no-audit
|
|
38
38
|
script:
|
|
@@ -49,7 +49,7 @@ default:
|
|
|
49
49
|
# TODO this runs on gke01-london for firewall reasons to be able to talk to registry.npmjs.org
|
|
50
50
|
"Publish to npm - dry-run":
|
|
51
51
|
stage: deploy
|
|
52
|
-
image: ${CI_REGISTRY}/infra/baseimages/node:
|
|
52
|
+
image: ${CI_REGISTRY}/infra/baseimages/node:24-alpine
|
|
53
53
|
before_script:
|
|
54
54
|
- npm ci --prefer-offline --no-audit
|
|
55
55
|
script:
|
|
@@ -67,7 +67,7 @@ default:
|
|
|
67
67
|
# TODO this runs on gke01-london for firewall reasons to be able to talk to registry.npmjs.org
|
|
68
68
|
"Publish to npm":
|
|
69
69
|
stage: deploy
|
|
70
|
-
image: ${CI_REGISTRY}/infra/baseimages/node:
|
|
70
|
+
image: ${CI_REGISTRY}/infra/baseimages/node:24-alpine
|
|
71
71
|
before_script:
|
|
72
72
|
- npm ci --prefer-offline --no-audit
|
|
73
73
|
script:
|
|
@@ -83,7 +83,7 @@ default:
|
|
|
83
83
|
|
|
84
84
|
.generate_sbom: &generate_sbom
|
|
85
85
|
stage: generate_artifacts
|
|
86
|
-
image: ${ACR_HOSTNAME}/infra/baseimages/node:
|
|
86
|
+
image: ${ACR_HOSTNAME}/infra/baseimages/node:24-alpine
|
|
87
87
|
before_script:
|
|
88
88
|
- npm ci --prefer-offline --no-audit
|
|
89
89
|
script:
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Development Commands
|
|
6
|
+
|
|
7
|
+
- **Build**: `npm run build` - Builds ESM and CJS modules using tsup
|
|
8
|
+
- **Test**: `npm test` - Runs tests in watch mode using Vitest
|
|
9
|
+
- **Test CI**: `npm run test:ci` - Runs tests once for CI environments
|
|
10
|
+
- **Test Debug**: `npm run test-debug` - Runs tests with debugging enabled
|
|
11
|
+
- **Lint**: `npm run lint` - Runs Biome linter with error-on-warnings
|
|
12
|
+
- **Lint Fix**: `npm run lint:fix` - Runs linter and auto-fixes issues
|
|
13
|
+
- **Format**: `npm run format` - Checks code formatting with Biome
|
|
14
|
+
- **Format Fix**: `npm run format:fix` - Auto-formats code with Biome
|
|
15
|
+
|
|
16
|
+
## Architecture
|
|
17
|
+
|
|
18
|
+
This is a TypeScript HTML diff library that compares two HTML snippets and highlights differences. It's a port of the C# HtmlDiff.NET library.
|
|
19
|
+
|
|
20
|
+
### Core Components
|
|
21
|
+
|
|
22
|
+
- **HtmlDiff** (`src/HtmlDiff.ts`): Main class with `execute()` static method and configurable instance options
|
|
23
|
+
- **WordSplitter** (`src/WordSplitter.ts`): Converts HTML to word arrays for comparison
|
|
24
|
+
- **MatchFinder** (`src/MatchFinder.ts`): Finds matching blocks between old and new text
|
|
25
|
+
- **Operation** (`src/Operation.ts`): Represents diff operations (Equal, Insert, Delete, Replace)
|
|
26
|
+
- **Action** (`src/Action.ts`): Enum for operation types
|
|
27
|
+
- **Match** (`src/Match.ts`): Represents matched text blocks
|
|
28
|
+
- **Utils** (`src/Utils.ts`): Utility functions for HTML tag handling
|
|
29
|
+
|
|
30
|
+
### Key Features
|
|
31
|
+
|
|
32
|
+
- Configurable diff accuracy via `repeatingWordsAccuracy` (0-1)
|
|
33
|
+
- Whitespace difference handling via `ignoreWhitespaceDifferences`
|
|
34
|
+
- Orphan match filtering via `orphanMatchThreshold`
|
|
35
|
+
- Block expressions for grouping text (dates, etc.)
|
|
36
|
+
- Special handling for HTML formatting tags
|
|
37
|
+
|
|
38
|
+
### Build System
|
|
39
|
+
|
|
40
|
+
- **tsup**: Builds ESM/CJS modules from `src/HtmlDiff.ts` entry point
|
|
41
|
+
- **Biome**: Handles linting and formatting (replaces ESLint/Prettier)
|
|
42
|
+
- **Vitest**: Test runner with coverage reporting
|
|
43
|
+
- **Husky**: Git hooks with lint-staged for pre-commit checks
|
|
44
|
+
|
|
45
|
+
### Testing
|
|
46
|
+
|
|
47
|
+
Tests are in `/test` directory using Vitest. Run `npm test` for watch mode or `npm run test:ci` for single run. Coverage reports generated with Istanbul provider.
|
|
48
|
+
|
|
49
|
+
### Release Process
|
|
50
|
+
|
|
51
|
+
Releases happen via merge requests to `prod` branch from `main`. Version must be bumped in package.json following semver.
|