Skip to content

Commit ea52d9c

Browse files
Merge branch 'release/1.1.0'
2 parents 8399544 + 29a7f5f commit ea52d9c

17 files changed

+118
-58
lines changed

Diff for: .eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
{
3131
"ignore": [
3232
"history",
33+
"lodash",
3334
// Workaround for alexgorbatchev/eslint-import-resolver-typescript#17
3435
"regexp-tree/ast",
3536
"RegexColorizer"

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22
node_js:
33
- 'node'
4-
- '8'
4+
- '10'
55
script:
66
- npm run travisci
77
cache:

Diff for: demo/index.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<script
4545
crossorigin="anonymous"
46-
src="https://polyfill.app/api/polyfill?features=url,es.number.is-nan,es.string.raw,event.constructor&context=window"
46+
src="https://polyfill.app/api/polyfill?features=class-list,es.array.includes,es.number.is-nan,es.string.raw,event.constructor,url&context=window"
4747
></script>
4848
</head>
4949

@@ -125,6 +125,7 @@
125125
id="delimiter"
126126
class="form-control js-delimiter track-field"
127127
>
128+
<option value="block">Block</option>
128129
<option value="&#10;">Newline</option>
129130
<option value=",">Comma</option>
130131
<option value=" ">Space</option>
@@ -171,7 +172,7 @@
171172
<div class="card-header">
172173
Your Regular Expression, optimized and colored:
173174
</div>
174-
<div class="card-body js-output-optimized"></div>
175+
<div class="card-body output-optimized js-output-optimized"></div>
175176
<div class="card-footer text-muted">
176177
Optimization by
177178
<a
@@ -184,7 +185,7 @@
184185
</div>
185186
</div>
186187

187-
<div class="form-group output-container">
188+
<div class="form-group output-container js-output-container">
188189
<label for="output">
189190
Strings matched by your Regular Expression:
190191
</label>
@@ -250,6 +251,11 @@ <h5 class="card-title">Thanks for your feedback!</h5>
250251
integrity="sha256-MuBtHI2giF+TT2E9FjNxVovCaSkndV8cq59ddt915Co="
251252
src="https://cdnjs.cloudflare.com/ajax/libs/history/4.9.0/history.min.js"
252253
></script>
254+
<script
255+
crossorigin="anonymous"
256+
integrity="sha256-yEkk5ZYVs/fZgvxWU+sCb8bHTk9jScxIaZQD+CZ4vcg="
257+
src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.core.min.js"
258+
></script>
253259
<script src="https://cdn.jsdelivr.net/gh/slevithan/[email protected]/regex-colorizer.min.js"></script>
254260
<script type="text/javascript" src="lib/demo.js"></script>
255261
</body>

Diff for: demo/src/_variables.scss

+12
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,15 @@ $breakpoint-sm: 576px;
3030
$breakpoint-md: 768px;
3131
$breakpoint-lg: 992px;
3232
$breakpoint-xl: 1200px;
33+
34+
@mixin md-only {
35+
@media (min-width: #{$breakpoint-md}) and (max-width: #{$breakpoint-lg - 1px}) {
36+
@content;
37+
}
38+
}
39+
40+
@mixin lg-up {
41+
@media (min-width: #{$breakpoint-lg}) {
42+
@content;
43+
}
44+
}

Diff for: demo/src/components/demo-form.scss

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
@import '../_variables';
22

3+
#pattern {
4+
font-size: 140%;
5+
}
6+
7+
#max-results,
8+
#delimiter {
9+
// Inherit from <body>: https://stackoverflow.com/a/2875114
10+
font-size: inherit;
11+
}
12+
313
input:invalid,
414
textarea:invalid,
515
select:invalid {
616
border: 2px solid $danger;
717
}
818

9-
.automaticHeight {
10-
box-sizing: padding-box;
11-
overflow: hidden;
12-
resize: none;
13-
}
14-
1519
.alert pre {
1620
color: inherit;
1721
margin-top: 1em;

Diff for: demo/src/components/demo-output.scss

+23-6
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,37 @@ span[title] {
99
margin-top: 1em;
1010
}
1111

12+
.output-optimized {
13+
font-size: 125%;
14+
}
15+
1216
#output {
13-
border: 1px $primary dotted;
14-
font-size: 1.1em;
15-
height: 30em;
16-
line-height: 1.6em;
17-
padding: 0.5em;
17+
font-size: 1rem;
18+
line-height: 1.6rem;
19+
20+
&.plaintext-output {
21+
border: 1px $primary dotted;
22+
max-height: 30em;
23+
padding: 0.5em;
24+
}
1825

1926
&.wrap-output {
2027
white-space: pre-wrap;
2128
}
2229

23-
&.is-waiting {
30+
&:not(.plaintext-output) > * {
31+
margin-bottom: -0.75em;
32+
overflow: auto;
33+
34+
&:last-child {
35+
margin-bottom: 0;
36+
}
37+
}
38+
39+
.is-waiting & {
2440
background: no-repeat center/5em
2541
url('https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.19.3/images/loader-large.gif');
42+
height: 20px + 64px + 20px; // height of loading graphic, plus padding
2643
}
2744

2845
& > :nth-child(odd) {

Diff for: demo/src/components/demo-output.ts

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
/* eslint-disable lines-between-class-members */
22

3+
import { escape } from 'lodash'; // eslint-disable-line import/no-extraneous-dependencies
34
import { colorizeRegex } from '../utils/colorize-regex';
45
import { getElement } from '../utils/dom';
56

67
import './demo-output.scss';
78

89
export default class DemoOutput {
10+
protected $container: HTMLDivElement;
911
protected $expansions: HTMLPreElement;
1012
protected $displayCount: HTMLSpanElement;
1113
protected $totalCount: HTMLSpanElement;
1214
protected $optimized: HTMLDivElement;
1315
protected $optimizedContainer: HTMLDivElement;
1416

1517
public constructor() {
18+
this.$container = getElement('.js-output-container');
1619
this.$expansions = getElement('.js-output');
1720
this.$displayCount = getElement('.js-output-count');
1821
this.$totalCount = getElement('.js-total-count');
@@ -21,15 +24,27 @@ export default class DemoOutput {
2124
}
2225

2326
public display(expansions: string[], delimiter: string) {
24-
this.$expansions.classList.toggle('wrap-output', delimiter !== '\n');
25-
this.$expansions.innerHTML = expansions
26-
.map(string => `<span>${string}</span>`)
27-
.join(delimiter);
27+
const isBlockOutput = delimiter === 'block';
28+
const isWrappingDelimiter = ['\n', 'block'].includes(delimiter);
29+
30+
this.$expansions.classList.toggle('plaintext-output', !isBlockOutput);
31+
this.$expansions.classList.toggle('wrap-output', !isWrappingDelimiter);
32+
33+
if (isBlockOutput) {
34+
this.$expansions.innerHTML = expansions
35+
.map(string => `<div class="alert alert-light">${escape(string)}</div>`)
36+
.join('\n');
37+
} else {
38+
this.$expansions.innerHTML = expansions
39+
.map(string => `<span>${escape(string)}</span>`)
40+
.join(delimiter);
41+
}
42+
2843
this.$displayCount.innerText = expansions.length.toLocaleString();
2944
}
3045

3146
public hideWaiting() {
32-
this.$expansions.classList.remove('is-waiting');
47+
this.$container.classList.remove('is-waiting');
3348
}
3449

3550
public setOptimizedPattern(optimizedPattern: string) {
@@ -46,9 +61,12 @@ export default class DemoOutput {
4661
}
4762

4863
public showWaiting() {
64+
this.$container.classList.add('is-waiting');
65+
66+
this.$expansions.classList.remove('plaintext-output', 'wrap-output');
4967
this.$expansions.innerHTML = '';
50-
this.$expansions.classList.add('is-waiting');
51-
this.$optimizedContainer.hidden = true;
68+
69+
this.$optimized.textContent = '...';
5270
this.$displayCount.innerText = '...';
5371
this.$totalCount.innerText = '...';
5472
}

Diff for: demo/src/demo.scss

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
@import './_variables';
2+
3+
body {
4+
@include md-only {
5+
font-size: 1em;
6+
}
7+
@include lg-up {
8+
font-size: 1.1em;
9+
}
10+
}
11+
112
.navbar {
213
> .container {
314
justify-content: inherit;

Diff for: demo/src/demo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ initializeNewWorker();
115115
const urlData = UrlStorage.read();
116116
const exampleInput = String.raw`/^((https?|ftp|file):\/\/)?([\d\-a-z]{1,5}\.){2,5}([a-z]{2,6})\/([\d\-._a-z]{1,10}\/){0,5}$/`;
117117
const initialData = {
118-
delimiter: urlData.delimiter || '&#10;', // newline
118+
delimiter: urlData.delimiter || 'block',
119119
numResults: urlData.numResults || 100,
120120
pattern: urlData.pattern || exampleInput,
121121
};

Diff for: demo/src/utils/auto-expand-field.scss

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.automaticHeight {
2+
box-sizing: padding-box;
3+
overflow: hidden;
4+
resize: none;
5+
}

Diff for: demo/src/utils/auto-expand-field.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["field"] }] */
2+
import './auto-expand-field.scss';
23

34
/* eslint-disable @typescript-eslint/no-explicit-any */
45
/**

Diff for: demo/src/worker/polyfills.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const featuresToPolyfill = [
44
'es.array.includes',
55
'es.array.iterator',
66
'es.number.is-finite',
7+
'es.number.is-integer',
78
'es.object.assign',
89
'es.string.code-point-at',
910
'es.string.from-code-point',

Diff for: demo/webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
mode: 'production',
77
externals: {
88
history: 'History',
9+
lodash: '_',
910
RegexColorizer: 'RegexColorizer',
1011
},
1112
module: {

Diff for: jest.config.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ module.exports = {
99
tsConfig: 'tsconfig.test.json',
1010
},
1111
},
12-
moduleFileExtensions: ['js', 'json', 'ts'],
12+
preset: 'ts-jest',
13+
restoreMocks: true,
1314
testEnvironment: 'node',
14-
testMatch: ['**/src/**/?*.spec.(js|ts)'],
15-
transform: {
16-
'^.+\\.ts$': 'ts-jest',
17-
},
1815
verbose: true,
1916
};

Diff for: package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "regex-to-strings",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wimpyprogrammer/regex-to-strings.git"
@@ -15,26 +15,25 @@
1515
"main": "lib/index.js",
1616
"types": "./lib/index.d.ts",
1717
"files": [
18-
"lib/**/!(*.spec).js",
19-
"lib/**/*.d.ts"
18+
"lib/"
2019
],
2120
"sideEffects": [
2221
"demo/**/polyfills.ts",
2322
"*.scss"
2423
],
2524
"engines": {
26-
"node": ">=8"
25+
"node": ">=10"
2726
},
2827
"scripts": {
29-
"build": "npm run clean && babel src -d lib --extensions '.js,.ts' && npm run build-types",
28+
"build": "npm run clean && babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts' && npm run build-types",
3029
"build-demo": "npm run clean-demo && webpack --config demo/webpack.config.js",
3130
"build-types": "tsc -p ./tsconfig.release-types.json",
3231
"clean": "rimraf lib/*",
3332
"clean-demo": "rimraf demo/lib/*",
3433
"format": "prettier --write '{src,demo/src}/**'",
35-
"lint": "tsc -p ./tsconfig.release.json; eslint . --ext .js,.ts --parser-options=project:./tsconfig.release.json",
36-
"lint-demo": "tsc -p ./demo/tsconfig.json; eslint . --ext .js,.ts --parser-options=project:./demo/tsconfig.json",
37-
"lint-tests": "tsc -p ./tsconfig.test.json; eslint . --ext .js,.ts --parser-options=project:./tsconfig.test.json",
34+
"lint": "tsc -p ./tsconfig.release.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./tsconfig.release.json",
35+
"lint-demo": "tsc -p ./demo/tsconfig.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./demo/tsconfig.json",
36+
"lint-tests": "tsc -p ./tsconfig.test.json && eslint . --ext .js,.ts --report-unused-disable-directives --parser-options=project:./tsconfig.test.json",
3837
"precommit": "pretty-quick --staged",
3938
"prepublish": "npx publish-please guard",
4039
"publish-please": "npx publish-please",
@@ -48,10 +47,11 @@
4847
"@babel/plugin-proposal-class-properties": "^7.5.5",
4948
"@babel/preset-env": "^7.5.5",
5049
"@babel/preset-typescript": "^7.3.3",
51-
"@types/escape-string-regexp": "^1.0.0",
50+
"@types/escape-string-regexp": "^2.0.1",
5251
"@types/history": "^4.7.3",
53-
"@types/jest": "^24.0.18",
52+
"@types/jest": "^26.0.10",
5453
"@types/jest-when": "^2.4.1",
54+
"@types/lodash": "^4.14.140",
5555
"@typescript-eslint/eslint-plugin": "^1.13.0",
5656
"@typescript-eslint/parser": "^1.13.0",
5757
"codecov": "^3.5.0",
@@ -63,25 +63,25 @@
6363
"eslint-plugin-import": "^2.18.2",
6464
"eslint-plugin-jest": "^22.16.0",
6565
"husky": "0.14.3",
66-
"jest": "^24.9.0",
66+
"jest": "^26.4.2",
6767
"jest-when": "^2.7.0",
6868
"node-sass": "^4.12.0",
6969
"prettier": "1.18.2",
7070
"pretty-quick": "1.7.0",
7171
"rimraf": "^2.7.1",
7272
"sass-loader": "^7.3.1",
7373
"style-loader": "^1.0.0",
74-
"ts-jest": "^24.0.2",
74+
"ts-jest": "^26.3.0",
7575
"ts-loader": "^6.0.4",
7676
"typescript": "^3.6.2",
7777
"webpack": "^4.39.3",
7878
"webpack-command": "^0.4.2",
7979
"worker-loader": "^2.0.0"
8080
},
8181
"dependencies": {
82-
"escape-string-regexp": "^1.0.5",
82+
"escape-string-regexp": "^4.0.0",
8383
"pandemonium": "^1.4.1",
84-
"regexp-tree": "0.1.11"
84+
"regexp-tree": "^0.1.21"
8585
},
8686
"snyk": true
8787
}

0 commit comments

Comments
 (0)