@sentientui/core 0.30.0 → 0.31.1
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/README.md +21 -5
- package/dist/chunk-SFNOFZUH.mjs +2 -0
- package/dist/chunk-SFNOFZUH.mjs.map +1 -0
- package/dist/{index-B0PkJoeB.d.cts → index-DErBinAw.d.cts} +68 -3
- package/dist/{index-BIdUwF-v.d.ts → index-DxWcBI5U.d.ts} +68 -3
- 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-graph.d.cts +4 -4
- package/dist/index-graph.d.ts +4 -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-local.js +1 -1
- package/dist/index-local.js.map +1 -1
- package/dist/index-local.mjs +1 -1
- package/dist/index-local.mjs.map +1 -1
- package/dist/index-server.d.cts +14 -3
- package/dist/index-server.d.ts +14 -3
- 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.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-CY_Luh5i.d.ts → session-meta-DydKfQiR.d.cts} +2 -0
- package/dist/{session-meta-CY_Luh5i.d.cts → session-meta-DydKfQiR.d.ts} +2 -0
- package/llms.txt +4 -4
- package/package.json +2 -2
- package/dist/chunk-HY23LTUY.mjs +0 -2
- package/dist/chunk-HY23LTUY.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a1 as SlotConfigEntry, a0 as SitePalette, a2 as SlotDeclInput, I as CompoundLocator } from './session-meta-
|
|
1
|
+
import { a1 as SlotConfigEntry, a0 as SitePalette, a2 as SlotDeclInput, I as CompoundLocator } from './session-meta-DydKfQiR.cjs';
|
|
2
2
|
import { SlotResult } from '@sentientui/policy';
|
|
3
3
|
|
|
4
4
|
/** Manages anonymous session identity with cookie + localStorage layers. */
|
|
@@ -142,6 +142,25 @@ declare const LEGACY_SESSION_COOKIE_NAME = "_snt_uid";
|
|
|
142
142
|
*/
|
|
143
143
|
declare function sessionCookieName(apiKey?: string): string;
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Where a registry component is EXPECTED to exist — `CompoundLocator.page`.
|
|
147
|
+
*
|
|
148
|
+
* '*' every page
|
|
149
|
+
* '/pricing' exactly that path (a trailing slash is ignored)
|
|
150
|
+
* '/products/*' any path under /products/ (not /products itself)
|
|
151
|
+
*
|
|
152
|
+
* It answers one question only: "if this component's element is absent here,
|
|
153
|
+
* is that a broken locator?" It does NOT gate serving — a component is decided
|
|
154
|
+
* wherever its element resolves. Before it existed nothing recorded where a
|
|
155
|
+
* component belongs, so an absence on any page was reported as a locator miss:
|
|
156
|
+
* on a multi-page site a component that lives only on /pricing collected misses
|
|
157
|
+
* from every other page view and was auto-suspended as "element not found"
|
|
158
|
+
* while working fine. Unscoped (legacy) components therefore report only
|
|
159
|
+
* verification failures, never absence.
|
|
160
|
+
*/
|
|
161
|
+
declare const PAGE_SCOPE_RE: RegExp;
|
|
162
|
+
declare function pageScopeMatches(page: string | undefined, pathname: string): boolean;
|
|
163
|
+
|
|
145
164
|
/**
|
|
146
165
|
* The adaptation reveal — the 0.X-second moment a visitor notices the page is
|
|
147
166
|
* for them (`what-sentient-is-becoming.md` §"Fast generation and the wow",
|
|
@@ -217,7 +236,11 @@ declare function attachMicroSignalDetectors(emit: MicroSignalEmitter, node: Elem
|
|
|
217
236
|
declare function _registerConsentUpgradeInit(apiKey: string, reinit: (config: SentientConfig) => SentientClient): void;
|
|
218
237
|
type SentientConfig = {
|
|
219
238
|
apiKey: string;
|
|
220
|
-
|
|
239
|
+
/**
|
|
240
|
+
* @deprecated Unused — the project's type is set in the dashboard. Safe to omit.
|
|
241
|
+
* Still accepted so existing installs keep type-checking; nothing reads it.
|
|
242
|
+
*/
|
|
243
|
+
context?: 'landing' | 'ecommerce' | 'saas' | 'marketplace';
|
|
221
244
|
/** @internal — not exposed to users; defaults to the hosted SentientUI API. */
|
|
222
245
|
ingestUrl?: string;
|
|
223
246
|
debug?: boolean;
|
|
@@ -369,6 +392,12 @@ type DecideInput = {
|
|
|
369
392
|
}>;
|
|
370
393
|
slots?: SlotDeclInput[];
|
|
371
394
|
slotsFrom?: 'request' | 'registry';
|
|
395
|
+
/** Registry mode only: decide just these published slot ids (1–50) instead
|
|
396
|
+
* of every published slot — see `requestSlots`. */
|
|
397
|
+
registrySlotIds?: string[];
|
|
398
|
+
/** Registry mode only: `false` omits the snippet bootstrap data (editor goals,
|
|
399
|
+
* section map) the React SDK never reads — two queries per page saved. */
|
|
400
|
+
bootstrap?: false;
|
|
372
401
|
/**
|
|
373
402
|
* Caller's build version (e.g. the snippet's `__SNIPPET_VERSION__`), sent
|
|
374
403
|
* as `v` on the wire. Additive/best-effort: the server persists it for
|
|
@@ -454,6 +483,42 @@ type SentientClient = {
|
|
|
454
483
|
* the first report of an id, capped, and the server keeps it only at
|
|
455
484
|
* first registration. */
|
|
456
485
|
reportSlots(slotIds: string[], baselineTexts?: Record<string, string>): void;
|
|
486
|
+
/**
|
|
487
|
+
* Ask the server for the registry config of these MOUNTED slots. Batches a
|
|
488
|
+
* tick's mounts into one decide scoped to exactly those ids, once per id per
|
|
489
|
+
* client; ids the server has nothing published for are passed on to
|
|
490
|
+
* `reportSlots` (with their baseline text) so they register as drafts.
|
|
491
|
+
* Listeners from `onSlotsChanged` fire when the answer lands. Optional so
|
|
492
|
+
* hand-rolled/test clients keep type-checking.
|
|
493
|
+
*/
|
|
494
|
+
requestSlots?(slotIds: string[], baselineTexts?: Record<string, string>): void;
|
|
495
|
+
/**
|
|
496
|
+
* Decide these MOUNTED request-declared slots (useAdaptiveTokens,
|
|
497
|
+
* AdaptiveGroup) that nothing preloaded: a tick's mounts batch into one
|
|
498
|
+
* `decide({ slots })`, once per id per client. Listeners from
|
|
499
|
+
* `onSlotsChanged` fire when it lands. Optional for hand-rolled clients.
|
|
500
|
+
*/
|
|
501
|
+
decideSlots?(decls: SlotDeclInput[]): void;
|
|
502
|
+
/**
|
|
503
|
+
* Withdraw slots from a `requestSlots`/`decideSlots` batch that has not
|
|
504
|
+
* been sent yet (the hooks call this from their unmount cleanup). A slot
|
|
505
|
+
* that mounted and unmounted inside one tick — a redirecting route, a
|
|
506
|
+
* StrictMode probe — is not on the page, so it must not become a trial.
|
|
507
|
+
* In-flight requests are unaffected. Optional for hand-rolled clients.
|
|
508
|
+
*/
|
|
509
|
+
cancelSlots?(slotIds: string[]): void;
|
|
510
|
+
/** Subscribe to slot result/config changes. Returns the unsubscribe. */
|
|
511
|
+
onSlotsChanged?(listener: () => void): () => void;
|
|
512
|
+
/**
|
|
513
|
+
* Whether the result `getSlotResult` returns for this slot was DECIDED for
|
|
514
|
+
* this session — an SSR seed or a decide response — as opposed to a
|
|
515
|
+
* snapshot from an earlier visit or the baseline written when a decide
|
|
516
|
+
* failed. Only a decided arm has a `slot_decisions` row, so only a decided
|
|
517
|
+
* arm may be exposed: recording an impression for a seeded one trains an
|
|
518
|
+
* arm the server never served this session. Optional for hand-rolled
|
|
519
|
+
* clients (absent reads as decided).
|
|
520
|
+
*/
|
|
521
|
+
isSlotDecided?(slotId: string): boolean;
|
|
457
522
|
/** Site palette served with registry block decisions. Null when absent. */
|
|
458
523
|
getSitePalette(): SitePalette | null;
|
|
459
524
|
/** Current persona estimate. Band is always `confidenceBand(confidence)`. Null when nothing is known yet. */
|
|
@@ -503,4 +568,4 @@ declare function grantConsent(apiKey?: string): void;
|
|
|
503
568
|
*/
|
|
504
569
|
declare function init(config: SentientConfig): SentientClient;
|
|
505
570
|
|
|
506
|
-
export { type AssignResult as A, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, type GoalDefinition as G, LEGACY_SESSION_COOKIE_NAME as L, type MicroSignalEmitter as M,
|
|
571
|
+
export { type AssignResult as A, sanitizePageUrl as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, sessionCookieName as F, type GoalDefinition as G, LEGACY_SESSION_COOKIE_NAME as L, type MicroSignalEmitter as M, PAGE_SCOPE_RE as P, type QueueConfig as Q, REVEAL_MS as R, type SectionMapEntry as S, type WeightEntry as W, _registerConsentUpgradeInit as _, type Assignment as a, type AssignmentCache as b, type ComponentWeightEntry as c, type DecideOutcome as d, type EventType as e, type GoalOptions as f, type GraphClient as g, type GraphConfig as h, type GraphSnapshot as i, LOCAL_MODE_BANNER as j, type MicroSignalType as k, PROD_KEYLESS_ERROR as l, type PageNode as m, type RevealOptions as n, type SentientClient as o, type SentientConfig as p, type SentientEvent as q, type SessionConfig as r, type SessionManager as s, attachMicroSignalDetectors as t, grantConsent as u, init as v, isDoNotTrackEnabled as w, pageScopeMatches as x, resetRevealStyles as y, reveal as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a1 as SlotConfigEntry, a0 as SitePalette, a2 as SlotDeclInput, I as CompoundLocator } from './session-meta-
|
|
1
|
+
import { a1 as SlotConfigEntry, a0 as SitePalette, a2 as SlotDeclInput, I as CompoundLocator } from './session-meta-DydKfQiR.js';
|
|
2
2
|
import { SlotResult } from '@sentientui/policy';
|
|
3
3
|
|
|
4
4
|
/** Manages anonymous session identity with cookie + localStorage layers. */
|
|
@@ -142,6 +142,25 @@ declare const LEGACY_SESSION_COOKIE_NAME = "_snt_uid";
|
|
|
142
142
|
*/
|
|
143
143
|
declare function sessionCookieName(apiKey?: string): string;
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Where a registry component is EXPECTED to exist — `CompoundLocator.page`.
|
|
147
|
+
*
|
|
148
|
+
* '*' every page
|
|
149
|
+
* '/pricing' exactly that path (a trailing slash is ignored)
|
|
150
|
+
* '/products/*' any path under /products/ (not /products itself)
|
|
151
|
+
*
|
|
152
|
+
* It answers one question only: "if this component's element is absent here,
|
|
153
|
+
* is that a broken locator?" It does NOT gate serving — a component is decided
|
|
154
|
+
* wherever its element resolves. Before it existed nothing recorded where a
|
|
155
|
+
* component belongs, so an absence on any page was reported as a locator miss:
|
|
156
|
+
* on a multi-page site a component that lives only on /pricing collected misses
|
|
157
|
+
* from every other page view and was auto-suspended as "element not found"
|
|
158
|
+
* while working fine. Unscoped (legacy) components therefore report only
|
|
159
|
+
* verification failures, never absence.
|
|
160
|
+
*/
|
|
161
|
+
declare const PAGE_SCOPE_RE: RegExp;
|
|
162
|
+
declare function pageScopeMatches(page: string | undefined, pathname: string): boolean;
|
|
163
|
+
|
|
145
164
|
/**
|
|
146
165
|
* The adaptation reveal — the 0.X-second moment a visitor notices the page is
|
|
147
166
|
* for them (`what-sentient-is-becoming.md` §"Fast generation and the wow",
|
|
@@ -217,7 +236,11 @@ declare function attachMicroSignalDetectors(emit: MicroSignalEmitter, node: Elem
|
|
|
217
236
|
declare function _registerConsentUpgradeInit(apiKey: string, reinit: (config: SentientConfig) => SentientClient): void;
|
|
218
237
|
type SentientConfig = {
|
|
219
238
|
apiKey: string;
|
|
220
|
-
|
|
239
|
+
/**
|
|
240
|
+
* @deprecated Unused — the project's type is set in the dashboard. Safe to omit.
|
|
241
|
+
* Still accepted so existing installs keep type-checking; nothing reads it.
|
|
242
|
+
*/
|
|
243
|
+
context?: 'landing' | 'ecommerce' | 'saas' | 'marketplace';
|
|
221
244
|
/** @internal — not exposed to users; defaults to the hosted SentientUI API. */
|
|
222
245
|
ingestUrl?: string;
|
|
223
246
|
debug?: boolean;
|
|
@@ -369,6 +392,12 @@ type DecideInput = {
|
|
|
369
392
|
}>;
|
|
370
393
|
slots?: SlotDeclInput[];
|
|
371
394
|
slotsFrom?: 'request' | 'registry';
|
|
395
|
+
/** Registry mode only: decide just these published slot ids (1–50) instead
|
|
396
|
+
* of every published slot — see `requestSlots`. */
|
|
397
|
+
registrySlotIds?: string[];
|
|
398
|
+
/** Registry mode only: `false` omits the snippet bootstrap data (editor goals,
|
|
399
|
+
* section map) the React SDK never reads — two queries per page saved. */
|
|
400
|
+
bootstrap?: false;
|
|
372
401
|
/**
|
|
373
402
|
* Caller's build version (e.g. the snippet's `__SNIPPET_VERSION__`), sent
|
|
374
403
|
* as `v` on the wire. Additive/best-effort: the server persists it for
|
|
@@ -454,6 +483,42 @@ type SentientClient = {
|
|
|
454
483
|
* the first report of an id, capped, and the server keeps it only at
|
|
455
484
|
* first registration. */
|
|
456
485
|
reportSlots(slotIds: string[], baselineTexts?: Record<string, string>): void;
|
|
486
|
+
/**
|
|
487
|
+
* Ask the server for the registry config of these MOUNTED slots. Batches a
|
|
488
|
+
* tick's mounts into one decide scoped to exactly those ids, once per id per
|
|
489
|
+
* client; ids the server has nothing published for are passed on to
|
|
490
|
+
* `reportSlots` (with their baseline text) so they register as drafts.
|
|
491
|
+
* Listeners from `onSlotsChanged` fire when the answer lands. Optional so
|
|
492
|
+
* hand-rolled/test clients keep type-checking.
|
|
493
|
+
*/
|
|
494
|
+
requestSlots?(slotIds: string[], baselineTexts?: Record<string, string>): void;
|
|
495
|
+
/**
|
|
496
|
+
* Decide these MOUNTED request-declared slots (useAdaptiveTokens,
|
|
497
|
+
* AdaptiveGroup) that nothing preloaded: a tick's mounts batch into one
|
|
498
|
+
* `decide({ slots })`, once per id per client. Listeners from
|
|
499
|
+
* `onSlotsChanged` fire when it lands. Optional for hand-rolled clients.
|
|
500
|
+
*/
|
|
501
|
+
decideSlots?(decls: SlotDeclInput[]): void;
|
|
502
|
+
/**
|
|
503
|
+
* Withdraw slots from a `requestSlots`/`decideSlots` batch that has not
|
|
504
|
+
* been sent yet (the hooks call this from their unmount cleanup). A slot
|
|
505
|
+
* that mounted and unmounted inside one tick — a redirecting route, a
|
|
506
|
+
* StrictMode probe — is not on the page, so it must not become a trial.
|
|
507
|
+
* In-flight requests are unaffected. Optional for hand-rolled clients.
|
|
508
|
+
*/
|
|
509
|
+
cancelSlots?(slotIds: string[]): void;
|
|
510
|
+
/** Subscribe to slot result/config changes. Returns the unsubscribe. */
|
|
511
|
+
onSlotsChanged?(listener: () => void): () => void;
|
|
512
|
+
/**
|
|
513
|
+
* Whether the result `getSlotResult` returns for this slot was DECIDED for
|
|
514
|
+
* this session — an SSR seed or a decide response — as opposed to a
|
|
515
|
+
* snapshot from an earlier visit or the baseline written when a decide
|
|
516
|
+
* failed. Only a decided arm has a `slot_decisions` row, so only a decided
|
|
517
|
+
* arm may be exposed: recording an impression for a seeded one trains an
|
|
518
|
+
* arm the server never served this session. Optional for hand-rolled
|
|
519
|
+
* clients (absent reads as decided).
|
|
520
|
+
*/
|
|
521
|
+
isSlotDecided?(slotId: string): boolean;
|
|
457
522
|
/** Site palette served with registry block decisions. Null when absent. */
|
|
458
523
|
getSitePalette(): SitePalette | null;
|
|
459
524
|
/** Current persona estimate. Band is always `confidenceBand(confidence)`. Null when nothing is known yet. */
|
|
@@ -503,4 +568,4 @@ declare function grantConsent(apiKey?: string): void;
|
|
|
503
568
|
*/
|
|
504
569
|
declare function init(config: SentientConfig): SentientClient;
|
|
505
570
|
|
|
506
|
-
export { type AssignResult as A, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, type GoalDefinition as G, LEGACY_SESSION_COOKIE_NAME as L, type MicroSignalEmitter as M,
|
|
571
|
+
export { type AssignResult as A, sanitizePageUrl as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, sessionCookieName as F, type GoalDefinition as G, LEGACY_SESSION_COOKIE_NAME as L, type MicroSignalEmitter as M, PAGE_SCOPE_RE as P, type QueueConfig as Q, REVEAL_MS as R, type SectionMapEntry as S, type WeightEntry as W, _registerConsentUpgradeInit as _, type Assignment as a, type AssignmentCache as b, type ComponentWeightEntry as c, type DecideOutcome as d, type EventType as e, type GoalOptions as f, type GraphClient as g, type GraphConfig as h, type GraphSnapshot as i, LOCAL_MODE_BANNER as j, type MicroSignalType as k, PROD_KEYLESS_ERROR as l, type PageNode as m, type RevealOptions as n, type SentientClient as o, type SentientConfig as p, type SentientEvent as q, type SessionConfig as r, type SessionManager as s, attachMicroSignalDetectors as t, grantConsent as u, init as v, isDoNotTrackEnabled as w, pageScopeMatches as x, resetRevealStyles as y, reveal as z };
|
package/dist/index-engagement.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var R=Object.defineProperty,de=Object.defineProperties,ue=Object.getOwnPropertyDescriptor,pe=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertyNames,Y=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var X=(e,t,n)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))Z.call(t,n)&&X(e,n,t[n]);if(Y)for(var n of Y(t))fe.call(t,n)&&X(e,n,t[n]);return e},O=(e,t)=>de(e,pe(t));var me=(e,t)=>{for(var n in t)R(e,n,{get:t[n],enumerable:!0})},ye=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ge(t))!Z.call(e,o)&&o!==n&&R(e,o,{get:()=>t[o],enumerable:!(a=ue(t,o))||a.enumerable});return e};var he=e=>ye(R({},"__esModule",{value:!0}),e);var Oe={};me(Oe,{SEMANTIC_TYPES:()=>I,classifyFeatures:()=>T,classifySection:()=>te,featuresFromElement:()=>C,startEngagementCapture:()=>le});module.exports=he(Oe);var I=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Se={banner:"hero",navigation:"navigation",contentinfo:"footer"};function we(e){let t=e.ariaRole?Se[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 e.actionCount>=5?"navigation":"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 be(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var ve=[["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]],P=[["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]],ee={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Te(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function T(e){var o,i;let t=we(e);if(t)return{type:(o=ee[t])!=null?o:"generic",strength:"strong"};let n=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[u,r]of ve)if(r.test(n))return{type:u,strength:"strong"};for(let[u,r]of P)if(r.test(e.bodyText))return{type:u,strength:"strong"};let a=be(e);return{type:(i=ee[a])!=null?i:"generic",strength:"weak"}}function C(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:Te(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length},n?{ariaRole:n}:{})}function te(e){return T(C(e)).type}var ae=require("@sentientui/policy");var Ce=require("@sentientui/policy");function ne(e,t,n,a){let o=[];{let r=!1,c=[],f=()=>{if(r)return;let y=Date.now();for(c.push(y);c.length>0&&y-c[0]>500;)c.shift();c.length>=3&&(r=!0,e("rage_click"))};t.addEventListener("click",f),o.push(()=>t.removeEventListener("click",f))}{let i=!1,u=r=>{if(i||!(r.target instanceof Node)||!t.contains(r.target)&&t!==r.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",u),o.push(()=>document.removeEventListener("copy",u))}{let i=!1,u=!1,r=null,c=()=>{r!==null&&(clearTimeout(r),r=null)},f=()=>{i||!u||(c(),r=setTimeout(()=>{!i&&u&&(i=!0,e("scroll_hesitation"))},3e3))},y=()=>{c(),f()},p=b=>{for(let k of b)u=k.intersectionRatio>.3,u?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,u=n!=null?n:Date.now(),r=()=>{if(i||document.visibilityState!=="hidden")return;let c=Date.now()-u;c<15e3&&(i=!0,e("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",r),o.push(()=>document.removeEventListener("visibilitychange",r))}return()=>{for(let i of o)i()}}function oe(){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 Ee=["data-sentient-id","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 ke(e){return{tag:e.tagName.toLowerCase(),text:_(e).slice(0,40)}}function se(e){return e.replace(/["\\\]]/g,"\\$&")}function E(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function re(e,t){var u;let n=e.tagName.toLowerCase();if(!n)return null;let a=((u=e.getAttribute("class"))!=null?u:"").split(/\s+/).filter(r=>/^[a-zA-Z][\w-]*$/.test(r)),o=[n,...a.map(r=>`${n}.${r}`)];for(let r of o)if(E(t,r))return r;let i=e.parentElement;if(i&&i!==t){let r=re(i,t);if(r){for(let p of o){let h=`${r} > ${p}`;if(E(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=`${r} > ${n}:nth-of-type(${f+1})`;if(E(t,p))return p}}}return null}function ie(e,t){let n=ke(e),a=e.getAttribute("id");if(a&&E(t,`#${se(a)}`))return{v:1,id:a,fingerprint:n};for(let i of Ee){let u=e.getAttribute(i);if(u&&E(t,`[${i}="${se(u)}"]`))return{v:1,dataAttr:{name:i,value:u},fingerprint:n}}let o=re(e,t);return o?{v:1,selector:o,fingerprint:n}:null}var Re="section, header, footer, nav, main > div, [data-sentient-section]",Ie=2e4;function xe(e){let t=Array.from(e.querySelectorAll(Re)),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 Ae(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 x=()=>{};function le(e,t){var N,L,$,K,G,j,F,B,W,U,H,q,z,V,Q;let n=(N=t.doc)!=null?N:typeof document!="undefined"?document:void 0;if(!n||typeof IntersectionObserver=="undefined"||oe()||!t.apiKey||!t.apiKey.startsWith("pk_"))return x;let a=((L=t.apiBase)!=null?L:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),o=xe(n);if(o.length===0)return x;let i=new Map,u=[];for(let s of o){let l=(G=[(K=t.sectionTypes)==null?void 0:K[($=s.getAttribute("data-sentient-id"))!=null?$:""],s.getAttribute("data-sentient-type")].find(v=>I.includes(v)))!=null?G:null,d=C(s),g=(F=l!=null?l:(j=t.typeOf)==null?void 0:j.call(t,s))!=null?F:T(d).type,S=ie(s,n),A=S?`nc-${g}-${(0,ae.fnv1a)(JSON.stringify({id:(B=S.id)!=null?B:null,dataAttr:(W=S.dataAttr)!=null?W:null,selector:(U=S.selector)!=null?U:null})).toString(36)}`:`nc-${g}`;i.set(s,A);let J=P.filter(([,v])=>v.test(d.bodyText)).map(([v])=>v);u.push(O(w({componentId:A,semanticType:g,source:l?"markup":"auto"},S?{locator:S}:{}),{observation:w(w({tag:d.tag,idClass:d.idClass.slice(0,200),headingText:d.headingText,textLength:d.textLength,actionCount:d.actionCount},d.ariaRole?{ariaRole:d.ariaRole}:{}),J.length>0?{patternFlags:J}:{})}))}let r=(V=(z=(q=(H=n.defaultView)!=null?H:typeof window!="undefined"?window:void 0)==null?void 0:q.location)==null?void 0:z.pathname)!=null?V:"/";Ae(t.apiKey,a,r,u);let c=new Map,f=s=>{let l=c.get(s);return l||(l={ms:0,scroll:0,enterAt:null,intersecting:!1},c.set(s,l)),l},y=new IntersectionObserver(s=>{for(let l of s){let d=i.get(l.target);if(!d)continue;let g=f(d);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 s of i.keys())y.observe(s);let p=()=>{let s=Date.now();for(let[l,d]of c)if(d.enterAt!=null&&(d.ms+=s-d.enterAt,d.enterAt=null),!(d.ms<=0)){try{e.track({projectId:t.apiKey,componentId:l,eventType:"dwell",payload:{dwell_time:Math.round(d.ms),scroll_depth:Number(d.scroll.toFixed(2))}})}catch(g){}d.ms=0}},h=()=>{if(n.hidden)p();else{let s=Date.now();for(let l of c.values())l.intersecting&&(l.enterAt=s)}},b=!1,k=s=>{if(p(),s!=null&&s.persisted){b=!0;return}try{y.disconnect()}catch(l){}},D=s=>{if(!(s!=null&&s.persisted)||!b)return;b=!1;let l=Date.now();for(let d of c.values())d.enterAt=d.intersecting&&!n.hidden?l:null};n.addEventListener("visibilitychange",h);let m=(Q=n.defaultView)!=null?Q:typeof window!="undefined"?window:void 0;m==null||m.addEventListener("pagehide",k),m==null||m.addEventListener("pageshow",D);let ce=setInterval(()=>{if(n.hidden||b)return;p();let s=Date.now();for(let l of c.values())l.intersecting&&(l.enterAt=s)},Ie),M=[];return t.microSignals&&[...i.entries()].forEach(([s,l],d)=>{M.push(ne((g,S={})=>{try{e.track({projectId:t.apiKey,componentId:l,eventType:"micro_signal",payload:w({signalType:g},S)})}catch(A){}},s,void 0,{tabLoss:d===0}))}),()=>{p(),clearInterval(ce),n.removeEventListener("visibilitychange",h),m==null||m.removeEventListener("pagehide",k),m==null||m.removeEventListener("pageshow",D);for(let s of M)s();try{y.disconnect()}catch(s){}}}0&&(module.exports={SEMANTIC_TYPES,classifyFeatures,classifySection,featuresFromElement,startEngagementCapture});
|
|
1
|
+
"use strict";var R=Object.defineProperty,de=Object.defineProperties,ue=Object.getOwnPropertyDescriptor,ge=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertyNames,Y=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var X=(e,t,n)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))Z.call(t,n)&&X(e,n,t[n]);if(Y)for(var n of Y(t))fe.call(t,n)&&X(e,n,t[n]);return e},O=(e,t)=>de(e,ge(t));var me=(e,t)=>{for(var n in t)R(e,n,{get:t[n],enumerable:!0})},ye=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pe(t))!Z.call(e,o)&&o!==n&&R(e,o,{get:()=>t[o],enumerable:!(a=ue(t,o))||a.enumerable});return e};var he=e=>ye(R({},"__esModule",{value:!0}),e);var Oe={};me(Oe,{SEMANTIC_TYPES:()=>I,classifyFeatures:()=>T,classifySection:()=>te,featuresFromElement:()=>E,startEngagementCapture:()=>le});module.exports=he(Oe);var I=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Se={banner:"hero",navigation:"navigation",contentinfo:"footer"};function we(e){let t=e.ariaRole?Se[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 e.actionCount>=5?"navigation":"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 be(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var ve=[["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]],_=[["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]],ee={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Te(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function T(e){var o,i;let t=we(e);if(t)return{type:(o=ee[t])!=null?o:"generic",strength:"strong"};let n=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[u,r]of ve)if(r.test(n))return{type:u,strength:"strong"};for(let[u,r]of _)if(r.test(e.bodyText))return{type:u,strength:"strong"};let a=be(e);return{type:(i=ee[a])!=null?i:"generic",strength:"weak"}}function E(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:Te(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length},n?{ariaRole:n}:{})}function te(e){return T(E(e)).type}var ae=require("@sentientui/policy");var Ee=require("@sentientui/policy");function ne(e,t,n,a){let o=[];{let r=!1,c=[],f=()=>{if(r)return;let y=Date.now();for(c.push(y);c.length>0&&y-c[0]>500;)c.shift();c.length>=3&&(r=!0,e("rage_click"))};t.addEventListener("click",f),o.push(()=>t.removeEventListener("click",f))}{let i=!1,u=r=>{if(i||!(r.target instanceof Node)||!t.contains(r.target)&&t!==r.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",u),o.push(()=>document.removeEventListener("copy",u))}{let i=!1,u=!1,r=null,c=()=>{r!==null&&(clearTimeout(r),r=null)},f=()=>{i||!u||(c(),r=setTimeout(()=>{!i&&u&&(i=!0,e("scroll_hesitation"))},3e3))},y=()=>{c(),f()},g=b=>{for(let k of b)u=k.intersectionRatio>.3,u?f():c()},h=new IntersectionObserver(g,{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,u=n!=null?n:Date.now(),r=()=>{if(i||document.visibilityState!=="hidden")return;let c=Date.now()-u;c<15e3&&(i=!0,e("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",r),o.push(()=>document.removeEventListener("visibilitychange",r))}return()=>{for(let i of o)i()}}function oe(){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 Ce=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function P(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function ke(e){return{tag:e.tagName.toLowerCase(),text:P(e).slice(0,40)}}function se(e){return e.replace(/["\\\]]/g,"\\$&")}function C(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function re(e,t){var u;let n=e.tagName.toLowerCase();if(!n)return null;let a=((u=e.getAttribute("class"))!=null?u:"").split(/\s+/).filter(r=>/^[a-zA-Z][\w-]*$/.test(r)),o=[n,...a.map(r=>`${n}.${r}`)];for(let r of o)if(C(t,r))return r;let i=e.parentElement;if(i&&i!==t){let r=re(i,t);if(r){for(let g of o){let h=`${r} > ${g}`;if(C(t,h))return h}let c=Array.from(i.children).filter(g=>g.tagName.toLowerCase()===n),f=c.indexOf(e),y=c.some(g=>g!==e&&P(g)!==P(e));if(f>=0&&y){let g=`${r} > ${n}:nth-of-type(${f+1})`;if(C(t,g))return g}}}return null}function ie(e,t){let n=ke(e),a=e.getAttribute("id");if(a&&C(t,`#${se(a)}`))return{v:1,id:a,fingerprint:n};for(let i of Ce){let u=e.getAttribute(i);if(u&&C(t,`[${i}="${se(u)}"]`))return{v:1,dataAttr:{name:i,value:u},fingerprint:n}}let o=re(e,t);return o?{v:1,selector:o,fingerprint:n}:null}var Re="section, header, footer, nav, main > div, [data-sentient-section]",Ie=2e4;function xe(e){let t=Array.from(e.querySelectorAll(Re)),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 Ae(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 x=()=>{};function le(e,t){var N,L,$,K,G,j,F,B,W,q,U,z,H,V,Q;let n=(N=t.doc)!=null?N:typeof document!="undefined"?document:void 0;if(!n||typeof IntersectionObserver=="undefined"||oe()||!t.apiKey||!t.apiKey.startsWith("pk_"))return x;let a=((L=t.apiBase)!=null?L:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),o=xe(n);if(o.length===0)return x;let i=new Map,u=[];for(let s of o){let l=(G=[(K=t.sectionTypes)==null?void 0:K[($=s.getAttribute("data-sentient-id"))!=null?$:""],s.getAttribute("data-sentient-type")].find(v=>I.includes(v)))!=null?G:null,d=E(s),p=(F=l!=null?l:(j=t.typeOf)==null?void 0:j.call(t,s))!=null?F:T(d).type,S=ie(s,n),A=S?`nc-${p}-${(0,ae.fnv1a)(JSON.stringify({id:(B=S.id)!=null?B:null,dataAttr:(W=S.dataAttr)!=null?W:null,selector:(q=S.selector)!=null?q:null})).toString(36)}`:`nc-${p}`;i.set(s,A);let J=_.filter(([,v])=>v.test(d.bodyText)).map(([v])=>v);u.push(O(w({componentId:A,semanticType:p,source:l?"markup":"auto"},S?{locator:S}:{}),{observation:w(w({tag:d.tag,idClass:d.idClass.slice(0,200),headingText:d.headingText,textLength:d.textLength,actionCount:d.actionCount},d.ariaRole?{ariaRole:d.ariaRole}:{}),J.length>0?{patternFlags:J}:{})}))}let r=(V=(H=(z=(U=n.defaultView)!=null?U:typeof window!="undefined"?window:void 0)==null?void 0:z.location)==null?void 0:H.pathname)!=null?V:"/";Ae(t.apiKey,a,r,u);let c=new Map,f=s=>{let l=c.get(s);return l||(l={ms:0,scroll:0,enterAt:null,intersecting:!1},c.set(s,l)),l},y=new IntersectionObserver(s=>{for(let l of s){let d=i.get(l.target);if(!d)continue;let p=f(d);l.isIntersecting?(p.intersecting=!0,p.enterAt=Date.now(),l.intersectionRatio>p.scroll&&(p.scroll=l.intersectionRatio)):(p.intersecting=!1,p.enterAt!=null&&(p.ms+=Date.now()-p.enterAt,p.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let s of i.keys())y.observe(s);let g=()=>{let s=Date.now();for(let[l,d]of c)if(d.enterAt!=null&&(d.ms+=s-d.enterAt,d.enterAt=null),!(d.ms<=0)){try{e.track({projectId:t.apiKey,componentId:l,eventType:"dwell",payload:{dwell_time:Math.round(d.ms),scroll_depth:Number(d.scroll.toFixed(2))}})}catch(p){}d.ms=0}},h=()=>{if(n.hidden)g();else{let s=Date.now();for(let l of c.values())l.intersecting&&(l.enterAt=s)}},b=!1,k=s=>{if(g(),s!=null&&s.persisted){b=!0;return}try{y.disconnect()}catch(l){}},D=s=>{if(!(s!=null&&s.persisted)||!b)return;b=!1;let l=Date.now();for(let d of c.values())d.enterAt=d.intersecting&&!n.hidden?l:null};n.addEventListener("visibilitychange",h);let m=(Q=n.defaultView)!=null?Q:typeof window!="undefined"?window:void 0;m==null||m.addEventListener("pagehide",k),m==null||m.addEventListener("pageshow",D);let ce=setInterval(()=>{if(n.hidden||b)return;g();let s=Date.now();for(let l of c.values())l.intersecting&&(l.enterAt=s)},Ie),M=[];return t.microSignals&&[...i.entries()].forEach(([s,l],d)=>{M.push(ne((p,S={})=>{try{e.track({projectId:t.apiKey,componentId:l,eventType:"micro_signal",payload:w({signalType:p},S)})}catch(A){}},s,void 0,{tabLoss:d===0}))}),()=>{g(),clearInterval(ce),n.removeEventListener("visibilitychange",h),m==null||m.removeEventListener("pagehide",k),m==null||m.removeEventListener("pageshow",D);for(let s of M)s();try{y.disconnect()}catch(s){}}}0&&(module.exports={SEMANTIC_TYPES,classifyFeatures,classifySection,featuresFromElement,startEngagementCapture});
|
|
2
2
|
//# sourceMappingURL=index-engagement.js.map
|