@junobuild/analytics 0.0.21 → 0.0.22-next-2024-05-17
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/declarations/orbiter/orbiter.did.d.ts +7 -2
- package/declarations/orbiter/orbiter.factory.did.js +8 -3
- package/declarations/orbiter/orbiter.factory.did.mjs +8 -3
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/declarations/orbiter/orbiter.did.d.ts +7 -2
- package/dist/declarations/orbiter/orbiter.factory.did.js +8 -3
- package/dist/declarations/orbiter/orbiter.factory.did.mjs +8 -3
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types/env.d.ts +3 -0
- package/dist/types/types/idb.d.ts +1 -1
- package/dist/types/utils/analytics.utils.d.ts +1 -0
- package/dist/types/utils/log.utils.d.ts +1 -0
- package/dist/workers/analytics.worker.js +38 -39
- package/dist/workers/analytics.worker.js.map +4 -4
- package/package.json +4 -4
- package/declarations/orbiter/index.d.ts +0 -45
- package/declarations/orbiter/index.js +0 -37
- package/dist/declarations/orbiter/index.d.ts +0 -45
- package/dist/declarations/orbiter/index.js +0 -37
|
@@ -51,7 +51,7 @@ export interface Controller {
|
|
|
51
51
|
}
|
|
52
52
|
export type ControllerScope = {Write: null} | {Admin: null};
|
|
53
53
|
export interface DelSatelliteConfig {
|
|
54
|
-
|
|
54
|
+
version: [] | [bigint];
|
|
55
55
|
}
|
|
56
56
|
export interface DeleteControllersArgs {
|
|
57
57
|
controllers: Array<Principal>;
|
|
@@ -72,6 +72,7 @@ export interface MemorySize {
|
|
|
72
72
|
export interface OrbiterSatelliteConfig {
|
|
73
73
|
updated_at: bigint;
|
|
74
74
|
created_at: bigint;
|
|
75
|
+
version: [] | [bigint];
|
|
75
76
|
enabled: boolean;
|
|
76
77
|
}
|
|
77
78
|
export interface PageView {
|
|
@@ -84,6 +85,7 @@ export interface PageView {
|
|
|
84
85
|
created_at: bigint;
|
|
85
86
|
satellite_id: Principal;
|
|
86
87
|
device: PageViewDevice;
|
|
88
|
+
version: [] | [bigint];
|
|
87
89
|
user_agent: [] | [string];
|
|
88
90
|
}
|
|
89
91
|
export interface PageViewDevice {
|
|
@@ -111,10 +113,11 @@ export interface SetPageView {
|
|
|
111
113
|
href: string;
|
|
112
114
|
satellite_id: Principal;
|
|
113
115
|
device: PageViewDevice;
|
|
116
|
+
version: [] | [bigint];
|
|
114
117
|
user_agent: [] | [string];
|
|
115
118
|
}
|
|
116
119
|
export interface SetSatelliteConfig {
|
|
117
|
-
|
|
120
|
+
version: [] | [bigint];
|
|
118
121
|
enabled: boolean;
|
|
119
122
|
}
|
|
120
123
|
export interface SetTrackEvent {
|
|
@@ -123,6 +126,7 @@ export interface SetTrackEvent {
|
|
|
123
126
|
metadata: [] | [Array<[string, string]>];
|
|
124
127
|
name: string;
|
|
125
128
|
satellite_id: Principal;
|
|
129
|
+
version: [] | [bigint];
|
|
126
130
|
user_agent: [] | [string];
|
|
127
131
|
}
|
|
128
132
|
export interface TrackEvent {
|
|
@@ -132,6 +136,7 @@ export interface TrackEvent {
|
|
|
132
136
|
name: string;
|
|
133
137
|
created_at: bigint;
|
|
134
138
|
satellite_id: Principal;
|
|
139
|
+
version: [] | [bigint];
|
|
135
140
|
}
|
|
136
141
|
export interface _SERVICE {
|
|
137
142
|
del_controllers: ActorMethod<[DeleteControllersArgs], Array<[Principal, Controller]>>;
|
|
@@ -14,7 +14,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
14
14
|
scope: ControllerScope,
|
|
15
15
|
expires_at: IDL.Opt(IDL.Nat64)
|
|
16
16
|
});
|
|
17
|
-
const DelSatelliteConfig = IDL.Record({
|
|
17
|
+
const DelSatelliteConfig = IDL.Record({version: IDL.Opt(IDL.Nat64)});
|
|
18
18
|
const DepositCyclesArgs = IDL.Record({
|
|
19
19
|
cycles: IDL.Nat,
|
|
20
20
|
destination_id: IDL.Principal
|
|
@@ -42,6 +42,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
42
42
|
created_at: IDL.Nat64,
|
|
43
43
|
satellite_id: IDL.Principal,
|
|
44
44
|
device: PageViewDevice,
|
|
45
|
+
version: IDL.Opt(IDL.Nat64),
|
|
45
46
|
user_agent: IDL.Opt(IDL.Text)
|
|
46
47
|
});
|
|
47
48
|
const AnalyticsBrowsersPageViews = IDL.Record({
|
|
@@ -83,7 +84,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
83
84
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
84
85
|
name: IDL.Text,
|
|
85
86
|
created_at: IDL.Nat64,
|
|
86
|
-
satellite_id: IDL.Principal
|
|
87
|
+
satellite_id: IDL.Principal,
|
|
88
|
+
version: IDL.Opt(IDL.Nat64)
|
|
87
89
|
});
|
|
88
90
|
const AnalyticsTrackEvents = IDL.Record({
|
|
89
91
|
total: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Nat32))
|
|
@@ -91,6 +93,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
91
93
|
const OrbiterSatelliteConfig = IDL.Record({
|
|
92
94
|
updated_at: IDL.Nat64,
|
|
93
95
|
created_at: IDL.Nat64,
|
|
96
|
+
version: IDL.Opt(IDL.Nat64),
|
|
94
97
|
enabled: IDL.Bool
|
|
95
98
|
});
|
|
96
99
|
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
@@ -112,6 +115,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
112
115
|
href: IDL.Text,
|
|
113
116
|
satellite_id: IDL.Principal,
|
|
114
117
|
device: PageViewDevice,
|
|
118
|
+
version: IDL.Opt(IDL.Nat64),
|
|
115
119
|
user_agent: IDL.Opt(IDL.Text)
|
|
116
120
|
});
|
|
117
121
|
const Result = IDL.Variant({Ok: PageView, Err: IDL.Text});
|
|
@@ -120,7 +124,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
120
124
|
Err: IDL.Vec(IDL.Tuple(AnalyticKey, IDL.Text))
|
|
121
125
|
});
|
|
122
126
|
const SetSatelliteConfig = IDL.Record({
|
|
123
|
-
|
|
127
|
+
version: IDL.Opt(IDL.Nat64),
|
|
124
128
|
enabled: IDL.Bool
|
|
125
129
|
});
|
|
126
130
|
const SetTrackEvent = IDL.Record({
|
|
@@ -129,6 +133,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
129
133
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
130
134
|
name: IDL.Text,
|
|
131
135
|
satellite_id: IDL.Principal,
|
|
136
|
+
version: IDL.Opt(IDL.Nat64),
|
|
132
137
|
user_agent: IDL.Opt(IDL.Text)
|
|
133
138
|
});
|
|
134
139
|
const Result_2 = IDL.Variant({Ok: TrackEvent, Err: IDL.Text});
|
|
@@ -14,7 +14,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
14
14
|
scope: ControllerScope,
|
|
15
15
|
expires_at: IDL.Opt(IDL.Nat64)
|
|
16
16
|
});
|
|
17
|
-
const DelSatelliteConfig = IDL.Record({
|
|
17
|
+
const DelSatelliteConfig = IDL.Record({version: IDL.Opt(IDL.Nat64)});
|
|
18
18
|
const DepositCyclesArgs = IDL.Record({
|
|
19
19
|
cycles: IDL.Nat,
|
|
20
20
|
destination_id: IDL.Principal
|
|
@@ -42,6 +42,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
42
42
|
created_at: IDL.Nat64,
|
|
43
43
|
satellite_id: IDL.Principal,
|
|
44
44
|
device: PageViewDevice,
|
|
45
|
+
version: IDL.Opt(IDL.Nat64),
|
|
45
46
|
user_agent: IDL.Opt(IDL.Text)
|
|
46
47
|
});
|
|
47
48
|
const AnalyticsBrowsersPageViews = IDL.Record({
|
|
@@ -83,7 +84,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
83
84
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
84
85
|
name: IDL.Text,
|
|
85
86
|
created_at: IDL.Nat64,
|
|
86
|
-
satellite_id: IDL.Principal
|
|
87
|
+
satellite_id: IDL.Principal,
|
|
88
|
+
version: IDL.Opt(IDL.Nat64)
|
|
87
89
|
});
|
|
88
90
|
const AnalyticsTrackEvents = IDL.Record({
|
|
89
91
|
total: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Nat32))
|
|
@@ -91,6 +93,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
91
93
|
const OrbiterSatelliteConfig = IDL.Record({
|
|
92
94
|
updated_at: IDL.Nat64,
|
|
93
95
|
created_at: IDL.Nat64,
|
|
96
|
+
version: IDL.Opt(IDL.Nat64),
|
|
94
97
|
enabled: IDL.Bool
|
|
95
98
|
});
|
|
96
99
|
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
@@ -112,6 +115,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
112
115
|
href: IDL.Text,
|
|
113
116
|
satellite_id: IDL.Principal,
|
|
114
117
|
device: PageViewDevice,
|
|
118
|
+
version: IDL.Opt(IDL.Nat64),
|
|
115
119
|
user_agent: IDL.Opt(IDL.Text)
|
|
116
120
|
});
|
|
117
121
|
const Result = IDL.Variant({Ok: PageView, Err: IDL.Text});
|
|
@@ -120,7 +124,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
120
124
|
Err: IDL.Vec(IDL.Tuple(AnalyticKey, IDL.Text))
|
|
121
125
|
});
|
|
122
126
|
const SetSatelliteConfig = IDL.Record({
|
|
123
|
-
|
|
127
|
+
version: IDL.Opt(IDL.Nat64),
|
|
124
128
|
enabled: IDL.Bool
|
|
125
129
|
});
|
|
126
130
|
const SetTrackEvent = IDL.Record({
|
|
@@ -129,6 +133,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
129
133
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
130
134
|
name: IDL.Text,
|
|
131
135
|
satellite_id: IDL.Principal,
|
|
136
|
+
version: IDL.Opt(IDL.Nat64),
|
|
132
137
|
user_agent: IDL.Opt(IDL.Text)
|
|
133
138
|
});
|
|
134
139
|
const Result_2 = IDL.Variant({Ok: TrackEvent, Err: IDL.Text});
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var w="abcdefghijklmnopqrstuvwxyz234567",s=Object.create(null);for(let e=0;e<w.length;e++)s[w[e]]=e;s[0]=s.o;s[1]=s.i;var R=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);var c=e=>e==null,x=e=>!c(e),P=class extends Error{},o=(e,t)=>{if(c(e))throw new P(t)};var d=e=>x(e)?[e]:[];var u=()=>typeof window<"u",f=({key:e,envPrefix:t})=>typeof process<"u"?x(t)?process.env[`${t}${e}`]:process.env[`NEXT_PUBLIC_${e}`]??process.env[`VITE_${e}`]??process.env[`PUBLIC_${e}`]:void 0;var h="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var b=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=h[r[e]&63];return t};var v=()=>BigInt(Date.now())*BigInt(1e6);var m=()=>({collected_at:v(),updated_at:[],version:[]}),g=()=>{let{userAgent:e}=navigator;return{user_agent:d(e)}};var S="Analytics worker not initialized. Did you call `initOrbiter`?",i=e=>{c(e)&&console.warn(S)};var j=()=>{if(!(typeof crypto>"u"))return b()},l=j(),n,_=e=>{let{path:t}=e.worker??{},r=t===void 0?"./workers/analytics.worker.js":t;n=new Worker(r);let a=()=>console.warn("Unable to connect to the analytics web worker. Have you deployed it?");return n?.addEventListener("error",a,!1),D(e),{cleanup(){n?.removeEventListener("error",a,!1)}}},k=()=>{let e=async()=>await E(),t=new Proxy(history.pushState,{apply:async(r,a,p)=>{r.apply(a,p),await e()}});return history.pushState=t,addEventListener("popstate",e,{passive:!0}),{cleanup(){t=null,removeEventListener("popstate",e,!1)}}},I="No session ID initialized.",y=async()=>{if(!u())return;o(l,I);let{title:e,location:{href:t},referrer:r}=document,{innerWidth:a,innerHeight:p}=window,{timeZone:N}=Intl.DateTimeFormat().resolvedOptions(),U={title:e,href:t,referrer:d(x(r)&&r!==""?r:void 0),device:{inner_width:a,inner_height:p},time_zone:N,session_id:l,...g(),...m()};await(await import("./idb.services-V6IDWAXJ.js")).setPageView({key:b(),view:U})},E=async()=>{i(n),await y(),n?.postMessage({msg:"junoTrackPageView"})},O=async e=>{if(!u())return;o(l,I),i(n),await(await import("./idb.services-V6IDWAXJ.js")).setTrackEvent({key:b(),track:{...e,session_id:l,...g(),...m()}}),n?.postMessage({msg:"junoTrackEvent"})},D=e=>{i(n),n?.postMessage({msg:"junoInitEnvironment",data:e})},T=()=>{i(n),n?.postMessage({msg:"junoStartTrackTimer"})},A=()=>{i(n),n?.postMessage({msg:"junoStopTracker"})};var B=e=>{let t=e?.satelliteId??f({key:"SATELLITE_ID",envPrefix:e?.envPrefix});o(t,"Satellite ID is not configured. Orbiter cannot be initialized without a target Satellite.");let r=e?.orbiterId??f({key:"ORBITER_ID",envPrefix:e?.envPrefix});o(r,"Orbiter ID is not configured. The analytics cannot be initialized without an Orbiter.");let a=e?.container??f({key:"CONTAINER",envPrefix:e?.envPrefix});return{orbiterId:r,satelliteId:t,container:a,worker:e?.worker}},ue=async e=>{await y();let t=B(e),{cleanup:r}=_(t),{cleanup:a}=k();return T(),()=>{A(),r(),a()}};export{ue as initOrbiter,O as trackEvent,E as trackPageView};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../node_modules/@dfinity/principal/src/utils/base32.ts", "../../../../node_modules/@dfinity/principal/src/utils/getCrc.ts", "../../../utils/src/utils/debounce.utils.ts", "../../../utils/src/utils/json.utils.ts", "../../../utils/src/utils/null.utils.ts", "../../../utils/src/utils/did.utils.ts", "../../../utils/src/utils/env.utils.ts", "../../../../node_modules/nanoid/index.browser.js", "../../src/utils/date.utils.ts", "../../src/utils/analytics.utils.ts", "../../src/services/analytics.services.ts", "../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["const alphabet = 'abcdefghijklmnopqrstuvwxyz234567';\n\n// Build a lookup table for decoding.\nconst lookupTable: Record<string, number> = Object.create(null);\nfor (let i = 0; i < alphabet.length; i++) {\n lookupTable[alphabet[i]] = i;\n}\n\n// Add aliases for rfc4648.\nlookupTable['0'] = lookupTable.o;\nlookupTable['1'] = lookupTable.i;\n\n/**\n * @param input The input array to encode.\n * @returns A Base32 string encoding the input.\n */\nexport function encode(input: Uint8Array): string {\n // How many bits will we skip from the first byte.\n let skip = 0;\n // 5 high bits, carry from one byte to the next.\n let bits = 0;\n\n // The output string in base32.\n let output = '';\n\n function encodeByte(byte: number) {\n if (skip < 0) {\n // we have a carry from the previous byte\n bits |= byte >> -skip;\n } else {\n // no carry\n bits = (byte << skip) & 248;\n }\n\n if (skip > 3) {\n // Not enough data to produce a character, get us another one\n skip -= 8;\n return 1;\n }\n\n if (skip < 4) {\n // produce a character\n output += alphabet[bits >> 3];\n skip += 5;\n }\n\n return 0;\n }\n\n for (let i = 0; i < input.length; ) {\n i += encodeByte(input[i]);\n }\n\n return output + (skip < 0 ? alphabet[bits >> 3] : '');\n}\n\n/**\n * @param input The base32 encoded string to decode.\n */\nexport function decode(input: string): Uint8Array {\n // how many bits we have from the previous character.\n let skip = 0;\n // current byte we're producing.\n let byte = 0;\n\n const output = new Uint8Array(((input.length * 4) / 3) | 0);\n let o = 0;\n\n function decodeChar(char: string) {\n // Consume a character from the stream, store\n // the output in this.output. As before, better\n // to use update().\n let val = lookupTable[char.toLowerCase()];\n if (val === undefined) {\n throw new Error(`Invalid character: ${JSON.stringify(char)}`);\n }\n\n // move to the high bits\n val <<= 3;\n byte |= val >>> skip;\n skip += 5;\n\n if (skip >= 8) {\n // We have enough bytes to produce an output\n output[o++] = byte;\n skip -= 8;\n\n if (skip > 0) {\n byte = (val << (5 - skip)) & 255;\n } else {\n byte = 0;\n }\n }\n }\n\n for (const c of input) {\n decodeChar(c);\n }\n\n return output.slice(0, o);\n}\n", "// This file is translated to JavaScript from\n// https://lxp32.github.io/docs/a-simple-example-crc32-calculation/\nconst lookUpTable: Uint32Array = new Uint32Array([\n 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,\n 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,\n 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,\n 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,\n 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,\n 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,\n 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,\n 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,\n 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,\n 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,\n 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,\n 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,\n 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,\n 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,\n 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,\n 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,\n 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,\n 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,\n 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,\n 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,\n 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,\n 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,\n 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,\n 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,\n 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,\n 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,\n 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,\n 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,\n 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,\n 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,\n 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,\n 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,\n]);\n\n/**\n * Calculate the CRC32 of an ArrayBufferLike.\n * @param buf The BufferLike to calculate the CRC32 of.\n */\nexport function getCrc32(buf: ArrayBufferLike): number {\n const b = new Uint8Array(buf);\n let crc = -1;\n\n for (let i = 0; i < b.length; i++) {\n const byte = b[i];\n const t = (byte ^ crc) & 0xff;\n crc = lookUpTable[t] ^ (crc >>> 8);\n }\n\n return (crc ^ -1) >>> 0;\n}\n", "/* eslint-disable-next-line @typescript-eslint/ban-types */\nexport const debounce = (func: Function, timeout?: number) => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: unknown[]) => {\n const next = () => func(...args);\n\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(next, timeout !== undefined && timeout > 0 ? timeout : 300);\n };\n};\n", "import {Principal} from '@dfinity/principal';\nimport {nonNullish} from './null.utils';\n\nconst JSON_KEY_BIGINT = '__bigint__';\nconst JSON_KEY_PRINCIPAL = '__principal__';\nconst JSON_KEY_UINT8ARRAY = '__uint8array__';\n\n/**\n * A parser that interprets revived BigInt, Principal, and Uint8Array when constructing JavaScript values or objects.\n */\nexport const jsonReplacer = (_key: string, value: unknown): unknown => {\n if (typeof value === 'bigint') {\n return {[JSON_KEY_BIGINT]: `${value}`};\n }\n\n if (nonNullish(value) && value instanceof Principal) {\n return {[JSON_KEY_PRINCIPAL]: value.toText()};\n }\n\n if (nonNullish(value) && value instanceof Uint8Array) {\n return {[JSON_KEY_UINT8ARRAY]: Array.from(value)};\n }\n\n return value;\n};\n\n/**\n * A function that alters the behavior of the stringification process for BigInt, Principal and Uint8Array.\n */\nexport const jsonReviver = (_key: string, value: unknown): unknown => {\n const mapValue = <T>(key: string): T => (value as Record<string, T>)[key];\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_BIGINT in value) {\n return BigInt(mapValue(JSON_KEY_BIGINT));\n }\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_PRINCIPAL in value) {\n return Principal.fromText(mapValue(JSON_KEY_PRINCIPAL));\n }\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_UINT8ARRAY in value) {\n return Uint8Array.from(mapValue(JSON_KEY_UINT8ARRAY));\n }\n\n return value;\n};\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {jsonReplacer, jsonReviver} from './json.utils';\nimport {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data, jsonReplacer)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text(), jsonReviver);\n};\n", "export const isBrowser = () => typeof window !== `undefined`;\n", "export { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {toNullable} from '@junobuild/utils';\nimport {nowInBigIntNanoSeconds} from './date.utils';\n\nexport const timestamp = (): {collected_at: bigint; updated_at: [] | [bigint]} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: []\n});\n\nexport const userAgent = (): {user_agent: [] | [string]} => {\n const {userAgent} = navigator;\n return {user_agent: toNullable(userAgent)};\n};\n", "import {assertNonNullish, isBrowser, nonNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {IdbPageView} from '../types/idb';\nimport type {PostMessageInitEnvData} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\nimport {timestamp, userAgent} from '../utils/analytics.utils';\n\nconst initSessionId = (): string | undefined => {\n // I faced this issue when I used the library in Docusaurus which does not implement the crypto API when server-side rendering.\n // https://github.com/ai/nanoid/issues?q=crypto+not+defined\n if (typeof crypto === 'undefined') {\n return undefined;\n }\n\n return nanoid();\n};\n\nconst sessionId = initSessionId();\n\nlet worker: Worker | undefined;\n\nexport const initWorker = (env: Environment): {cleanup: () => void} => {\n const {path}: EnvironmentWorker = env.worker ?? {};\n const workerUrl = path === undefined ? './workers/analytics.worker.js' : path;\n\n worker = new Worker(workerUrl);\n\n const consoleWarn = () =>\n console.warn('Unable to connect to the analytics web worker. Have you deployed it?');\n\n worker?.addEventListener('error', consoleWarn, false);\n\n initWorkerEnvironment(env);\n\n return {\n cleanup() {\n worker?.removeEventListener('error', consoleWarn, false);\n }\n };\n};\n\nexport const initTrackPageViews = (): {cleanup: () => void} => {\n const trackPages = async () => await trackPageView();\n\n let pushStateProxy: typeof history.pushState | null = new Proxy(history.pushState, {\n apply: async (\n target,\n thisArg,\n argArray: [data: unknown, unused: string, url?: string | URL | null | undefined]\n ) => {\n target.apply(thisArg, argArray);\n await trackPages();\n }\n });\n\n history.pushState = pushStateProxy;\n\n addEventListener('popstate', trackPages, {passive: true});\n\n return {\n cleanup() {\n pushStateProxy = null;\n removeEventListener('popstate', trackPages, false);\n }\n };\n};\n\nconst WORKER_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you call `initOrbiter`?' as const;\nconst SESSION_ID_UNDEFINED_MSG = 'No session ID initialized.' as const;\n\nexport const setPageView = async () => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n\n const {\n title,\n location: {href},\n referrer\n } = document;\n const {innerWidth, innerHeight} = window;\n const {timeZone} = Intl.DateTimeFormat().resolvedOptions();\n\n const data: IdbPageView = {\n title,\n href,\n referrer: toNullable(nonNullish(referrer) && referrer !== '' ? referrer : undefined),\n device: {\n inner_width: innerWidth,\n inner_height: innerHeight\n },\n time_zone: timeZone,\n session_id: sessionId as string,\n ...userAgent(),\n ...timestamp()\n };\n\n const idb = await import('./idb.services');\n await idb.setPageView({\n key: nanoid(),\n view: data\n });\n};\n\nexport const trackPageView = async () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n await setPageView();\n\n worker?.postMessage({msg: 'junoTrackPageView'});\n};\n\nexport const trackEvent = async (data: TrackEvent) => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n const idb = await import('./idb.services');\n await idb.setTrackEvent({\n key: nanoid(),\n track: {...data, session_id: sessionId as string, ...userAgent(), ...timestamp()}\n });\n\n worker?.postMessage({msg: 'junoTrackEvent'});\n};\n\nexport const initWorkerEnvironment = (env: PostMessageInitEnvData) => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoInitEnvironment', data: env});\n};\n\nexport const startTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStartTrackTimer'});\n};\n\nexport const stopTracking = () => {\n assertNonNullish(worker, WORKER_UNDEFINED_MSG);\n\n worker?.postMessage({msg: 'junoStopTracker'});\n};\n", "import {\n initTrackPageViews,\n initWorker,\n setPageView,\n startTracking,\n stopTracking\n} from './services/analytics.services';\nimport type {Environment} from './types/env';\n\nexport {trackEvent, trackPageView} from './services/analytics.services';\nexport * from './types/env';\n\nexport const initOrbiter = async (env: Environment): Promise<() => void> => {\n // Save first page as soon as possible\n await setPageView();\n\n const {cleanup: workerCleanup} = initWorker(env);\n\n const {cleanup: pushHistoryCleanup} = initTrackPageViews();\n\n // Starting tracking will instantly sync the first page and the data from previous sessions that have not been synced yet\n startTracking();\n\n return () => {\n stopTracking();\n workerCleanup();\n pushHistoryCleanup();\n };\n};\n"],
|
|
5
|
-
"mappings": "AAAA,IAAMA,EAAW,mCAGXC,EAAsC,OAAO,OAAO,IAAI,EAC9D,QAASC,EAAI,EAAGA,EAAIF,EAAS,OAAQE,IACnCD,EAAYD,EAASE,CAAC,CAAC,EAAIA,EAI7BD,EAAY,CAAG,EAAIA,EAAY,EAC/BA,EAAY,CAAG,EAAIA,EAAY,ECR/B,IAAME,EAA2B,IAAI,YAAY,CAC/C,EAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WACpF,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WACpF,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WACpF,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WACpF,UAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WACpF,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WACpF,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WACpF,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WACpF,WAAY,SAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WACpF,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WACpF,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WACpF,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WACpF,WAAY,UAAY,WAAY,WAAY,WAAY,WAAY,WAAY,WACpF,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WACpF,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WACpF,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WAAY,WACpF,WAAY,WAAY,SAAY,WAAY,WAAY,WAAY,SAAY,WACpF,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WACpF,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WACpF,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WACpF,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,WAAY,WACpF,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WACpF,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WACpF,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UAAY,WACpF,WAAY,WAAY,WAAY,SAAY,WAAY,WAAY,WAAY,SACpF,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UACpF,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UACpF,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UACpF,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,WACpF,WAAY,WAAY,WAAY,SAAY,WAAY,WAAY,WAAY,UACpF,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UACpF,WAAY,WAAY,WAAY,UAAY,WAAY,WAAY,WAAY,UACrF,EGlCM,IAAMC,EAAgBC,GAC3BA,GAAa,KAGFC,EAAiBD,GAC5B,CAACD,EAAUC,CAAQ,EAERE,EAAN,cAA2B,KAAM,CAAC,EAE5BC,EAG0B,CAAIC,EAAUC,IAA2B,CAC9E,GAAIN,EAAUK,CAAK,EACjB,MAAM,IAAIF,EAAaG,CAAO,CAElC,ECdO,IAAMC,EAAiBC,GACrBC,EAAWD,CAAK,EAAI,CAACA,CAAK,EAAI,CAAC,
|
|
6
|
-
"names": ["alphabet", "lookupTable", "i", "lookUpTable", "isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "value", "nonNullish", "isBrowser", "nanoid", "size", "id", "
|
|
3
|
+
"sources": ["../../../../node_modules/@dfinity/principal/src/utils/base32.ts", "../../../../node_modules/@dfinity/principal/src/utils/getCrc.ts", "../../../utils/src/utils/debounce.utils.ts", "../../../utils/src/utils/json.utils.ts", "../../../utils/src/utils/null.utils.ts", "../../../utils/src/utils/did.utils.ts", "../../../utils/src/utils/env.utils.ts", "../../../../node_modules/nanoid/url-alphabet/index.js", "../../../../node_modules/nanoid/index.browser.js", "../../src/utils/date.utils.ts", "../../src/utils/analytics.utils.ts", "../../src/utils/log.utils.ts", "../../src/services/analytics.services.ts", "../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["const alphabet = 'abcdefghijklmnopqrstuvwxyz234567';\n\n// Build a lookup table for decoding.\nconst lookupTable: Record<string, number> = Object.create(null);\nfor (let i = 0; i < alphabet.length; i++) {\n lookupTable[alphabet[i]] = i;\n}\n\n// Add aliases for rfc4648.\nlookupTable['0'] = lookupTable.o;\nlookupTable['1'] = lookupTable.i;\n\n/**\n * @param input The input array to encode.\n * @returns A Base32 string encoding the input.\n */\nexport function encode(input: Uint8Array): string {\n // How many bits will we skip from the first byte.\n let skip = 0;\n // 5 high bits, carry from one byte to the next.\n let bits = 0;\n\n // The output string in base32.\n let output = '';\n\n function encodeByte(byte: number) {\n if (skip < 0) {\n // we have a carry from the previous byte\n bits |= byte >> -skip;\n } else {\n // no carry\n bits = (byte << skip) & 248;\n }\n\n if (skip > 3) {\n // Not enough data to produce a character, get us another one\n skip -= 8;\n return 1;\n }\n\n if (skip < 4) {\n // produce a character\n output += alphabet[bits >> 3];\n skip += 5;\n }\n\n return 0;\n }\n\n for (let i = 0; i < input.length; ) {\n i += encodeByte(input[i]);\n }\n\n return output + (skip < 0 ? alphabet[bits >> 3] : '');\n}\n\n/**\n * @param input The base32 encoded string to decode.\n */\nexport function decode(input: string): Uint8Array {\n // how many bits we have from the previous character.\n let skip = 0;\n // current byte we're producing.\n let byte = 0;\n\n const output = new Uint8Array(((input.length * 4) / 3) | 0);\n let o = 0;\n\n function decodeChar(char: string) {\n // Consume a character from the stream, store\n // the output in this.output. As before, better\n // to use update().\n let val = lookupTable[char.toLowerCase()];\n if (val === undefined) {\n throw new Error(`Invalid character: ${JSON.stringify(char)}`);\n }\n\n // move to the high bits\n val <<= 3;\n byte |= val >>> skip;\n skip += 5;\n\n if (skip >= 8) {\n // We have enough bytes to produce an output\n output[o++] = byte;\n skip -= 8;\n\n if (skip > 0) {\n byte = (val << (5 - skip)) & 255;\n } else {\n byte = 0;\n }\n }\n }\n\n for (const c of input) {\n decodeChar(c);\n }\n\n return output.slice(0, o);\n}\n", "// This file is translated to JavaScript from\n// https://lxp32.github.io/docs/a-simple-example-crc32-calculation/\nconst lookUpTable: Uint32Array = new Uint32Array([\n 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,\n 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,\n 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,\n 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,\n 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,\n 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,\n 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,\n 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,\n 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,\n 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,\n 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,\n 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,\n 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,\n 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,\n 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,\n 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,\n 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,\n 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,\n 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,\n 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,\n 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,\n 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,\n 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,\n 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,\n 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,\n 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,\n 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,\n 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,\n 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,\n 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,\n 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,\n 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,\n]);\n\n/**\n * Calculate the CRC32 of an ArrayBufferLike.\n * @param buf The BufferLike to calculate the CRC32 of.\n */\nexport function getCrc32(buf: ArrayBufferLike): number {\n const b = new Uint8Array(buf);\n let crc = -1;\n\n for (let i = 0; i < b.length; i++) {\n const byte = b[i];\n const t = (byte ^ crc) & 0xff;\n crc = lookUpTable[t] ^ (crc >>> 8);\n }\n\n return (crc ^ -1) >>> 0;\n}\n", "/* eslint-disable-next-line @typescript-eslint/ban-types */\nexport const debounce = (func: Function, timeout?: number) => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: unknown[]) => {\n const next = () => func(...args);\n\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(next, timeout !== undefined && timeout > 0 ? timeout : 300);\n };\n};\n", "import {Principal} from '@dfinity/principal';\nimport {nonNullish} from './null.utils';\n\nconst JSON_KEY_BIGINT = '__bigint__';\nconst JSON_KEY_PRINCIPAL = '__principal__';\nconst JSON_KEY_UINT8ARRAY = '__uint8array__';\n\n/**\n * A parser that interprets revived BigInt, Principal, and Uint8Array when constructing JavaScript values or objects.\n */\nexport const jsonReplacer = (_key: string, value: unknown): unknown => {\n if (typeof value === 'bigint') {\n return {[JSON_KEY_BIGINT]: `${value}`};\n }\n\n if (nonNullish(value) && value instanceof Principal) {\n return {[JSON_KEY_PRINCIPAL]: value.toText()};\n }\n\n if (nonNullish(value) && value instanceof Uint8Array) {\n return {[JSON_KEY_UINT8ARRAY]: Array.from(value)};\n }\n\n return value;\n};\n\n/**\n * A function that alters the behavior of the stringification process for BigInt, Principal and Uint8Array.\n */\nexport const jsonReviver = (_key: string, value: unknown): unknown => {\n const mapValue = <T>(key: string): T => (value as Record<string, T>)[key];\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_BIGINT in value) {\n return BigInt(mapValue(JSON_KEY_BIGINT));\n }\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_PRINCIPAL in value) {\n return Principal.fromText(mapValue(JSON_KEY_PRINCIPAL));\n }\n\n if (nonNullish(value) && typeof value === 'object' && JSON_KEY_UINT8ARRAY in value) {\n return Uint8Array.from(mapValue(JSON_KEY_UINT8ARRAY));\n }\n\n return value;\n};\n", "/** Is null or undefined */\nexport const isNullish = <T>(argument: T | undefined | null): argument is undefined | null =>\n argument === null || argument === undefined;\n\n/** Not null and not undefined */\nexport const nonNullish = <T>(argument: T | undefined | null): argument is NonNullable<T> =>\n !isNullish(argument);\n\nexport class NullishError extends Error {}\n\nexport const assertNonNullish: <T>(\n value: T,\n message?: string\n) => asserts value is NonNullable<T> = <T>(value: T, message?: string): void => {\n if (isNullish(value)) {\n throw new NullishError(message);\n }\n};\n", "import {jsonReplacer, jsonReviver} from './json.utils';\nimport {nonNullish} from './null.utils';\n\nexport const toNullable = <T>(value?: T): [] | [T] => {\n return nonNullish(value) ? [value] : [];\n};\n\nexport const fromNullable = <T>(value: [] | [T]): T | undefined => {\n return value?.[0];\n};\n\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob: Blob = new Blob([JSON.stringify(data, jsonReplacer)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob: Blob = new Blob([data instanceof Uint8Array ? data : new Uint8Array(data)], {\n type: 'application/json; charset=utf-8'\n });\n return JSON.parse(await blob.text(), jsonReviver);\n};\n", "import {nonNullish} from './null.utils';\n\nexport const isBrowser = () => typeof window !== `undefined`;\n\nexport const processEnv = ({\n key,\n envPrefix\n}: {\n key: 'SATELLITE_ID' | 'ORBITER_ID' | 'CONTAINER';\n envPrefix?: string;\n}): string | undefined =>\n typeof process !== 'undefined'\n ? nonNullish(envPrefix)\n ? process.env[`${envPrefix}${key}`]\n : process.env[`NEXT_PUBLIC_${key}`] ??\n process.env[`VITE_${key}`] ??\n process.env[`PUBLIC_${key}`]\n : undefined;\n", "export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n", "import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array(size))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n", "export const nowInBigIntNanoSeconds = (): bigint => BigInt(Date.now()) * BigInt(1e6);\n", "import {toNullable} from '@junobuild/utils';\nimport {nowInBigIntNanoSeconds} from './date.utils';\n\nexport const timestamp = (): {\n collected_at: bigint;\n updated_at: [] | [bigint];\n version: [] | [bigint];\n} => ({\n collected_at: nowInBigIntNanoSeconds(),\n updated_at: [],\n version: []\n});\n\nexport const userAgent = (): {user_agent: [] | [string]} => {\n const {userAgent} = navigator;\n return {user_agent: toNullable(userAgent)};\n};\n", "import {isNullish} from '@junobuild/utils';\n\nconst WORKER_UNDEFINED_MSG =\n 'Analytics worker not initialized. Did you call `initOrbiter`?' as const;\n\nexport const warningWorkerNotInitialized = <T>(value: T) => {\n if (isNullish(value)) {\n console.warn(WORKER_UNDEFINED_MSG);\n }\n};\n", "import {assertNonNullish, isBrowser, nonNullish, toNullable} from '@junobuild/utils';\nimport {nanoid} from 'nanoid';\nimport type {Environment, EnvironmentWorker} from '../types/env';\nimport type {IdbPageView} from '../types/idb';\nimport type {PostMessageInitEnvData} from '../types/post-message';\nimport type {TrackEvent} from '../types/track';\nimport {timestamp, userAgent} from '../utils/analytics.utils';\nimport {warningWorkerNotInitialized} from '../utils/log.utils';\n\nconst initSessionId = (): string | undefined => {\n // I faced this issue when I used the library in Docusaurus which does not implement the crypto API when server-side rendering.\n // https://github.com/ai/nanoid/issues?q=crypto+not+defined\n if (typeof crypto === 'undefined') {\n return undefined;\n }\n\n return nanoid();\n};\n\nconst sessionId = initSessionId();\n\nlet worker: Worker | undefined;\n\nexport const initWorker = (env: Environment): {cleanup: () => void} => {\n const {path}: EnvironmentWorker = env.worker ?? {};\n const workerUrl = path === undefined ? './workers/analytics.worker.js' : path;\n\n worker = new Worker(workerUrl);\n\n const consoleWarn = () =>\n console.warn('Unable to connect to the analytics web worker. Have you deployed it?');\n\n worker?.addEventListener('error', consoleWarn, false);\n\n initWorkerEnvironment(env);\n\n return {\n cleanup() {\n worker?.removeEventListener('error', consoleWarn, false);\n }\n };\n};\n\nexport const initTrackPageViews = (): {cleanup: () => void} => {\n const trackPages = async () => await trackPageView();\n\n let pushStateProxy: typeof history.pushState | null = new Proxy(history.pushState, {\n apply: async (\n target,\n thisArg,\n argArray: [data: unknown, unused: string, url?: string | URL | null | undefined]\n ) => {\n target.apply(thisArg, argArray);\n await trackPages();\n }\n });\n\n history.pushState = pushStateProxy;\n\n addEventListener('popstate', trackPages, {passive: true});\n\n return {\n cleanup() {\n pushStateProxy = null;\n removeEventListener('popstate', trackPages, false);\n }\n };\n};\n\nconst SESSION_ID_UNDEFINED_MSG = 'No session ID initialized.' as const;\n\nexport const setPageView = async () => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n\n const {\n title,\n location: {href},\n referrer\n } = document;\n const {innerWidth, innerHeight} = window;\n const {timeZone} = Intl.DateTimeFormat().resolvedOptions();\n\n const data: IdbPageView = {\n title,\n href,\n referrer: toNullable(nonNullish(referrer) && referrer !== '' ? referrer : undefined),\n device: {\n inner_width: innerWidth,\n inner_height: innerHeight\n },\n time_zone: timeZone,\n session_id: sessionId as string,\n ...userAgent(),\n ...timestamp()\n };\n\n const idb = await import('./idb.services');\n await idb.setPageView({\n key: nanoid(),\n view: data\n });\n};\n\nexport const trackPageView = async () => {\n warningWorkerNotInitialized(worker);\n\n await setPageView();\n\n worker?.postMessage({msg: 'junoTrackPageView'});\n};\n\nexport const trackEvent = async (data: TrackEvent) => {\n if (!isBrowser()) {\n return;\n }\n\n assertNonNullish(sessionId, SESSION_ID_UNDEFINED_MSG);\n warningWorkerNotInitialized(worker);\n\n const idb = await import('./idb.services');\n await idb.setTrackEvent({\n key: nanoid(),\n track: {...data, session_id: sessionId as string, ...userAgent(), ...timestamp()}\n });\n\n worker?.postMessage({msg: 'junoTrackEvent'});\n};\n\nexport const initWorkerEnvironment = (env: PostMessageInitEnvData) => {\n warningWorkerNotInitialized(worker);\n\n worker?.postMessage({msg: 'junoInitEnvironment', data: env});\n};\n\nexport const startTracking = () => {\n warningWorkerNotInitialized(worker);\n\n worker?.postMessage({msg: 'junoStartTrackTimer'});\n};\n\nexport const stopTracking = () => {\n warningWorkerNotInitialized(worker);\n\n worker?.postMessage({msg: 'junoStopTracker'});\n};\n", "import {assertNonNullish, processEnv} from '@junobuild/utils';\nimport {\n initTrackPageViews,\n initWorker,\n setPageView,\n startTracking,\n stopTracking\n} from './services/analytics.services';\nimport type {Environment, UserEnvironment} from './types/env';\n\nexport {trackEvent, trackPageView} from './services/analytics.services';\nexport * from './types/env';\n\nconst parseEnv = (userEnv?: UserEnvironment): Environment => {\n const satelliteId =\n userEnv?.satelliteId ?? processEnv({key: 'SATELLITE_ID', envPrefix: userEnv?.envPrefix});\n\n assertNonNullish(\n satelliteId,\n 'Satellite ID is not configured. Orbiter cannot be initialized without a target Satellite.'\n );\n\n const orbiterId =\n userEnv?.orbiterId ?? processEnv({key: 'ORBITER_ID', envPrefix: userEnv?.envPrefix});\n\n assertNonNullish(\n orbiterId,\n 'Orbiter ID is not configured. The analytics cannot be initialized without an Orbiter.'\n );\n\n const container =\n userEnv?.container ?? processEnv({key: 'CONTAINER', envPrefix: userEnv?.envPrefix});\n\n return {\n orbiterId,\n satelliteId,\n container,\n worker: userEnv?.worker\n };\n};\n\nexport const initOrbiter = async (userEnv?: UserEnvironment): Promise<() => void> => {\n // Save first page as soon as possible\n await setPageView();\n\n const env = parseEnv(userEnv);\n\n const {cleanup: workerCleanup} = initWorker(env);\n\n const {cleanup: pushHistoryCleanup} = initTrackPageViews();\n\n // Starting tracking will instantly sync the first page and the data from previous sessions that have not been synced yet\n startTracking();\n\n return () => {\n stopTracking();\n workerCleanup();\n pushHistoryCleanup();\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["alphabet", "lookupTable", "i", "lookUpTable", "isNullish", "argument", "nonNullish", "NullishError", "assertNonNullish", "value", "message", "toNullable", "value", "nonNullish", "isBrowser", "processEnv", "key", "envPrefix", "nonNullish", "urlAlphabet", "nanoid", "size", "id", "bytes", "urlAlphabet", "nowInBigIntNanoSeconds", "timestamp", "nowInBigIntNanoSeconds", "userAgent", "g", "WORKER_UNDEFINED_MSG", "warningWorkerNotInitialized", "value", "initSessionId", "nanoid", "sessionId", "worker", "initWorker", "env", "path", "workerUrl", "consoleWarn", "initWorkerEnvironment", "initTrackPageViews", "trackPages", "trackPageView", "pushStateProxy", "target", "thisArg", "argArray", "SESSION_ID_UNDEFINED_MSG", "setPageView", "j", "d", "title", "href", "referrer", "innerWidth", "innerHeight", "timeZone", "data", "g", "o", "userAgent", "timestamp", "warningWorkerNotInitialized", "trackEvent", "startTracking", "stopTracking", "parseEnv", "userEnv", "satelliteId", "h", "d", "orbiterId", "container", "initOrbiter", "setPageView", "env", "workerCleanup", "initWorker", "pushHistoryCleanup", "initTrackPageViews", "startTracking", "stopTracking"]
|
|
7
7
|
}
|
|
@@ -51,7 +51,7 @@ export interface Controller {
|
|
|
51
51
|
}
|
|
52
52
|
export type ControllerScope = {Write: null} | {Admin: null};
|
|
53
53
|
export interface DelSatelliteConfig {
|
|
54
|
-
|
|
54
|
+
version: [] | [bigint];
|
|
55
55
|
}
|
|
56
56
|
export interface DeleteControllersArgs {
|
|
57
57
|
controllers: Array<Principal>;
|
|
@@ -72,6 +72,7 @@ export interface MemorySize {
|
|
|
72
72
|
export interface OrbiterSatelliteConfig {
|
|
73
73
|
updated_at: bigint;
|
|
74
74
|
created_at: bigint;
|
|
75
|
+
version: [] | [bigint];
|
|
75
76
|
enabled: boolean;
|
|
76
77
|
}
|
|
77
78
|
export interface PageView {
|
|
@@ -84,6 +85,7 @@ export interface PageView {
|
|
|
84
85
|
created_at: bigint;
|
|
85
86
|
satellite_id: Principal;
|
|
86
87
|
device: PageViewDevice;
|
|
88
|
+
version: [] | [bigint];
|
|
87
89
|
user_agent: [] | [string];
|
|
88
90
|
}
|
|
89
91
|
export interface PageViewDevice {
|
|
@@ -111,10 +113,11 @@ export interface SetPageView {
|
|
|
111
113
|
href: string;
|
|
112
114
|
satellite_id: Principal;
|
|
113
115
|
device: PageViewDevice;
|
|
116
|
+
version: [] | [bigint];
|
|
114
117
|
user_agent: [] | [string];
|
|
115
118
|
}
|
|
116
119
|
export interface SetSatelliteConfig {
|
|
117
|
-
|
|
120
|
+
version: [] | [bigint];
|
|
118
121
|
enabled: boolean;
|
|
119
122
|
}
|
|
120
123
|
export interface SetTrackEvent {
|
|
@@ -123,6 +126,7 @@ export interface SetTrackEvent {
|
|
|
123
126
|
metadata: [] | [Array<[string, string]>];
|
|
124
127
|
name: string;
|
|
125
128
|
satellite_id: Principal;
|
|
129
|
+
version: [] | [bigint];
|
|
126
130
|
user_agent: [] | [string];
|
|
127
131
|
}
|
|
128
132
|
export interface TrackEvent {
|
|
@@ -132,6 +136,7 @@ export interface TrackEvent {
|
|
|
132
136
|
name: string;
|
|
133
137
|
created_at: bigint;
|
|
134
138
|
satellite_id: Principal;
|
|
139
|
+
version: [] | [bigint];
|
|
135
140
|
}
|
|
136
141
|
export interface _SERVICE {
|
|
137
142
|
del_controllers: ActorMethod<[DeleteControllersArgs], Array<[Principal, Controller]>>;
|
|
@@ -14,7 +14,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
14
14
|
scope: ControllerScope,
|
|
15
15
|
expires_at: IDL.Opt(IDL.Nat64)
|
|
16
16
|
});
|
|
17
|
-
const DelSatelliteConfig = IDL.Record({
|
|
17
|
+
const DelSatelliteConfig = IDL.Record({version: IDL.Opt(IDL.Nat64)});
|
|
18
18
|
const DepositCyclesArgs = IDL.Record({
|
|
19
19
|
cycles: IDL.Nat,
|
|
20
20
|
destination_id: IDL.Principal
|
|
@@ -42,6 +42,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
42
42
|
created_at: IDL.Nat64,
|
|
43
43
|
satellite_id: IDL.Principal,
|
|
44
44
|
device: PageViewDevice,
|
|
45
|
+
version: IDL.Opt(IDL.Nat64),
|
|
45
46
|
user_agent: IDL.Opt(IDL.Text)
|
|
46
47
|
});
|
|
47
48
|
const AnalyticsBrowsersPageViews = IDL.Record({
|
|
@@ -83,7 +84,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
83
84
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
84
85
|
name: IDL.Text,
|
|
85
86
|
created_at: IDL.Nat64,
|
|
86
|
-
satellite_id: IDL.Principal
|
|
87
|
+
satellite_id: IDL.Principal,
|
|
88
|
+
version: IDL.Opt(IDL.Nat64)
|
|
87
89
|
});
|
|
88
90
|
const AnalyticsTrackEvents = IDL.Record({
|
|
89
91
|
total: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Nat32))
|
|
@@ -91,6 +93,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
91
93
|
const OrbiterSatelliteConfig = IDL.Record({
|
|
92
94
|
updated_at: IDL.Nat64,
|
|
93
95
|
created_at: IDL.Nat64,
|
|
96
|
+
version: IDL.Opt(IDL.Nat64),
|
|
94
97
|
enabled: IDL.Bool
|
|
95
98
|
});
|
|
96
99
|
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
@@ -112,6 +115,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
112
115
|
href: IDL.Text,
|
|
113
116
|
satellite_id: IDL.Principal,
|
|
114
117
|
device: PageViewDevice,
|
|
118
|
+
version: IDL.Opt(IDL.Nat64),
|
|
115
119
|
user_agent: IDL.Opt(IDL.Text)
|
|
116
120
|
});
|
|
117
121
|
const Result = IDL.Variant({Ok: PageView, Err: IDL.Text});
|
|
@@ -120,7 +124,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
120
124
|
Err: IDL.Vec(IDL.Tuple(AnalyticKey, IDL.Text))
|
|
121
125
|
});
|
|
122
126
|
const SetSatelliteConfig = IDL.Record({
|
|
123
|
-
|
|
127
|
+
version: IDL.Opt(IDL.Nat64),
|
|
124
128
|
enabled: IDL.Bool
|
|
125
129
|
});
|
|
126
130
|
const SetTrackEvent = IDL.Record({
|
|
@@ -129,6 +133,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
129
133
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
130
134
|
name: IDL.Text,
|
|
131
135
|
satellite_id: IDL.Principal,
|
|
136
|
+
version: IDL.Opt(IDL.Nat64),
|
|
132
137
|
user_agent: IDL.Opt(IDL.Text)
|
|
133
138
|
});
|
|
134
139
|
const Result_2 = IDL.Variant({Ok: TrackEvent, Err: IDL.Text});
|
|
@@ -14,7 +14,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
14
14
|
scope: ControllerScope,
|
|
15
15
|
expires_at: IDL.Opt(IDL.Nat64)
|
|
16
16
|
});
|
|
17
|
-
const DelSatelliteConfig = IDL.Record({
|
|
17
|
+
const DelSatelliteConfig = IDL.Record({version: IDL.Opt(IDL.Nat64)});
|
|
18
18
|
const DepositCyclesArgs = IDL.Record({
|
|
19
19
|
cycles: IDL.Nat,
|
|
20
20
|
destination_id: IDL.Principal
|
|
@@ -42,6 +42,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
42
42
|
created_at: IDL.Nat64,
|
|
43
43
|
satellite_id: IDL.Principal,
|
|
44
44
|
device: PageViewDevice,
|
|
45
|
+
version: IDL.Opt(IDL.Nat64),
|
|
45
46
|
user_agent: IDL.Opt(IDL.Text)
|
|
46
47
|
});
|
|
47
48
|
const AnalyticsBrowsersPageViews = IDL.Record({
|
|
@@ -83,7 +84,8 @@ export const idlFactory = ({IDL}) => {
|
|
|
83
84
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
84
85
|
name: IDL.Text,
|
|
85
86
|
created_at: IDL.Nat64,
|
|
86
|
-
satellite_id: IDL.Principal
|
|
87
|
+
satellite_id: IDL.Principal,
|
|
88
|
+
version: IDL.Opt(IDL.Nat64)
|
|
87
89
|
});
|
|
88
90
|
const AnalyticsTrackEvents = IDL.Record({
|
|
89
91
|
total: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Nat32))
|
|
@@ -91,6 +93,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
91
93
|
const OrbiterSatelliteConfig = IDL.Record({
|
|
92
94
|
updated_at: IDL.Nat64,
|
|
93
95
|
created_at: IDL.Nat64,
|
|
96
|
+
version: IDL.Opt(IDL.Nat64),
|
|
94
97
|
enabled: IDL.Bool
|
|
95
98
|
});
|
|
96
99
|
const MemorySize = IDL.Record({stable: IDL.Nat64, heap: IDL.Nat64});
|
|
@@ -112,6 +115,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
112
115
|
href: IDL.Text,
|
|
113
116
|
satellite_id: IDL.Principal,
|
|
114
117
|
device: PageViewDevice,
|
|
118
|
+
version: IDL.Opt(IDL.Nat64),
|
|
115
119
|
user_agent: IDL.Opt(IDL.Text)
|
|
116
120
|
});
|
|
117
121
|
const Result = IDL.Variant({Ok: PageView, Err: IDL.Text});
|
|
@@ -120,7 +124,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
120
124
|
Err: IDL.Vec(IDL.Tuple(AnalyticKey, IDL.Text))
|
|
121
125
|
});
|
|
122
126
|
const SetSatelliteConfig = IDL.Record({
|
|
123
|
-
|
|
127
|
+
version: IDL.Opt(IDL.Nat64),
|
|
124
128
|
enabled: IDL.Bool
|
|
125
129
|
});
|
|
126
130
|
const SetTrackEvent = IDL.Record({
|
|
@@ -129,6 +133,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
129
133
|
metadata: IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))),
|
|
130
134
|
name: IDL.Text,
|
|
131
135
|
satellite_id: IDL.Principal,
|
|
136
|
+
version: IDL.Opt(IDL.Nat64),
|
|
132
137
|
user_agent: IDL.Opt(IDL.Text)
|
|
133
138
|
});
|
|
134
139
|
const Result_2 = IDL.Variant({Ok: TrackEvent, Err: IDL.Text});
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var Je=Object.create;var G=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var Ze=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var we=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Qe=(e,t)=>{for(var r in t)G(e,r,{get:t[r],enumerable:!0})},et=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ye(t))!ze.call(e,o)&&o!==r&&G(e,o,{get:()=>t[o],enumerable:!(n=$e(t,o))||n.enumerable});return e};var tt=(e,t,r)=>(r=e!=null?Je(Xe(e)):{},et(t||!e||!e.__esModule?G(r,"default",{value:e,enumerable:!0}):r,e));var me=h(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.decode=I.encode=void 0;var L="abcdefghijklmnopqrstuvwxyz234567",k=Object.create(null);for(let e=0;e<L.length;e++)k[L[e]]=e;k[0]=k.o;k[1]=k.i;function rt(e){let t=0,r=0,n="";function o(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=L[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=o(e[s]);return n+(t<0?L[r>>3]:"")}I.encode=rt;function nt(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),o=0;function s(a){let c=k[a.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(a)}`);c<<=3,r|=c>>>t,t+=5,t>=8&&(n[o++]=r,t-=8,t>0?r=c<<5-t&255:r=0)}for(let a of e)s(a);return n.slice(0,o)}I.decode=nt});var _e=h(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.getCrc32=void 0;var ot=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function st(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=ot[s]^r>>>8}return(r^-1)>>>0}j.getCrc32=st});var $=h(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});u.output=u.exists=u.hash=u.bytes=u.bool=u.number=u.isBytes=void 0;function N(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}u.number=N;function ve(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}u.bool=ve;function Ae(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}u.isBytes=Ae;function J(e,...t){if(!Ae(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}u.bytes=J;function Ee(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");N(e.outputLen),N(e.blockLen)}u.hash=Ee;function ke(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}u.exists=ke;function Ie(e,t){J(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}u.output=Ie;var it={number:N,bool:ve,bytes:J,hash:Ee,exists:ke,output:Ie};u.default=it});var Pe=h(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.crypto=void 0;var C=Ze("node:crypto");M.crypto=C&&typeof C=="object"&&"webcrypto"in C?C.webcrypto:void 0});var Z=h(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.randomBytes=i.wrapXOFConstructorWithOpts=i.wrapConstructorWithOpts=i.wrapConstructor=i.checkOpts=i.Hash=i.concatBytes=i.toBytes=i.utf8ToBytes=i.asyncLoop=i.nextTick=i.hexToBytes=i.bytesToHex=i.byteSwap32=i.byteSwapIfBE=i.byteSwap=i.isLE=i.rotl=i.rotr=i.createView=i.u32=i.u8=i.isBytes=void 0;var Y=Pe(),z=$();function at(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}i.isBytes=at;var ct=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);i.u8=ct;var ft=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));i.u32=ft;var dt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);i.createView=dt;var ut=(e,t)=>e<<32-t|e>>>t;i.rotr=ut;var xt=(e,t)=>e<<t|e>>>32-t>>>0;i.rotl=xt;i.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var lt=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;i.byteSwap=lt;i.byteSwapIfBE=i.isLE?e=>e:e=>(0,i.byteSwap)(e);function bt(e){for(let t=0;t<e.length;t++)e[t]=(0,i.byteSwap)(e[t])}i.byteSwap32=bt;var pt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ht(e){(0,z.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=pt[e[r]];return t}i.bytesToHex=ht;var y={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Te(e){if(e>=y._0&&e<=y._9)return e-y._0;if(e>=y._A&&e<=y._F)return e-(y._A-10);if(e>=y._a&&e<=y._f)return e-(y._a-10)}function yt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let a=Te(e.charCodeAt(s)),c=Te(e.charCodeAt(s+1));if(a===void 0||c===void 0){let d=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+s)}n[o]=a*16+c}return n}i.hexToBytes=yt;var gt=async()=>{};i.nextTick=gt;async function wt(e,t,r){let n=Date.now();for(let o=0;o<e;o++){r(o);let s=Date.now()-n;s>=0&&s<t||(await(0,i.nextTick)(),n+=s)}}i.asyncLoop=wt;function Se(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}i.utf8ToBytes=Se;function V(e){return typeof e=="string"&&(e=Se(e)),(0,z.bytes)(e),e}i.toBytes=V;function mt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];(0,z.bytes)(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}i.concatBytes=mt;var X=class{clone(){return this._cloneInto()}};i.Hash=X;var _t={}.toString;function vt(e,t){if(t!==void 0&&_t.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(e,t)}i.checkOpts=vt;function At(e){let t=n=>e().update(V(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}i.wrapConstructor=At;function Et(e){let t=(n,o)=>e(o).update(V(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}i.wrapConstructorWithOpts=Et;function kt(e){let t=(n,o)=>e(o).update(V(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}i.wrapXOFConstructorWithOpts=kt;function It(e=32){if(Y.crypto&&typeof Y.crypto.getRandomValues=="function")return Y.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}i.randomBytes=It});var Be=h(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.HashMD=w.Maj=w.Chi=void 0;var Q=$(),U=Z();function Pt(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),a=Number(r>>o&s),c=Number(r&s),d=n?4:0,b=n?0:4;e.setUint32(t+d,a,n),e.setUint32(t+b,c,n)}var Tt=(e,t,r)=>e&t^~e&r;w.Chi=Tt;var St=(e,t,r)=>e&t^e&r^t&r;w.Maj=St;var ee=class extends U.Hash{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,U.createView)(this.buffer)}update(t){(0,Q.exists)(this);let{view:r,buffer:n,blockLen:o}=this;t=(0,U.toBytes)(t);let s=t.length;for(let a=0;a<s;){let c=Math.min(o-this.pos,s-a);if(c===o){let d=(0,U.createView)(t);for(;o<=s-a;a+=o)this.process(d,a);continue}n.set(t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,Q.exists)(this),(0,Q.output)(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(n,0),a=0);for(let f=a;f<o;f++)r[f]=0;Pt(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=(0,U.createView)(t),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let b=d/4,g=this.get();if(b>g.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<b;f++)c.setUint32(4*f,g[f],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:a,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=a,o%r&&t.buffer.set(n),t}};w.HashMD=ee});var Ue=h(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.sha224=P.sha256=void 0;var te=Be(),l=Z(),Bt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),m=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_=new Uint32Array(64),D=class extends te.HashMD{constructor(){super(64,32,8,!1),this.A=m[0]|0,this.B=m[1]|0,this.C=m[2]|0,this.D=m[3]|0,this.E=m[4]|0,this.F=m[5]|0,this.G=m[6]|0,this.H=m[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:a,G:c,H:d}=this;return[t,r,n,o,s,a,c,d]}set(t,r,n,o,s,a,c,d){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=c|0,this.H=d|0}process(t,r){for(let f=0;f<16;f++,r+=4)_[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let B=_[f-15],E=_[f-2],ge=(0,l.rotr)(B,7)^(0,l.rotr)(B,18)^B>>>3,q=(0,l.rotr)(E,17)^(0,l.rotr)(E,19)^E>>>10;_[f]=q+_[f-7]+ge+_[f-16]|0}let{A:n,B:o,C:s,D:a,E:c,F:d,G:b,H:g}=this;for(let f=0;f<64;f++){let B=(0,l.rotr)(c,6)^(0,l.rotr)(c,11)^(0,l.rotr)(c,25),E=g+B+(0,te.Chi)(c,d,b)+Bt[f]+_[f]|0,q=((0,l.rotr)(n,2)^(0,l.rotr)(n,13)^(0,l.rotr)(n,22))+(0,te.Maj)(n,o,s)|0;g=b,b=d,d=c,c=a+E|0,a=s,s=o,o=n,n=E+q|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,d=d+this.F|0,b=b+this.G|0,g=g+this.H|0,this.set(n,o,s,a,c,d,b,g)}roundClean(){_.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},re=class extends D{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};P.sha256=(0,l.wrapConstructor)(()=>new D);P.sha224=(0,l.wrapConstructor)(()=>new re)});var Oe=h(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.sha224=void 0;var Ut=Ue();function Ot(e){return Ut.sha224.create().update(new Uint8Array(e)).digest()}H.sha224=Ot});var Ne=h(p=>{"use strict";Object.defineProperty(p,"__esModule",{value:!0});p.Principal=p.JSON_KEY_PRINCIPAL=void 0;var Le=me(),Lt=_e(),jt=Oe();p.JSON_KEY_PRINCIPAL="__principal__";var Nt=2,je=4,Ct="aaaaa-aa",Mt=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},Vt=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),ne=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([je]))}static managementCanister(){return this.fromHex(Ct)}static selfAuthenticating(t){let r=(0,jt.sha224)(t);return new this(new Uint8Array([...r,Nt]))}static from(t){if(typeof t=="string")return e.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new e(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new e(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(Mt(t))}static fromText(t){let r=t;if(t.includes(p.JSON_KEY_PRINCIPAL)){let a=JSON.parse(t);p.JSON_KEY_PRINCIPAL in a&&(r=a[p.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),o=(0,Le.decode)(n);o=o.slice(4,o.length);let s=new this(o);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===je}toUint8Array(){return this._arr}toHex(){return Vt(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,(0,Lt.getCrc32)(this._arr));let n=new Uint8Array(t),o=Uint8Array.from(this._arr),s=new Uint8Array([...n,...o]),c=(0,Le.encode)(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[p.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(t){for(let r=0;r<Math.min(this._arr.length,t._arr.length);r++){if(this._arr[r]<t._arr[r])return"lt";if(this._arr[r]>t._arr[r])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let r=this.compareTo(t);return r=="lt"||r=="eq"}gtEq(t){let r=this.compareTo(t);return r=="gt"||r=="eq"}};p.Principal=ne});function S(e){return new Promise((t,r)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>r(e.error)})}function K(e,t){let r=indexedDB.open(e);r.onupgradeneeded=()=>r.result.createObjectStore(t);let n=S(r);return(o,s)=>n.then(a=>s(a.transaction(t,o).objectStore(t)))}function fe(){return ce||(ce=K("keyval-store","keyval")),ce}function de(e,t,r=fe()){return r("readwrite",n=>(n.put(t,e),S(n.transaction)))}function ue(e,t=fe()){return t("readwrite",r=>(e.forEach(n=>r.delete(n)),S(r.transaction)))}function Kt(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},S(e.transaction)}function xe(e=fe()){return e("readonly",t=>{if(t.getAll&&t.getAllKeys)return Promise.all([S(t.getAllKeys()),S(t.getAll())]).then(([n,o])=>n.map((s,a)=>[s,o[a]]));let r=[];return e("readonly",n=>Kt(n,o=>r.push([o.key,o.value])).then(()=>r))})}var ce,He=we(()=>{});var pe={};Qe(pe,{delPageViews:()=>Gt,delTrackEvents:()=>Yt,getPageViews:()=>qt,getTrackEvents:()=>$t,setPageView:()=>Wt,setTrackEvent:()=>Jt});var le,be,Wt,qt,Gt,Jt,$t,Yt,he=we(()=>{"use strict";He();le=K("juno-views","views"),be=K("juno-events","events"),Wt=({key:e,view:t})=>de(e,t,le),qt=()=>xe(le),Gt=e=>ue(e,le),Jt=({key:e,track:t})=>de(e,t,be),$t=()=>xe(be),Yt=e=>ue(e,be)});var Dt=tt(Ne(),1);var Ce=e=>e==null,oe=e=>!Ce(e),Ht=class extends Error{},v=(e,t)=>{if(Ce(e))throw new Ht(t)};var F=e=>oe(e)?[e]:[];var se=()=>typeof window<"u";import{randomFillSync as Ve}from"crypto";var Me="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Ft=128,A,T,Rt=e=>{!A||A.length<e?(A=Buffer.allocUnsafe(e*Ft),Ve(A),T=0):T+e>A.length&&(Ve(A),T=0),T+=e};var R=(e=21)=>{Rt(e-=0);let t="";for(let r=T-e;r<T;r++)t+=Me[A[r]&63];return t};var De=()=>BigInt(Date.now())*BigInt(1e6);var ie=()=>({collected_at:De(),updated_at:[]}),ae=()=>{let{userAgent:e}=navigator;return{user_agent:F(e)}};var Xt=()=>{if(!(typeof crypto>"u"))return R()},W=Xt(),x,Fe=e=>{let{path:t}=e.worker??{},r=t===void 0?"./workers/analytics.worker.js":t;x=new Worker(r);let n=()=>console.warn("Unable to connect to the analytics web worker. Have you deployed it?");return x?.addEventListener("error",n,!1),Zt(e),{cleanup(){x?.removeEventListener("error",n,!1)}}},Re=()=>{let e=async()=>await We(),t=new Proxy(history.pushState,{apply:async(r,n,o)=>{r.apply(n,o),await e()}});return history.pushState=t,addEventListener("popstate",e,{passive:!0}),{cleanup(){t=null,removeEventListener("popstate",e,!1)}}},O="Analytics worker not initialized. Did you call `initOrbiter`?",Ke="No session ID initialized.",ye=async()=>{if(!se())return;v(W,Ke);let{title:e,location:{href:t},referrer:r}=document,{innerWidth:n,innerHeight:o}=window,{timeZone:s}=Intl.DateTimeFormat().resolvedOptions(),a={title:e,href:t,referrer:F(oe(r)&&r!==""?r:void 0),device:{inner_width:n,inner_height:o},time_zone:s,session_id:W,...ae(),...ie()};await(await Promise.resolve().then(()=>(he(),pe))).setPageView({key:R(),view:a})},We=async()=>{v(x,O),await ye(),x?.postMessage({msg:"junoTrackPageView"})},zt=async e=>{if(!se())return;v(W,Ke),v(x,O),await(await Promise.resolve().then(()=>(he(),pe))).setTrackEvent({key:R(),track:{...e,session_id:W,...ae(),...ie()}}),x?.postMessage({msg:"junoTrackEvent"})},Zt=e=>{v(x,O),x?.postMessage({msg:"junoInitEnvironment",data:e})},qe=()=>{v(x,O),x?.postMessage({msg:"junoStartTrackTimer"})},Ge=()=>{v(x,O),x?.postMessage({msg:"junoStopTracker"})};var Ir=async e=>{await ye();let{cleanup:t}=Fe(e),{cleanup:r}=Re();return qe(),()=>{Ge(),t(),r()}};export{Ir as initOrbiter,zt as trackEvent,We as trackPageView};
|
|
3
|
+
var Je=Object.create;var z=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var Qe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var _e=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),et=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},tt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xe(t))!Ze.call(e,o)&&o!==r&&z(e,o,{get:()=>t[o],enumerable:!(n=ze(t,o))||n.enumerable});return e};var rt=(e,t,r)=>(r=e!=null?Je(Ye(e)):{},tt(t||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e));var ve=h(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.decode=E.encode=void 0;var N="abcdefghijklmnopqrstuvwxyz234567",A=Object.create(null);for(let e=0;e<N.length;e++)A[N[e]]=e;A[0]=A.o;A[1]=A.i;function nt(e){let t=0,r=0,n="";function o(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=N[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=o(e[s]);return n+(t<0?N[r>>3]:"")}E.encode=nt;function ot(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),o=0;function s(a){let c=A[a.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(a)}`);c<<=3,r|=c>>>t,t+=5,t>=8&&(n[o++]=r,t-=8,t>0?r=c<<5-t&255:r=0)}for(let a of e)s(a);return n.slice(0,o)}E.decode=ot});var Ie=h(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.getCrc32=void 0;var st=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function it(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=st[s]^r>>>8}return(r^-1)>>>0}L.getCrc32=it});var Y=h(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});u.output=u.exists=u.hash=u.bytes=u.bool=u.number=u.isBytes=void 0;function j(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}u.number=j;function Ae(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}u.bool=Ae;function Ee(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}u.isBytes=Ee;function X(e,...t){if(!Ee(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}u.bytes=X;function ke(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");j(e.outputLen),j(e.blockLen)}u.hash=ke;function Pe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}u.exists=Pe;function Te(e,t){X(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}u.output=Te;var at={number:j,bool:Ae,bytes:X,hash:ke,exists:Pe,output:Te};u.default=at});var Se=h(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.crypto=void 0;var C=Qe("node:crypto");M.crypto=C&&typeof C=="object"&&"webcrypto"in C?C.webcrypto:void 0});var te=h(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.randomBytes=i.wrapXOFConstructorWithOpts=i.wrapConstructorWithOpts=i.wrapConstructor=i.checkOpts=i.Hash=i.concatBytes=i.toBytes=i.utf8ToBytes=i.asyncLoop=i.nextTick=i.hexToBytes=i.bytesToHex=i.byteSwap32=i.byteSwapIfBE=i.byteSwap=i.isLE=i.rotl=i.rotr=i.createView=i.u32=i.u8=i.isBytes=void 0;var Z=Se(),ee=Y();function ct(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}i.isBytes=ct;var ft=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);i.u8=ft;var dt=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));i.u32=dt;var ut=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);i.createView=ut;var xt=(e,t)=>e<<32-t|e>>>t;i.rotr=xt;var lt=(e,t)=>e<<t|e>>>32-t>>>0;i.rotl=lt;i.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var bt=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;i.byteSwap=bt;i.byteSwapIfBE=i.isLE?e=>e:e=>(0,i.byteSwap)(e);function pt(e){for(let t=0;t<e.length;t++)e[t]=(0,i.byteSwap)(e[t])}i.byteSwap32=pt;var ht=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function yt(e){(0,ee.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=ht[e[r]];return t}i.bytesToHex=yt;var y={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ue(e){if(e>=y._0&&e<=y._9)return e-y._0;if(e>=y._A&&e<=y._F)return e-(y._A-10);if(e>=y._a&&e<=y._f)return e-(y._a-10)}function gt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let a=Ue(e.charCodeAt(s)),c=Ue(e.charCodeAt(s+1));if(a===void 0||c===void 0){let d=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+s)}n[o]=a*16+c}return n}i.hexToBytes=gt;var wt=async()=>{};i.nextTick=wt;async function mt(e,t,r){let n=Date.now();for(let o=0;o<e;o++){r(o);let s=Date.now()-n;s>=0&&s<t||(await(0,i.nextTick)(),n+=s)}}i.asyncLoop=mt;function Be(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}i.utf8ToBytes=Be;function V(e){return typeof e=="string"&&(e=Be(e)),(0,ee.bytes)(e),e}i.toBytes=V;function _t(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];(0,ee.bytes)(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}i.concatBytes=_t;var Q=class{clone(){return this._cloneInto()}};i.Hash=Q;var vt={}.toString;function It(e,t){if(t!==void 0&&vt.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(e,t)}i.checkOpts=It;function At(e){let t=n=>e().update(V(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}i.wrapConstructor=At;function Et(e){let t=(n,o)=>e(o).update(V(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}i.wrapConstructorWithOpts=Et;function kt(e){let t=(n,o)=>e(o).update(V(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}i.wrapXOFConstructorWithOpts=kt;function Pt(e=32){if(Z.crypto&&typeof Z.crypto.getRandomValues=="function")return Z.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}i.randomBytes=Pt});var Oe=h(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.HashMD=w.Maj=w.Chi=void 0;var re=Y(),O=te();function Tt(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),a=Number(r>>o&s),c=Number(r&s),d=n?4:0,b=n?0:4;e.setUint32(t+d,a,n),e.setUint32(t+b,c,n)}var St=(e,t,r)=>e&t^~e&r;w.Chi=St;var Ut=(e,t,r)=>e&t^e&r^t&r;w.Maj=Ut;var ne=class extends O.Hash{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,O.createView)(this.buffer)}update(t){(0,re.exists)(this);let{view:r,buffer:n,blockLen:o}=this;t=(0,O.toBytes)(t);let s=t.length;for(let a=0;a<s;){let c=Math.min(o-this.pos,s-a);if(c===o){let d=(0,O.createView)(t);for(;o<=s-a;a+=o)this.process(d,a);continue}n.set(t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,re.exists)(this),(0,re.output)(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(n,0),a=0);for(let f=a;f<o;f++)r[f]=0;Tt(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=(0,O.createView)(t),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let b=d/4,g=this.get();if(b>g.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<b;f++)c.setUint32(4*f,g[f],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:a,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=a,o%r&&t.buffer.set(n),t}};w.HashMD=ne});var Ne=h(k=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.sha224=k.sha256=void 0;var oe=Oe(),l=te(),Bt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),m=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_=new Uint32Array(64),D=class extends oe.HashMD{constructor(){super(64,32,8,!1),this.A=m[0]|0,this.B=m[1]|0,this.C=m[2]|0,this.D=m[3]|0,this.E=m[4]|0,this.F=m[5]|0,this.G=m[6]|0,this.H=m[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:a,G:c,H:d}=this;return[t,r,n,o,s,a,c,d]}set(t,r,n,o,s,a,c,d){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=c|0,this.H=d|0}process(t,r){for(let f=0;f<16;f++,r+=4)_[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let B=_[f-15],I=_[f-2],me=(0,l.rotr)(B,7)^(0,l.rotr)(B,18)^B>>>3,J=(0,l.rotr)(I,17)^(0,l.rotr)(I,19)^I>>>10;_[f]=J+_[f-7]+me+_[f-16]|0}let{A:n,B:o,C:s,D:a,E:c,F:d,G:b,H:g}=this;for(let f=0;f<64;f++){let B=(0,l.rotr)(c,6)^(0,l.rotr)(c,11)^(0,l.rotr)(c,25),I=g+B+(0,oe.Chi)(c,d,b)+Bt[f]+_[f]|0,J=((0,l.rotr)(n,2)^(0,l.rotr)(n,13)^(0,l.rotr)(n,22))+(0,oe.Maj)(n,o,s)|0;g=b,b=d,d=c,c=a+I|0,a=s,s=o,o=n,n=I+J|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,d=d+this.F|0,b=b+this.G|0,g=g+this.H|0,this.set(n,o,s,a,c,d,b,g)}roundClean(){_.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},se=class extends D{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};k.sha256=(0,l.wrapConstructor)(()=>new D);k.sha224=(0,l.wrapConstructor)(()=>new se)});var Le=h(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.sha224=void 0;var Ot=Ne();function Nt(e){return Ot.sha224.create().update(new Uint8Array(e)).digest()}H.sha224=Nt});var Me=h(p=>{"use strict";Object.defineProperty(p,"__esModule",{value:!0});p.Principal=p.JSON_KEY_PRINCIPAL=void 0;var je=ve(),Lt=Ie(),jt=Le();p.JSON_KEY_PRINCIPAL="__principal__";var Ct=2,Ce=4,Mt="aaaaa-aa",Vt=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},Dt=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),ie=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Ce]))}static managementCanister(){return this.fromHex(Mt)}static selfAuthenticating(t){let r=(0,jt.sha224)(t);return new this(new Uint8Array([...r,Ct]))}static from(t){if(typeof t=="string")return e.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new e(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new e(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(Vt(t))}static fromText(t){let r=t;if(t.includes(p.JSON_KEY_PRINCIPAL)){let a=JSON.parse(t);p.JSON_KEY_PRINCIPAL in a&&(r=a[p.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),o=(0,je.decode)(n);o=o.slice(4,o.length);let s=new this(o);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Ce}toUint8Array(){return this._arr}toHex(){return Dt(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,(0,Lt.getCrc32)(this._arr));let n=new Uint8Array(t),o=Uint8Array.from(this._arr),s=new Uint8Array([...n,...o]),c=(0,je.encode)(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[p.JSON_KEY_PRINCIPAL]:this.toText()}}compareTo(t){for(let r=0;r<Math.min(this._arr.length,t._arr.length);r++){if(this._arr[r]<t._arr[r])return"lt";if(this._arr[r]>t._arr[r])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let r=this.compareTo(t);return r=="lt"||r=="eq"}gtEq(t){let r=this.compareTo(t);return r=="gt"||r=="eq"}};p.Principal=ie});function U(e){return new Promise((t,r)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>r(e.error)})}function q(e,t){let r=indexedDB.open(e);r.onupgradeneeded=()=>r.result.createObjectStore(t);let n=U(r);return(o,s)=>n.then(a=>s(a.transaction(t,o).objectStore(t)))}function ue(){return de||(de=q("keyval-store","keyval")),de}function xe(e,t,r=ue()){return r("readwrite",n=>(n.put(t,e),U(n.transaction)))}function le(e,t=ue()){return t("readwrite",r=>(e.forEach(n=>r.delete(n)),U(r.transaction)))}function $t(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},U(e.transaction)}function be(e=ue()){return e("readonly",t=>{if(t.getAll&&t.getAllKeys)return Promise.all([U(t.getAllKeys()),U(t.getAll())]).then(([n,o])=>n.map((s,a)=>[s,o[a]]));let r=[];return e("readonly",n=>$t(n,o=>r.push([o.key,o.value])).then(()=>r))})}var de,Re=_e(()=>{});var ye={};et(ye,{delPageViews:()=>Jt,delTrackEvents:()=>Yt,getPageViews:()=>Gt,getTrackEvents:()=>Xt,setPageView:()=>qt,setTrackEvent:()=>zt});var pe,he,qt,Gt,Jt,zt,Xt,Yt,ge=_e(()=>{"use strict";Re();pe=q("juno-views","views"),he=q("juno-events","events"),qt=({key:e,view:t})=>xe(e,t,pe),Gt=()=>be(pe),Jt=e=>le(e,pe),zt=({key:e,track:t})=>xe(e,t,he),Xt=()=>be(he),Yt=e=>le(e,he)});var Ht=rt(Me(),1);var R=e=>e==null,W=e=>!R(e),Rt=class extends Error{},P=(e,t)=>{if(R(e))throw new Rt(t)};var F=e=>W(e)?[e]:[];var ae=()=>typeof window<"u",K=({key:e,envPrefix:t})=>typeof process<"u"?W(t)?process.env[`${t}${e}`]:process.env[`NEXT_PUBLIC_${e}`]??process.env[`VITE_${e}`]??process.env[`PUBLIC_${e}`]:void 0;import{webcrypto as De}from"node:crypto";var Ve="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Wt=128,v,T;function Ft(e){!v||v.length<e?(v=Buffer.allocUnsafe(e*Wt),De.getRandomValues(v),T=0):T+e>v.length&&(De.getRandomValues(v),T=0),T+=e}function $(e=21){Ft(e-=0);let t="";for(let r=T-e;r<T;r++)t+=Ve[v[r]&63];return t}var He=()=>BigInt(Date.now())*BigInt(1e6);var ce=()=>({collected_at:He(),updated_at:[],version:[]}),fe=()=>{let{userAgent:e}=navigator;return{user_agent:F(e)}};var Kt="Analytics worker not initialized. Did you call `initOrbiter`?",S=e=>{R(e)&&console.warn(Kt)};var Zt=()=>{if(!(typeof crypto>"u"))return $()},G=Zt(),x,We=e=>{let{path:t}=e.worker??{},r=t===void 0?"./workers/analytics.worker.js":t;x=new Worker(r);let n=()=>console.warn("Unable to connect to the analytics web worker. Have you deployed it?");return x?.addEventListener("error",n,!1),er(e),{cleanup(){x?.removeEventListener("error",n,!1)}}},Fe=()=>{let e=async()=>await $e(),t=new Proxy(history.pushState,{apply:async(r,n,o)=>{r.apply(n,o),await e()}});return history.pushState=t,addEventListener("popstate",e,{passive:!0}),{cleanup(){t=null,removeEventListener("popstate",e,!1)}}},Ke="No session ID initialized.",we=async()=>{if(!ae())return;P(G,Ke);let{title:e,location:{href:t},referrer:r}=document,{innerWidth:n,innerHeight:o}=window,{timeZone:s}=Intl.DateTimeFormat().resolvedOptions(),a={title:e,href:t,referrer:F(W(r)&&r!==""?r:void 0),device:{inner_width:n,inner_height:o},time_zone:s,session_id:G,...fe(),...ce()};await(await Promise.resolve().then(()=>(ge(),ye))).setPageView({key:$(),view:a})},$e=async()=>{S(x),await we(),x?.postMessage({msg:"junoTrackPageView"})},Qt=async e=>{if(!ae())return;P(G,Ke),S(x),await(await Promise.resolve().then(()=>(ge(),ye))).setTrackEvent({key:$(),track:{...e,session_id:G,...fe(),...ce()}}),x?.postMessage({msg:"junoTrackEvent"})},er=e=>{S(x),x?.postMessage({msg:"junoInitEnvironment",data:e})},qe=()=>{S(x),x?.postMessage({msg:"junoStartTrackTimer"})},Ge=()=>{S(x),x?.postMessage({msg:"junoStopTracker"})};var tr=e=>{let t=e?.satelliteId??K({key:"SATELLITE_ID",envPrefix:e?.envPrefix});P(t,"Satellite ID is not configured. Orbiter cannot be initialized without a target Satellite.");let r=e?.orbiterId??K({key:"ORBITER_ID",envPrefix:e?.envPrefix});P(r,"Orbiter ID is not configured. The analytics cannot be initialized without an Orbiter.");let n=e?.container??K({key:"CONTAINER",envPrefix:e?.envPrefix});return{orbiterId:r,satelliteId:t,container:n,worker:e?.worker}},Nr=async e=>{await we();let t=tr(e),{cleanup:r}=We(t),{cleanup:n}=Fe();return qe(),()=>{Ge(),r(),n()}};export{Nr as initOrbiter,Qt as trackEvent,$e as trackPageView};
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
@noble/hashes/utils.js:
|