Skip to content

Commit bb19243

Browse files
committed
fix(esm): reorganiza exports
1 parent 240531c commit bb19243

File tree

6 files changed

+97
-101
lines changed

6 files changed

+97
-101
lines changed

core/src/global/config.ts

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,4 @@
1-
import { Mode } from '../interface';
2-
3-
export interface IonicConfig {
4-
/**
5-
* The mode determines which platform styles to use.
6-
* Possible values are: `"ios"` or `"md"`.
7-
*/
8-
mode?: Mode;
9-
persistConfig?: boolean;
10-
11-
inputShims?: boolean;
12-
backButtonIcon?: string;
13-
backButtonText?: string;
14-
spinner?: string;
15-
loadingSpinner?: string;
16-
menuIcon?: string;
17-
animated?: boolean;
18-
pickerSpinner?: string;
19-
refreshingIcon?: string;
20-
refreshingSpinner?: string;
21-
menuType?: string;
22-
scrollPadding?: string;
23-
inputBlurring?: string;
24-
scrollAssist?: boolean;
25-
hideCaretOnScroll?: string;
26-
infiniteLoadingSpinner?: string;
27-
keyboardHeight?: number;
28-
swipeBackEnabled?: boolean;
29-
30-
tabbarPlacement?: string;
31-
tabbarLayout?: string;
32-
tabbarHighlight?: boolean;
33-
34-
actionSheetEnter?: string;
35-
alertEnter?: string;
36-
loadingEnter?: string;
37-
modalEnter?: string;
38-
popoverEnter?: string;
39-
toastEnter?: string;
40-
pickerEnter?: string;
41-
42-
actionSheetLeave?: string;
43-
alertLeave?: string;
44-
loadingLeave?: string;
45-
modalLeave?: string;
46-
popoverLeave?: string;
47-
toastLeave?: string;
48-
pickerLeave?: string;
49-
}
1+
import { IonicConfig } from '../interface';
502

513
export class Config {
524

@@ -81,3 +33,43 @@ export class Config {
8133
this.m.set(key, value);
8234
}
8335
}
36+
37+
const IONIC_PREFIX = 'ionic:';
38+
const IONIC_SESSION_KEY = 'ionic-persist-config';
39+
40+
export function configFromSession(): any {
41+
try {
42+
const configStr = window.sessionStorage.getItem(IONIC_SESSION_KEY);
43+
return configStr !== null ? JSON.parse(configStr) : {};
44+
} catch {
45+
return {};
46+
}
47+
}
48+
49+
export function saveConfig(config: any) {
50+
try {
51+
window.sessionStorage.setItem(IONIC_SESSION_KEY, JSON.stringify(config));
52+
} catch {
53+
return;
54+
}
55+
}
56+
57+
export function configFromURL() {
58+
const config: any = {};
59+
const win = window;
60+
win.location.search.slice(1)
61+
.split('&')
62+
.map(entry => entry.split('='))
63+
.map(([key, value]) => [decodeURIComponent(key), decodeURIComponent(value)])
64+
.filter(([key]) => startsWith(key, IONIC_PREFIX))
65+
.map(([key, value]) => [key.slice(IONIC_PREFIX.length), value])
66+
.forEach(([key, value]) => {
67+
config[key] = value;
68+
});
69+
70+
return config;
71+
}
72+
73+
function startsWith(input: string, search: string): boolean {
74+
return input.substr(0, search.length) === search;
75+
}

core/src/global/ionic-global.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import 'ionicons';
22

3-
import { configFromSession, configFromURL, saveConfig } from '../utils/config';
43
import { isPlatform, setupPlatforms } from '../utils/platform';
54

6-
import { Config } from './config';
5+
import { Config, configFromSession, configFromURL, saveConfig } from './config';
76

87
const win = window;
98
const Ionic = (win as any)['Ionic'] = (win as any)['Ionic'] || {};

core/src/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,5 @@ export const enum ViewLifecycle {
99
}
1010

1111
// util functions
12-
export * from './utils/helpers';
13-
export * from './utils/haptic';
14-
export * from './utils/framework-delegate';
1512
export * from './utils/platform';
1613
export * from './utils/config';

core/src/interface.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export type BackButtonEvent = CustomEvent<{
4444
register(priority: number, handler: () => Promise<any> | void): void;
4545
}>
4646

47+
export interface FrameworkDelegate {
48+
attachViewToDom(container: any, component: any, propsOrDataObj?: any, cssClasses?: string[]): Promise<HTMLElement>;
49+
removeViewFromDom(container: any, component: any): Promise<void>;
50+
}
51+
4752
declare global {
4853
interface StencilGlobalHTMLAttributes {
4954
// for ion-menu and ion-split-pane

core/src/utils/config.ts

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
1-
import { IonicConfig } from '../interface';
1+
import { Mode } from '../interface';
2+
3+
export interface IonicConfig {
4+
/**
5+
* The mode determines which platform styles to use.
6+
* Possible values are: `"ios"` or `"md"`.
7+
*/
8+
mode?: Mode;
9+
persistConfig?: boolean;
10+
11+
inputShims?: boolean;
12+
backButtonIcon?: string;
13+
backButtonText?: string;
14+
spinner?: string;
15+
loadingSpinner?: string;
16+
menuIcon?: string;
17+
animated?: boolean;
18+
pickerSpinner?: string;
19+
refreshingIcon?: string;
20+
refreshingSpinner?: string;
21+
menuType?: string;
22+
scrollPadding?: string;
23+
inputBlurring?: string;
24+
scrollAssist?: boolean;
25+
hideCaretOnScroll?: string;
26+
infiniteLoadingSpinner?: string;
27+
keyboardHeight?: number;
28+
swipeBackEnabled?: boolean;
29+
30+
tabbarPlacement?: string;
31+
tabbarLayout?: string;
32+
tabbarHighlight?: boolean;
33+
34+
actionSheetEnter?: string;
35+
alertEnter?: string;
36+
loadingEnter?: string;
37+
modalEnter?: string;
38+
popoverEnter?: string;
39+
toastEnter?: string;
40+
pickerEnter?: string;
41+
42+
actionSheetLeave?: string;
43+
alertLeave?: string;
44+
loadingLeave?: string;
45+
modalLeave?: string;
46+
popoverLeave?: string;
47+
toastLeave?: string;
48+
pickerLeave?: string;
49+
}
250

351
export function setupConfig(config: IonicConfig) {
452
const win = window as any;
@@ -14,43 +62,3 @@ export function setupConfig(config: IonicConfig) {
1462
};
1563
return win.Ionic.config;
1664
}
17-
18-
const IONIC_PREFIX = 'ionic:';
19-
const IONIC_SESSION_KEY = 'ionic-persist-config';
20-
21-
export function configFromSession(): any {
22-
try {
23-
const configStr = window.sessionStorage.getItem(IONIC_SESSION_KEY);
24-
return configStr !== null ? JSON.parse(configStr) : {};
25-
} catch {
26-
return {};
27-
}
28-
}
29-
30-
export function saveConfig(config: any) {
31-
try {
32-
window.sessionStorage.setItem(IONIC_SESSION_KEY, JSON.stringify(config));
33-
} catch {
34-
return;
35-
}
36-
}
37-
38-
export function configFromURL() {
39-
const config: any = {};
40-
const win = window;
41-
win.location.search.slice(1)
42-
.split('&')
43-
.map(entry => entry.split('='))
44-
.map(([key, value]) => [decodeURIComponent(key), decodeURIComponent(value)])
45-
.filter(([key]) => startsWith(key, IONIC_PREFIX))
46-
.map(([key, value]) => [key.slice(IONIC_PREFIX.length), value])
47-
.forEach(([key, value]) => {
48-
config[key] = value;
49-
});
50-
51-
return config;
52-
}
53-
54-
function startsWith(input: string, search: string): boolean {
55-
return input.substr(0, search.length) === search;
56-
}

core/src/utils/framework-delegate.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import { ComponentRef } from '../interface';
2-
3-
export interface FrameworkDelegate {
4-
attachViewToDom(container: any, component: any, propsOrDataObj?: any, cssClasses?: string[]): Promise<HTMLElement>;
5-
removeViewFromDom(container: any, component: any): Promise<void>;
6-
}
1+
import { ComponentRef, FrameworkDelegate } from '../interface';
72

83
export async function attachComponent(
94
delegate: FrameworkDelegate | undefined,

0 commit comments

Comments
 (0)