Skip to content

Commit b40f7d3

Browse files
authored
fix(): update to Stencil One 🎉🎊
1 parent 7f1829e commit b40f7d3

File tree

572 files changed

+14833
-10323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

572 files changed

+14833
-10323
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ log.txt
1515
coverage/
1616
collection/
1717
dist/
18+
dist-transpiled/
1819
node_modules/
1920
tmp/
2021
temp/
@@ -49,10 +50,16 @@ demos/src/**/*.ngfactory.ts
4950
demos/src/**/*.d.ts
5051
demos/src/**/*.metadata.json
5152
demos/src/**/*.css.shim.ts
53+
prerender.html
54+
prerender-domino.html
55+
prerender-hydrated.html
56+
prerender-static.html
5257

5358
# stencil
5459
angular/css/
5560
core/css/
61+
core/hydrated/
5662
core/loader/
63+
core/www/
5764
.stencil/
5865
angular/build/

.scripts/release-dev.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const fs = require('fs-extra');
77

88
const common = require('./common');
99

10+
const DIST_NPM_TAG = 'dev';
1011
const DIST_TAG = 'dev';
1112

1213
async function main() {
@@ -37,7 +38,7 @@ async function main() {
3738
packages.forEach(package => {
3839
common.prepareDevPackage(tasks, package, devVersion);
3940
});
40-
common.publishPackages(tasks, packages, devVersion, DIST_TAG);
41+
common.publishPackages(tasks, packages, devVersion, DIST_NPM_TAG);
4142

4243
const listr = new Listr(tasks);
4344
await listr.run();

angular/scripts/rollup.config.js

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ export default {
77
format: 'es'
88
},
99
external: (id) => {
10-
// inline @ionic/core deps
11-
if (id === '@ionic/core') {
12-
return false;
13-
}
1410
// anything else is external
1511
// Windows: C:\xxxxxx\xxx
1612
const colonPosition = 1;

angular/src/app-initialize.ts

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineCustomElements } from '@ionic/core/loader';
1+
import { applyPolyfills, defineCustomElements } from '@ionic/core/loader';
22

33
import { Config } from './providers/config';
44
import { IonicWindow } from './types/interfaces';
@@ -10,26 +10,27 @@ export function appInitialize(config: Config, doc: Document) {
1010
const Ionic = win.Ionic = win.Ionic || {};
1111

1212
Ionic.config = config;
13-
Ionic.asyncQueue = false;
14-
15-
Ionic.ael = (elm, eventName, cb, opts) => {
16-
if (elm.__zone_symbol__addEventListener && skipZone(eventName)) {
17-
elm.__zone_symbol__addEventListener(eventName, cb, opts);
18-
} else {
19-
elm.addEventListener(eventName, cb, opts);
20-
}
21-
};
22-
23-
Ionic.rel = (elm, eventName, cb, opts) => {
24-
if (elm.__zone_symbol__removeEventListener && skipZone(eventName)) {
25-
elm.__zone_symbol__removeEventListener(eventName, cb, opts);
26-
} else {
27-
elm.removeEventListener(eventName, cb, opts);
28-
}
29-
};
30-
31-
return defineCustomElements(win, {
32-
exclude: ['ion-tabs', 'ion-tab']
13+
14+
return applyPolyfills().then(() => {
15+
return defineCustomElements(win, {
16+
exclude: ['ion-tabs', 'ion-tab'],
17+
syncQueue: true,
18+
raf: h => (win.__zone_symbol__requestAnimationFrame) ? win.__zone_symbol__requestAnimationFrame(h) : requestAnimationFrame(h),
19+
ael(elm, eventName, cb, opts) {
20+
if ((elm as any).__zone_symbol__addEventListener && skipZone(eventName)) {
21+
(elm as any).__zone_symbol__addEventListener(eventName, cb, opts);
22+
} else {
23+
elm.addEventListener(eventName, cb, opts);
24+
}
25+
},
26+
rel(elm, eventName, cb, opts) {
27+
if ((elm as any).__zone_symbol__removeEventListener && skipZone(eventName)) {
28+
(elm as any).__zone_symbol__removeEventListener(eventName, cb, opts);
29+
} else {
30+
elm.removeEventListener(eventName, cb, opts);
31+
}
32+
}
33+
});
3334
});
3435
}
3536
};

angular/src/directives/navigation/ion-router-outlet.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
9494
if ((this.nativeEl as any).componentOnReady) {
9595
this.nativeEl.componentOnReady().then(() => {
9696
if (this._swipeGesture === undefined) {
97-
this.swipeGesture = this.config.getBoolean('swipeBackEnabled', this.nativeEl.mode === 'ios');
97+
this.swipeGesture = this.config.getBoolean('swipeBackEnabled', (this.nativeEl as any).mode === 'ios');
9898
}
9999
});
100100
}

angular/src/directives/proxies.ts

+180-180
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { DOCUMENT } from '@angular/common';
2-
import { Inject, Injectable } from '@angular/core';
3-
import { ActionSheetOptions } from '@ionic/core';
1+
import { Injectable } from '@angular/core';
2+
import { ActionSheetOptions, actionSheetController } from '@ionic/core';
43

54
import { OverlayBaseController } from '../util/overlay';
65

76
@Injectable({
87
providedIn: 'root',
98
})
109
export class ActionSheetController extends OverlayBaseController<ActionSheetOptions, HTMLIonActionSheetElement> {
11-
constructor(@Inject(DOCUMENT) doc: any) {
12-
super('ion-action-sheet-controller', doc);
10+
constructor() {
11+
super(actionSheetController);
1312
}
1413
}
+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { DOCUMENT } from '@angular/common';
2-
import { Inject, Injectable } from '@angular/core';
3-
import { AlertOptions } from '@ionic/core';
1+
import { Injectable } from '@angular/core';
2+
import { AlertOptions, alertController } from '@ionic/core';
43

54
import { OverlayBaseController } from '../util/overlay';
65

76
@Injectable({
87
providedIn: 'root',
98
})
109
export class AlertController extends OverlayBaseController<AlertOptions, HTMLIonAlertElement> {
11-
constructor(@Inject(DOCUMENT) doc: any) {
12-
super('ion-alert-controller', doc);
10+
constructor() {
11+
super(alertController);
1312
}
1413
}
+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { DOCUMENT } from '@angular/common';
2-
import { Inject, Injectable } from '@angular/core';
3-
import { LoadingOptions } from '@ionic/core';
1+
import { Injectable } from '@angular/core';
2+
import { LoadingOptions, loadingController } from '@ionic/core';
43

54
import { OverlayBaseController } from '../util/overlay';
65

76
@Injectable({
87
providedIn: 'root',
98
})
109
export class LoadingController extends OverlayBaseController<LoadingOptions, HTMLIonLoadingElement> {
11-
constructor(@Inject(DOCUMENT) doc: any) {
12-
super('ion-loading-controller', doc);
10+
constructor() {
11+
super(loadingController);
1312
}
1413
}

angular/src/providers/modal-controller.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { DOCUMENT } from '@angular/common';
2-
import { ComponentFactoryResolver, Inject, Injectable, Injector } from '@angular/core';
3-
import { ModalOptions } from '@ionic/core';
1+
import { ComponentFactoryResolver, Injectable, Injector } from '@angular/core';
2+
import { ModalOptions, modalController } from '@ionic/core';
43

54
import { OverlayBaseController } from '../util/overlay';
65

@@ -13,9 +12,8 @@ export class ModalController extends OverlayBaseController<ModalOptions, HTMLIon
1312
private angularDelegate: AngularDelegate,
1413
private resolver: ComponentFactoryResolver,
1514
private injector: Injector,
16-
@Inject(DOCUMENT) doc: any
1715
) {
18-
super('ion-modal-controller', doc);
16+
super(modalController);
1917
}
2018

2119
create(opts: ModalOptions): Promise<HTMLIonModalElement> {
+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { DOCUMENT } from '@angular/common';
2-
import { Inject, Injectable } from '@angular/core';
3-
import { PickerOptions } from '@ionic/core';
1+
import { Injectable } from '@angular/core';
2+
import { PickerOptions, pickerController } from '@ionic/core';
43

54
import { OverlayBaseController } from '../util/overlay';
65

76
@Injectable({
87
providedIn: 'root',
98
})
109
export class PickerController extends OverlayBaseController<PickerOptions, HTMLIonPickerElement> {
11-
constructor(@Inject(DOCUMENT) doc: any) {
12-
super('ion-picker-controller', doc);
10+
constructor() {
11+
super(pickerController);
1312
}
1413
}

angular/src/providers/popover-controller.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { DOCUMENT } from '@angular/common';
2-
import { ComponentFactoryResolver, Inject, Injectable, Injector } from '@angular/core';
3-
import { PopoverOptions } from '@ionic/core';
1+
import { ComponentFactoryResolver, Injectable, Injector } from '@angular/core';
2+
import { PopoverOptions, popoverController } from '@ionic/core';
43

54
import { OverlayBaseController } from '../util/overlay';
65

@@ -13,9 +12,8 @@ export class PopoverController extends OverlayBaseController<PopoverOptions, HTM
1312
private angularDelegate: AngularDelegate,
1413
private resolver: ComponentFactoryResolver,
1514
private injector: Injector,
16-
@Inject(DOCUMENT) doc: any
1715
) {
18-
super('ion-popover-controller', doc);
16+
super(popoverController);
1917
}
2018

2119
create(opts: PopoverOptions): Promise<HTMLIonPopoverElement> {
+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { DOCUMENT } from '@angular/common';
2-
import { Inject, Injectable } from '@angular/core';
3-
import { ToastOptions } from '@ionic/core';
1+
import { Injectable } from '@angular/core';
2+
import { ToastOptions, toastController } from '@ionic/core';
43

54
import { OverlayBaseController } from '../util/overlay';
65

76
@Injectable({
87
providedIn: 'root',
98
})
109
export class ToastController extends OverlayBaseController<ToastOptions, HTMLIonToastElement> {
11-
constructor(@Inject(DOCUMENT) doc: any) {
12-
super('ion-toast-controller', doc);
10+
constructor() {
11+
super(toastController);
1312
}
1413
}

angular/src/types/interfaces.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11

22
export interface IonicGlobal {
33
config?: any;
4-
ael?: (elm: any, eventName: string, cb: (ev: Event) => void, opts: any) => void;
5-
raf?: (ts: number) => void;
6-
rel?: (elm: any, eventName: string, cb: (ev: Event) => void, opts: any) => void;
74
asyncQueue?: boolean;
85
}
96

107
export interface IonicWindow extends Window {
118
Ionic: IonicGlobal;
12-
__zone_symbol__requestAnimationFrame: (ts: number) => void;
9+
__zone_symbol__requestAnimationFrame?: (ts: FrameRequestCallback) => number;
10+
}
11+
12+
export interface HTMLStencilElement extends HTMLElement {
13+
componentOnReady(): Promise<this>;
14+
forceUpdate(): void;
1315
}

angular/src/util/overlay.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
import { proxyMethod } from './util';
21

3-
export class OverlayBaseController<Opts, Overlay> {
4-
constructor(private ctrl: string, private doc: Document) {}
2+
interface ControllerShape<Opts, HTMLElm> {
3+
create(options: Opts): Promise<HTMLElm>;
4+
dismiss(data?: any, role?: string, id?: string): Promise<boolean>;
5+
getTop(): Promise<HTMLElm | undefined>;
6+
}
7+
8+
export class OverlayBaseController<Opts, Overlay> implements ControllerShape<Opts, Overlay> {
9+
constructor(private ctrl: ControllerShape<Opts, Overlay>) {}
510

611
/**
712
* Creates a new overlay
813
*/
9-
create(opts?: Opts): Promise<Overlay> {
10-
return proxyMethod(this.ctrl, this.doc, 'create', opts);
14+
create(opts: Opts) {
15+
return this.ctrl.create(opts);
1116
}
1217

1318
/**
1419
* When `id` is not provided, it dismisses the top overlay.
1520
*/
16-
dismiss(data?: any, role?: string, id?: string): Promise<void> {
17-
return proxyMethod(this.ctrl, this.doc, 'dismiss', data, role, id);
21+
dismiss(data?: any, role?: string, id?: string) {
22+
return this.ctrl.dismiss(data, role, id);
1823
}
1924

2025
/**
2126
* Returns the top overlay.
2227
*/
23-
getTop(): Promise<Overlay | undefined> {
24-
return proxyMethod(this.ctrl, this.doc, 'getTop');
28+
getTop() {
29+
return this.ctrl.getTop();
2530
}
2631
}

angular/src/util/util.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { HTMLStencilElement } from '../types/interfaces';
12

23
export function proxyMethod(ctrlName: string, doc: Document, methodName: string, ...args: any[]) {
34
const controller = ensureElementInBody(ctrlName, doc);

angular/test/test-app/e2e/src/router-link.e2e-spec.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
11
import { browser, element, by, protractor } from 'protractor';
22
import { waitTime, testStack, testLifeCycle, handleErrorMessages } from './utils';
3-
import { HttpUrlEncodingCodec } from '@angular/common/http';
43

54
const EC = protractor.ExpectedConditions;
65

76
describe('router-link params and fragments', () => {
87
const queryParam = 'A&=#Y';
98
const fragment = 'myDiv1';
109
const id = 'MyPageID==';
11-
10+
1211
afterEach(() => {
1312
handleErrorMessages();
1413
});
15-
14+
1615
it('should go to a page with properly encoded values', async () => {
1716
await browser.get('/router-link?ionic:_testing=true');
1817
await element(by.css('#queryParamsFragment')).click();
19-
18+
2019
const expectedRoute = `${encodeURIComponent(id)}?token=${encodeURIComponent(queryParam)}#${encodeURIComponent(fragment)}`;
2120

2221
browser.wait(EC.urlContains(expectedRoute), 5000);
2322
});
24-
23+
2524
it('should return to a page with preserved query param and fragment', async () => {
2625
await browser.get('/router-link?ionic:_testing=true');
2726
await element(by.css('#queryParamsFragment')).click();
28-
await element(by.css('#goToPage3')).click();
29-
27+
await waitTime(200);
28+
await element(by.css('#goToPage3')).click();
29+
3030
browser.wait(EC.urlContains('router-link-page3'), 5000);
31-
32-
await element(by.css('#goBackFromPage3')).click();
33-
31+
await waitTime(200);
32+
33+
await element(by.css('#goBackFromPage3')).click();
34+
3435
const expectedRoute = `${encodeURIComponent(id)}?token=${encodeURIComponent(queryParam)}#${encodeURIComponent(fragment)}`;
3536
browser.wait(EC.urlContains(expectedRoute), 5000);
3637
});
37-
38+
3839
it('should preserve query param and fragment with defaultHref string', async () => {
3940
await browser.get('/router-link-page3?ionic:_testing=true');
40-
41+
4142
await element(by.css('#goBackFromPage3')).click();
4243

4344
const expectedRoute = '?token=ABC#fragment';

angular/test/test-app/e2e/src/tabs.e2e-spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ describe('tabs', () => {
140140
const tab = await getSelectedTab();
141141
await tab.$('#goto-nested-page1').click();
142142

143+
await waitTime(600);
143144
await testStack('app-nested-outlet ion-router-outlet', ['app-nested-outlet-page']);
144145

145146
const nestedOutlet = await element(by.css('app-nested-outlet'));

0 commit comments

Comments
 (0)