From 8100cf7089bdd423d402e98dcb0578eec84e5ff1 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Thu, 9 Jul 2020 23:43:28 -0700 Subject: [PATCH] chore: cleanup --- apps/app/perf-app/recycling/tests.ts | 1 - .../app/generated-tests/tests.ts | 8 -- .../app/action-bar/font-icons-page.ts | 7 +- e2e/ui-tests-app/app/action-bar/icons-page.ts | 7 +- .../app/action-bar/local-icons-page.ts | 7 +- e2e/ui-tests-app/app/action-bar/main-page.ts | 4 +- .../modal-page-hidden-action-bar-page.ts | 2 +- e2e/ui-tests-app/app/action-bar/modal-page.ts | 5 +- .../modal-test-hidden-action-bar-page.ts | 6 +- .../modal-test-with-action-bar-page.ts | 6 +- .../app/action-bar/system-icons-page.ts | 4 +- .../app/action-bar/transparent-bg-css-page.ts | 4 +- .../app/animation/animation-army-100-page.ts | 18 +-- .../app/animation/animation-curves-page.ts | 12 +- .../effect-summary-details-page.android.ts | 14 +-- .../effect-summary-details-page.ios.ts | 13 +- .../app/animation/height-basic-page.ts | 2 +- .../app/animation/layout-stack-height-page.ts | 4 +- e2e/ui-tests-app/app/animation/main-page.ts | 4 +- .../app/button/background-page.ts | 7 +- .../app/button/border-playground-page.ts | 7 +- .../app/button/issue-4385-page.ts | 6 +- e2e/ui-tests-app/app/button/main-page.ts | 4 +- .../app/button/tappable-span-page.ts | 4 +- .../app/issues/open-file-6895-page.ts | 10 +- e2e/ui-tests-app/package.json | 5 +- nativescript-core/bundle-entry-points.ts | 1 - nativescript-core/connectivity/index.ios.ts | 11 +- nativescript-core/data/observable/index.d.ts | 9 +- .../file-system/file-name-resolver/index.ts | 96 -------------- nativescript-core/globals/index.ts | 1 - nativescript-core/index.d.ts | 118 ++++-------------- nativescript-core/index.ts | 41 +++--- .../module-name-resolver/index.d.ts | 4 + .../module-name-resolver/index.ts | 3 +- .../qualifier-matcher/index.d.ts | 3 + .../qualifier-matcher/index.ts | 3 + nativescript-core/package.json | 4 +- nativescript-core/trace/index.d.ts | 38 +++--- nativescript-core/trace/index.ts | 2 +- .../ui/animation/index.android.ts | 1 + nativescript-core/ui/animation/index.d.ts | 2 + nativescript-core/ui/animation/index.ios.ts | 1 + .../ui/animation/keyframe-animation.ts | 15 +-- nativescript-core/ui/border/index.ts | 46 ------- .../ui/builder/module-name-sanitizer.d.ts | 5 + .../ui/builder/module-name-sanitizer.ts | 5 + .../ui/core/view-base/index.d.ts | 4 - nativescript-core/ui/enums/index.d.ts | 35 ++++++ nativescript-core/ui/enums/index.ts | 32 +++++ nativescript-core/ui/frame/frame-common.ts | 3 +- nativescript-core/ui/frame/index.d.ts | 4 +- nativescript-core/ui/index.d.ts | 14 ++- nativescript-core/ui/index.ts | 12 +- nativescript-core/ui/page/index.d.ts | 8 +- nativescript-core/ui/page/page-common.d.ts | 52 ++++++++ nativescript-core/ui/page/page-common.ts | 9 +- .../ui/styling/css-selector/index.ts | 18 +++ .../ui/text-base/index.android.ts | 4 +- nativescript-core/ui/text-base/index.ios.ts | 6 +- nativescript-core/ui/text-base/span.ts | 9 +- .../ui/web-view/web-view-common.ts | 9 +- nativescript-core/utils/index.android.ts | 1 + nativescript-core/utils/index.d.ts | 1 + nativescript-core/utils/index.ios.ts | 1 + nativescript-core/utils/types.ts | 4 +- package.json | 2 +- tests/app/App_Resources/iOS/Info.plist | 9 ++ tests/app/data/observable-tests.ts | 4 +- .../file-system-access-tests.ts | 35 +++--- .../file-name-resolver-tests.ts | 42 ------- .../module-name-resolver-tests.ts | 2 +- tests/app/pages/file-load-test.ts | 16 ++- tests/app/test-runner.ts | 27 +--- tests/app/trace/trace-tests.ts | 4 +- tests/app/ui-helper.ts | 2 +- tests/app/ui/border/border-tests.ts | 8 -- tests/app/ui/border/border.md | 19 --- .../builder/builder-file-qualifiers-tests.ts | 5 +- tests/app/ui/builder/builder-tests.ts | 3 +- tests/app/ui/gestures/gestures-tests.ts | 77 ++++++------ tests/app/ui/root-view/root-view-tests.ts | 26 ++-- tests/app/ui/tabs/tabs-root-tests.ts | 11 +- tests/app/ui/view/view-tests-common.ts | 40 +++--- tests/app/xml-declaration/mainPage.xml | 3 - .../template-builder-tests/template-view.ts | 4 +- .../xml-declaration/xml-declaration-tests.ts | 47 +++---- tests/package.json | 4 +- tests/reference.d.ts | 1 - 89 files changed, 493 insertions(+), 704 deletions(-) delete mode 100644 nativescript-core/file-system/file-name-resolver/index.ts delete mode 100644 nativescript-core/ui/border/index.ts create mode 100644 nativescript-core/ui/page/page-common.d.ts delete mode 100644 tests/app/name-resolvers-tests/file-name-resolver-tests.ts delete mode 100644 tests/app/ui/border/border-tests.ts delete mode 100644 tests/app/ui/border/border.md diff --git a/apps/app/perf-app/recycling/tests.ts b/apps/app/perf-app/recycling/tests.ts index 178859f66..4c7254677 100644 --- a/apps/app/perf-app/recycling/tests.ts +++ b/apps/app/perf-app/recycling/tests.ts @@ -1,7 +1,6 @@ import { time } from "tns-core-modules/profiling"; import { ActionBar } from "tns-core-modules/ui/action-bar"; import { ActivityIndicator } from "tns-core-modules/ui/activity-indicator"; -import { Border } from "tns-core-modules/ui/border"; import { Button } from "tns-core-modules/ui/button"; import { ContentView } from "tns-core-modules/ui/content-view"; import { DatePicker } from "tns-core-modules/ui/date-picker"; diff --git a/e2e/scoped-packages/app/generated-tests/tests.ts b/e2e/scoped-packages/app/generated-tests/tests.ts index 9f6815826..9f51276eb 100644 --- a/e2e/scoped-packages/app/generated-tests/tests.ts +++ b/e2e/scoped-packages/app/generated-tests/tests.ts @@ -430,14 +430,6 @@ import * as module_ui_animation_keyframe_animation_core from "@nativescript/core import * as module_ui_animation_keyframe_animation_compat from "tns-core-modules/ui/animation/keyframe-animation"; compare("ui/animation/keyframe-animation", module_ui_animation_keyframe_animation_core, module_ui_animation_keyframe_animation_compat); -import * as module_ui_border_core from "@nativescript/core/ui/border"; -import * as module_ui_border_compat from "tns-core-modules/ui/border"; -compare("ui/border", module_ui_border_core, module_ui_border_compat); - -import * as module_ui_border_border_core from "@nativescript/core/ui/border/border"; -import * as module_ui_border_border_compat from "tns-core-modules/ui/border/border"; -compare("ui/border/border", module_ui_border_border_core, module_ui_border_border_compat); - import * as module_ui_bottom_navigation_core from "@nativescript/core/ui/bottom-navigation"; import * as module_ui_bottom_navigation_compat from "tns-core-modules/ui/bottom-navigation"; compare("ui/bottom-navigation", module_ui_bottom_navigation_core, module_ui_bottom_navigation_compat); diff --git a/e2e/ui-tests-app/app/action-bar/font-icons-page.ts b/e2e/ui-tests-app/app/action-bar/font-icons-page.ts index 92b243d5a..39beea328 100644 --- a/e2e/ui-tests-app/app/action-bar/font-icons-page.ts +++ b/e2e/ui-tests-app/app/action-bar/font-icons-page.ts @@ -1,12 +1,9 @@ -import * as frame from "tns-core-modules/ui/frame"; -import { EventData } from "tns-core-modules/ui/frame"; -import { Button } from "tns-core-modules/ui/button"; -import { ActionBar } from "tns-core-modules/ui/action-bar"; +import { Frame, EventData, Button, ActionBar } from "@nativescript/core"; const iconModes = ["automatic", "alwaysOriginal", "alwaysTemplate", undefined]; export function navigate(args) { - frame.topmost().navigate("ui-tests-app/action-bar/clean"); + Frame.topmost().navigate("ui-tests-app/action-bar/clean"); } export function onChangeRenderingMode(args: EventData) { diff --git a/e2e/ui-tests-app/app/action-bar/icons-page.ts b/e2e/ui-tests-app/app/action-bar/icons-page.ts index 2d20576ac..b35e432b5 100644 --- a/e2e/ui-tests-app/app/action-bar/icons-page.ts +++ b/e2e/ui-tests-app/app/action-bar/icons-page.ts @@ -1,12 +1,9 @@ -import * as frame from "tns-core-modules/ui/frame"; -import { EventData } from "tns-core-modules/ui/frame"; -import { Button } from "tns-core-modules/ui/button"; -import { ActionBar } from "tns-core-modules/ui/action-bar"; +import { EventData, Frame, Button, ActionBar } from "@nativescript/core"; const iconModes = ["automatic", "alwaysOriginal", "alwaysTemplate", undefined]; export function navigate() { - frame.topmost().navigate("action-bar/clean-page"); + Frame.topmost().navigate("action-bar/clean-page"); } export function onChangeRenderingMode(args: EventData) { diff --git a/e2e/ui-tests-app/app/action-bar/local-icons-page.ts b/e2e/ui-tests-app/app/action-bar/local-icons-page.ts index 2d20576ac..09c7f126e 100644 --- a/e2e/ui-tests-app/app/action-bar/local-icons-page.ts +++ b/e2e/ui-tests-app/app/action-bar/local-icons-page.ts @@ -1,12 +1,9 @@ -import * as frame from "tns-core-modules/ui/frame"; -import { EventData } from "tns-core-modules/ui/frame"; -import { Button } from "tns-core-modules/ui/button"; -import { ActionBar } from "tns-core-modules/ui/action-bar"; +import { EventData, Frame, Button, ActionBar } from "@nativescript/core"; const iconModes = ["automatic", "alwaysOriginal", "alwaysTemplate", undefined]; export function navigate() { - frame.topmost().navigate("action-bar/clean-page"); + Frame.topmost().navigate("action-bar/clean-page"); } export function onChangeRenderingMode(args: EventData) { diff --git a/e2e/ui-tests-app/app/action-bar/main-page.ts b/e2e/ui-tests-app/app/action-bar/main-page.ts index 55292cf88..cbbd3973b 100644 --- a/e2e/ui-tests-app/app/action-bar/main-page.ts +++ b/e2e/ui-tests-app/app/action-bar/main-page.ts @@ -1,7 +1,5 @@ -import { EventData } from "tns-core-modules/data/observable"; +import { EventData, Frame, Button, ActionBar, WrapLayout, Page } from "@nativescript/core"; import { SubMainPageViewModel } from "../sub-main-page-view-model"; -import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout"; -import { Page } from "tns-core-modules/ui/page"; export function pageLoaded(args: EventData) { const page = args.object; diff --git a/e2e/ui-tests-app/app/action-bar/modal-page-hidden-action-bar-page.ts b/e2e/ui-tests-app/app/action-bar/modal-page-hidden-action-bar-page.ts index 070baebd2..b9568d782 100644 --- a/e2e/ui-tests-app/app/action-bar/modal-page-hidden-action-bar-page.ts +++ b/e2e/ui-tests-app/app/action-bar/modal-page-hidden-action-bar-page.ts @@ -1,4 +1,4 @@ -import { ShownModallyData } from "tns-core-modules/ui/page"; +import { ShownModallyData } from "@nativescript/core"; let closeCallback: Function; diff --git a/e2e/ui-tests-app/app/action-bar/modal-page.ts b/e2e/ui-tests-app/app/action-bar/modal-page.ts index 72e1e8c46..e963c5ab6 100644 --- a/e2e/ui-tests-app/app/action-bar/modal-page.ts +++ b/e2e/ui-tests-app/app/action-bar/modal-page.ts @@ -1,7 +1,4 @@ -import { ShownModallyData } from "tns-core-modules/ui/page"; -import { Button } from "tns-core-modules/ui/button"; -import { Label } from "tns-core-modules/ui/label"; -import { Page } from "tns-core-modules/ui/page"; +import { EventData, Page, Button, Label, ShownModallyData } from "@nativescript/core"; let closeCallback: Function; diff --git a/e2e/ui-tests-app/app/action-bar/modal-test-hidden-action-bar-page.ts b/e2e/ui-tests-app/app/action-bar/modal-test-hidden-action-bar-page.ts index 567e8ff86..1d55a8a25 100644 --- a/e2e/ui-tests-app/app/action-bar/modal-test-hidden-action-bar-page.ts +++ b/e2e/ui-tests-app/app/action-bar/modal-test-hidden-action-bar-page.ts @@ -1,6 +1,4 @@ -import { EventData } from "tns-core-modules/data/observable"; -import { Page } from "tns-core-modules/ui/page"; -import { topmost } from "tns-core-modules/ui/frame"; +import { EventData, Frame, Page, ActionBar } from "@nativescript/core"; export function btnClick(args: EventData) { (args.object).page.showModal("action-bar/modal-page", { @@ -11,5 +9,5 @@ export function btnClick(args: EventData) { } export function btnBack(args: EventData) { - topmost().goBack(); + Frame.topmost().goBack(); } diff --git a/e2e/ui-tests-app/app/action-bar/modal-test-with-action-bar-page.ts b/e2e/ui-tests-app/app/action-bar/modal-test-with-action-bar-page.ts index 63d00cba3..4dceba7a5 100644 --- a/e2e/ui-tests-app/app/action-bar/modal-test-with-action-bar-page.ts +++ b/e2e/ui-tests-app/app/action-bar/modal-test-with-action-bar-page.ts @@ -1,6 +1,4 @@ -import { EventData } from "tns-core-modules/data/observable"; -import { Page } from "tns-core-modules/ui/page"; -import { topmost } from "tns-core-modules/ui/frame"; +import { EventData, Frame, Page } from "@nativescript/core"; export function btnClick(args: EventData) { (args.object).page.showModal("action-bar/modal-page-hidden-action-bar-page", { @@ -11,5 +9,5 @@ export function btnClick(args: EventData) { } export function btnBack(args: EventData) { - topmost().goBack(); + Frame.topmost().goBack(); } diff --git a/e2e/ui-tests-app/app/action-bar/system-icons-page.ts b/e2e/ui-tests-app/app/action-bar/system-icons-page.ts index 5deb05827..cbc92082c 100644 --- a/e2e/ui-tests-app/app/action-bar/system-icons-page.ts +++ b/e2e/ui-tests-app/app/action-bar/system-icons-page.ts @@ -1,5 +1,5 @@ -import * as frame from "tns-core-modules/ui/frame"; +import { Frame } from "@nativescript/core"; export function navigate() { - frame.topmost().navigate("action-bar/clean-page"); + Frame.topmost().navigate("action-bar/clean-page"); } diff --git a/e2e/ui-tests-app/app/action-bar/transparent-bg-css-page.ts b/e2e/ui-tests-app/app/action-bar/transparent-bg-css-page.ts index 5deb05827..cbc92082c 100644 --- a/e2e/ui-tests-app/app/action-bar/transparent-bg-css-page.ts +++ b/e2e/ui-tests-app/app/action-bar/transparent-bg-css-page.ts @@ -1,5 +1,5 @@ -import * as frame from "tns-core-modules/ui/frame"; +import { Frame } from "@nativescript/core"; export function navigate() { - frame.topmost().navigate("action-bar/clean-page"); + Frame.topmost().navigate("action-bar/clean-page"); } diff --git a/e2e/ui-tests-app/app/animation/animation-army-100-page.ts b/e2e/ui-tests-app/app/animation/animation-army-100-page.ts index 04a68a91d..866761186 100644 --- a/e2e/ui-tests-app/app/animation/animation-army-100-page.ts +++ b/e2e/ui-tests-app/app/animation/animation-army-100-page.ts @@ -1,16 +1,10 @@ -import * as view from "tns-core-modules/ui/core/view"; -import { View } from "tns-core-modules/ui/core/view"; -import * as pages from "tns-core-modules/ui/page"; -import { Button } from "tns-core-modules/ui/button"; -import { SegmentedBar, SegmentedBarItem } from "tns-core-modules/ui/segmented-bar"; -import { Label } from "tns-core-modules/ui/label"; -import { Animation, AnimationDefinition } from "tns-core-modules/ui/animation"; -import * as fpsMeter from "tns-core-modules/fps-meter"; +import { getViewById, View, Page, Button, SegmentedBar, SegmentedBarItem, Label, Animation, AnimationDefinition } from "@nativescript/core"; +import * as fpsMeter from "@nativescript/core/fps-meter"; let fpsCallbackId; export function onLoaded(args) { const page = args.object; - const fpsLabel = view.getViewById(page, "fps") as Label; + const fpsLabel = getViewById(page, "fps") as Label; fpsCallbackId = fpsMeter.addCallback((fps: number, minFps: number) => { fpsLabel.text = `${fps.toFixed(2)}/${minFps.toFixed(2)}`; }); @@ -85,13 +79,13 @@ export function getBoxPropertyAnimationData(property: string, export function easeAnimate(args) { const clicked = args.object as Button; - const page: pages.Page = clicked.page; - const select = view.getViewById(page, "select") as SegmentedBar; + const page: Page = clicked.page; + const select = getViewById(page, "select") as SegmentedBar; const item: SegmentedBarItem = select.items[select.selectedIndex]; const animsIn: AnimationDefinition[] = []; const animsOut: AnimationDefinition[] = []; for (let i = 0; i < 100; i++) { - const box = view.getViewById(page, "el-" + i) as Label; + const box = getViewById(page, "el-" + i) as Label; const prop = getBoxPropertyAnimationData(item.title, clicked.text, box, 32, 24); animsIn.push({ [prop.animateKey]: prop.animateValueTo, diff --git a/e2e/ui-tests-app/app/animation/animation-curves-page.ts b/e2e/ui-tests-app/app/animation/animation-curves-page.ts index 025013f0f..046e2650b 100644 --- a/e2e/ui-tests-app/app/animation/animation-curves-page.ts +++ b/e2e/ui-tests-app/app/animation/animation-curves-page.ts @@ -1,14 +1,10 @@ -import * as view from "tns-core-modules/ui/core/view"; -import * as pages from "tns-core-modules/ui/page"; -import { Button } from "tns-core-modules/ui/button"; -import { SegmentedBar, SegmentedBarItem } from "tns-core-modules/ui/segmented-bar"; -import { Label } from "tns-core-modules/ui/label"; +import { getViewById, View, Page, Button, SegmentedBar, SegmentedBarItem, Label, Animation, AnimationDefinition } from "@nativescript/core"; export function easeAnimate(args) { const clicked = args.object as Button; - const page: pages.Page = clicked.page; - const target = view.getViewById(page, "target") as Label; - const select = view.getViewById(page, "select") as SegmentedBar; + const page: Page = clicked.page; + const target = getViewById(page, "target") as Label; + const select = getViewById(page, "select") as SegmentedBar; const item: SegmentedBarItem = select.items[select.selectedIndex]; const easeType: string = clicked.text; const extent = 128; diff --git a/e2e/ui-tests-app/app/animation/effect-summary-details-page.android.ts b/e2e/ui-tests-app/app/animation/effect-summary-details-page.android.ts index 0b87dcad2..df8ad6dd3 100644 --- a/e2e/ui-tests-app/app/animation/effect-summary-details-page.android.ts +++ b/e2e/ui-tests-app/app/animation/effect-summary-details-page.android.ts @@ -1,16 +1,12 @@ -import * as view from "tns-core-modules/ui/core/view"; -import * as pages from "tns-core-modules/ui/page"; -import * as platform from "tns-core-modules/platform"; +import { getViewById, View, Page, Button, SegmentedBar, SegmentedBarItem, Label, Animation, AnimationDefinition, Screen, TextView } from "@nativescript/core"; // import * as uiUtils from "tns-core-modules/ui/utils"; -import { Animation } from "tns-core-modules/ui/animation"; -import { TextView } from "tns-core-modules/ui/text-view"; // import { isIOS } from "tns-core-modules/platform"; let toggle = false; export function pageLoaded(args) { const page = args.object; - const screenHeight = platform.screen.mainScreen.heightDIPs; + const screenHeight = Screen.mainScreen.heightDIPs; const screenYCenter = (screenHeight / 2); page.bindingContext = { screenHeight, @@ -42,9 +38,9 @@ http://spaceipsum.com` } export function theFinalFrontier(args) { - const clicked = args.object as view.View; - const page: pages.Page = clicked.page; - const details = view.getViewById(page, "details") as TextView; + const clicked = args.object as View; + const page: Page = clicked.page; + const details = getViewById(page, "details") as TextView; const ctx = page.bindingContext; const detailHeaderHeight: number = ctx.detailsHeight; diff --git a/e2e/ui-tests-app/app/animation/effect-summary-details-page.ios.ts b/e2e/ui-tests-app/app/animation/effect-summary-details-page.ios.ts index 03c03f0f9..df138d84a 100644 --- a/e2e/ui-tests-app/app/animation/effect-summary-details-page.ios.ts +++ b/e2e/ui-tests-app/app/animation/effect-summary-details-page.ios.ts @@ -1,16 +1,13 @@ -import * as view from "tns-core-modules/ui/core/view"; -import * as pages from "tns-core-modules/ui/page"; +import { getViewById, View, Page, Button, SegmentedBar, SegmentedBarItem, Label, Animation, AnimationDefinition, Screen, TextView } from "@nativescript/core"; import * as platform from "tns-core-modules/platform"; import * as uiUtils from "tns-core-modules/ui/utils"; -import { Animation } from "tns-core-modules/ui/animation"; -import { TextView } from "tns-core-modules/ui/text-view"; import { isIOS } from "tns-core-modules/platform"; let toggle = false; export function pageLoaded(args) { const page = args.object; - const screenHeight = platform.screen.mainScreen.heightDIPs; + const screenHeight = Screen.mainScreen.heightDIPs; const screenYCenter = (screenHeight / 2); page.bindingContext = { screenHeight, @@ -42,9 +39,9 @@ http://spaceipsum.com` } export function theFinalFrontier(args) { - const clicked = args.object as view.View; - const page: pages.Page = clicked.page; - const details = view.getViewById(page, "details") as TextView; + const clicked = args.object as View; + const page: Page = clicked.page; + const details = getViewById(page, "details") as TextView; const ctx = page.bindingContext; const detailHeaderHeight: number = ctx.detailsHeight; diff --git a/e2e/ui-tests-app/app/animation/height-basic-page.ts b/e2e/ui-tests-app/app/animation/height-basic-page.ts index 8cd68627a..39113dc05 100644 --- a/e2e/ui-tests-app/app/animation/height-basic-page.ts +++ b/e2e/ui-tests-app/app/animation/height-basic-page.ts @@ -1,4 +1,4 @@ -import { Label } from "tns-core-modules/ui/label"; +import { Label } from "@nativescript/core"; let toggle = false; diff --git a/e2e/ui-tests-app/app/animation/layout-stack-height-page.ts b/e2e/ui-tests-app/app/animation/layout-stack-height-page.ts index 09c5135df..14e6ab082 100644 --- a/e2e/ui-tests-app/app/animation/layout-stack-height-page.ts +++ b/e2e/ui-tests-app/app/animation/layout-stack-height-page.ts @@ -1,7 +1,7 @@ -import * as view from "tns-core-modules/ui/core/view"; +import { View } from "@nativescript/core"; export function tapLabel(args) { - const clicked: view.View = args.object; + const clicked: View = args.object; const graffiti = clicked as any; clicked.animate({ height: graffiti.toggle ? 64 : 128, diff --git a/e2e/ui-tests-app/app/animation/main-page.ts b/e2e/ui-tests-app/app/animation/main-page.ts index 075a9d599..5b3d78729 100644 --- a/e2e/ui-tests-app/app/animation/main-page.ts +++ b/e2e/ui-tests-app/app/animation/main-page.ts @@ -1,7 +1,5 @@ -import { EventData } from "tns-core-modules/data/observable"; import { SubMainPageViewModel } from "../sub-main-page-view-model"; -import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout"; -import { Page } from "tns-core-modules/ui/page"; +import { EventData, WrapLayout, Page, ActionBar } from "@nativescript/core"; export function pageLoaded(args: EventData) { const page = args.object; diff --git a/e2e/ui-tests-app/app/button/background-page.ts b/e2e/ui-tests-app/app/button/background-page.ts index 63b2739b6..516df468b 100644 --- a/e2e/ui-tests-app/app/button/background-page.ts +++ b/e2e/ui-tests-app/app/button/background-page.ts @@ -1,13 +1,12 @@ -import * as view from "tns-core-modules/ui/core/view"; -import * as pages from "tns-core-modules/ui/page"; +import { View, Page } from "@nativescript/core"; export function applyTap(args) { - var page = (args.object).page; + var page = (args.object).page; var css = "#test-element { " + args.object.tag + " }"; page.css = css; } export function resetTap(args) { - var page = (args.object).page; + var page = (args.object).page; page.css = ""; } diff --git a/e2e/ui-tests-app/app/button/border-playground-page.ts b/e2e/ui-tests-app/app/button/border-playground-page.ts index e04c78be0..0c5ee9587 100644 --- a/e2e/ui-tests-app/app/button/border-playground-page.ts +++ b/e2e/ui-tests-app/app/button/border-playground-page.ts @@ -1,9 +1,4 @@ -import { EventData } from "tns-core-modules/data/observable"; -import { View } from "tns-core-modules/ui/core/view"; -import { Button } from "tns-core-modules/ui/button"; -import { Color } from "tns-core-modules/color"; -import { TextView } from "tns-core-modules/ui/text-view"; -import { ScrollView } from "tns-core-modules/ui/scroll-view"; +import { EventData, Frame, Button, ScrollView, TextView, Color, View } from "@nativescript/core"; let red = new Color("red"); let green = new Color("green"); diff --git a/e2e/ui-tests-app/app/button/issue-4385-page.ts b/e2e/ui-tests-app/app/button/issue-4385-page.ts index 52d73a6bc..23812eca5 100644 --- a/e2e/ui-tests-app/app/button/issue-4385-page.ts +++ b/e2e/ui-tests-app/app/button/issue-4385-page.ts @@ -1,6 +1,4 @@ -import { EventData, Observable } from "tns-core-modules/data/observable"; -import { Page } from "tns-core-modules/ui/page"; -import * as frame from "tns-core-modules/ui/frame"; +import { EventData, Page, Observable, Frame } from "@nativescript/core"; export function navigatingTo(args: EventData) { const page = args.object; @@ -8,7 +6,7 @@ export function navigatingTo(args: EventData) { } export function onNavBtnTap(args) { - frame.topmost().goBack(); + Frame.topmost().goBack(); } export class TestPage extends Observable { diff --git a/e2e/ui-tests-app/app/button/main-page.ts b/e2e/ui-tests-app/app/button/main-page.ts index 5239daa13..8184ed335 100644 --- a/e2e/ui-tests-app/app/button/main-page.ts +++ b/e2e/ui-tests-app/app/button/main-page.ts @@ -1,7 +1,5 @@ -import { EventData } from "tns-core-modules/data/observable"; import { SubMainPageViewModel } from "../sub-main-page-view-model"; -import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout"; -import { Page } from "tns-core-modules/ui/page"; +import { EventData, Page, WrapLayout } from "@nativescript/core"; export function pageLoaded(args: EventData) { const page = args.object; diff --git a/e2e/ui-tests-app/app/button/tappable-span-page.ts b/e2e/ui-tests-app/app/button/tappable-span-page.ts index 44e1a5c93..e9d8239a4 100644 --- a/e2e/ui-tests-app/app/button/tappable-span-page.ts +++ b/e2e/ui-tests-app/app/button/tappable-span-page.ts @@ -1,6 +1,4 @@ -import { Label } from "tns-core-modules/ui/label"; -import { EventData, TextBase } from "tns-core-modules/ui/text-base"; -import { Page } from "tns-core-modules/ui/page"; +import { EventData, Page, TextBase, Label } from "@nativescript/core"; export function foxTap(args: EventData) { let page = (args.object).page; diff --git a/e2e/ui-tests-app/app/issues/open-file-6895-page.ts b/e2e/ui-tests-app/app/issues/open-file-6895-page.ts index 86e826923..9c91b44fe 100644 --- a/e2e/ui-tests-app/app/issues/open-file-6895-page.ts +++ b/e2e/ui-tests-app/app/issues/open-file-6895-page.ts @@ -1,15 +1,13 @@ -import { isIOS, isAndroid } from "tns-core-modules/platform"; -import * as fs from "tns-core-modules/file-system/file-system"; -import * as utils from "tns-core-modules/utils/utils"; +import { isIOS, isAndroid, knownFolders, path, Utils } from "@nativescript/core"; export function openFile() { let directory; if (isIOS) { - directory = fs.knownFolders.ios.downloads(); + directory = knownFolders.ios.downloads(); } else if (isAndroid) { directory = android.os.Environment.getExternalStorageDirectory().getAbsolutePath().toString(); } - const filePath = fs.path.join(directory, "Test_File_Open.txt"); - utils.openFile(filePath); + const filePath = path.join(directory, "Test_File_Open.txt"); + Utils.openFile(filePath); } diff --git a/e2e/ui-tests-app/package.json b/e2e/ui-tests-app/package.json index f04d286fd..295cc87f9 100644 --- a/e2e/ui-tests-app/package.json +++ b/e2e/ui-tests-app/package.json @@ -13,8 +13,7 @@ "license": "SEE LICENSE IN ", "repository": "", "dependencies": { - "@nativescript/core": "file:../../dist/nativescript-core-7.0.0-rc.6.tgz", - "@nativescript/core-widgets": "^7.0.0-rc.0" + "@nativescript/core": "file:../../dist/nativescript-core-7.0.0-rc.9.tgz" }, "devDependencies": { "@testdeck/mocha": "0.0.6", @@ -29,7 +28,7 @@ "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", "@nativescript/webpack": "^2.0.0-alpha.3", - "@nativescript/types": "file:../../dist/nativescript-types-7.0.0-rc.0.tgz", + "@nativescript/types": "~7.0.0-rc.0", "typescript": "~3.9.0" }, "gitHead": "8ab7726d1ee9991706069c1359c552e67ee0d1a4", diff --git a/nativescript-core/bundle-entry-points.ts b/nativescript-core/bundle-entry-points.ts index 06c2f2ab3..c39d18e32 100644 --- a/nativescript-core/bundle-entry-points.ts +++ b/nativescript-core/bundle-entry-points.ts @@ -11,7 +11,6 @@ if (global.TNS_WEBPACK) { global.registerModule('ui/text-base/span', () => require('./ui/text-base/span')); global.registerModule('ui/action-bar', () => require('./ui/action-bar')); global.registerModule('ui/activity-indicator', () => require('./ui/activity-indicator')); - global.registerModule('ui/border', () => require('./ui/border')); global.registerModule('ui/bottom-navigation', () => require('./ui/bottom-navigation')); global.registerModule('ui/button', () => require('./ui/button')); global.registerModule('ui/content-view', () => require('./ui/content-view')); diff --git a/nativescript-core/connectivity/index.ios.ts b/nativescript-core/connectivity/index.ios.ts index 40f9ff93c..85b0b6b75 100644 --- a/nativescript-core/connectivity/index.ios.ts +++ b/nativescript-core/connectivity/index.ios.ts @@ -55,9 +55,14 @@ function _getConnectionTypeFromFlags(flags: number): number { return connectionType.mobile; } - const cfDict = CFNetworkCopySystemProxySettings(); - const nsDict = cfDict.takeUnretainedValue(); - const keys = nsDict.objectForKey('__SCOPED__'); + let keys: any; + if (typeof CFNetworkCopySystemProxySettings !== 'undefined') { + const cfDict = CFNetworkCopySystemProxySettings(); + if (cfDict && cfDict.takeUnretainedValue) { + const nsDict = cfDict.takeUnretainedValue(); + keys = nsDict.objectForKey('__SCOPED__'); + } + } if (isVPNConnected(keys)) { return connectionType.vpn; diff --git a/nativescript-core/data/observable/index.d.ts b/nativescript-core/data/observable/index.d.ts index e4f156955..fee5d282e 100644 --- a/nativescript-core/data/observable/index.d.ts +++ b/nativescript-core/data/observable/index.d.ts @@ -149,10 +149,10 @@ export class Observable { */ hasListeners(eventName: string): boolean; - //@private + public _emit(eventNames: string); + /** * This method is intended to be overriden by inheritors to provide additional implementation. - * @private */ _createPropertyChangeData(name: string, value: any, oldValue?: any): PropertyChangeData; @@ -162,11 +162,6 @@ export class Observable { * @private */ public _isViewBase: boolean; - - /** - * @private - */ - _emit(eventNames: string); //@endprivate } diff --git a/nativescript-core/file-system/file-name-resolver/index.ts b/nativescript-core/file-system/file-name-resolver/index.ts deleted file mode 100644 index 891119050..000000000 --- a/nativescript-core/file-system/file-name-resolver/index.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { FileNameResolver as FileNameResolverDefinition } from '.'; -import { PlatformContext } from '../../module-name-resolver/qualifier-matcher'; -import { screen, Device } from '../../platform'; -import { path as fsPath, Folder, File } from '..'; -import { Trace } from '../../trace'; -import * as appCommonModule from '../../application/application-common'; - -import { findMatch, stripQualifiers } from '../../module-name-resolver/qualifier-matcher'; - -export class FileNameResolver implements FileNameResolverDefinition { - private _context: PlatformContext; - private _cache = {}; - - constructor(context: PlatformContext) { - console.log('FileNameResolver is deprecated; use ModuleNameResolver instead'); - - this._context = context; - } - - public resolveFileName(path: string, ext: string): string { - const key = path + ext; - let result: string = this._cache[key]; - if (result === undefined) { - result = this.resolveFileNameImpl(path, ext); - this._cache[key] = result; - } - - return result; - } - - public clearCache(): void { - this._cache = {}; - } - - private resolveFileNameImpl(path: string, ext: string): string { - let result: string = null; - path = fsPath.normalize(path); - ext = '.' + ext; - - // This call will return a clean path without qualifiers - path = stripQualifiers(path); - - const candidates = this.getFileCandidatesFromFolder(path, ext); - result = findMatch(path, ext, candidates, this._context); - - return result; - } - - private getFileCandidatesFromFolder(path: string, ext: string): Array { - const candidates = new Array(); - const folderPath = path.substring(0, path.lastIndexOf(fsPath.separator) + 1); - - if (Folder.exists(folderPath)) { - const folder = Folder.fromPath(folderPath); - folder.eachEntity((e) => { - if (e instanceof File) { - const file = e; - if (file.path.indexOf(path) === 0 && file.extension === ext) { - candidates.push(file.path); - } - } - - return true; - }); - } else { - if (Trace.isEnabled()) { - Trace.write('Could not find folder ' + folderPath + ' when loading ' + path + ext, Trace.categories.Navigation); - } - } - - return candidates; - } -} - -let resolverInstance: FileNameResolver; - -export function resolveFileName(path: string, ext: string): string { - if (!resolverInstance) { - resolverInstance = new FileNameResolver({ - width: screen.mainScreen.widthDIPs, - height: screen.mainScreen.heightDIPs, - os: Device.os, - deviceType: Device.deviceType, - }); - } - - return resolverInstance.resolveFileName(path, ext); -} -export function clearCache() { - if (resolverInstance) { - resolverInstance.clearCache(); - } -} - -appCommonModule.on('cssChanged', (args) => (resolverInstance = undefined)); -appCommonModule.on('livesync', (args) => clearCache()); diff --git a/nativescript-core/globals/index.ts b/nativescript-core/globals/index.ts index efb442363..f09ac2d02 100644 --- a/nativescript-core/globals/index.ts +++ b/nativescript-core/globals/index.ts @@ -41,7 +41,6 @@ export function installPolyfills(moduleName: string, exportNames: string[]) { } export function initGlobal() { - console.log('initGlobal called, init:', (global).hasInitGlobal); if (!(global).hasInitGlobal) { (global).hasInitGlobal = true; // ts-helpers diff --git a/nativescript-core/index.d.ts b/nativescript-core/index.d.ts index e53bb6d50..5c2e36017 100644 --- a/nativescript-core/index.d.ts +++ b/nativescript-core/index.d.ts @@ -27,32 +27,6 @@ export declare const Application: { hasLaunched: typeof hasLaunched; android: AndroidApplication; ios: iOSApplication; -} = { - launchEvent: 'launch', - displayedEvent: 'displayed', - uncaughtErrorEvent: 'uncaughtError', - discardedErrorEvent: 'discardedError', - suspendEvent: 'suspend', - resumeEvent: 'resume', - exitEvent: 'exit', - lowMemoryEvent: 'lowMemory', - orientationChangedEvent: 'orientationChanged', - getMainEntry, - getRootView, - resetRootView, - setResources, - setCssFileName, - getCssFileName, - loadAppCss, - addCss, - on, - off, - run, - orientation, - getNativeApplication, - hasLaunched, - android, - ios, }; import { setString, getString, clear, flush, getAllKeys, getBoolean, getNumber, hasKey, remove, setBoolean, setNumber } from './application-settings'; export declare const ApplicationSettings: { @@ -67,18 +41,6 @@ export declare const ApplicationSettings: { setBoolean: typeof setBoolean; getNumber: typeof getNumber; setNumber: typeof setNumber; -} = { - clear, - flush, - hasKey, - remove, - setString, - getString, - getAllKeys, - getBoolean, - setBoolean, - getNumber, - setNumber, }; export { Color } from './color'; import { connectionType, getConnectionType, startMonitoring, stopMonitoring } from './connectivity'; @@ -87,14 +49,9 @@ export declare const Connectivity: { getConnectionType: typeof getConnectionType; startMonitoring: typeof startMonitoring; stopMonitoring: typeof stopMonitoring; -} = { - connectionType, - getConnectionType, - startMonitoring, - stopMonitoring, }; export { ObservableArray, ChangeType, ChangedData } from './data/observable-array'; -export { Observable, PropertyChangeData, EventData } from './data/observable'; +export { Observable, PropertyChangeData, EventData, WrappedValue, fromObject, fromObjectRecursive } from './data/observable'; export { VirtualArray, ItemsLoading } from './data/virtual-array'; export { File, FileSystemEntity, Folder, knownFolders, path } from './file-system'; export { HttpRequestOptions, HttpResponse, Headers, HttpResponseEncoding, HttpContent } from './http'; @@ -105,50 +62,19 @@ export declare const Http: { getJSON: typeof getJSON; getString: typeof httpGetString; request: typeof request; -} = { - getFile, - getImage, - getJSON, - getString, - request, }; export { ImageAsset, ImageAssetOptions } from './image-asset'; export { ImageSource } from './image-source'; +export { ModuleNameResolver, ModuleListProvider, PlatformContext, _setResolver } from './module-name-resolver'; export { isAndroid, isIOS, screen as Screen, IDevice, Device, platformNames } from './platform'; -export { InstrumentationMode, TimerInfo } from './profiling'; -import { enable as profilingEnable, disable as profilingDisable, time, uptime, start, stop, isRunning, dumpProfiles, resetProfiles, profile, startCPUProfile, stopCPUProfile } from './profiling'; -export declare const Profiling: { - enable: typeof profilingEnable; - disable: typeof profilingDisable; - time: typeof time; - uptime: typeof uptime; - start: typeof start; - stop: typeof stop; - isRunning: typeof isRunning; - dumpProfiles: typeof dumpProfiles; - resetProfiles: typeof resetProfiles; - profile: typeof profile; - startCPUProfile: typeof startCPUProfile; - stopCPUProfile: typeof stopCPUProfile; -} = { - enable: profilingEnable, - disable: profilingDisable, - time, - uptime, - start, - stop, - isRunning, - dumpProfiles, - resetProfiles, - profile, - startCPUProfile, - stopCPUProfile, -}; +// Profiling +export { InstrumentationMode, TimerInfo, profile, enable as profilingEnable, disable as profilingDisable, time as profilingTime, uptime as profilingUptime, start as profilingStart, stop as profilingStop, isRunning as profilingIsRunning, dumpProfiles as profilingDumpProfiles, resetProfiles as profilingResetProfiles, startCPUProfile as profilingStartCPU, stopCPUProfile as profilingStopCPU } from './profiling'; export { encoding } from './text'; export * from './trace'; export * from './ui'; -import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, ios as iosUtils } from './utils'; +import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, ios as iosUtils, Source } from './utils'; +import { ClassInfo, getClass, getBaseClasses, getClassInfo, isBoolean, isDefined, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, toUIString, verifyCallback } from './utils/types'; export declare const Utils: { GC: typeof GC; isFontIconURI: typeof isFontIconURI; @@ -166,22 +92,20 @@ export declare const Utils: { layout: typeof layout; android: typeof androidUtils; ios: typeof iosUtils; -} = { - GC, - isFontIconURI, - isDataURI, - isFileOrResourcePath, - executeOnMainThread, - mainThreadify, - isMainThread, - dispatchToMainThread, - releaseNativeObject, - getModuleName, - openFile, - openUrl, - isRealDevice, - layout, - android, - ios, + Source: typeof Source; + ClassInfo: typeof ClassInfo; + getClass: typeof getClass; + getBaseClasses: typeof getBaseClasses; + getClassInfo: typeof getClassInfo; + isBoolean: typeof isBoolean; + isDefined: typeof isDefined; + isFunction: typeof isFunction; + isNullOrUndefined: typeof isNullOrUndefined; + isNumber: typeof isNumber; + isObject: typeof isObject; + isString: typeof isString; + isUndefined: typeof isUndefined; + toUIString: typeof toUIString; + verifyCallback: typeof verifyCallback; }; export { XmlParser, ParserEventType, ParserEvent } from './xml'; diff --git a/nativescript-core/index.ts b/nativescript-core/index.ts index 321b33253..b1ce9cc10 100644 --- a/nativescript-core/index.ts +++ b/nativescript-core/index.ts @@ -68,7 +68,7 @@ export const Connectivity = { }; export { ObservableArray, ChangeType, ChangedData } from './data/observable-array'; -export { Observable, PropertyChangeData, EventData } from './data/observable'; +export { Observable, PropertyChangeData, EventData, WrappedValue, fromObject, fromObjectRecursive } from './data/observable'; export { VirtualArray, ItemsLoading } from './data/virtual-array'; export { File, FileSystemEntity, Folder, knownFolders, path } from './file-system'; @@ -87,26 +87,11 @@ export const Http = { export { ImageAsset, ImageAssetOptions } from './image-asset'; export { ImageSource } from './image-source'; +export { ModuleNameResolver, ModuleListProvider, PlatformContext, _setResolver } from './module-name-resolver'; export { isAndroid, isIOS, screen as Screen, IDevice, Device, platformNames } from './platform'; -// Export interfaces from "profiling" module -export { InstrumentationMode, TimerInfo } from './profiling'; -// Export methods from "profiling" module -import { enable as profilingEnable, disable as profilingDisable, time, uptime, start, stop, isRunning, dumpProfiles, resetProfiles, profile, startCPUProfile, stopCPUProfile } from './profiling'; -export const Profiling = { - enable: profilingEnable, - disable: profilingDisable, - time, - uptime, - start, - stop, - isRunning, - dumpProfiles, - resetProfiles, - profile, - startCPUProfile, - stopCPUProfile, -}; +// Profiling +export { InstrumentationMode, TimerInfo, profile, enable as profilingEnable, disable as profilingDisable, time as profilingTime, uptime as profilingUptime, start as profilingStart, stop as profilingStop, isRunning as profilingIsRunning, dumpProfiles as profilingDumpProfiles, resetProfiles as profilingResetProfiles, startCPUProfile as profilingStartCPU, stopCPUProfile as profilingStopCPU } from './profiling'; export { encoding } from './text'; @@ -114,7 +99,8 @@ export * from './trace'; export * from './ui'; -import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, ios as iosUtils } from './utils'; +import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, ios as iosUtils, Source } from './utils'; +import { ClassInfo, getClass, getBaseClasses, getClassInfo, isBoolean, isDefined, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, toUIString, verifyCallback } from './utils/types'; export const Utils = { GC, @@ -135,6 +121,21 @@ export const Utils = { layout, android: androidUtils, ios: iosUtils, + Source, + ClassInfo, + getClass, + getBaseClasses, + getClassInfo, + isBoolean, + isDefined, + isFunction, + isNullOrUndefined, + isNumber, + isObject, + isString, + isUndefined, + toUIString, + verifyCallback, }; export { XmlParser, ParserEventType, ParserEvent } from './xml'; diff --git a/nativescript-core/module-name-resolver/index.d.ts b/nativescript-core/module-name-resolver/index.d.ts index e8880435f..077b7db23 100644 --- a/nativescript-core/module-name-resolver/index.d.ts +++ b/nativescript-core/module-name-resolver/index.d.ts @@ -17,4 +17,8 @@ export class ModuleNameResolver { export function resolveModuleName(path: string, ext: string): string; export function clearCache(): void; +/** + * Used to set a global singular instance of ModuleNameResolver + * @param resolver instance + */ export function _setResolver(resolver: ModuleNameResolver); diff --git a/nativescript-core/module-name-resolver/index.ts b/nativescript-core/module-name-resolver/index.ts index 499cc125d..661aede1f 100644 --- a/nativescript-core/module-name-resolver/index.ts +++ b/nativescript-core/module-name-resolver/index.ts @@ -1,4 +1,3 @@ -import { ModuleNameResolver as ModuleNameResolverDefinition } from './'; import { screen, Device } from '../platform'; import * as appCommonModule from '../application/application-common'; import { PlatformContext, findMatch, stripQualifiers } from './qualifier-matcher'; @@ -9,7 +8,7 @@ export { PlatformContext } from './qualifier-matcher'; export type ModuleListProvider = () => string[]; -export class ModuleNameResolver implements ModuleNameResolverDefinition { +export class ModuleNameResolver { private _cache = {}; constructor(private context: PlatformContext, private moduleListProvider: ModuleListProvider = global.getRegisteredModules) {} diff --git a/nativescript-core/module-name-resolver/qualifier-matcher/index.d.ts b/nativescript-core/module-name-resolver/qualifier-matcher/index.d.ts index 11a041918..e20d667db 100644 --- a/nativescript-core/module-name-resolver/qualifier-matcher/index.d.ts +++ b/nativescript-core/module-name-resolver/qualifier-matcher/index.d.ts @@ -2,6 +2,9 @@ * Provides ModuleNameResolver class used for loading files based on device capabilities. */ +/** + * Used with qualifier matchers and module resolution + */ export interface PlatformContext { width: number; height: number; diff --git a/nativescript-core/module-name-resolver/qualifier-matcher/index.ts b/nativescript-core/module-name-resolver/qualifier-matcher/index.ts index b600173f1..9c98ec6d0 100644 --- a/nativescript-core/module-name-resolver/qualifier-matcher/index.ts +++ b/nativescript-core/module-name-resolver/qualifier-matcher/index.ts @@ -3,6 +3,9 @@ const MIN_W: string = 'minW'; const MIN_H: string = 'minH'; const PRIORITY_STEP = 10000; +/** + * Used with qualifier matchers and module resolution + */ export interface PlatformContext { width: number; height: number; diff --git a/nativescript-core/package.json b/nativescript-core/package.json index a2484a0c1..bde293017 100644 --- a/nativescript-core/package.json +++ b/nativescript-core/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "NativeScript Core Modules", - "version": "7.0.0-rc.6", + "version": "7.0.0-rc.9", "homepage": "https://www.nativescript.org", "repository": { "type": "git", @@ -19,7 +19,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@nativescript/core-widgets": "~7.0.0-rc.0", + "@nativescript/ui-base": "~7.0.0-rc.0", "@nativescript/hook": "~1.0.0", "css-tree": "^1.0.0-alpha.39", "reduce-css-calc": "^2.1.6", diff --git a/nativescript-core/trace/index.d.ts b/nativescript-core/trace/index.d.ts index d693067de..116e4c4fb 100644 --- a/nativescript-core/trace/index.d.ts +++ b/nativescript-core/trace/index.d.ts @@ -123,24 +123,24 @@ export namespace Trace { export const separator = ','; export const All: Array; - export function concat(): string; - - class ConsoleWriter implements TraceWriter { - public write(message: any, category: string, type?: number): void; - } - - export class DefaultErrorHandler implements TraceErrorHandler { - handlerError(error: any): void; - } - - export function getErrorHandler(): TraceErrorHandler; - - export function setErrorHandler(handler: TraceErrorHandler): void; - - /** - * Passes an error to the registered ErrorHandler - * @param error The error to be handled. - */ - export function error(error: string | Error): void; + export function concat(...args: any): string; } + + class ConsoleWriter implements TraceWriter { + public write(message: any, category: string, type?: number): void; + } + + export class DefaultErrorHandler implements TraceErrorHandler { + handlerError(error: any): void; + } + + export function getErrorHandler(): TraceErrorHandler; + + export function setErrorHandler(handler: TraceErrorHandler): void; + + /** + * Passes an error to the registered ErrorHandler + * @param error The error to be handled. + */ + export function error(error: string | Error): void; } diff --git a/nativescript-core/trace/index.ts b/nativescript-core/trace/index.ts index 4df62d78d..dabb1f055 100644 --- a/nativescript-core/trace/index.ts +++ b/nativescript-core/trace/index.ts @@ -204,7 +204,7 @@ export namespace Trace { export const separator = ','; export const All = [VisualTreeEvents, Layout, Style, ViewHierarchy, NativeLifecycle, Debug, Navigation, Test, Binding, Error, Animation, Transition, Livesync, ModuleNameResolver].join(separator); - export function concat(): string { + export function concat(...args: any): string { let result: string; for (let i = 0; i < arguments.length; i++) { if (!result) { diff --git a/nativescript-core/ui/animation/index.android.ts b/nativescript-core/ui/animation/index.android.ts index bc31283b5..9c8950c4c 100644 --- a/nativescript-core/ui/animation/index.android.ts +++ b/nativescript-core/ui/animation/index.android.ts @@ -12,6 +12,7 @@ import { Device, screen } from '../../platform'; import lazy from '../../utils/lazy'; export * from './animation-common'; +export { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './keyframe-animation'; let argbEvaluator: android.animation.ArgbEvaluator; function ensureArgbEvaluator() { diff --git a/nativescript-core/ui/animation/index.d.ts b/nativescript-core/ui/animation/index.d.ts index a3bcf2dd5..abd4941a4 100644 --- a/nativescript-core/ui/animation/index.d.ts +++ b/nativescript-core/ui/animation/index.d.ts @@ -2,6 +2,8 @@ import { Color } from '../../color'; import { PercentLength } from '../styling/style-properties'; +export { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './keyframe-animation'; + /** * Defines animation options for the View.animate method. */ diff --git a/nativescript-core/ui/animation/index.ios.ts b/nativescript-core/ui/animation/index.ios.ts index 8b04b446d..ddf206099 100644 --- a/nativescript-core/ui/animation/index.ios.ts +++ b/nativescript-core/ui/animation/index.ios.ts @@ -12,6 +12,7 @@ import { ios as iosNativeHelper } from '../../utils/native-helper'; import { screen } from '../../platform'; export * from './animation-common'; +export { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './keyframe-animation'; let _transform = '_transform'; let _skip = '_skip'; diff --git a/nativescript-core/ui/animation/keyframe-animation.ts b/nativescript-core/ui/animation/keyframe-animation.ts index e63700e99..100f180a4 100644 --- a/nativescript-core/ui/animation/keyframe-animation.ts +++ b/nativescript-core/ui/animation/keyframe-animation.ts @@ -1,6 +1,3 @@ -// Definitions. -import { Keyframes as KeyframesDefinition, UnparsedKeyframe as UnparsedKeyframeDefinition, KeyframeDeclaration as KeyframeDeclarationDefinition, KeyframeInfo as KeyframeInfoDefinition, KeyframeAnimationInfo as KeyframeAnimationInfoDefinition, KeyframeAnimation as KeyframeAnimationDefinition } from './keyframe-animation'; - import { View } from '../core/view'; import { Color } from '../../color'; @@ -13,28 +10,28 @@ import { unsetValue } from '../core/properties'; import { Animation } from '.'; import { backgroundColorProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty, rotateProperty, opacityProperty, rotateXProperty, rotateYProperty, widthProperty, heightProperty, PercentLength } from '../styling/style-properties'; -export class Keyframes implements KeyframesDefinition { +export class Keyframes { name: string; keyframes: Array; } -export class UnparsedKeyframe implements UnparsedKeyframeDefinition { +export class UnparsedKeyframe { values: Array; declarations: Array; } -export class KeyframeDeclaration implements KeyframeDeclarationDefinition { +export class KeyframeDeclaration { public property: string; public value: any; } -export class KeyframeInfo implements KeyframeInfoDefinition { +export class KeyframeInfo { public duration: number; public declarations: Array; public curve?: any = AnimationCurve.ease; } -export class KeyframeAnimationInfo implements KeyframeAnimationInfoDefinition { +export class KeyframeAnimationInfo { public keyframes: Array; public name?: string = ''; public duration?: number = 0.3; @@ -59,7 +56,7 @@ interface Keyframe { forceLayer?: boolean; } -export class KeyframeAnimation implements KeyframeAnimationDefinition { +export class KeyframeAnimation { public animations: Array; public delay: number = 0; public iterations: number = 1; diff --git a/nativescript-core/ui/border/index.ts b/nativescript-core/ui/border/index.ts deleted file mode 100644 index d94661fec..000000000 --- a/nativescript-core/ui/border/index.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Border as BorderDefinition } from '.'; -import { ContentView } from '../content-view'; -import { View, CSSType } from '../core/view'; -import { layout } from '../../utils'; - -@Deprecated -@CSSType('Border') -export class Border extends ContentView implements BorderDefinition { - get cornerRadius(): number { - if (typeof this.borderRadius === 'number') { - return this.borderRadius; - } - - return 0; - } - set cornerRadius(value: number) { - this.borderRadius = value; - } - - public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void { - const width = layout.getMeasureSpecSize(widthMeasureSpec); - const widthMode = layout.getMeasureSpecMode(widthMeasureSpec); - - const height = layout.getMeasureSpecSize(heightMeasureSpec); - const heightMode = layout.getMeasureSpecMode(heightMeasureSpec); - - const horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth; - const verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth; - - const result = View.measureChild(this, this.layoutView, layout.makeMeasureSpec(width - horizontalBorderLength, widthMode), layout.makeMeasureSpec(height - verticalBorderLength, heightMode)); - - const widthAndState = View.resolveSizeAndState(result.measuredWidth + horizontalBorderLength, width, widthMode, 0); - const heightAndState = View.resolveSizeAndState(result.measuredHeight + verticalBorderLength, height, heightMode, 0); - - this.setMeasuredDimension(widthAndState, heightAndState); - } - - public onLayout(left: number, top: number, right: number, bottom: number): void { - let horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth; - let verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth; - - View.layoutChild(this, this.layoutView, this.effectiveBorderLeftWidth, this.effectiveBorderTopWidth, right - left - horizontalBorderLength, bottom - top - verticalBorderLength); - } -} - -Border.prototype.recycleNativeView = 'auto'; diff --git a/nativescript-core/ui/builder/module-name-sanitizer.d.ts b/nativescript-core/ui/builder/module-name-sanitizer.d.ts index 2a844296a..d712e0f77 100644 --- a/nativescript-core/ui/builder/module-name-sanitizer.d.ts +++ b/nativescript-core/ui/builder/module-name-sanitizer.d.ts @@ -1 +1,6 @@ +/** + * Helps sanitize a module name if it is prefixed with '~/', '~' or '/' + * @param moduleName the name + * @param removeExtension whether to remove extension + */ export function sanitizeModuleName(moduleName: string, removeExtension?: boolean): string; diff --git a/nativescript-core/ui/builder/module-name-sanitizer.ts b/nativescript-core/ui/builder/module-name-sanitizer.ts index 45119d85a..43b91115d 100644 --- a/nativescript-core/ui/builder/module-name-sanitizer.ts +++ b/nativescript-core/ui/builder/module-name-sanitizer.ts @@ -1,3 +1,8 @@ +/** + * Helps sanitize a module name if it is prefixed with '~/', '~' or '/' + * @param moduleName the name + * @param removeExtension whether to remove extension + */ export function sanitizeModuleName(moduleName: string, removeExtension: boolean = true): string { moduleName = moduleName.trim(); diff --git a/nativescript-core/ui/core/view-base/index.d.ts b/nativescript-core/ui/core/view-base/index.d.ts index dd0bf6999..f0d311568 100644 --- a/nativescript-core/ui/core/view-base/index.d.ts +++ b/nativescript-core/ui/core/view-base/index.d.ts @@ -417,10 +417,6 @@ export abstract class ViewBase extends Observable { */ public ensureDomNode(); - //@private - /** - * @private - */ public recycleNativeView: 'always' | 'never' | 'auto'; /** diff --git a/nativescript-core/ui/enums/index.d.ts b/nativescript-core/ui/enums/index.d.ts index b1abc78d9..2fb4d5e77 100644 --- a/nativescript-core/ui/enums/index.d.ts +++ b/nativescript-core/ui/enums/index.d.ts @@ -666,3 +666,38 @@ export module UserInterfaceStyle { */ export const dark: string; } + +/** + * Singular rollup for convenience of all enums + */ +export declare const Enums: { + Accuracy: typeof Accuracy; + AndroidActionBarIconVisibility: typeof AndroidActionBarIconVisibility; + AndroidActionItemPosition: typeof AndroidActionItemPosition; + AnimationCurve: typeof AnimationCurve; + AutocapitalizationType: typeof AutocapitalizationType; + BackgroundRepeat: typeof BackgroundRepeat; + DeviceOrientation: typeof DeviceOrientation; + DeviceType: typeof DeviceType; + Dock: typeof Dock; + FontAttributes: typeof FontAttributes; + FontStyle: typeof FontStyle; + FontWeight: typeof FontWeight; + HorizontalAlignment: typeof HorizontalAlignment; + IOSActionItemPosition: typeof IOSActionItemPosition; + ImageFormat: typeof ImageFormat; + KeyboardType: typeof KeyboardType; + NavigationBarVisibility: typeof NavigationBarVisibility; + Orientation: typeof Orientation; + ReturnKeyType: typeof ReturnKeyType; + StatusBarStyle: typeof StatusBarStyle; + Stretch: typeof Stretch; + SystemAppearance: typeof SystemAppearance; + TextAlignment: typeof TextAlignment; + TextDecoration: typeof TextDecoration; + TextTransform: typeof TextTransform; + UpdateTextTrigger: typeof UpdateTextTrigger; + VerticalAlignment: typeof VerticalAlignment; + Visibility: typeof Visibility; + WhiteSpace: typeof WhiteSpace; +}; diff --git a/nativescript-core/ui/enums/index.ts b/nativescript-core/ui/enums/index.ts index 9c4d29116..3c2a28e9e 100644 --- a/nativescript-core/ui/enums/index.ts +++ b/nativescript-core/ui/enums/index.ts @@ -195,3 +195,35 @@ export module SystemAppearance { export const light = 'light'; export const dark = 'dark'; } + +export const Enums = { + Accuracy, + AndroidActionBarIconVisibility, + AndroidActionItemPosition, + AnimationCurve, + AutocapitalizationType, + BackgroundRepeat, + DeviceOrientation, + DeviceType, + Dock, + FontAttributes, + FontStyle, + FontWeight, + HorizontalAlignment, + IOSActionItemPosition, + ImageFormat, + KeyboardType, + NavigationBarVisibility, + Orientation, + ReturnKeyType, + StatusBarStyle, + Stretch, + SystemAppearance, + TextAlignment, + TextDecoration, + TextTransform, + UpdateTextTrigger, + VerticalAlignment, + Visibility, + WhiteSpace, +}; diff --git a/nativescript-core/ui/frame/frame-common.ts b/nativescript-core/ui/frame/frame-common.ts index 54ef4065b..1634402c6 100644 --- a/nativescript-core/ui/frame/frame-common.ts +++ b/nativescript-core/ui/frame/frame-common.ts @@ -1,5 +1,4 @@ // Types. -import { Frame as FrameDefinition } from '.'; import { BackstackEntry, NavigationContext, NavigationEntry, NavigationTransition, NavigationType } from './frame-interfaces'; import { Page } from '../page'; import { View, CustomLayoutView, CSSType } from '../core/view'; @@ -35,7 +34,7 @@ function buildEntryFromArgs(arg: any): NavigationEntry { } @CSSType('Frame') -export class FrameBase extends CustomLayoutView implements FrameDefinition { +export class FrameBase extends CustomLayoutView { public static androidOptionSelectedEvent = 'optionSelected'; private _animated: boolean; diff --git a/nativescript-core/ui/frame/index.d.ts b/nativescript-core/ui/frame/index.d.ts index 6c4db101d..bfb1eb651 100644 --- a/nativescript-core/ui/frame/index.d.ts +++ b/nativescript-core/ui/frame/index.d.ts @@ -1,4 +1,4 @@ -import { NavigationType } from './frame-common'; +import { NavigationType, FrameBase } from './frame-common'; import { Page } from '../page'; import { Observable, EventData } from '../../data/observable'; import { View } from '../core/view'; @@ -10,7 +10,7 @@ export * from './frame-interfaces'; * Represents the logical View unit that is responsible for navigation within an application. * Nested frames are supported, enabling hierarchical navigation scenarios. */ -export class Frame extends View { +export class Frame extends FrameBase { /** * Gets a frame by id. */ diff --git a/nativescript-core/ui/index.d.ts b/nativescript-core/ui/index.d.ts index 65b02e6fb..8ce5ba729 100644 --- a/nativescript-core/ui/index.d.ts +++ b/nativescript-core/ui/index.d.ts @@ -1,10 +1,12 @@ export { ActionBar, ActionItem, ActionItems, NavigationButton } from './action-bar'; export { ActivityIndicator } from './activity-indicator'; -export { Animation, AnimationDefinition } from './animation'; +export { Animation, AnimationDefinition, KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './animation'; export { BottomNavigation, SelectedIndexChangedEventData } from './bottom-navigation'; export { Builder, LoadOptions } from './builder'; +export { sanitizeModuleName } from './builder/module-name-sanitizer'; export { Button } from './button'; export { ContentView } from './content-view'; +export { Binding, BindingOptions } from './core/bindable'; export { ViewBase, ShowModalOptions, eachDescendant, getAncestor, getViewById } from './core/view-base'; export { View, Template, KeyedTemplate, ShownModallyData } from './core/view'; export { Property, CoercibleProperty, InheritedProperty, CssProperty, InheritedCssProperty, ShorthandProperty, CssAnimationProperty, unsetValue } from './core/properties'; @@ -14,8 +16,7 @@ export { DatePicker } from './date-picker'; export { action, alert, confirm, login, prompt, getCurrentPage, Dialogs, DialogStrings, DialogOptions, CancelableOptions, AlertOptions, PromptResult, PromptOptions, ActionOptions, ConfirmOptions, LoginResult, LoginOptions, inputType, capitalizationType } from './dialogs'; export * from './editable-text-base'; -import * as enumsModule from './enums'; -export const Enums = enumsModule; +export { Enums } from './enums'; export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry } from './frame'; export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData } from './gestures'; @@ -29,7 +30,7 @@ export * from './layouts'; // barrel export export { ListPicker } from './list-picker'; export { ListView, ItemEventData, TemplatedItemsView, ItemsSource } from './list-view'; -export { Page, NavigatedData } from './page'; +export { Page, NavigatedData, PageBase } from './page'; export { Placeholder, CreateViewEventData } from './placeholder'; export { Progress } from './progress'; export { ProxyViewContainer } from './proxy-view-container'; @@ -41,8 +42,11 @@ export { Slider } from './slider'; // TODO: Consider adding APIs from style // export { addTaggedAdditionalCSS, removeTaggedAdditionalCSS } from "./styling/style-scope"; +export { animationTimingFunctionConverter, timeConverter } from './styling/converters'; export { Style, CommonLayoutParams } from './styling/style'; export * from './styling/style-properties'; +export { CssAnimationParser, parseKeyframeDeclarations } from './styling/css-animation-parser'; +export { CSSHelper } from './styling/css-selector'; export { Switch } from './switch'; export { TabContentItem } from './tab-navigation-base/tab-content-item'; @@ -51,7 +55,7 @@ export { TabStrip, TabStripItemEventData } from './tab-navigation-base/tab-strip export { TabStripItem } from './tab-navigation-base/tab-strip-item'; export { TabView, TabViewItem } from './tab-view'; export { Tabs } from './tabs'; -export { TextBase } from './text-base'; +export { TextBase, TextTransform } from './text-base'; export { FormattedString } from './text-base/formatted-string'; export { Span } from './text-base/span'; export { TextField } from './text-field'; diff --git a/nativescript-core/ui/index.ts b/nativescript-core/ui/index.ts index 0e2efdb5d..8ce5ba729 100644 --- a/nativescript-core/ui/index.ts +++ b/nativescript-core/ui/index.ts @@ -1,10 +1,12 @@ export { ActionBar, ActionItem, ActionItems, NavigationButton } from './action-bar'; export { ActivityIndicator } from './activity-indicator'; -export { Animation, AnimationDefinition } from './animation'; +export { Animation, AnimationDefinition, KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './animation'; export { BottomNavigation, SelectedIndexChangedEventData } from './bottom-navigation'; export { Builder, LoadOptions } from './builder'; +export { sanitizeModuleName } from './builder/module-name-sanitizer'; export { Button } from './button'; export { ContentView } from './content-view'; +export { Binding, BindingOptions } from './core/bindable'; export { ViewBase, ShowModalOptions, eachDescendant, getAncestor, getViewById } from './core/view-base'; export { View, Template, KeyedTemplate, ShownModallyData } from './core/view'; export { Property, CoercibleProperty, InheritedProperty, CssProperty, InheritedCssProperty, ShorthandProperty, CssAnimationProperty, unsetValue } from './core/properties'; @@ -14,8 +16,7 @@ export { DatePicker } from './date-picker'; export { action, alert, confirm, login, prompt, getCurrentPage, Dialogs, DialogStrings, DialogOptions, CancelableOptions, AlertOptions, PromptResult, PromptOptions, ActionOptions, ConfirmOptions, LoginResult, LoginOptions, inputType, capitalizationType } from './dialogs'; export * from './editable-text-base'; -import * as enumsModule from './enums'; -export const Enums = enumsModule; +export { Enums } from './enums'; export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry } from './frame'; export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData } from './gestures'; @@ -29,7 +30,7 @@ export * from './layouts'; // barrel export export { ListPicker } from './list-picker'; export { ListView, ItemEventData, TemplatedItemsView, ItemsSource } from './list-view'; -export { Page, NavigatedData } from './page'; +export { Page, NavigatedData, PageBase } from './page'; export { Placeholder, CreateViewEventData } from './placeholder'; export { Progress } from './progress'; export { ProxyViewContainer } from './proxy-view-container'; @@ -41,8 +42,11 @@ export { Slider } from './slider'; // TODO: Consider adding APIs from style // export { addTaggedAdditionalCSS, removeTaggedAdditionalCSS } from "./styling/style-scope"; +export { animationTimingFunctionConverter, timeConverter } from './styling/converters'; export { Style, CommonLayoutParams } from './styling/style'; export * from './styling/style-properties'; +export { CssAnimationParser, parseKeyframeDeclarations } from './styling/css-animation-parser'; +export { CSSHelper } from './styling/css-selector'; export { Switch } from './switch'; export { TabContentItem } from './tab-navigation-base/tab-content-item'; diff --git a/nativescript-core/ui/page/index.d.ts b/nativescript-core/ui/page/index.d.ts index 06b2f27f8..e0c8d97f7 100644 --- a/nativescript-core/ui/page/index.d.ts +++ b/nativescript-core/ui/page/index.d.ts @@ -1,12 +1,14 @@ -import { CssProperty, Property } from '../core/properties'; +import { PageBase } from './page-common'; +import { CssProperty, Property } from '../core/properties'; import { Style } from '../styling/style'; import { EventData } from '../../data/observable'; -import { ContentView } from '../content-view'; import { Frame } from '../frame'; import { ActionBar } from '../action-bar'; import { KeyframeAnimationInfo } from '../animation/keyframe-animation'; import { Color } from '../../color'; +export * from './page-common'; + /** * Defines the data for the page navigation events. */ @@ -29,7 +31,7 @@ export module knownCollections { /** * Represents a logical unit for navigation (inside Frame). */ -export class Page extends ContentView { +export declare class Page extends PageBase { /** * String value used when hooking to navigatingTo event. */ diff --git a/nativescript-core/ui/page/page-common.d.ts b/nativescript-core/ui/page/page-common.d.ts new file mode 100644 index 000000000..62a3eaa85 --- /dev/null +++ b/nativescript-core/ui/page/page-common.d.ts @@ -0,0 +1,52 @@ +import { Page as PageDefinition } from '.'; +import { ContentView } from '../content-view'; +import { Frame } from '../frame'; +import { KeyframeAnimationInfo } from '../animation'; +import { NavigatedData } from '.'; +import { Color } from '../../color'; +import { ActionBar } from '../action-bar'; +import { View } from '../core/view'; +export declare class PageBase extends ContentView { + static navigatingToEvent: string; + static navigatedToEvent: string; + static navigatingFromEvent: string; + static navigatedFromEvent: string; + _frame: Frame; + actionBarHidden: boolean; + enableSwipeBackNavigation: boolean; + backgroundSpanUnderStatusBar: boolean; + hasActionBar: boolean; + readonly navigationContext: any; + + actionBar: ActionBar; + + statusBarStyle: 'light' | 'dark'; + androidStatusBarBackground: Color; + + readonly page: PageDefinition; + + _addChildFromBuilder(name: string, value: any): void; + + getKeyframeAnimationWithName(animationName: string): KeyframeAnimationInfo; + + readonly frame: Frame; + + createNavigatedData(eventName: string, isBackNavigation: boolean): NavigatedData { + return { + eventName: eventName, + object: this, + context: this.navigationContext, + isBackNavigation: isBackNavigation, + }; + } + + onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext?: any): void; + + onNavigatedTo(isBackNavigation: boolean): void; + + onNavigatingFrom(isBackNavigation: boolean): void; + + onNavigatedFrom(isBackNavigation: boolean): void; + + eachChildView(callback: (child: View) => boolean): void; +} diff --git a/nativescript-core/ui/page/page-common.ts b/nativescript-core/ui/page/page-common.ts index dfdb50ea7..96b224343 100644 --- a/nativescript-core/ui/page/page-common.ts +++ b/nativescript-core/ui/page/page-common.ts @@ -1,4 +1,4 @@ -import { Page as PageDefinition, NavigatedData } from '.'; +import { Page as PageDefinition } from '.'; import { ContentView } from '../content-view'; import { View, CSSType, ShownModallyData } from '../core/view'; import { booleanConverter } from '../core/view-base'; @@ -12,8 +12,13 @@ import { ActionBar } from '../action-bar'; import { KeyframeAnimationInfo } from '../animation/keyframe-animation'; import { profile } from '../../profiling'; +interface NavigatedData extends EventData { + context: any; + isBackNavigation: boolean; +} + @CSSType('Page') -export class PageBase extends ContentView implements PageDefinition { +export class PageBase extends ContentView { public static navigatingToEvent = 'navigatingTo'; public static navigatedToEvent = 'navigatedTo'; public static navigatingFromEvent = 'navigatingFrom'; diff --git a/nativescript-core/ui/styling/css-selector/index.ts b/nativescript-core/ui/styling/css-selector/index.ts index ddc97fc7f..8be899e2b 100644 --- a/nativescript-core/ui/styling/css-selector/index.ts +++ b/nativescript-core/ui/styling/css-selector/index.ts @@ -695,3 +695,21 @@ export class SelectorsMatch implements ChangeAccumulator { return set; } } + +export const CSSHelper = { + createSelector, + SelectorCore, + SimpleSelector, + InvalidSelector, + UniversalSelector, + TypeSelector, + ClassSelector, + AttributeSelector, + PseudoClassSelector, + SimpleSelectorSequence, + Selector, + RuleSet, + SelectorsMap, + fromAstNodes, + SelectorsMatch, +}; diff --git a/nativescript-core/ui/text-base/index.android.ts b/nativescript-core/ui/text-base/index.android.ts index dc1dd3fe3..558ebf9a9 100644 --- a/nativescript-core/ui/text-base/index.android.ts +++ b/nativescript-core/ui/text-base/index.android.ts @@ -10,7 +10,7 @@ import { colorProperty, fontSizeProperty, fontInternalProperty, paddingLeftPrope import { FormattedString } from './formatted-string'; import { Span } from './span'; import { layout } from '../../utils'; -import { isString } from '../../utils/types'; +import { isString, isNullOrUndefined } from '../../utils/types'; export * from './text-base-common'; @@ -40,7 +40,7 @@ function initializeTextTransformation(): void { return createSpannableStringBuilder(formattedText, (view).getTextSize()); } else { const text = this.textBase.text; - const stringValue = text === null || text === undefined ? '' : text.toString(); + const stringValue = isNullOrUndefined(text) ? '' : text.toString(); return getTransformedText(stringValue, this.textBase.textTransform); } diff --git a/nativescript-core/ui/text-base/index.ios.ts b/nativescript-core/ui/text-base/index.ios.ts index bbc6543ab..e7abbf2b0 100644 --- a/nativescript-core/ui/text-base/index.ios.ts +++ b/nativescript-core/ui/text-base/index.ios.ts @@ -8,7 +8,7 @@ import { Color } from '../../color'; import { FormattedString } from './formatted-string'; import { Span } from './span'; import { colorProperty, fontInternalProperty, VerticalAlignment } from '../styling/style-properties'; -import { isString } from '../../utils/types'; +import { isString, isDefined, isNullOrUndefined } from '../../utils/types'; import { ios } from '../../utils'; export * from './text-base-common'; @@ -307,7 +307,7 @@ export class TextBase extends TextBaseCommon { dict.set(NSParagraphStyleAttributeName, paragraphStyle); } - const source = getTransformedText(this.text ? this.text.toString() : '', this.textTransform); + const source = getTransformedText(isNullOrUndefined(this.text) ? '' : `${this.text}`, this.textTransform); if (dict.size > 0 || isTextView) { if (isTextView && this.nativeTextViewProtected.font) { // UITextView's font seems to change inside. @@ -349,7 +349,7 @@ export class TextBase extends TextBaseCommon { const span = formattedString.spans.getItem(i); const text = span.text; const textTransform = (formattedString.parent).textTransform; - let spanText = text === null || text === undefined ? '' : text.toString(); + let spanText = isNullOrUndefined(text) ? '' : `${text}`; if (textTransform !== 'none' && textTransform !== 'initial') { spanText = getTransformedText(spanText, textTransform); } diff --git a/nativescript-core/ui/text-base/span.ts b/nativescript-core/ui/text-base/span.ts index 1ccbff50d..ac8e6e6db 100644 --- a/nativescript-core/ui/text-base/span.ts +++ b/nativescript-core/ui/text-base/span.ts @@ -4,6 +4,7 @@ import { ViewBase } from '../core/view-base'; import { FontStyle, FontWeight } from '../styling/font'; import { TextDecoration } from '../text-base'; import { EventData } from '../../data/observable'; +import { isNullOrUndefined, isString } from '../../utils/types'; export class Span extends ViewBase implements SpanDefinition { static linkTapEvent = 'linkTap'; @@ -66,8 +67,12 @@ export class Span extends ViewBase implements SpanDefinition { } set text(value: string) { if (this._text !== value) { - // value can be a number - this._text = `${value}`.replace('\\n', '\n').replace('\\t', '\t'); + if (isNullOrUndefined(value)) { + this._text = ''; + } else { + // value can be a number + this._text = isString(value) ? `${value}`.replace('\\n', '\n').replace('\\t', '\t') : `${value}`; + } this.notifyPropertyChange('text', this._text); } } diff --git a/nativescript-core/ui/web-view/web-view-common.ts b/nativescript-core/ui/web-view/web-view-common.ts index 3857425f1..9ee5f41be 100644 --- a/nativescript-core/ui/web-view/web-view-common.ts +++ b/nativescript-core/ui/web-view/web-view-common.ts @@ -65,10 +65,15 @@ export abstract class WebViewBase extends ContainerView { [srcProperty.setNative](src: string) { this.stopLoading(); - // Add file:/// prefix for local files. + // Add file:// prefix for local files. // They should be loaded with _loadUrl() method as it handles query params. if (src.indexOf('~/') === 0) { - src = `file:///${knownFolders.currentApp().path}/` + src.substr(2); + let appPath = knownFolders.currentApp().path; + if (appPath && appPath.indexOf('/') !== 0) { + // ensure slash is correct + appPath = `/${appPath}`; + } + src = `file://${appPath}/` + src.substr(2); } else if (src.indexOf('/') === 0) { src = 'file://' + src; } diff --git a/nativescript-core/utils/index.android.ts b/nativescript-core/utils/index.android.ts index 5859d1101..66b809479 100644 --- a/nativescript-core/utils/index.android.ts +++ b/nativescript-core/utils/index.android.ts @@ -5,6 +5,7 @@ import { Trace } from '../trace'; export { ad } from './native-helper'; export * from './utils-common'; +export { Source } from './debug'; const MIN_URI_SHARE_RESTRICTED_APK_VERSION = 24; diff --git a/nativescript-core/utils/index.d.ts b/nativescript-core/utils/index.d.ts index 47561068a..9bc522137 100644 --- a/nativescript-core/utils/index.d.ts +++ b/nativescript-core/utils/index.d.ts @@ -1,6 +1,7 @@ import { dip, px } from '../ui/core/view'; export * from './mainthread-helper'; +export { Source } from './debug'; export const RESOURCE_PREFIX: string; export const FILE_PREFIX: string; diff --git a/nativescript-core/utils/index.ios.ts b/nativescript-core/utils/index.ios.ts index 6b75b4ca5..52fe8c479 100644 --- a/nativescript-core/utils/index.ios.ts +++ b/nativescript-core/utils/index.ios.ts @@ -3,6 +3,7 @@ import { Trace } from '../trace'; export { ios } from './native-helper'; export * from './utils-common'; +export { Source } from './debug'; export function openFile(filePath: string): boolean { try { diff --git a/nativescript-core/utils/types.ts b/nativescript-core/utils/types.ts index f20859c61..90e812909 100644 --- a/nativescript-core/utils/types.ts +++ b/nativescript-core/utils/types.ts @@ -27,7 +27,7 @@ export function isObject(value: any): boolean { } export function isUndefined(value: any): boolean { - return value === undefined; + return typeof value === 'undefined'; } export function isDefined(value: any): boolean { @@ -35,7 +35,7 @@ export function isDefined(value: any): boolean { } export function isNullOrUndefined(value: any): boolean { - return value === undefined || value === null; + return typeof value === 'undefined' || value === null; } export function verifyCallback(value: any) { diff --git a/package.json b/package.json index c899e38e6..7ea0a6626 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "NativeScript", "description": "NativeScript Core Modules", "homepage": "https://nativescript.org", - "version": "7.0.0-rc.6", + "version": "7.0.0-rc.9", "repository": { "type": "git", "url": "https://github.com/NativeScript/NativeScript" diff --git a/tests/app/App_Resources/iOS/Info.plist b/tests/app/App_Resources/iOS/Info.plist index ea3e3ea23..9c86c36ff 100644 --- a/tests/app/App_Resources/iOS/Info.plist +++ b/tests/app/App_Resources/iOS/Info.plist @@ -43,5 +43,14 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSAllowsArbitraryLoadsForMedia + + NSAllowsArbitraryLoadsInWebContent + + diff --git a/tests/app/data/observable-tests.ts b/tests/app/data/observable-tests.ts index e47e592fc..80512ff4b 100644 --- a/tests/app/data/observable-tests.ts +++ b/tests/app/data/observable-tests.ts @@ -1,10 +1,10 @@ // >> observable-require -import { Observable, fromObject, fromObjectRecursive, PropertyChangeData, EventData, WrappedValue } from "@nativescript/core/data/observable"; +import { Observable, PropertyChangeData, EventData, WrappedValue, fromObject, fromObjectRecursive } from "@nativescript/core"; // << observable-require import * as TKUnit from "../tk-unit"; import * as types from "@nativescript/core/utils/types"; -import { ObservableArray } from "@nativescript/core/data/observable-array"; +import { ObservableArray } from "@nativescript/core"; var TESTED_NAME = "tested"; class TestObservable extends Observable { diff --git a/tests/app/file-system-access-tests/file-system-access-tests.ts b/tests/app/file-system-access-tests/file-system-access-tests.ts index 380885ccd..bfde59ce7 100644 --- a/tests/app/file-system-access-tests/file-system-access-tests.ts +++ b/tests/app/file-system-access-tests/file-system-access-tests.ts @@ -1,18 +1,16 @@ import * as TKUnit from "../tk-unit"; -import * as fs from "@nativescript/core/file-system"; +import { knownFolders, path, File, Folder } from "@nativescript/core"; export var test_UTF8_BOM_is_not_returned = function () { - var path = fs.path.join(fs.knownFolders.currentApp().path, "file-system-access-tests", "xml.expected"); - if (!fs.File.exists(path)) { - TKUnit.assert(false, "Could not read file utf8.txt"); - - return; + const folder1 = path.join(knownFolders.documents().path, "file-system-access-tests"); + if (!Folder.exists(folder1)) { + Folder.fromPath(folder1); } - - var file = fs.File.fromPath(path); + var filePath = path.join(folder1, "xml.expected"); + var file = File.fromPath(filePath); var onError = function (error) { - TKUnit.assert(false, "Could not read file utf8.txt"); + TKUnit.assert(false, "Could not read file xml.expected"); }; var text = file.readTextSync(onError); @@ -24,21 +22,28 @@ export var test_UTF8_BOM_is_not_returned = function () { }; export var test_file_exists_on_folder = function () { - var path = fs.path.join(fs.knownFolders.currentApp().path, "file-system-access-tests", "folder"); + const folder1 = path.join(knownFolders.documents().path, "file-system-access-tests"); + if (!Folder.exists(folder1)) { + Folder.fromPath(folder1); + } + var filePath = path.join(folder1, "folder"); + if (!Folder.exists(filePath)) { + Folder.fromPath(filePath); + } - if (!fs.Folder.exists(path)) { - TKUnit.assert(false, `Could not read path ${path}`); + if (!Folder.exists(filePath)) { + TKUnit.assert(false, `Could not read path ${filePath}`); return; } - TKUnit.assertTrue(fs.File.exists(path), "File.exists() returned false for folder!"); + TKUnit.assertTrue(File.exists(filePath), "File.exists() returned false for folder!"); }; export var test_leading_slash_is_not_returned = function () { var parts = ["app", "tns_modules", "fileName"]; var expected = parts.join("/"); - var path = fs.path.join(...parts); + var filePath = path.join(...parts); - TKUnit.assertEqual(path, expected, "Leading slash should not be part of the path"); + TKUnit.assertEqual(filePath, expected, "Leading slash should not be part of the path"); }; diff --git a/tests/app/name-resolvers-tests/file-name-resolver-tests.ts b/tests/app/name-resolvers-tests/file-name-resolver-tests.ts deleted file mode 100644 index d974dbc03..000000000 --- a/tests/app/name-resolvers-tests/file-name-resolver-tests.ts +++ /dev/null @@ -1,42 +0,0 @@ -import * as TKUnit from "../tk-unit"; -import * as fs from "@nativescript/core/file-system"; -import { FileNameResolver } from "@nativescript/core/file-system/file-name-resolver"; -import { - androidPhonePortraitContext, - androidPhoneLandscapeContext, - androidTabletPortraitContext, - iPhoneLandscapeContext, - iPhonePortraitContext -} from "./qualifier-matcher-tests"; - -const testFilePath = "~/name-resolvers-tests/files/test".replace("~", fs.knownFolders.currentApp().path); - -export function test_file_resolver_with_android_phone_portrait() { - const fileResolver = new FileNameResolver(androidPhonePortraitContext); - const result = fileResolver.resolveFileName(testFilePath, "xml"); - TKUnit.assertEqual(result, testFilePath + ".xml", "File path"); -} - -export function test_file_resolver_with_android_phone_landscape() { - const fileResolver = new FileNameResolver(androidPhoneLandscapeContext); - const result = fileResolver.resolveFileName(testFilePath, "xml"); - TKUnit.assertEqual(result, testFilePath + ".land.xml", "File path"); -} - -export function test_file_resolver_with_android_tablet_portrait() { - const fileResolver = new FileNameResolver(androidTabletPortraitContext); - const result = fileResolver.resolveFileName(testFilePath, "xml"); - TKUnit.assertEqual(result, testFilePath + ".minWH600.xml", "File path"); -} - -export function test_file_resolver_with_ios_phone_landscape() { - const fileResolver = new FileNameResolver(iPhoneLandscapeContext); - const result = fileResolver.resolveFileName(testFilePath, "xml"); - TKUnit.assertEqual(result, testFilePath + ".land.xml", "File path"); -} - -export function test_file_resolver_with_ios_phone_portrait() { - const fileResolver = new FileNameResolver(iPhonePortraitContext); - const result = fileResolver.resolveFileName(testFilePath, "xml"); - TKUnit.assertEqual(result, testFilePath + ".xml", "File path"); -} diff --git a/tests/app/name-resolvers-tests/module-name-resolver-tests.ts b/tests/app/name-resolvers-tests/module-name-resolver-tests.ts index 5ffe9524a..e028631f9 100644 --- a/tests/app/name-resolvers-tests/module-name-resolver-tests.ts +++ b/tests/app/name-resolvers-tests/module-name-resolver-tests.ts @@ -1,5 +1,5 @@ import * as TKUnit from "../tk-unit"; -import { ModuleNameResolver, ModuleListProvider } from "@nativescript/core/module-name-resolver"; +import { ModuleNameResolver, ModuleListProvider } from "@nativescript/core"; import { androidPhonePortraitContext, diff --git a/tests/app/pages/file-load-test.ts b/tests/app/pages/file-load-test.ts index ce1270d7e..5901a7559 100644 --- a/tests/app/pages/file-load-test.ts +++ b/tests/app/pages/file-load-test.ts @@ -1,15 +1,13 @@ -import * as label from "@nativescript/core/ui/label"; -import * as pages from "@nativescript/core/ui/page"; -import * as fs from "@nativescript/core/file-system"; -import * as fileResolverModule from "@nativescript/core/file-system/file-name-resolver"; +import { Page, Label, knownFolders, path, ModuleNameResolver } from "@nativescript/core"; export function createPage() { - var page = new pages.Page(); - var lbl = new label.Label(); + var page = new Page(); + var lbl = new Label(); var moduleName = "tests/pages/files/test"; - var resolver = new fileResolverModule.FileNameResolver({ + ModuleNameResolver + var resolver = new ModuleNameResolver({ width: 400, height: 600, os: "android", @@ -17,8 +15,8 @@ export function createPage() { }); // Current app full path. - var currentAppPath = fs.knownFolders.currentApp().path; - var moduleNamePath = fs.path.join(currentAppPath, moduleName); + var currentAppPath = knownFolders.currentApp().path; + var moduleNamePath = path.join(currentAppPath, moduleName); var fileName = resolver.resolveFileName(moduleNamePath, "xml"); lbl.text = fileName; diff --git a/tests/app/test-runner.ts b/tests/app/test-runner.ts index 6c3e23c55..d3b97cc5c 100644 --- a/tests/app/test-runner.ts +++ b/tests/app/test-runner.ts @@ -2,29 +2,20 @@ import * as TKUnit from './tk-unit'; import './ui-test'; -import { _resetRootView } from '@nativescript/core/application'; -import * as platform from '@nativescript/core/platform'; -import { Trace } from '@nativescript/core/trace'; -import { Button } from '@nativescript/core/ui/button'; -import { Frame } from '@nativescript/core/ui/frame'; -import { StackLayout } from '@nativescript/core/ui/layouts/stack-layout'; -import { Page } from '@nativescript/core/ui/page'; -import { TextView } from '@nativescript/core/ui/text-view'; -import { ios } from '@nativescript/core/utils'; - +import { isIOS, Application, Device, platformNames, Trace, Button, Frame, StackLayout, Page, TextView, Utils } from '@nativescript/core'; Frame.defaultAnimatedNavigation = false; export function isRunningOnEmulator(): boolean { // These checks are not good enough to be added to modules but they keep unit tests green. - if (platform.Device.os === platform.platformNames.android) { + if (Device.os === platformNames.android) { return android.os.Build.FINGERPRINT.indexOf("generic") > -1 || android.os.Build.HARDWARE.toLowerCase() === "goldfish" || android.os.Build.HARDWARE.toLowerCase() === "donatello" || // VS Emulator android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("sdk") > -1 || android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("emulator") > -1; // VS Emulator } - else if (platform.Device.os === platform.platformNames.ios) { + else if (Device.os === platformNames.ios) { return (__dirname.search("Simulator") > -1); } } @@ -102,9 +93,6 @@ allTests["FILE-SYSTEM-ACCESS"] = fileSystemAccessTests; import * as qualifierMatcherTests from "./name-resolvers-tests/qualifier-matcher-tests"; allTests["QUALIFIER-MATCHER"] = qualifierMatcherTests; -import * as fileNameResolverTests from "./name-resolvers-tests/file-name-resolver-tests"; -allTests["FILE-NAME-RESOLVER"] = fileNameResolverTests; - import * as moduleNameResolverTests from "./name-resolvers-tests/module-name-resolver-tests"; allTests["MODULE-NAME-RESOLVER"] = moduleNameResolverTests; @@ -154,7 +142,7 @@ import * as scrollViewSafeAreaTests from "./ui/scroll-view/scroll-view-safe-area import * as repeaterSafeAreaTests from "./ui/repeater/repeater-safe-area-tests"; import * as webViewSafeAreaTests from "./ui/web-view/web-view-safe-area-tests"; -if (platform.isIOS && ios.MajorVersion > 10) { +if (isIOS && Utils.ios.MajorVersion > 10) { allTests["SAFEAREALAYOUT"] = safeAreaLayoutTests; allTests["SAFEAREA-LISTVIEW"] = safeAreaListViewtTests; allTests["SAFEAREA-SCROLL-VIEW"] = scrollViewSafeAreaTests; @@ -186,9 +174,6 @@ allTests["VISUAL-STATE"] = visualStateTests; import * as valueSourceTests from "./ui/styling/value-source-tests"; allTests["VALUE-SOURCE"] = valueSourceTests; -import * as borderTests from "./ui/border/border-tests"; -allTests["BORDER"] = borderTests; - import * as builderTests from "./ui/builder/builder-tests"; allTests["BUILDER"] = builderTests; @@ -397,7 +382,7 @@ function generateTestFile(allTests: TestInfo[]) { let testName = testCase.testName; let duration = (testCase.duration / 1000).toFixed(2); - testCases.push(``) + testCases.push(``) if (!testCase.isPassed) { failedTestCount++; testCases.push(``) @@ -436,7 +421,7 @@ function showReportPage(finalMessage: string) { page.content = stack; messageContainer.focus(); page.style.fontSize = 11; - if (platform.isAndroid) { + if (isAndroid) { page.on('navigatedTo', () => { messageContainer.focus(); setTimeout(() => messageContainer.dismissSoftInput()); diff --git a/tests/app/trace/trace-tests.ts b/tests/app/trace/trace-tests.ts index f6b749f60..af9f37817 100644 --- a/tests/app/trace/trace-tests.ts +++ b/tests/app/trace/trace-tests.ts @@ -4,7 +4,7 @@ import { Trace } from "@nativescript/core"; export var test_DummyTestForSnippetOnly0 = function () { // >> trace-all-categories - Trace.setCategories(Trace.categories.All); + Trace.setCategories(Trace.categories.All.join(',')); Trace.enable(); // << trace-all-categories }; @@ -20,7 +20,7 @@ export var test_DummyTestForSnippetOnly1 = function () { , Trace.categories.Style , Trace.categories.ViewHierarchy , Trace.categories.VisualTreeEvents - )); + ).join(',')); Trace.enable(); // << trace-specific-categories }; diff --git a/tests/app/ui-helper.ts b/tests/app/ui-helper.ts index 0f1bcac16..fdbe5a6f8 100644 --- a/tests/app/ui-helper.ts +++ b/tests/app/ui-helper.ts @@ -137,7 +137,7 @@ export function buildUIWithWeakRefAndInteract(createFunc: () => // An additional GC and wait are needed since WebKit upgrade to version 12.0 // (TEXT-FIELD.testMemoryLeak test started failing sporadically) Utils.GC(); - TKUnit.wait(0.1); + TKUnit.wait(0.2); } Utils.GC(); try { diff --git a/tests/app/ui/border/border-tests.ts b/tests/app/ui/border/border-tests.ts deleted file mode 100644 index c2542f8cb..000000000 --- a/tests/app/ui/border/border-tests.ts +++ /dev/null @@ -1,8 +0,0 @@ -// >> border-require -import { Border } from "@nativescript/core/ui/border"; -// << border-require -import * as helper from "../../ui-helper"; - -export function test_recycling() { - helper.nativeView_recycling_test(() => new Border()); -} diff --git a/tests/app/ui/border/border.md b/tests/app/ui/border/border.md deleted file mode 100644 index b8a3b0722..000000000 --- a/tests/app/ui/border/border.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -nav-title: "Border How-To" -title: "border" -environment: nativescript -description: "Examples for using Border" -previous_url: /ApiReference/ui/border/HOW-TO ---- -# Border -Using borders requires the Border module. -{%snippet border-require%} - -### Declaring a Border. -``` XML - - -