@rindo/core 2.18.0 → 2.22.3
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/cli/config-flags.d.ts +33 -21
- package/cli/index.cjs +670 -388
- package/cli/index.d.ts +3 -0
- package/cli/index.js +670 -388
- package/cli/package.json +1 -1
- package/compiler/lib.dom.d.ts +434 -251
- package/compiler/lib.dom.iterable.d.ts +7 -13
- package/compiler/lib.es2015.collection.d.ts +62 -1
- package/compiler/lib.es2015.promise.d.ts +9 -4
- package/compiler/lib.es2015.proxy.d.ts +91 -2
- package/compiler/lib.es2015.reflect.d.ts +25 -2
- package/compiler/lib.es2015.symbol.wellknown.d.ts +3 -3
- package/compiler/lib.es2017.intl.d.ts +16 -1
- package/compiler/lib.es2019.d.ts +1 -0
- package/compiler/lib.es2019.intl.d.ts +25 -0
- package/compiler/lib.es2020.intl.d.ts +31 -6
- package/compiler/lib.es2021.intl.d.ts +11 -3
- package/compiler/lib.es2022.d.ts +1 -0
- package/compiler/lib.es2022.error.d.ts +2 -2
- package/compiler/lib.es2022.sharedmemory.d.ts +27 -0
- package/compiler/lib.es5.d.ts +39 -14
- package/compiler/lib.esnext.intl.d.ts +5 -1
- package/compiler/lib.webworker.d.ts +318 -55
- package/compiler/lib.webworker.iterable.d.ts +11 -3
- package/compiler/package.json +1 -1
- package/compiler/rindo.d.ts +3 -25
- package/compiler/rindo.js +53912 -51834
- package/compiler/rindo.min.js +2 -2
- package/compiler/sys/in-memory-fs.d.ts +3 -3
- package/compiler/transpile.d.ts +32 -0
- package/dependencies.json +3 -1
- package/dev-server/client/app-error.d.ts +1 -1
- package/dev-server/client/index.d.ts +2 -2
- package/dev-server/client/index.js +241 -241
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +3 -3
- package/dev-server/index.d.ts +1 -1
- package/dev-server/index.js +2 -2
- package/dev-server/open-in-editor-api.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +1182 -1148
- package/dev-server/ws.js +1 -1
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +2 -2
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +800 -673
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +19 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/polyfills/css-shim.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/index.js +154 -143
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.d.ts +1 -1
- package/internal/hydrate/runner.js +106 -106
- package/internal/package.json +1 -1
- package/internal/rindo-core/index.d.ts +9 -10
- package/internal/rindo-private.d.ts +149 -80
- package/internal/rindo-public-compiler.d.ts +68 -32
- package/internal/rindo-public-docs.d.ts +24 -0
- package/internal/rindo-public-runtime.d.ts +79 -7
- package/internal/testing/index.js +187 -175
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +905 -896
- package/mock-doc/index.d.ts +2 -2
- package/mock-doc/index.js +905 -896
- package/mock-doc/package.json +1 -1
- package/package.json +48 -57
- package/readme.md +44 -31
- package/screenshot/compare/build/p-f4745c2f.entry.js +1 -1
- package/screenshot/index.d.ts +1 -1
- package/screenshot/index.js +3 -3
- package/screenshot/package.json +1 -1
- package/screenshot/pixel-match.js +983 -849
- package/sys/node/autoprefixer.js +2 -2
- package/sys/node/glob.js +1 -1
- package/sys/node/index.d.ts +4 -0
- package/sys/node/index.js +407 -418
- package/sys/node/package.json +1 -1
- package/sys/node/prompts.js +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.d.ts +6 -6
- package/testing/index.js +1136 -1277
- package/testing/jest/jest-config.d.ts +1 -1
- package/testing/jest/jest-preprocessor.d.ts +3 -3
- package/testing/jest/jest-serializer.d.ts +1 -2
- package/testing/matchers/index.d.ts +3 -3
- package/testing/mock-fetch.d.ts +1 -1
- package/testing/mocks.d.ts +2 -2
- package/testing/package.json +1 -1
- package/testing/puppeteer/puppeteer-declarations.d.ts +5 -5
- package/testing/puppeteer/puppeteer-element.d.ts +2 -2
- package/testing/puppeteer/puppeteer-events.d.ts +1 -1
- package/testing/testing-logger.d.ts +1 -1
- package/testing/testing-utils.d.ts +1 -1
- package/testing/testing.d.ts +1 -1
package/mock-doc/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rindo/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./internal/rindo-core/index.cjs",
|
|
6
6
|
"module": "./internal/rindo-core/index.js",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"testing/"
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "
|
|
27
|
+
"build": "npm run tsc.scripts && npm run tsc.prod && npm run rollup.prod.ci",
|
|
28
28
|
"changelog": "conventional-changelog -p angular -o -i CHANGELOG.md -s",
|
|
29
|
-
"clean": "
|
|
30
|
-
"clean-scripts": "
|
|
31
|
-
"license": "node scripts --license",
|
|
32
|
-
"lint": "eslint \"src/*.ts\" \"src/**/*.ts\"",
|
|
29
|
+
"clean": "rm -rf build/ cli/ compiler/ dev-server/ internal/ mock-doc/ sys/ testing/ && npm run clean-scripts",
|
|
30
|
+
"clean-scripts": "rm -rf scripts/build",
|
|
31
|
+
"license": "node scripts/build --license",
|
|
32
|
+
"lint": "eslint \"bin/*\" \"scripts/*.ts\" \"scripts/**/*.ts\" \"src/*.ts\" \"src/**/*.ts\"",
|
|
33
33
|
"prettier": "npm run prettier.base -- --write",
|
|
34
|
-
"prettier.base": "prettier \"./({bin,scripts,src}/**/*.{ts,tsx,js,jsx})|bin/rindo\"",
|
|
34
|
+
"prettier.base": "prettier --cache \"./({bin,scripts,src}/**/*.{ts,tsx,js,jsx})|bin/rindo|.github/(**/)?*.(yml|yaml)|*.js\"",
|
|
35
35
|
"prettier.dry-run": "npm run prettier.base -- --list-different",
|
|
36
|
-
"release": "node scripts --release --publish",
|
|
37
|
-
"release.prepare": "node scripts --release --prepare",
|
|
36
|
+
"release": "npm run tsc.scripts && node scripts/build --any-branch --release --publish",
|
|
37
|
+
"release.prepare": "npm run tsc.scripts && node scripts/build --any-branch --release --prepare",
|
|
38
38
|
"rollup": "rollup --config",
|
|
39
39
|
"rollup.prod": "rollup --config --config-prod",
|
|
40
40
|
"rollup.prod.ci": "rollup --config --config-prod --config-ci",
|
|
@@ -42,57 +42,49 @@
|
|
|
42
42
|
"start": "npm run watch",
|
|
43
43
|
"tsc": "tsc --incremental",
|
|
44
44
|
"tsc.prod": "tsc",
|
|
45
|
-
"tsc.scripts": "tsc
|
|
46
|
-
"tsc.watch": "tsc --incremental --watch"
|
|
47
|
-
"watch": "node scripts && npm run tsc && concurrently \"npm run rollup.watch\" \"npm run tsc.watch\""
|
|
45
|
+
"tsc.scripts": "tsc --build --force scripts/tsconfig.json",
|
|
46
|
+
"tsc.watch": "tsc --incremental --watch"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@
|
|
49
|
+
"@familyjs/prettier-config": "^2.0.0",
|
|
51
50
|
"@rollup/plugin-commonjs": "15.1.0",
|
|
52
|
-
"@rollup/plugin-json": "
|
|
51
|
+
"@rollup/plugin-json": "6.0.0",
|
|
53
52
|
"@rollup/plugin-node-resolve": "9.0.0",
|
|
54
53
|
"@rollup/plugin-replace": "2.3.4",
|
|
55
|
-
"@rollup/pluginutils": "
|
|
56
|
-
"@types/
|
|
57
|
-
"@types/eslint": "^8.4.2",
|
|
54
|
+
"@rollup/pluginutils": "5.0.2",
|
|
55
|
+
"@types/eslint": "^8.4.6",
|
|
58
56
|
"@types/exit": "^0.1.31",
|
|
59
57
|
"@types/fs-extra": "^9.0.8",
|
|
60
|
-
"@types/glob": "^
|
|
58
|
+
"@types/glob": "^8.0.0",
|
|
61
59
|
"@types/graceful-fs": "^4.1.5",
|
|
62
60
|
"@types/inquirer": "^7.3.1",
|
|
63
61
|
"@types/jest": "^27.0.3",
|
|
64
|
-
"@types/listr": "^0.14.
|
|
65
|
-
"@types/
|
|
66
|
-
"@types/
|
|
67
|
-
"@types/
|
|
68
|
-
"@types/parse5": "^6.0.0",
|
|
69
|
-
"@types/pixelmatch": "^4.0.0",
|
|
70
|
-
"@types/pngjs": "^3.4.2",
|
|
62
|
+
"@types/listr": "^0.14.4",
|
|
63
|
+
"@types/node": "^16.11.62",
|
|
64
|
+
"@types/pixelmatch": "^5.2.4",
|
|
65
|
+
"@types/pngjs": "^6.0.1",
|
|
71
66
|
"@types/prompts": "^2.0.9",
|
|
72
|
-
"@types/semver": "^7.3.
|
|
67
|
+
"@types/semver": "^7.3.12",
|
|
73
68
|
"@types/sizzle": "^2.3.2",
|
|
74
69
|
"@types/webpack": "^4.41.26",
|
|
75
|
-
"@types/ws": "^
|
|
70
|
+
"@types/ws": "^8.5.4",
|
|
76
71
|
"@types/yarnpkg__lockfile": "^1.1.5",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
78
|
-
"@typescript-eslint/parser": "^5.
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^5.38.0",
|
|
73
|
+
"@typescript-eslint/parser": "^5.38.0",
|
|
79
74
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
80
|
-
"ansi-colors": "4.1.
|
|
81
|
-
"autoprefixer": "10.
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"css": "^3.0.0",
|
|
86
|
-
"dts-bundle-generator": "~5.3.0",
|
|
87
|
-
"eslint": "^8.13.0",
|
|
75
|
+
"ansi-colors": "4.1.3",
|
|
76
|
+
"autoprefixer": "10.4.13",
|
|
77
|
+
"conventional-changelog-cli": "^2.2.2",
|
|
78
|
+
"dts-bundle-generator": "~7.1.0",
|
|
79
|
+
"eslint": "^8.23.1",
|
|
88
80
|
"eslint-config-prettier": "^8.5.0",
|
|
89
|
-
"eslint-plugin-jest": "^
|
|
81
|
+
"eslint-plugin-jest": "^27.0.4",
|
|
90
82
|
"eslint-plugin-jsdoc": "^39.3.1",
|
|
83
|
+
"eslint-plugin-simple-import-sort": "^9.0.0",
|
|
91
84
|
"execa": "4.1.0",
|
|
92
85
|
"exit": "^0.1.2",
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"glob": "7.1.6",
|
|
86
|
+
"fs-extra": "^11.0.0",
|
|
87
|
+
"glob": "8.1.0",
|
|
96
88
|
"graceful-fs": "~4.2.6",
|
|
97
89
|
"hash.js": "^1.1.7",
|
|
98
90
|
"inquirer": "^7.3.3",
|
|
@@ -100,29 +92,28 @@
|
|
|
100
92
|
"jest-cli": "^27.4.5",
|
|
101
93
|
"jest-environment-node": "^27.4.4",
|
|
102
94
|
"listr": "^0.14.3",
|
|
103
|
-
"magic-string": "^0.
|
|
95
|
+
"magic-string": "^0.27.0",
|
|
104
96
|
"merge-source-map": "^1.1.0",
|
|
105
97
|
"mime-db": "^1.46.0",
|
|
106
|
-
"minimatch": "
|
|
98
|
+
"minimatch": "5.1.2",
|
|
107
99
|
"node-fetch": "2.6.7",
|
|
108
|
-
"open": "8.
|
|
100
|
+
"open": "^8.4.0",
|
|
109
101
|
"open-in-editor": "2.2.0",
|
|
110
|
-
"parse5": "
|
|
102
|
+
"parse5": "7.1.2",
|
|
111
103
|
"path-browserify": "^1.0.1",
|
|
112
|
-
"pixelmatch": "
|
|
104
|
+
"pixelmatch": "5.3.0",
|
|
113
105
|
"postcss": "^8.2.8",
|
|
114
|
-
"prettier": "2.
|
|
115
|
-
"prompts": "2.4.
|
|
106
|
+
"prettier": "2.8.3",
|
|
107
|
+
"prompts": "2.4.2",
|
|
116
108
|
"puppeteer": "~10.0.0",
|
|
117
109
|
"rollup": "2.42.3",
|
|
118
110
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
119
|
-
"
|
|
120
|
-
"semver": "7.3.4",
|
|
111
|
+
"semver": "^7.3.7",
|
|
121
112
|
"sizzle": "^2.3.6",
|
|
122
|
-
"terser": "5.
|
|
123
|
-
"typescript": "4.
|
|
113
|
+
"terser": "5.16.1",
|
|
114
|
+
"typescript": "4.9.4",
|
|
124
115
|
"webpack": "^4.46.0",
|
|
125
|
-
"ws": "
|
|
116
|
+
"ws": "8.12.0"
|
|
126
117
|
},
|
|
127
118
|
"engines": {
|
|
128
119
|
"node": ">=12.10.0",
|
|
@@ -130,22 +121,22 @@
|
|
|
130
121
|
},
|
|
131
122
|
"repository": {
|
|
132
123
|
"type": "git",
|
|
133
|
-
"url": "git+https://github.com/
|
|
124
|
+
"url": "git+https://github.com/familyjs/rindo.git"
|
|
134
125
|
},
|
|
135
|
-
"author": "
|
|
126
|
+
"author": "Family Team",
|
|
136
127
|
"homepage": "https://rindojs.web.app/",
|
|
137
128
|
"description": "A Compiler for Web Components and Progressive Web Apps",
|
|
138
129
|
"keywords": [
|
|
139
130
|
"web components",
|
|
140
131
|
"components",
|
|
141
132
|
"rindo",
|
|
142
|
-
"
|
|
133
|
+
"familyjs",
|
|
143
134
|
"webapp",
|
|
144
135
|
"custom elements",
|
|
145
136
|
"pwa",
|
|
146
137
|
"progressive web app"
|
|
147
138
|
],
|
|
148
|
-
"prettier": "@
|
|
139
|
+
"prettier": "@familyjs/prettier-config",
|
|
149
140
|
"volta": {
|
|
150
141
|
"node": "16.13.0",
|
|
151
142
|
"npm": "8.1.1"
|
package/readme.md
CHANGED
|
@@ -9,49 +9,53 @@
|
|
|
9
9
|
</h1>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
A compiler for generating <a href="https://www.webcomponents.org/introduction">Web Components</a>
|
|
12
|
+
A compiler for generating <a href="https://www.webcomponents.org/introduction" target="_blank" rel="noopener noref">Web Components</a>, built by the <a href="https://family-js.web.app/">Family team</a>.
|
|
13
|
+
</p>
|
|
14
|
+
<p align="center">
|
|
15
|
+
Rindo allows developers to use technologies like TypeScript and JSX to define components, then generate 100% standards-based Web Components that run on both <a href="https://rindojs.web.app/docs/browser-support" target="_blank" rel="noopener noref">modern browsers and legacy browsers</a>
|
|
13
16
|
</p>
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
To create a new project using an interactive cli, run:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm init rindo
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
To start developing your new Rindo project, run:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm start
|
|
35
|
-
```
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="https://www.npmjs.com/package/@rindo/core">
|
|
20
|
+
<img src="https://img.shields.io/npm/v/@rindo/core.svg" alt="RindoJS is released under the MIT license." /></a>
|
|
21
|
+
<a href="https://github.com/familyjs/rindo/blob/main/LICENSE.md">
|
|
22
|
+
<img src="https://img.shields.io/badge/license-MIT-yellow.svg" alt="RindoJS is released under the MIT license." />
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://github.com/familyjs/rindo/blob/main/.github/CONTRIBUTING.md">
|
|
25
|
+
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome!" />
|
|
26
|
+
</a>
|
|
27
|
+
</p>
|
|
36
28
|
|
|
37
|
-
|
|
29
|
+
<h2 align="center">
|
|
30
|
+
<a href="https://rindojs.web.app/docs/getting-started#starting-a-new-project">Quick Start</a>
|
|
31
|
+
<span> · </span>
|
|
32
|
+
<a href="https://rindojs.web.app/docs/introduction">Documentation</a>
|
|
33
|
+
<span> · </span>
|
|
34
|
+
<a href="https://github.com/familyjs/rindo/blob/main/.github/CONTRIBUTING.md">Contribute</a>
|
|
35
|
+
</h2>
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
### Getting Started
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
Start a new project by following our quick [Getting Started guide](https://rindojs.web.app/docs/getting-started).
|
|
40
|
+
We would love to hear from you!
|
|
41
|
+
If you have any feedback or run into issues using Rindo, please file an [issue](https://github.com/familyjs/rindo/issues/new) on this repository.
|
|
42
42
|
|
|
43
|
+
### Examples
|
|
44
|
+
A Rindo component looks a lot like a class-based React component, with the addition of TypeScript decorators:
|
|
43
45
|
```tsx
|
|
44
46
|
import { Component, Prop, h } from '@rindo/core';
|
|
45
47
|
|
|
46
48
|
@Component({
|
|
47
|
-
tag: 'my-component',
|
|
48
|
-
styleUrl: 'my-component.css'
|
|
49
|
+
tag: 'my-component', // the name of the component's custom HTML tag
|
|
50
|
+
styleUrl: 'my-component.css', // css styles to apply to the component
|
|
51
|
+
shadow: true, // this component uses the ShadowDOM
|
|
49
52
|
})
|
|
50
53
|
export class MyComponent {
|
|
51
|
-
|
|
54
|
+
// The component accepts two arguments:
|
|
52
55
|
@Prop() first: string;
|
|
53
56
|
@Prop() last: string;
|
|
54
57
|
|
|
58
|
+
//The following HTML is rendered when our component is used
|
|
55
59
|
render() {
|
|
56
60
|
return (
|
|
57
61
|
<div>
|
|
@@ -62,13 +66,22 @@ export class MyComponent {
|
|
|
62
66
|
}
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
The component above can be used like any other HTML element:
|
|
66
70
|
|
|
67
71
|
```html
|
|
68
72
|
<my-component first="Rindo" last="JS"></my-component>
|
|
69
73
|
```
|
|
70
74
|
|
|
71
|
-
|
|
75
|
+
Since Rindo generates web components, they work in any major framework or with no framework at all.
|
|
76
|
+
In many cases, Rindo can be used as a drop in replacement for traditional frontend framework, though using it as such is certainly not required.
|
|
77
|
+
|
|
78
|
+
### Contributing
|
|
79
|
+
|
|
80
|
+
Thanks for your interest in contributing!
|
|
81
|
+
Please take a moment to read up on our guidelines for [contributing](https://github.com/familyjs/rindo/blob/main/.github/CONTRIBUTING.md).
|
|
82
|
+
Please note that this project is released with a [Contributor Code of Conduct](https://github.com/familyjs/rindo/blob/main/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
|
83
|
+
|
|
84
|
+
### Thanks
|
|
72
85
|
Rindo's internal testing suite is supported by the [BrowserStack Open-Source Program](https://www.browserstack.com/open-source)
|
|
73
86
|
<br>
|
|
74
|
-
<a
|
|
87
|
+
<a href="https://www.browserstack.com/" target="_blank" rel="noopener noref"><img width="200" src="https://www.browserstack.com/images/layout/browserstack-logo-600x315.png"></a>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,d as s,h as i,g as e}from"./p-fbbae598.js";import{s as n}from"./p-081b0641.js";const h={threshold:.1,includeAA:!1,alpha:.1,aaColor:[255,255,0],diffColor:[255,0,0],diffColorAlt:null,diffMask:!1};function o(t){return ArrayBuffer.isView(t)&&1===t.constructor.BYTES_PER_ELEMENT}function r(t,s,i,e,n,h){const o=Math.max(s-1,0),r=Math.max(i-1,0),c=Math.min(s+1,e-1),d=Math.min(i+1,n-1),f=4*(i*e+s);let u,p,m,g,w=s===o||s===c||i===r||i===d?1:0,y=0,v=0;for(let n=o;n<=c;n++)for(let h=r;h<=d;h++){if(n===s&&h===i)continue;const o=l(t,t,f,4*(h*e+n),!0);if(0===o){if(w++,w>2)return!1}else o<y?(y=o,u=n,p=h):o>v&&(v=o,m=n,g=h)}return 0!==y&&0!==v&&(a(t,u,p,e,n)&&a(h,u,p,e,n)||a(t,m,g,e,n)&&a(h,m,g,e,n))}function a(t,s,i,e,n){const h=Math.max(s-1,0),o=Math.max(i-1,0),r=Math.min(s+1,e-1),a=Math.min(i+1,n-1),l=4*(i*e+s);let c=s===h||s===r||i===o||i===a?1:0;for(let n=h;n<=r;n++)for(let h=o;h<=a;h++){if(n===s&&h===i)continue;const o=4*(h*e+n);if(t[l]===t[o]&&t[l+1]===t[o+1]&&t[l+2]===t[o+2]&&t[l+3]===t[o+3]&&c++,c>2)return!0}return!1}function l(t,s,i,e,n){let h=t[i+0],o=t[i+1],r=t[i+2],a=t[i+3],l=s[e+0],p=s[e+1],m=s[e+2],g=s[e+3];if(a===g&&h===l&&o===p&&r===m)return 0;a<255&&(a/=255,h=u(h,a),o=u(o,a),r=u(r,a)),g<255&&(g/=255,l=u(l,g),p=u(p,g),m=u(m,g));const w=c(h,o,r),y=c(l,p,m),v=w-y;if(n)return v;const b=d(h,o,r)-d(l,p,m),x=f(h,o,r)-f(l,p,m),M=.5053*v*v+.299*b*b+.1957*x*x;return w>y?-M:M}function c(t,s,i){return.29889531*t+.58662247*s+.11448223*i}function d(t,s,i){return.59597799*t-.2741761*s-.32180189*i}function f(t,s,i){return.21147017*t-.52261711*s+.31114694*i}function u(t,s){return 255+(t-255)*s}function p(t,s,i,e,n){t[s+0]=i,t[s+1]=e,t[s+2]=n,t[s+3]=255}function m(t,s,i,e){const n=u(c(t[s+0],t[s+1],t[s+2]),i*t[s+3]/255);p(e,s,n,n,n)}function g(t,s,i){if(y.has(s))return void i(y.get(s));if(w.has(s))return void w.get(s).push(i);w.set(s,[i]);const e=document.createElement("script");e.src=`${t}screenshot_${s}.js`,document.head.appendChild(e)}window.loadScreenshot=(t,s)=>{const i=w.get(t);i&&(i.forEach(t=>t(s)),w.delete(t)),y.set(t,s)};const w=new Map,y=new Map;class v{constructor(i){t(this,i),this.imageASrc=null,this.imageBSrc=null,this.imageAClass="is-loading",this.imageBClass="is-loading",this.canvasClass="is-loading",this.imagesLoaded=new Set,this.isImageALoaded=!1,this.isImageBLoaded=!1,this.isMismatchInitialized=!1,this.hasCalculatedMismatch=!1,this.compareLoaded=s(this,"compareLoaded",7)}componentWillLoad(){this.loadScreenshots()}componentWillUpdate(){this.loadScreenshots()}loadScreenshots(){if(this.show&&this.diff.hasIntersected)return this.diff.identical?(this.imageASrc=this.imagesUrl+this.diff.imageA,this.isImageALoaded=!0,this.imageAClass="has-loaded",this.imageBSrc=this.imagesUrl+this.diff.imageB,this.isImageBLoaded=!0,void(this.imageBClass="has-loaded")):void(this.isMismatchInitialized||(this.isMismatchInitialized=!0,null!=this.jsonpUrl?(null!=this.diff.imageA&&g(this.jsonpUrl,this.diff.imageA,t=>{this.imageASrc=t}),null!=this.diff.imageB&&g(this.jsonpUrl,this.diff.imageB,t=>{this.imageBSrc=t})):(this.imageASrc=this.imagesUrl+this.diff.imageA,this.imageBSrc=this.imagesUrl+this.diff.imageB)))}async compareImages(){const t=this.diff;this.isImageALoaded&&this.isImageBLoaded&&!this.hasCalculatedMismatch&&t.comparable&&(this.hasCalculatedMismatch=!0,t.mismatchedPixels=await function(t,s,i,e,n,a){let c=-1;try{const d=document.createElement("canvas");d.width=e,d.height=n;const f=document.createElement("canvas");f.width=e,f.height=n;const u=d.getContext("2d");u.drawImage(t,0,0);const g=f.getContext("2d");g.drawImage(s,0,0);const w=document.createElement("canvas").getContext("2d");w.drawImage(t,0,0),w.getImageData(0,0,e,n);const y=u.getImageData(0,0,e,n).data,v=g.getImageData(0,0,e,n).data,b=i.getContext("2d"),x=b.createImageData(e,d.height);c=function(t,s,i,e,n,a){if(!o(t)||!o(s)||i&&!o(i))throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");if(t.length!==s.length||i&&i.length!==t.length)throw new Error("Image sizes do not match.");if(t.length!==e*n*4)throw new Error("Image data size does not match width/height.");a=Object.assign({},h,a);const c=e*n,d=new Uint32Array(t.buffer,t.byteOffset,c),f=new Uint32Array(s.buffer,s.byteOffset,c);let u=!0;for(let t=0;t<c;t++)if(d[t]!==f[t]){u=!1;break}if(u){if(i&&!a.diffMask)for(let s=0;s<c;s++)m(t,4*s,a.alpha,i);return 0}const g=35215*a.threshold*a.threshold;let w=0;for(let h=0;h<n;h++)for(let o=0;o<e;o++){const c=4*(h*e+o),d=l(t,s,c,c);Math.abs(d)>g?a.includeAA||!r(t,o,h,e,n,s)&&!r(s,o,h,e,n,t)?(i&&p(i,c,...d<0&&a.diffColorAlt||a.diffColor),w++):i&&!a.diffMask&&p(i,c,...a.aaColor):i&&(a.diffMask||m(t,c,a.alpha,i))}return w}(y,v,x.data,e,n,{threshold:a}),b.putImageData(x,0,0)}catch(t){console.error(t)}return c}(this.imageA,this.imageB,this.canvas,Math.round(t.width*t.deviceScaleFactor),Math.round(t.height*t.deviceScaleFactor),t.threshold),this.canvasClass="has-loaded",n(t.imageA,t.imageB,t.mismatchedPixels,t.threshold),this.compareLoaded.emit(t))}render(){const t=this.diff,s={width:t.width+"px",height:t.height+"px"};return[i("compare-cell",null,null!=t.imageA?i("a",{href:this.imagesUrl+t.imageA,target:"_blank"},i("img",{src:this.imageASrc,class:this.imageAClass,style:s,onLoad:this.diff.identical?null:()=>{this.isImageALoaded=!0,this.imageAClass="has-loaded",this.compareImages()},ref:t=>this.imageA=t})):i("img",{style:s,class:"is-loading"})),i("compare-cell",null,null!=t.imageB?i("a",{href:this.imagesUrl+t.imageB,target:"_blank"},i("img",{src:this.imageBSrc,class:this.imageBClass,style:s,onLoad:this.diff.identical?null:()=>{this.isImageBLoaded=!0,this.imageBClass="has-loaded",this.compareImages()},ref:t=>this.imageB=t})):i("img",{style:s,class:"is-loading"})),i("compare-cell",null,this.diff.identical?i("img",{style:s,src:this.imageASrc}):i("canvas",{width:Math.round(t.width*t.deviceScaleFactor),height:Math.round(t.height*t.deviceScaleFactor),class:this.canvasClass,style:s,hidden:!t.comparable,ref:t=>this.canvas=t})),i("compare-cell",null,i("compare-analysis",{aId:this.aId,bId:this.bId,mismatchedPixels:this.diff.mismatchedPixels,diff:this.diff}))]}get elm(){return e(this)}}v.style="compare-row img,compare-row canvas{display:block;box-shadow:var(--screenshot-box-shadow);border-radius:var(--screenshot-border-radius)}compare-row a{display:block}.is-loading{visibility:hidden}";class b{constructor(s){t(this,s)}render(){if(!this.a||!this.b||!this.diffs)return;let t=0;this.diffs.forEach(s=>{s.width>t&&(t=s.width)}),t-=6;const s={width:t+"px"};return[i("th-cell",null,i("div",{style:s},i("a",{href:this.a.url,target:"_blank"},this.a.message))),i("th-cell",null,i("div",{style:s},i("a",{href:this.b.url,target:"_blank"},this.b.message))),i("th-cell",null,i("div",{style:s},i("a",{href:`https://github.com/
|
|
1
|
+
import{r as t,d as s,h as i,g as e}from"./p-fbbae598.js";import{s as n}from"./p-081b0641.js";const h={threshold:.1,includeAA:!1,alpha:.1,aaColor:[255,255,0],diffColor:[255,0,0],diffColorAlt:null,diffMask:!1};function o(t){return ArrayBuffer.isView(t)&&1===t.constructor.BYTES_PER_ELEMENT}function r(t,s,i,e,n,h){const o=Math.max(s-1,0),r=Math.max(i-1,0),c=Math.min(s+1,e-1),d=Math.min(i+1,n-1),f=4*(i*e+s);let u,p,m,g,w=s===o||s===c||i===r||i===d?1:0,y=0,v=0;for(let n=o;n<=c;n++)for(let h=r;h<=d;h++){if(n===s&&h===i)continue;const o=l(t,t,f,4*(h*e+n),!0);if(0===o){if(w++,w>2)return!1}else o<y?(y=o,u=n,p=h):o>v&&(v=o,m=n,g=h)}return 0!==y&&0!==v&&(a(t,u,p,e,n)&&a(h,u,p,e,n)||a(t,m,g,e,n)&&a(h,m,g,e,n))}function a(t,s,i,e,n){const h=Math.max(s-1,0),o=Math.max(i-1,0),r=Math.min(s+1,e-1),a=Math.min(i+1,n-1),l=4*(i*e+s);let c=s===h||s===r||i===o||i===a?1:0;for(let n=h;n<=r;n++)for(let h=o;h<=a;h++){if(n===s&&h===i)continue;const o=4*(h*e+n);if(t[l]===t[o]&&t[l+1]===t[o+1]&&t[l+2]===t[o+2]&&t[l+3]===t[o+3]&&c++,c>2)return!0}return!1}function l(t,s,i,e,n){let h=t[i+0],o=t[i+1],r=t[i+2],a=t[i+3],l=s[e+0],p=s[e+1],m=s[e+2],g=s[e+3];if(a===g&&h===l&&o===p&&r===m)return 0;a<255&&(a/=255,h=u(h,a),o=u(o,a),r=u(r,a)),g<255&&(g/=255,l=u(l,g),p=u(p,g),m=u(m,g));const w=c(h,o,r),y=c(l,p,m),v=w-y;if(n)return v;const b=d(h,o,r)-d(l,p,m),x=f(h,o,r)-f(l,p,m),M=.5053*v*v+.299*b*b+.1957*x*x;return w>y?-M:M}function c(t,s,i){return.29889531*t+.58662247*s+.11448223*i}function d(t,s,i){return.59597799*t-.2741761*s-.32180189*i}function f(t,s,i){return.21147017*t-.52261711*s+.31114694*i}function u(t,s){return 255+(t-255)*s}function p(t,s,i,e,n){t[s+0]=i,t[s+1]=e,t[s+2]=n,t[s+3]=255}function m(t,s,i,e){const n=u(c(t[s+0],t[s+1],t[s+2]),i*t[s+3]/255);p(e,s,n,n,n)}function g(t,s,i){if(y.has(s))return void i(y.get(s));if(w.has(s))return void w.get(s).push(i);w.set(s,[i]);const e=document.createElement("script");e.src=`${t}screenshot_${s}.js`,document.head.appendChild(e)}window.loadScreenshot=(t,s)=>{const i=w.get(t);i&&(i.forEach(t=>t(s)),w.delete(t)),y.set(t,s)};const w=new Map,y=new Map;class v{constructor(i){t(this,i),this.imageASrc=null,this.imageBSrc=null,this.imageAClass="is-loading",this.imageBClass="is-loading",this.canvasClass="is-loading",this.imagesLoaded=new Set,this.isImageALoaded=!1,this.isImageBLoaded=!1,this.isMismatchInitialized=!1,this.hasCalculatedMismatch=!1,this.compareLoaded=s(this,"compareLoaded",7)}componentWillLoad(){this.loadScreenshots()}componentWillUpdate(){this.loadScreenshots()}loadScreenshots(){if(this.show&&this.diff.hasIntersected)return this.diff.identical?(this.imageASrc=this.imagesUrl+this.diff.imageA,this.isImageALoaded=!0,this.imageAClass="has-loaded",this.imageBSrc=this.imagesUrl+this.diff.imageB,this.isImageBLoaded=!0,void(this.imageBClass="has-loaded")):void(this.isMismatchInitialized||(this.isMismatchInitialized=!0,null!=this.jsonpUrl?(null!=this.diff.imageA&&g(this.jsonpUrl,this.diff.imageA,t=>{this.imageASrc=t}),null!=this.diff.imageB&&g(this.jsonpUrl,this.diff.imageB,t=>{this.imageBSrc=t})):(this.imageASrc=this.imagesUrl+this.diff.imageA,this.imageBSrc=this.imagesUrl+this.diff.imageB)))}async compareImages(){const t=this.diff;this.isImageALoaded&&this.isImageBLoaded&&!this.hasCalculatedMismatch&&t.comparable&&(this.hasCalculatedMismatch=!0,t.mismatchedPixels=await function(t,s,i,e,n,a){let c=-1;try{const d=document.createElement("canvas");d.width=e,d.height=n;const f=document.createElement("canvas");f.width=e,f.height=n;const u=d.getContext("2d");u.drawImage(t,0,0);const g=f.getContext("2d");g.drawImage(s,0,0);const w=document.createElement("canvas").getContext("2d");w.drawImage(t,0,0),w.getImageData(0,0,e,n);const y=u.getImageData(0,0,e,n).data,v=g.getImageData(0,0,e,n).data,b=i.getContext("2d"),x=b.createImageData(e,d.height);c=function(t,s,i,e,n,a){if(!o(t)||!o(s)||i&&!o(i))throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");if(t.length!==s.length||i&&i.length!==t.length)throw new Error("Image sizes do not match.");if(t.length!==e*n*4)throw new Error("Image data size does not match width/height.");a=Object.assign({},h,a);const c=e*n,d=new Uint32Array(t.buffer,t.byteOffset,c),f=new Uint32Array(s.buffer,s.byteOffset,c);let u=!0;for(let t=0;t<c;t++)if(d[t]!==f[t]){u=!1;break}if(u){if(i&&!a.diffMask)for(let s=0;s<c;s++)m(t,4*s,a.alpha,i);return 0}const g=35215*a.threshold*a.threshold;let w=0;for(let h=0;h<n;h++)for(let o=0;o<e;o++){const c=4*(h*e+o),d=l(t,s,c,c);Math.abs(d)>g?a.includeAA||!r(t,o,h,e,n,s)&&!r(s,o,h,e,n,t)?(i&&p(i,c,...d<0&&a.diffColorAlt||a.diffColor),w++):i&&!a.diffMask&&p(i,c,...a.aaColor):i&&(a.diffMask||m(t,c,a.alpha,i))}return w}(y,v,x.data,e,n,{threshold:a}),b.putImageData(x,0,0)}catch(t){console.error(t)}return c}(this.imageA,this.imageB,this.canvas,Math.round(t.width*t.deviceScaleFactor),Math.round(t.height*t.deviceScaleFactor),t.threshold),this.canvasClass="has-loaded",n(t.imageA,t.imageB,t.mismatchedPixels,t.threshold),this.compareLoaded.emit(t))}render(){const t=this.diff,s={width:t.width+"px",height:t.height+"px"};return[i("compare-cell",null,null!=t.imageA?i("a",{href:this.imagesUrl+t.imageA,target:"_blank"},i("img",{src:this.imageASrc,class:this.imageAClass,style:s,onLoad:this.diff.identical?null:()=>{this.isImageALoaded=!0,this.imageAClass="has-loaded",this.compareImages()},ref:t=>this.imageA=t})):i("img",{style:s,class:"is-loading"})),i("compare-cell",null,null!=t.imageB?i("a",{href:this.imagesUrl+t.imageB,target:"_blank"},i("img",{src:this.imageBSrc,class:this.imageBClass,style:s,onLoad:this.diff.identical?null:()=>{this.isImageBLoaded=!0,this.imageBClass="has-loaded",this.compareImages()},ref:t=>this.imageB=t})):i("img",{style:s,class:"is-loading"})),i("compare-cell",null,this.diff.identical?i("img",{style:s,src:this.imageASrc}):i("canvas",{width:Math.round(t.width*t.deviceScaleFactor),height:Math.round(t.height*t.deviceScaleFactor),class:this.canvasClass,style:s,hidden:!t.comparable,ref:t=>this.canvas=t})),i("compare-cell",null,i("compare-analysis",{aId:this.aId,bId:this.bId,mismatchedPixels:this.diff.mismatchedPixels,diff:this.diff}))]}get elm(){return e(this)}}v.style="compare-row img,compare-row canvas{display:block;box-shadow:var(--screenshot-box-shadow);border-radius:var(--screenshot-border-radius)}compare-row a{display:block}.is-loading{visibility:hidden}";class b{constructor(s){t(this,s)}render(){if(!this.a||!this.b||!this.diffs)return;let t=0;this.diffs.forEach(s=>{s.width>t&&(t=s.width)}),t-=6;const s={width:t+"px"};return[i("th-cell",null,i("div",{style:s},i("a",{href:this.a.url,target:"_blank"},this.a.message))),i("th-cell",null,i("div",{style:s},i("a",{href:this.b.url,target:"_blank"},this.b.message))),i("th-cell",null,i("div",{style:s},i("a",{href:`https://github.com/familyjs/family/compare/${this.a.id}...${this.b.id}`,target:"_blank"},"Compare: ",this.a.id," - ",this.b.id))),i("th-cell",{class:"analysis"},i("div",null,"Analysis"))]}}b.style=":host{display:flex}th-cell{display:block;flex:1;font-weight:500;font-size:12px}th-cell div{padding-left:12px;padding-right:12px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}th-cell a{color:var(--font-color);text-decoration:none}th-cell a:hover{color:var(--analysis-data-color);text-decoration:underline}.analysis div{width:262px}";export{v as compare_row,b as compare_thead}
|
package/screenshot/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ScreenshotConnector } from './connector-base';
|
|
2
2
|
export { ScreenshotLocalConnector } from './connector-local';
|
|
3
|
-
export {
|
|
3
|
+
export { Screenshot, ScreenshotBuild, ScreenshotCompareResults, ScreenshotDiff } from '@rindo/core/internal';
|
package/screenshot/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
3
|
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
10
9
|
const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
10
|
+
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
11
11
|
|
|
12
12
|
function fileExists(filePath) {
|
|
13
13
|
return new Promise((resolve) => {
|