1
0
mirror of https://github.com/lrsjng/pagemap.git synced 2025-08-06 21:26:29 +02:00
This commit is contained in:
Lars Jung
2019-03-30 18:10:35 +01:00
parent 294813ff26
commit 94086fff4e
4 changed files with 2809 additions and 1978 deletions

4
dist/pagemap.min.js vendored
View File

@@ -1,2 +1,2 @@
/*! pagemap v0.5.0 - https://larsjung.de/pagemap/ */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.pagemap=e():t.pagemap=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e){(function(e){"use strict";var n=e.window,r=n.document,o=r.documentElement,i=r.querySelector("body"),c=function(t){return"rgba(0,0,0,"+t/100+")"},u={viewport:null,styles:{"header,footer,section,article":c(8),"h1,a":c(10),"h2,h3,h4":c(8)},back:c(2),view:c(5),drag:c(10),interval:null},l=function(t,e,n,r){return n.split(/\s+/).forEach(function(n){return t[e](n,r)})},f=function(t,e,n){return l(t,"addEventListener",e,n)},s=function(t,e,n){return l(t,"removeEventListener",e,n)},a=function(t,e,n,r){return{x:t,y:e,w:n,h:r}},h=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{x:0,y:0};return a(t.x-e.x,t.y-e.y,t.w,t.h)},p=function(){return a(0,0,o.scrollWidth,o.scrollHeight)},d=function(){return a(n.pageXOffset,n.pageYOffset,o.clientWidth,o.clientHeight)},v=function(t){var e=t.getBoundingClientRect();return{x:e.left+n.pageXOffset,y:e.top+n.pageYOffset}},y=function(t){var e=v(t),n=e.x,r=e.y;return a(n,r,t.offsetWidth,t.offsetHeight)},g=function(t){var e=v(t),n=e.x,r=e.y;return a(n+t.clientLeft,r+t.clientTop,t.clientWidth,t.clientHeight)},x=function(t){var e=v(t),n=e.x,r=e.y;return a(n+t.clientLeft-t.scrollLeft,r+t.clientTop-t.scrollTop,t.scrollWidth,t.scrollHeight)};t.exports=function(t,e){var o=Object.assign({},u,e),c=t.getContext("2d"),l=function(){var e=t.clientWidth,n=t.clientHeight;return function(t,r){return Math.min(e/t,n/r)}}(),a=function(e,n){t.width=e,t.height=n,t.style.width=e+"px",t.style.height=n+"px"},v=o.viewport,m=function(t){return Array.from((v||r).querySelectorAll(t))},w=!1,b=void 0,E=void 0,H=void 0,L=void 0,O=void 0,T=function(t,e){e&&(c.beginPath(),c.rect(t.x,t.y,t.w,t.h),c.fillStyle=e,c.fill())},W=function(t){Object.keys(t).forEach(function(e){var n=t[e];m(e).forEach(function(t){T(h(y(t),b),n)})})},j=function(){b=v?x(v):p(),E=v?g(v):d(),H=l(b.w,b.h),a(b.w*H,b.h*H),c.setTransform(1,0,0,1,0,0),c.clearRect(0,0,t.width,t.height),c.scale(H,H),T(h(b,b),o.back),W(o.styles),T(h(E,b),w?o.drag:o.view)},X=function(e){e.preventDefault();var r=g(t),o=(e.pageX-r.x)/H-E.w*L,i=(e.pageY-r.y)/H-E.h*O;v?(v.scrollLeft=o,v.scrollTop=i):n.scrollTo(o,i),j()},Y=function e(r){w=!1,t.style.cursor="pointer",i.style.cursor="auto",s(n,"mousemove",X),s(n,"mouseup",e),X(r)},k=function(e){w=!0;var r=g(t),o=h(E,b);L=((e.pageX-r.x)/H-o.x)/o.w,O=((e.pageY-r.y)/H-o.y)/o.h,(L<0||L>1||O<0||O>1)&&(L=.5,O=.5),t.style.cursor="crosshair",i.style.cursor="crosshair",f(n,"mousemove",X),f(n,"mouseup",Y),X(e)},S=function(){t.style.cursor="pointer",f(t,"mousedown",k),f(v||n,"load resize scroll",j),o.interval>0&&setInterval(function(){return j()},o.interval),j()};return S(),{redraw:j}}}).call(e,function(){return this}())}])});
/*! pagemap v0.6.0 - https://larsjung.de/pagemap/ */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pagemap",[],t):"object"==typeof exports?exports.pagemap=t():e.pagemap=t()}("undefined"!=typeof self?self:this,function(){return function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(n,e,t){(function(e){var b=e.window,w=b.document,j=w.documentElement,O=w.querySelector("body"),t=function(e){return"rgba(0,0,0,".concat(e/100,")")},S={viewport:null,styles:{"header,footer,section,article":t(8),"h1,a":t(10),"h2,h3,h4":t(8)},back:t(2),view:t(5),drag:t(10),interval:null},r=function(t,n,e,r){return e.split(/\s+/).forEach(function(e){return t[n](e,r)})},T=function(e,t,n){return r(e,"addEventListener",t,n)},E=function(e,t,n){return r(e,"removeEventListener",t,n)},H=function(e,t,n,r){return{x:e,y:t,w:n,h:r}},L=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{x:0,y:0};return H(e.x-t.x,e.y-t.y,e.w,e.h)},P=function(e){var t=e.getBoundingClientRect();return{x:t.left+b.pageXOffset,y:t.top+b.pageYOffset}},W=function(e){var t=P(e),n=t.x,r=t.y;return H(n+e.clientLeft,r+e.clientTop,e.clientWidth,e.clientHeight)};n.exports=function(o,e){var n,r,i,c,u,l,f,t=Object.assign({},S,e),a=o.getContext("2d"),s=(n=o.clientWidth,r=o.clientHeight,function(e,t){return Math.min(n/e,r/t)}),p=t.viewport,d=!1,h=function(e,t){t&&(a.beginPath(),a.rect(e.x,e.y,e.w,e.h),a.fillStyle=t,a.fill())},y=function(n){Object.keys(n).forEach(function(e){var t=n[e];(function(e){return Array.from((p||w).querySelectorAll(e))})(e).forEach(function(e){h(L(function(e){var t=P(e),n=t.x,r=t.y;return H(n,r,e.offsetWidth,e.offsetHeight)}(e),i),t)})})},g=function(){i=p?function(e){var t=P(e),n=t.x,r=t.y;return H(n+e.clientLeft-e.scrollLeft,r+e.clientTop-e.scrollTop,e.scrollWidth,e.scrollHeight)}(p):H(0,0,j.scrollWidth,j.scrollHeight),c=p?W(p):H(b.pageXOffset,b.pageYOffset,j.clientWidth,j.clientHeight),u=s(i.w,i.h),function(e,t){o.width=e,o.height=t,o.style.width="".concat(e,"px"),o.style.height="".concat(t,"px")}(i.w*u,i.h*u),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,o.width,o.height),a.scale(u,u),h(L(i,i),t.back),y(t.styles),h(L(c,i),d?t.drag:t.view)},v=function(e){e.preventDefault();var t=W(o),n=(e.pageX-t.x)/u-c.w*l,r=(e.pageY-t.y)/u-c.h*f;p?(p.scrollLeft=n,p.scrollTop=r):b.scrollTo(n,r),g()},m=function e(t){d=!1,o.style.cursor="pointer",O.style.cursor="auto",E(b,"mousemove",v),E(b,"mouseup",e),v(t)},x=function(e){d=!0;var t=W(o),n=L(c,i);l=((e.pageX-t.x)/u-n.x)/n.w,f=((e.pageY-t.y)/u-n.y)/n.h,(l<0||1<l||f<0||1<f)&&(f=l=.5),o.style.cursor="crosshair",O.style.cursor="crosshair",T(b,"mousemove",v),T(b,"mouseup",m),v(e)};return o.style.cursor="pointer",T(o,"mousedown",x),T(p||b,"load resize scroll",g),0<t.interval&&setInterval(function(){return g()},t.interval),g(),{redraw:g}}}).call(this,t(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n}])});

17
ghu.js
View File

@@ -1,5 +1,5 @@
const {resolve, join} = require('path');
const {ghu, jszip, mapfn, read, remove, run, uglify, webpack, wrap, write} = require('ghu');
const {ghu, jszip, mapfn, read, remove, uglify, webpack, wrap, write} = require('ghu');
const NAME = 'pagemap';
@@ -22,24 +22,23 @@ ghu.task('clean', () => {
return remove(`${BUILD}, ${DIST}`);
});
ghu.task('lint', () => {
return run('eslint .', {stdio: 'inherit'});
});
ghu.task('build:script', runtime => {
const webpackConfig = {
mode: 'none',
output: {
library: NAME,
libraryTarget: 'umd'
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: '(typeof self !== \'undefined\' ? self : this)'
},
module: {
loaders: [
rules: [
{
include: [SRC],
loader: 'babel-loader',
query: {
cacheDirectory: true,
presets: ['env']
presets: ['@babel/preset-env']
}
}
]
@@ -48,7 +47,7 @@ ghu.task('build:script', runtime => {
return read(`${SRC}/${NAME}.js`)
.then(webpack(webpackConfig, {showStats: false}))
.then(uglify({compressor: {warnings: false}}))
.then(uglify())
.then(wrap(runtime.commentJs))
.then(write(`${DIST}/${NAME}.min.js`, {overwrite: true}))
.then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.min.js`, {overwrite: true}));

4755
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "pagemap",
"version": "0.5.0",
"version": "0.6.0",
"description": "Mini map for web pages.",
"homepage": "https://larsjung.de/pagemap/",
"bugs": "https://github.com/lrsjng/pagemap/issues",
@@ -17,10 +17,11 @@
"precommit": "npm run -s lint && npm run -s build"
},
"devDependencies": {
"babel-loader": "7.0.0",
"babel-preset-env": "1.7.0",
"eslint": "5.15.1",
"ghu": "0.13.0"
"@babel/core": "7.4.0",
"@babel/preset-env": "7.4.2",
"babel-loader": "8.0.5",
"eslint": "5.16.0",
"ghu": "0.15.0"
},
"engines": {
"node": ">=8.0.0"