1
0
mirror of https://github.com/lrsjng/pagemap.git synced 2025-08-13 16:34:03 +02:00
This commit is contained in:
Lars Jung
2024-11-09 19:17:33 +01:00
parent cff4c99036
commit 192be62516
10 changed files with 5372 additions and 6182 deletions

View File

@@ -1,6 +0,0 @@
/build/
/coverage/
/dist/
/es5/
/local/
/node_modules/

View File

@@ -1,182 +0,0 @@
---
root: true
env:
es6: true
node: true
parserOptions:
ecmaVersion: 2019
rules:
array-bracket-spacing: [2, never]
arrow-parens: [2, as-needed]
arrow-spacing: 2
block-scoped-var: 2
brace-style: [2, 1tbs, {allowSingleLine: true}]
camelcase: 0
comma-dangle: [2, never]
comma-spacing: [2, {before: false, after: true}]
comma-style: [2, last]
complexity: [1, 16] ###
computed-property-spacing: [2, never]
consistent-return: 2
consistent-this: [2, self]
constructor-super: 2
curly: [2, multi-line]
default-case: 2
dot-location: [2, property]
dot-notation: [2, {allowKeywords: true}]
eol-last: 2
eqeqeq: 2
func-names: 2
func-style: [2, declaration, {allowArrowFunctions: true}]
generator-star-spacing: [2, after]
guard-for-in: 2
handle-callback-err: 2
indent: [2, 4]
key-spacing: [2, {beforeColon: false, afterColon: true}]
keyword-spacing: [2, {before: true, after: true}]
linebreak-style: [2, unix]
max-depth: [1, 4]
max-len: [0, 80, 4]
max-nested-callbacks: [1, 3]
max-params: [1, 5] ###
max-statements: [1, 48] ###
new-cap: 0
new-parens: 2
newline-after-var: 0
no-alert: 2
no-array-constructor: 2
no-bitwise: 2
no-caller: 2
no-catch-shadow: 2
no-class-assign: 2
no-cond-assign: 2
no-console: 0 ###
no-const-assign: 2
no-constant-condition: 1
no-continue: 0
no-control-regex: 2
no-debugger: 2
no-delete-var: 2
no-div-regex: 2
no-dupe-args: 2
no-dupe-class-members: 2
no-dupe-keys: 2
no-duplicate-case: 2
no-else-return: 1
no-empty: 2
no-empty-character-class: 2
no-empty-pattern: 2
no-eq-null: 2
no-eval: 2
no-ex-assign: 2
no-extend-native: 1
no-extra-bind: 2
no-extra-boolean-cast: 2
no-extra-parens: 1
no-extra-semi: 2
no-fallthrough: 2
no-floating-decimal: 2
no-func-assign: 2
no-implicit-coercion: [2, {boolean: false, number: true, string: true}]
no-implied-eval: 2
no-inline-comments: 0
no-inner-declarations: [2, functions]
no-invalid-regexp: 2
no-invalid-this: 2
no-irregular-whitespace: 2
no-iterator: 2
no-label-var: 2
no-labels: 2
no-lone-blocks: 2
no-lonely-if: 2
no-loop-func: 1
no-magic-numbers: 0
no-mixed-requires: [2, false]
no-mixed-spaces-and-tabs: [2, false]
no-multi-spaces: 2
no-multi-str: 2
no-multiple-empty-lines: [2, {max: 4}]
no-native-reassign: 1
no-negated-in-lhs: 2
no-nested-ternary: 0
no-new: 2
no-new-func: 2
no-new-object: 2
no-new-require: 2
no-new-wrappers: 2
no-obj-calls: 2
no-octal: 2
no-octal-escape: 2
no-param-reassign: 0
no-path-concat: 2
no-plusplus: 2
no-process-env: 2
no-process-exit: 2
no-proto: 2
no-redeclare: 2
no-regex-spaces: 2
no-restricted-modules: 2
no-return-assign: 2
no-script-url: 2
no-self-compare: 2
no-sequences: 2
no-shadow: 2
no-shadow-restricted-names: 2
no-spaced-func: 2
no-sparse-arrays: 2
no-sync: 0
no-ternary: 0
no-this-before-super: 2
no-throw-literal: 1
no-trailing-spaces: 2
no-undef: 2
no-undef-init: 2
no-undefined: 0
no-underscore-dangle: 0
no-unexpected-multiline: 2
no-unneeded-ternary: 2
no-unreachable: 2
no-useless-call: 2
no-useless-concat: 2
no-unused-expressions: 2
no-unused-vars: [1, {vars: all, args: after-used}]
no-use-before-define: 2
no-var: 2
no-void: 2
no-warning-comments: [1, {terms: [todo, fixme, xxx], location: start}]
no-with: 2
object-curly-spacing: [2, never]
object-shorthand: [2, always]
one-var: [2, never]
operator-assignment: [2, always]
operator-linebreak: [2, after]
padded-blocks: [2, never]
prefer-arrow-callback: 2
prefer-const: 1
prefer-reflect: 1
prefer-spread: 2
prefer-template: 0 ###
quote-props: [2, as-needed]
quotes: [2, single, avoid-escape]
radix: 2
require-yield: 2
semi: 2
semi-spacing: [2, {before: false, after: true}]
sort-vars: 0
space-before-blocks: [2, always]
space-before-function-paren: [2, {anonymous: always, named: never}]
space-in-parens: [2, never]
space-infix-ops: 2
space-unary-ops: [2, {words: true, nonwords: false}]
spaced-comment: [2, always]
strict: [2, never]
use-isnan: 2
valid-jsdoc: 2
valid-typeof: 2
vars-on-top: 0
wrap-iife: [2, outside]
wrap-regex: 2
yoda: [2, never, {exceptRange: true}]

View File

@@ -1,7 +1,6 @@
# pagemap
[![license][license-img]][github] [![web][web-img]][web] [![github][github-img]][github] [![npm][npm-img]][npm]
[![version][npm-v-img]][npm] [![downloads][npm-dm-img]][npm]
[![license][license-img]][github] [![github][github-img]][github] [![npm][npm-img]][npm]
Mini map for web pages.
@@ -45,7 +44,7 @@ pagemap(document.querySelector('#map'), {
## License
The MIT License (MIT)
Copyright (c) 2020 Lars Jung (https://larsjung.de)
Copyright (c) 2024 Lars Jung (https://larsjung.de)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -66,14 +65,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
[web]: https://larsjung.de/pagemap/
[github]: https://github.com/lrsjng/pagemap
[npm]: https://www.npmjs.org/package/pagemap
[license-img]: https://img.shields.io/badge/license-MIT-a0a060.svg?style=flat-square
[web-img]: https://img.shields.io/badge/web-larsjung.de/pagemap-a0a060.svg?style=flat-square
[github-img]: https://img.shields.io/badge/github-lrsjng/pagemap-a0a060.svg?style=flat-square
[npm-img]: https://img.shields.io/badge/npm-pagemap-a0a060.svg?style=flat-square
[npm-v-img]: https://img.shields.io/npm/v/pagemap.svg?style=flat-square
[npm-dm-img]: https://img.shields.io/npm/dm/pagemap.svg?style=flat-square

215
dist/pagemap.js vendored
View File

@@ -1,4 +1,4 @@
/*! pagemap v1.4.0 - https://larsjung.de/pagemap/ */
/*! pagemap v1.4.1 - undefined */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
@@ -8,108 +8,21 @@
exports["pagemap"] = factory();
else
root["pagemap"] = factory();
})((typeof self !== 'undefined' ? self : this), function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
})((typeof self !== 'undefined' ? self : this), () => {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/* WEBPACK VAR INJECTION */(function(global) {module.exports = function (canvas, options) {
var WIN = global.window;
module.exports = function (canvas, options) {
var WIN = __webpack_require__.g.window;
var DOC = WIN.document;
var DOC_EL = DOC.documentElement;
var BODY = DOC.querySelector('body');
var CTX = canvas.getContext('2d');
var black = function black(pc) {
return "rgba(0,0,0,".concat(pc / 100, ")");
};
var settings = Object.assign({
viewport: null,
styles: {
@@ -122,21 +35,17 @@ return /******/ (function(modules) { // webpackBootstrap
drag: black(10),
interval: null
}, options);
var _listener = function _listener(el, method, types, fn) {
return types.split(/\s+/).forEach(function (type) {
return el[method](type, fn);
});
};
var on = function on(el, types, fn) {
return _listener(el, 'addEventListener', types, fn);
};
var off = function off(el, types, fn) {
return _listener(el, 'removeEventListener', types, fn);
};
var Rect = function Rect(x, y, w, h) {
return {
x: x,
@@ -145,7 +54,6 @@ return /******/ (function(modules) { // webpackBootstrap
h: h
};
};
var rect_rel_to = function rect_rel_to(rect) {
var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
x: 0,
@@ -153,15 +61,12 @@ return /******/ (function(modules) { // webpackBootstrap
};
return Rect(rect.x - pos.x, rect.y - pos.y, rect.w, rect.h);
};
var rect_of_doc = function rect_of_doc() {
return Rect(0, 0, DOC_EL.scrollWidth, DOC_EL.scrollHeight);
};
var rect_of_win = function rect_of_win() {
return Rect(WIN.pageXOffset, WIN.pageYOffset, DOC_EL.clientWidth, DOC_EL.clientHeight);
};
var el_get_offset = function el_get_offset(el) {
var br = el.getBoundingClientRect();
return {
@@ -169,31 +74,24 @@ return /******/ (function(modules) { // webpackBootstrap
y: br.top + WIN.pageYOffset
};
};
var rect_of_el = function rect_of_el(el) {
var _el_get_offset = el_get_offset(el),
x = _el_get_offset.x,
y = _el_get_offset.y;
return Rect(x, y, el.offsetWidth, el.offsetHeight);
};
var rect_of_viewport = function rect_of_viewport(el) {
var _el_get_offset2 = el_get_offset(el),
x = _el_get_offset2.x,
y = _el_get_offset2.y;
return Rect(x + el.clientLeft, y + el.clientTop, el.clientWidth, el.clientHeight);
};
var rect_of_content = function rect_of_content(el) {
var _el_get_offset3 = el_get_offset(el),
x = _el_get_offset3.x,
y = _el_get_offset3.y;
return Rect(x + el.clientLeft - el.scrollLeft, y + el.clientTop - el.scrollTop, el.scrollWidth, el.scrollHeight);
};
var calc_scale = function () {
var width = canvas.clientWidth;
var height = canvas.clientHeight;
@@ -201,27 +99,22 @@ return /******/ (function(modules) { // webpackBootstrap
return Math.min(width / w, height / h);
};
}();
var resize_canvas = function resize_canvas(w, h) {
canvas.width = w;
canvas.height = h;
canvas.style.width = "".concat(w, "px");
canvas.style.height = "".concat(h, "px");
};
var viewport = settings.viewport;
var find = function find(sel) {
return Array.from((viewport || DOC).querySelectorAll(sel));
};
var drag = false;
var root_rect;
var view_rect;
var scale;
var drag_rx;
var drag_ry;
var draw_rect = function draw_rect(rect, col) {
if (col) {
CTX.beginPath();
@@ -230,7 +123,6 @@ return /******/ (function(modules) { // webpackBootstrap
CTX.fill();
}
};
var apply_styles = function apply_styles(styles) {
Object.keys(styles).forEach(function (sel) {
var col = styles[sel];
@@ -239,7 +131,6 @@ return /******/ (function(modules) { // webpackBootstrap
});
});
};
var draw = function draw() {
root_rect = viewport ? rect_of_content(viewport) : rect_of_doc();
view_rect = viewport ? rect_of_viewport(viewport) : rect_of_win();
@@ -252,98 +143,108 @@ return /******/ (function(modules) { // webpackBootstrap
apply_styles(settings.styles);
draw_rect(rect_rel_to(view_rect, root_rect), drag ? settings.drag : settings.view);
};
var on_drag = function on_drag(ev) {
ev.preventDefault();
var cr = rect_of_viewport(canvas);
var x = (ev.pageX - cr.x) / scale - view_rect.w * drag_rx;
var y = (ev.pageY - cr.y) / scale - view_rect.h * drag_ry;
if (viewport) {
viewport.scrollLeft = x;
viewport.scrollTop = y;
} else {
WIN.scrollTo(x, y);
}
draw();
};
var on_drag_end = function on_drag_end(ev) {
var _on_drag_end = function on_drag_end(ev) {
drag = false;
canvas.style.cursor = 'pointer';
BODY.style.cursor = 'auto';
off(WIN, 'mousemove', on_drag);
off(WIN, 'mouseup', on_drag_end);
off(WIN, 'mouseup', _on_drag_end);
on_drag(ev);
};
var on_drag_start = function on_drag_start(ev) {
drag = true;
var cr = rect_of_viewport(canvas);
var vr = rect_rel_to(view_rect, root_rect);
drag_rx = ((ev.pageX - cr.x) / scale - vr.x) / vr.w;
drag_ry = ((ev.pageY - cr.y) / scale - vr.y) / vr.h;
if (drag_rx < 0 || drag_rx > 1 || drag_ry < 0 || drag_ry > 1) {
drag_rx = 0.5;
drag_ry = 0.5;
}
canvas.style.cursor = 'crosshair';
BODY.style.cursor = 'crosshair';
on(WIN, 'mousemove', on_drag);
on(WIN, 'mouseup', on_drag_end);
on(WIN, 'mouseup', _on_drag_end);
on_drag(ev);
};
var init = function init() {
canvas.style.cursor = 'pointer';
on(canvas, 'mousedown', on_drag_start);
on(viewport || WIN, 'load resize scroll', draw);
if (settings.interval > 0) {
setInterval(function () {
return draw();
}, settings.interval);
}
draw();
};
init();
return {
redraw: draw
};
};
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
/***/ }),
/* 1 */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || new Function("return this")();
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ })
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/global */
/******/ (() => {
/******/ __webpack_require__.g = (function() {
/******/ if (typeof globalThis === 'object') return globalThis;
/******/ try {
/******/ return this || new Function('return this')();
/******/ } catch (e) {
/******/ if (typeof window === 'object') return window;
/******/ }
/******/ })();
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__(0);
/******/
/******/ return __webpack_exports__;
/******/ })()
;
});

4
dist/pagemap.min.js vendored
View File

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

252
eslint.config.cjs Normal file
View File

@@ -0,0 +1,252 @@
const globals = require("globals");
module.exports = [{
ignores: ["eslint.config.*", "build/", "coverage/", "dist/", "es5/", "local/", "node_modules/"],
}, {
languageOptions: {
globals: {
...globals.node,
},
ecmaVersion: 2019,
sourceType: "commonjs",
},
rules: {
"array-bracket-spacing": [2, "never"],
"arrow-parens": [2, "as-needed"],
"arrow-spacing": 2,
"block-scoped-var": 2,
"brace-style": [2, "1tbs", {
allowSingleLine: true,
}],
camelcase: 0,
"comma-dangle": [2, "never"],
"comma-spacing": [2, {
before: false,
after: true,
}],
"comma-style": [2, "last"],
complexity: [1, 16],
"computed-property-spacing": [2, "never"],
"consistent-return": 2,
"consistent-this": [2, "self"],
"constructor-super": 2,
curly: [2, "multi-line"],
"default-case": 2,
"dot-location": [2, "property"],
"dot-notation": [2, {
allowKeywords: true,
}],
"eol-last": 2,
eqeqeq: 2,
"func-names": 2,
"func-style": [2, "declaration", {
allowArrowFunctions: true,
}],
"generator-star-spacing": [2, "after"],
"guard-for-in": 2,
"handle-callback-err": 2,
indent: [2, 4],
"key-spacing": [2, {
beforeColon: false,
afterColon: true,
}],
"keyword-spacing": [2, {
before: true,
after: true,
}],
"linebreak-style": [2, "unix"],
"max-depth": [1, 4],
"max-len": [0, 80, 4],
"max-nested-callbacks": [1, 3],
"max-params": [1, 5],
"max-statements": [1, 48],
"new-cap": 0,
"new-parens": 2,
"newline-after-var": 0,
"no-alert": 2,
"no-array-constructor": 2,
"no-bitwise": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-console": 0,
"no-const-assign": 2,
"no-constant-condition": 1,
"no-continue": 0,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-div-regex": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-else-return": 1,
"no-empty": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-eq-null": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 1,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 1,
"no-extra-semi": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implicit-coercion": [2, {
boolean: false,
number: true,
string: true,
}],
"no-implied-eval": 2,
"no-inline-comments": 0,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-invalid-this": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-lonely-if": 2,
"no-loop-func": 1,
"no-magic-numbers": 0,
"no-mixed-requires": [2, false],
"no-mixed-spaces-and-tabs": [2, false],
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, {
max: 4,
}],
"no-native-reassign": 1,
"no-negated-in-lhs": 2,
"no-nested-ternary": 0,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-param-reassign": 0,
"no-path-concat": 2,
"no-plusplus": 2,
"no-process-env": 2,
"no-process-exit": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-restricted-modules": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-sync": 0,
"no-ternary": 0,
"no-this-before-super": 2,
"no-throw-literal": 1,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-undefined": 0,
"no-underscore-dangle": 0,
"no-unexpected-multiline": 2,
"no-unneeded-ternary": 2,
"no-unreachable": 2,
"no-useless-call": 2,
"no-useless-concat": 2,
"no-unused-expressions": 2,
"no-unused-vars": [1, {
vars: "all",
args: "after-used",
}],
"no-use-before-define": 2,
"no-var": 2,
"no-void": 2,
"no-warning-comments": [1, {
terms: ["todo", "fixme", "xxx"],
location: "start",
}],
"no-with": 2,
"object-curly-spacing": [2, "never"],
"object-shorthand": [2, "always"],
"one-var": [2, "never"],
"operator-assignment": [2, "always"],
"operator-linebreak": [2, "after"],
"padded-blocks": [2, "never"],
"prefer-arrow-callback": 2,
"prefer-const": 1,
"prefer-reflect": 1,
"prefer-spread": 2,
"prefer-template": 0,
"quote-props": [2, "as-needed"],
quotes: [2, "single", "avoid-escape"],
radix: 2,
"require-yield": 2,
semi: 2,
"semi-spacing": [2, {
before: false,
after: true,
}],
"sort-vars": 0,
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, {
anonymous: "always",
named: "never",
}],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, {
words: true,
nonwords: false,
}],
"spaced-comment": [2, "always"],
strict: [2, "never"],
"use-isnan": 2,
// "valid-jsdoc": 2,
"valid-typeof": 2,
"vars-on-top": 0,
"wrap-iife": [2, "outside"],
"wrap-regex": 2,
yoda: [2, "never", {
exceptRange: true,
}],
},
}];

10624
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,7 @@
{
"name": "pagemap",
"version": "1.4.0",
"version": "1.4.1",
"description": "Mini map for web pages.",
"homepage": "https://larsjung.de/pagemap/",
"author": "Lars Jung <lrsjng@gmail.com> (https://larsjung.de)",
"license": "MIT",
"repository": {
@@ -18,11 +17,11 @@
"precommit": "npm run -s check && npm run -s build"
},
"devDependencies": {
"@babel/core": "7.10.5",
"@babel/preset-env": "7.10.4",
"eslint": "7.5.0",
"ghu": "0.25.0",
"jsdom": "16.3.0",
"scar": "2.3.0"
"@babel/core": "7.26.0",
"@babel/preset-env": "7.26.0",
"eslint": "9.14.0",
"ghu": "0.28.5",
"jsdom": "25.0.1",
"scar": "2.3.4"
}
}

View File

@@ -7,7 +7,7 @@
</head>
<body id="boxes-demo" class="checkers">
<div id="banner">
<div><a href="https://larsjung.de/pagemap/">pagemap</a> demo</div>
<div>pagemap demo</div>
<div><a href="text.html">text</a> - <strong>boxes</strong></div>
</div>

View File

@@ -7,7 +7,7 @@
</head>
<body id="text-demo">
<div id="banner">
<div><a href="https://larsjung.de/pagemap/">pagemap</a> demo</div>
<div>pagemap demo</div>
<div><strong>text</strong> - <a href="boxes.html">boxes</a></div>
</div>