@guidelytech/shared 0.4.1 → 0.6.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/dist/{chunk-QUKMOTT4.js → chunk-OLWGMDRX.js} +254 -2
- package/dist/chunk-OLWGMDRX.js.map +1 -0
- package/dist/index.cjs +444 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +473 -19
- package/dist/index.d.ts +473 -19
- package/dist/index.js +210 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +287 -2
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +142 -1
- package/dist/runtime.d.ts +142 -1
- package/dist/runtime.js +69 -3
- package/package.json +1 -1
- package/dist/chunk-QUKMOTT4.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CAPTURE_PARAM,
|
|
3
|
+
CAPTURE_SCREENSHOT_MAX_BYTES,
|
|
2
4
|
DEFAULT_PLATFORMS,
|
|
5
|
+
EMBED_IFRAME_ATTRS,
|
|
6
|
+
FILE_LINK_CLASS,
|
|
3
7
|
GUIDELY_ID_ATTRIBUTE,
|
|
8
|
+
MAX_COLLECTION_DEPTH,
|
|
4
9
|
MAX_PROPERTY_BYTES,
|
|
5
10
|
MAX_STACK_FRAMES,
|
|
11
|
+
MEDIA_FILE_MAX_BYTES,
|
|
12
|
+
MEDIA_FILE_TYPES,
|
|
13
|
+
MEDIA_IMAGE_MAX_BYTES,
|
|
14
|
+
MEDIA_IMAGE_TYPES,
|
|
15
|
+
MEDIA_MAX_BYTES,
|
|
16
|
+
MEDIA_VIDEO_MAX_BYTES,
|
|
17
|
+
MEDIA_VIDEO_TYPES,
|
|
6
18
|
NETWORK_PLUGIN,
|
|
19
|
+
PATH_ID_PATTERN,
|
|
20
|
+
PDF_BLOCK_CLASS,
|
|
21
|
+
PDF_MAX_PAGES,
|
|
22
|
+
PDF_PAGES_CLASS,
|
|
7
23
|
PLATFORMS,
|
|
8
24
|
RULE_FIELDS,
|
|
9
25
|
RULE_OPERATORS,
|
|
@@ -13,6 +29,7 @@ import {
|
|
|
13
29
|
SERVER_ASSISTED_FIELDS,
|
|
14
30
|
SOURCEMAP_MAX_FILES_PER_UPLOAD,
|
|
15
31
|
SOURCEMAP_MAX_FILE_BYTES,
|
|
32
|
+
VIDEO_ATTRS,
|
|
16
33
|
WS_MAX_MESSAGES_PER_SOCKET,
|
|
17
34
|
WS_MAX_MESSAGE_BYTES,
|
|
18
35
|
clamp,
|
|
@@ -23,27 +40,43 @@ import {
|
|
|
23
40
|
evaluateRule,
|
|
24
41
|
evaluateRules,
|
|
25
42
|
fingerprintError,
|
|
43
|
+
firstNameFromTraits,
|
|
26
44
|
fnv1a,
|
|
45
|
+
foldPathIds,
|
|
27
46
|
getPath,
|
|
28
47
|
guidePlatforms,
|
|
29
48
|
guidelyIdFromSelector,
|
|
49
|
+
isAllowedEmbedSrc,
|
|
50
|
+
isArticleListed,
|
|
30
51
|
isChecklistComplete,
|
|
52
|
+
isFileLink,
|
|
53
|
+
isMediaContentType,
|
|
31
54
|
isPlainObject,
|
|
32
55
|
isQuestionVisible,
|
|
33
56
|
isRuleGroup,
|
|
57
|
+
isSafeMediaUrl,
|
|
58
|
+
isVideoContentType,
|
|
34
59
|
matchUrlPattern,
|
|
60
|
+
matchesAudiences,
|
|
61
|
+
mediaKind,
|
|
62
|
+
mediaMaxBytes,
|
|
35
63
|
normalizeErrorMessage,
|
|
36
64
|
normalizeFrameFile,
|
|
65
|
+
pageLabel,
|
|
66
|
+
pageTerms,
|
|
37
67
|
parseStack,
|
|
38
68
|
randomId,
|
|
69
|
+
resourceCenterSections,
|
|
39
70
|
rolloutBucket,
|
|
40
71
|
safeRegExp,
|
|
41
72
|
sanitizeProperties,
|
|
42
73
|
screenPath,
|
|
43
74
|
slugify,
|
|
44
75
|
stripOrigin,
|
|
45
|
-
supportsPlatform
|
|
46
|
-
|
|
76
|
+
supportsPlatform,
|
|
77
|
+
toEmbedUrl,
|
|
78
|
+
visibleArticleIds
|
|
79
|
+
} from "./chunk-OLWGMDRX.js";
|
|
47
80
|
|
|
48
81
|
// src/targeting.ts
|
|
49
82
|
import { z } from "zod";
|
|
@@ -430,6 +463,14 @@ var PublishedGuideSchema = z4.object({
|
|
|
430
463
|
|
|
431
464
|
// src/messenger.ts
|
|
432
465
|
import { z as z5 } from "zod";
|
|
466
|
+
var REPLY_TIMES = ["minutes", "hour", "hours", "day"];
|
|
467
|
+
var STATUS_LEVELS = ["operational", "degraded", "outage", "maintenance"];
|
|
468
|
+
var MessengerPageRequestSchema = z5.object({
|
|
469
|
+
anonymousId: z5.string().min(1).max(128),
|
|
470
|
+
userId: z5.string().max(256).optional().nullable(),
|
|
471
|
+
/** Pathname only: query strings and fragments are never sent. */
|
|
472
|
+
path: z5.string().min(1).max(1e3)
|
|
473
|
+
});
|
|
433
474
|
var MESSAGE_AUTHORS = ["user", "scout", "agent", "system"];
|
|
434
475
|
var MAX_MESSAGE_LENGTH = 4e3;
|
|
435
476
|
var messageText = z5.string().trim().min(1).max(MAX_MESSAGE_LENGTH);
|
|
@@ -442,7 +483,11 @@ var StartConversationSchema = z5.object({
|
|
|
442
483
|
var ConversationLookupSchema = z5.object({
|
|
443
484
|
tokens: z5.array(z5.string().min(16).max(128)).max(50)
|
|
444
485
|
});
|
|
445
|
-
var PostMessageSchema = z5.object({
|
|
486
|
+
var PostMessageSchema = z5.object({
|
|
487
|
+
message: messageText,
|
|
488
|
+
/** The page the user is on now (omitted when URL collection is off and by older SDKs), so Scout answers for that page. */
|
|
489
|
+
pageUrl: z5.string().max(2e3).optional()
|
|
490
|
+
});
|
|
446
491
|
var ConversationRatingSchema = z5.object({
|
|
447
492
|
rating: z5.number().int().min(1).max(5),
|
|
448
493
|
comment: z5.string().max(1e3).optional()
|
|
@@ -675,17 +720,135 @@ function templateConfig(id) {
|
|
|
675
720
|
return { template: t, config: GuideConfigSchema.parse(t.config) };
|
|
676
721
|
}
|
|
677
722
|
|
|
723
|
+
// src/howto.ts
|
|
724
|
+
import { z as z7 } from "zod";
|
|
725
|
+
var HOWTO_STEP_KINDS = ["action", "text", "heading", "tip", "alert"];
|
|
726
|
+
var HOWTO_ACTIONS = ["click", "type", "select", "navigate"];
|
|
727
|
+
var NormalizedRectSchema = z7.object({
|
|
728
|
+
x: z7.number().min(0).max(1),
|
|
729
|
+
y: z7.number().min(0).max(1),
|
|
730
|
+
width: z7.number().min(0).max(1),
|
|
731
|
+
height: z7.number().min(0).max(1)
|
|
732
|
+
});
|
|
733
|
+
var CapturedElementSchema = z7.object({
|
|
734
|
+
/** Visible name: aria-label, associated label, text, placeholder, alt or title. */
|
|
735
|
+
label: z7.string().max(200).default(""),
|
|
736
|
+
/** button, link, tab, menuitem, checkbox, radio, field, dropdown, option, element… */
|
|
737
|
+
role: z7.string().max(40).default("element"),
|
|
738
|
+
tag: z7.string().max(40).default("")
|
|
739
|
+
});
|
|
740
|
+
var CaptureStepSchema = z7.object({
|
|
741
|
+
/** Random id from the SDK; a retried upload with the same id is stored once. */
|
|
742
|
+
clientId: z7.string().min(1).max(64),
|
|
743
|
+
action: z7.enum(HOWTO_ACTIONS),
|
|
744
|
+
url: z7.string().max(2e3),
|
|
745
|
+
pageTitle: z7.string().max(300).default(""),
|
|
746
|
+
element: CapturedElementSchema.optional(),
|
|
747
|
+
/** Typed text or chosen option; absent when it was sensitive (`valueRedacted`). */
|
|
748
|
+
value: z7.string().max(200).optional(),
|
|
749
|
+
valueRedacted: z7.boolean().default(false),
|
|
750
|
+
/** Selectors for the element, so the step can later become an interactive tour step. */
|
|
751
|
+
selectors: z7.array(SelectorStrategySchema).max(10).default([]),
|
|
752
|
+
/** Where the element sits in the screenshot. */
|
|
753
|
+
highlight: NormalizedRectSchema.optional(),
|
|
754
|
+
/** Number of regions the SDK blurred in the screenshot before upload. */
|
|
755
|
+
redactions: z7.number().int().min(0).max(1e3).default(0),
|
|
756
|
+
occurredAt: z7.string().datetime().optional()
|
|
757
|
+
});
|
|
758
|
+
function quoted(s) {
|
|
759
|
+
const t = (s ?? "").replace(/\s+/g, " ").trim();
|
|
760
|
+
return t.length > 60 ? `\u201C${t.slice(0, 57)}\u2026\u201D` : `\u201C${t}\u201D`;
|
|
761
|
+
}
|
|
762
|
+
function cleanLabel(label) {
|
|
763
|
+
const raw = (label ?? "").replace(/\s+/g, " ").trim();
|
|
764
|
+
const cleaned = raw.replace(/^[^\p{L}\p{N}“"'(]+/u, "").replace(/[\s:*]+$/u, "").replace(/[^\p{L}\p{N})”"'?!.%]+$/u, "").trim();
|
|
765
|
+
return cleaned || raw;
|
|
766
|
+
}
|
|
767
|
+
var SEPARATORS = /\s+[·|•–—-]\s+|\s*[|·•]\s*/;
|
|
768
|
+
var ID_SEGMENT = /^(?:\d+|[0-9a-f]{8,}(?:-[0-9a-f]{4,})*|[A-Za-z0-9_-]{20,})$/i;
|
|
769
|
+
function humanize(segment) {
|
|
770
|
+
const words = decodeURIComponent(segment).replace(/[-_+]+/g, " ").trim();
|
|
771
|
+
return words ? words.charAt(0).toUpperCase() + words.slice(1) : "";
|
|
772
|
+
}
|
|
773
|
+
function pageName(url, pageTitle) {
|
|
774
|
+
const title = (pageTitle ?? "").replace(/\s+/g, " ").trim();
|
|
775
|
+
const parts = title.split(SEPARATORS).map((p) => p.trim()).filter(Boolean);
|
|
776
|
+
if (parts.length > 1) return parts[0];
|
|
777
|
+
let segments = [];
|
|
778
|
+
try {
|
|
779
|
+
segments = new URL(url).pathname.split("/").filter((p) => p && !ID_SEGMENT.test(p));
|
|
780
|
+
} catch {
|
|
781
|
+
segments = [];
|
|
782
|
+
}
|
|
783
|
+
const fromPath = segments.slice(-2).map(humanize).filter(Boolean).join(" \u203A ");
|
|
784
|
+
if (!fromPath) return title || hostAndPath(url);
|
|
785
|
+
if (!title) return fromPath;
|
|
786
|
+
const lower = title.toLowerCase();
|
|
787
|
+
const mentionsPath = segments.some((seg) => humanize(seg).toLowerCase().split(" ").some((w) => w.length > 2 && lower.includes(w)));
|
|
788
|
+
return mentionsPath ? title : fromPath;
|
|
789
|
+
}
|
|
790
|
+
var ROLE_NOUN = { tab: "tab", menuitem: "menu item", field: "field", dropdown: "dropdown", option: "option" };
|
|
791
|
+
function describeCaptureStep(step) {
|
|
792
|
+
const label = cleanLabel(step.element?.label);
|
|
793
|
+
const role = step.element?.role ?? "";
|
|
794
|
+
switch (step.action) {
|
|
795
|
+
case "navigate": {
|
|
796
|
+
const where = pageName(step.url, step.pageTitle);
|
|
797
|
+
return where ? `Go to ${quoted(where)}` : "Open the page";
|
|
798
|
+
}
|
|
799
|
+
case "type": {
|
|
800
|
+
const field = label ? quoted(label) : "the field";
|
|
801
|
+
if (step.valueRedacted || !step.value) return `Fill in ${field}`;
|
|
802
|
+
return `Type ${quoted(step.value)} into ${field}`;
|
|
803
|
+
}
|
|
804
|
+
case "select":
|
|
805
|
+
if (step.value && label) return `Select ${quoted(step.value)} from ${quoted(label)}`;
|
|
806
|
+
if (step.value) return `Select ${quoted(step.value)}`;
|
|
807
|
+
return label ? `Choose an option in ${quoted(label)}` : "Choose an option";
|
|
808
|
+
case "click":
|
|
809
|
+
default:
|
|
810
|
+
if (role === "checkbox") return label ? `Check ${quoted(label)}` : "Check the box";
|
|
811
|
+
if (role === "switch") return label ? `Turn ${quoted(label)} on or off` : "Flip the switch";
|
|
812
|
+
if (role === "radio") return label ? `Select ${quoted(label)}` : "Select the option";
|
|
813
|
+
if (role === "menuitem") return label ? `Choose ${quoted(label)} from the menu` : "Choose the menu item";
|
|
814
|
+
if (role === "tab") return label ? `Open the ${quoted(label)} tab` : "Open the tab";
|
|
815
|
+
if (label) return `Click ${quoted(label)}`;
|
|
816
|
+
return ROLE_NOUN[role] ? `Click the ${ROLE_NOUN[role]}` : role === "link" ? "Click the link" : "Click the button";
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function hostAndPath(url) {
|
|
820
|
+
try {
|
|
821
|
+
const u = new URL(url);
|
|
822
|
+
return `${u.host}${u.pathname === "/" ? "" : u.pathname}`;
|
|
823
|
+
} catch {
|
|
824
|
+
return url.slice(0, 80);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
var NormalizedPointSchema = z7.object({ x: z7.number().min(0).max(1), y: z7.number().min(0).max(1) });
|
|
828
|
+
var ANNOTATION_COLORS = ["brand", "red", "amber", "green", "black", "white"];
|
|
829
|
+
var HowToAnnotationSchema = z7.discriminatedUnion("type", [
|
|
830
|
+
z7.object({ id: z7.string().min(1).max(32), type: z7.literal("arrow"), from: NormalizedPointSchema, to: NormalizedPointSchema, color: z7.enum(ANNOTATION_COLORS).default("brand") }),
|
|
831
|
+
z7.object({ id: z7.string().min(1).max(32), type: z7.literal("text"), at: NormalizedPointSchema, text: z7.string().trim().min(1).max(120), color: z7.enum(ANNOTATION_COLORS).default("brand") }),
|
|
832
|
+
z7.object({ id: z7.string().min(1).max(32), type: z7.literal("box"), rect: NormalizedRectSchema, color: z7.enum(ANNOTATION_COLORS).default("brand") })
|
|
833
|
+
]);
|
|
834
|
+
var MAX_ANNOTATIONS = 30;
|
|
835
|
+
|
|
678
836
|
// src/index.ts
|
|
679
837
|
var SDK_API_VERSION = "v1";
|
|
680
|
-
var SHARED_VERSION = "0.
|
|
838
|
+
var SHARED_VERSION = "0.6.1";
|
|
681
839
|
export {
|
|
682
840
|
ADVANCE_ON,
|
|
841
|
+
ANNOTATION_COLORS,
|
|
683
842
|
AUTOCAPTURE_EVENTS,
|
|
684
843
|
AppearanceSchema,
|
|
685
844
|
AuthoringPickSchema,
|
|
686
845
|
AutocaptureSettingsSchema,
|
|
687
846
|
BUTTON_ACTIONS,
|
|
688
847
|
ButtonSchema,
|
|
848
|
+
CAPTURE_PARAM,
|
|
849
|
+
CAPTURE_SCREENSHOT_MAX_BYTES,
|
|
850
|
+
CaptureStepSchema,
|
|
851
|
+
CapturedElementSchema,
|
|
689
852
|
ChecklistConfigSchema,
|
|
690
853
|
ChecklistProgressRequestSchema,
|
|
691
854
|
ChecklistTaskSchema,
|
|
@@ -693,9 +856,11 @@ export {
|
|
|
693
856
|
ConversationRatingSchema,
|
|
694
857
|
DEFAULT_CAPTURE_SETTINGS,
|
|
695
858
|
DEFAULT_PLATFORMS,
|
|
859
|
+
EMBED_IFRAME_ATTRS,
|
|
696
860
|
EVENT_NAMES,
|
|
697
861
|
ErrorTrackingSettingsSchema,
|
|
698
862
|
EventBatchSchema,
|
|
863
|
+
FILE_LINK_CLASS,
|
|
699
864
|
FrequencySchema,
|
|
700
865
|
GUIDELY_ID_ATTRIBUTE,
|
|
701
866
|
GUIDE_KINDS,
|
|
@@ -705,12 +870,31 @@ export {
|
|
|
705
870
|
GuideConfigSchema,
|
|
706
871
|
GuideStateUpdateSchema,
|
|
707
872
|
HEATMAP_VIEWPORTS,
|
|
873
|
+
HOWTO_ACTIONS,
|
|
874
|
+
HOWTO_STEP_KINDS,
|
|
875
|
+
HowToAnnotationSchema,
|
|
708
876
|
IdentifyRequestSchema,
|
|
877
|
+
MAX_ANNOTATIONS,
|
|
878
|
+
MAX_COLLECTION_DEPTH,
|
|
709
879
|
MAX_MESSAGE_LENGTH,
|
|
710
880
|
MAX_PROPERTY_BYTES,
|
|
711
881
|
MAX_STACK_FRAMES,
|
|
882
|
+
MEDIA_FILE_MAX_BYTES,
|
|
883
|
+
MEDIA_FILE_TYPES,
|
|
884
|
+
MEDIA_IMAGE_MAX_BYTES,
|
|
885
|
+
MEDIA_IMAGE_TYPES,
|
|
886
|
+
MEDIA_MAX_BYTES,
|
|
887
|
+
MEDIA_VIDEO_MAX_BYTES,
|
|
888
|
+
MEDIA_VIDEO_TYPES,
|
|
712
889
|
MESSAGE_AUTHORS,
|
|
890
|
+
MessengerPageRequestSchema,
|
|
713
891
|
NETWORK_PLUGIN,
|
|
892
|
+
NormalizedPointSchema,
|
|
893
|
+
NormalizedRectSchema,
|
|
894
|
+
PATH_ID_PATTERN,
|
|
895
|
+
PDF_BLOCK_CLASS,
|
|
896
|
+
PDF_MAX_PAGES,
|
|
897
|
+
PDF_PAGES_CLASS,
|
|
714
898
|
PLACEMENTS,
|
|
715
899
|
PLATFORMS,
|
|
716
900
|
PostMessageSchema,
|
|
@@ -718,6 +902,7 @@ export {
|
|
|
718
902
|
PublishedGuideSchema,
|
|
719
903
|
REPLAY_MAX_COMPRESSED_BYTES,
|
|
720
904
|
REPLAY_MAX_RAW_BYTES,
|
|
905
|
+
REPLY_TIMES,
|
|
721
906
|
RULE_FIELDS,
|
|
722
907
|
RULE_OPERATORS,
|
|
723
908
|
ReplayChunkSchema,
|
|
@@ -733,6 +918,7 @@ export {
|
|
|
733
918
|
SHARED_VERSION,
|
|
734
919
|
SOURCEMAP_MAX_FILES_PER_UPLOAD,
|
|
735
920
|
SOURCEMAP_MAX_FILE_BYTES,
|
|
921
|
+
STATUS_LEVELS,
|
|
736
922
|
STEP_TYPES,
|
|
737
923
|
SURVEY_QUESTION_TYPES,
|
|
738
924
|
SdkEventSchema,
|
|
@@ -746,32 +932,50 @@ export {
|
|
|
746
932
|
TRIGGER_TYPES,
|
|
747
933
|
TargetSchema,
|
|
748
934
|
TriggerSchema,
|
|
935
|
+
VIDEO_ATTRS,
|
|
749
936
|
WS_MAX_MESSAGES_PER_SOCKET,
|
|
750
937
|
WS_MAX_MESSAGE_BYTES,
|
|
751
938
|
clamp,
|
|
939
|
+
cleanLabel,
|
|
752
940
|
compare,
|
|
753
941
|
compareVersions,
|
|
754
942
|
defaultGuideConfig,
|
|
755
943
|
defaultStep,
|
|
944
|
+
describeCaptureStep,
|
|
756
945
|
describeRule,
|
|
757
946
|
emptyRuleGroup,
|
|
758
947
|
evaluateRule,
|
|
759
948
|
evaluateRules,
|
|
760
949
|
fingerprintError,
|
|
950
|
+
firstNameFromTraits,
|
|
761
951
|
fnv1a,
|
|
952
|
+
foldPathIds,
|
|
762
953
|
getPath,
|
|
763
954
|
guidePlatforms,
|
|
764
955
|
guidelyIdFromSelector,
|
|
956
|
+
isAllowedEmbedSrc,
|
|
957
|
+
isArticleListed,
|
|
765
958
|
isChecklistComplete,
|
|
959
|
+
isFileLink,
|
|
960
|
+
isMediaContentType,
|
|
766
961
|
isPlainObject,
|
|
767
962
|
isQuestionVisible,
|
|
768
963
|
isRuleGroup,
|
|
964
|
+
isSafeMediaUrl,
|
|
965
|
+
isVideoContentType,
|
|
769
966
|
matchUrlPattern,
|
|
967
|
+
matchesAudiences,
|
|
968
|
+
mediaKind,
|
|
969
|
+
mediaMaxBytes,
|
|
770
970
|
normalizeErrorMessage,
|
|
771
971
|
normalizeFrameFile,
|
|
972
|
+
pageLabel,
|
|
973
|
+
pageName,
|
|
974
|
+
pageTerms,
|
|
772
975
|
parseStack,
|
|
773
976
|
randomId,
|
|
774
977
|
resolveCaptureSettings,
|
|
978
|
+
resourceCenterSections,
|
|
775
979
|
rolloutBucket,
|
|
776
980
|
safeRegExp,
|
|
777
981
|
sanitizeProperties,
|
|
@@ -780,7 +984,9 @@ export {
|
|
|
780
984
|
stripOrigin,
|
|
781
985
|
supportsPlatform,
|
|
782
986
|
templateConfig,
|
|
987
|
+
toEmbedUrl,
|
|
783
988
|
validateGuideConfig,
|
|
989
|
+
visibleArticleIds,
|
|
784
990
|
visibleButtons
|
|
785
991
|
};
|
|
786
992
|
//# sourceMappingURL=index.js.map
|