Mods to avoid conflict with webpHeroPolyfills

Former-commit-id: b208f401f7968f1aa7d072894eb05ef3fe8611bf [formerly 958484cc6122cf430656eacac8308190f9357538] [formerly bec17cef0fcc2dea989d6f5fee523fb7528c4645] [formerly b7f539411c022cc41a2e8e15b249166270e8df6c [formerly d211a744cf555d6ef61fb928b1ca1e4ca1f618ac [formerly 5eda5870a52a732c3d489273411a7af67c877764]]]
Former-commit-id: 941b7bcf1021939e7e6f4c3bb8c26e759fc6d911 [formerly c97293c3c78c77ef931c355500c9af16b4e73708 [formerly 9261be5ddb9dd90698771b869255875bf596f68a]]
Former-commit-id: 9886903e7d6082170eea3943aa77fe87f6eff338 [formerly b0b363ebbaf2033d168f7e463cbd203890e7f5a4]
Former-commit-id: 4f2b2aadc182a86881f2847e20b8998d9b8bfa6b
This commit is contained in:
Jaifroid 2021-07-16 17:53:58 +01:00
parent 700e861162
commit c726dafac0
8 changed files with 274 additions and 106 deletions

View File

@ -162,9 +162,9 @@
<Content Include="www\I\AviationHistoryBanner3.jpg" /> <Content Include="www\I\AviationHistoryBanner3.jpg" />
<Content Include="www\I\Hand_sanitizer_banner.jpg" /> <Content Include="www\I\Hand_sanitizer_banner.jpg" />
<Content Include="www\I\IriomoteBanner1.jpg" /> <Content Include="www\I\IriomoteBanner1.jpg" />
<Content Include="www\js\lib\arrayFromPolyfill.js" />
<Content Include="www\js\lib\promisePolyfill.js" /> <Content Include="www\js\lib\promisePolyfill.js" />
<Content Include="www\js\lib\webpHeroBundle_0.0.0-dev.27.js" /> <Content Include="www\js\lib\webpHeroBundle_0.0.0-dev.27.js" />
<Content Include="www\js\lib\webpHeroPolyfills_0.0.0-dev.27.js" />
<Content Include="www\js\lib\zstddec.js" /> <Content Include="www\js\lib\zstddec.js" />
<Content Include="www\js\lib\zstddec_wrapper.js" /> <Content Include="www\js\lib\zstddec_wrapper.js" />
<None Include="Package.StoreAssociation.xml" /> <None Include="Package.StoreAssociation.xml" />

View File

@ -1,93 +1,93 @@
{ {
"name": "kiwix-js-pwa", "name": "kiwix-js-pwa",
"productName": "Kiwix JS PWA", "productName": "Kiwix JS PWA",
"version": "1.5.0", "version": "1.5.0",
"description": "Kiwix JS PWA packaged for the Electron framework", "description": "Kiwix JS PWA packaged for the Electron framework",
"main": "main.js", "main": "main.js",
"build": { "build": {
"appId": "kiwix.js.pwa", "appId": "kiwix.js.pwa",
"productName": "Kiwix JS PWA", "productName": "Kiwix JS PWA",
"directories": { "directories": {
"output": "bld/Electron", "output": "bld/Electron",
"buildResources": "bld" "buildResources": "bld"
}, },
"afterPack": "./scripts/appimage-fix.js", "afterPack": "./scripts/appimage-fix.js",
"win": { "win": {
"target": [ "target": [
{ {
"target": "NSIS", "target": "NSIS",
"arch": "ia32" "arch": "ia32"
} }
] ]
}, },
"linux": { "linux": {
"target": [ "target": [
{ {
"target": "AppImage", "target": "AppImage",
"arch": [ "arch": [
"x64", "x64",
"ia32" "ia32"
] ]
}, },
{ {
"target": "deb", "target": "deb",
"arch": [ "arch": [
"x64", "x64",
"ia32" "ia32"
] ]
} }
], ],
"category": "Education" "category": "Education"
}, },
"nsis": { "nsis": {
"oneClick": "false", "oneClick": "false",
"allowElevation": "true", "allowElevation": "true",
"runAfterFinish": "true" "runAfterFinish": "true"
}, },
"asar": false, "asar": false,
"files": [ "files": [
"archives/**", "archives/**",
"pwabuilder-sw.js", "pwabuilder-sw.js",
"index.html", "index.html",
"CHANGELOG.md", "CHANGELOG.md",
"LICENCE", "LICENCE",
"www/**", "www/**",
"preload.js", "preload.js",
"main.js" "main.js"
] ]
}, },
"scripts": { "scripts": {
"start": "electron .", "start": "electron .",
"dist-win": "electron-builder build --win", "dist-win": "electron-builder build --win",
"dist-linux": "electron-builder build --linux", "dist-linux": "electron-builder build --linux",
"package-mac": "electron-packager . kiwix-js-windows --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds", "package-mac": "electron-packager . kiwix-js-windows --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",
"package-win": "electron-packager . kiwix-js-windows --electron-version='10.4.0' --ignore=archives --ignore=AppPackages --ignore=BundleArtifacts --ignore=images$ --ignore=bin$ --ignore=bld$ --ignore=KiwixWebApp.* --ignore=[pP]ackage.[aSl] --ignore=node_ --ignore=[.]git[hi][ug][bn] --ignore=[.]vs$ --ignore=vscode --overwrite --platform=win32 --arch=ia32 --icon=www/img/icons/kiwix-64.ico --prune=true --out=bld/electron --version-string.CompanyName=Kiwix --version-string.FileDescription='Kiwix JS ZIM File Reader' --version-string.ProductName='Kiwix JS Windows Electron Edition'", "package-win": "electron-packager . kiwix-js-windows --electron-version='10.4.0' --ignore=archives --ignore=AppPackages --ignore=BundleArtifacts --ignore=images$ --ignore=bin$ --ignore=bld$ --ignore=KiwixWebApp.* --ignore=[pP]ackage.[aSl] --ignore=node_ --ignore=[.]git[hi][ug][bn] --ignore=[.]vs$ --ignore=vscode --overwrite --platform=win32 --arch=ia32 --icon=www/img/icons/kiwix-64.ico --prune=true --out=bld/electron --version-string.CompanyName=Kiwix --version-string.FileDescription='Kiwix JS ZIM File Reader' --version-string.ProductName='Kiwix JS Windows Electron Edition'",
"postpackage-win": "(robocopy archives bld\\Electron\\kiwix-js-windows-win32-ia32\\resources\\app\\archives\\ > null) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0", "postpackage-win": "(robocopy archives bld\\Electron\\kiwix-js-windows-win32-ia32\\resources\\app\\archives\\ > null) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0",
"package-linux": "electron-packager . kiwix-js-windows --overwrite --platform=linux --icon=www/img/icons/kiwix-64.png --electron-version='10.4.0' --ignore=archives --ignore=AppPackages --ignore=BundleArtifacts --ignore=images$ --ignore=bin$ --ignore=bld$ --ignore=KiwixWebApp.* --ignore=[pP]ackage.[aSl] --ignore=node_ --ignore=[.]git[hi][ug][bn] --ignore=[.]vs$ --ignore=vscode --overwrite --arch=x64 --prune=true --out=bld/electron --version-string.CompanyName=Kiwix --version-string.FileDescription='Kiwix JS ZIM File Reader' --version-string.ProductName='Kiwix JS Windows Electron Edition'", "package-linux": "electron-packager . kiwix-js-windows --overwrite --platform=linux --icon=www/img/icons/kiwix-64.png --electron-version='10.4.0' --ignore=archives --ignore=AppPackages --ignore=BundleArtifacts --ignore=images$ --ignore=bin$ --ignore=bld$ --ignore=KiwixWebApp.* --ignore=[pP]ackage.[aSl] --ignore=node_ --ignore=[.]git[hi][ug][bn] --ignore=[.]vs$ --ignore=vscode --overwrite --arch=x64 --prune=true --out=bld/electron --version-string.CompanyName=Kiwix --version-string.FileDescription='Kiwix JS ZIM File Reader' --version-string.ProductName='Kiwix JS Windows Electron Edition'",
"postpackage-linux": "(robocopy archives bld\\Electron\\kiwix-js-windows-linux-x64\\archives\\ > null) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0" "postpackage-linux": "(robocopy archives bld\\Electron\\kiwix-js-windows-linux-x64\\archives\\ > null) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0"
}, },
"repository": "https://github.com/kiwix/kiwix-js-windows", "repository": "https://github.com/kiwix/kiwix-js-windows",
"keywords": [ "keywords": [
"Kiwix", "Kiwix",
"offline", "offline",
"Wikipedia", "Wikipedia",
"ZIM", "ZIM",
"reader" "reader"
], ],
"author": { "author": {
"name": "Kiwix", "name": "Kiwix",
"email": "kiwix@kiwix.org" "email": "kiwix@kiwix.org"
}, },
"maintainer": "Jaifroid", "maintainer": "Jaifroid",
"license": "CC0-1.0", "license": "CC0-1.0",
"devDependencies": { "devDependencies": {
"electron": "10.4.0", "electron": "10.4.0",
"electron-builder": "^22.10.5", "electron-builder": "^22.10.5",
"electron-packager": "^15.2.0" "electron-packager": "^15.2.0"
}, },
"dependencies": { "dependencies": {
"@types/fs-extra": "^9.0.11" "@types/fs-extra": "^9.0.11"
} }
} }

View File

@ -60,6 +60,7 @@ const precacheFiles = [
"www/article.html", "www/article.html",
"www/js/app.js", "www/js/app.js",
"www/js/init.js", "www/js/init.js",
"www/js/lib/arrayFromPolyfill.js",
"www/js/lib/bootstrap.js", "www/js/lib/bootstrap.js",
"www/js/lib/bootstrap.min.js", "www/js/lib/bootstrap.min.js",
"www/js/lib/cache.js", "www/js/lib/cache.js",

View File

@ -421,8 +421,7 @@ require.config({
//'jquery': 'jquery-3.2.1', //'jquery': 'jquery-3.2.1',
//'bootstrap': 'bootstrap' //'bootstrap': 'bootstrap'
'bootstrap': 'bootstrap.min', 'bootstrap': 'bootstrap.min',
'webpHeroBundle': 'webpHeroBundle_0.0.0-dev.27', 'webpHeroBundle': 'webpHeroBundle_0.0.0-dev.27'
'webpHeroPolyfills': 'webpHeroPolyfills_0.0.0-dev.27'
}, },
shim: { shim: {
'jquery': { 'jquery': {
@ -431,13 +430,11 @@ require.config({
'bootstrap': { 'bootstrap': {
deps: ['jquery'] deps: ['jquery']
}, },
'webpHeroBundle': { 'webpHeroBundle': ''
deps: ['webpHeroPolyfills']
}
} }
}); });
requirejs(['bootstrap', 'promisePolyfill'], function () { requirejs(['bootstrap', 'promisePolyfill', 'arrayFromPolyfill'], function () {
requirejs(['../app']); requirejs(['../app']);
}); });

View File

@ -0,0 +1,172 @@
/* globals
IsCallable, GetMethod, Symbol, IsConstructor, Construct, ArrayCreate, GetIterator, IteratorClose,
ToString, IteratorStep, IteratorValue, Call, CreateDataPropertyOrThrow, ToObject, ToLength, Get, CreateMethodProperty
*/
(function () {
// Detection
if ('from' in Array && (function () {
try {
Array.from({ length: -Infinity });
if (Array.from(new self.Set(['a']))[0] !== 'a') {
return false;
}
if (Array.from(new self.Map([['a', 'one']]))[0][0] !== 'a') {
return false;
}
return true;
} catch (e) {
return false;
}
}())) { return; }
var toString = Object.prototype.toString;
var stringMatch = String.prototype.match;
// A cross-realm friendly way to detect if a value is a String object or literal.
function isString(value) {
if (typeof value === 'string') { return true; }
if (typeof value !== 'object') { return false; }
return toString.call(value) === '[object String]';
}
// 22.1.2.1. Array.from ( items [ , mapfn [ , thisArg ] ] )
CreateMethodProperty(Array, 'from', function from(items /* [ , mapfn [ , thisArg ] ] */) { // eslint-disable-line no-undef
// 1. Let C be the this value.
var C = this;
// 2. If mapfn is undefined, let mapping be false.
var mapfn = arguments.length > 1 ? arguments[1] : undefined;
if (mapfn === undefined) {
var mapping = false;
// 3. Else,
} else {
// a. If IsCallable(mapfn) is false, throw a TypeError exception.
if (IsCallable(mapfn) === false) {
throw new TypeError(Object.prototype.toString.call(mapfn) + ' is not a function.');
}
// b. If thisArg is present, let T be thisArg; else let T be undefined.
var thisArg = arguments.length > 2 ? arguments[2] : undefined;
if (thisArg !== undefined) {
var T = thisArg;
} else {
T = undefined;
}
// c. Let mapping be true.
mapping = true;
}
// 4. Let usingIterator be ? GetMethod(items, @@iterator).
var usingIterator = GetMethod(items, Symbol.iterator);
// 5. If usingIterator is not undefined, then
if (usingIterator !== undefined) {
// a. If IsConstructor(C) is true, then
if (IsConstructor(C)) {
// i. Let A be ? Construct(C).
var A = Construct(C);
// b. Else,
} else {
// i. Let A be ! ArrayCreate(0).
A = ArrayCreate(0);
}
// c. Let iteratorRecord be ? GetIterator(items, usingIterator).
var iteratorRecord = GetIterator(items, usingIterator);
// d. Let k be 0.
var k = 0;
// e. Repeat,
// eslint-disable-next-line no-constant-condition
while (true) {
// i. If k ≥ 2^53-1, then
if (k >= (Math.pow(2, 53) - 1)) {
// 1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
var error = new TypeError('Iteration count can not be greater than or equal 9007199254740991.');
// 2. Return ? IteratorClose(iteratorRecord, error).
return IteratorClose(iteratorRecord, error);
}
// ii. Let Pk be ! ToString(k).
var Pk = ToString(k);
// iii. Let next be ? IteratorStep(iteratorRecord).
var next = IteratorStep(iteratorRecord);
// iv. If next is false, then
if (next === false) {
// 1. Perform ? Set(A, "length", k, true).
A.length = k;
// 2. Return A.
return A;
}
// v. Let nextValue be ? IteratorValue(next).
var nextValue = IteratorValue(next);
// vi. If mapping is true, then
if (mapping) {
try {
// Polyfill.io - The try catch accounts for step 2.
// 1. Let mappedValue be Call(mapfn, T, « nextValue, k »).
var mappedValue = Call(mapfn, T, [nextValue, k]);
// 2. If mappedValue is an abrupt completion, return ? IteratorClose(iteratorRecord, mappedValue).
// 3. Let mappedValue be mappedValue.[[Value]].
} catch (e) {
return IteratorClose(iteratorRecord, e);
}
// vii. Else, let mappedValue be nextValue.
} else {
mappedValue = nextValue;
}
try {
// Polyfill.io - The try catch accounts for step ix.
// viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).
CreateDataPropertyOrThrow(A, Pk, mappedValue);
// ix. If defineStatus is an abrupt completion, return ? IteratorClose(iteratorRecord, defineStatus).
} catch (e) {
return IteratorClose(iteratorRecord, e);
}
// x. Increase k by 1.
k = k + 1;
}
}
// 6. NOTE: items is not an Iterable so assume it is an array-like object.
// 7. Let arrayLike be ! ToObject(items).
// Polyfill.io - For Strings we need to split astral symbols into surrogate pairs.
if (isString(items)) {
var arrayLike = stringMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
} else {
arrayLike = ToObject(items);
}
// 8. Let len be ? ToLength(? Get(arrayLike, "length")).
var len = ToLength(Get(arrayLike, "length"));
// 9. If IsConstructor(C) is true, then
if (IsConstructor(C)) {
// a. Let A be ? Construct(C, « len »).
A = Construct(C, [len]);
// 10. Else,
} else {
// a. Let A be ? ArrayCreate(len).
A = ArrayCreate(len);
}
// 11. Let k be 0.
k = 0;
// 12. Repeat, while k < len
while (k < len) {
// a. Let Pk be ! ToString(k).
Pk = ToString(k);
// b. Let kValue be ? Get(arrayLike, Pk).
var kValue = Get(arrayLike, Pk);
// c. If mapping is true, then
if (mapping === true) {
// i. Let mappedValue be ? Call(mapfn, T, « kValue, k »).
mappedValue = Call(mapfn, T, [kValue, k]);
// d. Else, let mappedValue be kValue.
} else {
mappedValue = kValue;
}
// e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
CreateDataPropertyOrThrow(A, Pk, mappedValue);
// f. Increase k by 1.
k = k + 1;
}
// 13. Perform ? Set(A, "length", len, true).
A.length = len;
// 14. Return A.
return A;
});
}());

View File

@ -1,4 +1,4 @@
/* /*
Yaku v0.19.3 Yaku v0.19.3
(c) 2015 Yad Smood. http://ysmood.org (c) 2015 Yad Smood. http://ysmood.org
License MIT License MIT

File diff suppressed because one or more lines are too long

View File

@ -94,7 +94,7 @@ define(['zstddec'], function() {
* Is the decompressor already working? * Is the decompressor already working?
* @type Boolean * @type Boolean
*/ */
var busy = false; appstate.zdBusy = false;
/** /**
* @typedef Decompressor * @typedef Decompressor
@ -121,7 +121,7 @@ define(['zstddec'], function() {
* @returns {Promise<ArrayBuffer>} Promise for an ArrayBuffer with decoded data * @returns {Promise<ArrayBuffer>} Promise for an ArrayBuffer with decoded data
*/ */
Decompressor.prototype.readSlice = function(offset, length) { Decompressor.prototype.readSlice = function(offset, length) {
busy = true; appstate.zdBusy = true;
this._inStreamPos = 0; this._inStreamPos = 0;
this._inStreamChunkedPos = 0; this._inStreamChunkedPos = 0;
this._outStreamPos = 0; this._outStreamPos = 0;
@ -139,7 +139,7 @@ define(['zstddec'], function() {
// Should you need to free the decoder stream handle, use command below, but be sure to create a new stream control object // Should you need to free the decoder stream handle, use command below, but be sure to create a new stream control object
// before attempting further decompression // before attempting further decompression
// zd._ZSTD_freeDStream(zd._decHandle); // zd._ZSTD_freeDStream(zd._decHandle);
busy = false; appstate.zdBusy = false;
return data; return data;
}); });
}; };
@ -152,7 +152,7 @@ define(['zstddec'], function() {
* @returns {Promise} A Promise for the readSlice() function * @returns {Promise} A Promise for the readSlice() function
*/ */
Decompressor.prototype.readSliceSingleThread = function (offset, length) { Decompressor.prototype.readSliceSingleThread = function (offset, length) {
if (!busy) { if (!appstate.zdBusy) {
return this.readSlice(offset, length); return this.readSlice(offset, length);
} else { } else {
// The decompressor is already in progress. // The decompressor is already in progress.
@ -260,4 +260,4 @@ define(['zstddec'], function() {
return { return {
Decompressor: Decompressor Decompressor: Decompressor
}; };
}); });