aptechka 0.92.2 → 0.92.3

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.
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-CwbdlIvT.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-auvTbYB3.cjs"),PageScroll=require("../PageScroll-DYsZDt3U.cjs"),historyManager=require("../historyManager-DB2fSEtH.cjs"),events=require("../events-UlGk63iC.cjs"),morph=require("../morph-C71wnWQv.cjs");require("../Store-B96mD8mD.cjs");require("../index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("../url-D0rESDQq.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,_g,_h;(_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,""),{scrollTop:((_f=(_e=event.state)==null?void 0:_e.data)==null?void 0:_f.scrollTop)||0,scrollLeft:((_h=(_g=event.state)==null?void 0:_g.data)==null?void 0:_h.scrollLeft)||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,scrollLeft:__privateGet(this,_scroll).x}):(historyManager.historyManager.updateCurrentStateData({scrollTop:__privateGet(this,_scroll).y,scrollLeft:__privateGet(this,_scroll).x}),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),__privateGet(this,_options).viewTransition&&document.startViewTransition?yield document.startViewTransition(()=>morph.morph(document,html)).finished:yield morph.morph(document,html),__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),options!=null&&options.keepScrollPosition||__privateGet(this,_scroll).element.scrollTo({top:(options==null?void 0:options.scrollTop)||0,left:(options==null?void 0:options.scrollLeft)||0,behavior:"instant"}),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-CwbdlIvT.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-auvTbYB3.cjs"),PageScroll=require("../PageScroll-DYsZDt3U.cjs"),historyManager=require("../historyManager-DB2fSEtH.cjs"),events=require("../events-UlGk63iC.cjs"),morph=require("../morph-C71wnWQv.cjs");require("../Store-B96mD8mD.cjs");require("../index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("../url-D0rESDQq.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,_g,_h;(_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,""),{scrollTop:((_f=(_e=event.state)==null?void 0:_e.data)==null?void 0:_f.scrollTop)||0,scrollLeft:((_h=(_g=event.state)==null?void 0:_g.data)==null?void 0:_h.scrollLeft)||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,scrollLeft:__privateGet(this,_scroll).x}):(historyManager.historyManager.updateCurrentStateData({scrollTop:__privateGet(this,_scroll).y,scrollLeft:__privateGet(this,_scroll).x}),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||__privateGet(this,_scroll).element.scrollTo({top:(options==null?void 0:options.scrollTop)||0,left:(options==null?void 0:options.scrollLeft)||0,behavior:"instant"})},"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
@@ -125,11 +125,20 @@ const _SPA = class _SPA {
125
125
  const h1 = document.querySelector("h1");
126
126
  title = (_e = (_d = h1 == null ? void 0 : h1.innerText) != null ? _d : h1 == null ? void 0 : h1.textContent) != null ? _e : fullUrl.pathname;
127
127
  }
128
- __privateGet(this, _announcerElement).create(html, title), __privateGet(this, _options).viewTransition && document.startViewTransition ? yield document.startViewTransition(() => morph(document, html)).finished : yield morph(document, html), __privateGet(this, _scroll).update(), __privateGet(this, _links).update(), __privateGet(this, _announcerElement).done(), options != null && options.keepScrollPosition || __privateGet(this, _scroll).element.scrollTo({
129
- top: (options == null ? void 0 : options.scrollTop) || 0,
130
- left: (options == null ? void 0 : options.scrollLeft) || 0,
131
- behavior: "instant"
132
- }), yield (_g = (_f = __privateGet(this, _options)).afterDiff) == null ? void 0 : _g.call(_f), dispatchEvent(document, "spaAfterUpdate", {
128
+ __privateGet(this, _announcerElement).create(html, title);
129
+ const updateDone = /* @__PURE__ */ __name(() => {
130
+ __privateGet(this, _scroll).update(), __privateGet(this, _links).update(), __privateGet(this, _announcerElement).done(), options != null && options.keepScrollPosition || __privateGet(this, _scroll).element.scrollTo({
131
+ top: (options == null ? void 0 : options.scrollTop) || 0,
132
+ left: (options == null ? void 0 : options.scrollLeft) || 0,
133
+ behavior: "instant"
134
+ });
135
+ }, "updateDone");
136
+ if (__privateGet(this, _options).viewTransition && document.startViewTransition) {
137
+ const v = document.startViewTransition(() => morph(document, html));
138
+ yield v.updateCallbackDone, updateDone(), yield v.finished;
139
+ } else
140
+ yield morph(document, html), updateDone();
141
+ yield (_g = (_f = __privateGet(this, _options)).afterDiff) == null ? void 0 : _g.call(_f), dispatchEvent(document, "spaAfterUpdate", {
133
142
  custom: !0
134
143
  });
135
144
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.92.2",
3
+ "version": "0.92.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"