forked from fingerprintjs/fingerprintjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to build the source code
- Loading branch information
Showing
11 changed files
with
687 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 1,29 @@ | ||
{ | ||
"name": "@fingerprintjs/fingerprintjs", | ||
"version": "3.0.0-dev", | ||
"version": "3.0.0-beta.2", | ||
"license": "MIT", | ||
"main": "dist/fp.cjs.js", | ||
"module": "dist/fp.esm.js", | ||
"types": "dist/fp.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "rimraf dist && rollup -c" | ||
}, | ||
"dependencies": { | ||
"tslib": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^4.0.2" | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@rollup/plugin-typescript": "^6.0.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.28.2", | ||
"rollup-plugin-dts": "^1.4.13", | ||
"rollup-plugin-license": "^2.2.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 1,62 @@ | ||
# FingerprintJS | ||
|
||
Work in progress, stay tuned. | ||
|
||
## Quick start | ||
|
||
### In browser | ||
|
||
```html | ||
<script> | ||
function onFingerprintJSLoad(fp) { | ||
fp.get().then(({ visitorId }) => console.log(visitorId)); | ||
} | ||
</script> | ||
<script | ||
async src="https://cdn.jsdelivr.net/npm/@fingerprintjs/[email protected]/dist/fp.min.js" | ||
onload="FingerprintJS.load().then(onFingerprintJSLoad)" | ||
></script> | ||
``` | ||
|
||
### Webpack/Rollup/Browserify | ||
|
||
```bash | ||
npm i @fingerprintjs/fingerprintjs | ||
``` | ||
|
||
```js | ||
import * as FPJS from '@fingerprintjs/fingerprintjs'; | ||
|
||
(async () => { | ||
const fpjs = await FPJS.load(); | ||
const { visitorId } = await fpjs.get(); | ||
console.log(visitorId) | ||
})(); | ||
``` | ||
|
||
## Version policy | ||
|
||
The library doesn't promise same visitor identifier between any versions | ||
but tries to keep them same as much as reasonable. | ||
|
||
The documented JS API follows [Semantic Versioning](https://semver.org). | ||
Using undocumented features is at you own risk. | ||
|
||
## Contribution | ||
|
||
### How to build | ||
|
||
```bash | ||
# Make sure you have Yarn installed | ||
yarn install | ||
yarn build | ||
``` | ||
|
||
### How to publish | ||
|
||
1. Bump the version. Changing the number in [package.json](package.json) is enough. | ||
2. Build the project. | ||
3. Run | ||
```bash | ||
yarn publish --access public # Add '--tag beta' (without the quotes) if you release a beta version | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,5 @@ | ||
FingerprintJS v<%= pkg.version %> - Copyright (c) FingerprintJS, Inc, <%= new Date().getFullYear() %> (https://fingerprintjs.com) | ||
Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. | ||
|
||
This software contains code from open-source projects: | ||
MurmurHash3 by Karan Lyons (https://github.com/karanlyons/murmurHash3.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,106 @@ | ||
const path = require('path') | ||
const jsonPlugin = require('@rollup/plugin-json') | ||
const nodeResolvePlugin = require('@rollup/plugin-node-resolve').nodeResolve | ||
const typescriptPlugin = require('@rollup/plugin-typescript') | ||
const terserPlugin = require('rollup-plugin-terser').terser | ||
const dtsPlugin = require('rollup-plugin-dts').default | ||
const licensePlugin = require('rollup-plugin-license') | ||
const { dependencies } = require('./package.json') | ||
|
||
const outputDirectory = 'dist' | ||
|
||
const commonBanner = licensePlugin({ | ||
banner: { | ||
content: { | ||
file: path.join(__dirname, 'resources', 'license_banner.txt'), | ||
}, | ||
}, | ||
}) | ||
|
||
const commonInput = { | ||
input: './src/index.ts', | ||
plugins: [ | ||
nodeResolvePlugin(), | ||
jsonPlugin(), | ||
typescriptPlugin({ | ||
declaration: false, | ||
}), | ||
commonBanner, | ||
], | ||
} | ||
|
||
const commonOutput = { | ||
name: 'FingerprintJS', | ||
} | ||
|
||
const commonTerser = terserPlugin({ | ||
format: { | ||
comments: false, | ||
}, | ||
safari10: true, | ||
}) | ||
|
||
module.exports = [ | ||
// Browser bundles. They have all the dependencies included for convenience. | ||
{ | ||
...commonInput, | ||
output: [ | ||
// IIFE for users who use Require.js or Electron and want to just call `window.FingerprintJS.load()` | ||
{ | ||
...commonOutput, | ||
file: `${outputDirectory}/fp.js`, | ||
format: 'iife', | ||
}, | ||
{ | ||
...commonOutput, | ||
file: `${outputDirectory}/fp.min.js`, | ||
format: 'iife', | ||
plugins: [commonTerser], | ||
}, | ||
|
||
// UMD for users who use Require.js or Electron and want to leverage them | ||
{ | ||
...commonOutput, | ||
file: `${outputDirectory}/fp.umd.js`, | ||
format: 'umd', | ||
}, | ||
{ | ||
...commonOutput, | ||
file: `${outputDirectory}/fp.umd.min.js`, | ||
format: 'umd', | ||
plugins: [commonTerser], | ||
}, | ||
], | ||
}, | ||
|
||
// NPM bundles. They have all the dependencies excluded for end code size optimization. | ||
{ | ||
...commonInput, | ||
external: Object.keys(dependencies), | ||
output: [ | ||
// CJS for usage with `require()` | ||
{ | ||
...commonOutput, | ||
file: `${outputDirectory}/fp.cjs.js`, | ||
format: 'cjs', | ||
}, | ||
|
||
// ESM for usage with `import` | ||
{ | ||
...commonOutput, | ||
file: `${outputDirectory}/fp.esm.js`, | ||
format: 'es', | ||
}, | ||
], | ||
}, | ||
|
||
// TypeScript definition | ||
{ | ||
...commonInput, | ||
plugins: [dtsPlugin(), commonBanner], | ||
output: { | ||
file: `${outputDirectory}/fp.d.ts`, | ||
format: 'es', | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 1,3 @@ | ||
export default function getEmptyEvalLength(): number { | ||
// todo: Check that `eval` doesn't prevent Terser from replacing identifiers | ||
return eval.toString().length | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.