@guidelytech/shared 0.4.1 → 0.5.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-5IQVBZO6.js +662 -0
- package/dist/chunk-5IQVBZO6.js.map +1 -0
- package/dist/index.cjs +203 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -15
- package/dist/index.d.ts +19 -15
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +204 -2
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +89 -1
- package/dist/runtime.d.ts +89 -1
- package/dist/runtime.js +37 -3
- package/package.json +1 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -266,4 +266,92 @@ declare const SENSITIVE_HEADER_PATTERN: RegExp;
|
|
|
266
266
|
/** Query parameter and JSON field names whose values are redacted. */
|
|
267
267
|
declare const SENSITIVE_PARAM_PATTERN: RegExp;
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Media in article bodies: uploaded images and videos, and video embeds from a fixed set of hosts.
|
|
271
|
+
* Sanitizers (server, browser runtime) only keep an `<iframe>` whose `src` is the canonical embed URL
|
|
272
|
+
* that `toEmbedUrl` produces, so authors can never point a frame anywhere else.
|
|
273
|
+
*/
|
|
274
|
+
type EmbedProvider = "youtube" | "vimeo" | "loom" | "wistia";
|
|
275
|
+
interface VideoEmbed {
|
|
276
|
+
provider: EmbedProvider;
|
|
277
|
+
/** Canonical player URL, safe to use as an iframe `src`. */
|
|
278
|
+
src: string;
|
|
279
|
+
/** Page a viewer can open instead (native SDKs show a link rather than a player). */
|
|
280
|
+
watchUrl: string;
|
|
281
|
+
/** Accessible iframe title. */
|
|
282
|
+
title: string;
|
|
283
|
+
}
|
|
284
|
+
declare const MEDIA_IMAGE_TYPES: readonly ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
285
|
+
declare const MEDIA_VIDEO_TYPES: readonly ["video/mp4", "video/webm"];
|
|
286
|
+
type MediaContentType = (typeof MEDIA_IMAGE_TYPES)[number] | (typeof MEDIA_VIDEO_TYPES)[number];
|
|
287
|
+
declare const MEDIA_IMAGE_MAX_BYTES: number;
|
|
288
|
+
declare const MEDIA_VIDEO_MAX_BYTES: number;
|
|
289
|
+
declare function isMediaContentType(type: string): type is MediaContentType;
|
|
290
|
+
declare function isVideoContentType(type: string): boolean;
|
|
291
|
+
declare function mediaMaxBytes(type: string): number;
|
|
292
|
+
/**
|
|
293
|
+
* Turns a pasted video page or player URL from YouTube, Vimeo, Loom or Wistia into its canonical
|
|
294
|
+
* embed. Returns null for anything else, including lookalike hosts.
|
|
295
|
+
*/
|
|
296
|
+
declare function toEmbedUrl(input: string): VideoEmbed | null;
|
|
297
|
+
/** True only for a canonical embed URL (exactly what `toEmbedUrl` returns), so an iframe can't be pointed elsewhere. */
|
|
298
|
+
declare function isAllowedEmbedSrc(src: string | null | undefined): boolean;
|
|
299
|
+
/** Fixed iframe attributes for an embed; sanitizers overwrite whatever the author's HTML carried. */
|
|
300
|
+
declare const EMBED_IFRAME_ATTRS: Readonly<Record<string, string>>;
|
|
301
|
+
/** Fixed `<video>` attributes: player controls, no autoplay or loop. */
|
|
302
|
+
declare const VIDEO_ATTRS: Readonly<Record<string, string>>;
|
|
303
|
+
/** `<video src>` / `poster` must be plain http(s): no data:, blob: or relative URLs (bodies render on customer sites). */
|
|
304
|
+
declare function isSafeMediaUrl(url: string | null | undefined): boolean;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Resource center structure shared by every SDK: nested collections and audience targeting.
|
|
308
|
+
*
|
|
309
|
+
* Audience targeting decides what the help widget lists; it is not access control. The published
|
|
310
|
+
* config (and every article body) is the same for all visitors of an environment, and end-user
|
|
311
|
+
* identities are self-asserted, so never rely on it to keep an article private.
|
|
312
|
+
*/
|
|
313
|
+
/** Collections nest at most this deep (a collection, its sections, and their sub-sections). */
|
|
314
|
+
declare const MAX_COLLECTION_DEPTH = 3;
|
|
315
|
+
interface RcCollectionLike {
|
|
316
|
+
id: string;
|
|
317
|
+
name: string;
|
|
318
|
+
order: number;
|
|
319
|
+
/** Parent collection; null/absent for a top-level collection. */
|
|
320
|
+
parentId?: string | null;
|
|
321
|
+
/** Shown only to members of any of these audiences; empty/absent means everyone. */
|
|
322
|
+
audienceIds?: string[];
|
|
323
|
+
}
|
|
324
|
+
interface RcArticleLike {
|
|
325
|
+
id: string;
|
|
326
|
+
collectionId?: string | null;
|
|
327
|
+
audienceIds?: string[];
|
|
328
|
+
}
|
|
329
|
+
interface RcSection<C extends RcCollectionLike, A extends RcArticleLike> {
|
|
330
|
+
/** null for articles outside any (known) collection. */
|
|
331
|
+
collection: C | null;
|
|
332
|
+
/** Collection names from the top level down, e.g. ["Billing", "Invoices"]. */
|
|
333
|
+
path: string[];
|
|
334
|
+
/** 0 for a top-level collection. */
|
|
335
|
+
depth: number;
|
|
336
|
+
articles: A[];
|
|
337
|
+
}
|
|
338
|
+
type Membership = ReadonlySet<string> | readonly string[] | undefined | null;
|
|
339
|
+
/** True when an item targeted at `required` audiences is shown to someone in `member`. */
|
|
340
|
+
declare function matchesAudiences(required: readonly string[] | undefined | null, member: Membership): boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Article sections in display order: each collection (depth first, siblings by `order`) with the
|
|
343
|
+
* visible articles filed directly in it, then the uncategorized articles. A collection the viewer
|
|
344
|
+
* isn't targeted by hides its whole subtree, and sections without visible articles are left out
|
|
345
|
+
* (their sub-collections still appear). Unknown parents count as top level, so an old config or a
|
|
346
|
+
* dangling reference never hides content.
|
|
347
|
+
*/
|
|
348
|
+
declare function resourceCenterSections<C extends RcCollectionLike, A extends RcArticleLike>(collections: readonly C[], articles: readonly A[], member?: Membership): Array<RcSection<C, A>>;
|
|
349
|
+
/**
|
|
350
|
+
* Whether one article is listed for a viewer: its own audiences and those of every collection above
|
|
351
|
+
* it must match. For articles outside a loaded list (e.g. server search results).
|
|
352
|
+
*/
|
|
353
|
+
declare function isArticleListed(collections: readonly RcCollectionLike[], article: RcArticleLike, member?: Membership): boolean;
|
|
354
|
+
/** Ids of the articles a viewer sees (for filtering server search results the same way). */
|
|
355
|
+
declare function visibleArticleIds(collections: readonly RcCollectionLike[], articles: readonly RcArticleLike[], member?: Membership): Set<string>;
|
|
356
|
+
|
|
357
|
+
export { DEFAULT_PLATFORMS, EMBED_IFRAME_ATTRS, type EmbedProvider, type ExceptionProperties, GUIDELY_ID_ATTRIBUTE, MAX_COLLECTION_DEPTH, MAX_PROPERTY_BYTES, MAX_STACK_FRAMES, MEDIA_IMAGE_MAX_BYTES, MEDIA_IMAGE_TYPES, MEDIA_VIDEO_MAX_BYTES, MEDIA_VIDEO_TYPES, type MediaContentType, NETWORK_PLUGIN, type NetworkPluginPayload, type NetworkRequest, type NetworkRequestType, PLATFORMS, type Platform, RULE_FIELDS, RULE_OPERATORS, type RcArticleLike, type RcCollectionLike, type RcSection, type Rule, type RuleField, type RuleGroup, type RuleOperator, SENSITIVE_HEADER_PATTERN, SENSITIVE_PARAM_PATTERN, SENSITIVE_PROPERTY_PATTERN, SERVER_ASSISTED_FIELDS, SOURCEMAP_MAX_FILES_PER_UPLOAD, SOURCEMAP_MAX_FILE_BYTES, type ShowWhen, type StackFrame, type SurveyAnswer, type SurveyAnswers, type TargetingContext, VIDEO_ATTRS, type VideoEmbed, WS_MAX_MESSAGES_PER_SOCKET, WS_MAX_MESSAGE_BYTES, type WebSocketMessage, clamp, compare, compareVersions, describeRule, emptyRuleGroup, evaluateRule, evaluateRules, fingerprintError, fnv1a, getPath, guidePlatforms, guidelyIdFromSelector, isAllowedEmbedSrc, isArticleListed, isChecklistComplete, isMediaContentType, isPlainObject, isQuestionVisible, isRuleGroup, isSafeMediaUrl, isVideoContentType, matchUrlPattern, matchesAudiences, mediaMaxBytes, normalizeErrorMessage, normalizeFrameFile, parseStack, randomId, resourceCenterSections, rolloutBucket, safeRegExp, sanitizeProperties, screenPath, slugify, stripOrigin, supportsPlatform, toEmbedUrl, visibleArticleIds };
|
package/dist/runtime.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_PLATFORMS,
|
|
3
|
+
EMBED_IFRAME_ATTRS,
|
|
3
4
|
GUIDELY_ID_ATTRIBUTE,
|
|
5
|
+
MAX_COLLECTION_DEPTH,
|
|
4
6
|
MAX_PROPERTY_BYTES,
|
|
5
7
|
MAX_STACK_FRAMES,
|
|
8
|
+
MEDIA_IMAGE_MAX_BYTES,
|
|
9
|
+
MEDIA_IMAGE_TYPES,
|
|
10
|
+
MEDIA_VIDEO_MAX_BYTES,
|
|
11
|
+
MEDIA_VIDEO_TYPES,
|
|
6
12
|
NETWORK_PLUGIN,
|
|
7
13
|
PLATFORMS,
|
|
8
14
|
RULE_FIELDS,
|
|
@@ -13,6 +19,7 @@ import {
|
|
|
13
19
|
SERVER_ASSISTED_FIELDS,
|
|
14
20
|
SOURCEMAP_MAX_FILES_PER_UPLOAD,
|
|
15
21
|
SOURCEMAP_MAX_FILE_BYTES,
|
|
22
|
+
VIDEO_ATTRS,
|
|
16
23
|
WS_MAX_MESSAGES_PER_SOCKET,
|
|
17
24
|
WS_MAX_MESSAGE_BYTES,
|
|
18
25
|
clamp,
|
|
@@ -27,28 +34,44 @@ import {
|
|
|
27
34
|
getPath,
|
|
28
35
|
guidePlatforms,
|
|
29
36
|
guidelyIdFromSelector,
|
|
37
|
+
isAllowedEmbedSrc,
|
|
38
|
+
isArticleListed,
|
|
30
39
|
isChecklistComplete,
|
|
40
|
+
isMediaContentType,
|
|
31
41
|
isPlainObject,
|
|
32
42
|
isQuestionVisible,
|
|
33
43
|
isRuleGroup,
|
|
44
|
+
isSafeMediaUrl,
|
|
45
|
+
isVideoContentType,
|
|
34
46
|
matchUrlPattern,
|
|
47
|
+
matchesAudiences,
|
|
48
|
+
mediaMaxBytes,
|
|
35
49
|
normalizeErrorMessage,
|
|
36
50
|
normalizeFrameFile,
|
|
37
51
|
parseStack,
|
|
38
52
|
randomId,
|
|
53
|
+
resourceCenterSections,
|
|
39
54
|
rolloutBucket,
|
|
40
55
|
safeRegExp,
|
|
41
56
|
sanitizeProperties,
|
|
42
57
|
screenPath,
|
|
43
58
|
slugify,
|
|
44
59
|
stripOrigin,
|
|
45
|
-
supportsPlatform
|
|
46
|
-
|
|
60
|
+
supportsPlatform,
|
|
61
|
+
toEmbedUrl,
|
|
62
|
+
visibleArticleIds
|
|
63
|
+
} from "./chunk-5IQVBZO6.js";
|
|
47
64
|
export {
|
|
48
65
|
DEFAULT_PLATFORMS,
|
|
66
|
+
EMBED_IFRAME_ATTRS,
|
|
49
67
|
GUIDELY_ID_ATTRIBUTE,
|
|
68
|
+
MAX_COLLECTION_DEPTH,
|
|
50
69
|
MAX_PROPERTY_BYTES,
|
|
51
70
|
MAX_STACK_FRAMES,
|
|
71
|
+
MEDIA_IMAGE_MAX_BYTES,
|
|
72
|
+
MEDIA_IMAGE_TYPES,
|
|
73
|
+
MEDIA_VIDEO_MAX_BYTES,
|
|
74
|
+
MEDIA_VIDEO_TYPES,
|
|
52
75
|
NETWORK_PLUGIN,
|
|
53
76
|
PLATFORMS,
|
|
54
77
|
RULE_FIELDS,
|
|
@@ -59,6 +82,7 @@ export {
|
|
|
59
82
|
SERVER_ASSISTED_FIELDS,
|
|
60
83
|
SOURCEMAP_MAX_FILES_PER_UPLOAD,
|
|
61
84
|
SOURCEMAP_MAX_FILE_BYTES,
|
|
85
|
+
VIDEO_ATTRS,
|
|
62
86
|
WS_MAX_MESSAGES_PER_SOCKET,
|
|
63
87
|
WS_MAX_MESSAGE_BYTES,
|
|
64
88
|
clamp,
|
|
@@ -73,21 +97,31 @@ export {
|
|
|
73
97
|
getPath,
|
|
74
98
|
guidePlatforms,
|
|
75
99
|
guidelyIdFromSelector,
|
|
100
|
+
isAllowedEmbedSrc,
|
|
101
|
+
isArticleListed,
|
|
76
102
|
isChecklistComplete,
|
|
103
|
+
isMediaContentType,
|
|
77
104
|
isPlainObject,
|
|
78
105
|
isQuestionVisible,
|
|
79
106
|
isRuleGroup,
|
|
107
|
+
isSafeMediaUrl,
|
|
108
|
+
isVideoContentType,
|
|
80
109
|
matchUrlPattern,
|
|
110
|
+
matchesAudiences,
|
|
111
|
+
mediaMaxBytes,
|
|
81
112
|
normalizeErrorMessage,
|
|
82
113
|
normalizeFrameFile,
|
|
83
114
|
parseStack,
|
|
84
115
|
randomId,
|
|
116
|
+
resourceCenterSections,
|
|
85
117
|
rolloutBucket,
|
|
86
118
|
safeRegExp,
|
|
87
119
|
sanitizeProperties,
|
|
88
120
|
screenPath,
|
|
89
121
|
slugify,
|
|
90
122
|
stripOrigin,
|
|
91
|
-
supportsPlatform
|
|
123
|
+
supportsPlatform,
|
|
124
|
+
toEmbedUrl,
|
|
125
|
+
visibleArticleIds
|
|
92
126
|
};
|
|
93
127
|
//# sourceMappingURL=runtime.js.map
|