@descope/sdk-mixins
Advanced tools
Comparing version 0.2.16 to 0.2.17
@@ -41,4 +41,4 @@ 'use strict'; | ||
const BASE_CONTENT_URL_KEY = 'base.content.url'; | ||
const BASE_CONTENT_URL = (IS_LOCAL_STORAGE && localStorage.getItem(BASE_CONTENT_URL_KEY)) || | ||
'https://static.descope.com/pages'; | ||
const BASE_CONTENT_URL = 'https://static.descope.com/pages'; | ||
const OVERRIDE_CONTENT_URL = (IS_LOCAL_STORAGE && localStorage.getItem(BASE_CONTENT_URL_KEY)) || ''; | ||
const ASSETS_FOLDER = 'v2-beta'; | ||
@@ -159,4 +159,12 @@ | ||
function getResourceUrl(projectId, filename, assetsFolder = ASSETS_FOLDER) { | ||
const url = new URL(BASE_CONTENT_URL); | ||
const baseUrlMixin = sdkHelpers.createSingletonMixin((superclass) => { | ||
return class BaseUrlMixinClass extends superclass { | ||
get baseUrl() { | ||
return this.getAttribute('base-url'); | ||
} | ||
}; | ||
}); | ||
function getResourceUrl({ projectId, filename, assetsFolder = ASSETS_FOLDER, baseUrl, }) { | ||
const url = new URL(OVERRIDE_CONTENT_URL || baseUrl || BASE_CONTENT_URL); | ||
url.pathname = sdkHelpers.pathJoin(url.pathname, projectId, assetsFolder, filename); | ||
@@ -166,6 +174,10 @@ return url.toString(); | ||
const staticResourcesMixin = sdkHelpers.createSingletonMixin((superclass) => { | ||
const BaseClass = sdkHelpers.compose(loggerMixin, projectIdMixin)(superclass); | ||
const BaseClass = sdkHelpers.compose(loggerMixin, projectIdMixin, baseUrlMixin)(superclass); | ||
return class StaticResourcesMixinClass extends BaseClass { | ||
async fetchStaticResource(filename, format) { | ||
const resourceUrl = getResourceUrl(this.projectId, filename); | ||
const resourceUrl = getResourceUrl({ | ||
projectId: this.projectId, | ||
filename, | ||
baseUrl: this.baseUrl, | ||
}); | ||
const res = await fetch(resourceUrl, { cache: 'default' }); | ||
@@ -1103,2 +1115,3 @@ if (!res.ok) { | ||
exports.baseUrlMixin = baseUrlMixin; | ||
exports.configMixin = configMixin; | ||
@@ -1105,0 +1118,0 @@ exports.createStateManagementMixin = createStateManagementMixin; |
@@ -39,4 +39,4 @@ import { __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib'; | ||
const BASE_CONTENT_URL_KEY = 'base.content.url'; | ||
const BASE_CONTENT_URL = (IS_LOCAL_STORAGE && localStorage.getItem(BASE_CONTENT_URL_KEY)) || | ||
'https://static.descope.com/pages'; | ||
const BASE_CONTENT_URL = 'https://static.descope.com/pages'; | ||
const OVERRIDE_CONTENT_URL = (IS_LOCAL_STORAGE && localStorage.getItem(BASE_CONTENT_URL_KEY)) || ''; | ||
const ASSETS_FOLDER = 'v2-beta'; | ||
@@ -157,4 +157,12 @@ | ||
function getResourceUrl(projectId, filename, assetsFolder = ASSETS_FOLDER) { | ||
const url = new URL(BASE_CONTENT_URL); | ||
const baseUrlMixin = createSingletonMixin((superclass) => { | ||
return class BaseUrlMixinClass extends superclass { | ||
get baseUrl() { | ||
return this.getAttribute('base-url'); | ||
} | ||
}; | ||
}); | ||
function getResourceUrl({ projectId, filename, assetsFolder = ASSETS_FOLDER, baseUrl, }) { | ||
const url = new URL(OVERRIDE_CONTENT_URL || baseUrl || BASE_CONTENT_URL); | ||
url.pathname = pathJoin(url.pathname, projectId, assetsFolder, filename); | ||
@@ -164,6 +172,10 @@ return url.toString(); | ||
const staticResourcesMixin = createSingletonMixin((superclass) => { | ||
const BaseClass = compose(loggerMixin, projectIdMixin)(superclass); | ||
const BaseClass = compose(loggerMixin, projectIdMixin, baseUrlMixin)(superclass); | ||
return class StaticResourcesMixinClass extends BaseClass { | ||
async fetchStaticResource(filename, format) { | ||
const resourceUrl = getResourceUrl(this.projectId, filename); | ||
const resourceUrl = getResourceUrl({ | ||
projectId: this.projectId, | ||
filename, | ||
baseUrl: this.baseUrl, | ||
}); | ||
const res = await fetch(resourceUrl, { cache: 'default' }); | ||
@@ -1101,3 +1113,3 @@ if (!res.ok) { | ||
export { configMixin, createStateManagementMixin, createValidateAttributesMixin, debuggerMixin, descopeUiMixin, formMixin, getResourceUrl, initElementMixin, initLifecycleMixin, loggerMixin, modalMixin, notificationsMixin, observeAttributesMixin, projectIdMixin, staticResourcesMixin, themeMixin }; | ||
export { baseUrlMixin, configMixin, createStateManagementMixin, createValidateAttributesMixin, debuggerMixin, descopeUiMixin, formMixin, getResourceUrl, initElementMixin, initLifecycleMixin, loggerMixin, modalMixin, notificationsMixin, observeAttributesMixin, projectIdMixin, staticResourcesMixin, themeMixin }; | ||
//# sourceMappingURL=index.esm.js.map |
{ | ||
"name": "@descope/sdk-mixins", | ||
"version": "0.2.16", | ||
"version": "0.2.17", | ||
"author": "Descope Team <info@descope.com>", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/descope/sdk-mixins", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
608590
7636