-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
94 changed files
with
1,300 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
<script type="module"> | ||
import '@vonage/vvd-scheme'; | ||
import '@vonage/vwc-scheme-select'; | ||
</script> | ||
|
||
<style> | ||
.change-scheme-component{ | ||
.change-scheme-component { | ||
position: absolute; | ||
right: 0; | ||
right: 0; | ||
top: 0; | ||
} | ||
</style> | ||
<vwc-scheme-select class="change-scheme-component"></vwc-scheme-select> | ||
<vwc-scheme-select class="change-scheme-component"></vwc-scheme-select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,14 @@ | ||
import { coreReady } from '@vonage/vvd-core'; | ||
import '@vonage/vvd-core'; | ||
import { style } from './vvd-context.css'; | ||
|
||
let initResolver: (value?: unknown) => void | PromiseLike<void>, | ||
initRejector: (reason?: unknown) => void | PromiseLike<void>; | ||
|
||
export const contextReady = new Promise((resolve, reject) => { | ||
initResolver = resolve; | ||
initRejector = reject; | ||
}); | ||
|
||
init(); | ||
|
||
async function init(): Promise<void> { | ||
try { | ||
injectGlobalStyle(); | ||
await coreReady; | ||
initResolver(); | ||
} catch (e) { | ||
initRejector(e); | ||
} | ||
function init(): void { | ||
injectGlobalStyle(); | ||
} | ||
|
||
function injectGlobalStyle() { | ||
const globalStyleSheet = document.createElement('style'); | ||
globalStyleSheet.type = 'text/css'; | ||
globalStyleSheet.innerHTML = style.cssText; | ||
document.head.appendChild(globalStyleSheet); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* This module exposes internal APIs to manage a Vivid overlay configuration state | ||
* state machine revolves over: | ||
* - uninitialised state for all | ||
* - first init merge where undefined resolved to defaults | ||
* - following merges applied over an existing state (undefined is not to touch) | ||
* | ||
* Static way to pre-configure Vivid is via `data-vvd-context` attribute on the HTML element. | ||
* As of now, only a single keyword token value is supported: | ||
* - none: suspend auto-init, to be used in custom initialization flavor | ||
*/ | ||
import { SchemeOption } from '@vonage/vvd-scheme'; | ||
|
||
const VVD_CONTEXT_ATTRIBUTE = 'data-vvd-context', | ||
MANUAL_KEY = 'none', | ||
VALID_CONFIGURATION_KEYS = [MANUAL_KEY, 'fonts', 'scheme']; | ||
|
||
export interface Configuration { | ||
autoInit: boolean; | ||
scheme?: SchemeOption; | ||
} | ||
export default Object.freeze({ | ||
initialConfiguration: buildInitialConfiguration(), | ||
validateConfiguration, | ||
}); | ||
|
||
function buildInitialConfiguration(): Configuration { | ||
const result: Configuration = { | ||
autoInit: true, | ||
}; | ||
const vvdContextAttrValue = document.documentElement.getAttribute( | ||
VVD_CONTEXT_ATTRIBUTE | ||
); | ||
if (vvdContextAttrValue === MANUAL_KEY) { | ||
result.autoInit = false; | ||
} | ||
return result; | ||
} | ||
|
||
function validateConfiguration(configuration: Partial<Configuration>) { | ||
const extraParams = Object.keys(configuration).filter( | ||
(k) => !VALID_CONFIGURATION_KEYS.includes(k) | ||
); | ||
|
||
if (extraParams.length) { | ||
throw new Error( | ||
`unexpected configuration part/s '${extraParams}', only some of '${VALID_CONFIGURATION_KEYS}' expected` | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
import configuration, { Configuration } from './config-resolver.js'; | ||
import configurer, { Configuration } from './vvd-configurer.js'; | ||
import fonts from '@vonage/vvd-fonts/vvd-fonts.js'; | ||
import schemeService from '@vonage/vvd-scheme'; | ||
|
||
let initResolver: (value?: unknown) => void | PromiseLike<void>, | ||
initRejector: (reason?: unknown) => void | PromiseLike<void>; | ||
let coreAutoInitDone: Promise<Array<unknown>>; | ||
if (configurer.initialConfiguration.autoInit) { | ||
coreAutoInitDone = applyConfiguration(configurer.initialConfiguration); | ||
} else { | ||
coreAutoInitDone = Promise.reject('auto-init unavailable when "none" used'); | ||
} | ||
|
||
export const coreReady = new Promise((resolve, reject) => { | ||
initResolver = resolve; | ||
initRejector = reject; | ||
export default Object.freeze({ | ||
set: applyConfiguration, | ||
coreReady: coreAutoInitDone, | ||
}); | ||
|
||
console.debug('effective config', JSON.stringify(configuration)); | ||
init(configuration); | ||
async function applyConfiguration(configuration: Partial<Configuration>) { | ||
configurer.validateConfiguration(configuration); | ||
return init(configuration); | ||
} | ||
|
||
async function init({ scheme }: Configuration): Promise<void> { | ||
Promise.all([fonts.init(), schemeService.set(scheme)]) | ||
.then(initResolver) | ||
.catch(initRejector); | ||
async function init( | ||
configuration: Partial<Configuration> | ||
): Promise<Array<unknown>> { | ||
return Promise.all([fonts.init(), schemeService.set(configuration.scheme)]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import vvdCore from '../vvd-core.js'; | ||
|
||
describe('vvd-core service', () => { | ||
it('verify basic core API', async () => { | ||
assert.isDefined(vvdCore, 'core service is defined'); | ||
assert.isObject(vvdCore, 'core service is a defaultly exported object'); | ||
assert.isFunction(vvdCore.set, 'core service has "set" API method'); | ||
assert.isDefined( | ||
vvdCore.coreReady, | ||
'core service has "coreReady" object (Promise)' | ||
); | ||
assert.isFunction( | ||
vvdCore.coreReady.then, | ||
'core service has "coreReady" object - ensure it is Promise' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ | |
"fs-extra": "^9.0.1", | ||
"lit-element": "^2.4.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.