@genn-inc/cluebase-frontend-sdk 0.0.2 → 0.0.6
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 -0
- package/dist/_generated/{identity-pii-policy.d.ts → identity-pii-policy-text-contains.d.ts} +1 -1
- package/dist/_generated/{identity-pii-policy.js → identity-pii-policy-text-contains.js} +1 -1
- package/dist/_generated/identity-pii-policy-whole-value.d.ts +37 -0
- package/dist/_generated/identity-pii-policy-whole-value.js +106 -0
- package/dist/_generated/otel-span-conversion.js +1 -9
- package/dist/context/action-context.js +27 -7
- package/dist/context/browser-storage.js +1 -2
- package/dist/context/environment.js +5 -3
- package/dist/context/identity.js +5 -9
- package/dist/context/organization.d.ts +1 -1
- package/dist/context/organization.js +6 -8
- package/dist/context/session.js +6 -8
- package/dist/context/tab.js +8 -12
- package/dist/context/trace.js +2 -1
- package/dist/exporter/batch.d.ts +3 -1
- package/dist/exporter/batch.js +6 -10
- package/dist/exporter/browser-outbox-records.d.ts +1 -1
- package/dist/exporter/browser-outbox-records.js +15 -6
- package/dist/exporter/browser-outbox.d.ts +5 -2
- package/dist/exporter/browser-outbox.js +48 -11
- package/dist/exporter/client.d.ts +2 -2
- package/dist/exporter/client.js +15 -30
- package/dist/exporter/delivery-response-contract.js +67 -17
- package/dist/exporter/delivery-response.d.ts +3 -1
- package/dist/exporter/delivery-response.js +31 -20
- package/dist/exporter/diagnostics.d.ts +1 -1
- package/dist/exporter/diagnostics.js +4 -1
- package/dist/exporter/event-id.js +1 -3
- package/dist/exporter/frontend-resource.js +5 -4
- package/dist/exporter/observation-source-event-exporter.d.ts +1 -0
- package/dist/exporter/observation-source-event-exporter.js +5 -2
- package/dist/exporter/path-template.js +3 -1
- package/dist/exporter/raw-event-to-source-signal.js +4 -2
- package/dist/exporter/sanitize.d.ts +3 -2
- package/dist/exporter/sanitize.js +4 -3
- package/dist/exporter/sdk-core-wasm.d.ts +5 -0
- package/dist/exporter/sdk-core-wasm.js +18 -0
- package/dist/exporter/source-event.d.ts +1 -0
- package/dist/exporter/span-to-source-signal.d.ts +1 -1
- package/dist/exporter/span-to-source-signal.js +122 -82
- package/dist/index.d.ts +5 -4
- package/dist/index.js +23 -11
- package/dist/instrumentation/action.js +9 -8
- package/dist/instrumentation/dom.js +13 -21
- package/dist/instrumentation/drag.js +0 -3
- package/dist/instrumentation/error.js +3 -1
- package/dist/instrumentation/form.js +5 -6
- package/dist/instrumentation/input.js +4 -8
- package/dist/instrumentation/location.js +3 -1
- package/dist/instrumentation/network-request.js +1 -1
- package/dist/instrumentation/network-span-attributes.js +2 -2
- package/dist/instrumentation/network.js +7 -3
- package/dist/instrumentation/performance.js +1 -2
- package/dist/internal/internal-log.js +2 -1
- package/dist/provider/_version.d.ts +1 -1
- package/dist/provider/_version.js +1 -1
- package/dist/provider/config.js +0 -1
- package/dist/provider/constants.d.ts +1 -1
- package/dist/provider/constants.js +0 -1
- package/dist/provider/sdk-error.d.ts +7 -0
- package/dist/provider/sdk-error.js +48 -0
- package/dist/provider/sdk-event-pipeline.d.ts +2 -1
- package/dist/provider/sdk-event-pipeline.js +6 -3
- package/dist/provider/sdk-input-normalization.js +2 -2
- package/dist/provider/sdk-otel-pipeline.js +5 -4
- package/dist/provider/sdk-runtime-surfaces.d.ts +15 -12
- package/dist/provider/sdk-runtime-surfaces.js +8 -7
- package/dist/provider/sdk.js +81 -12
- package/dist/provider/types.d.ts +6 -5
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm.d.ts +41 -0
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm.js +267 -0
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm_bg.wasm +0 -0
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm_bg.wasm.d.ts +12 -0
- package/dist/wasm/pkg-web/package.json +15 -0
- package/package.json +10 -3
package/dist/provider/sdk.js
CHANGED
|
@@ -7,12 +7,14 @@ import { TraceManager } from "../context/trace.js";
|
|
|
7
7
|
import { BatchTransport } from "../exporter/batch.js";
|
|
8
8
|
import { IngestClient } from "../exporter/client.js";
|
|
9
9
|
import { DiagnosticStore } from "../exporter/diagnostics.js";
|
|
10
|
-
import {
|
|
10
|
+
import { detectWholeValuePII, hashIdentityValue, isDeniedKey, } from "../exporter/sanitize.js";
|
|
11
|
+
import { initSdkCoreWasm } from "../exporter/sdk-core-wasm.js";
|
|
11
12
|
import { InternalMetricsStore } from "../internal/metrics.js";
|
|
12
13
|
import { isConfigValid, resolveConfig, validateConfig } from "./config.js";
|
|
13
14
|
import { DEFAULT_BATCH_FLUSH_THRESHOLD_BYTES, DEFAULT_CONSENT, DEFAULT_MAX_BATCH_QUEUE_BYTES, DEFAULT_MAX_BATCH_QUEUE_ITEMS, SDK_VERSION, } from "./constants.js";
|
|
14
|
-
import {
|
|
15
|
+
import { getSdkErrorDetails, reportSdkError } from "./sdk-error.js";
|
|
15
16
|
import { OFFICIAL_CUSTOM_EVENT_NAME, ProviderEventPipeline, readCurrentLifecycleUrl, } from "./sdk-event-pipeline.js";
|
|
17
|
+
import { isValidPublicCustomEventName, normalizeProfileAvatarUrl, normalizePublicIdentityId, toStringOrNull, } from "./sdk-input-normalization.js";
|
|
16
18
|
import { createCluebaseOtelPipeline, forceFlushCluebaseOtelProvider, shutdownCluebaseOtelProvider, shutdownCluebaseOtelProviderAsync, } from "./sdk-otel-pipeline.js";
|
|
17
19
|
import { ProviderRuntimeSurfaces } from "./sdk-runtime-surfaces.js";
|
|
18
20
|
const createNoopLogger = () => {
|
|
@@ -57,9 +59,8 @@ class CluebaseBrowserSdkImpl {
|
|
|
57
59
|
enqueueRawEvent: (event) => {
|
|
58
60
|
this.enqueueRawEvent(event);
|
|
59
61
|
},
|
|
60
|
-
|
|
62
|
+
eventPipeline: this.eventPipeline,
|
|
61
63
|
getConsent: () => this.consent,
|
|
62
|
-
getObservationContext: () => this.eventPipeline.getObservationContext(),
|
|
63
64
|
getTraceManager: () => this.traceManager,
|
|
64
65
|
getTransport: () => this.transport,
|
|
65
66
|
getTracerProvider: () => this.tracerProvider,
|
|
@@ -71,6 +72,19 @@ class CluebaseBrowserSdkImpl {
|
|
|
71
72
|
getDiagnostics() {
|
|
72
73
|
return this.diagnostics.snapshot();
|
|
73
74
|
}
|
|
75
|
+
withActionContext(callback) {
|
|
76
|
+
let snapshot = null;
|
|
77
|
+
try {
|
|
78
|
+
snapshot = this.traceManager?.getCurrentActionContext() ?? null;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
reportSdkError("withActionContext", error);
|
|
82
|
+
}
|
|
83
|
+
if (!snapshot || !this.traceManager) {
|
|
84
|
+
return callback();
|
|
85
|
+
}
|
|
86
|
+
return this.traceManager.runWithActionContext(snapshot, callback);
|
|
87
|
+
}
|
|
74
88
|
init(options) {
|
|
75
89
|
try {
|
|
76
90
|
const resolved = resolveConfig(options);
|
|
@@ -88,7 +102,6 @@ class CluebaseBrowserSdkImpl {
|
|
|
88
102
|
localSetupCheckEndpoint: resolved.localSetupCheckEndpoint,
|
|
89
103
|
projectKey: resolved.projectKey,
|
|
90
104
|
producerId: resolved.producerId,
|
|
91
|
-
transportProfile: resolved.transportProfile,
|
|
92
105
|
autocapture: resolved.autocapture,
|
|
93
106
|
captureNetwork: resolved.captureNetwork,
|
|
94
107
|
captureErrors: resolved.captureErrors,
|
|
@@ -135,6 +148,7 @@ class CluebaseBrowserSdkImpl {
|
|
|
135
148
|
client: ingestClient,
|
|
136
149
|
enabled: effectiveBatch.enabled,
|
|
137
150
|
flushIntervalMs: effectiveBatch.flushIntervalMs,
|
|
151
|
+
maxSize: effectiveBatch.maxSize,
|
|
138
152
|
maxPayloadBytes: effectiveBatch.maxPayloadBytes,
|
|
139
153
|
flushThresholdBytes: DEFAULT_BATCH_FLUSH_THRESHOLD_BYTES,
|
|
140
154
|
queueMaxBytes: DEFAULT_MAX_BATCH_QUEUE_BYTES,
|
|
@@ -165,6 +179,9 @@ class CluebaseBrowserSdkImpl {
|
|
|
165
179
|
if (this.consent !== "denied") {
|
|
166
180
|
this.warmupBrowserToken(ingestClient);
|
|
167
181
|
}
|
|
182
|
+
void initSdkCoreWasm().catch((error) => {
|
|
183
|
+
reportSdkError("init sdk core wasm", error);
|
|
184
|
+
});
|
|
168
185
|
this.tracerProvider = createCluebaseOtelPipeline({
|
|
169
186
|
resolved,
|
|
170
187
|
getTransport: () => this.transport,
|
|
@@ -192,11 +209,24 @@ class CluebaseBrowserSdkImpl {
|
|
|
192
209
|
}
|
|
193
210
|
this.installUnloadHandlers();
|
|
194
211
|
}
|
|
195
|
-
catch {
|
|
212
|
+
catch (error) {
|
|
213
|
+
const errorDetails = getSdkErrorDetails(error);
|
|
196
214
|
this.logger.error("Cluebase Frontend SDK init failed", {
|
|
197
215
|
error_code: "sdk_operation_failed",
|
|
216
|
+
...errorDetails,
|
|
198
217
|
});
|
|
218
|
+
reportSdkError("init", error);
|
|
199
219
|
this.warnPublicDrop("init", "sdk_operation_failed");
|
|
220
|
+
try {
|
|
221
|
+
this.shutdown();
|
|
222
|
+
}
|
|
223
|
+
catch (cleanupError) {
|
|
224
|
+
this.logger.error("Cluebase Frontend SDK init cleanup failed", {
|
|
225
|
+
error_code: "sdk_cleanup_failed",
|
|
226
|
+
...getSdkErrorDetails(cleanupError),
|
|
227
|
+
});
|
|
228
|
+
reportSdkError("init cleanup", cleanupError);
|
|
229
|
+
}
|
|
200
230
|
}
|
|
201
231
|
}
|
|
202
232
|
identify(userId, traits) {
|
|
@@ -268,6 +298,44 @@ class CluebaseBrowserSdkImpl {
|
|
|
268
298
|
});
|
|
269
299
|
}
|
|
270
300
|
}
|
|
301
|
+
linkExternalAccount(namespace, externalId) {
|
|
302
|
+
if (!this.ensureInitializedForPublicCall("linkExternalAccount")) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (!this.organizationManager) {
|
|
306
|
+
this.warnPublicDrop("linkExternalAccount", "organization manager is unavailable");
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
const organizationId = this.organizationManager.getContext().organizationId;
|
|
311
|
+
if (!organizationId) {
|
|
312
|
+
this.warnPublicDrop("linkExternalAccount", "setOrganization must be called before linkExternalAccount");
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const normalizedNamespace = normalizePublicIdentityId(namespace);
|
|
316
|
+
const normalizedExternalId = normalizePublicIdentityId(externalId);
|
|
317
|
+
if (!normalizedNamespace || !normalizedExternalId) {
|
|
318
|
+
this.warnPublicDrop("linkExternalAccount", "namespace and externalId must be non-empty strings");
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const sanitizedExternalId = this.sanitizeIdentityValue("externalId", normalizedExternalId);
|
|
322
|
+
this.enqueueOfficialCustomEvent(OFFICIAL_CUSTOM_EVENT_NAME.externalAccountLinked, {
|
|
323
|
+
identity_action: "link_external_account",
|
|
324
|
+
external_namespace: normalizedNamespace,
|
|
325
|
+
}, false, {
|
|
326
|
+
link_type: "canonical_subject_to_external",
|
|
327
|
+
organization_id: organizationId,
|
|
328
|
+
external_namespace: normalizedNamespace,
|
|
329
|
+
external_id: sanitizedExternalId,
|
|
330
|
+
});
|
|
331
|
+
this.flushLifecycleEvents();
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
this.logger.error("linkExternalAccount failed", {
|
|
335
|
+
error_code: "sdk_operation_failed",
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
271
339
|
reset() {
|
|
272
340
|
if (!this.initialized) {
|
|
273
341
|
return;
|
|
@@ -411,8 +479,7 @@ class CluebaseBrowserSdkImpl {
|
|
|
411
479
|
});
|
|
412
480
|
}
|
|
413
481
|
}
|
|
414
|
-
catch {
|
|
415
|
-
}
|
|
482
|
+
catch { }
|
|
416
483
|
}
|
|
417
484
|
warnPublicFieldDrop(operation, field, _reason) {
|
|
418
485
|
this.logger.warn(`Cluebase Frontend SDK ${operation} field dropped`, {
|
|
@@ -422,11 +489,13 @@ class CluebaseBrowserSdkImpl {
|
|
|
422
489
|
try {
|
|
423
490
|
if (typeof console !== "undefined" &&
|
|
424
491
|
typeof console.warn === "function") {
|
|
425
|
-
console.warn(`[cluebase] ${operation} field dropped`, {
|
|
492
|
+
console.warn(`[cluebase] ${operation} field dropped`, {
|
|
493
|
+
field,
|
|
494
|
+
error_code: "sdk_field_drop",
|
|
495
|
+
});
|
|
426
496
|
}
|
|
427
497
|
}
|
|
428
|
-
catch {
|
|
429
|
-
}
|
|
498
|
+
catch { }
|
|
430
499
|
}
|
|
431
500
|
sanitizeIdentifyTraits(traits) {
|
|
432
501
|
if (!traits) {
|
|
@@ -537,7 +606,7 @@ class CluebaseBrowserSdkImpl {
|
|
|
537
606
|
const trimmed = raw.trim();
|
|
538
607
|
if (!trimmed)
|
|
539
608
|
return trimmed;
|
|
540
|
-
const piiCategory =
|
|
609
|
+
const piiCategory = detectWholeValuePII(trimmed);
|
|
541
610
|
if (piiCategory === null)
|
|
542
611
|
return trimmed;
|
|
543
612
|
const hashed = hashIdentityValue(trimmed);
|
package/dist/provider/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { InternalMetricsSnapshot } from "../internal/metrics.js";
|
|
2
1
|
import type { DiagnosticsSnapshot } from "../exporter/diagnostics.js";
|
|
2
|
+
import type { InternalMetricsSnapshot } from "../internal/metrics.js";
|
|
3
3
|
import type { FrontendEventName, ParameterCaptureMode, SdkCollectionMode } from "./contracts.js";
|
|
4
4
|
export type { FrontendEventCategory, FrontendEventName, FrontendEventStatus, ParameterCaptureMode, SdkCollectionMode, } from "./contracts.js";
|
|
5
5
|
export type CluebaseConsentState = "granted" | "denied" | "unknown";
|
|
@@ -19,7 +19,6 @@ export type CluebaseGroupTraits = {
|
|
|
19
19
|
} & {
|
|
20
20
|
[traitName: string]: CanonicalJsonInputValue;
|
|
21
21
|
};
|
|
22
|
-
export type TransportProfile = "standard";
|
|
23
22
|
export type RequestLifecycleOutcome = "completed" | "failed" | "aborted" | "unknown";
|
|
24
23
|
export type DiagnosticCollectionConfig = {
|
|
25
24
|
enabledCollectors?: string[];
|
|
@@ -67,7 +66,6 @@ export type ResolvedCluebaseConfig = {
|
|
|
67
66
|
localSetupCheckEndpoint: string | null;
|
|
68
67
|
projectKey: string;
|
|
69
68
|
producerId: string;
|
|
70
|
-
transportProfile: TransportProfile;
|
|
71
69
|
autocapture: boolean;
|
|
72
70
|
captureNetwork: boolean;
|
|
73
71
|
captureErrors: boolean;
|
|
@@ -112,6 +110,7 @@ export type CluebaseBrowserSdk = {
|
|
|
112
110
|
init(options: CluebaseInitOptions): void;
|
|
113
111
|
identify(userId: string, traits?: CluebaseSubjectTraits): void;
|
|
114
112
|
setOrganization(organizationId: string, traits?: CluebaseGroupTraits): void;
|
|
113
|
+
linkExternalAccount(namespace: string, externalId: string): void;
|
|
115
114
|
logout(): void;
|
|
116
115
|
reset(): void;
|
|
117
116
|
track(eventName: string, properties?: CluebaseTrackProperties, metrics?: CluebaseTrackMetrics): void;
|
|
@@ -120,6 +119,7 @@ export type CluebaseBrowserSdk = {
|
|
|
120
119
|
flush(): Promise<void>;
|
|
121
120
|
close(): Promise<void>;
|
|
122
121
|
getDiagnostics(): DiagnosticsSnapshot;
|
|
122
|
+
withActionContext<T>(callback: () => T): T;
|
|
123
123
|
};
|
|
124
124
|
export type { CostCapability } from "../_generated/usage-governor-tables.js";
|
|
125
125
|
import type { CostCapability } from "../_generated/usage-governor-tables.js";
|
|
@@ -149,12 +149,14 @@ export type ParameterSnapshotLeaf = {
|
|
|
149
149
|
export type ParameterSnapshotValue = ParameterSnapshotLeaf | ParameterSnapshotValue[] | {
|
|
150
150
|
[key: string]: ParameterSnapshotValue;
|
|
151
151
|
};
|
|
152
|
-
export type SdkIdentityLinkType = "anonymous_to_user" | "user_to_organization" | "logout";
|
|
152
|
+
export type SdkIdentityLinkType = "anonymous_to_user" | "user_to_organization" | "logout" | "canonical_subject_to_external";
|
|
153
153
|
export type SdkIdentityLinkHint = {
|
|
154
154
|
link_type: SdkIdentityLinkType;
|
|
155
155
|
anonymous_id?: string | null;
|
|
156
156
|
user_id?: string | null;
|
|
157
157
|
organization_id?: string | null;
|
|
158
|
+
external_namespace?: string | null;
|
|
159
|
+
external_id?: string | null;
|
|
158
160
|
};
|
|
159
161
|
export type CluebaseContext = {
|
|
160
162
|
producer_id: string | null;
|
|
@@ -267,7 +269,6 @@ export type CaptureModuleContext = {
|
|
|
267
269
|
sessionId: string | null;
|
|
268
270
|
tabId: string | null;
|
|
269
271
|
};
|
|
270
|
-
shouldIgnoreElement?: (element: Element) => boolean;
|
|
271
272
|
startInteraction?: (input: {
|
|
272
273
|
interactionId?: string | null;
|
|
273
274
|
interactionInitiator?: string | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function spanToSdkSignalJson(span_json: string, options_json: string): string;
|
|
5
|
+
|
|
6
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
7
|
+
|
|
8
|
+
export interface InitOutput {
|
|
9
|
+
readonly memory: WebAssembly.Memory;
|
|
10
|
+
readonly spanToSdkSignalJson: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
11
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
12
|
+
readonly __externref_table_alloc: () => number;
|
|
13
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
14
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
15
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
16
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
17
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
18
|
+
readonly __wbindgen_start: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
25
|
+
* a precompiled `WebAssembly.Module`.
|
|
26
|
+
*
|
|
27
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
28
|
+
*
|
|
29
|
+
* @returns {InitOutput}
|
|
30
|
+
*/
|
|
31
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
35
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
36
|
+
*
|
|
37
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
38
|
+
*
|
|
39
|
+
* @returns {Promise<InitOutput>}
|
|
40
|
+
*/
|
|
41
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/* @ts-self-types="./cluebase_sdk_core_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} span_json
|
|
5
|
+
* @param {string} options_json
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function spanToSdkSignalJson(span_json, options_json) {
|
|
9
|
+
let deferred4_0;
|
|
10
|
+
let deferred4_1;
|
|
11
|
+
try {
|
|
12
|
+
const ptr0 = passStringToWasm0(span_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
13
|
+
const len0 = WASM_VECTOR_LEN;
|
|
14
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
15
|
+
const len1 = WASM_VECTOR_LEN;
|
|
16
|
+
const ret = wasm.spanToSdkSignalJson(ptr0, len0, ptr1, len1);
|
|
17
|
+
var ptr3 = ret[0];
|
|
18
|
+
var len3 = ret[1];
|
|
19
|
+
if (ret[3]) {
|
|
20
|
+
ptr3 = 0; len3 = 0;
|
|
21
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
22
|
+
}
|
|
23
|
+
deferred4_0 = ptr3;
|
|
24
|
+
deferred4_1 = len3;
|
|
25
|
+
return getStringFromWasm0(ptr3, len3);
|
|
26
|
+
} finally {
|
|
27
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function __wbg_get_imports() {
|
|
31
|
+
const import0 = {
|
|
32
|
+
__proto__: null,
|
|
33
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
34
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
35
|
+
},
|
|
36
|
+
__wbg_getRandomValues_a608c4436c19407a: function() { return handleError(function (arg0, arg1) {
|
|
37
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
38
|
+
}, arguments); },
|
|
39
|
+
__wbg_getTime_f5a55efff2585d5d: function(arg0) {
|
|
40
|
+
const ret = arg0.getTime();
|
|
41
|
+
return ret;
|
|
42
|
+
},
|
|
43
|
+
__wbg_new_0_72d020f0c63443d4: function() {
|
|
44
|
+
const ret = new Date();
|
|
45
|
+
return ret;
|
|
46
|
+
},
|
|
47
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
48
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
49
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
50
|
+
return ret;
|
|
51
|
+
},
|
|
52
|
+
__wbindgen_init_externref_table: function() {
|
|
53
|
+
const table = wasm.__wbindgen_externrefs;
|
|
54
|
+
const offset = table.grow(4);
|
|
55
|
+
table.set(0, undefined);
|
|
56
|
+
table.set(offset + 0, undefined);
|
|
57
|
+
table.set(offset + 1, null);
|
|
58
|
+
table.set(offset + 2, true);
|
|
59
|
+
table.set(offset + 3, false);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
__proto__: null,
|
|
64
|
+
"./cluebase_sdk_core_wasm_bg.js": import0,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function addToExternrefTable0(obj) {
|
|
69
|
+
const idx = wasm.__externref_table_alloc();
|
|
70
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
71
|
+
return idx;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
75
|
+
ptr = ptr >>> 0;
|
|
76
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getStringFromWasm0(ptr, len) {
|
|
80
|
+
return decodeText(ptr >>> 0, len);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let cachedUint8ArrayMemory0 = null;
|
|
84
|
+
function getUint8ArrayMemory0() {
|
|
85
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
86
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
87
|
+
}
|
|
88
|
+
return cachedUint8ArrayMemory0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function handleError(f, args) {
|
|
92
|
+
try {
|
|
93
|
+
return f.apply(this, args);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
const idx = addToExternrefTable0(e);
|
|
96
|
+
wasm.__wbindgen_exn_store(idx);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
101
|
+
if (realloc === undefined) {
|
|
102
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
103
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
104
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
105
|
+
WASM_VECTOR_LEN = buf.length;
|
|
106
|
+
return ptr;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let len = arg.length;
|
|
110
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
111
|
+
|
|
112
|
+
const mem = getUint8ArrayMemory0();
|
|
113
|
+
|
|
114
|
+
let offset = 0;
|
|
115
|
+
|
|
116
|
+
for (; offset < len; offset++) {
|
|
117
|
+
const code = arg.charCodeAt(offset);
|
|
118
|
+
if (code > 0x7F) break;
|
|
119
|
+
mem[ptr + offset] = code;
|
|
120
|
+
}
|
|
121
|
+
if (offset !== len) {
|
|
122
|
+
if (offset !== 0) {
|
|
123
|
+
arg = arg.slice(offset);
|
|
124
|
+
}
|
|
125
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
126
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
127
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
128
|
+
|
|
129
|
+
offset += ret.written;
|
|
130
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
WASM_VECTOR_LEN = offset;
|
|
134
|
+
return ptr;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function takeFromExternrefTable0(idx) {
|
|
138
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
139
|
+
wasm.__externref_table_dealloc(idx);
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
144
|
+
cachedTextDecoder.decode();
|
|
145
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
146
|
+
let numBytesDecoded = 0;
|
|
147
|
+
function decodeText(ptr, len) {
|
|
148
|
+
numBytesDecoded += len;
|
|
149
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
150
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
151
|
+
cachedTextDecoder.decode();
|
|
152
|
+
numBytesDecoded = len;
|
|
153
|
+
}
|
|
154
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const cachedTextEncoder = new TextEncoder();
|
|
158
|
+
|
|
159
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
160
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
161
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
162
|
+
view.set(buf);
|
|
163
|
+
return {
|
|
164
|
+
read: arg.length,
|
|
165
|
+
written: buf.length
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let WASM_VECTOR_LEN = 0;
|
|
171
|
+
|
|
172
|
+
let wasmModule, wasmInstance, wasm;
|
|
173
|
+
function __wbg_finalize_init(instance, module) {
|
|
174
|
+
wasmInstance = instance;
|
|
175
|
+
wasm = instance.exports;
|
|
176
|
+
wasmModule = module;
|
|
177
|
+
cachedUint8ArrayMemory0 = null;
|
|
178
|
+
wasm.__wbindgen_start();
|
|
179
|
+
return wasm;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function __wbg_load(module, imports) {
|
|
183
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
184
|
+
if (!module.ok) {
|
|
185
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
189
|
+
try {
|
|
190
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
const validResponse = expectedResponseType(module.type);
|
|
193
|
+
|
|
194
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
195
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
196
|
+
|
|
197
|
+
} else { throw e; }
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const bytes = await module.arrayBuffer();
|
|
202
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
203
|
+
} else {
|
|
204
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
205
|
+
|
|
206
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
207
|
+
return { instance, module };
|
|
208
|
+
} else {
|
|
209
|
+
return instance;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function expectedResponseType(type) {
|
|
214
|
+
switch (type) {
|
|
215
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function initSync(module) {
|
|
222
|
+
if (wasm !== undefined) return wasm;
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
if (module !== undefined) {
|
|
226
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
227
|
+
({module} = module)
|
|
228
|
+
} else {
|
|
229
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const imports = __wbg_get_imports();
|
|
234
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
235
|
+
module = new WebAssembly.Module(module);
|
|
236
|
+
}
|
|
237
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
238
|
+
return __wbg_finalize_init(instance, module);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function __wbg_init(module_or_path) {
|
|
242
|
+
if (wasm !== undefined) return wasm;
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
if (module_or_path !== undefined) {
|
|
246
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
247
|
+
({module_or_path} = module_or_path)
|
|
248
|
+
} else {
|
|
249
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (module_or_path === undefined) {
|
|
254
|
+
module_or_path = new URL('cluebase_sdk_core_wasm_bg.wasm', import.meta.url);
|
|
255
|
+
}
|
|
256
|
+
const imports = __wbg_get_imports();
|
|
257
|
+
|
|
258
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
259
|
+
module_or_path = fetch(module_or_path);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
263
|
+
|
|
264
|
+
return __wbg_finalize_init(instance, module);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const spanToSdkSignalJson: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
6
|
+
export const __externref_table_alloc: () => number;
|
|
7
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
8
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
9
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
11
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
12
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cluebase-sdk-core-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"cluebase_sdk_core_wasm_bg.wasm",
|
|
7
|
+
"cluebase_sdk_core_wasm.js",
|
|
8
|
+
"cluebase_sdk_core_wasm.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"main": "cluebase_sdk_core_wasm.js",
|
|
11
|
+
"types": "cluebase_sdk_core_wasm.d.ts",
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./snippets/*"
|
|
14
|
+
]
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genn-inc/cluebase-frontend-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/genn-inc/cluebase.git"
|
|
@@ -21,18 +21,23 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "node
|
|
24
|
+
"build:wasm": "node ../../../scripts/build-sdk-core-wasm.mjs --target web --dest src/wasm/pkg-web",
|
|
25
|
+
"build": "node ./scripts/clean-dist.mjs && node ../../../scripts/generate-shared-contract-tables.mjs && node ./scripts/generate-version-module.mjs && pnpm build:wasm && tsc -p tsconfig.build.json && node ./scripts/fix-esm-relative-imports.mjs && node ../../../scripts/copy-directory.mjs --from src/wasm --to dist/wasm",
|
|
25
26
|
"prepack": "pnpm build",
|
|
26
27
|
"prepublishOnly": "pnpm lint && pnpm test:cov && pnpm typecheck && pnpm test:package-import",
|
|
27
28
|
"lint": "pnpm exec biome lint src",
|
|
28
29
|
"test:package-import": "pnpm build && node ../../../tests/distribution/frontend-sdk/check-package-import.mjs",
|
|
30
|
+
"pretypecheck": "pnpm build:wasm",
|
|
29
31
|
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
32
|
+
"pretest": "pnpm build:wasm",
|
|
30
33
|
"test": "vitest run --config ../../../tests/config/vitest/frontend-sdk.config.ts",
|
|
34
|
+
"pretest:cov": "pnpm build:wasm",
|
|
31
35
|
"test:cov": "vitest run --config ../../../tests/config/vitest/frontend-sdk.config.ts --coverage"
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@cluebase/schema": "workspace:*",
|
|
35
39
|
"@cluebase/shared": "workspace:*",
|
|
40
|
+
"@opentelemetry/api": "1.10.0",
|
|
36
41
|
"@vitest/coverage-v8": "^3.2.4",
|
|
37
42
|
"jsdom": "^26.1.0",
|
|
38
43
|
"typescript": "^5.9.3",
|
|
@@ -40,7 +45,6 @@
|
|
|
40
45
|
},
|
|
41
46
|
"dependencies": {
|
|
42
47
|
"@noble/hashes": "1.8.0",
|
|
43
|
-
"@opentelemetry/api": ">=1.9.1 <1.10.0",
|
|
44
48
|
"@opentelemetry/api-logs": ">=0.218.0 <1.0.0",
|
|
45
49
|
"@opentelemetry/browser-instrumentation": ">=0.5.2 <1.0.0",
|
|
46
50
|
"@opentelemetry/core": ">=2.7.1 <3.0.0",
|
|
@@ -52,5 +56,8 @@
|
|
|
52
56
|
"@opentelemetry/sdk-trace-web": ">=2.7.1 <3.0.0",
|
|
53
57
|
"json-canonicalize": "2.0.0",
|
|
54
58
|
"zod": "^4.4.3"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@opentelemetry/api": ">=1.10.0 <1.11.0"
|
|
55
62
|
}
|
|
56
63
|
}
|