Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

idle-js

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idle-js - npm Package Compare versions

Comparing version 0.1.3 to 1.1.2

src/index.js

182

gulpfile.babel.js

@@ -1,37 +0,31 @@

import gulp from 'gulp';
import loadPlugins from 'gulp-load-plugins';
import del from 'del';
import glob from 'glob';
import path from 'path';
import {Instrumenter} from 'isparta';
import webpack from 'webpack';
import webpackStream from 'webpack-stream';
import source from 'vinyl-source-stream';
import gulp from 'gulp'
import loadPlugins from 'gulp-load-plugins'
import del from 'del'
import path from 'path'
import webpackStream from 'webpack-stream'
import manifest from './package.json'
import mochaGlobals from './test/setup/.globals';
import manifest from './package.json';
// Load all of our Gulp plugins
const $ = loadPlugins();
const $ = loadPlugins()
// Gather the library data from `package.json`
const config = manifest.babelBoilerplateOptions;
const mainFile = manifest.main;
const destinationFolder = path.dirname(mainFile);
const exportFileName = path.basename(mainFile, path.extname(mainFile));
const config = manifest.babelBoilerplateOptions
const mainFile = manifest.main
const destinationFolder = path.dirname(mainFile)
const exportFileName = path.basename(mainFile, path.extname(mainFile))
function cleanDist(done) {
del([destinationFolder]).then(() => done());
function cleanDist (done) {
del([destinationFolder]).then(() => done())
}
function cleanTmp(done) {
del(['tmp']).then(() => done());
function cleanTmp (done) {
del(['tmp']).then(() => done())
}
function onError() {
$.util.beep();
function onError () {
$.util.beep()
}
// Lint a set of files
function lint(files) {
function lint (files) {
return gulp.src(files)

@@ -42,24 +36,18 @@ .pipe($.plumber())

.pipe($.eslint.failOnError())
//.pipe($.jscs())
//.pipe($.jscs.reporter('fail'))
.on('error', onError);
.on('error', onError)
}
function lintSrc() {
return lint('src/**/*.js');
function lintSrc () {
return lint('src/**/*.js')
}
function lintTest() {
return lint('test/**/*.js');
function lintGulpfile () {
return lint('gulpfile.babel.js')
}
function lintGulpfile() {
return lint('gulpfile.babel.js');
}
function build() {
function build () {
return gulp.src(path.join('src', config.entryFileName))
// return gulp.src('./src/idle.js')
.pipe($.plumber())
.pipe(webpackStream({
mode: 'production',
output: {

@@ -71,4 +59,4 @@ filename: exportFileName + '.js',

module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader' } }
]

@@ -84,122 +72,24 @@ },

.pipe($.sourcemaps.write('./'))
.pipe(gulp.dest(destinationFolder));
.pipe(gulp.dest(destinationFolder))
}
function _mocha() {
return gulp.src(['test/setup/node.js', 'test/unit/**/*.js'], {read: false})
.pipe($.mocha({
reporter: 'dot',
globals: Object.keys(mochaGlobals.globals),
ignoreLeaks: false
}));
}
function _registerBabel() {
require('babel-register');
}
function test() {
_registerBabel();
return _mocha();
}
function coverage(done) {
_registerBabel();
gulp.src(['src/**/*.js'])
.pipe($.istanbul({ instrumenter: Instrumenter }))
.pipe($.istanbul.hookRequire())
.on('finish', () => {
return test()
.pipe($.istanbul.writeReports())
.on('end', done);
});
}
const watchFiles = ['src/**/*', 'example/**/*', 'package.json', '**/.eslintrc', '.jscsrc'];
// Run the headless unit tests as you make changes.
function watch() {
gulp.watch(watchFiles, ['example']);
}
function testBrowser() {
// Our testing bundle is made up of our unit tests, which
// should individually load up pieces of our application.
// We also include the browser setup file.
const testFiles = glob.sync('./test/unit/**/*.js');
const allFiles = ['./test/setup/browser.js'].concat(testFiles);
// Lets us differentiate between the first build and subsequent builds
var firstBuild = true;
// This empty stream might seem like a hack, but we need to specify all of our files through
// the `entry` option of webpack. Otherwise, it ignores whatever file(s) are placed in here.
return gulp.src('')
.pipe($.plumber())
.pipe(webpackStream({
watch: true,
entry: allFiles,
output: {
filename: '__spec-build.js'
},
module: {
loaders: [
// This is what allows us to author in future JavaScript
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
// This allows the test setup scripts to load `package.json`
{ test: /\.json$/, exclude: /node_modules/, loader: 'json-loader' }
]
},
plugins: [
// By default, webpack does `n=>n` compilation with entry files. This concatenates
// them into a single chunk.
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })
],
devtool: 'inline-source-map'
}, null, function() {
if (firstBuild) {
$.livereload.listen({port: 35729, host: 'localhost', start: true});
var watcher = gulp.watch(watchFiles, ['lint']);
} else {
$.livereload.reload('./tmp/__spec-build.js');
}
firstBuild = false;
}))
.pipe(gulp.dest('./tmp'));
}
// Remove the built files
gulp.task('clean', cleanDist);
gulp.task('clean', cleanDist)
// Remove our temporary files
gulp.task('clean-tmp', cleanTmp);
gulp.task('clean-tmp', cleanTmp)
// Lint our source code
gulp.task('lint-src', lintSrc);
gulp.task('lint-src', lintSrc)
// Lint our test code
gulp.task('lint-test', lintTest);
// Lint this file
gulp.task('lint-gulpfile', lintGulpfile);
gulp.task('lint-gulpfile', lintGulpfile)
// Lint everything
gulp.task('lint', ['lint-src', 'lint-test', 'lint-gulpfile']);
gulp.task('lint', gulp.parallel('lint-src', 'lint-gulpfile'))
// Build two versions of the library
gulp.task('build', ['lint', 'clean'], build);
gulp.task('build', gulp.series('lint', 'clean', build))
// Lint and run our tests
gulp.task('test', ['lint'], test);
// Set up coverage and run tests
gulp.task('coverage', ['lint'], coverage);
// Set up a livereload environment for our spec runner `test/runner.html`
gulp.task('test-browser', ['lint', 'clean-tmp'], testBrowser);
// Run the headless unit tests as you make changes.
gulp.task('watch', watch);
// An alias of test
gulp.task('default', ['test']);
// An alias of lint
gulp.task('default', gulp.series('lint'))
{
"name": "idle-js",
"version": "0.1.3",
"version": "1.1.2",
"description": "Detect user idleness",
"main": "dist/Idle.js",
"scripts": {
"test": "gulp",
"build": "gulp build",
"coverage": "gulp coverage",
"lint": "gulp lint",
"test-browser": "gulp test-browser",
"watch": "gulp watch",
"build": "gulp build",
"coverage": "gulp coverage"
"prepare": "gulp build",
"build-example": "npx webpack --mode=development ./example/webpack/entry.js -o ./example/webpack/bundle.js"
},

@@ -18,3 +17,7 @@ "repository": {

},
"keywords": [],
"keywords": [
"idle",
"events",
"interactivity"
],
"author": "hugohil <hugo@soixantecircuits.fr>",

@@ -29,42 +32,35 @@ "license": "MIT",

"gabrielstuff <gabriel@soixantecircuits.fr> (http://twitter.com/gabrielstuff)",
"hugohil <hugo@soixantecircuits.fr> (https://github.com/hugohil)"
"hugohil <hugo@soixantecircuits.fr> (https://github.com/hugohil)",
"Martin Hradil <mhradil@redhat.com> (https://github.com/himdel)"
],
"dependencies": {
"@babel/polyfill": "^7.2.5"
},
"browserslist": "> 0.25%, not dead",
"devDependencies": {
"babel-core": "^6.4.5",
"babel-eslint": "^4.1.6",
"babel-loader": "^6.2.0",
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"@babel/register": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
"babel-plugin-transform-object-assign": "^6.3.13",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.4.3",
"chai": "^3.4.1",
"del": "^2.2.0",
"glob": "^6.0.3",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.1",
"gulp-eslint": "^1.1.1",
"gulp-filter": "^3.0.0",
"gulp-istanbul": "^0.10.3",
"gulp-jscs": "^3.0.0",
"gulp-livereload": "^3.8.1",
"gulp-load-plugins": "^1.1.0",
"gulp-mocha": "^2.2.0",
"gulp-plumber": "^1.0.1",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.6.0",
"del": "^3.0.0",
"gulp": "^4.0.0",
"gulp-babel": "^8.0.0-beta.2",
"gulp-eslint": "^5.0.0",
"gulp-filter": "^5.1.0",
"gulp-load-plugins": "^1.5.0",
"gulp-plumber": "^1.2.1",
"gulp-rename": "^1.4.0",
"gulp-sourcemaps": "^2.6.4",
"gulp-uglify": "^1.5.1",
"gulp-util": "^3.0.7",
"isparta": "^4.0.0",
"json-loader": "^0.5.3",
"mocha": "^2.3.4",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0",
"vinyl-source-stream": "^1.1.0",
"webpack": "^1.12.9",
"webpack-stream": "^3.1.0"
"gulp-util": "^3.0.8",
"webpack": "^4.29.2",
"webpack-cli": "^3.2.3",
"webpack-stream": "^5.2.1"
},
"babelBoilerplateOptions": {
"entryFileName": "idle.js",
"entryFileName": "index.js",
"mainVarName": "IdleJs"
}
}

@@ -11,3 +11,3 @@ # idle-js

// Those are the default values
var idle = new idleJs({
var idle = new IdleJs({
idle: 10000, // idle time in ms

@@ -19,5 +19,17 @@ events: ['mousemove', 'keydown', 'mousedown', 'touchstart'], // events that will trigger the idle resetter

onShow: function () {}, // callback function to be executed when window become visible
keepTracking: true, // set it to false of you want to track only once
keepTracking: true, // set it to false if you want to be notified only on the first idleness change
startAtIdle: false // set it to true if you want to start in the idle state
}).start();
});
idle.start();
// In case stopping is needed
idle.stop() // stops all tracking
.reset() // reset visible and idle state to initial values
.start();
// Reset to a specific state
idle.reset({
idle: false,
visible: ! document.hidden,
})
```

@@ -29,3 +41,3 @@

* Run the command `webpack ./example/webpack/entry.js ./example/webpack/bundle.js`.
* Run the command `npx webpack ./example/webpack/entry.js ./example/webpack/bundle.js`.
* Open `./example/webpack/index.html` in your browser.

@@ -35,2 +47,2 @@

* Open `./example/vanilla/index.html`
* Open `./example/vanilla/index.html`

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc