Skip to content

Commit 5b83961

Browse files
committed
Update core
1 parent 5d37eba commit 5b83961

File tree

7 files changed

+75
-155
lines changed

7 files changed

+75
-155
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.0.0-beta.11
4+
5+
- Update StaticKit Core (update base64 polyfill)
6+
37
## 1.0.0-beta.10
48

59
- Update StaticKit Core

dist/statickit.esm.js

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -796,54 +796,26 @@ function _createClass(Constructor, protoProps, staticProps) {
796796

797797
var createClass = _createClass;
798798

799-
// Polyfill from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
800-
(function () {
801-
// base64 character set, plus padding character (=)
802-
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
803-
// Regular expression to check formal correctness of base64 encoded strings
804-
b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
805-
806-
window.btoa = window.btoa || function (string) {
807-
string = String(string);
808-
var bitmap,
809-
a,
810-
b,
811-
c,
812-
result = '',
813-
i = 0,
814-
rest = string.length % 3; // To determine the final padding
815-
816-
for (; i < string.length;) {
817-
if ((a = string.charCodeAt(i++)) > 255 || (b = string.charCodeAt(i++)) > 255 || (c = string.charCodeAt(i++)) > 255) throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
818-
bitmap = a << 16 | b << 8 | c;
819-
result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63) + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
820-
} // If there's need of padding, replace the last 'A's with equal signs
821-
822-
823-
return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
824-
};
825-
826-
window.atob = window.atob || function (string) {
827-
// atob can work with strings with whitespaces, even inside the encoded part,
828-
// but only \t, \n, \f, \r and ' ', which can be stripped.
829-
string = String(string).replace(/[\t\n\f\r ]+/g, '');
830-
if (!b64re.test(string)) throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."); // Adding the padding if missing, for semplicity
831-
832-
string += '=='.slice(2 - (string.length & 3));
833-
var bitmap,
834-
result = '',
835-
r1,
836-
r2,
837-
i = 0;
838-
839-
for (; i < string.length;) {
840-
bitmap = b64.indexOf(string.charAt(i++)) << 18 | b64.indexOf(string.charAt(i++)) << 12 | (r1 = b64.indexOf(string.charAt(i++))) << 6 | (r2 = b64.indexOf(string.charAt(i++)));
841-
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
842-
}
843-
844-
return result;
845-
};
846-
})();
799+
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
800+
function btoa(string) {
801+
string = String(string);
802+
var bitmap,
803+
a,
804+
b,
805+
c,
806+
result = '',
807+
i = 0,
808+
rest = string.length % 3; // To determine the final padding
809+
810+
for (; i < string.length;) {
811+
if ((a = string.charCodeAt(i++)) > 255 || (b = string.charCodeAt(i++)) > 255 || (c = string.charCodeAt(i++)) > 255) throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
812+
bitmap = a << 16 | b << 8 | c;
813+
result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63) + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
814+
} // If there's need of padding, replace the last 'A's with equal signs
815+
816+
817+
return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
818+
}
847819

848820
/**
849821
* Base-64 encodes a (JSON-castable) object.
@@ -853,7 +825,7 @@ var createClass = _createClass;
853825
*/
854826

855827
var encode = function encode(obj) {
856-
return window.btoa(JSON.stringify(obj));
828+
return btoa(JSON.stringify(obj));
857829
};
858830
/**
859831
* Appends a key-value pair to a target.

dist/statickit.js

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -799,54 +799,26 @@ var statickit = (function () {
799799

800800
var createClass = _createClass;
801801

802-
// Polyfill from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
803-
(function () {
804-
// base64 character set, plus padding character (=)
805-
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
806-
// Regular expression to check formal correctness of base64 encoded strings
807-
b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
808-
809-
window.btoa = window.btoa || function (string) {
810-
string = String(string);
811-
var bitmap,
812-
a,
813-
b,
814-
c,
815-
result = '',
816-
i = 0,
817-
rest = string.length % 3; // To determine the final padding
818-
819-
for (; i < string.length;) {
820-
if ((a = string.charCodeAt(i++)) > 255 || (b = string.charCodeAt(i++)) > 255 || (c = string.charCodeAt(i++)) > 255) throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
821-
bitmap = a << 16 | b << 8 | c;
822-
result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63) + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
823-
} // If there's need of padding, replace the last 'A's with equal signs
824-
825-
826-
return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
827-
};
828-
829-
window.atob = window.atob || function (string) {
830-
// atob can work with strings with whitespaces, even inside the encoded part,
831-
// but only \t, \n, \f, \r and ' ', which can be stripped.
832-
string = String(string).replace(/[\t\n\f\r ]+/g, '');
833-
if (!b64re.test(string)) throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."); // Adding the padding if missing, for semplicity
834-
835-
string += '=='.slice(2 - (string.length & 3));
836-
var bitmap,
837-
result = '',
838-
r1,
839-
r2,
840-
i = 0;
841-
842-
for (; i < string.length;) {
843-
bitmap = b64.indexOf(string.charAt(i++)) << 18 | b64.indexOf(string.charAt(i++)) << 12 | (r1 = b64.indexOf(string.charAt(i++))) << 6 | (r2 = b64.indexOf(string.charAt(i++)));
844-
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
845-
}
846-
847-
return result;
848-
};
849-
})();
802+
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
803+
function btoa(string) {
804+
string = String(string);
805+
var bitmap,
806+
a,
807+
b,
808+
c,
809+
result = '',
810+
i = 0,
811+
rest = string.length % 3; // To determine the final padding
812+
813+
for (; i < string.length;) {
814+
if ((a = string.charCodeAt(i++)) > 255 || (b = string.charCodeAt(i++)) > 255 || (c = string.charCodeAt(i++)) > 255) throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
815+
bitmap = a << 16 | b << 8 | c;
816+
result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63) + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
817+
} // If there's need of padding, replace the last 'A's with equal signs
818+
819+
820+
return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
821+
}
850822

851823
/**
852824
* Base-64 encodes a (JSON-castable) object.
@@ -856,7 +828,7 @@ var statickit = (function () {
856828
*/
857829

858830
var encode = function encode(obj) {
859-
return window.btoa(JSON.stringify(obj));
831+
return btoa(JSON.stringify(obj));
860832
};
861833
/**
862834
* Appends a key-value pair to a target.

dist/statickit.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/statickit.umd.js

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -802,54 +802,26 @@
802802

803803
var createClass = _createClass;
804804

805-
// Polyfill from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
806-
(function () {
807-
// base64 character set, plus padding character (=)
808-
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
809-
// Regular expression to check formal correctness of base64 encoded strings
810-
b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
811-
812-
window.btoa = window.btoa || function (string) {
813-
string = String(string);
814-
var bitmap,
815-
a,
816-
b,
817-
c,
818-
result = '',
819-
i = 0,
820-
rest = string.length % 3; // To determine the final padding
821-
822-
for (; i < string.length;) {
823-
if ((a = string.charCodeAt(i++)) > 255 || (b = string.charCodeAt(i++)) > 255 || (c = string.charCodeAt(i++)) > 255) throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
824-
bitmap = a << 16 | b << 8 | c;
825-
result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63) + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
826-
} // If there's need of padding, replace the last 'A's with equal signs
827-
828-
829-
return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
830-
};
831-
832-
window.atob = window.atob || function (string) {
833-
// atob can work with strings with whitespaces, even inside the encoded part,
834-
// but only \t, \n, \f, \r and ' ', which can be stripped.
835-
string = String(string).replace(/[\t\n\f\r ]+/g, '');
836-
if (!b64re.test(string)) throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."); // Adding the padding if missing, for semplicity
837-
838-
string += '=='.slice(2 - (string.length & 3));
839-
var bitmap,
840-
result = '',
841-
r1,
842-
r2,
843-
i = 0;
844-
845-
for (; i < string.length;) {
846-
bitmap = b64.indexOf(string.charAt(i++)) << 18 | b64.indexOf(string.charAt(i++)) << 12 | (r1 = b64.indexOf(string.charAt(i++))) << 6 | (r2 = b64.indexOf(string.charAt(i++)));
847-
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
848-
}
849-
850-
return result;
851-
};
852-
})();
805+
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
806+
function btoa(string) {
807+
string = String(string);
808+
var bitmap,
809+
a,
810+
b,
811+
c,
812+
result = '',
813+
i = 0,
814+
rest = string.length % 3; // To determine the final padding
815+
816+
for (; i < string.length;) {
817+
if ((a = string.charCodeAt(i++)) > 255 || (b = string.charCodeAt(i++)) > 255 || (c = string.charCodeAt(i++)) > 255) throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");
818+
bitmap = a << 16 | b << 8 | c;
819+
result += b64.charAt(bitmap >> 18 & 63) + b64.charAt(bitmap >> 12 & 63) + b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
820+
} // If there's need of padding, replace the last 'A's with equal signs
821+
822+
823+
return rest ? result.slice(0, rest - 3) + '==='.substring(rest) : result;
824+
}
853825

854826
/**
855827
* Base-64 encodes a (JSON-castable) object.
@@ -859,7 +831,7 @@
859831
*/
860832

861833
var encode = function encode(obj) {
862-
return window.btoa(JSON.stringify(obj));
834+
return btoa(JSON.stringify(obj));
863835
};
864836
/**
865837
* Appends a key-value pair to a target.

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@statickit/standalone",
3-
"version": "1.0.0-beta.10",
3+
"version": "1.0.0-beta.11",
44
"description": "The JavaScript client for StaticKit",
55
"homepage": "https://statickit.com",
66
"author": "Derrick Reimer",
@@ -29,8 +29,8 @@
2929
"rollup-plugin-terser": "5.1.1"
3030
},
3131
"dependencies": {
32-
"@statickit/core": "1.1.0",
33-
"hyperscript": "2.0.2"
32+
"@statickit/core": "^1.2.0",
33+
"hyperscript": "^2.0.2"
3434
},
3535
"husky": {
3636
"hooks": {

0 commit comments

Comments
 (0)