@prosopo/procaptcha-bundle 4.1.40 → 4.1.42
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/.turbo/turbo-build$colon$cjs.log +20 -16
- package/.turbo/turbo-build$colon$tsc.log +27 -27
- package/.turbo/turbo-build.log +19 -16
- package/CHANGELOG.md +24 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/index.cjs +128 -166
- package/dist/cjs/util/captcha/captchaRenderer.cjs +48 -69
- package/dist/cjs/util/captcha/components/bundleCaptcha.cjs +19 -23
- package/dist/cjs/util/config.cjs +21 -22
- package/dist/cjs/util/configCreator.cjs +17 -21
- package/dist/cjs/util/language.cjs +29 -21
- package/dist/cjs/util/timeout.cjs +15 -12
- package/dist/cjs/util/widgetFactory.cjs +56 -90
- package/dist/cjs/util/widgetThemeResolver.cjs +15 -15
- package/dist/index.js +123 -167
- package/dist/util/captcha/captchaRenderer.js +44 -66
- package/dist/util/captcha/components/bundleCaptcha.js +17 -21
- package/dist/util/config.js +22 -24
- package/dist/util/configCreator.js +18 -22
- package/dist/util/language.js +29 -22
- package/dist/util/timeout.js +16 -13
- package/dist/util/widgetFactory.js +55 -89
- package/dist/util/widgetThemeResolver.js +15 -15
- package/package.json +11 -11
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,70 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
timeout.setValidChallengeLength(renderOptions, element, config);
|
|
50
|
-
language.setLanguage(renderOptions, element, config);
|
|
51
|
-
}
|
|
52
|
-
makeEmotionCache(cacheKey, container) {
|
|
53
|
-
return createCache({
|
|
54
|
-
key: cacheKey,
|
|
55
|
-
prepend: true,
|
|
56
|
-
container
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
createReactRoot(container, identifierPrefix) {
|
|
60
|
-
return client.createRoot(container, {
|
|
61
|
-
identifierPrefix
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
renderCaptchaComponent(reactRoot, emotionCache, captchaComponent) {
|
|
65
|
-
reactRoot.render(
|
|
66
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.CacheProvider, { value: emotionCache, children: captchaComponent })
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_language = require("../language.cjs");
|
|
3
|
+
const require_configCreator = require("../configCreator.cjs");
|
|
4
|
+
const require_timeout = require("../timeout.cjs");
|
|
5
|
+
const require_bundleCaptcha = require("./components/bundleCaptcha.cjs");
|
|
6
|
+
let _emotion_cache = require("@emotion/cache");
|
|
7
|
+
_emotion_cache = require_runtime.__toESM(_emotion_cache, 1);
|
|
8
|
+
let _emotion_react = require("@emotion/react");
|
|
9
|
+
let react_dom_client = require("react-dom/client");
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
//#region src/util/captcha/captchaRenderer.tsx
|
|
12
|
+
var CaptchaRenderer = class {
|
|
13
|
+
renderCaptcha(settings, container, renderOptions, callbacks, isWeb2, i18n, invisible, widgetContainer, sourceElement) {
|
|
14
|
+
const config = require_configCreator.createConfig(renderOptions.siteKey, renderOptions.theme, renderOptions.language, isWeb2, invisible, renderOptions.userAccountAddress, renderOptions.ipv4, renderOptions.ipv6);
|
|
15
|
+
this.readAndValidateSettings(sourceElement || container, config, renderOptions);
|
|
16
|
+
const reactRoot = this.createReactRoot(container, settings.identifierPrefix);
|
|
17
|
+
const emotionCache = this.makeEmotionCache(settings.emotionCacheKey, container);
|
|
18
|
+
const captchaComponent = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_bundleCaptcha.BundleCaptcha, {
|
|
19
|
+
config,
|
|
20
|
+
callbacks,
|
|
21
|
+
i18n,
|
|
22
|
+
container: widgetContainer
|
|
23
|
+
});
|
|
24
|
+
this.renderCaptchaComponent(reactRoot, emotionCache, captchaComponent);
|
|
25
|
+
return reactRoot;
|
|
26
|
+
}
|
|
27
|
+
readAndValidateSettings(element, config, renderOptions) {
|
|
28
|
+
require_timeout.setValidChallengeLength(renderOptions, element, config);
|
|
29
|
+
require_language.setLanguage(renderOptions, element, config);
|
|
30
|
+
}
|
|
31
|
+
makeEmotionCache(cacheKey, container) {
|
|
32
|
+
return (0, _emotion_cache.default)({
|
|
33
|
+
key: cacheKey,
|
|
34
|
+
prepend: true,
|
|
35
|
+
container
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
createReactRoot(container, identifierPrefix) {
|
|
39
|
+
return (0, react_dom_client.createRoot)(container, { identifierPrefix });
|
|
40
|
+
}
|
|
41
|
+
renderCaptchaComponent(reactRoot, emotionCache, captchaComponent) {
|
|
42
|
+
reactRoot.render(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_emotion_react.CacheProvider, {
|
|
43
|
+
value: emotionCache,
|
|
44
|
+
children: captchaComponent
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
70
49
|
exports.CaptchaRenderer = CaptchaRenderer;
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
i18n,
|
|
20
|
-
container
|
|
21
|
-
},
|
|
22
|
-
componentKey
|
|
23
|
-
);
|
|
1
|
+
let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
2
|
+
let _prosopo_procaptcha_frictionless = require("@prosopo/procaptcha-frictionless");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/util/captcha/components/bundleCaptcha.tsx
|
|
6
|
+
var BundleCaptcha = (props) => {
|
|
7
|
+
const { config, callbacks, i18n, container } = props;
|
|
8
|
+
const [componentKey, setComponentKey] = (0, react.useState)(0);
|
|
9
|
+
const restart = () => {
|
|
10
|
+
setComponentKey((prevKey) => prevKey + 1);
|
|
11
|
+
};
|
|
12
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_prosopo_procaptcha_frictionless.ProcaptchaFrictionless, {
|
|
13
|
+
config,
|
|
14
|
+
callbacks: (0, _prosopo_procaptcha_common.getDefaultEvents)(callbacks),
|
|
15
|
+
restart,
|
|
16
|
+
i18n,
|
|
17
|
+
container
|
|
18
|
+
}, componentKey);
|
|
24
19
|
};
|
|
20
|
+
//#endregion
|
|
25
21
|
exports.BundleCaptcha = BundleCaptcha;
|
package/dist/cjs/util/config.cjs
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (script) {
|
|
9
|
-
return script;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return null;
|
|
1
|
+
//#region src/util/config.ts
|
|
2
|
+
var getProcaptchaScript = (names) => {
|
|
3
|
+
for (const name of names) {
|
|
4
|
+
const script = document.querySelector(`script[src*="${name}"]`);
|
|
5
|
+
if (script) return script;
|
|
6
|
+
}
|
|
7
|
+
return null;
|
|
13
8
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
var extractParams = (names) => {
|
|
10
|
+
const script = getProcaptchaScript(names);
|
|
11
|
+
if (script) {
|
|
12
|
+
const params = new URLSearchParams(script.src.split("?")[1]);
|
|
13
|
+
return {
|
|
14
|
+
onloadUrlCallback: params.get("onload") || void 0,
|
|
15
|
+
renderExplicit: params.get("render") || void 0
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
onloadUrlCallback: void 0,
|
|
20
|
+
renderExplicit: void 0
|
|
21
|
+
};
|
|
24
22
|
};
|
|
23
|
+
//#endregion
|
|
25
24
|
exports.extractParams = extractParams;
|
|
26
25
|
exports.getProcaptchaScript = getProcaptchaScript;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const types = require("@prosopo/types");
|
|
1
|
+
let _prosopo_types = require("@prosopo/types");
|
|
2
|
+
//#region src/util/configCreator.ts
|
|
4
3
|
function createConfig(siteKey, theme = "light", language, web2 = true, invisible = false, userAccountAddress, ipv4 = false, ipv6 = false) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
language,
|
|
20
|
-
ipv4,
|
|
21
|
-
ipv6
|
|
22
|
-
});
|
|
4
|
+
if (!siteKey) siteKey = process.env.PROSOPO_SITE_KEY || "";
|
|
5
|
+
return _prosopo_types.ProcaptchaConfigSchema.parse({
|
|
6
|
+
defaultEnvironment: process.env.PROSOPO_DEFAULT_ENVIRONMENT ? _prosopo_types.EnvironmentTypesSchema.parse(process.env.PROSOPO_DEFAULT_ENVIRONMENT) : _prosopo_types.EnvironmentTypesSchema.enum.development,
|
|
7
|
+
userAccountAddress: userAccountAddress || "",
|
|
8
|
+
account: { address: siteKey },
|
|
9
|
+
serverUrl: process.env.PROSOPO_SERVER_URL || "",
|
|
10
|
+
mongoAtlasUri: process.env.PROSOPO_MONGO_EVENTS_URI || "",
|
|
11
|
+
web2,
|
|
12
|
+
mode: invisible ? "invisible" : "visible",
|
|
13
|
+
theme,
|
|
14
|
+
language,
|
|
15
|
+
ipv4,
|
|
16
|
+
ipv6
|
|
17
|
+
});
|
|
23
18
|
}
|
|
19
|
+
//#endregion
|
|
24
20
|
exports.createConfig = createConfig;
|
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
let _prosopo_locale = require("@prosopo/locale");
|
|
2
|
+
//#region src/util/language.ts
|
|
3
|
+
/**
|
|
4
|
+
* Prioritizes language selection from:
|
|
5
|
+
* 1. renderOptions.language
|
|
6
|
+
* 2. element's data-language attribute
|
|
7
|
+
* 3. Defaults to 'en'
|
|
8
|
+
*
|
|
9
|
+
* Validates the language against currently supported languages
|
|
10
|
+
*
|
|
11
|
+
* @param renderOptions
|
|
12
|
+
* @param element
|
|
13
|
+
* @param config
|
|
14
|
+
*/
|
|
15
|
+
var setLanguage = (renderOptions, element, config) => {
|
|
16
|
+
const resolved = resolveLanguage(renderOptions, element);
|
|
17
|
+
if (resolved) config.language = resolved;
|
|
9
18
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return validateLanguage(languageAttribute);
|
|
19
|
+
var resolveLanguage = (renderOptions, element) => {
|
|
20
|
+
const languageAttribute = renderOptions?.language || element.getAttribute("data-language");
|
|
21
|
+
if (!languageAttribute) return;
|
|
22
|
+
return validateLanguage(languageAttribute);
|
|
16
23
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
var validateLanguage = (languageAttribute) => {
|
|
25
|
+
try {
|
|
26
|
+
return _prosopo_locale.LanguageSchema.parse(languageAttribute);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(`Invalid language attribute: ${languageAttribute}`);
|
|
29
|
+
return _prosopo_locale.LanguageSchema.parse("en");
|
|
30
|
+
}
|
|
24
31
|
};
|
|
32
|
+
//#endregion
|
|
25
33
|
exports.resolveLanguage = resolveLanguage;
|
|
26
34
|
exports.setLanguage = setLanguage;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
//#region src/util/timeout.ts
|
|
2
|
+
/**
|
|
3
|
+
* Set the timeout for a solved captcha
|
|
4
|
+
*
|
|
5
|
+
* @param renderOptions
|
|
6
|
+
* @param element
|
|
7
|
+
* @param config
|
|
8
|
+
*/
|
|
9
|
+
var setValidChallengeLength = (renderOptions, element, config) => {
|
|
10
|
+
const challengeValidLengthAttribute = renderOptions?.["challenge-valid-length"] || element.getAttribute("data-challenge-valid-length");
|
|
11
|
+
if (challengeValidLengthAttribute) {
|
|
12
|
+
config.captchas.image.solutionTimeout = Number.parseInt(challengeValidLengthAttribute);
|
|
13
|
+
config.captchas.pow.solutionTimeout = Number.parseInt(challengeValidLengthAttribute);
|
|
14
|
+
}
|
|
13
15
|
};
|
|
16
|
+
//#endregion
|
|
14
17
|
exports.setValidChallengeLength = setValidChallengeLength;
|
|
@@ -1,91 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const captchaRenderer = await this.getCaptchaRenderer(language$1);
|
|
58
|
-
const captchaRoot = captchaRenderer.renderCaptcha(
|
|
59
|
-
{
|
|
60
|
-
identifierPrefix: "procaptcha-",
|
|
61
|
-
emotionCacheKey: "procaptcha",
|
|
62
|
-
webComponentTag: "prosopo-procaptcha"
|
|
63
|
-
},
|
|
64
|
-
widgetInteractiveArea,
|
|
65
|
-
renderOptions,
|
|
66
|
-
callbacks,
|
|
67
|
-
isWeb2,
|
|
68
|
-
this.i18n,
|
|
69
|
-
invisible,
|
|
70
|
-
widgetContainer,
|
|
71
|
-
container
|
|
72
|
-
);
|
|
73
|
-
return captchaRoot;
|
|
74
|
-
}
|
|
75
|
-
async getCaptchaRenderer(language2) {
|
|
76
|
-
if (this._i18n === null) {
|
|
77
|
-
this._i18n = await locale.loadI18next(false, language2);
|
|
78
|
-
} else if (language2 && this._i18n.language !== language2) {
|
|
79
|
-
await this._i18n.changeLanguage(language2);
|
|
80
|
-
}
|
|
81
|
-
if (this.captchaRenderer === null) {
|
|
82
|
-
this.captchaRenderer = await this.createCaptchaRenderer();
|
|
83
|
-
}
|
|
84
|
-
return this.captchaRenderer;
|
|
85
|
-
}
|
|
86
|
-
async createCaptchaRenderer() {
|
|
87
|
-
const CaptchaRenderer = (await Promise.resolve().then(() => require("./captcha/captchaRenderer.cjs"))).CaptchaRenderer;
|
|
88
|
-
return new CaptchaRenderer();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
const require_language = require("./language.cjs");
|
|
2
|
+
let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
3
|
+
let _prosopo_locale = require("@prosopo/locale");
|
|
4
|
+
let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
|
|
5
|
+
//#region src/util/widgetFactory.ts
|
|
6
|
+
var WidgetFactory = class {
|
|
7
|
+
constructor(widgetThemeResolver) {
|
|
8
|
+
this.widgetThemeResolver = widgetThemeResolver;
|
|
9
|
+
this.captchaRenderer = null;
|
|
10
|
+
this._i18n = null;
|
|
11
|
+
}
|
|
12
|
+
get i18n() {
|
|
13
|
+
if (this._i18n === null) throw new Error("I18n is not initialized");
|
|
14
|
+
return this._i18n;
|
|
15
|
+
}
|
|
16
|
+
async createWidgets(containers, renderOptions, isWeb2 = true, invisible = false) {
|
|
17
|
+
return Promise.all(containers.map((container) => {
|
|
18
|
+
const callbacks = (0, _prosopo_procaptcha_common.getDefaultCallbacks)(container);
|
|
19
|
+
(0, _prosopo_procaptcha_common.setUserCallbacks)(renderOptions, callbacks, container);
|
|
20
|
+
return this.createWidget(container, renderOptions, callbacks, isWeb2, invisible);
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
async createWidget(container, renderOptions, callbacks, isWeb2 = true, invisible = false) {
|
|
24
|
+
renderOptions.theme = this.widgetThemeResolver.resolveWidgetTheme(container, renderOptions);
|
|
25
|
+
const widgetTheme = "light" === renderOptions.theme ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme;
|
|
26
|
+
let widgetInteractiveArea;
|
|
27
|
+
let widgetContainer;
|
|
28
|
+
if (invisible) {
|
|
29
|
+
const newDiv = document.createElement("div");
|
|
30
|
+
container.appendChild(newDiv);
|
|
31
|
+
widgetInteractiveArea = newDiv;
|
|
32
|
+
widgetContainer = newDiv;
|
|
33
|
+
} else {
|
|
34
|
+
const widgetResult = (0, _prosopo_widget_skeleton.createWidgetSkeleton)(container, widgetTheme, "prosopo-procaptcha");
|
|
35
|
+
widgetInteractiveArea = widgetResult.widgetInteractiveArea;
|
|
36
|
+
widgetContainer = widgetResult.webComponent;
|
|
37
|
+
}
|
|
38
|
+
const language = require_language.resolveLanguage(renderOptions, container);
|
|
39
|
+
return (await this.getCaptchaRenderer(language)).renderCaptcha({
|
|
40
|
+
identifierPrefix: "procaptcha-",
|
|
41
|
+
emotionCacheKey: "procaptcha",
|
|
42
|
+
webComponentTag: "prosopo-procaptcha"
|
|
43
|
+
}, widgetInteractiveArea, renderOptions, callbacks, isWeb2, this.i18n, invisible, widgetContainer, container);
|
|
44
|
+
}
|
|
45
|
+
async getCaptchaRenderer(language) {
|
|
46
|
+
if (this._i18n === null) this._i18n = await (0, _prosopo_locale.loadI18next)(false, language);
|
|
47
|
+
else if (language && this._i18n.language !== language) await this._i18n.changeLanguage(language);
|
|
48
|
+
if (this.captchaRenderer === null) this.captchaRenderer = await this.createCaptchaRenderer();
|
|
49
|
+
return this.captchaRenderer;
|
|
50
|
+
}
|
|
51
|
+
async createCaptchaRenderer() {
|
|
52
|
+
const CaptchaRenderer = (await Promise.resolve().then(() => require("./captcha/captchaRenderer.cjs"))).CaptchaRenderer;
|
|
53
|
+
return new CaptchaRenderer();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
91
57
|
exports.WidgetFactory = WidgetFactory;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
//#region src/util/widgetThemeResolver.ts
|
|
2
|
+
var WidgetThemeResolver = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.themesSet = /* @__PURE__ */ new Set(["light", "dark"]);
|
|
5
|
+
this.defaultTheme = "light";
|
|
6
|
+
}
|
|
7
|
+
resolveWidgetTheme(element, renderOptions) {
|
|
8
|
+
const themeAttribute = renderOptions.theme || element.getAttribute("data-theme") || this.defaultTheme;
|
|
9
|
+
return this.validateTheme(themeAttribute);
|
|
10
|
+
}
|
|
11
|
+
validateTheme(themeAttribute) {
|
|
12
|
+
return this.themesSet.has(themeAttribute) ? themeAttribute : this.defaultTheme;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
16
|
exports.WidgetThemeResolver = WidgetThemeResolver;
|