@proveanything/smartlinks 2.1.28 → 2.1.30
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/api/translations.d.ts +15 -0
- package/dist/api/translations.js +34 -2
- package/dist/docs/API_SUMMARY.md +19 -10
- package/dist/docs/translations.md +20 -0
- package/dist/iframeResponder.js +26 -2
- package/dist/index.d.ts +1 -0
- package/dist/openapi.yaml +0 -8
- package/dist/translationActivity.d.ts +40 -0
- package/dist/translationActivity.js +212 -0
- package/dist/types/broadcasts.d.ts +2 -4
- package/dist/types/comms.d.ts +1 -4
- package/dist/types/contact.d.ts +0 -1
- package/docs/API_SUMMARY.md +19 -10
- package/docs/translations.md +20 -0
- package/openapi.yaml +0 -8
- package/package.json +1 -1
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import type { TranslationActivity } from '../translationActivity.js';
|
|
1
2
|
import type { ResolvedTranslationResponse, TranslationHashOptions, TranslationListParams, TranslationListResponse, TranslationLookupRequest, TranslationLookupResponse, TranslationRecord, TranslationResolveOptions, TranslationUpdateRequest } from '../types/translations.js';
|
|
2
3
|
export declare namespace translations {
|
|
3
4
|
function hashText(text: string, options?: TranslationHashOptions): Promise<string>;
|
|
4
5
|
function hashTexts(texts: string[], options?: TranslationHashOptions): Promise<string[]>;
|
|
5
6
|
function normalizeText(text: string, options?: TranslationHashOptions): string;
|
|
6
7
|
function lookup(collectionId: string, body: TranslationLookupRequest): Promise<TranslationLookupResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Hear when content is being translated for the first time, in this window or in any app frame
|
|
10
|
+
* it embeds. Hosts use it to show a "translating this page" notice; apps never have to.
|
|
11
|
+
* Returns an unsubscribe function.
|
|
12
|
+
*/
|
|
13
|
+
function onActivity(cb: (activity: TranslationActivity) => void): () => void;
|
|
14
|
+
/** The "translating this page" line, in the language being translated into (for a host's banner). */
|
|
15
|
+
function translatingMessage(language: string | null | undefined): {
|
|
16
|
+
text: string;
|
|
17
|
+
lang: string;
|
|
18
|
+
dir: 'ltr' | 'rtl';
|
|
19
|
+
};
|
|
20
|
+
/** Whether a first-time translation is under way right now (see onActivity). */
|
|
21
|
+
function activity(): TranslationActivity;
|
|
7
22
|
function resolve(collectionId: string, body: TranslationLookupRequest, options?: TranslationResolveOptions): Promise<ResolvedTranslationResponse>;
|
|
8
23
|
function list(collectionId: string, params?: TranslationListParams): Promise<TranslationListResponse>;
|
|
9
24
|
function get(collectionId: string, translationId: string): Promise<TranslationRecord>;
|
package/dist/api/translations.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { patch, post, request } from '../http.js';
|
|
1
|
+
import { isProxyEnabled, patch, post, request } from '../http.js';
|
|
2
2
|
import { clearCachedTranslations, deriveTranslationContextKey, getCachedTranslations, getDefaultTranslationCacheTtlMs, hashTranslationText, normalizeTranslationText, setCachedTranslations, } from '../translationCache.js';
|
|
3
|
+
import { trackTranslation, onActivity as onTranslationActivity, activity as translationActivity, translatingMessage as translatingLine } from '../translationActivity.js';
|
|
3
4
|
function normalizeLookupRequest(body) {
|
|
4
5
|
var _a, _b, _c;
|
|
5
6
|
const texts = Array.isArray(body.texts)
|
|
@@ -65,9 +66,40 @@ export var translations;
|
|
|
65
66
|
async function lookup(collectionId, body) {
|
|
66
67
|
const path = `/public/collection/${encodeURIComponent(collectionId)}/translations/lookup`;
|
|
67
68
|
const normalized = normalizeLookupRequest(body);
|
|
68
|
-
|
|
69
|
+
// A request that may create translations can take a while the first time: say so, so a host
|
|
70
|
+
// (Portal, Hub) can show "translating…" without the app doing anything (translationActivity.ts).
|
|
71
|
+
// Through the parent (proxyMode), the host's IframeResponder counts it instead, so apps built on
|
|
72
|
+
// older SDKs are covered too and nothing is counted twice.
|
|
73
|
+
const settle = normalized.mode === 'cache-fill' && !isProxyEnabled() && !sameLanguage(normalized.sourceLanguage, normalized.targetLanguage)
|
|
74
|
+
? trackTranslation(normalized.targetLanguage, normalized.texts.length)
|
|
75
|
+
: null;
|
|
76
|
+
try {
|
|
77
|
+
return await post(path, normalized.requestBody);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
settle === null || settle === void 0 ? void 0 : settle();
|
|
81
|
+
}
|
|
69
82
|
}
|
|
70
83
|
translations.lookup = lookup;
|
|
84
|
+
/**
|
|
85
|
+
* Hear when content is being translated for the first time, in this window or in any app frame
|
|
86
|
+
* it embeds. Hosts use it to show a "translating this page" notice; apps never have to.
|
|
87
|
+
* Returns an unsubscribe function.
|
|
88
|
+
*/
|
|
89
|
+
function onActivity(cb) {
|
|
90
|
+
return onTranslationActivity(cb);
|
|
91
|
+
}
|
|
92
|
+
translations.onActivity = onActivity;
|
|
93
|
+
/** The "translating this page" line, in the language being translated into (for a host's banner). */
|
|
94
|
+
function translatingMessage(language) {
|
|
95
|
+
return translatingLine(language);
|
|
96
|
+
}
|
|
97
|
+
translations.translatingMessage = translatingMessage;
|
|
98
|
+
/** Whether a first-time translation is under way right now (see onActivity). */
|
|
99
|
+
function activity() {
|
|
100
|
+
return translationActivity();
|
|
101
|
+
}
|
|
102
|
+
translations.activity = activity;
|
|
71
103
|
async function resolve(collectionId, body, options = {}) {
|
|
72
104
|
var _a, _b, _c;
|
|
73
105
|
const normalized = normalizeLookupRequest(body);
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.30 | Generated: 2026-11-20T10:29:26.751Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -6041,7 +6041,7 @@ interface BroadcastAppendBulkBody {
|
|
|
6041
6041
|
}
|
|
6042
6042
|
```
|
|
6043
6043
|
|
|
6044
|
-
**BroadcastChannel** = `'email' | 'push' | 'sms'
|
|
6044
|
+
**BroadcastChannel** = `'email' | 'push' | 'sms'`
|
|
6045
6045
|
|
|
6046
6046
|
**BroadcastPreviewResponse** = ``
|
|
6047
6047
|
|
|
@@ -6932,7 +6932,7 @@ interface RegisterMethodResponse {
|
|
|
6932
6932
|
```typescript
|
|
6933
6933
|
interface SubscriptionsResolveRequest {
|
|
6934
6934
|
subject: { type: SubjectType; id: string; productId?: string }
|
|
6935
|
-
hints: { userId?: string; pushEndpoint?: string; email?: string
|
|
6935
|
+
hints: { userId?: string; pushEndpoint?: string; email?: string }
|
|
6936
6936
|
}
|
|
6937
6937
|
```
|
|
6938
6938
|
|
|
@@ -6945,11 +6945,9 @@ interface SubscriptionsResolveResponse {
|
|
|
6945
6945
|
contactId: string
|
|
6946
6946
|
subscribed: boolean
|
|
6947
6947
|
channels?: Partial<Record<BroadcastChannel, boolean>>
|
|
6948
|
-
walletForSubject?: boolean
|
|
6949
6948
|
}>
|
|
6950
6949
|
anySubscribed: boolean
|
|
6951
6950
|
anyMethods: boolean
|
|
6952
|
-
anyWalletForSubject: boolean
|
|
6953
6951
|
}
|
|
6954
6952
|
```
|
|
6955
6953
|
|
|
@@ -7293,7 +7291,7 @@ export interface RegisterMethodResponse { ok: true; contactId: string }
|
|
|
7293
7291
|
|
|
7294
7292
|
export interface SubscriptionsResolveRequest {
|
|
7295
7293
|
subject: { type: SubjectType; id: string; productId?: string }
|
|
7296
|
-
hints: { userId?: string; pushEndpoint?: string; email?: string
|
|
7294
|
+
hints: { userId?: string; pushEndpoint?: string; email?: string }
|
|
7297
7295
|
}
|
|
7298
7296
|
export interface SubscriptionsResolveResponse {
|
|
7299
7297
|
ok: true
|
|
@@ -7302,11 +7300,9 @@ export interface SubscriptionsResolveResponse {
|
|
|
7302
7300
|
contactId: string
|
|
7303
7301
|
subscribed: boolean
|
|
7304
7302
|
channels?: Partial<Record<BroadcastChannel, boolean>>
|
|
7305
|
-
walletForSubject?: boolean
|
|
7306
7303
|
}>
|
|
7307
7304
|
anySubscribed: boolean
|
|
7308
7305
|
anyMethods: boolean
|
|
7309
|
-
anyWalletForSubject: boolean
|
|
7310
7306
|
}
|
|
7311
7307
|
|
|
7312
7308
|
// Transactional send (single-contact, single-message)
|
|
@@ -7434,7 +7430,7 @@ export interface TransactionalSendError {
|
|
|
7434
7430
|
* - `transactional.phone_missing`
|
|
7435
7431
|
* - `transactional.whatsapp_missing`
|
|
7436
7432
|
* - `transactional.no_push_methods`
|
|
7437
|
-
* - `transactional.
|
|
7433
|
+
* - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
|
|
7438
7434
|
* - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
|
|
7439
7435
|
* - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
|
|
7440
7436
|
*/
|
|
@@ -7693,7 +7689,6 @@ interface CommMethodMeta {
|
|
|
7693
7689
|
auth?: string
|
|
7694
7690
|
phone?: string
|
|
7695
7691
|
email?: string
|
|
7696
|
-
walletObjectId?: string
|
|
7697
7692
|
subjectType?: SubjectType
|
|
7698
7693
|
subjectId?: string
|
|
7699
7694
|
productId?: string
|
|
@@ -15505,21 +15500,35 @@ Invoke ONE built-in server tool directly — no model in the loop. This is the "
|
|
|
15505
15500
|
**lookup**(collectionId: string,
|
|
15506
15501
|
body: TranslationLookupRequest) → `Promise<TranslationLookupResponse>`
|
|
15507
15502
|
|
|
15503
|
+
**onActivity**(cb: (activity: TranslationActivity) → `void`
|
|
15504
|
+
Hear when content is being translated for the first time, in this window or in any app frame it embeds. Hosts use it to show a "translating this page" notice; apps never have to. Returns an unsubscribe function.
|
|
15505
|
+
|
|
15506
|
+
**translatingMessage**(language: string | null | undefined) → ``
|
|
15507
|
+
The "translating this page" line, in the language being translated into (for a host's banner).
|
|
15508
|
+
|
|
15509
|
+
**activity**() → `TranslationActivity`
|
|
15510
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15511
|
+
|
|
15508
15512
|
**resolve**(collectionId: string,
|
|
15509
15513
|
body: TranslationLookupRequest,
|
|
15510
15514
|
options: TranslationResolveOptions = {}) → `Promise<ResolvedTranslationResponse>`
|
|
15515
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15511
15516
|
|
|
15512
15517
|
**list**(collectionId: string,
|
|
15513
15518
|
params?: TranslationListParams) → `Promise<TranslationListResponse>`
|
|
15519
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15514
15520
|
|
|
15515
15521
|
**get**(collectionId: string,
|
|
15516
15522
|
translationId: string) → `Promise<TranslationRecord>`
|
|
15523
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15517
15524
|
|
|
15518
15525
|
**update**(collectionId: string,
|
|
15519
15526
|
translationId: string,
|
|
15520
15527
|
body: TranslationUpdateRequest) → `Promise<TranslationRecord>`
|
|
15528
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15521
15529
|
|
|
15522
15530
|
**clearLocalCache**(collectionId?: string) → `Promise<void>`
|
|
15531
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15523
15532
|
|
|
15524
15533
|
### tts
|
|
15525
15534
|
|
|
@@ -253,6 +253,26 @@ await translations.resolve('collection-123', {
|
|
|
253
253
|
|
|
254
254
|
The SDK derives a deterministic local cache key from `context` so browser-local entries do not collide across different UI surfaces.
|
|
255
255
|
|
|
256
|
+
## "Translating this page" notice (hosts)
|
|
257
|
+
|
|
258
|
+
The first visitor to see content in a new language waits while it is translated. Apps do not need
|
|
259
|
+
to show anything for this: when a `cache-fill` request is still unanswered after about 0.6 s, the
|
|
260
|
+
SDK announces it, and announces again when it settles. Inside a frame it posts
|
|
261
|
+
`{ _smartlinksIframeMessage: true, type: 'smartlinks:translating', payload: { active, targetLanguage, texts } }`
|
|
262
|
+
to the parent. Already-translated content answers well inside the delay, so nothing is announced.
|
|
263
|
+
|
|
264
|
+
Portal and Hub listen once and show a banner:
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
const stop = translations.onActivity(({ active, targetLanguage, texts }) => {
|
|
268
|
+
setBanner(active ? targetLanguage : null)
|
|
269
|
+
})
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`onActivity` combines this window's own requests with those of every embedded app frame.
|
|
273
|
+
`translations.activity()` returns the state right now. An app that wants its own spinner can use the
|
|
274
|
+
same call.
|
|
275
|
+
|
|
256
276
|
## Hashing Helpers
|
|
257
277
|
|
|
258
278
|
The SDK also exposes the normalization and hashing helpers used by the local cache flow.
|
package/dist/iframeResponder.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import * as cache from './cache.js';
|
|
5
5
|
import { collection } from './api/collection.js';
|
|
6
6
|
import { getBaseURL, hasAuthCredentials } from './http.js';
|
|
7
|
+
import { trackTranslation } from './translationActivity.js';
|
|
7
8
|
/**
|
|
8
9
|
* Parent-side iframe responder for SmartLinks microapp embedding.
|
|
9
10
|
*
|
|
@@ -540,8 +541,17 @@ export class IframeResponder {
|
|
|
540
541
|
fetchOptions.body = JSON.stringify(proxyData.body);
|
|
541
542
|
fetchOptions.headers = Object.assign(Object.assign({}, fetchOptions.headers), { 'Content-Type': 'application/json' });
|
|
542
543
|
}
|
|
543
|
-
|
|
544
|
-
const
|
|
544
|
+
// An app's content translation: let the host show "translating this page" while it runs.
|
|
545
|
+
const settleTranslation = translationLookupTarget(proxyData.method, path, proxyData.body);
|
|
546
|
+
let fetchResponse;
|
|
547
|
+
let responseData;
|
|
548
|
+
try {
|
|
549
|
+
fetchResponse = await fetch(fullUrl, fetchOptions);
|
|
550
|
+
responseData = await fetchResponse.json().catch(() => null);
|
|
551
|
+
}
|
|
552
|
+
finally {
|
|
553
|
+
settleTranslation === null || settleTranslation === void 0 ? void 0 : settleTranslation();
|
|
554
|
+
}
|
|
545
555
|
if (!fetchResponse.ok) {
|
|
546
556
|
response.error = (responseData === null || responseData === void 0 ? void 0 : responseData.message) || (responseData === null || responseData === void 0 ? void 0 : responseData.errorText) || `Request failed with status ${fetchResponse.status}`;
|
|
547
557
|
response.statusCode = fetchResponse.status;
|
|
@@ -871,3 +881,17 @@ export function buildIframeSrc(options) {
|
|
|
871
881
|
path = '/' + path;
|
|
872
882
|
return `${base}/#${path}?${params.toString()}`.replace('/#/?', '/#?').replace('/#/', '/#/');
|
|
873
883
|
}
|
|
884
|
+
/** A proxied translations lookup that may create translations: start counting it (translationActivity.ts). */
|
|
885
|
+
function translationLookupTarget(method, path, body) {
|
|
886
|
+
if (String(method).toUpperCase() !== 'POST' || !/\/translations\/lookup(\?|$)/.test(path))
|
|
887
|
+
return null;
|
|
888
|
+
if (!body || typeof body !== 'object' || typeof body.targetLanguage !== 'string')
|
|
889
|
+
return null;
|
|
890
|
+
if (body.mode === 'cache-only')
|
|
891
|
+
return null;
|
|
892
|
+
const source = typeof body.sourceLanguage === 'string' ? body.sourceLanguage : 'en';
|
|
893
|
+
if (source.trim().toLowerCase() === body.targetLanguage.trim().toLowerCase())
|
|
894
|
+
return null;
|
|
895
|
+
const texts = Array.isArray(body.texts) ? body.texts.length : typeof body.text === 'string' ? 1 : 0;
|
|
896
|
+
return trackTranslation(body.targetLanguage, texts);
|
|
897
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export type { BroadcastSendRequest } from "./types/broadcasts.js";
|
|
|
36
36
|
export type { AppConfigOptions } from "./api/appConfiguration.js";
|
|
37
37
|
export type { AdditionalGtin, ISODateString, JsonPrimitive, JsonValue, ProductCreateRequest, ProductClaimCreateInput, ProductClaimCreateRequestBody, ProductClaimLookupInput, ProductFacetMap, ProductFacetValue, ProductImageUrlInput, ProductKey, ProductQueryRequest, ProductQueryResponse, ProductUpdateRequest, Product, ProductWriteInput, PublicProduct, } from "./types/product.js";
|
|
38
38
|
export type { TranslationLookupMode, TranslationContentType, TranslationQuality, TranslationItemStatus, TranslationContextValue, TranslationContext, TranslationLookupRequestBase, TranslationLookupSingleRequest, TranslationLookupBatchRequest, TranslationLookupRequest, TranslationLookupItem, TranslationLookupResponse, ResolvedTranslationItem, ResolvedTranslationResponse, TranslationHashOptions, TranslationResolveOptions, TranslationRecord, TranslationListParams, TranslationListResponse, TranslationUpdateRequest, } from "./types/translations.js";
|
|
39
|
+
export type { TranslationActivity } from "./translationActivity.js";
|
|
39
40
|
export type { FacetBucket, FacetDefinition, FacetDefinitionWriteInput, FacetGetParams, FacetListParams, FacetListResponse, FacetNamespaceListResponse, FacetQueryRequest, FacetQueryResponse, FacetValue, FacetValueDefinition, FacetValueGetParams, FacetValueListParams, FacetValueListResponse, FacetValueResponse, FacetValueWriteInput, PublicFacetListParams, } from "./types/facets.js";
|
|
40
41
|
export type { Collection, CollectionResponse, CollectionCreateRequest, CollectionUpdateRequest, DomainTarget, HubAvailabilityResponse, } from "./types/collection.js";
|
|
41
42
|
export type { Proof, ProofResponse, ProofWrite, ProofCreateRequest, ProofUpdateRequest, ProofClaimRequest, ProofGrant, GrantScope, GrantAudience, CreateGrantOptions, RedeemGrantOptions, RedeemGrantResult, ProofTransfer, ProofTransferType, ProofTransferState, TransferProofOptions, TransferProofResult, } from "./types/proof.js";
|
package/dist/openapi.yaml
CHANGED
|
@@ -27248,7 +27248,6 @@ components:
|
|
|
27248
27248
|
- email
|
|
27249
27249
|
- push
|
|
27250
27250
|
- sms
|
|
27251
|
-
- wallet
|
|
27252
27251
|
BroadcastPreviewResponse:
|
|
27253
27252
|
type: object
|
|
27254
27253
|
additionalProperties: true
|
|
@@ -28797,14 +28796,10 @@ components:
|
|
|
28797
28796
|
type: boolean
|
|
28798
28797
|
channels:
|
|
28799
28798
|
$ref: "#/components/schemas/BroadcastChannel"
|
|
28800
|
-
walletForSubject:
|
|
28801
|
-
type: boolean
|
|
28802
28799
|
anySubscribed:
|
|
28803
28800
|
type: boolean
|
|
28804
28801
|
anyMethods:
|
|
28805
28802
|
type: boolean
|
|
28806
|
-
anyWalletForSubject:
|
|
28807
|
-
type: boolean
|
|
28808
28803
|
required:
|
|
28809
28804
|
- ok
|
|
28810
28805
|
- subject
|
|
@@ -28813,7 +28808,6 @@ components:
|
|
|
28813
28808
|
- subscribed
|
|
28814
28809
|
- anySubscribed
|
|
28815
28810
|
- anyMethods
|
|
28816
|
-
- anyWalletForSubject
|
|
28817
28811
|
TransactionalSendRequest:
|
|
28818
28812
|
type: object
|
|
28819
28813
|
properties:
|
|
@@ -29420,8 +29414,6 @@ components:
|
|
|
29420
29414
|
type: string
|
|
29421
29415
|
email:
|
|
29422
29416
|
type: string
|
|
29423
|
-
walletObjectId:
|
|
29424
|
-
type: string
|
|
29425
29417
|
subjectType:
|
|
29426
29418
|
$ref: "#/components/schemas/SubjectType"
|
|
29427
29419
|
subjectId:
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface TranslationActivity {
|
|
2
|
+
/** true while at least one fresh translation is under way (here or in an embedded app frame). */
|
|
3
|
+
active: boolean;
|
|
4
|
+
/** The language being translated into (the most recent one when several are under way). */
|
|
5
|
+
targetLanguage: string | null;
|
|
6
|
+
/** How many texts are waiting to be translated, across everything under way. */
|
|
7
|
+
texts: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const TRANSLATING_MESSAGE = "smartlinks:translating";
|
|
10
|
+
/**
|
|
11
|
+
* Mark a request that may create translations. Returns a function to call when it settles.
|
|
12
|
+
* Nothing is announced unless the request is still running after the delay.
|
|
13
|
+
* @internal used by translations.lookup
|
|
14
|
+
*/
|
|
15
|
+
export declare function trackTranslation(targetLanguage: string, texts: number): () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Hear when content is being translated for the first time: requests made in this window and in
|
|
18
|
+
* every app frame embedded in it. The callback gets the combined state now and on every change.
|
|
19
|
+
* Returns an unsubscribe function.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* translations.onActivity(({ active, targetLanguage }) => setBanner(active ? targetLanguage : null))
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function onActivity(cb: (activity: TranslationActivity) => void): () => void;
|
|
26
|
+
/** The combined state right now. */
|
|
27
|
+
export declare function activity(): TranslationActivity;
|
|
28
|
+
/** @internal tests only */
|
|
29
|
+
export declare function _resetActivity(options?: {
|
|
30
|
+
showAfterMs?: number;
|
|
31
|
+
}): void;
|
|
32
|
+
/**
|
|
33
|
+
* The "translating this page" line in the language being translated into, with its text direction.
|
|
34
|
+
* zh-CN / zh-SG → Simplified, zh-TW / zh-HK → Traditional; unknown languages get English.
|
|
35
|
+
*/
|
|
36
|
+
export declare function translatingMessage(language: string | null | undefined): {
|
|
37
|
+
text: string;
|
|
38
|
+
lang: string;
|
|
39
|
+
dir: 'ltr' | 'rtl';
|
|
40
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// Translation activity: "this page is being translated for the first time".
|
|
2
|
+
//
|
|
3
|
+
// Every app's content translation goes through translations.lookup / resolve, so the SDK is the one
|
|
4
|
+
// place that knows a visitor is waiting on a fresh AI translation. When a request that may create
|
|
5
|
+
// translations ('cache-fill') is still unanswered after a short delay, the SDK announces it, and
|
|
6
|
+
// announces again when it settles. Answers already in the cache come back well inside the delay, so
|
|
7
|
+
// nothing shows for a page that is already translated.
|
|
8
|
+
//
|
|
9
|
+
// inside a frame → posts { _smartlinksIframeMessage, type: 'smartlinks:translating', payload } to the parent
|
|
10
|
+
// in any window → listeners from translations.onActivity() hear it directly
|
|
11
|
+
//
|
|
12
|
+
// A host (Portal, Hub) calls translations.onActivity(cb) once: it hears its own requests AND those
|
|
13
|
+
// of every app frame it embeds, combined into one state. Apps need do nothing.
|
|
14
|
+
export const TRANSLATING_MESSAGE = 'smartlinks:translating';
|
|
15
|
+
// One state per window, shared by every copy of the SDK loaded into it: an app drawn straight into
|
|
16
|
+
// the page usually bundles its own SDK, and the host's listener must still hear its requests.
|
|
17
|
+
const KEY = '__smartlinksTranslationActivity';
|
|
18
|
+
function fresh() {
|
|
19
|
+
return {
|
|
20
|
+
showAfterMs: 600,
|
|
21
|
+
sources: new Map(),
|
|
22
|
+
listeners: new Set(),
|
|
23
|
+
messageListening: false,
|
|
24
|
+
onMessage: null,
|
|
25
|
+
last: { active: false, targetLanguage: null, texts: 0 },
|
|
26
|
+
lastLang: null,
|
|
27
|
+
self: { count: 0, texts: 0, lang: null },
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function shared() {
|
|
31
|
+
const g = globalThis;
|
|
32
|
+
if (!g[KEY])
|
|
33
|
+
g[KEY] = fresh();
|
|
34
|
+
return g[KEY];
|
|
35
|
+
}
|
|
36
|
+
function current() {
|
|
37
|
+
let texts = 0;
|
|
38
|
+
let active = false;
|
|
39
|
+
for (const s of shared().sources.values()) {
|
|
40
|
+
if (s.count > 0) {
|
|
41
|
+
active = true;
|
|
42
|
+
texts += s.texts;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { active, targetLanguage: active ? shared().lastLang : null, texts };
|
|
46
|
+
}
|
|
47
|
+
function notify() {
|
|
48
|
+
const st = shared();
|
|
49
|
+
const next = current();
|
|
50
|
+
const last = st.last;
|
|
51
|
+
if (next.active === last.active && next.texts === last.texts && next.targetLanguage === last.targetLanguage)
|
|
52
|
+
return;
|
|
53
|
+
st.last = next;
|
|
54
|
+
for (const cb of st.listeners) {
|
|
55
|
+
try {
|
|
56
|
+
cb(next);
|
|
57
|
+
}
|
|
58
|
+
catch ( /* a listener's fault is its own */_a) { /* a listener's fault is its own */ }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function inIframe() {
|
|
62
|
+
try {
|
|
63
|
+
return typeof window !== 'undefined' && !!window.parent && window.parent !== window;
|
|
64
|
+
}
|
|
65
|
+
catch (_a) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function postParent(payload) {
|
|
70
|
+
if (!inIframe())
|
|
71
|
+
return;
|
|
72
|
+
try {
|
|
73
|
+
window.parent.postMessage({ _smartlinksIframeMessage: true, type: TRANSLATING_MESSAGE, payload }, '*');
|
|
74
|
+
}
|
|
75
|
+
catch ( /* ignore */_a) { /* ignore */ }
|
|
76
|
+
}
|
|
77
|
+
function setSource(key, s) {
|
|
78
|
+
const st = shared();
|
|
79
|
+
if (s.count > 0) {
|
|
80
|
+
st.sources.set(key, s);
|
|
81
|
+
if (s.lang)
|
|
82
|
+
st.lastLang = s.lang;
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
st.sources.delete(key);
|
|
86
|
+
notify();
|
|
87
|
+
}
|
|
88
|
+
function publishSelf() {
|
|
89
|
+
setSource('self', Object.assign({}, shared().self));
|
|
90
|
+
// An app frame that is itself a host passes its whole state up, so nesting still reaches the top.
|
|
91
|
+
const all = current();
|
|
92
|
+
postParent({ active: all.active, targetLanguage: all.targetLanguage, texts: all.texts });
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Mark a request that may create translations. Returns a function to call when it settles.
|
|
96
|
+
* Nothing is announced unless the request is still running after the delay.
|
|
97
|
+
* @internal used by translations.lookup
|
|
98
|
+
*/
|
|
99
|
+
export function trackTranslation(targetLanguage, texts) {
|
|
100
|
+
let shown = false;
|
|
101
|
+
let done = false;
|
|
102
|
+
const st = shared();
|
|
103
|
+
const self = st.self;
|
|
104
|
+
const timer = setTimeout(() => {
|
|
105
|
+
if (done)
|
|
106
|
+
return;
|
|
107
|
+
shown = true;
|
|
108
|
+
self.count += 1;
|
|
109
|
+
self.texts += texts;
|
|
110
|
+
self.lang = targetLanguage;
|
|
111
|
+
publishSelf();
|
|
112
|
+
}, st.showAfterMs);
|
|
113
|
+
return () => {
|
|
114
|
+
if (done)
|
|
115
|
+
return;
|
|
116
|
+
done = true;
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
if (!shown)
|
|
119
|
+
return;
|
|
120
|
+
self.count = Math.max(0, self.count - 1);
|
|
121
|
+
self.texts = Math.max(0, self.texts - texts);
|
|
122
|
+
publishSelf();
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function onMessage(event) {
|
|
126
|
+
const d = event === null || event === void 0 ? void 0 : event.data;
|
|
127
|
+
if (!d || typeof d !== 'object' || d.type !== TRANSLATING_MESSAGE)
|
|
128
|
+
return;
|
|
129
|
+
const p = d.payload || {};
|
|
130
|
+
const key = event.source || 'unknown-frame';
|
|
131
|
+
setSource(key, { count: p.active ? 1 : 0, texts: Number(p.texts) || 0, lang: typeof p.targetLanguage === 'string' ? p.targetLanguage : null });
|
|
132
|
+
// Pass it on when this window is itself inside a frame.
|
|
133
|
+
const all = current();
|
|
134
|
+
postParent({ active: all.active, targetLanguage: all.targetLanguage, texts: all.texts });
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Hear when content is being translated for the first time: requests made in this window and in
|
|
138
|
+
* every app frame embedded in it. The callback gets the combined state now and on every change.
|
|
139
|
+
* Returns an unsubscribe function.
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* translations.onActivity(({ active, targetLanguage }) => setBanner(active ? targetLanguage : null))
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export function onActivity(cb) {
|
|
146
|
+
const st = shared();
|
|
147
|
+
st.listeners.add(cb);
|
|
148
|
+
if (!st.messageListening && typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
|
|
149
|
+
st.onMessage = onMessage;
|
|
150
|
+
window.addEventListener('message', onMessage);
|
|
151
|
+
st.messageListening = true;
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
cb(current());
|
|
155
|
+
}
|
|
156
|
+
catch ( /* ignore */_a) { /* ignore */ }
|
|
157
|
+
return () => { st.listeners.delete(cb); };
|
|
158
|
+
}
|
|
159
|
+
/** The combined state right now. */
|
|
160
|
+
export function activity() {
|
|
161
|
+
return current();
|
|
162
|
+
}
|
|
163
|
+
/** @internal tests only */
|
|
164
|
+
export function _resetActivity(options = {}) {
|
|
165
|
+
const g = globalThis;
|
|
166
|
+
const old = g[KEY];
|
|
167
|
+
if ((old === null || old === void 0 ? void 0 : old.onMessage) && typeof window !== 'undefined' && typeof window.removeEventListener === 'function')
|
|
168
|
+
window.removeEventListener('message', old.onMessage);
|
|
169
|
+
g[KEY] = fresh();
|
|
170
|
+
if (options.showAfterMs !== undefined)
|
|
171
|
+
g[KEY].showAfterMs = options.showAfterMs;
|
|
172
|
+
}
|
|
173
|
+
// The notice itself, in the language being translated into (the visitor asked for it, so they may not
|
|
174
|
+
// read English). Hosts show it as is; a language not listed gets the English line.
|
|
175
|
+
const TRANSLATING_TEXT = {
|
|
176
|
+
en: 'Translating this page. This only happens the first time.',
|
|
177
|
+
de: 'Diese Seite wird übersetzt. Das passiert nur beim ersten Mal.',
|
|
178
|
+
fr: 'Traduction de la page en cours. Cela n’arrive que la première fois.',
|
|
179
|
+
es: 'Traduciendo esta página. Solo ocurre la primera vez.',
|
|
180
|
+
it: 'Traduzione della pagina in corso. Succede solo la prima volta.',
|
|
181
|
+
pt: 'Traduzindo esta página. Isso só acontece na primeira vez.',
|
|
182
|
+
nl: 'Deze pagina wordt vertaald. Dit gebeurt alleen de eerste keer.',
|
|
183
|
+
pl: 'Trwa tłumaczenie strony. Dzieje się to tylko za pierwszym razem.',
|
|
184
|
+
sv: 'Sidan översätts. Det händer bara första gången.',
|
|
185
|
+
da: 'Siden oversættes. Det sker kun første gang.',
|
|
186
|
+
nb: 'Siden oversettes. Dette skjer bare første gang.',
|
|
187
|
+
no: 'Siden oversettes. Dette skjer bare første gang.',
|
|
188
|
+
fi: 'Sivua käännetään. Tämä tapahtuu vain ensimmäisellä kerralla.',
|
|
189
|
+
tr: 'Sayfa çevriliyor. Bu yalnızca ilk seferde olur.',
|
|
190
|
+
ru: 'Страница переводится. Это происходит только в первый раз.',
|
|
191
|
+
uk: 'Сторінка перекладається. Це відбувається лише першого разу.',
|
|
192
|
+
ar: 'جارٍ ترجمة هذه الصفحة. يحدث هذا في المرة الأولى فقط.',
|
|
193
|
+
he: 'הדף מתורגם. זה קורה רק בפעם הראשונה.',
|
|
194
|
+
ja: 'このページを翻訳しています。初回のみ少々お待ちください。',
|
|
195
|
+
ko: '이 페이지를 번역하는 중입니다. 처음 한 번만 잠시 기다려 주세요.',
|
|
196
|
+
'zh-Hans': '正在翻译此页面,仅首次需要稍候。',
|
|
197
|
+
'zh-Hant': '正在翻譯此頁面,僅首次需要稍候。',
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* The "translating this page" line in the language being translated into, with its text direction.
|
|
201
|
+
* zh-CN / zh-SG → Simplified, zh-TW / zh-HK → Traditional; unknown languages get English.
|
|
202
|
+
*/
|
|
203
|
+
export function translatingMessage(language) {
|
|
204
|
+
const raw = String(language || 'en').trim();
|
|
205
|
+
const lower = raw.toLowerCase();
|
|
206
|
+
let key = TRANSLATING_TEXT[raw] ? raw : '';
|
|
207
|
+
if (!key && lower.startsWith('zh'))
|
|
208
|
+
key = /hant|tw|hk|mo/.test(lower) ? 'zh-Hant' : 'zh-Hans';
|
|
209
|
+
if (!key)
|
|
210
|
+
key = TRANSLATING_TEXT[lower.split('-')[0]] ? lower.split('-')[0] : 'en';
|
|
211
|
+
return { text: TRANSLATING_TEXT[key], lang: key, dir: key === 'ar' || key === 'he' ? 'rtl' : 'ltr' };
|
|
212
|
+
}
|
|
@@ -3,7 +3,8 @@ export interface ListBroadcastsQuery {
|
|
|
3
3
|
offset?: number;
|
|
4
4
|
appId?: string;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
/** Broadcast channels. Wallet is not one: wallet passes are messaged one-to-one (`comms.send` with `channel: 'wallet'`). */
|
|
7
|
+
export type BroadcastChannel = 'email' | 'push' | 'sms';
|
|
7
8
|
export interface BroadcastRecord {
|
|
8
9
|
id: string;
|
|
9
10
|
collectionId: string;
|
|
@@ -80,9 +81,6 @@ export type BroadcastPreviewResponse = {
|
|
|
80
81
|
} | {
|
|
81
82
|
channel: 'sms';
|
|
82
83
|
body: string;
|
|
83
|
-
} | {
|
|
84
|
-
channel: 'wallet';
|
|
85
|
-
payload: any;
|
|
86
84
|
};
|
|
87
85
|
export interface BroadcastSendTestRequest {
|
|
88
86
|
contactId?: string;
|
package/dist/types/comms.d.ts
CHANGED
|
@@ -294,7 +294,6 @@ export interface SubscriptionsResolveRequest {
|
|
|
294
294
|
userId?: string;
|
|
295
295
|
pushEndpoint?: string;
|
|
296
296
|
email?: string;
|
|
297
|
-
walletObjectId?: string;
|
|
298
297
|
};
|
|
299
298
|
}
|
|
300
299
|
export interface SubscriptionsResolveResponse {
|
|
@@ -308,11 +307,9 @@ export interface SubscriptionsResolveResponse {
|
|
|
308
307
|
contactId: string;
|
|
309
308
|
subscribed: boolean;
|
|
310
309
|
channels?: Partial<Record<BroadcastChannel, boolean>>;
|
|
311
|
-
walletForSubject?: boolean;
|
|
312
310
|
}>;
|
|
313
311
|
anySubscribed: boolean;
|
|
314
312
|
anyMethods: boolean;
|
|
315
|
-
anyWalletForSubject: boolean;
|
|
316
313
|
}
|
|
317
314
|
/**
|
|
318
315
|
* Send a single message to one contact using a template.
|
|
@@ -439,7 +436,7 @@ export interface TransactionalSendError {
|
|
|
439
436
|
* - `transactional.phone_missing`
|
|
440
437
|
* - `transactional.whatsapp_missing`
|
|
441
438
|
* - `transactional.no_push_methods`
|
|
442
|
-
* - `transactional.
|
|
439
|
+
* - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
|
|
443
440
|
* - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
|
|
444
441
|
* - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
|
|
445
442
|
*/
|
package/dist/types/contact.d.ts
CHANGED
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.30 | Generated: 2026-11-20T10:29:26.751Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -6041,7 +6041,7 @@ interface BroadcastAppendBulkBody {
|
|
|
6041
6041
|
}
|
|
6042
6042
|
```
|
|
6043
6043
|
|
|
6044
|
-
**BroadcastChannel** = `'email' | 'push' | 'sms'
|
|
6044
|
+
**BroadcastChannel** = `'email' | 'push' | 'sms'`
|
|
6045
6045
|
|
|
6046
6046
|
**BroadcastPreviewResponse** = ``
|
|
6047
6047
|
|
|
@@ -6932,7 +6932,7 @@ interface RegisterMethodResponse {
|
|
|
6932
6932
|
```typescript
|
|
6933
6933
|
interface SubscriptionsResolveRequest {
|
|
6934
6934
|
subject: { type: SubjectType; id: string; productId?: string }
|
|
6935
|
-
hints: { userId?: string; pushEndpoint?: string; email?: string
|
|
6935
|
+
hints: { userId?: string; pushEndpoint?: string; email?: string }
|
|
6936
6936
|
}
|
|
6937
6937
|
```
|
|
6938
6938
|
|
|
@@ -6945,11 +6945,9 @@ interface SubscriptionsResolveResponse {
|
|
|
6945
6945
|
contactId: string
|
|
6946
6946
|
subscribed: boolean
|
|
6947
6947
|
channels?: Partial<Record<BroadcastChannel, boolean>>
|
|
6948
|
-
walletForSubject?: boolean
|
|
6949
6948
|
}>
|
|
6950
6949
|
anySubscribed: boolean
|
|
6951
6950
|
anyMethods: boolean
|
|
6952
|
-
anyWalletForSubject: boolean
|
|
6953
6951
|
}
|
|
6954
6952
|
```
|
|
6955
6953
|
|
|
@@ -7293,7 +7291,7 @@ export interface RegisterMethodResponse { ok: true; contactId: string }
|
|
|
7293
7291
|
|
|
7294
7292
|
export interface SubscriptionsResolveRequest {
|
|
7295
7293
|
subject: { type: SubjectType; id: string; productId?: string }
|
|
7296
|
-
hints: { userId?: string; pushEndpoint?: string; email?: string
|
|
7294
|
+
hints: { userId?: string; pushEndpoint?: string; email?: string }
|
|
7297
7295
|
}
|
|
7298
7296
|
export interface SubscriptionsResolveResponse {
|
|
7299
7297
|
ok: true
|
|
@@ -7302,11 +7300,9 @@ export interface SubscriptionsResolveResponse {
|
|
|
7302
7300
|
contactId: string
|
|
7303
7301
|
subscribed: boolean
|
|
7304
7302
|
channels?: Partial<Record<BroadcastChannel, boolean>>
|
|
7305
|
-
walletForSubject?: boolean
|
|
7306
7303
|
}>
|
|
7307
7304
|
anySubscribed: boolean
|
|
7308
7305
|
anyMethods: boolean
|
|
7309
|
-
anyWalletForSubject: boolean
|
|
7310
7306
|
}
|
|
7311
7307
|
|
|
7312
7308
|
// Transactional send (single-contact, single-message)
|
|
@@ -7434,7 +7430,7 @@ export interface TransactionalSendError {
|
|
|
7434
7430
|
* - `transactional.phone_missing`
|
|
7435
7431
|
* - `transactional.whatsapp_missing`
|
|
7436
7432
|
* - `transactional.no_push_methods`
|
|
7437
|
-
* - `transactional.
|
|
7433
|
+
* - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
|
|
7438
7434
|
* - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
|
|
7439
7435
|
* - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
|
|
7440
7436
|
*/
|
|
@@ -7693,7 +7689,6 @@ interface CommMethodMeta {
|
|
|
7693
7689
|
auth?: string
|
|
7694
7690
|
phone?: string
|
|
7695
7691
|
email?: string
|
|
7696
|
-
walletObjectId?: string
|
|
7697
7692
|
subjectType?: SubjectType
|
|
7698
7693
|
subjectId?: string
|
|
7699
7694
|
productId?: string
|
|
@@ -15505,21 +15500,35 @@ Invoke ONE built-in server tool directly — no model in the loop. This is the "
|
|
|
15505
15500
|
**lookup**(collectionId: string,
|
|
15506
15501
|
body: TranslationLookupRequest) → `Promise<TranslationLookupResponse>`
|
|
15507
15502
|
|
|
15503
|
+
**onActivity**(cb: (activity: TranslationActivity) → `void`
|
|
15504
|
+
Hear when content is being translated for the first time, in this window or in any app frame it embeds. Hosts use it to show a "translating this page" notice; apps never have to. Returns an unsubscribe function.
|
|
15505
|
+
|
|
15506
|
+
**translatingMessage**(language: string | null | undefined) → ``
|
|
15507
|
+
The "translating this page" line, in the language being translated into (for a host's banner).
|
|
15508
|
+
|
|
15509
|
+
**activity**() → `TranslationActivity`
|
|
15510
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15511
|
+
|
|
15508
15512
|
**resolve**(collectionId: string,
|
|
15509
15513
|
body: TranslationLookupRequest,
|
|
15510
15514
|
options: TranslationResolveOptions = {}) → `Promise<ResolvedTranslationResponse>`
|
|
15515
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15511
15516
|
|
|
15512
15517
|
**list**(collectionId: string,
|
|
15513
15518
|
params?: TranslationListParams) → `Promise<TranslationListResponse>`
|
|
15519
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15514
15520
|
|
|
15515
15521
|
**get**(collectionId: string,
|
|
15516
15522
|
translationId: string) → `Promise<TranslationRecord>`
|
|
15523
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15517
15524
|
|
|
15518
15525
|
**update**(collectionId: string,
|
|
15519
15526
|
translationId: string,
|
|
15520
15527
|
body: TranslationUpdateRequest) → `Promise<TranslationRecord>`
|
|
15528
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15521
15529
|
|
|
15522
15530
|
**clearLocalCache**(collectionId?: string) → `Promise<void>`
|
|
15531
|
+
Whether a first-time translation is under way right now (see onActivity).
|
|
15523
15532
|
|
|
15524
15533
|
### tts
|
|
15525
15534
|
|
package/docs/translations.md
CHANGED
|
@@ -253,6 +253,26 @@ await translations.resolve('collection-123', {
|
|
|
253
253
|
|
|
254
254
|
The SDK derives a deterministic local cache key from `context` so browser-local entries do not collide across different UI surfaces.
|
|
255
255
|
|
|
256
|
+
## "Translating this page" notice (hosts)
|
|
257
|
+
|
|
258
|
+
The first visitor to see content in a new language waits while it is translated. Apps do not need
|
|
259
|
+
to show anything for this: when a `cache-fill` request is still unanswered after about 0.6 s, the
|
|
260
|
+
SDK announces it, and announces again when it settles. Inside a frame it posts
|
|
261
|
+
`{ _smartlinksIframeMessage: true, type: 'smartlinks:translating', payload: { active, targetLanguage, texts } }`
|
|
262
|
+
to the parent. Already-translated content answers well inside the delay, so nothing is announced.
|
|
263
|
+
|
|
264
|
+
Portal and Hub listen once and show a banner:
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
const stop = translations.onActivity(({ active, targetLanguage, texts }) => {
|
|
268
|
+
setBanner(active ? targetLanguage : null)
|
|
269
|
+
})
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`onActivity` combines this window's own requests with those of every embedded app frame.
|
|
273
|
+
`translations.activity()` returns the state right now. An app that wants its own spinner can use the
|
|
274
|
+
same call.
|
|
275
|
+
|
|
256
276
|
## Hashing Helpers
|
|
257
277
|
|
|
258
278
|
The SDK also exposes the normalization and hashing helpers used by the local cache flow.
|
package/openapi.yaml
CHANGED
|
@@ -27248,7 +27248,6 @@ components:
|
|
|
27248
27248
|
- email
|
|
27249
27249
|
- push
|
|
27250
27250
|
- sms
|
|
27251
|
-
- wallet
|
|
27252
27251
|
BroadcastPreviewResponse:
|
|
27253
27252
|
type: object
|
|
27254
27253
|
additionalProperties: true
|
|
@@ -28797,14 +28796,10 @@ components:
|
|
|
28797
28796
|
type: boolean
|
|
28798
28797
|
channels:
|
|
28799
28798
|
$ref: "#/components/schemas/BroadcastChannel"
|
|
28800
|
-
walletForSubject:
|
|
28801
|
-
type: boolean
|
|
28802
28799
|
anySubscribed:
|
|
28803
28800
|
type: boolean
|
|
28804
28801
|
anyMethods:
|
|
28805
28802
|
type: boolean
|
|
28806
|
-
anyWalletForSubject:
|
|
28807
|
-
type: boolean
|
|
28808
28803
|
required:
|
|
28809
28804
|
- ok
|
|
28810
28805
|
- subject
|
|
@@ -28813,7 +28808,6 @@ components:
|
|
|
28813
28808
|
- subscribed
|
|
28814
28809
|
- anySubscribed
|
|
28815
28810
|
- anyMethods
|
|
28816
|
-
- anyWalletForSubject
|
|
28817
28811
|
TransactionalSendRequest:
|
|
28818
28812
|
type: object
|
|
28819
28813
|
properties:
|
|
@@ -29420,8 +29414,6 @@ components:
|
|
|
29420
29414
|
type: string
|
|
29421
29415
|
email:
|
|
29422
29416
|
type: string
|
|
29423
|
-
walletObjectId:
|
|
29424
|
-
type: string
|
|
29425
29417
|
subjectType:
|
|
29426
29418
|
$ref: "#/components/schemas/SubjectType"
|
|
29427
29419
|
subjectId:
|