aptechka 0.94.4 → 0.94.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _CookiesClient=class _CookiesClient{static set(name,value,options={}){const encodedValue=encodeURIComponent(value);let cookieStr=`${name}=${encodedValue}`;if(options.maxAge){const expires=new Date(Date.now()+options.maxAge*1e3);cookieStr+=`; Expires=${expires.toUTCString()}`,cookieStr+=`; Max-Age=${options.maxAge}`}else options.expires&&(cookieStr+=`; Expires=${options.expires.toUTCString()}`);options.path&&(cookieStr+=`; Path=${options.path}`),options.domain&&(cookieStr+=`; Domain=${options.domain}`),options.secure&&(cookieStr+="; Secure"),options.sameSite&&(cookieStr+=`; SameSite=${options.sameSite}`),document.cookie=cookieStr}static has(name){const cookies=document.cookie.split("; ");for(const cookie of cookies){const[cookieName,cookieValue]=cookie.split("=");if(cookieName===name)return!0}return!1}static get(name){const cookies=document.cookie.split("; ");for(const cookie of cookies){const[cookieName,cookieValue]=cookie.split("=");if(cookieName===name)return decodeURIComponent(cookieValue)}return null}static getAll(){return document.cookie.split("; ").reduce((cookies,cookie)=>{const[name,value]=cookie.split("=");return name&&(cookies[name]=decodeURIComponent(value)),cookies},{})}static remove(name,options={}){this.set(name,"",__spreadProps(__spreadValues({},options),{maxAge:-1}))}static serialize(name,value,options={}){const encodedValue=encodeURIComponent(value);let cookieStr=`${name}=${encodedValue}`;if(options.maxAge){const expires=new Date(Date.now()+options.maxAge*1e3);cookieStr+=`; Expires=${expires.toUTCString()}`,cookieStr+=`; Max-Age=${options.maxAge}`}else options.expires&&(cookieStr+=`; Expires=${options.expires.toUTCString()}`);return options.path&&(cookieStr+=`; Path=${options.path}`),options.domain&&(cookieStr+=`; Domain=${options.domain}`),options.secure&&(cookieStr+="; Secure"),options.sameSite&&(cookieStr+=`; SameSite=${options.sameSite}`),cookieStr}};__name(_CookiesClient,"CookiesClient");let CookiesClient=_CookiesClient;exports.CookiesClient=CookiesClient;
1
+ "use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _CookiesClient=class _CookiesClient{static set(name,value,options={}){const encodedValue=encodeURIComponent(value);let cookieStr=`${name}=${encodedValue}`;if(options.maxAge!==void 0)if(options.maxAge<=0)cookieStr+=`; Expires=${new Date(0).toUTCString()}`,cookieStr+="; Max-Age=0";else{const expires=new Date(Date.now()+options.maxAge*1e3);cookieStr+=`; Expires=${expires.toUTCString()}`,cookieStr+=`; Max-Age=${options.maxAge}`}else options.expires&&(cookieStr+=`; Expires=${options.expires.toUTCString()}`);options.path&&(cookieStr+=`; Path=${options.path}`),options.domain&&(cookieStr+=`; Domain=${options.domain}`),options.secure&&(cookieStr+="; Secure"),options.sameSite&&(cookieStr+=`; SameSite=${options.sameSite}`),document.cookie=cookieStr}static has(name){const cookies=document.cookie.split("; ");for(const cookie of cookies){const[cookieName,cookieValue]=cookie.split("=");if(cookieName===name)return!0}return!1}static get(name){const cookies=document.cookie.split("; ");for(const cookie of cookies){const[cookieName,cookieValue]=cookie.split("=");if(cookieName===name)return decodeURIComponent(cookieValue)}return null}static getAll(){return document.cookie.split("; ").reduce((cookies,cookie)=>{const[name,value]=cookie.split("=");return name&&(cookies[name]=decodeURIComponent(value)),cookies},{})}static remove(name,options={}){const domains=options.domain?[options.domain,`.${options.domain}`]:[""],paths=options.path?[options.path,"/"]:["","/"];for(const domain of domains)for(const path of paths)document.cookie=[`${name}=`,"Expires=Thu, 01 Jan 1970 00:00:00 GMT","Max-Age=0",path?`Path=${path}`:"",domain?`Domain=${domain}`:""].filter(Boolean).join("; ")}static serialize(name,value,options={}){const encodedValue=encodeURIComponent(value);let cookieStr=`${name}=${encodedValue}`;if(options.maxAge){const expires=new Date(Date.now()+options.maxAge*1e3);cookieStr+=`; Expires=${expires.toUTCString()}`,cookieStr+=`; Max-Age=${options.maxAge}`}else options.expires&&(cookieStr+=`; Expires=${options.expires.toUTCString()}`);return options.path&&(cookieStr+=`; Path=${options.path}`),options.domain&&(cookieStr+=`; Domain=${options.domain}`),options.secure&&(cookieStr+="; Secure"),options.sameSite&&(cookieStr+=`; SameSite=${options.sameSite}`),cookieStr}};__name(_CookiesClient,"CookiesClient");let CookiesClient=_CookiesClient;exports.CookiesClient=CookiesClient;
@@ -1,23 +1,17 @@
1
- var __defProp = Object.defineProperty, __defProps = Object.defineProperties;
2
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
6
- for (var prop in b || (b = {}))
7
- __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
8
- if (__getOwnPropSymbols)
9
- for (var prop of __getOwnPropSymbols(b))
10
- __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
11
- return a;
12
- }, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)), __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
13
3
  const _CookiesClient = class _CookiesClient {
14
4
  static set(name, value, options = {}) {
15
5
  const encodedValue = encodeURIComponent(value);
16
6
  let cookieStr = `${name}=${encodedValue}`;
17
- if (options.maxAge) {
18
- const expires = new Date(Date.now() + options.maxAge * 1e3);
19
- cookieStr += `; Expires=${expires.toUTCString()}`, cookieStr += `; Max-Age=${options.maxAge}`;
20
- } else options.expires && (cookieStr += `; Expires=${options.expires.toUTCString()}`);
7
+ if (options.maxAge !== void 0)
8
+ if (options.maxAge <= 0)
9
+ cookieStr += `; Expires=${(/* @__PURE__ */ new Date(0)).toUTCString()}`, cookieStr += "; Max-Age=0";
10
+ else {
11
+ const expires = new Date(Date.now() + options.maxAge * 1e3);
12
+ cookieStr += `; Expires=${expires.toUTCString()}`, cookieStr += `; Max-Age=${options.maxAge}`;
13
+ }
14
+ else options.expires && (cookieStr += `; Expires=${options.expires.toUTCString()}`);
21
15
  options.path && (cookieStr += `; Path=${options.path}`), options.domain && (cookieStr += `; Domain=${options.domain}`), options.secure && (cookieStr += "; Secure"), options.sameSite && (cookieStr += `; SameSite=${options.sameSite}`), document.cookie = cookieStr;
22
16
  }
23
17
  static has(name) {
@@ -45,9 +39,16 @@ const _CookiesClient = class _CookiesClient {
45
39
  }, {});
46
40
  }
47
41
  static remove(name, options = {}) {
48
- this.set(name, "", __spreadProps(__spreadValues({}, options), {
49
- maxAge: -1
50
- }));
42
+ const domains = options.domain ? [options.domain, `.${options.domain}`] : [""], paths = options.path ? [options.path, "/"] : ["", "/"];
43
+ for (const domain of domains)
44
+ for (const path of paths)
45
+ document.cookie = [
46
+ `${name}=`,
47
+ "Expires=Thu, 01 Jan 1970 00:00:00 GMT",
48
+ "Max-Age=0",
49
+ path ? `Path=${path}` : "",
50
+ domain ? `Domain=${domain}` : ""
51
+ ].filter(Boolean).join("; ");
51
52
  }
52
53
  static serialize(name, value, options = {}) {
53
54
  const encodedValue = encodeURIComponent(value);
package/lib/spa/SPA.d.ts CHANGED
@@ -11,6 +11,8 @@ export interface SPAOptions extends Pick<LocalLinksOptions, 'base' | 'trailingSl
11
11
  export interface SPANavigateOptions extends LocalLinksLinkOptions {
12
12
  }
13
13
  export interface SPAEvents {
14
+ spaBeforeFetch: CustomEvent;
15
+ spaAfterFetch: CustomEvent;
14
16
  spaBeforeUpdate: CustomEvent;
15
17
  spaAfterUpdate: CustomEvent;
16
18
  }
package/lib/spa/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cache_index=require("../cache/index.cjs"),LocalLinks=require("../LocalLinks-DJPhk_Gn.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-auvTbYB3.cjs"),PageScroll=require("../PageScroll-DYsZDt3U.cjs"),historyManager=require("../historyManager-Car6P2ak.cjs"),events=require("../events-UlGk63iC.cjs"),morph=require("../morph-Bz2BCWvO.cjs"),scroll=require("../scroll-CTDesBpj.cjs");require("construct-style-sheets-polyfill");require("../index-BoGx2BWX.cjs");const url=require("../url-Dzvsir_7.cjs");var _cache,_domParser,_options,_scroll,_links,_announcerElement,_updateId,_isBack;const _SPA=class _SPA{constructor(options){__privateAdd(this,_cache,new cache_index.Cache);__privateAdd(this,_domParser,new DOMParser);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_isBack,!1);_SPA.instance||(_SPA.instance=this,__privateSet(this,_options,__spreadProps(__spreadValues({},options),{base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),historyManager.historyManager.addPopStateHandler(event=>{var _a,_b,_c,_d,_e,_f;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isBack,!0),this.navigate(location.href.replace(location.origin,""),{scrollValue:((_f=(_e=event.state)==null?void 0:_e.data)==null?void 0:_f.scrollTop)||0}))}))}get scroll(){return __privateGet(this,_scroll)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f,_g;let isBack=__privateGet(this,_isBack);__privateSet(this,_isBack,!1);const updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl));let contents=__privateGet(this,_cache).get(fullUrl.toString());if((!contents||options!=null&&options.revalidate)&&(contents=yield fetch(`${fullUrl}`,{headers:{"X-SPA":"true"}}).then(res=>res.text()).catch(()=>{window.location.assign(fullUrl)})),!contents||(options!=null&&options.cache&&__privateGet(this,_cache).set(fullUrl.toString(),contents),__privateGet(this,_updateId)!==updateId))return;isBack?historyManager.historyManager.updatePreviousStateData({scrollTop:__privateGet(this,_scroll).y}):(historyManager.historyManager.updateCurrentStateData({scrollTop:__privateGet(this,_scroll).y}),historyManager.historyManager.pushState(fullUrl));const html=__privateGet(this,_domParser).parseFromString(contents,"text/html");if(url.normalizeRelativeURLs(html,fullUrl),yield(_b=(_a=__privateGet(this,_options)).beforeDiff)==null?void 0:_b.call(_a,html),__privateGet(this,_updateId)!==updateId)return;events.dispatchEvent(document,"spaBeforeUpdate",{custom:!0});let title=(_c=html.querySelector("title"))==null?void 0:_c.textContent;if(title)document.title=title;else{const h1=document.querySelector("h1");title=(_e=(_d=h1==null?void 0:h1.innerText)!=null?_d:h1==null?void 0:h1.textContent)!=null?_e:fullUrl.pathname}__privateGet(this,_announcerElement).create(html,title);const updateDone=__name(()=>{__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),options!=null&&options.keepScrollPosition||scroll.scrollToElement((options==null?void 0:options.scrollValue)||0,__spreadValues({scrollElement:__privateGet(this,_scroll).element,behavior:"instant"},options==null?void 0:options.scrollOptions))},"updateDone");if(__privateGet(this,_options).viewTransition&&document.startViewTransition){const v=document.startViewTransition(()=>morph.morph(document,html));yield v.updateCallbackDone,updateDone(),yield v.finished}else yield morph.morph(document,html),updateDone();yield(_g=(_f=__privateGet(this,_options)).afterDiff)==null?void 0:_g.call(_f),events.dispatchEvent(document,"spaAfterUpdate",{custom:!0})})}};_cache=new WeakMap,_domParser=new WeakMap,_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_isBack=new WeakMap,__name(_SPA,"SPA"),_SPA.instance=null;let SPA=_SPA;exports.SPA=SPA;
1
+ "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cache_index=require("../cache/index.cjs"),LocalLinks=require("../LocalLinks-DJPhk_Gn.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-auvTbYB3.cjs"),PageScroll=require("../PageScroll-DYsZDt3U.cjs"),historyManager=require("../historyManager-Car6P2ak.cjs"),events=require("../events-UlGk63iC.cjs"),morph=require("../morph-Bz2BCWvO.cjs"),scroll=require("../scroll-CTDesBpj.cjs");require("construct-style-sheets-polyfill");require("../index-BoGx2BWX.cjs");const url=require("../url-Dzvsir_7.cjs");var _cache,_domParser,_options,_scroll,_links,_announcerElement,_updateId,_isBack;const _SPA=class _SPA{constructor(options){__privateAdd(this,_cache,new cache_index.Cache);__privateAdd(this,_domParser,new DOMParser);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_isBack,!1);_SPA.instance||(_SPA.instance=this,__privateSet(this,_options,__spreadProps(__spreadValues({},options),{base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),historyManager.historyManager.addPopStateHandler(event=>{var _a,_b,_c,_d,_e,_f;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isBack,!0),this.navigate(location.href.replace(location.origin,""),{scrollValue:((_f=(_e=event.state)==null?void 0:_e.data)==null?void 0:_f.scrollTop)||0}))}))}get scroll(){return __privateGet(this,_scroll)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f,_g;let isBack=__privateGet(this,_isBack);__privateSet(this,_isBack,!1);const updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl)),events.dispatchEvent(document,"spaBeforeFetch",{custom:!0});let contents=__privateGet(this,_cache).get(fullUrl.toString());if((!contents||options!=null&&options.revalidate)&&(contents=yield fetch(`${fullUrl}`,{headers:{"X-SPA":"true"}}).then(res=>res.text()).catch(()=>{window.location.assign(fullUrl)})),events.dispatchEvent(document,"spaAfterFetch",{custom:!0}),!contents||(options!=null&&options.cache&&__privateGet(this,_cache).set(fullUrl.toString(),contents),__privateGet(this,_updateId)!==updateId))return;isBack?historyManager.historyManager.updatePreviousStateData({scrollTop:__privateGet(this,_scroll).y}):(historyManager.historyManager.updateCurrentStateData({scrollTop:__privateGet(this,_scroll).y}),historyManager.historyManager.pushState(fullUrl));const html=__privateGet(this,_domParser).parseFromString(contents,"text/html");if(url.normalizeRelativeURLs(html,fullUrl),yield(_b=(_a=__privateGet(this,_options)).beforeDiff)==null?void 0:_b.call(_a,html),__privateGet(this,_updateId)!==updateId)return;events.dispatchEvent(document,"spaBeforeUpdate",{custom:!0});let title=(_c=html.querySelector("title"))==null?void 0:_c.textContent;if(title)document.title=title;else{const h1=document.querySelector("h1");title=(_e=(_d=h1==null?void 0:h1.innerText)!=null?_d:h1==null?void 0:h1.textContent)!=null?_e:fullUrl.pathname}__privateGet(this,_announcerElement).create(html,title);const updateDone=__name(()=>{__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),options!=null&&options.keepScrollPosition||scroll.scrollToElement((options==null?void 0:options.scrollValue)||0,__spreadValues({scrollElement:__privateGet(this,_scroll).element,behavior:"instant"},options==null?void 0:options.scrollOptions))},"updateDone");if(__privateGet(this,_options).viewTransition&&document.startViewTransition){const v=document.startViewTransition(()=>morph.morph(document,html));yield v.updateCallbackDone,updateDone(),yield v.finished}else yield morph.morph(document,html),updateDone();yield(_g=(_f=__privateGet(this,_options)).afterDiff)==null?void 0:_g.call(_f),events.dispatchEvent(document,"spaAfterUpdate",{custom:!0})})}};_cache=new WeakMap,_domParser=new WeakMap,_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_isBack=new WeakMap,__name(_SPA,"SPA"),_SPA.instance=null;let SPA=_SPA;exports.SPA=SPA;
package/lib/spa/index.js CHANGED
@@ -94,7 +94,9 @@ const _SPA = class _SPA {
94
94
  base: __privateGet(this, _options).base,
95
95
  trailingSlash: __privateGet(this, _options).trailingSlash
96
96
  });
97
- __privateGet(this, _options).urlModifier && (fullUrl = __privateGet(this, _options).urlModifier(fullUrl));
97
+ __privateGet(this, _options).urlModifier && (fullUrl = __privateGet(this, _options).urlModifier(fullUrl)), dispatchEvent(document, "spaBeforeFetch", {
98
+ custom: !0
99
+ });
98
100
  let contents = __privateGet(this, _cache).get(fullUrl.toString());
99
101
  if ((!contents || options != null && options.revalidate) && (contents = yield fetch(`${fullUrl}`, {
100
102
  headers: {
@@ -102,7 +104,9 @@ const _SPA = class _SPA {
102
104
  }
103
105
  }).then((res) => res.text()).catch(() => {
104
106
  window.location.assign(fullUrl);
105
- })), !contents || (options != null && options.cache && __privateGet(this, _cache).set(fullUrl.toString(), contents), __privateGet(this, _updateId) !== updateId))
107
+ })), dispatchEvent(document, "spaAfterFetch", {
108
+ custom: !0
109
+ }), !contents || (options != null && options.cache && __privateGet(this, _cache).set(fullUrl.toString(), contents), __privateGet(this, _updateId) !== updateId))
106
110
  return;
107
111
  isBack ? historyManager.updatePreviousStateData({
108
112
  scrollTop: __privateGet(this, _scroll).y
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.94.4",
3
+ "version": "0.94.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"