@guidelytech/sdk-core 0.1.0 → 0.2.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/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _guidelytech_guide_runtime from '@guidelytech/guide-runtime';
2
- import { PublishedGuide, FrequencyConfig, ProjectTheme, SdkConfigResponse, ChecklistTask, SdkEvent, TargetingContext, SelectorStrategy, AuthoringPick } from '@guidelytech/shared';
3
- export { GuideConfig, GuideStep, PublishedGuide, SdkConfigResponse, SdkEvent, TargetingContext } from '@guidelytech/shared';
2
+ import { PublishedGuide, FrequencyConfig, ProjectTheme, SdkConfigResponse, ChecklistTask, MessengerMessage, MessengerConversation, SdkEvent, TargetingContext, SelectorStrategy, AuthoringPick, AppSnapshot } from '@guidelytech/shared';
3
+ export { AppSnapshot, GuideConfig, GuideStep, PublishedGuide, SdkConfigResponse, SdkEvent, TargetingContext } from '@guidelytech/shared';
4
+ import { MessengerTab } from '@guidelytech/guide-runtime/messenger';
4
5
 
5
6
  /** Per-guide state kept locally and merged with the server's `IdentifyResponse.guideState`. */
6
7
  interface GuideLocalState {
@@ -50,6 +51,8 @@ declare const KEYS: {
50
51
  readonly session: "guidely:session";
51
52
  readonly active: "guidely:active";
52
53
  readonly authoring: "guidely:authoring";
54
+ /** Messenger conversations this browser can read: [{ id, token }]. */
55
+ readonly conversations: (key: string) => string;
53
56
  };
54
57
 
55
58
  type GuidelyEnvironment = "development" | "staging" | "production";
@@ -139,6 +142,12 @@ interface GuidelyEvents {
139
142
  responseId: string;
140
143
  }) => void;
141
144
  "resource-center:open": () => void;
145
+ "messenger:open": () => void;
146
+ /** A Scout or teammate message arrived in the messenger. */
147
+ "conversation:message": (info: {
148
+ message: MessengerMessage;
149
+ conversation: MessengerConversation;
150
+ }) => void;
142
151
  error: (error: Error) => void;
143
152
  /** Every tracked event (custom and lifecycle). */
144
153
  track: (event: SdkEvent) => void;
@@ -153,7 +162,7 @@ interface GuidelyEvents {
153
162
  type GuidelyEventName = keyof GuidelyEvents;
154
163
 
155
164
  declare const SDK_NAME = "@guidelytech/sdk-core";
156
- declare const SDK_VERSION = "0.1.0";
165
+ declare const SDK_VERSION = "0.2.0";
157
166
  declare const DEFAULT_API_URL = "https://api.guidely.app";
158
167
  /**
159
168
  * Framework-independent Guidely client. Create one per page with {@link createGuidely} or
@@ -182,6 +191,9 @@ declare class GuidelyClient {
182
191
  private widgets;
183
192
  private resourceCenter;
184
193
  private resourceCenterScope;
194
+ private messenger;
195
+ private messengerScope;
196
+ private messengerLoading;
185
197
  private cleanups;
186
198
  private timers;
187
199
  private visibilityObservers;
@@ -190,6 +202,8 @@ declare class GuidelyClient {
190
202
  private lastUrl;
191
203
  private authoring;
192
204
  private lastAudiences;
205
+ /** Set once the app calls identify()/reset(); bootstrap then leaves identity alone instead of re-identifying. */
206
+ private identitySettled;
193
207
  constructor(options: GuidelyOptions);
194
208
  /** Loads config (cache first, then network), wires listeners and evaluates triggers. Idempotent. */
195
209
  init(): Promise<void>;
@@ -249,6 +263,10 @@ declare class GuidelyClient {
249
263
  private navigate;
250
264
  private renderPersistentWidgets;
251
265
  private resumeActiveGuide;
266
+ /** Loads the messenger widget on demand (it is a separate chunk) and renders it. */
267
+ private loadMessenger;
268
+ private destroyMessenger;
269
+ private loadArticle;
252
270
  private searchResourceCenter;
253
271
  /** Current progress for a checklist guide (by id or key). */
254
272
  getChecklistProgress(idOrKey: string): ChecklistProgressState;
@@ -275,6 +293,11 @@ declare class GuidelyClient {
275
293
  isGuideCompleted(idOrKey: string): boolean;
276
294
  openResourceCenter(): void;
277
295
  closeResourceCenter(): void;
296
+ /** Opens the Scout messenger (when enabled for the project), optionally on a tab. */
297
+ openMessenger(tab?: MessengerTab): void;
298
+ closeMessenger(): void;
299
+ /** Opens a new messenger conversation, optionally pre-filling the message. */
300
+ showNewMessage(text?: string): void;
278
301
  on<K extends keyof GuidelyEvents>(event: K, cb: GuidelyEvents[K]): () => void;
279
302
  off<K extends keyof GuidelyEvents>(event: K, cb: GuidelyEvents[K]): void;
280
303
  /** Snapshot for debugging / devtools. */
@@ -436,6 +459,10 @@ type AuthoringOutgoingMessage = {
436
459
  type: "guidely:pong";
437
460
  sessionId: string;
438
461
  url: string;
462
+ } | {
463
+ type: "guidely:snapshot";
464
+ sessionId: string;
465
+ snapshot: AppSnapshot;
439
466
  };
440
467
  /** Messages the dashboard may post to the app window (origin-checked against `dashboardOrigin`). */
441
468
  type AuthoringIncomingMessage = {
@@ -460,10 +487,20 @@ type AuthoringIncomingMessage = {
460
487
  type: "guidely:stop-preview";
461
488
  } | {
462
489
  type: "guidely:ping";
490
+ } | {
491
+ type: "guidely:request-snapshot";
463
492
  } | {
464
493
  type: "guidely:exit";
465
494
  };
466
495
 
496
+ /**
497
+ * Serializes the current page into a static HTML document for the dashboard's editor canvas.
498
+ * Scripts, event handlers, Guidely's own UI and form values are dropped; `maskSelectors` text is
499
+ * replaced with bullets. Same-origin CSSOM rules are inlined; everything else resolves through a
500
+ * `<base href>` so stylesheets and images load from the app.
501
+ */
502
+ declare function captureSnapshot(doc: Document, maskSelectors: string[], maxBytes?: number): AppSnapshot | null;
503
+
467
504
  /**
468
505
  * @guidelytech/sdk-core — framework-independent Guidely browser SDK.
469
506
  *
@@ -479,4 +516,4 @@ declare const Guidely: {
479
516
  version: string;
480
517
  };
481
518
 
482
- export { AUTHORING_PARAM, type AuthoringIncomingMessage, type AuthoringOutgoingMessage, type ChecklistProgressState, type ConsentState, type ContextInput, DEFAULT_API_URL, type DeviceInfo, EventQueue, type EventQueueOptions, type GuideLocalState, type GuideStepInfo, Guidely, type GuidelyAccount, GuidelyClient, type GuidelyEnvironment, type GuidelyEventName, type GuidelyEvents, type GuidelyOptions, type GuidelyUser, HEARTBEAT_MS, KEYS, type KeyValueStore, type PersistedState, SDK_NAME, SDK_VERSION, type SessionState, type StorageKind, areMutuallyExclusive, buildContext, createGuidely, createStorage, Guidely as default, detectDevice, isExclusiveGuide, isFrequencyEligible, isWithinSchedule, watchNavigation };
519
+ export { AUTHORING_PARAM, type AuthoringIncomingMessage, type AuthoringOutgoingMessage, type ChecklistProgressState, type ConsentState, type ContextInput, DEFAULT_API_URL, type DeviceInfo, EventQueue, type EventQueueOptions, type GuideLocalState, type GuideStepInfo, Guidely, type GuidelyAccount, GuidelyClient, type GuidelyEnvironment, type GuidelyEventName, type GuidelyEvents, type GuidelyOptions, type GuidelyUser, HEARTBEAT_MS, KEYS, type KeyValueStore, type PersistedState, SDK_NAME, SDK_VERSION, type SessionState, type StorageKind, areMutuallyExclusive, buildContext, captureSnapshot, createGuidely, createStorage, Guidely as default, detectDevice, isExclusiveGuide, isFrequencyEligible, isWithinSchedule, watchNavigation };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _guidelytech_guide_runtime from '@guidelytech/guide-runtime';
2
- import { PublishedGuide, FrequencyConfig, ProjectTheme, SdkConfigResponse, ChecklistTask, SdkEvent, TargetingContext, SelectorStrategy, AuthoringPick } from '@guidelytech/shared';
3
- export { GuideConfig, GuideStep, PublishedGuide, SdkConfigResponse, SdkEvent, TargetingContext } from '@guidelytech/shared';
2
+ import { PublishedGuide, FrequencyConfig, ProjectTheme, SdkConfigResponse, ChecklistTask, MessengerMessage, MessengerConversation, SdkEvent, TargetingContext, SelectorStrategy, AuthoringPick, AppSnapshot } from '@guidelytech/shared';
3
+ export { AppSnapshot, GuideConfig, GuideStep, PublishedGuide, SdkConfigResponse, SdkEvent, TargetingContext } from '@guidelytech/shared';
4
+ import { MessengerTab } from '@guidelytech/guide-runtime/messenger';
4
5
 
5
6
  /** Per-guide state kept locally and merged with the server's `IdentifyResponse.guideState`. */
6
7
  interface GuideLocalState {
@@ -50,6 +51,8 @@ declare const KEYS: {
50
51
  readonly session: "guidely:session";
51
52
  readonly active: "guidely:active";
52
53
  readonly authoring: "guidely:authoring";
54
+ /** Messenger conversations this browser can read: [{ id, token }]. */
55
+ readonly conversations: (key: string) => string;
53
56
  };
54
57
 
55
58
  type GuidelyEnvironment = "development" | "staging" | "production";
@@ -139,6 +142,12 @@ interface GuidelyEvents {
139
142
  responseId: string;
140
143
  }) => void;
141
144
  "resource-center:open": () => void;
145
+ "messenger:open": () => void;
146
+ /** A Scout or teammate message arrived in the messenger. */
147
+ "conversation:message": (info: {
148
+ message: MessengerMessage;
149
+ conversation: MessengerConversation;
150
+ }) => void;
142
151
  error: (error: Error) => void;
143
152
  /** Every tracked event (custom and lifecycle). */
144
153
  track: (event: SdkEvent) => void;
@@ -153,7 +162,7 @@ interface GuidelyEvents {
153
162
  type GuidelyEventName = keyof GuidelyEvents;
154
163
 
155
164
  declare const SDK_NAME = "@guidelytech/sdk-core";
156
- declare const SDK_VERSION = "0.1.0";
165
+ declare const SDK_VERSION = "0.2.0";
157
166
  declare const DEFAULT_API_URL = "https://api.guidely.app";
158
167
  /**
159
168
  * Framework-independent Guidely client. Create one per page with {@link createGuidely} or
@@ -182,6 +191,9 @@ declare class GuidelyClient {
182
191
  private widgets;
183
192
  private resourceCenter;
184
193
  private resourceCenterScope;
194
+ private messenger;
195
+ private messengerScope;
196
+ private messengerLoading;
185
197
  private cleanups;
186
198
  private timers;
187
199
  private visibilityObservers;
@@ -190,6 +202,8 @@ declare class GuidelyClient {
190
202
  private lastUrl;
191
203
  private authoring;
192
204
  private lastAudiences;
205
+ /** Set once the app calls identify()/reset(); bootstrap then leaves identity alone instead of re-identifying. */
206
+ private identitySettled;
193
207
  constructor(options: GuidelyOptions);
194
208
  /** Loads config (cache first, then network), wires listeners and evaluates triggers. Idempotent. */
195
209
  init(): Promise<void>;
@@ -249,6 +263,10 @@ declare class GuidelyClient {
249
263
  private navigate;
250
264
  private renderPersistentWidgets;
251
265
  private resumeActiveGuide;
266
+ /** Loads the messenger widget on demand (it is a separate chunk) and renders it. */
267
+ private loadMessenger;
268
+ private destroyMessenger;
269
+ private loadArticle;
252
270
  private searchResourceCenter;
253
271
  /** Current progress for a checklist guide (by id or key). */
254
272
  getChecklistProgress(idOrKey: string): ChecklistProgressState;
@@ -275,6 +293,11 @@ declare class GuidelyClient {
275
293
  isGuideCompleted(idOrKey: string): boolean;
276
294
  openResourceCenter(): void;
277
295
  closeResourceCenter(): void;
296
+ /** Opens the Scout messenger (when enabled for the project), optionally on a tab. */
297
+ openMessenger(tab?: MessengerTab): void;
298
+ closeMessenger(): void;
299
+ /** Opens a new messenger conversation, optionally pre-filling the message. */
300
+ showNewMessage(text?: string): void;
278
301
  on<K extends keyof GuidelyEvents>(event: K, cb: GuidelyEvents[K]): () => void;
279
302
  off<K extends keyof GuidelyEvents>(event: K, cb: GuidelyEvents[K]): void;
280
303
  /** Snapshot for debugging / devtools. */
@@ -436,6 +459,10 @@ type AuthoringOutgoingMessage = {
436
459
  type: "guidely:pong";
437
460
  sessionId: string;
438
461
  url: string;
462
+ } | {
463
+ type: "guidely:snapshot";
464
+ sessionId: string;
465
+ snapshot: AppSnapshot;
439
466
  };
440
467
  /** Messages the dashboard may post to the app window (origin-checked against `dashboardOrigin`). */
441
468
  type AuthoringIncomingMessage = {
@@ -460,10 +487,20 @@ type AuthoringIncomingMessage = {
460
487
  type: "guidely:stop-preview";
461
488
  } | {
462
489
  type: "guidely:ping";
490
+ } | {
491
+ type: "guidely:request-snapshot";
463
492
  } | {
464
493
  type: "guidely:exit";
465
494
  };
466
495
 
496
+ /**
497
+ * Serializes the current page into a static HTML document for the dashboard's editor canvas.
498
+ * Scripts, event handlers, Guidely's own UI and form values are dropped; `maskSelectors` text is
499
+ * replaced with bullets. Same-origin CSSOM rules are inlined; everything else resolves through a
500
+ * `<base href>` so stylesheets and images load from the app.
501
+ */
502
+ declare function captureSnapshot(doc: Document, maskSelectors: string[], maxBytes?: number): AppSnapshot | null;
503
+
467
504
  /**
468
505
  * @guidelytech/sdk-core — framework-independent Guidely browser SDK.
469
506
  *
@@ -479,4 +516,4 @@ declare const Guidely: {
479
516
  version: string;
480
517
  };
481
518
 
482
- export { AUTHORING_PARAM, type AuthoringIncomingMessage, type AuthoringOutgoingMessage, type ChecklistProgressState, type ConsentState, type ContextInput, DEFAULT_API_URL, type DeviceInfo, EventQueue, type EventQueueOptions, type GuideLocalState, type GuideStepInfo, Guidely, type GuidelyAccount, GuidelyClient, type GuidelyEnvironment, type GuidelyEventName, type GuidelyEvents, type GuidelyOptions, type GuidelyUser, HEARTBEAT_MS, KEYS, type KeyValueStore, type PersistedState, SDK_NAME, SDK_VERSION, type SessionState, type StorageKind, areMutuallyExclusive, buildContext, createGuidely, createStorage, Guidely as default, detectDevice, isExclusiveGuide, isFrequencyEligible, isWithinSchedule, watchNavigation };
519
+ export { AUTHORING_PARAM, type AuthoringIncomingMessage, type AuthoringOutgoingMessage, type ChecklistProgressState, type ConsentState, type ContextInput, DEFAULT_API_URL, type DeviceInfo, EventQueue, type EventQueueOptions, type GuideLocalState, type GuideStepInfo, Guidely, type GuidelyAccount, GuidelyClient, type GuidelyEnvironment, type GuidelyEventName, type GuidelyEvents, type GuidelyOptions, type GuidelyUser, HEARTBEAT_MS, KEYS, type KeyValueStore, type PersistedState, SDK_NAME, SDK_VERSION, type SessionState, type StorageKind, areMutuallyExclusive, buildContext, captureSnapshot, createGuidely, createStorage, Guidely as default, detectDevice, isExclusiveGuide, isFrequencyEligible, isWithinSchedule, watchNavigation };