From b01ceb73c0703ce87c9d7a7724067395b2cd94bc Mon Sep 17 00:00:00 2001 From: april418 Date: Tue, 9 Jun 2026 19:05:22 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=E3=83=93=E3=83=AB=E3=83=89=E6=88=90?= =?UTF-8?q?=E6=9E=9C=E7=89=A9(cjs/esm)=E3=82=92=E3=82=B3=E3=83=9F=E3=83=83?= =?UTF-8?q?=E3=83=88=E5=AF=BE=E8=B1=A1=E3=81=8B=E3=82=89=E5=A4=96=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cjs/esm は publish CI の `pnpm run build`(tsc) で生成され publish される ため、リポジトリにコミットする必要がない。コミットは drift・レビュー ノイズ・コンフリクトを招くだけ。.gitignore に cjs/ esm/ を追加し追跡から 外す(--cached でディスク上のファイルは保持)。published パッケージは CI が 再ビルドするため不変。同組織の IMUID-js / im-ulid と方針を揃える。 Co-Authored-By: Claude Opus 4.8 --- .gitignore | 4 + cjs/Cookie.d.ts | 19 ----- cjs/Cookie.js | 58 ------------- cjs/Cookie.js.map | 1 - cjs/LocalStorage.d.ts | 5 -- cjs/LocalStorage.js | 36 --------- cjs/LocalStorage.js.map | 1 - cjs/SessionStorage.d.ts | 5 -- cjs/SessionStorage.js | 36 --------- cjs/SessionStorage.js.map | 1 - cjs/XHR.d.ts | 89 -------------------- cjs/XHR.js | 166 -------------------------------------- cjs/XHR.js.map | 1 - cjs/index.d.ts | 5 -- cjs/index.js | 42 ---------- cjs/index.js.map | 1 - cjs/sendBeacon.d.ts | 27 ------- cjs/sendBeacon.js | 60 -------------- cjs/sendBeacon.js.map | 1 - esm/Cookie.d.ts | 19 ----- esm/Cookie.js | 51 ------------ esm/Cookie.js.map | 1 - esm/LocalStorage.d.ts | 5 -- esm/LocalStorage.js | 29 ------- esm/LocalStorage.js.map | 1 - esm/SessionStorage.d.ts | 5 -- esm/SessionStorage.js | 29 ------- esm/SessionStorage.js.map | 1 - esm/XHR.d.ts | 89 -------------------- esm/XHR.js | 157 ----------------------------------- esm/XHR.js.map | 1 - esm/index.d.ts | 5 -- esm/index.js | 11 --- esm/index.js.map | 1 - esm/sendBeacon.d.ts | 27 ------- esm/sendBeacon.js | 54 ------------- esm/sendBeacon.js.map | 1 - 37 files changed, 4 insertions(+), 1041 deletions(-) delete mode 100644 cjs/Cookie.d.ts delete mode 100644 cjs/Cookie.js delete mode 100644 cjs/Cookie.js.map delete mode 100644 cjs/LocalStorage.d.ts delete mode 100644 cjs/LocalStorage.js delete mode 100644 cjs/LocalStorage.js.map delete mode 100644 cjs/SessionStorage.d.ts delete mode 100644 cjs/SessionStorage.js delete mode 100644 cjs/SessionStorage.js.map delete mode 100644 cjs/XHR.d.ts delete mode 100644 cjs/XHR.js delete mode 100644 cjs/XHR.js.map delete mode 100644 cjs/index.d.ts delete mode 100644 cjs/index.js delete mode 100644 cjs/index.js.map delete mode 100644 cjs/sendBeacon.d.ts delete mode 100644 cjs/sendBeacon.js delete mode 100644 cjs/sendBeacon.js.map delete mode 100644 esm/Cookie.d.ts delete mode 100644 esm/Cookie.js delete mode 100644 esm/Cookie.js.map delete mode 100644 esm/LocalStorage.d.ts delete mode 100644 esm/LocalStorage.js delete mode 100644 esm/LocalStorage.js.map delete mode 100644 esm/SessionStorage.d.ts delete mode 100644 esm/SessionStorage.js delete mode 100644 esm/SessionStorage.js.map delete mode 100644 esm/XHR.d.ts delete mode 100644 esm/XHR.js delete mode 100644 esm/XHR.js.map delete mode 100644 esm/index.d.ts delete mode 100644 esm/index.js delete mode 100644 esm/index.js.map delete mode 100644 esm/sendBeacon.d.ts delete mode 100644 esm/sendBeacon.js delete mode 100644 esm/sendBeacon.js.map diff --git a/.gitignore b/.gitignore index 7fd4d7b..9455564 100644 --- a/.gitignore +++ b/.gitignore @@ -91,6 +91,10 @@ out .nuxt dist +# build artifacts (pnpm build / CI publish で生成。commit しない) +cjs/ +esm/ + # Gatsby files .cache/ # Comment in the public line in if your project uses Gatsby and not Next.js diff --git a/cjs/Cookie.d.ts b/cjs/Cookie.d.ts deleted file mode 100644 index 9baa686..0000000 --- a/cjs/Cookie.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -interface SetCookieOption { - path?: string; - domain?: string; - maxAge?: number; - expires?: Date; - secure?: boolean; - sameSite?: 'strict' | 'lax' | 'none'; -} -export declare function getCookie(key: string): string | null; -export declare function setCookie(key: string, value: string, options?: SetCookieOption): void; -export declare function deleteCookie(key: string, options?: { - path?: string; - domain?: string; - secure?: boolean; - sameSite?: 'strict' | 'lax' | 'none'; -}): void; -export declare function getCookieAs(key: string): T | null; -export declare function setCookieAs(key: string, value: T, options?: SetCookieOption): void; -export {}; diff --git a/cjs/Cookie.js b/cjs/Cookie.js deleted file mode 100644 index 9a8c7a2..0000000 --- a/cjs/Cookie.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getCookie = getCookie; -exports.setCookie = setCookie; -exports.deleteCookie = deleteCookie; -exports.getCookieAs = getCookieAs; -exports.setCookieAs = setCookieAs; -function getCookie(key) { - var keyPrefix = "".concat(key, "="); - var charCount = keyPrefix.length; - var cookieList = document.cookie.split('; '); - for (var i = 0, len = cookieList.length, keyAndValue = void 0; i < len; i++) { - keyAndValue = cookieList[i]; - if (keyAndValue.substr(0, charCount) === keyPrefix) { - return keyAndValue.slice(charCount); - } - } - return null; -} -function setCookie(key, value, options) { - if (options === void 0) { options = {}; } - var path = options.path, domain = options.domain, maxAge = options.maxAge, expires = options.expires, secure = options.secure, sameSite = options.sameSite; - var request = "".concat(key, "=").concat(value); - if (path) - request += ";path=".concat(path); - if (domain) - request += ";domain=".concat(domain); - if (typeof maxAge === 'number') - request += ";max-age=".concat(maxAge); - if (expires) - request += ";expires=".concat(expires.toUTCString()); - if (secure) - request += ';secure'; - if (sameSite) - request += ";samesite=".concat(sameSite); - document.cookie = request; -} -function deleteCookie(key, options) { - if (options === void 0) { options = {}; } - setCookie(key, '', { - maxAge: 0, - path: options.path, - domain: options.domain, - secure: options.secure, - sameSite: options.sameSite, - }); -} -function getCookieAs(key) { - var value = getCookie(key); - if (value) - return JSON.parse(decodeURIComponent(value)); - return null; -} -function setCookieAs(key, value, options) { - if (options === void 0) { options = {}; } - setCookie(key, encodeURIComponent(JSON.stringify(value)), options); -} -//# sourceMappingURL=Cookie.js.map \ No newline at end of file diff --git a/cjs/Cookie.js.map b/cjs/Cookie.js.map deleted file mode 100644 index da2ad39..0000000 --- a/cjs/Cookie.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Cookie.js","sourceRoot":"","sources":["../src/Cookie.ts"],"names":[],"mappings":";;AASA,8BAaC;AAED,8BAgBC;AAED,oCAgBC;AAED,kCAKC;AAED,kCAMC;AAhED,SAAgB,SAAS,CAAC,GAAW;IACnC,IAAM,SAAS,GAAG,UAAG,GAAG,MAAG,CAAC;IAC5B,IAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;IACnC,IAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,WAAW,SAAA,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACnE,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;YACnD,OAAO,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,SAAS,CACvB,GAAW,EACX,KAAa,EACb,OAA6B;IAA7B,wBAAA,EAAA,YAA6B;IAEtB,IAAA,IAAI,GAA+C,OAAO,KAAtD,EAAE,MAAM,GAAuC,OAAO,OAA9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,wBAAA,EAAA,YAA6B;IAE7B,SAAS,CAAC,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC"} \ No newline at end of file diff --git a/cjs/LocalStorage.d.ts b/cjs/LocalStorage.d.ts deleted file mode 100644 index fe83399..0000000 --- a/cjs/LocalStorage.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare function getItem(key: string): string | null; -export declare function setItem(key: string, value: string): void; -export declare function removeItem(key: string): void; -export declare function getValue(key: string): T | null; -export declare function setValue(key: string, value: T): void; diff --git a/cjs/LocalStorage.js b/cjs/LocalStorage.js deleted file mode 100644 index 8e15f06..0000000 --- a/cjs/LocalStorage.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getItem = getItem; -exports.setItem = setItem; -exports.removeItem = removeItem; -exports.getValue = getValue; -exports.setValue = setValue; -function getItem(key) { - if (localStorage) - return localStorage.getItem(key); - else - return null; -} -function setItem(key, value) { - try { - localStorage.setItem(key, value); - } - catch (e) { - console.error(e); - } -} -function removeItem(key) { - if (localStorage) - localStorage.removeItem(key); -} -function getValue(key) { - var value = getItem(key); - if (value) - return JSON.parse(value); - else - return null; -} -function setValue(key, value) { - setItem(key, JSON.stringify(value)); -} -//# sourceMappingURL=LocalStorage.js.map \ No newline at end of file diff --git a/cjs/LocalStorage.js.map b/cjs/LocalStorage.js.map deleted file mode 100644 index 24c1a49..0000000 --- a/cjs/LocalStorage.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"LocalStorage.js","sourceRoot":"","sources":["../src/LocalStorage.ts"],"names":[],"mappings":";;AAAA,0BAGC;AAED,0BAMC;AAED,gCAEC;AAED,4BAIC;AAED,4BAEC;AAzBD,SAAgB,OAAO,CAAC,GAAW;IACjC,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;QAC9C,OAAO,IAAI,CAAC;AACnB,CAAC;AAED,SAAgB,OAAO,CAAC,GAAW,EAAE,KAAa;IAChD,IAAI,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,GAAW;IACpC,IAAI,YAAY;QAAE,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC;AAED,SAAgB,QAAQ,CAAc,GAAW;IAC/C,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;;QACpC,OAAO,IAAI,CAAC;AACnB,CAAC;AAED,SAAgB,QAAQ,CAAc,GAAW,EAAE,KAAQ;IACzD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACtC,CAAC"} \ No newline at end of file diff --git a/cjs/SessionStorage.d.ts b/cjs/SessionStorage.d.ts deleted file mode 100644 index fe83399..0000000 --- a/cjs/SessionStorage.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare function getItem(key: string): string | null; -export declare function setItem(key: string, value: string): void; -export declare function removeItem(key: string): void; -export declare function getValue(key: string): T | null; -export declare function setValue(key: string, value: T): void; diff --git a/cjs/SessionStorage.js b/cjs/SessionStorage.js deleted file mode 100644 index 8b17157..0000000 --- a/cjs/SessionStorage.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getItem = getItem; -exports.setItem = setItem; -exports.removeItem = removeItem; -exports.getValue = getValue; -exports.setValue = setValue; -function getItem(key) { - if (sessionStorage) - return sessionStorage.getItem(key); - else - return null; -} -function setItem(key, value) { - try { - sessionStorage.setItem(key, value); - } - catch (e) { - console.error(e); - } -} -function removeItem(key) { - if (sessionStorage) - sessionStorage.removeItem(key); -} -function getValue(key) { - var value = getItem(key); - if (value) - return JSON.parse(value); - else - return null; -} -function setValue(key, value) { - setItem(key, JSON.stringify(value)); -} -//# sourceMappingURL=SessionStorage.js.map \ No newline at end of file diff --git a/cjs/SessionStorage.js.map b/cjs/SessionStorage.js.map deleted file mode 100644 index a99be63..0000000 --- a/cjs/SessionStorage.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"SessionStorage.js","sourceRoot":"","sources":["../src/SessionStorage.ts"],"names":[],"mappings":";;AAAA,0BAGC;AAED,0BAMC;AAED,gCAEC;AAED,4BAIC;AAED,4BAEC;AAzBD,SAAgB,OAAO,CAAC,GAAW;IACjC,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;QAClD,OAAO,IAAI,CAAC;AACnB,CAAC;AAED,SAAgB,OAAO,CAAC,GAAW,EAAE,KAAa;IAChD,IAAI,CAAC;QACH,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,GAAW;IACpC,IAAI,cAAc;QAAE,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,QAAQ,CAAc,GAAW;IAC/C,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;;QACpC,OAAO,IAAI,CAAC;AACnB,CAAC;AAED,SAAgB,QAAQ,CAAc,GAAW,EAAE,KAAQ;IACzD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACtC,CAAC"} \ No newline at end of file diff --git a/cjs/XHR.d.ts b/cjs/XHR.d.ts deleted file mode 100644 index 433c612..0000000 --- a/cjs/XHR.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -type HTTPMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'; -type LoadCallbackPayload = { - status: number; - statusText: string; - readyState: number; - response: Response; -}; -type LoadCallback = (payload: LoadCallbackPayload) => unknown; -type XHRRequestOptions = { - timeout?: number; - requestHeaders?: { - [key: string]: string | string[]; - }; - withCredentials?: boolean; - asynchronous?: boolean; - onLoadFailure?: LoadCallback; - onFailure?: (event: Event | LoadCallbackPayload) => unknown; - onError?: (event: Event) => unknown; - onTimeout?: (event: Event) => unknown; -}; -type XHRParams = { - url: string; - method: HTTPMethod; - responseType?: XMLHttpRequestResponseType; - body?: Document | XMLHttpRequestBodyInit | null; - onLoadSuccess?: LoadCallback; -} & XHRRequestOptions; -/** - * Sends a request using XMLHttpRequest - * @param params - withCredentials and asynchronous are true if not set. - * @throws Network errors may occur during the execution of the XMLHttpRequest. - * These errors do not result in the throwing of exceptions but can be - * handled with the `onFailure` callback parameter. - */ -export declare function xhrRequest(params: XHRParams): XMLHttpRequest; -/** - * Sends a GET request using XMLHttpRequest - * @param url - * @param onLoad - * @param xhrRequestOptions - */ -export declare function get(url: string, onLoadSuccess: (payload: LoadCallbackPayload) => unknown, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest and send the request with the GET method. - * Set the request header to `Accept: application/json`. - * The expected data type can be specified by generics. - * @param url - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export declare function getData(url: string, onLoadSuccess: (data: Response) => unknown, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest and send data with the POST method. - * @param url - * @param body - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export declare function post(url: string, body?: XMLHttpRequestBodyInit | null, onLoadSuccess?: LoadCallback, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest to send data in JSON format using the POST method. - * Set the request header to `Content-Type: application/json`. - * @param url - * @param data - * @param onLoadSuccess - * @param xhrRequestOptions - * @throws {TypeError} - */ -export declare function postDataAsJson, Response>(url: string, data: Request, onLoadSuccess?: LoadCallback, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest to send data in application/x-www-form-urlencoded format using the POST method. - * The request header is set to `Content-Type: application/x-www-form-urlencoded;charset=UTF-8`. - * @param url - * @param data - * @param onLoad - * @param xhrRequestOptions - */ -export declare function postDataAsXWwwFormUrlEncoded, Response>(url: string, data: RequestBody, onLoadSuccess?: LoadCallback, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest to send data in multipart/form-data format using the POST method. - * The request header is set to `Content-Type: multipart/form-data; boundary=... ` is set in the request header. - * @template RequestBody - extends Record - * @param url - * @param data - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export declare function postDataAsMultipartFormData, Response>(url: string, data: RequestBody, onLoadSuccess?: LoadCallback, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -export {}; diff --git a/cjs/XHR.js b/cjs/XHR.js deleted file mode 100644 index 07b7c4f..0000000 --- a/cjs/XHR.js +++ /dev/null @@ -1,166 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.xhrRequest = xhrRequest; -exports.get = get; -exports.getData = getData; -exports.post = post; -exports.postDataAsJson = postDataAsJson; -exports.postDataAsXWwwFormUrlEncoded = postDataAsXWwwFormUrlEncoded; -exports.postDataAsMultipartFormData = postDataAsMultipartFormData; -/** - * Sends a request using XMLHttpRequest - * @param params - withCredentials and asynchronous are true if not set. - * @throws Network errors may occur during the execution of the XMLHttpRequest. - * These errors do not result in the throwing of exceptions but can be - * handled with the `onFailure` callback parameter. - */ -function xhrRequest(params) { - var url = params.url, method = params.method, responseType = params.responseType, _a = params.body, body = _a === void 0 ? null : _a, onLoadSuccess = params.onLoadSuccess, onLoadFailure = params.onLoadFailure, onFailure = params.onFailure, onError = params.onError, onTimeout = params.onTimeout, timeout = params.timeout, requestHeaders = params.requestHeaders, _b = params.withCredentials, withCredentials = _b === void 0 ? true : _b, _c = params.asynchronous, asynchronous = _c === void 0 ? true : _c; - var xhr = new XMLHttpRequest(); - xhr.open(method, url, asynchronous); - xhr.withCredentials = withCredentials; - if (typeof timeout === 'number') - xhr.timeout = timeout; - if (typeof responseType === 'string') - xhr.responseType = responseType; - var _loop_1 = function (name_1) { - var content = requestHeaders[name_1]; - var list = typeof content === 'string' ? [content] : content; - list.forEach(function (value) { - xhr.setRequestHeader(name_1, value); - }); - }; - for (var name_1 in requestHeaders) { - _loop_1(name_1); - } - xhr.addEventListener('load', function () { - var status = xhr.status, statusText = xhr.statusText, readyState = xhr.readyState, response = xhr.response; - var loadCallbackPayload = { - status: status, - statusText: statusText, - readyState: readyState, - response: response, - }; - if (status >= 200 && status < 300 && readyState === 4) { - if (onLoadSuccess) - onLoadSuccess(loadCallbackPayload); - } - else { - if (onLoadFailure) - onLoadFailure(loadCallbackPayload); - if (onFailure) - onFailure(loadCallbackPayload); - } - }); - xhr.addEventListener('error', function (event) { - if (onFailure) - onFailure(event); - if (onError) - onError(event); - }); - xhr.addEventListener('timeout', function (event) { - if (onFailure) - onFailure(event); - if (onTimeout) - onTimeout(event); - }); - xhr.send(body); - return xhr; -} -/** - * Sends a GET request using XMLHttpRequest - * @param url - * @param onLoad - * @param xhrRequestOptions - */ -function get(url, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - return xhrRequest(__assign({ url: url, method: 'GET', onLoadSuccess: onLoadSuccess }, xhrRequestOptions)); -} -/** - * Use XMLHttpRequest and send the request with the GET method. - * Set the request header to `Accept: application/json`. - * The expected data type can be specified by generics. - * @param url - * @param onLoadSuccess - * @param xhrRequestOptions - */ -function getData(url, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - return xhrRequest(__assign(__assign({ url: url, method: 'GET', responseType: 'json', onLoadSuccess: function (callbackPayload) { - var data = callbackPayload.response; - onLoadSuccess(data); - } }, xhrRequestOptions), { requestHeaders: __assign(__assign({}, xhrRequestOptions.requestHeaders), { Accept: 'application/json' }) })); -} -/** - * Use XMLHttpRequest and send data with the POST method. - * @param url - * @param body - * @param onLoadSuccess - * @param xhrRequestOptions - */ -function post(url, body, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - // If body is a string type, the request header is set to `Content-Type: text/plain;charset=UTF-8`. - return xhrRequest(__assign({ url: url, method: 'POST', body: body, onLoadSuccess: onLoadSuccess }, xhrRequestOptions)); -} -/** - * Use XMLHttpRequest to send data in JSON format using the POST method. - * Set the request header to `Content-Type: application/json`. - * @param url - * @param data - * @param onLoadSuccess - * @param xhrRequestOptions - * @throws {TypeError} - */ -function postDataAsJson(url, data, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - return post(url, JSON.stringify(data), onLoadSuccess, __assign({ requestHeaders: __assign(__assign({}, xhrRequestOptions.requestHeaders), { 'Content-Type': 'application/json' }) }, xhrRequestOptions)); -} -/** - * Use XMLHttpRequest to send data in application/x-www-form-urlencoded format using the POST method. - * The request header is set to `Content-Type: application/x-www-form-urlencoded;charset=UTF-8`. - * @param url - * @param data - * @param onLoad - * @param xhrRequestOptions - */ -function postDataAsXWwwFormUrlEncoded(url, data, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - var urlSearchParams = new URLSearchParams(); - for (var name_2 in data) { - urlSearchParams.append(name_2, String(data[name_2])); - } - // If the URLSearchParams type is set in body, the request header is set to `Content-Type: application/x-www-form-urlencoded;charset=UTF-8`. - return post(url, urlSearchParams, onLoadSuccess, xhrRequestOptions); -} -/** - * Use XMLHttpRequest to send data in multipart/form-data format using the POST method. - * The request header is set to `Content-Type: multipart/form-data; boundary=... ` is set in the request header. - * @template RequestBody - extends Record - * @param url - * @param data - * @param onLoadSuccess - * @param xhrRequestOptions - */ -function postDataAsMultipartFormData(url, data, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - var formData = new FormData(); - for (var name_3 in data) { - formData.append(name_3, data[name_3]); - } - // If the body is set to the FormData type, the request header is set to `Content-Type: multipart/form-data; boundary=... ` is set in the request header. - return post(url, formData, onLoadSuccess, xhrRequestOptions); -} -//# sourceMappingURL=XHR.js.map \ No newline at end of file diff --git a/cjs/XHR.js.map b/cjs/XHR.js.map deleted file mode 100644 index d6d0798..0000000 --- a/cjs/XHR.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"XHR.js","sourceRoot":"","sources":["../src/XHR.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAgDA,gCA6DC;AAQD,kBAWC;AAUD,0BAmBC;AASD,oBAcC;AAWD,wCAgBC;AAUD,oEAgBC;AAWD,kEAgBC;AA3ND;;;;;;GAMG;AACH,SAAgB,UAAU,CAAW,MAA2B;IAE5D,IAAA,GAAG,GAaD,MAAM,IAbL,EACH,MAAM,GAYJ,MAAM,OAZF,EACN,YAAY,GAWV,MAAM,aAXI,EACZ,KAUE,MAAM,KAVG,EAAX,IAAI,mBAAG,IAAI,KAAA,EACX,aAAa,GASX,MAAM,cATK,EACb,aAAa,GAQX,MAAM,cARK,EACb,SAAS,GAOP,MAAM,UAPC,EACT,OAAO,GAML,MAAM,QAND,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AnD,kCAAA,EAAA,sBAAmD;IAEnD,IAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,KAAK,IAAM,MAAI,IAAI,IAAI,EAAE,CAAC;QACxB,QAAQ,CAAC,MAAM,CAAC,MAAI,EAAE,IAAI,CAAC,MAAI,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,yJAAyJ;IACzJ,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;AAC/D,CAAC"} \ No newline at end of file diff --git a/cjs/index.d.ts b/cjs/index.d.ts deleted file mode 100644 index c56d718..0000000 --- a/cjs/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * as Cookie from './Cookie'; -export * as LocalStorage from './LocalStorage'; -export * as SessionStorage from './SessionStorage'; -export * as XHR from './XHR'; -export * as sendBeacon from './sendBeacon'; diff --git a/cjs/index.js b/cjs/index.js deleted file mode 100644 index ebbd0e6..0000000 --- a/cjs/index.js +++ /dev/null @@ -1,42 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.sendBeacon = exports.XHR = exports.SessionStorage = exports.LocalStorage = exports.Cookie = void 0; -exports.Cookie = __importStar(require("./Cookie")); -exports.LocalStorage = __importStar(require("./LocalStorage")); -exports.SessionStorage = __importStar(require("./SessionStorage")); -exports.XHR = __importStar(require("./XHR")); -exports.sendBeacon = __importStar(require("./sendBeacon")); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/cjs/index.js.map b/cjs/index.js.map deleted file mode 100644 index ddd28e6..0000000 --- a/cjs/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAmC;AACnC,+DAA+C;AAC/C,mEAAmD;AACnD,6CAA6B;AAC7B,2DAA2C"} \ No newline at end of file diff --git a/cjs/sendBeacon.d.ts b/cjs/sendBeacon.d.ts deleted file mode 100644 index 78f6d77..0000000 --- a/cjs/sendBeacon.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -type Body = Blob | string | FormData | URLSearchParams; -/** - * Call navigator.sendBeacon, fallback to XHR for legacy browsers. - * @param url - * @param body Blob types are sent as text/plain for stirng, multipart/form-data for FormData, and application/x-www-form-urlencoded for URLSearchParams, depending on their type. - */ -export declare function sendBeacon(url: string, body?: Body): boolean; -type AnyObjects = Record; -/** - * Convert data to URLSearchParams, execute sendBeacon function, and send data as application/x-www-form-urlencoded. - * @param url - * @param data - */ -export declare function sendBeaconAsXWwwUrlEncoded(url: string, data: T): boolean; -/** - * Convert data to FormData, execute sendBeacon function, and send data as multipart/form-data. - * @param url - * @param data - */ -export declare function sendBeaconAsMultipartFormData(url: string, data: T): boolean; -/** - * Convert the data to JSON.stringify and Blob, execute the sendBeacon function, and send the data as application/json. - * @param url - * @param data - */ -export declare function sendBeaconAsJson(url: string, data: T): boolean; -export {}; diff --git a/cjs/sendBeacon.js b/cjs/sendBeacon.js deleted file mode 100644 index 666e907..0000000 --- a/cjs/sendBeacon.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.sendBeacon = sendBeacon; -exports.sendBeaconAsXWwwUrlEncoded = sendBeaconAsXWwwUrlEncoded; -exports.sendBeaconAsMultipartFormData = sendBeaconAsMultipartFormData; -exports.sendBeaconAsJson = sendBeaconAsJson; -var XHR_1 = require("./XHR"); -/** - * Call navigator.sendBeacon, fallback to XHR for legacy browsers. - * @param url - * @param body Blob types are sent as text/plain for stirng, multipart/form-data for FormData, and application/x-www-form-urlencoded for URLSearchParams, depending on their type. - */ -function sendBeacon(url, body) { - if (navigator.sendBeacon) { - return navigator.sendBeacon(url, body); - } - else { - try { - (0, XHR_1.post)(url, body, void 0, { asynchronous: true, withCredentials: true }); - return true; - } - catch (_a) { - return false; - } - } -} -/** - * Convert data to URLSearchParams, execute sendBeacon function, and send data as application/x-www-form-urlencoded. - * @param url - * @param data - */ -function sendBeaconAsXWwwUrlEncoded(url, data) { - var urlSearchParams = new URLSearchParams(); - for (var name_1 in data) { - urlSearchParams.append(name_1, String(data[name_1])); - } - return sendBeacon(url, urlSearchParams); -} -/** - * Convert data to FormData, execute sendBeacon function, and send data as multipart/form-data. - * @param url - * @param data - */ -function sendBeaconAsMultipartFormData(url, data) { - var formData = new FormData(); - for (var name_2 in data) { - formData.append(name_2, String(data[name_2])); - } - return sendBeacon(url, formData); -} -/** - * Convert the data to JSON.stringify and Blob, execute the sendBeacon function, and send the data as application/json. - * @param url - * @param data - */ -function sendBeaconAsJson(url, data) { - var blob = new Blob([JSON.stringify(data)], { type: 'application/json' }); - return sendBeacon(url, blob); -} -//# sourceMappingURL=sendBeacon.js.map \ No newline at end of file diff --git a/cjs/sendBeacon.js.map b/cjs/sendBeacon.js.map deleted file mode 100644 index 7467987..0000000 --- a/cjs/sendBeacon.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"sendBeacon.js","sourceRoot":"","sources":["../src/sendBeacon.ts"],"names":[],"mappings":";;AASA,gCAWC;AASD,gEAUC;AAOD,sEAUC;AAOD,4CAGC;AAlED,6BAA2B;AAI3B;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAW,EAAE,IAAW;IACjD,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,IAAI,CAAC;YACH,IAAA,UAAI,EAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC;YACrE,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC;AAID;;;;GAIG;AACH,SAAgB,0BAA0B,CACxC,GAAW,EACX,IAAO;IAEP,IAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC9C,KAAK,IAAM,MAAI,IAAI,IAAI,EAAE,CAAC;QACxB,eAAe,CAAC,MAAM,CAAC,MAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,UAAU,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,SAAgB,6BAA6B,CAC3C,GAAW,EACX,IAAO;IAEP,IAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,KAAK,IAAM,MAAI,IAAI,IAAI,EAAE,CAAC;QACxB,QAAQ,CAAC,MAAM,CAAC,MAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAI,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAuB,GAAW,EAAE,IAAO;IACzE,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC,CAAC;IAC1E,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC"} \ No newline at end of file diff --git a/esm/Cookie.d.ts b/esm/Cookie.d.ts deleted file mode 100644 index 9baa686..0000000 --- a/esm/Cookie.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -interface SetCookieOption { - path?: string; - domain?: string; - maxAge?: number; - expires?: Date; - secure?: boolean; - sameSite?: 'strict' | 'lax' | 'none'; -} -export declare function getCookie(key: string): string | null; -export declare function setCookie(key: string, value: string, options?: SetCookieOption): void; -export declare function deleteCookie(key: string, options?: { - path?: string; - domain?: string; - secure?: boolean; - sameSite?: 'strict' | 'lax' | 'none'; -}): void; -export declare function getCookieAs(key: string): T | null; -export declare function setCookieAs(key: string, value: T, options?: SetCookieOption): void; -export {}; diff --git a/esm/Cookie.js b/esm/Cookie.js deleted file mode 100644 index ff6cfcb..0000000 --- a/esm/Cookie.js +++ /dev/null @@ -1,51 +0,0 @@ -export function getCookie(key) { - var keyPrefix = "".concat(key, "="); - var charCount = keyPrefix.length; - var cookieList = document.cookie.split('; '); - for (var i = 0, len = cookieList.length, keyAndValue = void 0; i < len; i++) { - keyAndValue = cookieList[i]; - if (keyAndValue.substr(0, charCount) === keyPrefix) { - return keyAndValue.slice(charCount); - } - } - return null; -} -export function setCookie(key, value, options) { - if (options === void 0) { options = {}; } - var path = options.path, domain = options.domain, maxAge = options.maxAge, expires = options.expires, secure = options.secure, sameSite = options.sameSite; - var request = "".concat(key, "=").concat(value); - if (path) - request += ";path=".concat(path); - if (domain) - request += ";domain=".concat(domain); - if (typeof maxAge === 'number') - request += ";max-age=".concat(maxAge); - if (expires) - request += ";expires=".concat(expires.toUTCString()); - if (secure) - request += ';secure'; - if (sameSite) - request += ";samesite=".concat(sameSite); - document.cookie = request; -} -export function deleteCookie(key, options) { - if (options === void 0) { options = {}; } - setCookie(key, '', { - maxAge: 0, - path: options.path, - domain: options.domain, - secure: options.secure, - sameSite: options.sameSite, - }); -} -export function getCookieAs(key) { - var value = getCookie(key); - if (value) - return JSON.parse(decodeURIComponent(value)); - return null; -} -export function setCookieAs(key, value, options) { - if (options === void 0) { options = {}; } - setCookie(key, encodeURIComponent(JSON.stringify(value)), options); -} -//# sourceMappingURL=Cookie.js.map \ No newline at end of file diff --git a/esm/Cookie.js.map b/esm/Cookie.js.map deleted file mode 100644 index 0e2dc67..0000000 --- a/esm/Cookie.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Cookie.js","sourceRoot":"","sources":["../src/Cookie.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,IAAM,SAAS,GAAG,UAAG,GAAG,MAAG,CAAC;IAC5B,IAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;IACnC,IAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,WAAW,SAAA,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACnE,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;YACnD,OAAO,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,IA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B,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAM,CAAC;IAC7D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,GAAW,EACX,KAAQ,EACR,OAA6B;IAA7B,wBAAA,EAAA,YAA6B;IAE7B,SAAS,CAAC,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC"} \ No newline at end of file diff --git a/esm/LocalStorage.d.ts b/esm/LocalStorage.d.ts deleted file mode 100644 index fe83399..0000000 --- a/esm/LocalStorage.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare function getItem(key: string): string | null; -export declare function setItem(key: string, value: string): void; -export declare function removeItem(key: string): void; -export declare function getValue(key: string): T | null; -export declare function setValue(key: string, value: T): void; diff --git a/esm/LocalStorage.js b/esm/LocalStorage.js deleted file mode 100644 index 49df307..0000000 --- a/esm/LocalStorage.js +++ /dev/null @@ -1,29 +0,0 @@ -export function getItem(key) { - if (localStorage) - return localStorage.getItem(key); - else - return null; -} -export function setItem(key, value) { - try { - localStorage.setItem(key, value); - } - catch (e) { - console.error(e); - } -} -export function removeItem(key) { - if (localStorage) - localStorage.removeItem(key); -} -export function getValue(key) { - var value = getItem(key); - if (value) - return JSON.parse(value); - else - return null; -} -export function setValue(key, value) { - setItem(key, JSON.stringify(value)); -} -//# sourceMappingURL=LocalStorage.js.map \ No newline at end of file diff --git a/esm/LocalStorage.js.map b/esm/LocalStorage.js.map deleted file mode 100644 index a526d1b..0000000 --- a/esm/LocalStorage.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"LocalStorage.js","sourceRoot":"","sources":["../src/LocalStorage.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;QAC9C,OAAO,IAAI,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,KAAa;IAChD,IAAI,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,YAAY;QAAE,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAc,GAAW;IAC/C,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;;QACpC,OAAO,IAAI,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAc,GAAW,EAAE,KAAQ;IACzD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACtC,CAAC"} \ No newline at end of file diff --git a/esm/SessionStorage.d.ts b/esm/SessionStorage.d.ts deleted file mode 100644 index fe83399..0000000 --- a/esm/SessionStorage.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare function getItem(key: string): string | null; -export declare function setItem(key: string, value: string): void; -export declare function removeItem(key: string): void; -export declare function getValue(key: string): T | null; -export declare function setValue(key: string, value: T): void; diff --git a/esm/SessionStorage.js b/esm/SessionStorage.js deleted file mode 100644 index 47b25a9..0000000 --- a/esm/SessionStorage.js +++ /dev/null @@ -1,29 +0,0 @@ -export function getItem(key) { - if (sessionStorage) - return sessionStorage.getItem(key); - else - return null; -} -export function setItem(key, value) { - try { - sessionStorage.setItem(key, value); - } - catch (e) { - console.error(e); - } -} -export function removeItem(key) { - if (sessionStorage) - sessionStorage.removeItem(key); -} -export function getValue(key) { - var value = getItem(key); - if (value) - return JSON.parse(value); - else - return null; -} -export function setValue(key, value) { - setItem(key, JSON.stringify(value)); -} -//# sourceMappingURL=SessionStorage.js.map \ No newline at end of file diff --git a/esm/SessionStorage.js.map b/esm/SessionStorage.js.map deleted file mode 100644 index 8b1e874..0000000 --- a/esm/SessionStorage.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"SessionStorage.js","sourceRoot":"","sources":["../src/SessionStorage.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;QAClD,OAAO,IAAI,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,KAAa;IAChD,IAAI,CAAC;QACH,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,cAAc;QAAE,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAc,GAAW;IAC/C,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;;QACpC,OAAO,IAAI,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAc,GAAW,EAAE,KAAQ;IACzD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACtC,CAAC"} \ No newline at end of file diff --git a/esm/XHR.d.ts b/esm/XHR.d.ts deleted file mode 100644 index 433c612..0000000 --- a/esm/XHR.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -type HTTPMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'; -type LoadCallbackPayload = { - status: number; - statusText: string; - readyState: number; - response: Response; -}; -type LoadCallback = (payload: LoadCallbackPayload) => unknown; -type XHRRequestOptions = { - timeout?: number; - requestHeaders?: { - [key: string]: string | string[]; - }; - withCredentials?: boolean; - asynchronous?: boolean; - onLoadFailure?: LoadCallback; - onFailure?: (event: Event | LoadCallbackPayload) => unknown; - onError?: (event: Event) => unknown; - onTimeout?: (event: Event) => unknown; -}; -type XHRParams = { - url: string; - method: HTTPMethod; - responseType?: XMLHttpRequestResponseType; - body?: Document | XMLHttpRequestBodyInit | null; - onLoadSuccess?: LoadCallback; -} & XHRRequestOptions; -/** - * Sends a request using XMLHttpRequest - * @param params - withCredentials and asynchronous are true if not set. - * @throws Network errors may occur during the execution of the XMLHttpRequest. - * These errors do not result in the throwing of exceptions but can be - * handled with the `onFailure` callback parameter. - */ -export declare function xhrRequest(params: XHRParams): XMLHttpRequest; -/** - * Sends a GET request using XMLHttpRequest - * @param url - * @param onLoad - * @param xhrRequestOptions - */ -export declare function get(url: string, onLoadSuccess: (payload: LoadCallbackPayload) => unknown, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest and send the request with the GET method. - * Set the request header to `Accept: application/json`. - * The expected data type can be specified by generics. - * @param url - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export declare function getData(url: string, onLoadSuccess: (data: Response) => unknown, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest and send data with the POST method. - * @param url - * @param body - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export declare function post(url: string, body?: XMLHttpRequestBodyInit | null, onLoadSuccess?: LoadCallback, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest to send data in JSON format using the POST method. - * Set the request header to `Content-Type: application/json`. - * @param url - * @param data - * @param onLoadSuccess - * @param xhrRequestOptions - * @throws {TypeError} - */ -export declare function postDataAsJson, Response>(url: string, data: Request, onLoadSuccess?: LoadCallback, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest to send data in application/x-www-form-urlencoded format using the POST method. - * The request header is set to `Content-Type: application/x-www-form-urlencoded;charset=UTF-8`. - * @param url - * @param data - * @param onLoad - * @param xhrRequestOptions - */ -export declare function postDataAsXWwwFormUrlEncoded, Response>(url: string, data: RequestBody, onLoadSuccess?: LoadCallback, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -/** - * Use XMLHttpRequest to send data in multipart/form-data format using the POST method. - * The request header is set to `Content-Type: multipart/form-data; boundary=... ` is set in the request header. - * @template RequestBody - extends Record - * @param url - * @param data - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export declare function postDataAsMultipartFormData, Response>(url: string, data: RequestBody, onLoadSuccess?: LoadCallback, xhrRequestOptions?: XHRRequestOptions): XMLHttpRequest; -export {}; diff --git a/esm/XHR.js b/esm/XHR.js deleted file mode 100644 index e2645cc..0000000 --- a/esm/XHR.js +++ /dev/null @@ -1,157 +0,0 @@ -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -/** - * Sends a request using XMLHttpRequest - * @param params - withCredentials and asynchronous are true if not set. - * @throws Network errors may occur during the execution of the XMLHttpRequest. - * These errors do not result in the throwing of exceptions but can be - * handled with the `onFailure` callback parameter. - */ -export function xhrRequest(params) { - var url = params.url, method = params.method, responseType = params.responseType, _a = params.body, body = _a === void 0 ? null : _a, onLoadSuccess = params.onLoadSuccess, onLoadFailure = params.onLoadFailure, onFailure = params.onFailure, onError = params.onError, onTimeout = params.onTimeout, timeout = params.timeout, requestHeaders = params.requestHeaders, _b = params.withCredentials, withCredentials = _b === void 0 ? true : _b, _c = params.asynchronous, asynchronous = _c === void 0 ? true : _c; - var xhr = new XMLHttpRequest(); - xhr.open(method, url, asynchronous); - xhr.withCredentials = withCredentials; - if (typeof timeout === 'number') - xhr.timeout = timeout; - if (typeof responseType === 'string') - xhr.responseType = responseType; - var _loop_1 = function (name_1) { - var content = requestHeaders[name_1]; - var list = typeof content === 'string' ? [content] : content; - list.forEach(function (value) { - xhr.setRequestHeader(name_1, value); - }); - }; - for (var name_1 in requestHeaders) { - _loop_1(name_1); - } - xhr.addEventListener('load', function () { - var status = xhr.status, statusText = xhr.statusText, readyState = xhr.readyState, response = xhr.response; - var loadCallbackPayload = { - status: status, - statusText: statusText, - readyState: readyState, - response: response, - }; - if (status >= 200 && status < 300 && readyState === 4) { - if (onLoadSuccess) - onLoadSuccess(loadCallbackPayload); - } - else { - if (onLoadFailure) - onLoadFailure(loadCallbackPayload); - if (onFailure) - onFailure(loadCallbackPayload); - } - }); - xhr.addEventListener('error', function (event) { - if (onFailure) - onFailure(event); - if (onError) - onError(event); - }); - xhr.addEventListener('timeout', function (event) { - if (onFailure) - onFailure(event); - if (onTimeout) - onTimeout(event); - }); - xhr.send(body); - return xhr; -} -/** - * Sends a GET request using XMLHttpRequest - * @param url - * @param onLoad - * @param xhrRequestOptions - */ -export function get(url, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - return xhrRequest(__assign({ url: url, method: 'GET', onLoadSuccess: onLoadSuccess }, xhrRequestOptions)); -} -/** - * Use XMLHttpRequest and send the request with the GET method. - * Set the request header to `Accept: application/json`. - * The expected data type can be specified by generics. - * @param url - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export function getData(url, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - return xhrRequest(__assign(__assign({ url: url, method: 'GET', responseType: 'json', onLoadSuccess: function (callbackPayload) { - var data = callbackPayload.response; - onLoadSuccess(data); - } }, xhrRequestOptions), { requestHeaders: __assign(__assign({}, xhrRequestOptions.requestHeaders), { Accept: 'application/json' }) })); -} -/** - * Use XMLHttpRequest and send data with the POST method. - * @param url - * @param body - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export function post(url, body, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - // If body is a string type, the request header is set to `Content-Type: text/plain;charset=UTF-8`. - return xhrRequest(__assign({ url: url, method: 'POST', body: body, onLoadSuccess: onLoadSuccess }, xhrRequestOptions)); -} -/** - * Use XMLHttpRequest to send data in JSON format using the POST method. - * Set the request header to `Content-Type: application/json`. - * @param url - * @param data - * @param onLoadSuccess - * @param xhrRequestOptions - * @throws {TypeError} - */ -export function postDataAsJson(url, data, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - return post(url, JSON.stringify(data), onLoadSuccess, __assign({ requestHeaders: __assign(__assign({}, xhrRequestOptions.requestHeaders), { 'Content-Type': 'application/json' }) }, xhrRequestOptions)); -} -/** - * Use XMLHttpRequest to send data in application/x-www-form-urlencoded format using the POST method. - * The request header is set to `Content-Type: application/x-www-form-urlencoded;charset=UTF-8`. - * @param url - * @param data - * @param onLoad - * @param xhrRequestOptions - */ -export function postDataAsXWwwFormUrlEncoded(url, data, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - var urlSearchParams = new URLSearchParams(); - for (var name_2 in data) { - urlSearchParams.append(name_2, String(data[name_2])); - } - // If the URLSearchParams type is set in body, the request header is set to `Content-Type: application/x-www-form-urlencoded;charset=UTF-8`. - return post(url, urlSearchParams, onLoadSuccess, xhrRequestOptions); -} -/** - * Use XMLHttpRequest to send data in multipart/form-data format using the POST method. - * The request header is set to `Content-Type: multipart/form-data; boundary=... ` is set in the request header. - * @template RequestBody - extends Record - * @param url - * @param data - * @param onLoadSuccess - * @param xhrRequestOptions - */ -export function postDataAsMultipartFormData(url, data, onLoadSuccess, xhrRequestOptions) { - if (xhrRequestOptions === void 0) { xhrRequestOptions = {}; } - var formData = new FormData(); - for (var name_3 in data) { - formData.append(name_3, data[name_3]); - } - // If the body is set to the FormData type, the request header is set to `Content-Type: multipart/form-data; boundary=... ` is set in the request header. - return post(url, formData, onLoadSuccess, xhrRequestOptions); -} -//# sourceMappingURL=XHR.js.map \ No newline at end of file diff --git a/esm/XHR.js.map b/esm/XHR.js.map deleted file mode 100644 index ebf73d5..0000000 --- a/esm/XHR.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"XHR.js","sourceRoot":"","sources":["../src/XHR.ts"],"names":[],"mappings":";;;;;;;;;;;AAyCA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAW,MAA2B;IAE5D,IAAA,GAAG,GAaD,MAAM,IAbL,EACH,MAAM,GAYJ,MAAM,OAZF,EACN,YAAY,GAWV,MAAM,aAXI,EACZ,KAUE,MAAM,KAVG,EAAX,IAAI,mBAAG,IAAI,KAAA,EACX,aAAa,GASX,MAAM,cATK,EACb,aAAa,GAQX,MAAM,cARK,EACb,SAAS,GAOP,MAAM,UAPC,EACT,OAAO,GAML,MAAM,QAND,EACP,SAAS,GAKP,MAAM,UALC,EACT,OAAO,GAIL,MAAM,QAJD,EACP,cAAc,GAGZ,MAAM,eAHM,EACd,KAEE,MAAM,gBAFc,EAAtB,eAAe,mBAAG,IAAI,KAAA,EACtB,KACE,MAAM,aADW,EAAnB,YAAY,mBAAG,IAAI,KAAA,CACV;IAEX,IAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;IACjC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAEpC,GAAG,CAAC,eAAe,GAAG,eAAe,CAAC;IACtC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,GAAG,CAAC,OAAO,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a/esm/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * as Cookie from './Cookie'; -export * as LocalStorage from './LocalStorage'; -export * as SessionStorage from './SessionStorage'; -export * as XHR from './XHR'; -export * as sendBeacon from './sendBeacon'; diff --git a/esm/index.js b/esm/index.js deleted file mode 100644 index 6e519f4..0000000 --- a/esm/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import * as Cookie_1 from './Cookie'; -export { Cookie_1 as Cookie }; -import * as LocalStorage_1 from './LocalStorage'; -export { LocalStorage_1 as LocalStorage }; -import * as SessionStorage_1 from './SessionStorage'; -export { SessionStorage_1 as SessionStorage }; -import * as XHR_1 from './XHR'; -export { XHR_1 as XHR }; -import * as sendBeacon_1 from './sendBeacon'; -export { sendBeacon_1 as sendBeacon }; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/esm/index.js.map b/esm/index.js.map deleted file mode 100644 index 6655cf0..0000000 --- a/esm/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"0BAAwB,UAAU;qBAAtB,MAAM;gCACY,gBAAgB;2BAAlC,YAAY;kCACQ,kBAAkB;6BAAtC,cAAc;uBACL,OAAO;kBAAhB,GAAG;8BACa,cAAc;yBAA9B,UAAU"} \ No newline at end of file diff --git a/esm/sendBeacon.d.ts b/esm/sendBeacon.d.ts deleted file mode 100644 index 78f6d77..0000000 --- a/esm/sendBeacon.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -type Body = Blob | string | FormData | URLSearchParams; -/** - * Call navigator.sendBeacon, fallback to XHR for legacy browsers. - * @param url - * @param body Blob types are sent as text/plain for stirng, multipart/form-data for FormData, and application/x-www-form-urlencoded for URLSearchParams, depending on their type. - */ -export declare function sendBeacon(url: string, body?: Body): boolean; -type AnyObjects = Record; -/** - * Convert data to URLSearchParams, execute sendBeacon function, and send data as application/x-www-form-urlencoded. - * @param url - * @param data - */ -export declare function sendBeaconAsXWwwUrlEncoded(url: string, data: T): boolean; -/** - * Convert data to FormData, execute sendBeacon function, and send data as multipart/form-data. - * @param url - * @param data - */ -export declare function sendBeaconAsMultipartFormData(url: string, data: T): boolean; -/** - * Convert the data to JSON.stringify and Blob, execute the sendBeacon function, and send the data as application/json. - * @param url - * @param data - */ -export declare function sendBeaconAsJson(url: string, data: T): boolean; -export {}; diff --git a/esm/sendBeacon.js b/esm/sendBeacon.js deleted file mode 100644 index 30c1640..0000000 --- a/esm/sendBeacon.js +++ /dev/null @@ -1,54 +0,0 @@ -import { post } from './XHR'; -/** - * Call navigator.sendBeacon, fallback to XHR for legacy browsers. - * @param url - * @param body Blob types are sent as text/plain for stirng, multipart/form-data for FormData, and application/x-www-form-urlencoded for URLSearchParams, depending on their type. - */ -export function sendBeacon(url, body) { - if (navigator.sendBeacon) { - return navigator.sendBeacon(url, body); - } - else { - try { - post(url, body, void 0, { asynchronous: true, withCredentials: true }); - return true; - } - catch (_a) { - return false; - } - } -} -/** - * Convert data to URLSearchParams, execute sendBeacon function, and send data as application/x-www-form-urlencoded. - * @param url - * @param data - */ -export function sendBeaconAsXWwwUrlEncoded(url, data) { - var urlSearchParams = new URLSearchParams(); - for (var name_1 in data) { - urlSearchParams.append(name_1, String(data[name_1])); - } - return sendBeacon(url, urlSearchParams); -} -/** - * Convert data to FormData, execute sendBeacon function, and send data as multipart/form-data. - * @param url - * @param data - */ -export function sendBeaconAsMultipartFormData(url, data) { - var formData = new FormData(); - for (var name_2 in data) { - formData.append(name_2, String(data[name_2])); - } - return sendBeacon(url, formData); -} -/** - * Convert the data to JSON.stringify and Blob, execute the sendBeacon function, and send the data as application/json. - * @param url - * @param data - */ -export function sendBeaconAsJson(url, data) { - var blob = new Blob([JSON.stringify(data)], { type: 'application/json' }); - return sendBeacon(url, blob); -} -//# sourceMappingURL=sendBeacon.js.map \ No newline at end of file diff --git a/esm/sendBeacon.js.map b/esm/sendBeacon.js.map deleted file mode 100644 index 9b83ace..0000000 --- a/esm/sendBe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