fix(): update to Stencil One 🎉🎊

This commit is contained in:
Manu MA
2019-06-19 21:33:50 +02:00
committed by GitHub
parent 7f1829eb21
commit b40f7d36d5
572 changed files with 14426 additions and 9916 deletions

View File

@ -1,49 +1,60 @@
import 'ionicons';
import { getMode, setMode } from '@stencil/core';
import { Mode } from '../interface';
import { isPlatform, setupPlatforms } from '../utils/platform';
import { Config, configFromSession, configFromURL, saveConfig } from './config';
declare const Context: any;
const win = typeof (window as any) !== 'undefined' ? window : {} as Window;
const config = /*@__PURE__*/new Config();
const Ionic = (win as any)['Ionic'] = (win as any)['Ionic'] || {};
let mode: Mode;
// queue used to coordinate DOM reads and
// write in order to avoid layout thrashing
Object.defineProperty(Ionic, 'queue', {
get: () => Context['queue']
});
// Setup platforms
setupPlatforms(win);
Context.isPlatform = isPlatform;
// create the Ionic.config from raw config object (if it exists)
// and convert Ionic.config into a ConfigApi that has a get() fn
const configObj = {
...configFromSession(win),
persistConfig: false,
...Ionic['config'],
...configFromURL(win)
};
const config = Ionic['config'] = Context['config'] = new Config(configObj);
if (config.getBoolean('persistConfig')) {
saveConfig(win, configObj);
export function getIonMode(ref?: any): Mode {
return (ref && getMode(ref)) || mode;
}
// first see if the mode was set as an attribute on <html>
// which could have been set by the user, or by prerendering
// otherwise get the mode via config settings, and fallback to md
const documentElement = (win as any).document ? win.document.documentElement : null;
const mode = config.get('mode', (documentElement && documentElement.getAttribute('mode')) || (isPlatform(win, 'ios') ? 'ios' : 'md'));
Ionic.mode = Context.mode = mode;
config.set('mode', mode);
if (documentElement) {
documentElement.setAttribute('mode', mode);
documentElement.classList.add(mode);
}
if (config.getBoolean('_testing')) {
config.set('animated', false);
export default function() {
const doc = document;
const win = window;
Context.config = config;
const Ionic = (win as any).Ionic = (win as any).Ionic || {};
// Setup platforms
setupPlatforms(win);
// create the Ionic.config from raw config object (if it exists)
// and convert Ionic.config into a ConfigApi that has a get() fn
const configObj = {
...configFromSession(win),
persistConfig: false,
...Ionic.config,
...configFromURL(win)
};
config.reset(configObj);
if (config.getBoolean('persistConfig')) {
saveConfig(win, configObj);
}
// first see if the mode was set as an attribute on <html>
// which could have been set by the user, or by prerendering
// otherwise get the mode via config settings, and fallback to md
Ionic.config = config;
Ionic.mode = mode = config.get('mode', (doc.documentElement.getAttribute('mode')) || (isPlatform(win, 'ios') ? 'ios' : 'md'));
config.set('mode', mode);
doc.documentElement.setAttribute('mode', mode);
doc.documentElement.classList.add(mode);
if (config.getBoolean('_testing')) {
config.set('animated', false);
}
setMode(
(elm: any) => (elm as any).mode = (elm as any).mode || elm.getAttribute('mode') || mode
);
}
export { config };