Skip to content

Commit

Permalink
upgrade plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Raruto committed Mar 16, 2022
1 parent 750cbf7 commit a7ec161
Show file tree
Hide file tree
Showing 13 changed files with 586 additions and 457 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
npm-debug.log
src/*.min.js
src/*.min.css
src/**/*.min.js
src/**/*.min.css
build/**/*.min.js
2 changes: 2 additions & 0 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default [
input: input,
output: output,
plugins: plugins,
moduleContext: { "node_modules/leaflet.fullscreen/Control.FullScreen.js": "window" },
},

//** "leaflet-ui.js" **//
Expand All @@ -40,6 +41,7 @@ export default [
file: "dist/" + plugin.name + ".js"
}),
plugins: plugins.concat(terser()),
moduleContext: { "node_modules/leaflet.fullscreen/Control.FullScreen.js": "window" },
},

//** "leaflet-ui.css" **//
Expand Down
1 change: 1 addition & 0 deletions dist/images/leaflet.fullscreenicon-fullscreen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dist/images/leaflet.locatecontrollocation-arrow-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dist/images/leaflet.locatecontrolspinner-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
874 changes: 493 additions & 381 deletions dist/leaflet-ui-src.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/leaflet-ui-src.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/leaflet-ui.css

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions dist/leaflet-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/leaflet-ui.js.map

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"rollup-plugin-terser": "^7.0.2"
},
"peerDependencies": {
"leaflet": "^1.6.0"
"leaflet": "^1.7.1"
},
"dependencies": {
"@raruto/leaflet-edit-osm": "0.0.2",
Expand All @@ -49,12 +49,12 @@
"leaflet-minimap": "^3.6.1",
"leaflet-pegman": "^0.1.6",
"leaflet-pointable": "^0.0.4",
"leaflet-rotate": "^0.1.3",
"leaflet-search": "^2.9.8",
"leaflet-rotate": "^0.1.4",
"leaflet-search": "^3.0.2",
"leaflet.control.resizer": "^0.0.1",
"leaflet.fullscreen": "^1.6.0",
"leaflet.gridlayer.googlemutant": "^0.13.4",
"leaflet.locatecontrol": "^0.74.0",
"leaflet.fullscreen": "^2.2.0",
"leaflet.gridlayer.googlemutant": "^0.13.5",
"leaflet.locatecontrol": "^0.76.0",
"leaflet.visualclick": "^1.1.4"
}
}
91 changes: 45 additions & 46 deletions src/leaflet-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,57 @@ import 'leaflet-easyprint';
import 'leaflet.control.resizer';
import 'leaflet.visualclick';

const currentScript = document.currentScript;
const currentVersion = version.split("+")[0].trim();

(function() {

var lazyLoader = {
const currentScript = document.currentScript;
const currentVersion = version.split("+")[0].trim();

baseURL: 'https://unpkg.com/',
var lazyLoader = {

// Sequentially download multiple scripts.
loadSyncScripts: function(urls) {
return urls.reduce((prev, curr) => prev.then(() => lazyLoader.loadAsyncScripts(curr)), Promise.resolve());
},
baseURL: 'https://unpkg.com/',

// Parallel download multiple scripts.
loadAsyncScripts: function(urls) {
return Promise.all(urls.map((url) => lazyLoader.loadScript(url)));
},
// Sequentially download multiple scripts.
loadSyncScripts: function(urls) {
return urls.reduce((prev, curr) => prev.then(() => lazyLoader.loadAsyncScripts(curr)), Promise.resolve());
},

// Dynamically load a single script.
loadScript: function(url) {
return new Promise((resolve, reject) => {
// Parallel download multiple scripts.
loadAsyncScripts: function(urls) {
return Promise.all(urls.map((url) => lazyLoader.loadScript(url)));
},

let type = url.split('.').pop().split('?')[0];
let tag = type == 'css' ? 'link' : 'script';
let script = document.createElement(tag);
let head = document.head;
let root_script = (head.contains(currentScript) ? currentScript : head.lastChild) || head;
let prev_tag = lazyLoader["prev_" + tag] || (tag == 'script' && lazyLoader.prev_link ? lazyLoader.prev_link : root_script);
let base_url = (url.indexOf(".") === 0 || url.indexOf("/") === 0 || url.indexOf('http://') === 0 || url.indexOf('https://') === 0) ? '' : lazyLoader.baseURL;
// Dynamically load a single script.
loadScript: function(url) {
return new Promise((resolve, reject) => {

if (type == 'css') {
script.rel = 'stylesheet';
}
let type = url.split('.').pop().split('?')[0];
let tag = type == 'css' ? 'link' : 'script';
let script = document.createElement(tag);
let head = document.head;
let root_script = (head.contains(currentScript) ? currentScript : head.lastChild) || head;
let prev_tag = lazyLoader["prev_" + tag] || (tag == 'script' && lazyLoader.prev_link ? lazyLoader.prev_link : root_script);
let base_url = (url.indexOf(".") === 0 || url.indexOf("/") === 0 || url.indexOf('http://') === 0 || url.indexOf('https://') === 0) ? '' : lazyLoader.baseURL;

script.addEventListener('load', resolve, {
once: true
});
script.setAttribute(type == 'css' ? 'href' : 'src', base_url + url);

if (prev_tag.parentNode && prev_tag.nextSibling)
prev_tag.parentNode.insertBefore(script, prev_tag.nextSibling);
else
head.appendChild(script);
if (type == 'css') {
script.rel = 'stylesheet';
}

lazyLoader["prev_" + tag] = script;
script.addEventListener('load', resolve, {
once: true
});
script.setAttribute(type == 'css' ? 'href' : 'src', base_url + url);

});
}
if (prev_tag.parentNode && prev_tag.nextSibling)
prev_tag.parentNode.insertBefore(script, prev_tag.nextSibling);
else
head.appendChild(script);

};
lazyLoader["prev_" + tag] = script;

});
}

(function() {
};

// You can ovveride them by passing one of the following to leaflet map constructor.
var default_options = {
Expand Down Expand Up @@ -132,7 +130,7 @@ var lazyLoader = {
position: 'bottomright'
},
rotateControl: {
position: 'bottomright'
position: 'bottomright',
},
scaleControl: {
width: 200,
Expand Down Expand Up @@ -247,6 +245,7 @@ var lazyLoader = {
resizerControl: false,
disableDefaultUI: false,
includeLeafletCSS: true,
includeLeafletUICSS: true,
apiKeys: undefined, // eg. { thunderforest: "", google: "", ... }
_isMiniMap: false, // used to prevent infinite loops when loading the minimap control.
});
Expand Down Expand Up @@ -483,7 +482,10 @@ var lazyLoader = {
// Load custom plugins.
if (this.options.plugins) {
if (!lazyLoader.loader) {
var core_plugins = ["leaflet-ui@" + currentVersion + "/dist/leaflet-ui.css"];
var core_plugins = [];
if (this.options.includeLeafletUICSS) {
core_plugins.unshift("leaflet-ui@" + currentVersion + "/dist/leaflet-ui.css");
}
if (!window.L) {
core_plugins.unshift("[email protected]/dist/leaflet.css");
core_plugins.unshift("[email protected]/dist/leaflet.js");
Expand Down Expand Up @@ -515,10 +517,7 @@ var lazyLoader = {
});
}

lazyLoader.loader
.then(function() {
this.fire('plugins_loaded');
}.bind(this));
lazyLoader.loader.then(() => this.fire('plugins_loaded'));
}
}

Expand Down

0 comments on commit a7ec161

Please sign in to comment.