@sentientui/core 0.22.0 → 0.24.0
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/dist/chunk-2NVSFI4V.mjs +2 -0
- package/dist/chunk-2NVSFI4V.mjs.map +1 -0
- package/dist/chunk-EWP6FTHE.mjs +2 -0
- package/dist/chunk-EWP6FTHE.mjs.map +1 -0
- package/dist/chunk-KIP52DUJ.mjs +2 -0
- package/dist/chunk-KIP52DUJ.mjs.map +1 -0
- package/dist/chunk-RL5B6M4G.mjs +2 -0
- package/dist/chunk-RL5B6M4G.mjs.map +1 -0
- package/dist/classify-DYlSjkFP.d.cts +47 -0
- package/dist/classify-DYlSjkFP.d.ts +47 -0
- package/dist/{index-BbrtAtrY.d.ts → index-BjVvN7cU.d.ts} +1 -1
- package/dist/{index-CXxvWxCB.d.cts → index-Cd0gMdJv.d.cts} +1 -1
- package/dist/index-engagement.d.cts +3 -28
- package/dist/index-engagement.d.ts +3 -28
- package/dist/index-engagement.js +1 -1
- package/dist/index-engagement.js.map +1 -1
- package/dist/index-engagement.mjs +1 -1
- package/dist/index-engagement.mjs.map +1 -1
- package/dist/index-graph.d.cts +14 -4
- package/dist/index-graph.d.ts +14 -4
- package/dist/index-graph.js +1 -1
- package/dist/index-graph.js.map +1 -1
- package/dist/index-graph.mjs +1 -1
- package/dist/index-graph.mjs.map +1 -1
- package/dist/index-local.d.cts +2 -2
- package/dist/index-local.d.ts +2 -2
- package/dist/index-server.d.cts +10 -2
- package/dist/index-server.d.ts +10 -2
- package/dist/index-server.js +1 -1
- package/dist/index-server.js.map +1 -1
- package/dist/index-server.mjs +1 -1
- package/dist/index-server.mjs.map +1 -1
- package/dist/index-topics.d.cts +21 -0
- package/dist/index-topics.d.ts +21 -0
- package/dist/index-topics.js +2 -0
- package/dist/index-topics.js.map +1 -0
- package/dist/index-topics.mjs +2 -0
- package/dist/index-topics.mjs.map +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{session-meta-BVvq5RBB.d.cts → session-meta-C-bMqVeq.d.cts} +32 -1
- package/dist/{session-meta-BVvq5RBB.d.ts → session-meta-C-bMqVeq.d.ts} +32 -1
- package/package.json +7 -2
- package/dist/chunk-2RH7I6AP.mjs +0 -2
- package/dist/chunk-2RH7I6AP.mjs.map +0 -1
- package/dist/chunk-CD2A55US.mjs +0 -2
- package/dist/chunk-CD2A55US.mjs.map +0 -1
- package/dist/chunk-QNEYUJJJ.mjs +0 -2
- package/dist/chunk-QNEYUJJJ.mjs.map +0 -1
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const SEMANTIC_TYPES: readonly SemanticType[];
|
|
4
|
-
/** Environment-agnostic section features — buildable from a browser Element or
|
|
5
|
-
* a server-parsed node (node-html-parser). */
|
|
6
|
-
type SectionFeatures = {
|
|
7
|
-
tag: string;
|
|
8
|
-
idClass: string;
|
|
9
|
-
headingText: string;
|
|
10
|
-
bodyText: string;
|
|
11
|
-
actionCount: number;
|
|
12
|
-
textLength: number;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Pure classification over extracted features. `strong` = keyword or content
|
|
16
|
-
* evidence (trustable enough to auto-apply); `weak` = structural fallback
|
|
17
|
-
* (cta/hero/navigation/generic — capture-worthy but not persona evidence).
|
|
18
|
-
*/
|
|
19
|
-
declare function classifyFeatures(f: SectionFeatures): {
|
|
20
|
-
type: SemanticType;
|
|
21
|
-
strength: 'strong' | 'weak';
|
|
22
|
-
};
|
|
23
|
-
/** Feature extraction from a live DOM element (browser paths). */
|
|
24
|
-
declare function featuresFromElement(el: Element): SectionFeatures;
|
|
25
|
-
/** Classify a page section into a semantic type (never null — falls back to
|
|
26
|
-
* 'generic' so the caller can still capture attention on it). */
|
|
27
|
-
declare function classifySection(el: Element): SemanticType;
|
|
1
|
+
import { b as SemanticType } from './classify-DYlSjkFP.js';
|
|
2
|
+
export { S as SEMANTIC_TYPES, a as SectionFeatures, c as classifyFeatures, d as classifySection, f as featuresFromElement } from './classify-DYlSjkFP.js';
|
|
28
3
|
|
|
29
4
|
type CaptureClient = {
|
|
30
5
|
track(event: {
|
|
@@ -56,4 +31,4 @@ type EngagementCaptureOptions = {
|
|
|
56
31
|
};
|
|
57
32
|
declare function startEngagementCapture(client: CaptureClient, opts: EngagementCaptureOptions): () => void;
|
|
58
33
|
|
|
59
|
-
export { type EngagementCaptureOptions,
|
|
34
|
+
export { type EngagementCaptureOptions, SemanticType, startEngagementCapture };
|
package/dist/index-engagement.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var E=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var B=(e,t,n)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))U.call(t,n)&&B(e,n,t[n]);if(j)for(var n of j(t))te.call(t,n)&&B(e,n,t[n]);return e};var ne=(e,t)=>{for(var n in t)E(e,n,{get:t[n],enumerable:!0})},oe=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ee(t))!U.call(e,o)&&o!==n&&E(e,o,{get:()=>t[o],enumerable:!(a=Z(t,o))||a.enumerable});return e};var se=e=>oe(E({},"__esModule",{value:!0}),e);var Se={};ne(Se,{SEMANTIC_TYPES:()=>C,classifyFeatures:()=>x,classifySection:()=>k,featuresFromElement:()=>A,startEngagementCapture:()=>J});module.exports=se(Se);var C=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],re={banner:"hero",navigation:"navigation",contentinfo:"footer"};function ie(e){let t=e.ariaRole?re[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function ae(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var ce=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],le=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],H={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function de(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function x(e){var o,i;let t=ie(e);if(t)return{type:(o=H[t])!=null?o:"generic",strength:"strong"};let n=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[d,s]of ce)if(s.test(n))return{type:d,strength:"strong"};for(let[d,s]of le)if(s.test(e.bodyText))return{type:d,strength:"strong"};let a=ae(e);return{type:(i=H[a])!=null?i:"generic",strength:"weak"}}function A(e){var a,o;let t=((a=e.textContent)!=null?a:"").replace(/\s+/g," ").trim(),n=e.getAttribute("role");return w({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((o=e.className)!=null?o:"")}`,headingText:de(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length},n?{ariaRole:n}:{})}function k(e){return x(A(e)).type}var ue=require("@sentientui/policy");function q(e,t,n,a){let o=[];{let s=!1,c=[],f=()=>{if(s)return;let y=Date.now();for(c.push(y);c.length>0&&y-c[0]>500;)c.shift();c.length>=3&&(s=!0,e("rage_click"))};t.addEventListener("click",f),o.push(()=>t.removeEventListener("click",f))}{let i=!1,d=s=>{if(i||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;i=!0;let c=typeof window!="undefined"?window.getSelection():null,f=c?c.toString().length:0;e("text_copy",{selectionLength:f})};document.addEventListener("copy",d),o.push(()=>document.removeEventListener("copy",d))}{let i=!1,d=!1,s=null,c=()=>{s!==null&&(clearTimeout(s),s=null)},f=()=>{i||!d||(c(),s=setTimeout(()=>{!i&&d&&(i=!0,e("scroll_hesitation"))},3e3))},y=()=>{c(),f()},p=S=>{for(let v of S)d=v.intersectionRatio>.3,d?f():c()},h=new IntersectionObserver(p,{threshold:[.3]});h.observe(t),window.addEventListener("scroll",y,{passive:!0}),o.push(()=>{h.disconnect(),window.removeEventListener("scroll",y),c()})}if((a==null?void 0:a.tabLoss)!==!1){let i=!1,d=n!=null?n:Date.now(),s=()=>{if(i||document.visibilityState!=="hidden")return;let c=Date.now()-d;c<15e3&&(i=!0,e("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let i of o)i()}}function Q(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(t=>t==="1"||t==="yes")}var pe=["data-testid","data-test","data-id","data-name","data-cy"];function _(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function ge(e){return{tag:e.tagName.toLowerCase(),text:_(e).slice(0,40)}}function V(e){return e.replace(/["\\\]]/g,"\\$&")}function b(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function z(e,t){var d;let n=e.tagName.toLowerCase();if(!n)return null;let a=((d=e.getAttribute("class"))!=null?d:"").split(/\s+/).filter(s=>/^[a-zA-Z][\w-]*$/.test(s)),o=[n,...a.map(s=>`${n}.${s}`)];for(let s of o)if(b(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=z(i,t);if(s){for(let p of o){let h=`${s} > ${p}`;if(b(t,h))return h}let c=Array.from(i.children).filter(p=>p.tagName.toLowerCase()===n),f=c.indexOf(e),y=c.some(p=>p!==e&&_(p)!==_(e));if(f>=0&&y){let p=`${s} > ${n}:nth-of-type(${f+1})`;if(b(t,p))return p}}}return null}function Y(e,t){let n=ge(e),a=e.getAttribute("id");if(a&&b(t,`#${V(a)}`))return{v:1,id:a,fingerprint:n};for(let i of pe){let d=e.getAttribute(i);if(d&&b(t,`[${i}="${V(d)}"]`))return{v:1,dataAttr:{name:i,value:d},fingerprint:n}}let o=z(e,t);return o?{v:1,selector:o,fingerprint:n}:null}var fe="section, header, footer, nav, main > div, [data-sentient-section]",me=2e4;function ye(e){let t=Array.from(e.querySelectorAll(fe)),n=t.filter(a=>t.filter(o=>o!==a&&a.contains(o)).length<2);return n.filter(a=>!n.some(o=>o!==a&&o.contains(a)))}function he(e,t,n,a){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:a})}).catch(()=>{})}catch(o){}}var R=()=>{};function J(e,t){var D,M,N,L,K,$,G,F,W;let n=(D=t.doc)!=null?D:typeof document!="undefined"?document:void 0;if(!n||typeof IntersectionObserver=="undefined"||Q()||!t.apiKey||!t.apiKey.startsWith("pk_"))return R;let a=((M=t.apiBase)!=null?M:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),o=ye(n);if(o.length===0)return R;let i=new Map,d=[];for(let r of o){let l=r.getAttribute("data-sentient-type"),u=l&&C.includes(l)?l:null,g=(L=u!=null?u:(N=t.typeOf)==null?void 0:N.call(t,r))!=null?L:k(r),T=`nc-${g}`;i.set(r,T);let I=Y(r,n);d.push(w({componentId:T,semanticType:g,source:u?"markup":"auto"},I?{locator:I}:{}))}let s=(F=(G=($=(K=n.defaultView)!=null?K:typeof window!="undefined"?window:void 0)==null?void 0:$.location)==null?void 0:G.pathname)!=null?F:"/";he(t.apiKey,a,s,d);let c=new Map,f=r=>{let l=c.get(r);return l||(l={ms:0,scroll:0,enterAt:null,intersecting:!1},c.set(r,l)),l},y=new IntersectionObserver(r=>{for(let l of r){let u=i.get(l.target);if(!u)continue;let g=f(u);l.isIntersecting?(g.intersecting=!0,g.enterAt=Date.now(),l.intersectionRatio>g.scroll&&(g.scroll=l.intersectionRatio)):(g.intersecting=!1,g.enterAt!=null&&(g.ms+=Date.now()-g.enterAt,g.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let r of i.keys())y.observe(r);let p=()=>{let r=Date.now();for(let[l,u]of c)if(u.enterAt!=null&&(u.ms+=r-u.enterAt,u.enterAt=null),!(u.ms<=0)){try{e.track({projectId:t.apiKey,componentId:l,eventType:"dwell",payload:{dwell_time:Math.round(u.ms),scroll_depth:Number(u.scroll.toFixed(2))}})}catch(g){}u.ms=0}},h=()=>{if(n.hidden)p();else{let r=Date.now();for(let l of c.values())l.intersecting&&(l.enterAt=r)}},S=!1,v=r=>{if(p(),r!=null&&r.persisted){S=!0;return}try{y.disconnect()}catch(l){}},O=r=>{if(!(r!=null&&r.persisted)||!S)return;S=!1;let l=Date.now();for(let u of c.values())u.enterAt=u.intersecting&&!n.hidden?l:null};n.addEventListener("visibilitychange",h);let m=(W=n.defaultView)!=null?W:typeof window!="undefined"?window:void 0;m==null||m.addEventListener("pagehide",v),m==null||m.addEventListener("pageshow",O);let X=setInterval(()=>{if(n.hidden||S)return;p();let r=Date.now();for(let l of c.values())l.intersecting&&(l.enterAt=r)},me),P=[];return t.microSignals&&[...i.entries()].forEach(([r,l],u)=>{P.push(q((g,T={})=>{try{e.track({projectId:t.apiKey,componentId:l,eventType:"micro_signal",payload:w({signalType:g},T)})}catch(I){}},r,void 0,{tabLoss:u===0}))}),()=>{p(),clearInterval(X),n.removeEventListener("visibilitychange",h),m==null||m.removeEventListener("pagehide",v),m==null||m.removeEventListener("pageshow",O);for(let r of P)r();try{y.disconnect()}catch(r){}}}0&&(module.exports={SEMANTIC_TYPES,classifyFeatures,classifySection,featuresFromElement,startEngagementCapture});
|
|
2
2
|
//# sourceMappingURL=index-engagement.js.map
|