@axcode/axcloud-sdk 0.2.0-dev.03fb26c → 0.2.0-dev.85285e0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/analytics-BOxmSWNt.d.ts +432 -0
- package/dist/analytics-LYZxP7PC.d.mts +432 -0
- package/dist/barnsport.d.mts +30 -0
- package/dist/barnsport.d.ts +30 -0
- package/dist/barnsport.js +69 -0
- package/dist/barnsport.js.map +1 -0
- package/dist/barnsport.mjs +4 -0
- package/dist/barnsport.mjs.map +1 -0
- package/dist/chunk-2A5NJAFA.mjs +15 -0
- package/dist/chunk-2A5NJAFA.mjs.map +1 -0
- package/dist/chunk-DI4M6A7K.js +474 -0
- package/dist/chunk-DI4M6A7K.js.map +1 -0
- package/dist/chunk-DSWRJZWR.js +18 -0
- package/dist/chunk-DSWRJZWR.js.map +1 -0
- package/dist/chunk-EX66R5IA.js +278 -0
- package/dist/chunk-EX66R5IA.js.map +1 -0
- package/dist/chunk-F3JPEND3.mjs +461 -0
- package/dist/chunk-F3JPEND3.mjs.map +1 -0
- package/dist/chunk-HRNRGCCT.mjs +262 -0
- package/dist/chunk-HRNRGCCT.mjs.map +1 -0
- package/dist/client-FOpKwe3e.d.mts +75 -0
- package/dist/client-FOpKwe3e.d.ts +75 -0
- package/dist/index.d.mts +10 -737
- package/dist/index.d.ts +10 -737
- package/dist/index.js +112 -632
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -585
- package/dist/index.mjs.map +1 -1
- package/dist/public.d.mts +27 -0
- package/dist/public.d.ts +27 -0
- package/dist/public.js +111 -0
- package/dist/public.js.map +1 -0
- package/dist/public.mjs +99 -0
- package/dist/public.mjs.map +1 -0
- package/dist/useBarnsport-1DObGZDl.d.mts +526 -0
- package/dist/useBarnsport-1DObGZDl.d.ts +526 -0
- package/package.json +11 -1
package/dist/index.mjs
CHANGED
|
@@ -1,342 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isAxCloudError, useAnalyticsRuntime, AxCloudClient } from './chunk-F3JPEND3.mjs';
|
|
2
|
+
export { AxCloudClient, AxCloudError, createClient, fetchAnalyticsPublicConfig, getClient, isAllowedAnalyticsEvent, isAxCloudError, isLocalAnalyticsHostname, sanitizeAnalyticsEventData, sanitizeAnalyticsPath, useAnalytics, useAnalyticsRuntime } from './chunk-F3JPEND3.mjs';
|
|
3
|
+
export { useBarnsportActivities, useBarnsportActivity, useBarnsportMunicipalities, useBarnsportSitemap, useBarnsportSport, useBarnsportSports, useSubmitBarnsportInterest } from './chunk-HRNRGCCT.mjs';
|
|
4
|
+
import { useAxCloudContext, AxCloudContext } from './chunk-2A5NJAFA.mjs';
|
|
5
|
+
export { useAxCloudContext } from './chunk-2A5NJAFA.mjs';
|
|
6
|
+
import { useState, useMemo, useCallback, useLayoutEffect, useRef } from 'react';
|
|
2
7
|
import { Auth0Provider, useAuth0 } from '@auth0/auth0-react';
|
|
3
8
|
import { QueryClientProvider, useQuery, useQueryClient, useMutation, QueryClient } from '@tanstack/react-query';
|
|
4
9
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
10
|
|
|
6
|
-
// src/core/errors.ts
|
|
7
|
-
var AxCloudError = class _AxCloudError extends Error {
|
|
8
|
-
constructor(message, code, status, details) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.name = "AxCloudError";
|
|
11
|
-
this.code = code;
|
|
12
|
-
this.status = status;
|
|
13
|
-
this.details = details;
|
|
14
|
-
const ErrorWithCapture = Error;
|
|
15
|
-
if (ErrorWithCapture.captureStackTrace) {
|
|
16
|
-
ErrorWithCapture.captureStackTrace(this, _AxCloudError);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
static fromResponse(status, body) {
|
|
20
|
-
const details = typeof body === "object" ? body : void 0;
|
|
21
|
-
const message = (typeof details?.message === "string" ? details.message : void 0) || (typeof details?.error === "string" ? details.error : void 0);
|
|
22
|
-
switch (status) {
|
|
23
|
-
case 401:
|
|
24
|
-
return new _AxCloudError(
|
|
25
|
-
message || "Authentication required",
|
|
26
|
-
"UNAUTHORIZED",
|
|
27
|
-
status,
|
|
28
|
-
details
|
|
29
|
-
);
|
|
30
|
-
case 403:
|
|
31
|
-
return new _AxCloudError(message || "Access denied", "FORBIDDEN", status, details);
|
|
32
|
-
case 404:
|
|
33
|
-
return new _AxCloudError(message || "Resource not found", "NOT_FOUND", status, details);
|
|
34
|
-
case 422:
|
|
35
|
-
return new _AxCloudError(
|
|
36
|
-
message || "Validation failed",
|
|
37
|
-
"VALIDATION_ERROR",
|
|
38
|
-
status,
|
|
39
|
-
details
|
|
40
|
-
);
|
|
41
|
-
default:
|
|
42
|
-
if (status >= 500) {
|
|
43
|
-
return new _AxCloudError(message || "Server error", "SERVER_ERROR", status, details);
|
|
44
|
-
}
|
|
45
|
-
return new _AxCloudError(message || "An error occurred", "UNKNOWN_ERROR", status, details);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
static networkError(originalError) {
|
|
49
|
-
const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
50
|
-
const message = isDev && originalError?.message ? originalError.message : "Network request failed";
|
|
51
|
-
return new _AxCloudError(
|
|
52
|
-
message,
|
|
53
|
-
"NETWORK_ERROR",
|
|
54
|
-
0,
|
|
55
|
-
isDev ? { originalError: originalError?.message } : void 0
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
static timeoutError(timeoutMs) {
|
|
59
|
-
return new _AxCloudError(`Request timed out after ${timeoutMs}ms`, "TIMEOUT_ERROR", 0, {
|
|
60
|
-
timeout: timeoutMs
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
function isAxCloudError(error) {
|
|
65
|
-
return error instanceof AxCloudError;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// src/core/client.ts
|
|
69
|
-
var AxCloudClient = class {
|
|
70
|
-
constructor(config) {
|
|
71
|
-
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
72
|
-
this.getAccessToken = config.getAccessToken;
|
|
73
|
-
this.apiKey = config.apiKey;
|
|
74
|
-
this.defaultTimeout = config.timeout ?? 3e4;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Update the access token getter (used when auth state changes)
|
|
78
|
-
*/
|
|
79
|
-
setAccessTokenGetter(getter) {
|
|
80
|
-
this.getAccessToken = getter;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Build URL with query parameters
|
|
84
|
-
*/
|
|
85
|
-
buildUrl(path, params) {
|
|
86
|
-
const url = new URL(`${this.baseUrl}${path}`);
|
|
87
|
-
if (params) {
|
|
88
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
89
|
-
if (value !== void 0) {
|
|
90
|
-
url.searchParams.append(key, String(value));
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return url.toString();
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* API key should only be sent to public endpoints.
|
|
98
|
-
* This avoids leaking public keys to authenticated/internal routes.
|
|
99
|
-
*/
|
|
100
|
-
shouldAttachApiKey(path) {
|
|
101
|
-
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
102
|
-
return normalized.startsWith("/public/") || normalized.startsWith("/api/public/") || normalized.startsWith("/content/public/") || normalized.startsWith("/media/public/") || normalized.startsWith("/documents/public/") || normalized.startsWith("/barnsport/public/") || normalized.startsWith("/api/barnsport/public/");
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Make an authenticated request
|
|
106
|
-
*/
|
|
107
|
-
async request(path, options = {}) {
|
|
108
|
-
const { body, params, headers: customHeaders, timeout, ...restOptions } = options;
|
|
109
|
-
const headers = {
|
|
110
|
-
"Content-Type": "application/json"
|
|
111
|
-
};
|
|
112
|
-
if (customHeaders) {
|
|
113
|
-
const customHeadersRecord = customHeaders;
|
|
114
|
-
Object.assign(headers, customHeadersRecord);
|
|
115
|
-
}
|
|
116
|
-
if (this.apiKey && this.shouldAttachApiKey(path)) {
|
|
117
|
-
headers["x-api-key"] = this.apiKey;
|
|
118
|
-
}
|
|
119
|
-
if (this.getAccessToken) {
|
|
120
|
-
try {
|
|
121
|
-
const token = await this.getAccessToken();
|
|
122
|
-
if (token) {
|
|
123
|
-
headers["Authorization"] = `Bearer ${token}`;
|
|
124
|
-
}
|
|
125
|
-
} catch (error) {
|
|
126
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
|
|
127
|
-
console.warn(
|
|
128
|
-
"[AxCloud SDK] Failed to fetch access token:",
|
|
129
|
-
error instanceof Error ? error.message : error
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const url = this.buildUrl(path, params);
|
|
135
|
-
const controller = new AbortController();
|
|
136
|
-
const requestTimeout = timeout ?? this.defaultTimeout;
|
|
137
|
-
const timeoutId = setTimeout(() => controller.abort(), requestTimeout);
|
|
138
|
-
try {
|
|
139
|
-
const response = await fetch(url, {
|
|
140
|
-
...restOptions,
|
|
141
|
-
headers,
|
|
142
|
-
body: body ? JSON.stringify(body) : void 0,
|
|
143
|
-
signal: controller.signal
|
|
144
|
-
});
|
|
145
|
-
const contentType = response.headers.get("content-type");
|
|
146
|
-
const isJson = contentType?.includes("application/json");
|
|
147
|
-
if (!response.ok) {
|
|
148
|
-
const errorBody = isJson ? await response.json().catch(() => null) : null;
|
|
149
|
-
throw AxCloudError.fromResponse(response.status, errorBody);
|
|
150
|
-
}
|
|
151
|
-
if (response.status === 204) {
|
|
152
|
-
return {};
|
|
153
|
-
}
|
|
154
|
-
return isJson ? await response.json() : {};
|
|
155
|
-
} catch (error) {
|
|
156
|
-
if (error instanceof AxCloudError) {
|
|
157
|
-
throw error;
|
|
158
|
-
}
|
|
159
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
160
|
-
throw AxCloudError.timeoutError(requestTimeout);
|
|
161
|
-
}
|
|
162
|
-
throw AxCloudError.networkError(error instanceof Error ? error : void 0);
|
|
163
|
-
} finally {
|
|
164
|
-
clearTimeout(timeoutId);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* GET request
|
|
169
|
-
*/
|
|
170
|
-
get(path, params) {
|
|
171
|
-
return this.request(path, { method: "GET", params });
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* POST request
|
|
175
|
-
*/
|
|
176
|
-
post(path, body) {
|
|
177
|
-
return this.request(path, { method: "POST", body });
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* PUT request
|
|
181
|
-
*/
|
|
182
|
-
put(path, body) {
|
|
183
|
-
return this.request(path, { method: "PUT", body });
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* PATCH request
|
|
187
|
-
*/
|
|
188
|
-
patch(path, body) {
|
|
189
|
-
return this.request(path, { method: "PATCH", body });
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* DELETE request
|
|
193
|
-
*/
|
|
194
|
-
delete(path) {
|
|
195
|
-
return this.request(path, { method: "DELETE" });
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
var clientRegistry = /* @__PURE__ */ new WeakMap();
|
|
199
|
-
function createClient(config, key) {
|
|
200
|
-
const client = new AxCloudClient(config);
|
|
201
|
-
if (key) {
|
|
202
|
-
clientRegistry.set(key, client);
|
|
203
|
-
}
|
|
204
|
-
return client;
|
|
205
|
-
}
|
|
206
|
-
function getClient(key) {
|
|
207
|
-
if (key) {
|
|
208
|
-
const client = clientRegistry.get(key);
|
|
209
|
-
if (client) {
|
|
210
|
-
return client;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
throw new Error("AxCloud client not found. Make sure AxCloudProvider is mounted and use useAxCloudContext() to get the client.");
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// src/core/analytics.ts
|
|
217
|
-
var EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]{1,63}$/;
|
|
218
|
-
var PROPERTY_KEY_PATTERN = /^[a-z][a-z0-9_]{0,47}$/;
|
|
219
|
-
var SENSITIVE_PROPERTY_PATTERN = /(^|_)(auth0|email|name|password|query|search|secret|token|trace|user|userid)($|_)/;
|
|
220
|
-
var EMAIL_VALUE_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
221
|
-
var OPAQUE_SEGMENT_PATTERNS = [
|
|
222
|
-
/^[0-9a-f]{8}-[0-9a-f-]{27,}$/i,
|
|
223
|
-
/^(org|user|section|document|content|poll|invitation|invite|trace|chan)[_-][a-z0-9_-]+$/i,
|
|
224
|
-
/^[a-f0-9]{20,}$/i,
|
|
225
|
-
/^[a-z0-9_-]{32,}$/i
|
|
226
|
-
];
|
|
227
|
-
var scriptLoads = /* @__PURE__ */ new Map();
|
|
228
|
-
function isLocalAnalyticsHostname(hostname) {
|
|
229
|
-
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
230
|
-
}
|
|
231
|
-
function sanitizeAnalyticsPath(pathname, customNormalizer) {
|
|
232
|
-
const rawPath = pathname.split(/[?#]/, 1)[0] || "/";
|
|
233
|
-
const normalizedInput = rawPath.startsWith("/") ? rawPath : `/${rawPath}`;
|
|
234
|
-
const custom = customNormalizer?.(normalizedInput);
|
|
235
|
-
if (custom === null) return null;
|
|
236
|
-
const path = custom ?? normalizedInput;
|
|
237
|
-
const cleanPath = path.split(/[?#]/, 1)[0] || "/";
|
|
238
|
-
const segments = cleanPath.split("/").map((segment) => {
|
|
239
|
-
if (!segment) return segment;
|
|
240
|
-
let decoded = segment;
|
|
241
|
-
try {
|
|
242
|
-
decoded = decodeURIComponent(segment);
|
|
243
|
-
} catch {
|
|
244
|
-
}
|
|
245
|
-
return OPAQUE_SEGMENT_PATTERNS.some((pattern) => pattern.test(decoded)) ? ":id" : segment;
|
|
246
|
-
});
|
|
247
|
-
return segments.join("/") || "/";
|
|
248
|
-
}
|
|
249
|
-
function sanitizeAnalyticsEventData(data) {
|
|
250
|
-
if (!data) return void 0;
|
|
251
|
-
const sanitized = {};
|
|
252
|
-
for (const [rawKey, rawValue] of Object.entries(data).slice(0, 20)) {
|
|
253
|
-
const key = rawKey.trim().toLowerCase();
|
|
254
|
-
if (!PROPERTY_KEY_PATTERN.test(key) || SENSITIVE_PROPERTY_PATTERN.test(key)) continue;
|
|
255
|
-
if (typeof rawValue === "string") {
|
|
256
|
-
const value = rawValue.trim();
|
|
257
|
-
if (!value || value.length > 100 || EMAIL_VALUE_PATTERN.test(value)) continue;
|
|
258
|
-
sanitized[key] = value;
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
if (typeof rawValue === "number" && Number.isFinite(rawValue)) {
|
|
262
|
-
sanitized[key] = rawValue;
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
if (typeof rawValue === "boolean") sanitized[key] = rawValue;
|
|
266
|
-
}
|
|
267
|
-
return Object.keys(sanitized).length > 0 ? sanitized : void 0;
|
|
268
|
-
}
|
|
269
|
-
function isAllowedAnalyticsEvent(eventName, allowedEvents) {
|
|
270
|
-
return EVENT_NAME_PATTERN.test(eventName) && Boolean(allowedEvents?.includes(eventName));
|
|
271
|
-
}
|
|
272
|
-
async function fetchAnalyticsPublicConfig(input) {
|
|
273
|
-
const baseUrl = input.apiUrl.replace(/\/$/, "");
|
|
274
|
-
const url = new URL(`${baseUrl}/analytics/public/config`);
|
|
275
|
-
url.searchParams.set("orgId", input.orgId);
|
|
276
|
-
url.searchParams.set("siteKey", input.siteKey);
|
|
277
|
-
url.searchParams.set("stage", input.stage);
|
|
278
|
-
url.searchParams.set("hostname", input.hostname);
|
|
279
|
-
const response = await fetch(url, {
|
|
280
|
-
method: "GET",
|
|
281
|
-
headers: { Accept: "application/json" },
|
|
282
|
-
signal: input.signal
|
|
283
|
-
});
|
|
284
|
-
if (!response.ok) throw new Error(`Analytics configuration returned ${response.status}`);
|
|
285
|
-
return response.json();
|
|
286
|
-
}
|
|
287
|
-
function loadAnalyticsScript(config, doc = document) {
|
|
288
|
-
if (!config.enabled || !config.websiteId || !config.scriptUrl) {
|
|
289
|
-
return Promise.reject(new Error("Analytics tracker configuration is incomplete"));
|
|
290
|
-
}
|
|
291
|
-
const key = `${config.scriptUrl}|${config.websiteId}`;
|
|
292
|
-
const existingPromise = scriptLoads.get(key);
|
|
293
|
-
if (existingPromise) return existingPromise;
|
|
294
|
-
const existing = doc.querySelector(
|
|
295
|
-
`script[data-axcloud-analytics-site="${config.websiteId}"]`
|
|
296
|
-
);
|
|
297
|
-
if (existing && doc.defaultView?.umami) {
|
|
298
|
-
return Promise.resolve();
|
|
299
|
-
}
|
|
300
|
-
const promise = new Promise((resolve, reject) => {
|
|
301
|
-
const script = existing || doc.createElement("script");
|
|
302
|
-
const onLoad = () => resolve();
|
|
303
|
-
const onError = () => reject(new Error("Analytics tracker failed to load"));
|
|
304
|
-
script.addEventListener("load", onLoad, { once: true });
|
|
305
|
-
script.addEventListener("error", onError, { once: true });
|
|
306
|
-
if (!existing) {
|
|
307
|
-
script.src = config.scriptUrl;
|
|
308
|
-
script.defer = true;
|
|
309
|
-
script.dataset.websiteId = config.websiteId;
|
|
310
|
-
script.dataset.axcloudAnalyticsSite = config.websiteId;
|
|
311
|
-
script.dataset.autoTrack = String(config.autoTrack === true);
|
|
312
|
-
if (config.hostUrl) script.dataset.hostUrl = config.hostUrl;
|
|
313
|
-
if (config.domains?.length) script.dataset.domains = config.domains.join(",");
|
|
314
|
-
if (config.respectDoNotTrack !== false) script.dataset.doNotTrack = "true";
|
|
315
|
-
if (config.excludeSearch !== false) script.dataset.excludeSearch = "true";
|
|
316
|
-
if (config.excludeHash !== false) script.dataset.excludeHash = "true";
|
|
317
|
-
doc.head.appendChild(script);
|
|
318
|
-
}
|
|
319
|
-
}).catch((error) => {
|
|
320
|
-
scriptLoads.delete(key);
|
|
321
|
-
throw error;
|
|
322
|
-
});
|
|
323
|
-
scriptLoads.set(key, promise);
|
|
324
|
-
return promise;
|
|
325
|
-
}
|
|
326
|
-
function sendAnalyticsPageView(pathname, options, targetWindow = window) {
|
|
327
|
-
const path = sanitizeAnalyticsPath(pathname, options.normalizePath);
|
|
328
|
-
const umami = targetWindow.umami;
|
|
329
|
-
if (!path || !umami) return false;
|
|
330
|
-
umami.track({ url: path, title: targetWindow.document.title });
|
|
331
|
-
return true;
|
|
332
|
-
}
|
|
333
|
-
function sendAnalyticsEvent(eventName, data, allowedEvents, targetWindow = window) {
|
|
334
|
-
const umami = targetWindow.umami;
|
|
335
|
-
if (!umami || !isAllowedAnalyticsEvent(eventName, allowedEvents)) return false;
|
|
336
|
-
umami.track(eventName, sanitizeAnalyticsEventData(data));
|
|
337
|
-
return true;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
11
|
// src/core/contentSlots.ts
|
|
341
12
|
var SLOT_ATTRIBUTE_KEYS = ["slot", "field", "key", "name"];
|
|
342
13
|
function getContentSlotMap(content) {
|
|
@@ -626,135 +297,6 @@ async function castVote(votingApiUrl, params) {
|
|
|
626
297
|
await ensureOk(response);
|
|
627
298
|
return readJson(response);
|
|
628
299
|
}
|
|
629
|
-
var AxCloudContext = createContext(null);
|
|
630
|
-
function useAxCloudContext() {
|
|
631
|
-
const context = useContext(AxCloudContext);
|
|
632
|
-
if (!context) {
|
|
633
|
-
throw new Error("useAxCloudContext must be used within a AxCloudProvider");
|
|
634
|
-
}
|
|
635
|
-
return context;
|
|
636
|
-
}
|
|
637
|
-
var NAVIGATION_EVENT = "axcloud-sdk:navigation";
|
|
638
|
-
var historySubscriberCount = 0;
|
|
639
|
-
var originalPushState = null;
|
|
640
|
-
var originalReplaceState = null;
|
|
641
|
-
function subscribeToNavigation(callback) {
|
|
642
|
-
if (typeof window === "undefined") return () => void 0;
|
|
643
|
-
if (historySubscriberCount === 0) {
|
|
644
|
-
originalPushState = window.history.pushState.bind(window.history);
|
|
645
|
-
originalReplaceState = window.history.replaceState.bind(window.history);
|
|
646
|
-
window.history.pushState = ((...args) => {
|
|
647
|
-
originalPushState?.(...args);
|
|
648
|
-
window.dispatchEvent(new Event(NAVIGATION_EVENT));
|
|
649
|
-
});
|
|
650
|
-
window.history.replaceState = ((...args) => {
|
|
651
|
-
originalReplaceState?.(...args);
|
|
652
|
-
window.dispatchEvent(new Event(NAVIGATION_EVENT));
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
historySubscriberCount += 1;
|
|
656
|
-
window.addEventListener("popstate", callback);
|
|
657
|
-
window.addEventListener(NAVIGATION_EVENT, callback);
|
|
658
|
-
return () => {
|
|
659
|
-
window.removeEventListener("popstate", callback);
|
|
660
|
-
window.removeEventListener(NAVIGATION_EVENT, callback);
|
|
661
|
-
historySubscriberCount = Math.max(0, historySubscriberCount - 1);
|
|
662
|
-
if (historySubscriberCount === 0) {
|
|
663
|
-
if (originalPushState) window.history.pushState = originalPushState;
|
|
664
|
-
if (originalReplaceState) window.history.replaceState = originalReplaceState;
|
|
665
|
-
originalPushState = null;
|
|
666
|
-
originalReplaceState = null;
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
function doNotTrackEnabled(config) {
|
|
671
|
-
if (config.respectDoNotTrack === false || typeof navigator === "undefined") return false;
|
|
672
|
-
return navigator.doNotTrack === "1";
|
|
673
|
-
}
|
|
674
|
-
function useAnalyticsRuntime(config) {
|
|
675
|
-
const [enabled, setEnabled] = useState(false);
|
|
676
|
-
const [ready, setReady] = useState(false);
|
|
677
|
-
const publicConfigRef = useRef(null);
|
|
678
|
-
const optionsRef = useRef(config.analytics);
|
|
679
|
-
optionsRef.current = config.analytics;
|
|
680
|
-
const trackPageView = useCallback(
|
|
681
|
-
(pathname) => {
|
|
682
|
-
if (!ready || !optionsRef.current || typeof window === "undefined") return false;
|
|
683
|
-
return sendAnalyticsPageView(pathname || window.location.pathname, optionsRef.current);
|
|
684
|
-
},
|
|
685
|
-
[ready]
|
|
686
|
-
);
|
|
687
|
-
const track = useCallback(
|
|
688
|
-
(eventName, data) => {
|
|
689
|
-
if (!ready || typeof window === "undefined") return false;
|
|
690
|
-
return sendAnalyticsEvent(eventName, data, publicConfigRef.current?.allowedEvents);
|
|
691
|
-
},
|
|
692
|
-
[ready]
|
|
693
|
-
);
|
|
694
|
-
useEffect(() => {
|
|
695
|
-
const options = config.analytics;
|
|
696
|
-
setEnabled(false);
|
|
697
|
-
setReady(false);
|
|
698
|
-
publicConfigRef.current = null;
|
|
699
|
-
if (!options?.enabled || !options.siteKey || typeof window === "undefined") return void 0;
|
|
700
|
-
if (isLocalAnalyticsHostname(window.location.hostname) && !options.trackLocalhost)
|
|
701
|
-
return void 0;
|
|
702
|
-
const controller = new AbortController();
|
|
703
|
-
let cancelled = false;
|
|
704
|
-
let unsubscribe = () => void 0;
|
|
705
|
-
const initialize = async () => {
|
|
706
|
-
try {
|
|
707
|
-
const publicConfig = await fetchAnalyticsPublicConfig({
|
|
708
|
-
apiUrl: config.apiUrl,
|
|
709
|
-
orgId: config.orgId,
|
|
710
|
-
siteKey: options.siteKey,
|
|
711
|
-
stage: config.stage,
|
|
712
|
-
hostname: window.location.hostname,
|
|
713
|
-
signal: controller.signal
|
|
714
|
-
});
|
|
715
|
-
if (cancelled || !publicConfig.enabled || doNotTrackEnabled(publicConfig)) return;
|
|
716
|
-
publicConfigRef.current = publicConfig;
|
|
717
|
-
setEnabled(true);
|
|
718
|
-
await loadAnalyticsScript(publicConfig);
|
|
719
|
-
if (cancelled) return;
|
|
720
|
-
setReady(true);
|
|
721
|
-
if (!publicConfig.autoTrack) {
|
|
722
|
-
const trackCurrentPage = () => {
|
|
723
|
-
sendAnalyticsPageView(window.location.pathname, options);
|
|
724
|
-
};
|
|
725
|
-
trackCurrentPage();
|
|
726
|
-
unsubscribe = subscribeToNavigation(trackCurrentPage);
|
|
727
|
-
}
|
|
728
|
-
} catch (error) {
|
|
729
|
-
if (!cancelled && !(error instanceof Error && error.name === "AbortError")) {
|
|
730
|
-
setEnabled(false);
|
|
731
|
-
setReady(false);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
void initialize();
|
|
736
|
-
return () => {
|
|
737
|
-
cancelled = true;
|
|
738
|
-
controller.abort();
|
|
739
|
-
unsubscribe();
|
|
740
|
-
};
|
|
741
|
-
}, [
|
|
742
|
-
config.analytics?.enabled,
|
|
743
|
-
config.analytics?.siteKey,
|
|
744
|
-
config.analytics?.trackLocalhost,
|
|
745
|
-
config.analytics?.normalizePath,
|
|
746
|
-
config.apiUrl,
|
|
747
|
-
config.orgId,
|
|
748
|
-
config.stage
|
|
749
|
-
]);
|
|
750
|
-
return useMemo(
|
|
751
|
-
() => ({ enabled, ready, track, trackPageView }),
|
|
752
|
-
[enabled, ready, track, trackPageView]
|
|
753
|
-
);
|
|
754
|
-
}
|
|
755
|
-
function useAnalytics() {
|
|
756
|
-
return useAxCloudContext().analytics;
|
|
757
|
-
}
|
|
758
300
|
|
|
759
301
|
// src/react/auth/auth0Invitation.ts
|
|
760
302
|
var AUTH0_INVITATION_PATTERN = /^[A-Za-z0-9_-]{1,2048}$/;
|
|
@@ -1980,126 +1522,6 @@ function useMemberDocumentDownload(documentId) {
|
|
|
1980
1522
|
refetch: query.refetch
|
|
1981
1523
|
};
|
|
1982
1524
|
}
|
|
1983
|
-
function useBarnsportMunicipalities() {
|
|
1984
|
-
const { client, orgId } = useAxCloudContext();
|
|
1985
|
-
const query = useQuery({
|
|
1986
|
-
queryKey: ["axcloud", "barnsport", "municipalities", orgId],
|
|
1987
|
-
queryFn: () => client.get(
|
|
1988
|
-
`/barnsport/public/${orgId}/municipalities`
|
|
1989
|
-
),
|
|
1990
|
-
staleTime: 1e3 * 60 * 30
|
|
1991
|
-
});
|
|
1992
|
-
return {
|
|
1993
|
-
municipalities: query.data?.items ?? [],
|
|
1994
|
-
count: query.data?.count ?? 0,
|
|
1995
|
-
isLoading: query.isLoading,
|
|
1996
|
-
isError: query.isError,
|
|
1997
|
-
error: query.error,
|
|
1998
|
-
refetch: query.refetch
|
|
1999
|
-
};
|
|
2000
|
-
}
|
|
2001
|
-
function useBarnsportSports() {
|
|
2002
|
-
const { client, orgId } = useAxCloudContext();
|
|
2003
|
-
const query = useQuery({
|
|
2004
|
-
queryKey: ["axcloud", "barnsport", "sports", orgId],
|
|
2005
|
-
queryFn: () => client.get(
|
|
2006
|
-
`/barnsport/public/${orgId}/sports`
|
|
2007
|
-
),
|
|
2008
|
-
staleTime: 1e3 * 60 * 30
|
|
2009
|
-
});
|
|
2010
|
-
return {
|
|
2011
|
-
sports: query.data?.items ?? [],
|
|
2012
|
-
count: query.data?.count ?? 0,
|
|
2013
|
-
isLoading: query.isLoading,
|
|
2014
|
-
isError: query.isError,
|
|
2015
|
-
error: query.error,
|
|
2016
|
-
refetch: query.refetch
|
|
2017
|
-
};
|
|
2018
|
-
}
|
|
2019
|
-
function useBarnsportSport(slug) {
|
|
2020
|
-
const { client, orgId } = useAxCloudContext();
|
|
2021
|
-
const query = useQuery({
|
|
2022
|
-
queryKey: ["axcloud", "barnsport", "sport", orgId, slug],
|
|
2023
|
-
queryFn: () => client.get(
|
|
2024
|
-
`/barnsport/public/${orgId}/sports/${slug || ""}`
|
|
2025
|
-
),
|
|
2026
|
-
enabled: Boolean(slug),
|
|
2027
|
-
staleTime: 1e3 * 60 * 15
|
|
2028
|
-
});
|
|
2029
|
-
return {
|
|
2030
|
-
sport: query.data?.sport ?? null,
|
|
2031
|
-
isLoading: query.isLoading,
|
|
2032
|
-
isError: query.isError,
|
|
2033
|
-
error: query.error,
|
|
2034
|
-
refetch: query.refetch
|
|
2035
|
-
};
|
|
2036
|
-
}
|
|
2037
|
-
function useBarnsportActivities(filters = {}) {
|
|
2038
|
-
const { client, orgId } = useAxCloudContext();
|
|
2039
|
-
const params = { ...filters };
|
|
2040
|
-
const query = useQuery({
|
|
2041
|
-
queryKey: ["axcloud", "barnsport", "activities", orgId, filters],
|
|
2042
|
-
queryFn: () => client.get(
|
|
2043
|
-
`/barnsport/public/${orgId}/activities`,
|
|
2044
|
-
params
|
|
2045
|
-
),
|
|
2046
|
-
staleTime: 1e3 * 60 * 5
|
|
2047
|
-
});
|
|
2048
|
-
return {
|
|
2049
|
-
activities: query.data?.items ?? [],
|
|
2050
|
-
count: query.data?.count ?? 0,
|
|
2051
|
-
nextCursor: query.data?.nextCursor ?? null,
|
|
2052
|
-
isLoading: query.isLoading,
|
|
2053
|
-
isError: query.isError,
|
|
2054
|
-
error: query.error,
|
|
2055
|
-
refetch: query.refetch
|
|
2056
|
-
};
|
|
2057
|
-
}
|
|
2058
|
-
function useBarnsportActivity(slug) {
|
|
2059
|
-
const { client, orgId } = useAxCloudContext();
|
|
2060
|
-
const query = useQuery({
|
|
2061
|
-
queryKey: ["axcloud", "barnsport", "activity", orgId, slug],
|
|
2062
|
-
queryFn: () => client.get(
|
|
2063
|
-
`/barnsport/public/${orgId}/activities/${slug || ""}`
|
|
2064
|
-
),
|
|
2065
|
-
enabled: Boolean(slug),
|
|
2066
|
-
staleTime: 1e3 * 60 * 5
|
|
2067
|
-
});
|
|
2068
|
-
return {
|
|
2069
|
-
activity: query.data?.activity ?? null,
|
|
2070
|
-
isLoading: query.isLoading,
|
|
2071
|
-
isError: query.isError,
|
|
2072
|
-
error: query.error,
|
|
2073
|
-
refetch: query.refetch
|
|
2074
|
-
};
|
|
2075
|
-
}
|
|
2076
|
-
function useBarnsportSitemap(baseUrl) {
|
|
2077
|
-
const { client, orgId } = useAxCloudContext();
|
|
2078
|
-
const query = useQuery({
|
|
2079
|
-
queryKey: ["axcloud", "barnsport", "sitemap", orgId, baseUrl],
|
|
2080
|
-
queryFn: () => client.get(`/barnsport/public/${orgId}/sitemap`, {
|
|
2081
|
-
baseUrl
|
|
2082
|
-
}),
|
|
2083
|
-
staleTime: 1e3 * 60 * 15
|
|
2084
|
-
});
|
|
2085
|
-
return {
|
|
2086
|
-
sitemap: query.data ?? null,
|
|
2087
|
-
urls: query.data?.urls ?? [],
|
|
2088
|
-
isLoading: query.isLoading,
|
|
2089
|
-
isError: query.isError,
|
|
2090
|
-
error: query.error,
|
|
2091
|
-
refetch: query.refetch
|
|
2092
|
-
};
|
|
2093
|
-
}
|
|
2094
|
-
function useSubmitBarnsportInterest() {
|
|
2095
|
-
const { client, orgId } = useAxCloudContext();
|
|
2096
|
-
return useMutation({
|
|
2097
|
-
mutationFn: (submission) => client.post(
|
|
2098
|
-
`/barnsport/public/${orgId}/interest`,
|
|
2099
|
-
submission
|
|
2100
|
-
)
|
|
2101
|
-
});
|
|
2102
|
-
}
|
|
2103
1525
|
function LoginButton({
|
|
2104
1526
|
children = "Log in",
|
|
2105
1527
|
returnTo,
|
|
@@ -2343,6 +1765,6 @@ function LinkedAccountsList({
|
|
|
2343
1765
|
] });
|
|
2344
1766
|
}
|
|
2345
1767
|
|
|
2346
|
-
export {
|
|
1768
|
+
export { AxCloudProvider, LinkedAccountsList, LoginButton, LogoutButton, ModuleGate, ProtectedRoute, castVote, castVoteWithCode, checkEligibility, checkVotingCode, createContentSlotReader, createFormHelper, getBallot, getContentSlotMap, getVotingReceipt, submitForm, useAuth, useAvatar, useBranding, useCodeBallot, useContent, useContentItem, useDocumentDownload, useDocuments, useFormStats, useForms, useLinkedAccounts, useLogo, useMedia, useMediaList, useMemberDocumentDownload, useMemberDocumentFolders, useMemberDocuments, useModuleAccess, useMySection, useNews, useOrg, usePageContent, useSections, useUpdateFormSubmission, useUpdateMyProfile, useUser, userHasAllPermissions, userHasAnyPermission, userHasPermission };
|
|
2347
1769
|
//# sourceMappingURL=index.mjs.map
|
|
2348
1770
|
//# sourceMappingURL=index.mjs.map
|