@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260326110644 → 0.8.1-dev.20260328110533
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CopyButton-XONTQQW7.mjs +55 -0
- package/dist/HlsPlayer-FFEIK6FG.mjs +7 -0
- package/dist/IframeClient-J22NMEVY.mjs +96 -0
- package/dist/LinkNodeButton-KBSXOEHS.mjs +169 -0
- package/dist/chunk-3IDT4246.mjs +400 -0
- package/dist/chunk-CVVLFQ4J.mjs +131 -0
- package/dist/index.d.mts +32 -17
- package/dist/index.d.ts +32 -17
- package/dist/index.js +3636 -1392
- package/dist/index.mjs +2571 -1263
- package/package.json +7 -1
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
// src/components/Button.tsx
|
|
2
|
+
import React3, { useState as useState2 } from "react";
|
|
3
|
+
|
|
4
|
+
// src/components/ToastService.tsx
|
|
5
|
+
var ToastService = class _ToastService {
|
|
6
|
+
static initialize(showToast, closeToast) {
|
|
7
|
+
_ToastService.showToast = showToast;
|
|
8
|
+
_ToastService.closeToast = closeToast;
|
|
9
|
+
}
|
|
10
|
+
static showError(message) {
|
|
11
|
+
if (_ToastService.showToast) {
|
|
12
|
+
_ToastService.showToast(message, "error");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
static showInfo(message) {
|
|
16
|
+
if (_ToastService.showToast) {
|
|
17
|
+
_ToastService.showToast(message, "info");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
static close() {
|
|
21
|
+
if (_ToastService.closeToast) {
|
|
22
|
+
_ToastService.closeToast();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var ToastService_default = ToastService;
|
|
27
|
+
|
|
28
|
+
// src/components/StyleTypes.tsx
|
|
29
|
+
var buttonClasses = /* @__PURE__ */ new Map([
|
|
30
|
+
["Primary" /* Solid */, "btn-solid"],
|
|
31
|
+
["PrimaryHollow" /* Hollow */, "btn-hollow"],
|
|
32
|
+
["Link" /* Link */, "btn-link"]
|
|
33
|
+
]);
|
|
34
|
+
var progressClasses = /* @__PURE__ */ new Map([
|
|
35
|
+
["Primary" /* Solid */, ""],
|
|
36
|
+
["PrimaryHollow" /* Hollow */, ""],
|
|
37
|
+
["Link" /* Link */, ""]
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
// src/components/Confirm.tsx
|
|
41
|
+
import { useState } from "react";
|
|
42
|
+
|
|
43
|
+
// src/components/ClientButton.tsx
|
|
44
|
+
import React from "react";
|
|
45
|
+
import { jsx } from "react/jsx-runtime";
|
|
46
|
+
var ClientButton = (props) => {
|
|
47
|
+
const execute = async (event) => {
|
|
48
|
+
if (props.onClick !== void 0) {
|
|
49
|
+
props.onClick();
|
|
50
|
+
} else {
|
|
51
|
+
ToastService_default.showError("No action defined.");
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
|
|
55
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsx(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
type: "button",
|
|
59
|
+
onClick: execute,
|
|
60
|
+
className: buttonClass + " " + props.className,
|
|
61
|
+
children: props.children
|
|
62
|
+
}
|
|
63
|
+
) });
|
|
64
|
+
};
|
|
65
|
+
var ClientButton_default = ClientButton;
|
|
66
|
+
|
|
67
|
+
// src/components/Confirm.tsx
|
|
68
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
69
|
+
var Confirm = ({ message, onConfirm, onCancel }) => {
|
|
70
|
+
const [showModal, setShowModal] = useState(true);
|
|
71
|
+
const handleConfirmAction = () => {
|
|
72
|
+
setShowModal(false);
|
|
73
|
+
if (onConfirm) {
|
|
74
|
+
onConfirm();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const handleCancelAction = () => {
|
|
78
|
+
setShowModal(false);
|
|
79
|
+
if (onCancel) {
|
|
80
|
+
onCancel();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: showModal && /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 flex items-center justify-center z-50", children: [
|
|
84
|
+
/* @__PURE__ */ jsx2("div", { className: "absolute inset-0 bg-black opacity-70" }),
|
|
85
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-white rounded-md p-6 w-2/6 shadow border z-50", children: [
|
|
86
|
+
/* @__PURE__ */ jsx2("p", { className: "text-xl font-medium mb-4", children: "Confirmation" }),
|
|
87
|
+
/* @__PURE__ */ jsx2("p", { className: "mb-4", children: message }),
|
|
88
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-8", children: [
|
|
89
|
+
/* @__PURE__ */ jsx2(
|
|
90
|
+
ClientButton_default,
|
|
91
|
+
{
|
|
92
|
+
onClick: handleCancelAction,
|
|
93
|
+
ButtonType: "PrimaryHollow" /* Hollow */,
|
|
94
|
+
children: "Cancel"
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ jsx2(
|
|
98
|
+
ClientButton_default,
|
|
99
|
+
{
|
|
100
|
+
onClick: handleConfirmAction,
|
|
101
|
+
children: "Confirm"
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
] })
|
|
105
|
+
] })
|
|
106
|
+
] }) });
|
|
107
|
+
};
|
|
108
|
+
var Confirm_default = Confirm;
|
|
109
|
+
{
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/components/Button.tsx
|
|
113
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
114
|
+
var Button = (props) => {
|
|
115
|
+
const [inProgress, setInProgress] = useState2(false);
|
|
116
|
+
const [isActionPerformed, setIsActionPerformed] = useState2(false);
|
|
117
|
+
const [responseMessage, setResponseMessage] = useState2(null);
|
|
118
|
+
const [showModal, setShowModal] = useState2(null);
|
|
119
|
+
const execute = async (event) => {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
event.stopPropagation();
|
|
122
|
+
if (props.confirm) {
|
|
123
|
+
const confirmed = await showConfirmation("Are you sure you want to delete this item?");
|
|
124
|
+
setShowModal(null);
|
|
125
|
+
if (!confirmed) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (props.oneTimeAction && isActionPerformed) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
setInProgress(true);
|
|
133
|
+
let isValid = true;
|
|
134
|
+
if (props.onValidate !== void 0) {
|
|
135
|
+
isValid = await props.onValidate();
|
|
136
|
+
if (!isValid) {
|
|
137
|
+
setInProgress(false);
|
|
138
|
+
ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (props.onClick !== void 0) {
|
|
143
|
+
let response = await props.onClick();
|
|
144
|
+
if (response.isSuccessful) {
|
|
145
|
+
setIsActionPerformed(true);
|
|
146
|
+
setResponseMessage(response.message);
|
|
147
|
+
if (props.showToast) {
|
|
148
|
+
ToastService_default.showInfo(response.message || "");
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
ToastService_default.showError(response.message || "");
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
ToastService_default.showError("No action defined.");
|
|
155
|
+
}
|
|
156
|
+
setInProgress(false);
|
|
157
|
+
};
|
|
158
|
+
const showConfirmation = (message) => {
|
|
159
|
+
return new Promise((resolve) => {
|
|
160
|
+
const onConfirm = () => resolve(true);
|
|
161
|
+
const onCancel = () => resolve(false);
|
|
162
|
+
setShowModal(/* @__PURE__ */ jsx3(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
|
|
166
|
+
let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Solid */);
|
|
167
|
+
const isDisabled = inProgress || isActionPerformed && props.oneTimeAction;
|
|
168
|
+
return /* @__PURE__ */ jsxs2(React3.Fragment, { children: [
|
|
169
|
+
/* @__PURE__ */ jsxs2(
|
|
170
|
+
"button",
|
|
171
|
+
{
|
|
172
|
+
type: "submit",
|
|
173
|
+
onClick: execute,
|
|
174
|
+
disabled: props.disabled,
|
|
175
|
+
title: isDisabled ? "The button is disabled to prevent any action" : "",
|
|
176
|
+
className: buttonClass + " relative " + props.className,
|
|
177
|
+
children: [
|
|
178
|
+
isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
|
|
179
|
+
inProgress && /* @__PURE__ */ jsx3(React3.Fragment, { children: props.hideProgressIndicator === true ? /* @__PURE__ */ jsx3("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ jsxs2("svg", { className: "animate-spin ml-2 mr-3 h-5 w-5 " + progressClass, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
180
|
+
/* @__PURE__ */ jsx3("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
181
|
+
/* @__PURE__ */ jsx3("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
182
|
+
] }) })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
showModal
|
|
187
|
+
] });
|
|
188
|
+
};
|
|
189
|
+
var Button_default = Button;
|
|
190
|
+
|
|
191
|
+
// src/clients/CacheManage.tsx
|
|
192
|
+
import NodeCache from "node-cache";
|
|
193
|
+
var CacheManager = class _CacheManager {
|
|
194
|
+
constructor() {
|
|
195
|
+
this.maxCacheSize = 1e3;
|
|
196
|
+
this.cache = new NodeCache({ stdTTL: 0, checkperiod: 300 });
|
|
197
|
+
}
|
|
198
|
+
static getInstance() {
|
|
199
|
+
if (!_CacheManager.instance) {
|
|
200
|
+
_CacheManager.instance = new _CacheManager();
|
|
201
|
+
}
|
|
202
|
+
return _CacheManager.instance;
|
|
203
|
+
}
|
|
204
|
+
get(key) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
set(key, data, ttl) {
|
|
208
|
+
}
|
|
209
|
+
clear() {
|
|
210
|
+
this.cache.flushAll();
|
|
211
|
+
}
|
|
212
|
+
size() {
|
|
213
|
+
return this.cache.keys().length;
|
|
214
|
+
}
|
|
215
|
+
destroy() {
|
|
216
|
+
this.cache.close();
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// src/clients/ServiceClient.tsx
|
|
221
|
+
var ServerApiError = class extends Error {
|
|
222
|
+
constructor(data, status) {
|
|
223
|
+
super(data.message || "---");
|
|
224
|
+
this.status = status;
|
|
225
|
+
this.data = data;
|
|
226
|
+
this.data.isSuccessful = false;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var ServiceClient = class {
|
|
230
|
+
constructor(apiBaseUrl, session) {
|
|
231
|
+
this.cacheManager = CacheManager.getInstance();
|
|
232
|
+
this.baseUrl = apiBaseUrl;
|
|
233
|
+
this.session = session;
|
|
234
|
+
}
|
|
235
|
+
buildFullPath(path, params) {
|
|
236
|
+
let updatedPath = path;
|
|
237
|
+
if (params) {
|
|
238
|
+
Object.keys(params).forEach((key) => {
|
|
239
|
+
updatedPath = updatedPath.replace(
|
|
240
|
+
`{${key}}`,
|
|
241
|
+
String(params[key])
|
|
242
|
+
);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return this.baseUrl + updatedPath;
|
|
246
|
+
}
|
|
247
|
+
getConfig() {
|
|
248
|
+
const config = { headers: {} };
|
|
249
|
+
if (this.session) {
|
|
250
|
+
if (this.session.oAuthToken) {
|
|
251
|
+
config.headers["Authorization"] = "Bearer " + this.session.oAuthToken;
|
|
252
|
+
}
|
|
253
|
+
config.headers["cid"] = this.session.cid || "";
|
|
254
|
+
config.headers["UserCurrencyCode"] = this.session.userCurrencyCode || "INR";
|
|
255
|
+
config.headers["MarketCode"] = this.session?.marketCode || "IND";
|
|
256
|
+
}
|
|
257
|
+
return config;
|
|
258
|
+
}
|
|
259
|
+
handleFetchError(error) {
|
|
260
|
+
console.log(error);
|
|
261
|
+
const serverApiError = error;
|
|
262
|
+
if (serverApiError) {
|
|
263
|
+
return serverApiError.data;
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
message: "There is some error. Please try after sometime.",
|
|
267
|
+
isSuccessful: false
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
async fetchJsonWithCache(fullPath, config) {
|
|
271
|
+
const cacheKey = fullPath + "--" + (this.session?.marketCode || "IND");
|
|
272
|
+
const cachedData = this.cacheManager.get(cacheKey);
|
|
273
|
+
if (cachedData) {
|
|
274
|
+
return cachedData;
|
|
275
|
+
}
|
|
276
|
+
console.log("*****************CALLING API:", cacheKey, (/* @__PURE__ */ new Date()).toISOString());
|
|
277
|
+
const response = await fetch(fullPath, { headers: config.headers });
|
|
278
|
+
if (!response.ok) {
|
|
279
|
+
const apiErrorData = await response.json();
|
|
280
|
+
throw new ServerApiError(apiErrorData, response.status);
|
|
281
|
+
}
|
|
282
|
+
const cacheControl = response.headers.get("Cache-Control");
|
|
283
|
+
let revalidate = null;
|
|
284
|
+
if (cacheControl) {
|
|
285
|
+
const maxAgeMatch = cacheControl.match(/max-age=(\d+)/);
|
|
286
|
+
if (maxAgeMatch && maxAgeMatch[1]) {
|
|
287
|
+
const maxAge = parseInt(maxAgeMatch[1], 10);
|
|
288
|
+
revalidate = maxAge * 1e3;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const data = await response.json();
|
|
292
|
+
data.isSuccessful = true;
|
|
293
|
+
if (revalidate !== null && revalidate > 0) {
|
|
294
|
+
console.log("revalidate............I am caching:" + revalidate);
|
|
295
|
+
this.cacheManager.set(cacheKey, data, revalidate);
|
|
296
|
+
}
|
|
297
|
+
return data;
|
|
298
|
+
}
|
|
299
|
+
// private async refreshToken(): Promise<void> {
|
|
300
|
+
// console.log("*******************calling refresh token***********************");
|
|
301
|
+
// try {
|
|
302
|
+
// const response = await fetch(this.baseUrl + "/auth/storefront/login/refreshToken", {
|
|
303
|
+
// method: 'POST',
|
|
304
|
+
// headers: {
|
|
305
|
+
// 'Content-Type': 'application/json'
|
|
306
|
+
// },
|
|
307
|
+
// body: JSON.stringify({ refreshToken: this.session.refreshToken })
|
|
308
|
+
// });
|
|
309
|
+
// if (!response.ok) {
|
|
310
|
+
// throw new Error("Failed to refresh token");
|
|
311
|
+
// }
|
|
312
|
+
// const responseData = await response.json();
|
|
313
|
+
// this.session.oAuthToken = responseData.result.accessToken;
|
|
314
|
+
// if (typeof window === "undefined") {
|
|
315
|
+
// // Running on the server
|
|
316
|
+
// } else {
|
|
317
|
+
// await fetch("/api/login", {
|
|
318
|
+
// method: "post",
|
|
319
|
+
// headers: {
|
|
320
|
+
// "Content-Type": "application/json",
|
|
321
|
+
// },
|
|
322
|
+
// body: JSON.stringify({ session: this.session }),
|
|
323
|
+
// });
|
|
324
|
+
// }
|
|
325
|
+
// } catch (error: any) {
|
|
326
|
+
// throw new Error("Failed to refresh token");
|
|
327
|
+
// }
|
|
328
|
+
// }
|
|
329
|
+
async handleRequest(request) {
|
|
330
|
+
try {
|
|
331
|
+
return await request();
|
|
332
|
+
} catch (error) {
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async post(path, data) {
|
|
337
|
+
const request = async () => {
|
|
338
|
+
const fullPath = this.baseUrl + path;
|
|
339
|
+
const config = this.getConfig();
|
|
340
|
+
const response = await fetch(fullPath, {
|
|
341
|
+
method: "POST",
|
|
342
|
+
headers: {
|
|
343
|
+
...config.headers,
|
|
344
|
+
"Content-Type": "application/json"
|
|
345
|
+
},
|
|
346
|
+
body: JSON.stringify(data)
|
|
347
|
+
});
|
|
348
|
+
if (!response.ok) {
|
|
349
|
+
const apiErrorData = await response.json();
|
|
350
|
+
throw new ServerApiError(apiErrorData, response.status);
|
|
351
|
+
}
|
|
352
|
+
const responseData = await response.json();
|
|
353
|
+
responseData.isSuccessful = true;
|
|
354
|
+
return responseData;
|
|
355
|
+
};
|
|
356
|
+
try {
|
|
357
|
+
return await this.handleRequest(request);
|
|
358
|
+
} catch (error) {
|
|
359
|
+
return this.handleFetchError(error);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
async getSingle(path, params) {
|
|
363
|
+
const request = async () => {
|
|
364
|
+
const sanitizedParams = params ? Object.fromEntries(
|
|
365
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
366
|
+
) : void 0;
|
|
367
|
+
const fullPath = this.buildFullPath(path, sanitizedParams);
|
|
368
|
+
const config = this.getConfig();
|
|
369
|
+
return await this.fetchJsonWithCache(fullPath, config);
|
|
370
|
+
};
|
|
371
|
+
try {
|
|
372
|
+
return await this.handleRequest(request);
|
|
373
|
+
} catch (error) {
|
|
374
|
+
return this.handleFetchError(error);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
async get(path, params) {
|
|
378
|
+
const request = async () => {
|
|
379
|
+
const sanitizedParams = params ? Object.fromEntries(
|
|
380
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
381
|
+
) : void 0;
|
|
382
|
+
const fullPath = this.buildFullPath(path, sanitizedParams);
|
|
383
|
+
const config = this.getConfig();
|
|
384
|
+
console.log(fullPath);
|
|
385
|
+
return await this.fetchJsonWithCache(fullPath, config);
|
|
386
|
+
};
|
|
387
|
+
try {
|
|
388
|
+
return await this.handleRequest(request);
|
|
389
|
+
} catch (error) {
|
|
390
|
+
return this.handleFetchError(error);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
var ServiceClient_default = ServiceClient;
|
|
395
|
+
|
|
396
|
+
export {
|
|
397
|
+
buttonClasses,
|
|
398
|
+
Button_default,
|
|
399
|
+
ServiceClient_default
|
|
400
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// src/components/HlsPlayer.tsx
|
|
2
|
+
import React, { useRef, useEffect, useState, useCallback } from "react";
|
|
3
|
+
import Hls from "hls.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var HlsPlayer = React.memo(
|
|
6
|
+
({
|
|
7
|
+
assetUrl,
|
|
8
|
+
posterUrl,
|
|
9
|
+
intrinsicWidth,
|
|
10
|
+
intrinsicHeight,
|
|
11
|
+
showControls = true,
|
|
12
|
+
loop = false,
|
|
13
|
+
playOptions = "autoplay"
|
|
14
|
+
}) => {
|
|
15
|
+
const videoRef = useRef(null);
|
|
16
|
+
const hlsRef = useRef(null);
|
|
17
|
+
const [isPlaying, setIsPlaying] = useState(playOptions === "autoplay");
|
|
18
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
19
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
20
|
+
const wasManuallyPausedRef = useRef(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const checkMobile = () => {
|
|
23
|
+
const hasTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
24
|
+
const isSmallScreen = window.innerWidth <= 768;
|
|
25
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
26
|
+
const isMobileUA = /android|iphone|ipad|ipod/i.test(ua);
|
|
27
|
+
setIsMobile(hasTouch || isSmallScreen || isMobileUA);
|
|
28
|
+
};
|
|
29
|
+
checkMobile();
|
|
30
|
+
window.addEventListener("resize", checkMobile);
|
|
31
|
+
return () => window.removeEventListener("resize", checkMobile);
|
|
32
|
+
}, []);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const v = videoRef.current;
|
|
35
|
+
if (!v || !assetUrl) return;
|
|
36
|
+
if (hlsRef.current) {
|
|
37
|
+
hlsRef.current.destroy();
|
|
38
|
+
hlsRef.current = null;
|
|
39
|
+
}
|
|
40
|
+
if (Hls.isSupported()) {
|
|
41
|
+
const hls = new Hls();
|
|
42
|
+
hls.loadSource(assetUrl);
|
|
43
|
+
hls.attachMedia(v);
|
|
44
|
+
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
|
45
|
+
if (isPlaying && !wasManuallyPausedRef.current) {
|
|
46
|
+
v.play().catch(console.error);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
hlsRef.current = hls;
|
|
50
|
+
} else if (v.canPlayType("application/vnd.apple.mpegurl")) {
|
|
51
|
+
v.src = assetUrl;
|
|
52
|
+
}
|
|
53
|
+
}, [assetUrl, isPlaying]);
|
|
54
|
+
const handlePlayPause = useCallback(() => {
|
|
55
|
+
const v = videoRef.current;
|
|
56
|
+
if (!v) return;
|
|
57
|
+
if (v.paused) {
|
|
58
|
+
wasManuallyPausedRef.current = false;
|
|
59
|
+
v.play().then(() => setIsPlaying(true));
|
|
60
|
+
} else {
|
|
61
|
+
wasManuallyPausedRef.current = true;
|
|
62
|
+
v.pause();
|
|
63
|
+
setIsPlaying(false);
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
const handleMouseEnter = useCallback(() => {
|
|
67
|
+
if (isMobile) return;
|
|
68
|
+
setIsHovered(true);
|
|
69
|
+
if (playOptions === "playOnHover" && videoRef.current && !wasManuallyPausedRef.current) {
|
|
70
|
+
videoRef.current.play().then(() => setIsPlaying(true));
|
|
71
|
+
}
|
|
72
|
+
}, [playOptions, isMobile]);
|
|
73
|
+
const handleMouseLeave = useCallback(() => {
|
|
74
|
+
if (isMobile) return;
|
|
75
|
+
setIsHovered(false);
|
|
76
|
+
if (playOptions === "playOnHover" && videoRef.current) {
|
|
77
|
+
videoRef.current.pause();
|
|
78
|
+
videoRef.current.currentTime = 0;
|
|
79
|
+
setIsPlaying(false);
|
|
80
|
+
}
|
|
81
|
+
}, [playOptions, isMobile]);
|
|
82
|
+
return /* @__PURE__ */ jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: "relative w-full aspect-video bg-black",
|
|
86
|
+
onMouseEnter: handleMouseEnter,
|
|
87
|
+
onMouseLeave: handleMouseLeave,
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
"video",
|
|
91
|
+
{
|
|
92
|
+
ref: videoRef,
|
|
93
|
+
className: "w-full h-full object-contain",
|
|
94
|
+
poster: posterUrl,
|
|
95
|
+
controls: showControls && (isMobile || isPlaying),
|
|
96
|
+
muted: playOptions === "autoplay" || playOptions === "playOnHover",
|
|
97
|
+
autoPlay: playOptions === "autoplay",
|
|
98
|
+
loop,
|
|
99
|
+
playsInline: true,
|
|
100
|
+
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
!isMobile && playOptions === "playOnHover" && posterUrl && /* @__PURE__ */ jsx(
|
|
104
|
+
"img",
|
|
105
|
+
{
|
|
106
|
+
src: posterUrl,
|
|
107
|
+
width: intrinsicWidth,
|
|
108
|
+
height: intrinsicHeight,
|
|
109
|
+
alt: "poster",
|
|
110
|
+
className: `absolute inset-0 object-cover transition-opacity ${isHovered ? "opacity-0" : "opacity-100"}`
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
!isMobile && !isPlaying && /* @__PURE__ */ jsx(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
className: "absolute inset-0 flex items-center justify-center cursor-pointer",
|
|
117
|
+
onClick: handlePlayPause,
|
|
118
|
+
children: "\u25B6"
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
HlsPlayer.displayName = "HlsPlayer";
|
|
127
|
+
var HlsPlayer_default = HlsPlayer;
|
|
128
|
+
|
|
129
|
+
export {
|
|
130
|
+
HlsPlayer_default
|
|
131
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
type WidgetRegistryType = Record<string, ComponentType<any>>;
|
|
4
|
+
declare function registerWidgets(widgets: WidgetRegistryType): void;
|
|
5
|
+
declare function getWidget(code: string): ComponentType<any> | undefined;
|
|
2
6
|
|
|
3
7
|
interface ViewControlProps {
|
|
4
8
|
value?: any;
|
|
5
|
-
controlType
|
|
9
|
+
controlType?: string;
|
|
6
10
|
format?: string;
|
|
7
11
|
width?: string;
|
|
8
12
|
apiBaseUrl?: string;
|
|
9
|
-
customProps?: Record<string,
|
|
13
|
+
customProps?: Record<string, unknown>;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
declare const ViewControl: React.
|
|
16
|
+
declare const ViewControl: React.FC<ViewControlProps>;
|
|
13
17
|
|
|
14
18
|
declare const ViewControlTypes: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
lineText: string;
|
|
20
|
+
asset: string;
|
|
21
|
+
multilineTextBullets: string;
|
|
22
|
+
money: string;
|
|
23
|
+
date: string;
|
|
24
|
+
time: string;
|
|
25
|
+
datetime: string;
|
|
26
|
+
number: string;
|
|
27
|
+
multilineText: string;
|
|
28
|
+
moneyText: string;
|
|
29
|
+
percentage: string;
|
|
30
|
+
statusBg: string;
|
|
31
|
+
progressIndicator: string;
|
|
32
|
+
timeUntilStarts: string;
|
|
33
|
+
timeUntilStartsStyled: string;
|
|
34
|
+
aiGeneratedSummary: string;
|
|
26
35
|
};
|
|
27
36
|
|
|
28
37
|
interface InputCallbackValues<T> {
|
|
@@ -191,7 +200,7 @@ interface Session {
|
|
|
191
200
|
interface PageBodyRendererProps {
|
|
192
201
|
rawBody?: string;
|
|
193
202
|
routeParameters?: {
|
|
194
|
-
[key: string]:
|
|
203
|
+
[key: string]: unknown;
|
|
195
204
|
};
|
|
196
205
|
query?: {
|
|
197
206
|
[key: string]: string;
|
|
@@ -200,7 +209,13 @@ interface PageBodyRendererProps {
|
|
|
200
209
|
host: string;
|
|
201
210
|
path: string;
|
|
202
211
|
apiBaseUrl: string;
|
|
212
|
+
breadcrumb?: string;
|
|
213
|
+
donotApplyContainerClass?: boolean;
|
|
214
|
+
donotApplyContainerLargeClass?: boolean;
|
|
215
|
+
serviceClient?: ServiceClientInterface;
|
|
216
|
+
assetBaseUrl?: string;
|
|
217
|
+
device?: string;
|
|
203
218
|
}
|
|
204
219
|
declare const PageBodyRenderer: React.FC<PageBodyRendererProps>;
|
|
205
220
|
|
|
206
|
-
export { type ActionResponse, DataList, InputControl, type InputControlProps, InputControlType, PageBodyRenderer, ViewControl, type ViewControlProps, ViewControlTypes };
|
|
221
|
+
export { type ActionResponse, DataList, InputControl, type InputControlProps, InputControlType, PageBodyRenderer, ViewControl, type ViewControlProps, ViewControlTypes, type WidgetRegistryType, getWidget, registerWidgets };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
type WidgetRegistryType = Record<string, ComponentType<any>>;
|
|
4
|
+
declare function registerWidgets(widgets: WidgetRegistryType): void;
|
|
5
|
+
declare function getWidget(code: string): ComponentType<any> | undefined;
|
|
2
6
|
|
|
3
7
|
interface ViewControlProps {
|
|
4
8
|
value?: any;
|
|
5
|
-
controlType
|
|
9
|
+
controlType?: string;
|
|
6
10
|
format?: string;
|
|
7
11
|
width?: string;
|
|
8
12
|
apiBaseUrl?: string;
|
|
9
|
-
customProps?: Record<string,
|
|
13
|
+
customProps?: Record<string, unknown>;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
declare const ViewControl: React.
|
|
16
|
+
declare const ViewControl: React.FC<ViewControlProps>;
|
|
13
17
|
|
|
14
18
|
declare const ViewControlTypes: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
lineText: string;
|
|
20
|
+
asset: string;
|
|
21
|
+
multilineTextBullets: string;
|
|
22
|
+
money: string;
|
|
23
|
+
date: string;
|
|
24
|
+
time: string;
|
|
25
|
+
datetime: string;
|
|
26
|
+
number: string;
|
|
27
|
+
multilineText: string;
|
|
28
|
+
moneyText: string;
|
|
29
|
+
percentage: string;
|
|
30
|
+
statusBg: string;
|
|
31
|
+
progressIndicator: string;
|
|
32
|
+
timeUntilStarts: string;
|
|
33
|
+
timeUntilStartsStyled: string;
|
|
34
|
+
aiGeneratedSummary: string;
|
|
26
35
|
};
|
|
27
36
|
|
|
28
37
|
interface InputCallbackValues<T> {
|
|
@@ -191,7 +200,7 @@ interface Session {
|
|
|
191
200
|
interface PageBodyRendererProps {
|
|
192
201
|
rawBody?: string;
|
|
193
202
|
routeParameters?: {
|
|
194
|
-
[key: string]:
|
|
203
|
+
[key: string]: unknown;
|
|
195
204
|
};
|
|
196
205
|
query?: {
|
|
197
206
|
[key: string]: string;
|
|
@@ -200,7 +209,13 @@ interface PageBodyRendererProps {
|
|
|
200
209
|
host: string;
|
|
201
210
|
path: string;
|
|
202
211
|
apiBaseUrl: string;
|
|
212
|
+
breadcrumb?: string;
|
|
213
|
+
donotApplyContainerClass?: boolean;
|
|
214
|
+
donotApplyContainerLargeClass?: boolean;
|
|
215
|
+
serviceClient?: ServiceClientInterface;
|
|
216
|
+
assetBaseUrl?: string;
|
|
217
|
+
device?: string;
|
|
203
218
|
}
|
|
204
219
|
declare const PageBodyRenderer: React.FC<PageBodyRendererProps>;
|
|
205
220
|
|
|
206
|
-
export { type ActionResponse, DataList, InputControl, type InputControlProps, InputControlType, PageBodyRenderer, ViewControl, type ViewControlProps, ViewControlTypes };
|
|
221
|
+
export { type ActionResponse, DataList, InputControl, type InputControlProps, InputControlType, PageBodyRenderer, ViewControl, type ViewControlProps, ViewControlTypes, type WidgetRegistryType, getWidget, registerWidgets };
|