From 1525c8973351dc0269deeb129cc3d1a2bd2ec7cd Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sat, 4 Jul 2020 01:12:55 -0700 Subject: [PATCH] chore: cleanup --- api-reports/NativeScript.api.md | 66 ++-- .../animation-frame/animation-frame.d.ts | 5 - .../application-settings.d.ts | 5 - .../application/application.d.ts | 11 +- nativescript-core/color/color.d.ts | 5 - nativescript-core/color/known-colors.d.ts | 6 +- .../connectivity/connectivity.d.ts | 5 - .../css-value/reworkcss-value.d.ts | 4 - nativescript-core/css/reworkcss.d.ts | 4 - nativescript-core/css/system-classes.d.ts | 5 - .../observable-array/observable-array.d.ts | 7 +- .../data/observable/observable.d.ts | 5 - .../data/virtual-array/virtual-array.d.ts | 8 +- .../file-name-resolver.d.ts | 8 +- .../file-system/file-system-access.d.ts | 4 - .../file-system/file-system.d.ts | 5 - nativescript-core/fps-meter/fps-meter.d.ts | 5 - nativescript-core/fps-meter/fps-native.d.ts | 4 - nativescript-core/globals/Readme.md | 9 - .../globals/{core/globals-core.ts => core.ts} | 1 - .../globals/core/globals-core.d.ts | 6 - nativescript-core/globals/core/package.json | 6 - nativescript-core/globals/globals.ts | 10 - .../globals/{globals.d.ts => index.d.ts} | 2 +- nativescript-core/globals/index.ts | 78 +++++ nativescript-core/globals/package.json | 6 - .../polyfills/animation/animation.d.ts | 5 - .../globals/polyfills/animation/animation.ts | 6 - .../globals/polyfills/animation/package.json | 6 - .../globals/polyfills/dialogs/dialogs.d.ts | 5 - .../globals/polyfills/dialogs/dialogs.ts | 6 - .../globals/polyfills/dialogs/package.json | 6 - .../globals/polyfills/fetch/fetch.d.ts | 6 - .../globals/polyfills/fetch/fetch.ts | 8 - .../globals/polyfills/fetch/package.json | 6 - .../polyfills/polyfill-helpers/package.json | 6 - .../polyfill-helpers/polyfill-helpers.d.ts | 6 - .../polyfill-helpers/polyfill-helpers.ts | 26 -- .../globals/polyfills/text/package.json | 5 - .../globals/polyfills/text/text.ts | 8 - .../globals/polyfills/timers/package.json | 6 - .../globals/polyfills/timers/timers.d.ts | 5 - .../globals/polyfills/timers/timers.ts | 6 - .../globals/polyfills/xhr/package.json | 6 - .../globals/polyfills/xhr/xhr.d.ts | 5 - .../globals/polyfills/xhr/xhr.ts | 6 - .../http/http-request/http-request.d.ts | 6 +- nativescript-core/http/http.d.ts | 7 +- .../image-asset/image-asset.d.ts | 4 - .../image-source/image-source.d.ts | 7 +- nativescript-core/index.d.ts | 2 - nativescript-core/index.ts | 6 +- .../js-libs/easysax/easysax.d.ts | 7 +- .../js-libs/esprima/esprima.d.ts | 6 +- .../polymer-expressions.d.ts | 7 +- nativescript-core/matrix/matrix.d.ts | 3 +- .../module-name-resolver.d.ts | 3 +- .../module-name-resolver.ts | 10 +- .../non-bundle-workflow-compat.ts | 16 +- .../qualifier-matcher/qualifier-matcher.d.ts | 3 +- nativescript-core/module.d.ts | 1 - nativescript-core/package.json | 26 +- nativescript-core/platform/platform.d.ts | 3 +- nativescript-core/profiling/profiling.d.ts | 3 +- nativescript-core/references.d.ts | 2 + nativescript-core/text/formatted-string.d.ts | 7 +- nativescript-core/text/span.d.ts | 6 +- nativescript-core/text/text.d.ts | 7 +- nativescript-core/timer/timer.d.ts | 5 - nativescript-core/tns-core-modules.d.ts | 3 - nativescript-core/trace/Readme.md | 33 +- nativescript-core/trace/index.ts | 299 ++++++++++++++++++ nativescript-core/trace/package.json | 6 - nativescript-core/trace/trace.d.ts | 146 --------- nativescript-core/trace/trace.ts | 216 ------------- nativescript-core/tsconfig.barrels.json | 9 +- nativescript-core/tsconfig.json | 7 +- .../ui/action-bar/action-bar-common.ts | 29 +- .../ui/action-bar/action-bar.android.ts | 6 +- .../ui/action-bar/action-bar.d.ts | 9 +- .../activity-indicator-common.ts | 2 - .../activity-indicator.d.ts | 7 +- .../ui/animation/animation-common.ts | 14 +- .../ui/animation/animation.android.ts | 61 ++-- nativescript-core/ui/animation/animation.d.ts | 7 +- .../ui/animation/animation.ios.ts | 38 +-- .../ui/animation/keyframe-animation.d.ts | 4 - .../ui/animation/keyframe-animation.ts | 13 +- nativescript-core/ui/border/border.d.ts | 7 +- .../bottom-navigation.android.ts | 15 +- .../bottom-navigation/bottom-navigation.d.ts | 10 +- .../bottom-navigation.ios.ts | 40 +-- .../ui/builder/binding-builder.d.ts | 7 +- nativescript-core/ui/builder/builder.d.ts | 6 +- .../component-builder/component-builder.d.ts | 4 - .../ui/builder/module-name-sanitizer.d.ts | 4 - nativescript-core/ui/button/button-common.ts | 4 +- .../{button.android.ts => index.android.ts} | 0 .../ui/button/{button.d.ts => index.d.ts} | 8 +- .../ui/button/{button.ios.ts => index.ios.ts} | 0 nativescript-core/ui/button/package.json | 5 - .../ui/content-view/content-view.d.ts | 33 -- .../{content-view.ts => index.ts} | 20 +- .../ui/content-view/package.json | 5 - .../ui/core/bindable/bindable.d.ts | 71 ----- .../core/bindable/{bindable.ts => index.ts} | 62 +++- .../ui/core/bindable/package.json | 5 - .../control-state-change.d.ts | 4 - .../properties/{properties.ts => index.ts} | 84 +++-- .../ui/core/properties/package.json | 5 - .../ui/core/properties/properties.d.ts | 165 ---------- .../ui/core/view-base/view-base.d.ts | 17 +- .../ui/core/view-base/view-base.ts | 23 +- nativescript-core/ui/core/view/view-common.ts | 32 +- ...iew-helper.android.ts => index.android.ts} | 0 .../{view-helper.d.ts => index.d.ts} | 2 +- .../{view-helper.ios.ts => index.ios.ts} | 35 +- .../ui/core/view/view-helper/package.json | 5 - .../view/view-helper/view-helper-common.ts | 12 +- .../ui/core/view/view.android.ts | 18 +- nativescript-core/ui/core/view/view.d.ts | 15 +- nativescript-core/ui/core/view/view.ios.ts | 58 ++-- .../weak-event-listener.d.ts | 4 - .../ui/date-picker/date-picker-common.ts | 3 +- ...ate-picker.android.ts => index.android.ts} | 0 .../{date-picker.d.ts => index.d.ts} | 8 +- .../{date-picker.ios.ts => index.ios.ts} | 4 +- nativescript-core/ui/date-picker/package.json | 5 - .../ui/dialogs/dialogs-common.ts | 158 ++++++++- .../{dialogs.android.ts => index.android.ts} | 2 +- .../ui/dialogs/{dialogs.d.ts => index.d.ts} | 6 +- .../dialogs/{dialogs.ios.ts => index.ios.ts} | 42 +-- nativescript-core/ui/dialogs/package.json | 5 - .../editable-text-base-common.ts | 7 +- .../editable-text-base.d.ts | 10 +- nativescript-core/ui/enums/enums.d.ts | 6 +- .../ui/frame/fragment.transitions.android.ts | 64 ++-- .../ui/frame/fragment.transitions.d.ts | 8 +- .../ui/frame/fragment.transitions.ios.ts | 14 +- .../ui/frame/fragment.transitions.types.ts | 4 - nativescript-core/ui/frame/frame-common.ts | 32 +- nativescript-core/ui/frame/frame.android.ts | 85 ++--- nativescript-core/ui/frame/frame.d.ts | 13 +- nativescript-core/ui/frame/frame.ios.ts | 81 +++-- .../frame/transition-definitions.android.d.ts | 5 - nativescript-core/ui/gestures/gestures.d.ts | 8 +- .../ui/html-view/html-view-common.ts | 6 +- ...{html-view.android.ts => index.android.ts} | 0 .../html-view/{html-view.d.ts => index.d.ts} | 8 +- .../{html-view.ios.ts => index.ios.ts} | 5 +- nativescript-core/ui/html-view/package.json | 5 - .../ui/image-cache/image-cache.d.ts | 7 +- nativescript-core/ui/image/image-common.ts | 15 +- nativescript-core/ui/image/image.d.ts | 11 +- nativescript-core/ui/image/image.ios.ts | 13 +- nativescript-core/ui/index.ts | 5 +- nativescript-core/ui/label/label.d.ts | 7 +- .../absolute-layout/absolute-layout.d.ts | 9 +- .../ui/layouts/dock-layout/dock-layout.d.ts | 8 +- .../flexbox-layout/flexbox-layout.d.ts | 9 +- .../ui/layouts/grid-layout/grid-layout.d.ts | 8 +- .../ui/layouts/layout-base-common.ts | 7 +- nativescript-core/ui/layouts/layout-base.d.ts | 10 +- .../ui/layouts/stack-layout/stack-layout.d.ts | 6 +- .../ui/layouts/wrap-layout/wrap-layout.d.ts | 8 +- ...ist-picker.android.ts => index.android.ts} | 5 +- .../{list-picker.d.ts => index.d.ts} | 14 +- .../{list-picker.ios.ts => index.ios.ts} | 5 +- .../ui/list-picker/list-picker-common.ts | 11 +- nativescript-core/ui/list-picker/package.json | 5 - ...{list-view.android.ts => index.android.ts} | 0 .../list-view/{list-view.d.ts => index.d.ts} | 12 +- .../{list-view.ios.ts => index.ios.ts} | 15 +- .../ui/list-view/list-view-common.ts | 9 +- nativescript-core/ui/list-view/package.json | 5 - .../{page.android.ts => index.android.ts} | 4 +- .../ui/page/{page.d.ts => index.d.ts} | 16 +- .../ui/page/{page.ios.ts => index.ios.ts} | 6 +- nativescript-core/ui/page/package.json | 5 - ...laceholder.android.ts => index.android.ts} | 9 +- .../{placeholder.d.ts => index.d.ts} | 8 +- .../placeholder/{placeholder.ts => index.ts} | 9 +- nativescript-core/ui/placeholder/package.json | 5 - .../ui/placeholder/placeholder-common.ts | 13 + .../{progress.android.ts => index.android.ts} | 0 .../ui/progress/{progress.d.ts => index.d.ts} | 8 +- .../{progress.ios.ts => index.ios.ts} | 0 nativescript-core/ui/progress/package.json | 5 - .../ui/progress/progress-common.ts | 5 +- .../{proxy-view-container.ts => index.ts} | 23 +- .../ui/proxy-view-container/package.json | 5 - .../proxy-view-container.d.ts | 8 - .../ui/repeater/{repeater.ts => index.ts} | 31 +- nativescript-core/ui/repeater/package.json | 5 - nativescript-core/ui/repeater/repeater.d.ts | 52 --- ...croll-view.android.ts => index.android.ts} | 0 .../{scroll-view.d.ts => index.d.ts} | 9 +- .../{scroll-view.ios.ts => index.ios.ts} | 5 +- nativescript-core/ui/scroll-view/package.json | 5 - .../ui/search-bar/search-bar-common.ts | 7 +- .../ui/search-bar/search-bar.android.ts | 8 +- .../ui/search-bar/search-bar.d.ts | 10 +- .../ui/segmented-bar/segmented-bar-common.ts | 20 +- .../ui/segmented-bar/segmented-bar.d.ts | 115 +++---- nativescript-core/ui/slider/slider-common.ts | 6 +- nativescript-core/ui/slider/slider.d.ts | 8 +- nativescript-core/ui/styling/background.d.ts | 8 +- nativescript-core/ui/styling/converters.d.ts | 6 - .../ui/styling/css-animation-parser.d.ts | 7 - .../ui/styling/css-selector/css-selector.d.ts | 84 ----- .../{css-selector.ts => index.ts} | 37 ++- .../ui/styling/css-selector/package.json | 5 - nativescript-core/ui/styling/font.android.ts | 10 +- nativescript-core/ui/styling/font.d.ts | 6 +- nativescript-core/ui/styling/font.ios.ts | 6 +- nativescript-core/ui/styling/gradient.d.ts | 4 - .../ui/styling/style-properties.d.ts | 7 +- .../ui/styling/style-properties.ts | 31 +- nativescript-core/ui/styling/style-scope.d.ts | 7 +- nativescript-core/ui/styling/style-scope.ts | 32 +- .../ui/styling/style/{style.ts => index.ts} | 19 +- .../ui/styling/style/package.json | 5 - nativescript-core/ui/styling/style/style.d.ts | 234 -------------- nativescript-core/ui/switch/switch-common.ts | 6 +- nativescript-core/ui/switch/switch.d.ts | 8 +- .../tab-content-item.android.ts | 9 +- .../tab-content-item/tab-content-item.d.ts | 8 +- .../tab-navigation-base.d.ts | 14 +- .../tab-strip-item/tab-strip-item.d.ts | 8 +- .../tab-strip/tab-strip.d.ts | 11 +- .../ui/tab-view/tab-view-common.ts | 15 +- .../ui/tab-view/tab-view.android.ts | 21 +- nativescript-core/ui/tab-view/tab-view.d.ts | 10 +- nativescript-core/ui/tab-view/tab-view.ios.ts | 50 +-- nativescript-core/ui/tabs/tabs.android.ts | 8 +- nativescript-core/ui/tabs/tabs.d.ts | 6 +- nativescript-core/ui/tabs/tabs.ios.ts | 28 +- .../ui/text-base/formatted-string.d.ts | 7 +- .../ui/text-base/formatted-string.ts | 7 +- ...{text-base.android.ts => index.android.ts} | 0 .../text-base/{text-base.d.ts => index.d.ts} | 12 +- .../{text-base.ios.ts => index.ios.ts} | 14 +- nativescript-core/ui/text-base/package.json | 5 - nativescript-core/ui/text-base/span.d.ts | 6 +- nativescript-core/ui/text-base/span.ts | 5 +- .../ui/text-base/text-base-common.ts | 31 +- .../ui/text-field/text-field-common.ts | 5 +- .../ui/text-field/text-field.d.ts | 8 +- nativescript-core/ui/text-view/text-view.d.ts | 9 +- .../ui/time-picker/time-picker-common.ts | 3 +- .../ui/time-picker/time-picker.d.ts | 8 +- .../ui/transition/fade-transition.d.ts | 6 +- .../ui/transition/flip-transition.d.ts | 6 +- .../ui/transition/slide-transition.d.ts | 6 +- .../ui/transition/transition.d.ts | 6 +- nativescript-core/ui/utils.d.ts | 8 +- .../ui/web-view/web-view-common.ts | 20 +- .../ui/web-view/web-view.android.ts | 30 +- nativescript-core/ui/web-view/web-view.d.ts | 7 +- nativescript-core/ui/web-view/web-view.ios.ts | 25 +- nativescript-core/utils/debug.d.ts | 4 - ...out-helper.android.ts => index.android.ts} | 0 .../{layout-helper.d.ts => index.d.ts} | 0 .../{layout-helper.ios.ts => index.ios.ts} | 0 .../utils/layout-helper/package.json | 6 - nativescript-core/utils/lazy.d.ts | 4 - .../utils/native-helper.android.ts | 6 +- nativescript-core/utils/native-helper.ios.ts | 6 +- nativescript-core/utils/package.json | 3 - nativescript-core/utils/types.d.ts | 4 - nativescript-core/utils/utils.android.ts | 30 +- nativescript-core/utils/utils.d.ts | 4 - nativescript-core/utils/utils.ios.ts | 6 +- nativescript-core/xml/xml.d.ts | 3 +- 274 files changed, 1755 insertions(+), 2733 deletions(-) delete mode 100644 nativescript-core/globals/Readme.md rename nativescript-core/globals/{core/globals-core.ts => core.ts} (99%) delete mode 100644 nativescript-core/globals/core/globals-core.d.ts delete mode 100644 nativescript-core/globals/core/package.json delete mode 100644 nativescript-core/globals/globals.ts rename nativescript-core/globals/{globals.d.ts => index.d.ts} (71%) create mode 100644 nativescript-core/globals/index.ts delete mode 100644 nativescript-core/globals/package.json delete mode 100644 nativescript-core/globals/polyfills/animation/animation.d.ts delete mode 100644 nativescript-core/globals/polyfills/animation/animation.ts delete mode 100644 nativescript-core/globals/polyfills/animation/package.json delete mode 100644 nativescript-core/globals/polyfills/dialogs/dialogs.d.ts delete mode 100644 nativescript-core/globals/polyfills/dialogs/dialogs.ts delete mode 100644 nativescript-core/globals/polyfills/dialogs/package.json delete mode 100644 nativescript-core/globals/polyfills/fetch/fetch.d.ts delete mode 100644 nativescript-core/globals/polyfills/fetch/fetch.ts delete mode 100644 nativescript-core/globals/polyfills/fetch/package.json delete mode 100644 nativescript-core/globals/polyfills/polyfill-helpers/package.json delete mode 100644 nativescript-core/globals/polyfills/polyfill-helpers/polyfill-helpers.d.ts delete mode 100644 nativescript-core/globals/polyfills/polyfill-helpers/polyfill-helpers.ts delete mode 100644 nativescript-core/globals/polyfills/text/package.json delete mode 100644 nativescript-core/globals/polyfills/text/text.ts delete mode 100644 nativescript-core/globals/polyfills/timers/package.json delete mode 100644 nativescript-core/globals/polyfills/timers/timers.d.ts delete mode 100644 nativescript-core/globals/polyfills/timers/timers.ts delete mode 100644 nativescript-core/globals/polyfills/xhr/package.json delete mode 100644 nativescript-core/globals/polyfills/xhr/xhr.d.ts delete mode 100644 nativescript-core/globals/polyfills/xhr/xhr.ts create mode 100644 nativescript-core/trace/index.ts delete mode 100644 nativescript-core/trace/package.json delete mode 100644 nativescript-core/trace/trace.d.ts delete mode 100644 nativescript-core/trace/trace.ts rename nativescript-core/ui/button/{button.android.ts => index.android.ts} (100%) rename nativescript-core/ui/button/{button.d.ts => index.d.ts} (90%) rename nativescript-core/ui/button/{button.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/ui/button/package.json delete mode 100644 nativescript-core/ui/content-view/content-view.d.ts rename nativescript-core/ui/content-view/{content-view.ts => index.ts} (81%) delete mode 100644 nativescript-core/ui/content-view/package.json delete mode 100644 nativescript-core/ui/core/bindable/bindable.d.ts rename nativescript-core/ui/core/bindable/{bindable.ts => index.ts} (91%) delete mode 100644 nativescript-core/ui/core/bindable/package.json rename nativescript-core/ui/core/properties/{properties.ts => index.ts} (94%) delete mode 100644 nativescript-core/ui/core/properties/package.json delete mode 100644 nativescript-core/ui/core/properties/properties.d.ts rename nativescript-core/ui/core/view/view-helper/{view-helper.android.ts => index.android.ts} (100%) rename nativescript-core/ui/core/view/view-helper/{view-helper.d.ts => index.d.ts} (99%) rename nativescript-core/ui/core/view/view-helper/{view-helper.ios.ts => index.ios.ts} (92%) delete mode 100644 nativescript-core/ui/core/view/view-helper/package.json rename nativescript-core/ui/date-picker/{date-picker.android.ts => index.android.ts} (100%) rename nativescript-core/ui/date-picker/{date-picker.d.ts => index.d.ts} (91%) rename nativescript-core/ui/date-picker/{date-picker.ios.ts => index.ios.ts} (96%) delete mode 100644 nativescript-core/ui/date-picker/package.json rename nativescript-core/ui/dialogs/{dialogs.android.ts => index.android.ts} (99%) rename nativescript-core/ui/dialogs/{dialogs.d.ts => index.d.ts} (98%) rename nativescript-core/ui/dialogs/{dialogs.ios.ts => index.ios.ts} (95%) delete mode 100644 nativescript-core/ui/dialogs/package.json rename nativescript-core/ui/html-view/{html-view.android.ts => index.android.ts} (100%) rename nativescript-core/ui/html-view/{html-view.d.ts => index.d.ts} (85%) rename nativescript-core/ui/html-view/{html-view.ios.ts => index.ios.ts} (97%) delete mode 100644 nativescript-core/ui/html-view/package.json rename nativescript-core/ui/list-picker/{list-picker.android.ts => index.android.ts} (97%) rename nativescript-core/ui/list-picker/{list-picker.d.ts => index.d.ts} (83%) rename nativescript-core/ui/list-picker/{list-picker.ios.ts => index.ios.ts} (94%) delete mode 100644 nativescript-core/ui/list-picker/package.json rename nativescript-core/ui/list-view/{list-view.android.ts => index.android.ts} (100%) rename nativescript-core/ui/list-view/{list-view.d.ts => index.d.ts} (95%) rename nativescript-core/ui/list-view/{list-view.ios.ts => index.ios.ts} (97%) delete mode 100644 nativescript-core/ui/list-view/package.json rename nativescript-core/ui/page/{page.android.ts => index.android.ts} (95%) rename nativescript-core/ui/page/{page.d.ts => index.d.ts} (94%) rename nativescript-core/ui/page/{page.ios.ts => index.ios.ts} (99%) delete mode 100644 nativescript-core/ui/page/package.json rename nativescript-core/ui/placeholder/{placeholder.android.ts => index.android.ts} (68%) rename nativescript-core/ui/placeholder/{placeholder.d.ts => index.d.ts} (87%) rename nativescript-core/ui/placeholder/{placeholder.ts => index.ts} (67%) delete mode 100644 nativescript-core/ui/placeholder/package.json create mode 100644 nativescript-core/ui/placeholder/placeholder-common.ts rename nativescript-core/ui/progress/{progress.android.ts => index.android.ts} (100%) rename nativescript-core/ui/progress/{progress.d.ts => index.d.ts} (86%) rename nativescript-core/ui/progress/{progress.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/ui/progress/package.json rename nativescript-core/ui/proxy-view-container/{proxy-view-container.ts => index.ts} (84%) delete mode 100644 nativescript-core/ui/proxy-view-container/package.json delete mode 100644 nativescript-core/ui/proxy-view-container/proxy-view-container.d.ts rename nativescript-core/ui/repeater/{repeater.ts => index.ts} (86%) delete mode 100644 nativescript-core/ui/repeater/package.json delete mode 100644 nativescript-core/ui/repeater/repeater.d.ts rename nativescript-core/ui/scroll-view/{scroll-view.android.ts => index.android.ts} (100%) rename nativescript-core/ui/scroll-view/{scroll-view.d.ts => index.d.ts} (91%) rename nativescript-core/ui/scroll-view/{scroll-view.ios.ts => index.ios.ts} (97%) delete mode 100644 nativescript-core/ui/scroll-view/package.json delete mode 100644 nativescript-core/ui/styling/css-selector/css-selector.d.ts rename nativescript-core/ui/styling/css-selector/{css-selector.ts => index.ts} (96%) delete mode 100644 nativescript-core/ui/styling/css-selector/package.json rename nativescript-core/ui/styling/style/{style.ts => index.ts} (93%) delete mode 100644 nativescript-core/ui/styling/style/package.json delete mode 100644 nativescript-core/ui/styling/style/style.d.ts rename nativescript-core/ui/text-base/{text-base.android.ts => index.android.ts} (100%) rename nativescript-core/ui/text-base/{text-base.d.ts => index.d.ts} (93%) rename nativescript-core/ui/text-base/{text-base.ios.ts => index.ios.ts} (97%) delete mode 100644 nativescript-core/ui/text-base/package.json rename nativescript-core/utils/layout-helper/{layout-helper.android.ts => index.android.ts} (100%) rename nativescript-core/utils/layout-helper/{layout-helper.d.ts => index.d.ts} (100%) rename nativescript-core/utils/layout-helper/{layout-helper.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/utils/layout-helper/package.json delete mode 100644 nativescript-core/utils/package.json diff --git a/api-reports/NativeScript.api.md b/api-reports/NativeScript.api.md index 9c0d3c5d7..0a82f4aef 100644 --- a/api-reports/NativeScript.api.md +++ b/api-reports/NativeScript.api.md @@ -212,7 +212,7 @@ export class AndroidApplication extends Observable { } // @public -export class Animation { +class Animation_2 { constructor(animationDefinitions: Array, playSequentially?: boolean); // (undocumented) public cancel: () => void; @@ -226,6 +226,8 @@ export class Animation { public _resolveAnimationCurve(curve: any): any; } +export { Animation_2 as Animation } + // @public export interface AnimationDefinition { backgroundColor?: Color; @@ -276,12 +278,12 @@ export const Application: { addCss: typeof addCss; on: typeof on; off: typeof off; - run: typeof run; - orientation: typeof orientation; + run: typeof run_2; + orientation: typeof orientation_2; getNativeApplication: typeof getNativeApplication; hasLaunched: typeof hasLaunched; - android: import("./application/application").AndroidApplication; - ios: import("./application/application").iOSApplication; + android: AndroidApplication; + ios: iOSApplication; }; // @public @@ -300,7 +302,7 @@ export const ApplicationSettings: { clear: typeof clear; flush: typeof flush; hasKey: typeof hasKey; - remove: typeof remove; + remove: typeof remove_2; setString: typeof setString; getString: typeof getString; getAllKeys: typeof getAllKeys; @@ -620,12 +622,12 @@ export interface EventData { } // @public -export class File extends FileSystemEntity { +class File_2 extends FileSystemEntity { static exists(path: string): boolean; extension: string; - static fromPath(path: string): File; + static fromPath(path: string): File_2; isLocked: boolean; @@ -648,6 +650,8 @@ export class File extends FileSystemEntity { writeTextSync(content: string, onError?: (error: any) => any, encoding?: string): void; } +export { File_2 as File } + // @public export class FileSystemEntity { lastModified: Date; @@ -731,7 +735,7 @@ export class Folder extends FileSystemEntity { getEntitiesSync(onError?: (error: any) => any): Array; - getFile(name: string): File; + getFile(name: string): File_2; getFolder(name: string): Folder; @@ -852,7 +856,7 @@ export class Frame extends View { // Warning: (ae-forgotten-export) The symbol "NavigationType" needs to be exported by the entry point index.d.ts // // (undocumented) - setCurrent(entry: BackstackEntry, navigationType: NavigationType): void; + setCurrent(entry: BackstackEntry, navigationType: NavigationType_2): void; // (undocumented) static _stack(): Array; @@ -865,7 +869,7 @@ export class Frame extends View { _updateActionBar(page?: Page, disableNavBarAnimation?: boolean); // (undocumented) - _updateBackstack(entry: BackstackEntry, navigationType: NavigationType): void; + _updateBackstack(entry: BackstackEntry, navigationType: NavigationType_2): void; } // @public @@ -989,7 +993,9 @@ export namespace GridUnitType { } // @public (undocumented) -export type Headers = { [key: string]: string | string[] }; +type Headers_2 = { [key: string]: string | string[] }; + +export { Headers_2 as Headers } // @public export class HtmlView extends View { @@ -1015,7 +1021,7 @@ export interface HttpContent { toArrayBuffer: () => ArrayBuffer; - toFile: (destinationFilePath?: string) => File; + toFile: (destinationFilePath?: string) => File_2; toImage: () => Promise; @@ -1043,7 +1049,7 @@ export interface HttpRequestOptions { export interface HttpResponse { content?: HttpContent; - headers: Headers; + headers: Headers_2; statusCode: number; } @@ -1057,7 +1063,7 @@ export enum HttpResponseEncoding { } // @public -export class Image extends View { +class Image_2 extends View { android: any /* android.widget.ImageView */; decodeHeight: Length; @@ -1080,6 +1086,8 @@ export class Image extends View { tintColor: Color; } +export { Image_2 as Image } + // @public (undocumented) export class ImageAsset extends Observable { constructor(asset: any); @@ -1437,7 +1445,7 @@ export interface NavigationContext { // (undocumented) isBackNavigation: boolean; // (undocumented) - navigationType: NavigationType; + navigationType: NavigationType_2; } // @public @@ -1666,7 +1674,7 @@ export interface ParserEvent { namespace?: string; // Warning: (ae-forgotten-export) The symbol "Position" needs to be exported by the entry point index.d.ts - position: Position; + position: Position_2; prefix?: string; @@ -1721,10 +1729,10 @@ export class Placeholder extends View { export const Profiling: { enable: typeof enable; disable: typeof disable; - time: typeof time; + time: typeof time_2; uptime: typeof uptime; start: typeof start; - stop: typeof stop; + stop: typeof stop_2; isRunning: typeof isRunning; dumpProfiles: typeof dumpProfiles; resetProfiles: typeof resetProfiles; @@ -1774,11 +1782,13 @@ export interface RotationGestureEventData extends GestureEventDataWithState { } // @public -export module Screen { +module Screen_2 { const // Warning: (ae-forgotten-export) The symbol "ScreenMetrics" needs to be exported by the entry point index.d.ts mainScreen: ScreenMetrics; } +export { Screen_2 as Screen } + // @public (undocumented) export interface ScrollEventData extends EventData { // (undocumented) @@ -2350,7 +2360,7 @@ export class TabStripItem extends View { iconSource: string; - image: Image; + image: Image_2; // (undocumented) _index: number; @@ -2575,7 +2585,7 @@ export const Trace: { removeWriter: typeof removeWriter; clearWriters: typeof clearWriters; setErrorHandler: typeof setErrorHandler; - write: typeof write; + write: typeof write_2; error: typeof error; enable: typeof enable_2; disable: typeof disable_2; @@ -2666,7 +2676,7 @@ export abstract class View extends ViewBase { color: Color; // (undocumented) public static combineMeasuredStates(curState: number, newState): number; - public createAnimation(options: AnimationDefinition): Animation; + public createAnimation(options: AnimationDefinition): Animation_2; css: string; // (undocumented) cssClasses: Set; @@ -2691,9 +2701,9 @@ export abstract class View extends ViewBase { // (undocumented) public getGestureObservers(type: GestureTypes): Array; // Warning: (ae-forgotten-export) The symbol "Point" needs to be exported by the entry point index.d.ts - public getLocationInWindow(): Point; - public getLocationOnScreen(): Point; - public getLocationRelativeTo(otherView: View): Point; + public getLocationInWindow(): Point_2; + public getLocationOnScreen(): Point_2; + public getLocationRelativeTo(otherView: View): Point_2; public getMeasuredHeight(): number; // (undocumented) public getMeasuredState(): number; @@ -2756,7 +2766,7 @@ export abstract class View extends ViewBase { // (undocumented) _redrawNativeBackground(value: any): void; // (undocumented) - _removeAnimation(animation: Animation): boolean; + _removeAnimation(animation: Animation_2): boolean; public static resolveSizeAndState(size: number, specSize: number, specMode: number, childMeasuredState: number): number; rotate: number; rotateX: number; @@ -3043,7 +3053,7 @@ export class WrapLayout extends LayoutBase { // @public export class XmlParser { - constructor(onEvent: (event: ParserEvent) => void, onError?: (error: Error, position: Position) => void, processNamespaces?: boolean, angularSyntax?: boolean); + constructor(onEvent: (event: ParserEvent) => void, onError?: (error: Error, position: Position_2) => void, processNamespaces?: boolean, angularSyntax?: boolean); parse(xmlString: string): void; } diff --git a/nativescript-core/animation-frame/animation-frame.d.ts b/nativescript-core/animation-frame/animation-frame.d.ts index c899d0901..c5ebe7b16 100644 --- a/nativescript-core/animation-frame/animation-frame.d.ts +++ b/nativescript-core/animation-frame/animation-frame.d.ts @@ -1,8 +1,3 @@ -/** - * Allows you to create, cancel and react to listeners to animation frames. - * @module "animation-frame" - */ /** */ - /** * Callback called on frame rendered * @argument time Time of the current frame in milliseconds diff --git a/nativescript-core/application-settings/application-settings.d.ts b/nativescript-core/application-settings/application-settings.d.ts index e90c11676..6f1163c37 100644 --- a/nativescript-core/application-settings/application-settings.d.ts +++ b/nativescript-core/application-settings/application-settings.d.ts @@ -1,9 +1,4 @@ /** - * Allows you to save and restore any kind of information related to your application. - * @module "application-settings" - */ /** */ - -/** * Checks whether such a key exists. * @param key The key to check for. */ diff --git a/nativescript-core/application/application.d.ts b/nativescript-core/application/application.d.ts index 6649b8d92..cc0371890 100644 --- a/nativescript-core/application/application.d.ts +++ b/nativescript-core/application/application.d.ts @@ -1,11 +1,6 @@ -/** - * Contains the application abstraction with all related methods. - * @module "application" - */ /** */ - -/// - -import { NavigationEntry, View, Observable, EventData } from "../ui/frame"; +import { NavigationEntry } from "../ui/frame"; +import { View } from '../ui/core/view'; +import { Observable, EventData } from '../data/observable'; /** * String value used when hooking to launch event. diff --git a/nativescript-core/color/color.d.ts b/nativescript-core/color/color.d.ts index cb6712cf3..c66bbe4e8 100644 --- a/nativescript-core/color/color.d.ts +++ b/nativescript-core/color/color.d.ts @@ -1,9 +1,4 @@ /** - * Allows creating colors to be used when styling the UI. - * @module "color" - */ /** */ - -/** * Represents a color object. Stores all color components (alpha (opacity), red, green, blue) in a [0..255] range. */ export class Color { diff --git a/nativescript-core/color/known-colors.d.ts b/nativescript-core/color/known-colors.d.ts index b846b02d4..21288171f 100644 --- a/nativescript-core/color/known-colors.d.ts +++ b/nativescript-core/color/known-colors.d.ts @@ -1,8 +1,4 @@ -/** - * @module "color/known-colors" - */ /** */ - -export const AliceBlue; +export const AliceBlue; export const AntiqueWhite; export const Aqua; export const Aquamarine; diff --git a/nativescript-core/connectivity/connectivity.d.ts b/nativescript-core/connectivity/connectivity.d.ts index 1322f8042..75f2068b2 100644 --- a/nativescript-core/connectivity/connectivity.d.ts +++ b/nativescript-core/connectivity/connectivity.d.ts @@ -1,9 +1,4 @@ /** - * Contains connectivity utility methods. - * @module "connectivity" - */ /** */ - -/** * Gets the type of connection. * Returns a value from the connectivity.connectionType enumeration. * To use this method on Android you need to have the android.permission.ACCESS_NETWORK_STATE permission added to the AndroidManifest.xml file. diff --git a/nativescript-core/css-value/reworkcss-value.d.ts b/nativescript-core/css-value/reworkcss-value.d.ts index d022d3eeb..72aeabe02 100644 --- a/nativescript-core/css-value/reworkcss-value.d.ts +++ b/nativescript-core/css-value/reworkcss-value.d.ts @@ -1,7 +1,3 @@ -/** - * @module "css-value" - */ /** */ - interface CSSValue { type: string; string: string; diff --git a/nativescript-core/css/reworkcss.d.ts b/nativescript-core/css/reworkcss.d.ts index b7376381b..ce7d3ecc7 100644 --- a/nativescript-core/css/reworkcss.d.ts +++ b/nativescript-core/css/reworkcss.d.ts @@ -1,7 +1,3 @@ -/** - * @module "css" - */ /** */ - export interface Position { start: { line: number; column: number }; end: { line: number; column: number }; diff --git a/nativescript-core/css/system-classes.d.ts b/nativescript-core/css/system-classes.d.ts index 43edcfee9..00a33587d 100644 --- a/nativescript-core/css/system-classes.d.ts +++ b/nativescript-core/css/system-classes.d.ts @@ -1,8 +1,3 @@ -/** - * @module "system-classes" - * This is an internal module. - */ /** */ - /** * String value "ns-" used for CSS system class prefix. */ diff --git a/nativescript-core/data/observable-array/observable-array.d.ts b/nativescript-core/data/observable-array/observable-array.d.ts index 417d47b8d..72fcf99e7 100644 --- a/nativescript-core/data/observable-array/observable-array.d.ts +++ b/nativescript-core/data/observable-array/observable-array.d.ts @@ -1,9 +1,4 @@ -/** - * Contains the ObservableArray class, which is capable of detecting and responding to changes of a collection of objects. - * @module "data/observable-array" - */ /** */ - -// Test: http://jsperf.com/array-vs-observable-array-vs-array-observe +// Test: http://jsperf.com/array-vs-observable-array-vs-array-observe import { Observable, EventData } from "../observable"; /** diff --git a/nativescript-core/data/observable/observable.d.ts b/nativescript-core/data/observable/observable.d.ts index f87684c82..30fcc9fbf 100644 --- a/nativescript-core/data/observable/observable.d.ts +++ b/nativescript-core/data/observable/observable.d.ts @@ -1,9 +1,4 @@ /** - * Contains the Observable class, which represents an observable object, or "data" in the model-view paradigm. - * @module "data/observable" - */ /** */ - -/** * Base event data. */ export interface EventData { diff --git a/nativescript-core/data/virtual-array/virtual-array.d.ts b/nativescript-core/data/virtual-array/virtual-array.d.ts index 5bd820fd4..9c832db52 100644 --- a/nativescript-core/data/virtual-array/virtual-array.d.ts +++ b/nativescript-core/data/virtual-array/virtual-array.d.ts @@ -1,11 +1,5 @@ -/** - * Contains the VirtualArray class, which is an advanced array like class that helps loading items on demand. - * @module "data/virtual-array" - */ /** */ - -import { Observable, EventData } from "../observable"; +import { Observable, EventData } from "../observable"; import { ObservableArray, ChangedData, ChangeType } from "../observable-array"; -export { ChangedData, ChangeType } from "../observable-array"; /** * Advanced array like class that helps loading items on demand. diff --git a/nativescript-core/file-system/file-name-resolver/file-name-resolver.d.ts b/nativescript-core/file-system/file-name-resolver/file-name-resolver.d.ts index ed8a4cfa0..454e5e88b 100644 --- a/nativescript-core/file-system/file-name-resolver/file-name-resolver.d.ts +++ b/nativescript-core/file-system/file-name-resolver/file-name-resolver.d.ts @@ -1,10 +1,4 @@ -/** - * Provides FileNameResolver class used for loading files based on device capabilities. - * @module "file-system/file-name-resolver" - */ /** */ - -import { PlatformContext } from "../../module-name-resolver/qualifier-matcher"; -export { PlatformContext } from "../../module-name-resolver/qualifier-matcher"; +import { PlatformContext } from "../../module-name-resolver/qualifier-matcher"; export class FileNameResolver { constructor(context: PlatformContext); diff --git a/nativescript-core/file-system/file-system-access.d.ts b/nativescript-core/file-system/file-system-access.d.ts index 883c77f12..214b58452 100644 --- a/nativescript-core/file-system/file-system-access.d.ts +++ b/nativescript-core/file-system/file-system-access.d.ts @@ -1,8 +1,4 @@ /** - * @module "file-system/file-system-access" - */ /** */ - -/** * An utility class used to provide methods to access and work with the file system. */ export class FileSystemAccess { diff --git a/nativescript-core/file-system/file-system.d.ts b/nativescript-core/file-system/file-system.d.ts index a21ca661a..f0c09e0d2 100644 --- a/nativescript-core/file-system/file-system.d.ts +++ b/nativescript-core/file-system/file-system.d.ts @@ -1,9 +1,4 @@ /** - * Provides high-level abstractions for file system entities such as files, folders, known folders, paths, separators, etc. - * @module "file-system" - */ /** */ - -/** * Represents a single entity on the file system. */ export class FileSystemEntity { diff --git a/nativescript-core/fps-meter/fps-meter.d.ts b/nativescript-core/fps-meter/fps-meter.d.ts index 43a650b9e..cbf3baab7 100644 --- a/nativescript-core/fps-meter/fps-meter.d.ts +++ b/nativescript-core/fps-meter/fps-meter.d.ts @@ -1,9 +1,4 @@ /** - * Allows you to capture the frames-per-second metrics of your application. - * @module "fps-meter" - */ /** */ - -/** * Starts the frames-per-second meter. */ export function start(): void; diff --git a/nativescript-core/fps-meter/fps-native.d.ts b/nativescript-core/fps-meter/fps-native.d.ts index 91ee3d01a..64135ed89 100644 --- a/nativescript-core/fps-meter/fps-native.d.ts +++ b/nativescript-core/fps-meter/fps-native.d.ts @@ -1,8 +1,4 @@ /** - * @module "fps-meter/fps-native" - */ /** */ - -/** * An utility class used to measure frames per second. */ export class FPSCallback { diff --git a/nativescript-core/globals/Readme.md b/nativescript-core/globals/Readme.md deleted file mode 100644 index 199a5d14b..000000000 --- a/nativescript-core/globals/Readme.md +++ /dev/null @@ -1,9 +0,0 @@ -Globals module for defining functions part of the global context - you need only to call *require* for this module and all globals will be registered. For example: -```js - require("globals"); - - setTimeout(function(){ console.log("Test"); }, 2000); - -``` - -Global functions/objects are: setTimeout, clearTimeout, setInterval, clearInterval and console. diff --git a/nativescript-core/globals/core/globals-core.ts b/nativescript-core/globals/core.ts similarity index 99% rename from nativescript-core/globals/core/globals-core.ts rename to nativescript-core/globals/core.ts index 82ae15740..25ea409d2 100644 --- a/nativescript-core/globals/core/globals-core.ts +++ b/nativescript-core/globals/core.ts @@ -1,6 +1,5 @@ // Required by TypeScript compiler import "../ts-helpers"; - import "../register-module-helpers"; // This method iterates all the keys in the source exports object and copies them to the destination exports one. diff --git a/nativescript-core/globals/core/globals-core.d.ts b/nativescript-core/globals/core/globals-core.d.ts deleted file mode 100644 index c1932b4be..000000000 --- a/nativescript-core/globals/core/globals-core.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Nothing exported. Side effects: registers ts-helpers and module-helpers - * @module "globals/core" - */ /** */ -import "../ts-helpers"; -import "../register-module-helpers"; diff --git a/nativescript-core/globals/core/package.json b/nativescript-core/globals/core/package.json deleted file mode 100644 index 4fe964dec..000000000 --- a/nativescript-core/globals/core/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "core", - "main": "globals-core", - "types": "globals-core.d.ts", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/globals/globals.ts b/nativescript-core/globals/globals.ts deleted file mode 100644 index 55957821c..000000000 --- a/nativescript-core/globals/globals.ts +++ /dev/null @@ -1,10 +0,0 @@ -import "./core"; - -import "./polyfills/timers"; -import "./polyfills/animation"; -import "./polyfills/dialogs"; -import "./polyfills/text"; -import "./polyfills/xhr"; -import "./polyfills/fetch"; - -import "./decorators"; diff --git a/nativescript-core/globals/globals.d.ts b/nativescript-core/globals/index.d.ts similarity index 71% rename from nativescript-core/globals/globals.d.ts rename to nativescript-core/globals/index.d.ts index d2fbe139c..97bebc2cb 100644 --- a/nativescript-core/globals/globals.d.ts +++ b/nativescript-core/globals/index.d.ts @@ -1,4 +1,4 @@ /** * Register globals such as setTimeout, setInterval, console etc. */ -export function install(); +export function initGlobal(); diff --git a/nativescript-core/globals/index.ts b/nativescript-core/globals/index.ts new file mode 100644 index 000000000..9ee06b92d --- /dev/null +++ b/nativescript-core/globals/index.ts @@ -0,0 +1,78 @@ +export let hasInitGlobal = false; + +function registerOnGlobalContext(moduleName: string, exportName: string): void { + Object.defineProperty(global, exportName, { + get: function () { + // We do not need to cache require() call since it is already cached in the runtime. + let m = global.loadModule(moduleName); + + // Redefine the property to make sure the above code is executed only once. + let resolvedValue = m[exportName]; + Object.defineProperty(global, exportName, { value: resolvedValue, configurable: true, writable: true }); + + return resolvedValue; + }, + configurable: true + }); +} + +export function installPolyfills(moduleName: string, exportNames: string[]) { + if (global.__snapshot) { + const loadedModule = global.loadModule(moduleName); + exportNames.forEach(exportName => global[exportName] = loadedModule[exportName]); + } else { + exportNames.forEach(exportName => registerOnGlobalContext(moduleName, exportName)); + } +} + +export function initGlobal() { + console.log("initPolyfills called, init:", hasInitGlobal); + if (!hasInitGlobal) { + hasInitGlobal = true; + // apply global polyfills first + require("./core"); + + // DOM api polyfills + global.registerModule("timer", () => require("../timer")); + installPolyfills("timer", [ + "setTimeout", + "clearTimeout", + "setInterval", + "clearInterval", + ]); + + global.registerModule("animation", () => require("../animation-frame")); + installPolyfills("animation", [ + "requestAnimationFrame", + "cancelAnimationFrame", + ]); + + global.registerModule("ui-dialogs", () => require("../ui/dialogs")); + installPolyfills("ui-dialogs", [ + "alert", + "confirm", + "prompt", + "login", + "action", + ]); + + global.registerModule("text", () => require("../text")); + installPolyfills("text", ["TextDecoder", "TextEncoder"]); + + global.registerModule("xhr", () => require("../xhr")); + installPolyfills("xhr", [ + "XMLHttpRequest", + "FormData", + "Blob", + "File", + "FileReader", + ]); + + global.registerModule("fetch", () => require("../fetch")); + installPolyfills("fetch", ["fetch", "Headers", "Request", "Response"]); + + // Custom decorators + require("./decorators"); + } +} + diff --git a/nativescript-core/globals/package.json b/nativescript-core/globals/package.json deleted file mode 100644 index 501faaa6d..000000000 --- a/nativescript-core/globals/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "globals", - "main": "globals", - "types": "globals.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/globals/polyfills/animation/animation.d.ts b/nativescript-core/globals/polyfills/animation/animation.d.ts deleted file mode 100644 index e149a301d..000000000 --- a/nativescript-core/globals/polyfills/animation/animation.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Installs animations polyfill. - * @module "globals/polyfills/animations" - */ /** */ -import "../../core"; diff --git a/nativescript-core/globals/polyfills/animation/animation.ts b/nativescript-core/globals/polyfills/animation/animation.ts deleted file mode 100644 index 6c38fa34b..000000000 --- a/nativescript-core/globals/polyfills/animation/animation.ts +++ /dev/null @@ -1,6 +0,0 @@ -import "../../core"; -import { installPolyfills } from "../polyfill-helpers"; - -global.registerModule("animation", () => require("../../../animation-frame")); - -installPolyfills("animation", ["requestAnimationFrame", "cancelAnimationFrame"]); diff --git a/nativescript-core/globals/polyfills/animation/package.json b/nativescript-core/globals/polyfills/animation/package.json deleted file mode 100644 index a647c1dd4..000000000 --- a/nativescript-core/globals/polyfills/animation/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "animation", - "main": "animation", - "types": "animation.d.ts", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/globals/polyfills/dialogs/dialogs.d.ts b/nativescript-core/globals/polyfills/dialogs/dialogs.d.ts deleted file mode 100644 index 731a7db3f..000000000 --- a/nativescript-core/globals/polyfills/dialogs/dialogs.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Installs dialogs polyfill. - * @module "globals/polyfills/dialogs" - */ /** */ -import "../../core"; diff --git a/nativescript-core/globals/polyfills/dialogs/dialogs.ts b/nativescript-core/globals/polyfills/dialogs/dialogs.ts deleted file mode 100644 index 7a23c9454..000000000 --- a/nativescript-core/globals/polyfills/dialogs/dialogs.ts +++ /dev/null @@ -1,6 +0,0 @@ -import "../../core"; -import { installPolyfills } from "../polyfill-helpers"; - -global.registerModule("ui-dialogs", () => require("../../../ui/dialogs")); - -installPolyfills("ui-dialogs", ["alert", "confirm", "prompt", "login", "action"]); diff --git a/nativescript-core/globals/polyfills/dialogs/package.json b/nativescript-core/globals/polyfills/dialogs/package.json deleted file mode 100644 index 93b54e894..000000000 --- a/nativescript-core/globals/polyfills/dialogs/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "dialogs", - "main": "dialogs", - "types": "dialogs.d.ts", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/globals/polyfills/fetch/fetch.d.ts b/nativescript-core/globals/polyfills/fetch/fetch.d.ts deleted file mode 100644 index 707285527..000000000 --- a/nativescript-core/globals/polyfills/fetch/fetch.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Installs fetch polyfill. - * @module "globals/polyfills/fetch" - */ /** */ -import "../../core"; -import "../../polyfills/xhr"; diff --git a/nativescript-core/globals/polyfills/fetch/fetch.ts b/nativescript-core/globals/polyfills/fetch/fetch.ts deleted file mode 100644 index db6295ed6..000000000 --- a/nativescript-core/globals/polyfills/fetch/fetch.ts +++ /dev/null @@ -1,8 +0,0 @@ -import "../../core"; -import "../../polyfills/xhr"; - -import { installPolyfills } from "../polyfill-helpers"; - -global.registerModule("fetch", () => require("../../../fetch")); - -installPolyfills("fetch", ["fetch", "Headers", "Request", "Response"]); diff --git a/nativescript-core/globals/polyfills/fetch/package.json b/nativescript-core/globals/polyfills/fetch/package.json deleted file mode 100644 index 1ee34bb86..000000000 --- a/nativescript-core/globals/polyfills/fetch/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "fetch", - "main": "fetch", - "types": "fetch.d.ts", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/globals/polyfills/polyfill-helpers/package.json b/nativescript-core/globals/polyfills/polyfill-helpers/package.json deleted file mode 100644 index bad4e07e5..000000000 --- a/nativescript-core/globals/polyfills/polyfill-helpers/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "polyfill-helpers", - "main": "polyfill-helpers", - "types": "polyfill-helpers.d.ts", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/globals/polyfills/polyfill-helpers/polyfill-helpers.d.ts b/nativescript-core/globals/polyfills/polyfill-helpers/polyfill-helpers.d.ts deleted file mode 100644 index b8981f3c4..000000000 --- a/nativescript-core/globals/polyfills/polyfill-helpers/polyfill-helpers.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Global polyfills helpers. - * @module "globals/polyfills/polyfill-helpers" - */ /** */ -import "../../core"; -export declare function installPolyfills(moduleName: string, exportNames: string[]): void; diff --git a/nativescript-core/globals/polyfills/polyfill-helpers/polyfill-helpers.ts b/nativescript-core/globals/polyfills/polyfill-helpers/polyfill-helpers.ts deleted file mode 100644 index 41da510dc..000000000 --- a/nativescript-core/globals/polyfills/polyfill-helpers/polyfill-helpers.ts +++ /dev/null @@ -1,26 +0,0 @@ -import "../../core"; - -function registerOnGlobalContext(moduleName: string, exportName: string): void { - Object.defineProperty(global, exportName, { - get: function () { - // We do not need to cache require() call since it is already cached in the runtime. - let m = global.loadModule(moduleName); - - // Redefine the property to make sure the above code is executed only once. - let resolvedValue = m[exportName]; - Object.defineProperty(global, exportName, { value: resolvedValue, configurable: true, writable: true }); - - return resolvedValue; - }, - configurable: true - }); -} - -export function installPolyfills(moduleName: string, exportNames: string[]) { - if (global.__snapshot) { - const loadedModule = global.loadModule(moduleName); - exportNames.forEach(exportName => global[exportName] = loadedModule[exportName]); - } else { - exportNames.forEach(exportName => registerOnGlobalContext(moduleName, exportName)); - } -} diff --git a/nativescript-core/globals/polyfills/text/package.json b/nativescript-core/globals/polyfills/text/package.json deleted file mode 100644 index 92a163063..000000000 --- a/nativescript-core/globals/polyfills/text/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name" : "text", - "main" : "text", - "nativescript": {} -} diff --git a/nativescript-core/globals/polyfills/text/text.ts b/nativescript-core/globals/polyfills/text/text.ts deleted file mode 100644 index 61c2bfc2a..000000000 --- a/nativescript-core/globals/polyfills/text/text.ts +++ /dev/null @@ -1,8 +0,0 @@ -import "../../core"; -import "../../polyfills/xhr"; - -import { installPolyfills } from "../polyfill-helpers"; - -global.registerModule("text", () => require("../../../text")); - -installPolyfills("text", ["TextDecoder", "TextEncoder"]); diff --git a/nativescript-core/globals/polyfills/timers/package.json b/nativescript-core/globals/polyfills/timers/package.json deleted file mode 100644 index 5b55ed17c..000000000 --- a/nativescript-core/globals/polyfills/timers/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "timers", - "main": "timers", - "types": "timers.d.ts", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/globals/polyfills/timers/timers.d.ts b/nativescript-core/globals/polyfills/timers/timers.d.ts deleted file mode 100644 index e4685ab35..000000000 --- a/nativescript-core/globals/polyfills/timers/timers.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Installs timers polyfill. - * @module "globals/polyfills/fetch" - */ /** */ -import "../../core"; diff --git a/nativescript-core/globals/polyfills/timers/timers.ts b/nativescript-core/globals/polyfills/timers/timers.ts deleted file mode 100644 index d85fde570..000000000 --- a/nativescript-core/globals/polyfills/timers/timers.ts +++ /dev/null @@ -1,6 +0,0 @@ -import "../../core"; -import { installPolyfills } from "../polyfill-helpers"; - -global.registerModule("timer", () => require("../../../timer")); - -installPolyfills("timer", ["setTimeout", "clearTimeout", "setInterval", "clearInterval"]); diff --git a/nativescript-core/globals/polyfills/xhr/package.json b/nativescript-core/globals/polyfills/xhr/package.json deleted file mode 100644 index afa59a1f1..000000000 --- a/nativescript-core/globals/polyfills/xhr/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "xhr", - "main": "xhr", - "types": "xhr.d.ts", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/globals/polyfills/xhr/xhr.d.ts b/nativescript-core/globals/polyfills/xhr/xhr.d.ts deleted file mode 100644 index 19f8e447f..000000000 --- a/nativescript-core/globals/polyfills/xhr/xhr.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Installs xhr polyfill. - * @module "globals/polyfills/fetch" - */ /** */ - import "../../core"; diff --git a/nativescript-core/globals/polyfills/xhr/xhr.ts b/nativescript-core/globals/polyfills/xhr/xhr.ts deleted file mode 100644 index 64fe1294a..000000000 --- a/nativescript-core/globals/polyfills/xhr/xhr.ts +++ /dev/null @@ -1,6 +0,0 @@ -import "../../core"; -import { installPolyfills } from "../polyfill-helpers"; - -global.registerModule("xhr", () => require("../../../xhr")); - -installPolyfills("xhr", ["XMLHttpRequest", "FormData", "Blob", "File", "FileReader"]); diff --git a/nativescript-core/http/http-request/http-request.d.ts b/nativescript-core/http/http-request/http-request.d.ts index 8ae122533..8c027c739 100644 --- a/nativescript-core/http/http-request/http-request.d.ts +++ b/nativescript-core/http/http-request/http-request.d.ts @@ -1,7 +1,3 @@ -/** - * @module "http/http-request" - */ /** */ - -import { HttpRequestOptions, HttpResponse, Headers } from ".."; +import { HttpRequestOptions, HttpResponse, Headers } from ".."; export const request: (options: HttpRequestOptions) => Promise; export function addHeader(headers: Headers, key: string, value: string): void; diff --git a/nativescript-core/http/http.d.ts b/nativescript-core/http/http.d.ts index 35e3ca1ef..2262f78c4 100644 --- a/nativescript-core/http/http.d.ts +++ b/nativescript-core/http/http.d.ts @@ -1,9 +1,4 @@ -/** - * Allows you to send web requests and receive the responses. - * @module "http" - */ /** */ - -import { ImageSource } from "../image-source"; +import { ImageSource } from "../image-source"; import { File } from "../file-system"; /** diff --git a/nativescript-core/image-asset/image-asset.d.ts b/nativescript-core/image-asset/image-asset.d.ts index b21688040..4e2dd3693 100644 --- a/nativescript-core/image-asset/image-asset.d.ts +++ b/nativescript-core/image-asset/image-asset.d.ts @@ -1,7 +1,3 @@ -/** - * @module "image-asset" - */ /** */ - import { Observable } from "../data/observable"; export class ImageAsset extends Observable { diff --git a/nativescript-core/image-source/image-source.d.ts b/nativescript-core/image-source/image-source.d.ts index 20c4fbcda..66cf3613d 100644 --- a/nativescript-core/image-source/image-source.d.ts +++ b/nativescript-core/image-source/image-source.d.ts @@ -1,9 +1,4 @@ -/** - * Contains the ImageSource class, which encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images. - * @module "image-source" - */ /** */ - -import { ImageAsset } from "../image-asset"; +import { ImageAsset } from "../image-asset"; import { Font } from "../ui/styling/font"; import { Color } from "../color"; /** diff --git a/nativescript-core/index.d.ts b/nativescript-core/index.d.ts index 7fab07b92..b31f3d53a 100644 --- a/nativescript-core/index.d.ts +++ b/nativescript-core/index.d.ts @@ -1,5 +1,3 @@ -/// - export { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, iOSApplication, AndroidApplication, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, } from "./application"; import { getMainEntry, getRootView, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, AndroidApplication, iOSApplication } from "./application"; export declare const Application: { diff --git a/nativescript-core/index.ts b/nativescript-core/index.ts index bfe4cb255..b06cd5359 100644 --- a/nativescript-core/index.ts +++ b/nativescript-core/index.ts @@ -1,4 +1,8 @@ -/// +// apply polyfills first +import { initGlobal, hasInitGlobal } from './globals'; +if (!hasInitGlobal) { + initGlobal(); +} // Export all interfaces from "application" module export { diff --git a/nativescript-core/js-libs/easysax/easysax.d.ts b/nativescript-core/js-libs/easysax/easysax.d.ts index 621058d26..bc905a07f 100644 --- a/nativescript-core/js-libs/easysax/easysax.d.ts +++ b/nativescript-core/js-libs/easysax/easysax.d.ts @@ -1,9 +1,4 @@ -/** - * @module "js-libs/easysax" - * @private - */ /** */ - -//@private +//@private export class EasySAXParser { constructor(); parse(xml: string): void; diff --git a/nativescript-core/js-libs/esprima/esprima.d.ts b/nativescript-core/js-libs/esprima/esprima.d.ts index 203952511..519a73a9c 100644 --- a/nativescript-core/js-libs/esprima/esprima.d.ts +++ b/nativescript-core/js-libs/esprima/esprima.d.ts @@ -1,8 +1,4 @@ -/** - * @module "js-libs/esprima" - */ /** */ - -/* tslint:disable */ +/* tslint:disable */ // Type definitions for Esprima v1.2.0 // Project: http://esprima.org diff --git a/nativescript-core/js-libs/polymer-expressions/polymer-expressions.d.ts b/nativescript-core/js-libs/polymer-expressions/polymer-expressions.d.ts index f84afd00a..444f06fc7 100644 --- a/nativescript-core/js-libs/polymer-expressions/polymer-expressions.d.ts +++ b/nativescript-core/js-libs/polymer-expressions/polymer-expressions.d.ts @@ -1,9 +1,4 @@ -/** - * @module "js-libs/polymer-expressions" - * @private - */ /** */ - -//@private +//@private export class PolymerExpressions { static getExpression(expression: string): Expression; } diff --git a/nativescript-core/matrix/matrix.d.ts b/nativescript-core/matrix/matrix.d.ts index 790e8ddc5..e292f4baa 100644 --- a/nativescript-core/matrix/matrix.d.ts +++ b/nativescript-core/matrix/matrix.d.ts @@ -2,8 +2,7 @@ * Contains utility methods for transforming css matrixes. * All methods in this module are experimental and * may be changed in a non-major version. - * @module "matrix" - */ /** */ + */ import { TransformFunctionsInfo } from "../ui/animation/animation"; diff --git a/nativescript-core/module-name-resolver/module-name-resolver.d.ts b/nativescript-core/module-name-resolver/module-name-resolver.d.ts index 170b47bbc..1d0fb8cb3 100644 --- a/nativescript-core/module-name-resolver/module-name-resolver.d.ts +++ b/nativescript-core/module-name-resolver/module-name-resolver.d.ts @@ -1,10 +1,9 @@ /** * Provides ModuleNameResolver class used for loading files based on device capabilities. - * @module "module-name-resolver" */ /** */ import { PlatformContext } from "./qualifier-matcher"; -export { PlatformContext } from "./qualifier-matcher"; +// export { PlatformContext } from "./qualifier-matcher"; export type ModuleListProvider = () => string[]; diff --git a/nativescript-core/module-name-resolver/module-name-resolver.ts b/nativescript-core/module-name-resolver/module-name-resolver.ts index 6ce9e7cc7..58ccc9b64 100644 --- a/nativescript-core/module-name-resolver/module-name-resolver.ts +++ b/nativescript-core/module-name-resolver/module-name-resolver.ts @@ -4,9 +4,7 @@ import * as appCommonModule from "../application/application-common"; import { PlatformContext, findMatch, stripQualifiers } from "./qualifier-matcher"; import { registerModulesFromFileSystem } from "./non-bundle-workflow-compat"; import { - isEnabled as traceEnabled, - write as traceWrite, - categories as traceCategories + Trace } from "../trace"; export class ModuleNameResolver implements ModuleNameResolverDefinition { @@ -23,8 +21,8 @@ export class ModuleNameResolver implements ModuleNameResolverDefinition { this._cache[key] = result; } - if (traceEnabled()) { - traceWrite(`path: '${path}' with ext: '${ext}' resolved: '${result}'`, traceCategories.ModuleNameResolver); + if (Trace.isEnabled()) { + Trace.write(`path: '${path}' with ext: '${ext}' resolved: '${result}'`, Trace.categories.ModuleNameResolver); } return result; @@ -81,7 +79,7 @@ export function resolveModuleName(path: string, ext: string): string { } function resolveModuleSnapshot(path, ext) { - traceWrite(`Resolving module in SNAPSHOT context - path: '${path}' with ext: '${ext}'`, traceCategories.ModuleNameResolver); + Trace.write(`Resolving module in SNAPSHOT context - path: '${path}' with ext: '${ext}'`, Trace.categories.ModuleNameResolver); // Platform module when in snapshot. So resolve modules with default android phone. // NB: The only module name that should ever be resolved while in snapshot is app.css, because it is diff --git a/nativescript-core/module-name-resolver/non-bundle-workflow-compat.ts b/nativescript-core/module-name-resolver/non-bundle-workflow-compat.ts index f92822085..7cac5f0be 100644 --- a/nativescript-core/module-name-resolver/non-bundle-workflow-compat.ts +++ b/nativescript-core/module-name-resolver/non-bundle-workflow-compat.ts @@ -1,24 +1,22 @@ import * as fs from "../file-system/file-system"; import * as appCommonModule from "../application/application-common"; import { - isEnabled as traceEnabled, - write as traceWrite, - categories as traceCategories + Trace } from "../trace"; const cache = new Set(); let initialized = false; function register(name: string, loader: (name?: string) => void) { - if (traceEnabled()) { - traceWrite(`[Compat] Register module: ${name}`, traceCategories.ModuleNameResolver); + if (Trace.isEnabled()) { + Trace.write(`[Compat] Register module: ${name}`, Trace.categories.ModuleNameResolver); } global.registerModule(name, loader); if (name.startsWith("tns_modules")) { const nonTnsModulesName = name.substr("tns_modules".length + 1); - if (traceEnabled()) { - traceWrite(`[Compat] Register module: ${nonTnsModulesName}`, traceCategories.ModuleNameResolver); + if (Trace.isEnabled()) { + Trace.write(`[Compat] Register module: ${nonTnsModulesName}`, Trace.categories.ModuleNameResolver); } global.registerModule(nonTnsModulesName, loader); } @@ -66,8 +64,8 @@ function processFolder(path: string): boolean { } cache.add(path); - if (traceEnabled()) { - traceWrite(`[Compat] Processing folder: ${path}`, traceCategories.ModuleNameResolver); + if (Trace.isEnabled()) { + Trace.write(`[Compat] Processing folder: ${path}`, Trace.categories.ModuleNameResolver); } let folderEmpty = true; diff --git a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts b/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts index b278e078d..38ee0621e 100644 --- a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts +++ b/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts @@ -1,7 +1,6 @@ /** * Provides ModuleNameResolver class used for loading files based on device capabilities. - * @module "module-name-resolver/qualifier-matcher" - */ /** */ + */ export interface PlatformContext { width: number; diff --git a/nativescript-core/module.d.ts b/nativescript-core/module.d.ts index 523d69a70..5783ed49d 100644 --- a/nativescript-core/module.d.ts +++ b/nativescript-core/module.d.ts @@ -1,4 +1,3 @@ -/// declare var global: NodeJS.Global; interface ModuleResolver { diff --git a/nativescript-core/package.json b/nativescript-core/package.json index 9f353ac21..556f98a6d 100644 --- a/nativescript-core/package.json +++ b/nativescript-core/package.json @@ -19,17 +19,17 @@ ], "license": "Apache-2.0", "dependencies": { - "css-tree": "^1.0.0-alpha.37", - "nativescript-hook": "0.2.5", + "@nativescript/hook": "~1.0.0", + "css-tree": "^1.0.0-alpha.39", "reduce-css-calc": "^2.1.6", - "semver": "6.3.0", - "tns-core-modules-widgets": "6.5.10", - "tslib": "1.10.0" + "semver": "~7.3.2", + "tns-core-modules-widgets": "~6.5.2", + "tslib": "~2.0.0" }, "devDependencies": { - "@types/chai": "~4.2.5", - "@types/node": "~10.12.18", - "tns-platform-declarations": "6.5.10" + "@types/chai": "~4.2.11", + "@types/node": "~14.0.14", + "tns-platform-declarations": "~6.5.8" }, "scripts": { "version": "conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md", @@ -49,15 +49,5 @@ "inject": true } ] - }, - "snapshot": { - "android": { - "tns-java-classes": { - "modules": [ - "ui/frame/activity", - "ui/frame/fragment" - ] - } - } } } diff --git a/nativescript-core/platform/platform.d.ts b/nativescript-core/platform/platform.d.ts index 4335eb274..c4c569dd2 100644 --- a/nativescript-core/platform/platform.d.ts +++ b/nativescript-core/platform/platform.d.ts @@ -1,7 +1,6 @@ /** * Contains all kinds of information about the device, its operating system and software. - * @module "platform" - */ /** */ + */ /* tslint:disable:class-name */ diff --git a/nativescript-core/profiling/profiling.d.ts b/nativescript-core/profiling/profiling.d.ts index 80ee37ecb..614544c72 100644 --- a/nativescript-core/profiling/profiling.d.ts +++ b/nativescript-core/profiling/profiling.d.ts @@ -1,8 +1,7 @@ /** * Contains contains utility methods for profiling. * All methods in this module are experimental and may be changed in a non-major version. - * @module "profiling" - */ /** */ + */ interface TimerInfo { totalTime: number; diff --git a/nativescript-core/references.d.ts b/nativescript-core/references.d.ts index 708d07818..9f2e56dc4 100644 --- a/nativescript-core/references.d.ts +++ b/nativescript-core/references.d.ts @@ -1,3 +1,5 @@ /// /// /// +/// +/// diff --git a/nativescript-core/text/formatted-string.d.ts b/nativescript-core/text/formatted-string.d.ts index 47acb3698..be6a91105 100644 --- a/nativescript-core/text/formatted-string.d.ts +++ b/nativescript-core/text/formatted-string.d.ts @@ -1,6 +1 @@ -/** - * Contains the FormattedString and Span classes, which are used to create a formatted (rich text) strings. - * @module "text/formatted-string" - */ /** */ - - export * from "../ui/text-base/formatted-string"; \ No newline at end of file +export * from "../ui/text-base/formatted-string"; \ No newline at end of file diff --git a/nativescript-core/text/span.d.ts b/nativescript-core/text/span.d.ts index 154dc540b..48e6d256d 100644 --- a/nativescript-core/text/span.d.ts +++ b/nativescript-core/text/span.d.ts @@ -1,5 +1 @@ -/** - * @module "text/span" - */ /** */ - -export * from "../ui/text-base/span"; \ No newline at end of file +export * from "../ui/text-base/span"; \ No newline at end of file diff --git a/nativescript-core/text/text.d.ts b/nativescript-core/text/text.d.ts index 4fa2515eb..97db0f32b 100644 --- a/nativescript-core/text/text.d.ts +++ b/nativescript-core/text/text.d.ts @@ -1,9 +1,4 @@ -/** - * Defines specific text related enumerations. - * @module "text" - */ /** */ - -export * from "./text-common"; +export * from "./text-common"; /** * Defines the supported character encodings. diff --git a/nativescript-core/timer/timer.d.ts b/nativescript-core/timer/timer.d.ts index 7e9fe7aff..f7eb057bd 100644 --- a/nativescript-core/timer/timer.d.ts +++ b/nativescript-core/timer/timer.d.ts @@ -1,9 +1,4 @@ /** - * Allows you to create, start, stop and react to timers. - * @module "timer" - */ /** */ - -/** * Calls a function after a specified delay. * @param callback The function to be called. * @param milliseconds The time to wait before the function is called. Defaults to 0. diff --git a/nativescript-core/tns-core-modules.d.ts b/nativescript-core/tns-core-modules.d.ts index 1a9ec6d30..53f96ea1c 100644 --- a/nativescript-core/tns-core-modules.d.ts +++ b/nativescript-core/tns-core-modules.d.ts @@ -1,6 +1,3 @@ -/* tslint:disable:no-unused-variable */ -/// - declare enum RequestContext { "audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import", diff --git a/nativescript-core/trace/Readme.md b/nativescript-core/trace/Readme.md index 0b9e09b6b..5ae5bc3e5 100644 --- a/nativescript-core/trace/Readme.md +++ b/nativescript-core/trace/Readme.md @@ -2,8 +2,8 @@ The trace module is used to track code execution and to receive notifications fo It is disabled by default and to enable it you will need to call its enable() method. ```js -import * as trace from "trace"; -trace.enable(); +import { Trace } from "@nativescript/core"; +Trace.enable(); ``` The module writes its output through a collection of TraceWriter objects. By default there is one ConsoleWriter instance added to the module. There is a filtering functionality which is implemented by the `setCategories(string)` method. The method argument is a string containing one or more comma-delimited categories: `"Layout,VisualTreeEvents"`. @@ -11,28 +11,28 @@ The module writes its output through a collection of TraceWriter objects. By def How to specify category(s): ```js -import * as trace from "trace"; +import { Trace } from "@nativescript/core"; // only the Layout messages are traced -trace.setCategories(traceCategories.Layout); +Trace.setCategories(Trace.categories.Layout); ``` ```js -import * as trace from "trace"; +import { Trace } from "@nativescript/core"; // set Layout + VisualTreeEvents categories -trace.setCategories(traceCategories.concat(traceCategories.Layout, traceCategories.VisualTreeEvents)); +Trace.setCategories(Trace.categories.concat(Trace.categories.Layout, Trace.categories.VisualTreeEvents)); ``` ```js -import * as trace from "trace"; +import { Trace } from "@nativescript/core"; // trace everything -trace.setCategories(traceCategories.All); +Trace.setCategories(Trace.categories.All); ``` How to trace: ```js -import * as trace from "trace"; -traceWrite("tracing message", traceCategories.Layout); +import { Trace } from "@nativescript/core"; +Trace.write("tracing message", Trace.categories.Layout); ``` The module also supports events notifications through the EventListener interface. You may call the `trace.notifyEvent` method and all registered listeners will receive a notification for the event. @@ -40,9 +40,9 @@ The module also supports events notifications through the EventListener interfac How to create and register a listener: ```js -import * as trace from "trace"; +import { Trace } from "@nativescript/core"; -class Listener implements trace.EventListener { +class Listener implements Trace.EventListener { public filter: string; public receivedEvents: Array<{ sender: Object; name: string }> = []; @@ -63,15 +63,14 @@ class Listener implements trace.EventListener { var listener = new Listener("_onAttached"); // register the listener -trace.addEventListener(listener); +Trace.addEventListener(listener); ``` How to raise events: ```js -import * as trace from "trace"; -import * as view from "ui/core/view"; +import { Trace, View } from "@nativescript/core"; -var newView = new view.View(); -trace.notifyEvent(newView, "_viewCreated"); +var newView = new View(); +Trace.notifyEvent(newView, "_viewCreated"); ``` diff --git a/nativescript-core/trace/index.ts b/nativescript-core/trace/index.ts new file mode 100644 index 000000000..8247f3d20 --- /dev/null +++ b/nativescript-core/trace/index.ts @@ -0,0 +1,299 @@ +/** + * An interface used to define a writer used by trace to print (log). + */ +export interface TraceWriter { + write(message: any, category: string, type?: number): void; +} + +/** + * An interface used to trace information about specific event. + */ +export interface EventListener { + filter: string; + on(object: Object, name: string, data?: any): void; +} + +/** + * An interface used to for handling trace error + */ +export interface ErrorHandler { + handlerError(error: Error): any; +} + +let enabled = false; +let _categories = {}; +let _writers: Array = []; +let _eventListeners: Array = []; +let _errorHandler: ErrorHandler; + +export namespace Trace { + /** + * Enables the trace module. + */ + export function enable() { + enabled = true; + } + + /** + * Disables the trace module. + */ + export function disable() { + enabled = false; + } + + /** + * A function that returns whether the tracer is enabled and there is a point in writing messages. + * Check this to avoid writing complex string templates. + * Send error messages even if tracing is disabled. + */ + export function isEnabled() { + return enabled; + } + + /** + * Adds a TraceWriter instance to the trace module. + * @param writer The TraceWriter instance to add. + */ + export function addWriter(writer: TraceWriter) { + _writers.push(writer); + } + + /** + * Removes a TraceWriter instance from the trace module. + * @param writer The TraceWriter instance to remove. + */ + export function removeWriter(writer: TraceWriter) { + let index = _writers.indexOf(writer); + if (index >= 0) { + _writers.splice(index, 1); + } + } + + /** + * Clears all the writers from the trace module. + */ + export function clearWriters() { + if (_writers.length > 0) { + _writers.splice(0, _writers.length); + } + } + + /** + * Sets the categories the module will trace. + * @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced. + */ + export function setCategories(categories: string) { + _categories = {}; + addCategories(categories); + } + + /** + * Adds categories to existing categories the module will trace. + * @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced. + */ + export function addCategories(categories: string) { + let split = categories.split(","); + for (let i = 0; i < split.length; i++) { + _categories[split[i].trim()] = true; + } + } + + /** + * Check if category is already set in trace module. + * @param category The category to check. + */ + export function isCategorySet(category: string): boolean { + return category in _categories; + } + + /** + * Writes a message using the available writers. + * @param message The message to be written. + * @param category The category of the message. + * @param type Optional, the type of the message - info, warning, error. + */ + export function write(message: any, category: string, type?: number) { + // print error no matter what + let i; + if (type === messageType.error) { + for (i = 0; i < _writers.length; i++) { + _writers[i].write(message, category, type); + } + + return; + } + + if (!enabled) { + return; + } + + if (!(category in _categories)) { + return; + } + + for (i = 0; i < _writers.length; i++) { + _writers[i].write(message, category, type); + } + } + + /** + * Notifies all the attached listeners for an event that has occurred in the sender object. + * @param object The Object instance that raised the event. + * @param name The name of the raised event. + * @param data An optional parameter that passes the data associated with the event. + */ + export function notifyEvent(object: Object, name: string, data?: any) { + if (!enabled) { + return; + } + + let i, listener: EventListener, filters: Array; + for (i = 0; i < _eventListeners.length; i++) { + listener = _eventListeners[i]; + if (listener.filter) { + filters = listener.filter.split(","); + filters.forEach((value: string) => { + if (value.trim() === name) { + listener.on(object, name, data); + } + }); + } else { + listener.on(object, name, data); + } + } + } + + export function addEventListener(listener: EventListener) { + _eventListeners.push(listener); + } + + export function removeEventListener(listener: EventListener) { + const index = _eventListeners.indexOf(listener); + if (index >= 0) { + _eventListeners.splice(index, 1); + } + } + + export module messageType { + export const log = 0; + export const info = 1; + export const warn = 2; + export const error = 3; + } + + /** + * all predefined categories. + */ + export module categories { + export const VisualTreeEvents = "VisualTreeEvents"; + export const Layout = "Layout"; + export const Style = "Style"; + export const ViewHierarchy = "ViewHierarchy"; + export const NativeLifecycle = "NativeLifecycle"; + export const Debug = "Debug"; + export const Navigation = "Navigation"; + export const Test = "Test"; + export const Binding = "Binding"; + export const BindingError = "BindingError"; + export const Error = "Error"; + export const Animation = "Animation"; + export const Transition = "Transition"; + export const Livesync = "Livesync"; + export const ModuleNameResolver = "ModuleNameResolver"; + + 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 { + let result: string; + for (let i = 0; i < arguments.length; i++) { + if (!result) { + result = arguments[i]; + continue; + } + + result = result.concat(separator, arguments[i]); + } + + return result; + } + } + + class ConsoleWriter implements TraceWriter { + public write(message: any, category: string, type?: number) { + if (!console) { + return; + } + + let msgType; + if (type === undefined) { + msgType = messageType.log; + } else { + msgType = type; + } + + switch (msgType) { + case messageType.log: + console.log(category + ": " + message); + break; + case messageType.info: + console.info(category + ": " + message); + break; + case messageType.warn: + console.warn(category + ": " + message); + break; + case messageType.error: + console.error(category + ": " + message); + break; + } + } + } + // register a ConsoleWriter by default + addWriter(new ConsoleWriter()); + + export class DefaultErrorHandler implements ErrorHandler { + handlerError(error) { + throw error; + } + } + setErrorHandler(new DefaultErrorHandler()); + + export function getErrorHandler(): ErrorHandler { + return _errorHandler; + } + + export function setErrorHandler(handler: ErrorHandler) { + _errorHandler = handler; + } + + /** + * Passes an error to the registered ErrorHandler + * @param error The error to be handled. + */ + export function error(error: string | Error) { + if (!_errorHandler) { + return; + } + + if (typeof error === "string") { + error = new Error(error); + } + + _errorHandler.handlerError(error); + } +} diff --git a/nativescript-core/trace/package.json b/nativescript-core/trace/package.json deleted file mode 100644 index 00c12c18a..000000000 --- a/nativescript-core/trace/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "trace", - "main": "trace", - "types": "trace.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/trace/trace.d.ts b/nativescript-core/trace/trace.d.ts deleted file mode 100644 index a4d40dd34..000000000 --- a/nativescript-core/trace/trace.d.ts +++ /dev/null @@ -1,146 +0,0 @@ -/** - * Allows you to trace and print specific information based on categories. - * @module "trace" - */ /** */ - -/** - * Enables the trace module. - */ -export function enable(): void; - -/** - * Disables the trace module. - */ -export function disable(): void; - -/** - * A function that returns whether the tracer is enabled and there is a point in writing messages. - * Check this to avoid writing complex string templates. - * Send error messages even if tracing is disabled. - */ -export function isEnabled(): boolean; - -/** - * Adds a TraceWriter instance to the trace module. - * @param writer The TraceWriter instance to add. - */ -export function addWriter(writer: TraceWriter); - -/** - * Removes a TraceWriter instance from the trace module. - * @param writer The TraceWriter instance to remove. - */ -export function removeWriter(writer: TraceWriter); - -/** - * Clears all the writers from the trace module. - */ -export function clearWriters(); - -/** - * Sets the categories the module will trace. - * @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced. - */ -export function setCategories(categories: string); - -/** - * Adds categories to existing categories the module will trace. - * @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced. - */ -export function addCategories(categories: string); - -/** - * Check if category is already set in trace module. - * @param category The category to check. - */ -export function isCategorySet(category: string): boolean; - -/** - * Writes a message using the available writers. - * @param message The message to be written. - * @param category The category of the message. - * @param type Optional, the type of the message - info, warning, error. - */ -export function write(message: any, category: string, type?: number); - -/** - * Passes an error to the registered ErrorHandler - * @param error The error to be handled. - */ -export function error(error: string | Error); -/** - * Notifies all the attached listeners for an event that has occurred in the sender object. - * @param object The Object instance that raised the event. - * @param name The name of the raised event. - * @param data An optional parameter that passes the data associated with the event. - */ -export function notifyEvent(object: Object, name: string, data?: any); - -export function addEventListener(listener: EventListener); - -export function removeEventListener(listener: EventListener); - -export function getErrorHandler(): ErrorHandler; - -export function setErrorHandler(handler: ErrorHandler); - -/** - * An enum that defines all predefined categories. - */ -export module categories { - export const VisualTreeEvents: string; - export const Layout: string; - export const Style: string; - export const ViewHierarchy: string; - export const NativeLifecycle: string; - export const Debug: string; - export const Navigation: string; - export const Test: string; - export const Binding: string; - export const Error: string; - export const Animation: string; - export const Transition: string; - export const Livesync: string; - export const ModuleNameResolver: string; - - export const separator: string; - export const All: string; - - export function concat(...categories: string[]): string; -} - -/** - * An enum that defines all predefined message types. - */ -export module messageType { - export const log: number; - export const info: number; - export const warn: number; - export const error: number; -} - -/** - * An interface used to define a writer used by trace to print (log). - */ -export interface TraceWriter { - write(message: any, category: string, type?: number); -} - -/** - * An interface used to trace information about specific event. - */ -export interface EventListener { - filter: string; - on(object: Object, name: string, data?: any); -} - -/** - * An interface used to for handling trace error - */ -export interface ErrorHandler { - handlerError(error: Error); -} - -export class DefaultErrorHandler implements ErrorHandler { - handlerError(error); -} diff --git a/nativescript-core/trace/trace.ts b/nativescript-core/trace/trace.ts deleted file mode 100644 index 368a4c18d..000000000 --- a/nativescript-core/trace/trace.ts +++ /dev/null @@ -1,216 +0,0 @@ -import { EventListener, TraceWriter, ErrorHandler } from "."; - -let enabled = false; -let _categories = {}; -let _writers: Array = []; -let _eventListeners: Array = []; -let _errorHandler: ErrorHandler; - -export function enable() { - enabled = true; -} - -export function disable() { - enabled = false; -} - -export function isEnabled() { - return enabled; -} - -export function isCategorySet(category: string): boolean { - return category in _categories; -} - -export function addWriter(writer: TraceWriter) { - _writers.push(writer); -} - -export function removeWriter(writer: TraceWriter) { - let index = _writers.indexOf(writer); - if (index >= 0) { - _writers.splice(index, 1); - } -} - -export function clearWriters() { - if (_writers.length > 0) { - _writers.splice(0, _writers.length); - } -} - -export function setCategories(categories: string) { - _categories = {}; - addCategories(categories); -} - -export function addCategories(categories: string) { - let split = categories.split(","); - for (let i = 0; i < split.length; i++) { - _categories[split[i].trim()] = true; - } -} - -export function write(message: any, category: string, type?: number) { - // print error no matter what - let i; - if (type === messageType.error) { - for (i = 0; i < _writers.length; i++) { - _writers[i].write(message, category, type); - } - - return; - } - - if (!enabled) { - return; - } - - if (!(category in _categories)) { - return; - } - - for (i = 0; i < _writers.length; i++) { - _writers[i].write(message, category, type); - } -} - -export function notifyEvent(object: Object, name: string, data?: any) { - if (!enabled) { - return; - } - - let i, - listener: EventListener, - filters: Array; - for (i = 0; i < _eventListeners.length; i++) { - listener = _eventListeners[i]; - if (listener.filter) { - filters = listener.filter.split(","); - filters.forEach((value: string) => { - if (value.trim() === name) { - listener.on(object, name, data); - } - }); - } else { - listener.on(object, name, data); - } - } -} - -export function addEventListener(listener: EventListener) { - _eventListeners.push(listener); -} - -export function removeEventListener(listener: EventListener) { - const index = _eventListeners.indexOf(listener); - if (index >= 0) { - _eventListeners.splice(index, 1); - } -} - -export module messageType { - export const log = 0; - export const info = 1; - export const warn = 2; - export const error = 3; -} - -export module categories { - export const VisualTreeEvents = "VisualTreeEvents"; - export const Layout = "Layout"; - export const Style = "Style"; - export const ViewHierarchy = "ViewHierarchy"; - export const NativeLifecycle = "NativeLifecycle"; - export const Debug = "Debug"; - export const Navigation = "Navigation"; - export const Test = "Test"; - export const Binding = "Binding"; - export const BindingError = "BindingError"; - export const Error = "Error"; - export const Animation = "Animation"; - export const Transition = "Transition"; - export const Livesync = "Livesync"; - export const ModuleNameResolver = "ModuleNameResolver"; - - 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 { - let result: string; - for (let i = 0; i < arguments.length; i++) { - if (!result) { - result = arguments[i]; - continue; - } - - result = result.concat(separator, arguments[i]); - } - - return result; - } -} - -class ConsoleWriter implements TraceWriter { - public write(message: any, category: string, type?: number) { - if (!console) { - return; - } - - let msgType; - if (type === undefined) { - msgType = messageType.log; - } else { - msgType = type; - } - - switch (msgType) { - case messageType.log: - console.log(category + ": " + message); - break; - case messageType.info: - console.info(category + ": " + message); - break; - case messageType.warn: - console.warn(category + ": " + message); - break; - case messageType.error: - console.error(category + ": " + message); - break; - } - } -} -// register a ConsoleWriter by default -addWriter(new ConsoleWriter()); - -export class DefaultErrorHandler implements ErrorHandler { - handlerError(error) { - throw error; - } -} -setErrorHandler(new DefaultErrorHandler()); - -export function getErrorHandler(): ErrorHandler { - return _errorHandler; -} - -export function setErrorHandler(handler: ErrorHandler) { - _errorHandler = handler; -} -export function error(error: string | Error) { - if (!_errorHandler) { - return; - } - - if (typeof error === "string") { - error = new Error(error); - } - - _errorHandler.handlerError(error); -} diff --git a/nativescript-core/tsconfig.barrels.json b/nativescript-core/tsconfig.barrels.json index 6106fda72..c1e5f0323 100644 --- a/nativescript-core/tsconfig.barrels.json +++ b/nativescript-core/tsconfig.barrels.json @@ -6,14 +6,7 @@ "outDir": "../temp/dts-out" }, "files": [ - "index.ts", - "ui/index.ts", - "ui/layouts/index.ts" - ], - "include": [ - "index.ts", - "ui/index.ts", - "ui/layouts/index.ts" + "index.ts" ], "exclude": [ "tns-core-modules/node_modules/" diff --git a/nativescript-core/tsconfig.json b/nativescript-core/tsconfig.json index 973fb73e0..64c600e37 100644 --- a/nativescript-core/tsconfig.json +++ b/nativescript-core/tsconfig.json @@ -20,12 +20,7 @@ "chai", "mocha" ], - "baseUrl": ".", - "paths": { - "@nativescript/core/*": [ - "nativescript-core/*" - ] - } + "baseUrl": "." }, "include": [ "**/*.ts" diff --git a/nativescript-core/ui/action-bar/action-bar-common.ts b/nativescript-core/ui/action-bar/action-bar-common.ts index be5603e7d..627a02eb1 100644 --- a/nativescript-core/ui/action-bar/action-bar-common.ts +++ b/nativescript-core/ui/action-bar/action-bar-common.ts @@ -7,23 +7,16 @@ import { import { profile } from "../../profiling"; -export * from "../core/view"; - import { View, - ViewBase, - Property, - unsetValue, - booleanConverter, - horizontalAlignmentProperty, - verticalAlignmentProperty, CSSType, - traceWrite, - traceCategories, - traceMessageType } from "../core/view"; -import { ShorthandProperty, CssProperty, Style } from "../core/properties/properties"; -import { Length } from "../core/view"; +import { ViewBase, booleanConverter } from "../core/view-base"; +import { Trace } from "../../trace"; +import { ShorthandProperty, CssProperty, Property, unsetValue } from "../core/properties"; +import { Length, horizontalAlignmentProperty, + verticalAlignmentProperty } from "../styling/style-properties"; +import { Style } from '../styling/style'; export module knownCollections { export const actionItems = "actionItems"; @@ -378,9 +371,9 @@ function onVisibilityChanged(item: ActionItemBase, oldValue: string, newValue: s } export function traceMissingIcon(icon: string) { - traceWrite("Could not load action bar icon: " + icon, - traceCategories.Error, - traceMessageType.error); + Trace.write("Could not load action bar icon: " + icon, + Trace.categories.Error, + Trace.messageType.error); } function convertToContentInset(this: void, value: string | Length): [CssProperty, any][] { @@ -436,7 +429,7 @@ export const androidContentInsetLeftProperty = new CssProperty({ if (view) { view.effectiveContentInsetLeft = Length.toDevicePixels(newValue); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } }, valueConverter: Length.parse }); @@ -450,7 +443,7 @@ export const androidContentInsetRightProperty = new CssProperty({ if (view) { view.effectiveContentInsetRight = Length.toDevicePixels(newValue); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } }, valueConverter: Length.parse }); diff --git a/nativescript-core/ui/action-bar/action-bar.android.ts b/nativescript-core/ui/action-bar/action-bar.android.ts index 38b937f95..fe59fb8e2 100644 --- a/nativescript-core/ui/action-bar/action-bar.android.ts +++ b/nativescript-core/ui/action-bar/action-bar.android.ts @@ -1,9 +1,13 @@ import { AndroidActionItemSettings, AndroidActionBarSettings as AndroidActionBarSettingsDefinition, ActionItem as ActionItemDefinition } from "."; import { ActionItemBase, ActionBarBase, isVisible, - View, layout, colorProperty, flatProperty, Color, + flatProperty, traceMissingIcon, androidContentInsetLeftProperty, androidContentInsetRightProperty } from "./action-bar-common"; +import { View} from '../core/view'; +import { Color} from '../../color'; +import { layout} from '../../utils/utils'; +import { colorProperty} from '../core/bindable'; import { RESOURCE_PREFIX, isFontIconURI } from "../../utils/utils"; import { ImageSource } from "../../image-source"; import * as application from "../../application"; diff --git a/nativescript-core/ui/action-bar/action-bar.d.ts b/nativescript-core/ui/action-bar/action-bar.d.ts index fd3c00546..5b4b0b59d 100644 --- a/nativescript-core/ui/action-bar/action-bar.d.ts +++ b/nativescript-core/ui/action-bar/action-bar.d.ts @@ -1,9 +1,6 @@ -/** - * Contains the action bar related classes. - * @module "ui/action-bar" - */ /** */ - -import { EventData, ViewBase, View } from "../core/view"; +import { View } from "../core/view"; +import { ViewBase } from "../core/view-base"; +import { EventData } from "../../data/observable"; /** * Provides an abstraction over the ActionBar (android) and NavigationBar (iOS). diff --git a/nativescript-core/ui/activity-indicator/activity-indicator-common.ts b/nativescript-core/ui/activity-indicator/activity-indicator-common.ts index 2b33b0b5f..046120f26 100644 --- a/nativescript-core/ui/activity-indicator/activity-indicator-common.ts +++ b/nativescript-core/ui/activity-indicator/activity-indicator-common.ts @@ -1,8 +1,6 @@ import { ActivityIndicator as ActivityIndicatorDefinition } from "."; import { View, Property, booleanConverter, CSSType } from "../core/view"; -export * from "../core/view"; - @CSSType("ActivityIndicator") export class ActivityIndicatorBase extends View implements ActivityIndicatorDefinition { public busy: boolean; diff --git a/nativescript-core/ui/activity-indicator/activity-indicator.d.ts b/nativescript-core/ui/activity-indicator/activity-indicator.d.ts index ee9ed5a98..f135d3e14 100644 --- a/nativescript-core/ui/activity-indicator/activity-indicator.d.ts +++ b/nativescript-core/ui/activity-indicator/activity-indicator.d.ts @@ -1,9 +1,4 @@ -/** - * Contains the ActivityIndicator class, which represents a widget for showing that something is currently busy. - * @module "ui/activity-indicator" - */ /** */ - -import { View } from "../core/view"; +import { View } from "../core/view"; /** * Represents a UI widget which displays a progress indicator hinting the user for some background operation running. diff --git a/nativescript-core/ui/animation/animation-common.ts b/nativescript-core/ui/animation/animation-common.ts index 31344c33d..1ca06a220 100644 --- a/nativescript-core/ui/animation/animation-common.ts +++ b/nativescript-core/ui/animation/animation-common.ts @@ -12,12 +12,10 @@ import { // Requires. import { Color } from "../../color"; import { - isEnabled as traceEnabled, write as traceWrite, - categories as traceCategories, messageType as traceType + Trace } from "../../trace"; import { PercentLength } from "../styling/style-properties"; -export { Color, traceEnabled, traceWrite, traceCategories, traceType }; export * from "./animation-interfaces"; export module Properties { @@ -57,8 +55,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition { throw new Error("No animation definitions specified"); } - if (traceEnabled()) { - traceWrite("Analyzing " + animationDefinitions.length + " animation definitions...", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Analyzing " + animationDefinitions.length + " animation definitions...", Trace.categories.Animation); } this._propertyAnimations = new Array(); @@ -72,8 +70,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition { if (this._propertyAnimations.length === 0) { throw new Error("Nothing to animate."); } - if (traceEnabled()) { - traceWrite("Created " + this._propertyAnimations.length + " individual property animations.", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Created " + this._propertyAnimations.length + " individual property animations.", Trace.categories.Animation); } this._playSequentially = playSequentially; @@ -83,7 +81,7 @@ export abstract class AnimationBase implements AnimationBaseDefinition { protected _rejectAlreadyPlaying(): AnimationPromiseDefinition { const reason = "Animation is already playing."; - traceWrite(reason, traceCategories.Animation, traceType.warn); + Trace.write(reason, Trace.categories.Animation, Trace.messageType.warn); return new Promise((resolve, reject) => { reject(reason); diff --git a/nativescript-core/ui/animation/animation.android.ts b/nativescript-core/ui/animation/animation.android.ts index d9cff4378..81105df41 100644 --- a/nativescript-core/ui/animation/animation.android.ts +++ b/nativescript-core/ui/animation/animation.android.ts @@ -4,9 +4,10 @@ import { View } from "../core/view"; // Requires import { - AnimationBase, Properties, CubicBezierAnimationCurve, Color, traceWrite, - traceEnabled, traceCategories, traceType + AnimationBase, Properties, CubicBezierAnimationCurve } from "./animation-common"; +import { Color } from "../../color"; +import { Trace } from "../../trace"; import { opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty, @@ -44,40 +45,40 @@ propertyKeys[Properties.width] = Symbol(keyPrefix + Properties.width); export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator | android.view.animation.LinearInterpolator): android.view.animation.Interpolator { switch (curve) { case "easeIn": - if (traceEnabled()) { - traceWrite("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", Trace.categories.Animation); } return easeIn(); case "easeOut": - if (traceEnabled()) { - traceWrite("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", Trace.categories.Animation); } return easeOut(); case "easeInOut": - if (traceEnabled()) { - traceWrite("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", Trace.categories.Animation); } return easeInOut(); case "linear": - if (traceEnabled()) { - traceWrite("Animation curve resolved to android.view.animation.LinearInterpolator().", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Animation curve resolved to android.view.animation.LinearInterpolator().", Trace.categories.Animation); } return linear(); case "spring": - if (traceEnabled()) { - traceWrite("Animation curve resolved to android.view.animation.BounceInterpolator().", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Animation curve resolved to android.view.animation.BounceInterpolator().", Trace.categories.Animation); } return bounce(); case "ease": return (androidx).core.view.animation.PathInterpolatorCompat.create(0.25, 0.1, 0.25, 1.0); default: - if (traceEnabled()) { - traceWrite("Animation curve resolved to original: " + curve, traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Animation curve resolved to original: " + curve, Trace.categories.Animation); } if (curve instanceof CubicBezierAnimationCurve) { return (androidx).core.view.animation.PathInterpolatorCompat.create(curve.x1, curve.y1, curve.x2, curve.y2); @@ -143,18 +144,18 @@ export class Animation extends AnimationBase { let that = new WeakRef(this); this._animatorListener = new android.animation.Animator.AnimatorListener({ onAnimationStart: function (animator: android.animation.Animator): void { - if (traceEnabled()) { - traceWrite("MainAnimatorListener.onAndroidAnimationStart(" + animator + ")", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("MainAnimatorListener.onAndroidAnimationStart(" + animator + ")", Trace.categories.Animation); } }, onAnimationRepeat: function (animator: android.animation.Animator): void { - if (traceEnabled()) { - traceWrite("MainAnimatorListener.onAnimationRepeat(" + animator + ")", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("MainAnimatorListener.onAnimationRepeat(" + animator + ")", Trace.categories.Animation); } }, onAnimationEnd: function (animator: android.animation.Animator): void { - if (traceEnabled()) { - traceWrite("MainAnimatorListener.onAnimationEnd(" + animator + ")", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("MainAnimatorListener.onAnimationEnd(" + animator + ")", Trace.categories.Animation); } const thisRef = that.get(); if (thisRef) { @@ -162,8 +163,8 @@ export class Animation extends AnimationBase { } }, onAnimationCancel: function (animator: android.animation.Animator): void { - if (traceEnabled()) { - traceWrite("MainAnimatorListener.onAnimationCancel(" + animator + ")", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("MainAnimatorListener.onAnimationCancel(" + animator + ")", Trace.categories.Animation); } const thisRef = that.get(); if (thisRef) { @@ -207,12 +208,12 @@ export class Animation extends AnimationBase { public cancel(): void { if (!this.isPlaying) { - traceWrite("Animation is not currently playing.", traceCategories.Animation, traceType.warn); + Trace.write("Animation is not currently playing.", Trace.categories.Animation, Trace.messageType.warn); return; } - traceWrite("Cancelling AnimatorSet.", traceCategories.Animation); + Trace.write("Cancelling AnimatorSet.", Trace.categories.Animation); this._animatorSet.cancel(); } @@ -238,8 +239,8 @@ export class Animation extends AnimationBase { } } - if (traceEnabled()) { - traceWrite("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), Trace.categories.Animation); } this._animatorSet.setupStartValues(); @@ -276,8 +277,8 @@ export class Animation extends AnimationBase { return; } - if (traceEnabled()) { - traceWrite("Creating ObjectAnimator(s) for animation: " + Animation._getAnimationInfo(propertyAnimation) + "...", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Creating ObjectAnimator(s) for animation: " + Animation._getAnimationInfo(propertyAnimation) + "...", Trace.categories.Animation); } if (propertyAnimation.target === null || propertyAnimation.target === undefined) { @@ -546,8 +547,8 @@ export class Animation extends AnimationBase { animators[i].setInterpolator(propertyAnimation.curve); } - if (traceEnabled()) { - traceWrite("Animator created: " + animators[i], traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Animator created: " + animators[i], Trace.categories.Animation); } } diff --git a/nativescript-core/ui/animation/animation.d.ts b/nativescript-core/ui/animation/animation.d.ts index cffda757f..14b1989c2 100644 --- a/nativescript-core/ui/animation/animation.d.ts +++ b/nativescript-core/ui/animation/animation.d.ts @@ -1,8 +1,5 @@ -/** - * @module "ui/animation" - */ /** */ - -import { View, Color } from "../core/view"; +import { View } from "../core/view"; +import { Color } from "../../color"; import { PercentLength } from "../styling/style-properties"; /** diff --git a/nativescript-core/ui/animation/animation.ios.ts b/nativescript-core/ui/animation/animation.ios.ts index b1f816aa2..d1c431d59 100644 --- a/nativescript-core/ui/animation/animation.ios.ts +++ b/nativescript-core/ui/animation/animation.ios.ts @@ -7,9 +7,9 @@ import { View } from "../core/view"; // Requires import { - AnimationBase, Properties, CubicBezierAnimationCurve, - traceWrite, traceEnabled, traceCategories, traceType + AnimationBase, Properties, CubicBezierAnimationCurve } from "./animation-common"; +import { Trace } from "../../trace"; import { opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty, @@ -167,12 +167,12 @@ export class Animation extends AnimationBase { } if (!playSequentially) { - if (traceEnabled()) { - traceWrite("Non-merged Property Animations: " + this._propertyAnimations.length, traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Non-merged Property Animations: " + this._propertyAnimations.length, Trace.categories.Animation); } this._mergedPropertyAnimations = Animation._mergeAffineTransformAnimations(this._propertyAnimations); - if (traceEnabled()) { - traceWrite("Merged Property Animations: " + this._mergedPropertyAnimations.length, traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Merged Property Animations: " + this._mergedPropertyAnimations.length, Trace.categories.Animation); } } else { @@ -200,14 +200,14 @@ export class Animation extends AnimationBase { } if (that._cancelledAnimations > 0 && (that._cancelledAnimations + that._finishedAnimations) === that._mergedPropertyAnimations.length) { - if (traceEnabled()) { - traceWrite(that._cancelledAnimations + " animations cancelled.", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write(that._cancelledAnimations + " animations cancelled.", Trace.categories.Animation); } that._rejectAnimationFinishedPromise(); } else if (that._finishedAnimations === that._mergedPropertyAnimations.length) { - if (traceEnabled()) { - traceWrite(that._finishedAnimations + " animations finished.", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write(that._finishedAnimations + " animations finished.", Trace.categories.Animation); } that._resolveAnimationFinishedPromise(); } @@ -232,7 +232,7 @@ export class Animation extends AnimationBase { public cancel(): void { if (!this.isPlaying) { - traceWrite("Animation is not currently playing.", traceCategories.Animation, traceType.warn); + Trace.write("Animation is not currently playing.", Trace.categories.Animation, Trace.messageType.warn); return; } @@ -256,8 +256,8 @@ export class Animation extends AnimationBase { return (cancelled?: boolean) => { if (cancelled && finishedCallback) { - if (traceEnabled()) { - traceWrite("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", Trace.categories.Animation); } finishedCallback(cancelled); @@ -664,12 +664,12 @@ export class Animation extends AnimationBase { iterations: propertyAnimations[i].iterations, curve: propertyAnimations[i].curve }; - if (traceEnabled()) { - traceWrite("Curve: " + propertyAnimations[i].curve, traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Curve: " + propertyAnimations[i].curve, Trace.categories.Animation); } newTransformAnimation.value[propertyAnimations[i].property] = propertyAnimations[i].value; - if (traceEnabled()) { - traceWrite("Created new transform animation: " + Animation._getAnimationInfo(newTransformAnimation), traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Created new transform animation: " + Animation._getAnimationInfo(newTransformAnimation), Trace.categories.Animation); } // Merge all compatible affine transform animations to the right into this new animation. @@ -677,8 +677,8 @@ export class Animation extends AnimationBase { if (j < length) { for (; j < length; j++) { if (Animation._canBeMerged(propertyAnimations[i], propertyAnimations[j])) { - if (traceEnabled()) { - traceWrite("Merging animations: " + Animation._getAnimationInfo(newTransformAnimation) + " + " + Animation._getAnimationInfo(propertyAnimations[j]) + ";", traceCategories.Animation); + if (Trace.isEnabled()) { + Trace.write("Merging animations: " + Animation._getAnimationInfo(newTransformAnimation) + " + " + Animation._getAnimationInfo(propertyAnimations[j]) + ";", Trace.categories.Animation); } newTransformAnimation.value[propertyAnimations[j].property] = propertyAnimations[j].value; // Mark that it has been merged so we can skip it on our outer loop. diff --git a/nativescript-core/ui/animation/keyframe-animation.d.ts b/nativescript-core/ui/animation/keyframe-animation.d.ts index 8682aab13..7ddbd5776 100644 --- a/nativescript-core/ui/animation/keyframe-animation.d.ts +++ b/nativescript-core/ui/animation/keyframe-animation.d.ts @@ -1,7 +1,3 @@ -/** - * @module "ui/animation/keyframe-animation" - */ /** */ - import { View } from "../core/view"; export declare const ANIMATION_PROPERTIES; diff --git a/nativescript-core/ui/animation/keyframe-animation.ts b/nativescript-core/ui/animation/keyframe-animation.ts index f500d6f10..b00db38ae 100644 --- a/nativescript-core/ui/animation/keyframe-animation.ts +++ b/nativescript-core/ui/animation/keyframe-animation.ts @@ -8,11 +8,12 @@ import { KeyframeAnimation as KeyframeAnimationDefinition, } from "./keyframe-animation"; -import { View, Color } from "../core/view"; +import { View } from "../core/view"; +import { Color } from "../../color"; import { AnimationCurve } from "../enums"; -import { write as traceWrite, categories as traceCategories, messageType as traceType } from "../../trace"; +import { Trace } from "../../trace"; // Types. import { unsetValue } from "../core/properties"; @@ -148,7 +149,7 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition { public cancel() { if (!this.isPlaying) { - traceWrite("Keyframe animation is already playing.", traceCategories.Animation, traceType.warn); + Trace.write("Keyframe animation is already playing.", Trace.categories.Animation, Trace.messageType.warn); return; } @@ -169,7 +170,7 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition { public play(view: View): Promise { if (this._isPlaying) { - traceWrite("Keyframe animation is already playing.", traceCategories.Animation, traceType.warn); + Trace.write("Keyframe animation is already playing.", Trace.categories.Animation, Trace.messageType.warn); return new Promise(resolve => { resolve(); @@ -262,9 +263,9 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition { animation.play(isLastIteration).then(() => { this.animate(view, index + 1, iterations); }, (error: any) => { - traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn); + Trace.write(typeof error === "string" ? error : error.message, Trace.categories.Animation, Trace.messageType.warn); }).catch((error: any) => { - traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn); + Trace.write(typeof error === "string" ? error : error.message, Trace.categories.Animation, Trace.messageType.warn); }); // tslint:disable-line } } diff --git a/nativescript-core/ui/border/border.d.ts b/nativescript-core/ui/border/border.d.ts index 9c7baf7df..df3212c6e 100644 --- a/nativescript-core/ui/border/border.d.ts +++ b/nativescript-core/ui/border/border.d.ts @@ -1,9 +1,4 @@ -/** - * Contains the Border class, which represents a UI border component. - * @module "ui/animation/keyframe-animation" - */ /** */ - -import { ContentView } from "../content-view"; +import { ContentView } from "../content-view"; /** * Represents a UI border component. diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts b/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts index 091a1a5eb..8013902aa 100644 --- a/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts +++ b/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts @@ -8,8 +8,9 @@ import { TextTransform } from "../text-base"; import * as application from "../../application"; import { ImageSource } from "../../image-source"; import { ad, isFontIconURI, layout, RESOURCE_PREFIX } from "../../utils/utils"; -import { Color, CSSType } from "../core/view"; -import { Frame, View } from "../frame"; +import { CSSType, View } from "../core/view"; +import { Color } from "../../color"; +import { Frame } from "../frame"; import { Font } from "../styling/font"; import { getIconSpecSize, itemsProperty, selectedIndexProperty, TabNavigationBase, tabStripProperty @@ -17,7 +18,7 @@ import { import { getTransformedText } from "../text-base"; // TODO: Impl trace -// import { isEnabled as traceEnabled, write as traceWrite } from "../../../trace"; +// import { Trace } from "../../../trace"; const PRIMARY_COLOR = "colorPrimary"; const DEFAULT_ELEVATION = 8; @@ -278,8 +279,8 @@ export class BottomNavigation extends TabNavigationBase { public createNativeView() { initializeNativeClasses(); - // if (traceEnabled()) { - // traceWrite("BottomNavigation._createUI(" + this + ");", traceCategory); + // if (Trace.isEnabled()) { + // Trace.write("BottomNavigation._createUI(" + this + ");", traceCategory); // } const context: android.content.Context = this._context; @@ -848,8 +849,8 @@ export class BottomNavigation extends TabNavigationBase { [selectedIndexProperty.setNative](value: number) { // const smoothScroll = false; - // if (traceEnabled()) { - // traceWrite("TabView this._viewPager.setCurrentItem(" + value + ", " + smoothScroll + ");", traceCategory); + // if (Trace.isEnabled()) { + // Trace.write("TabView this._viewPager.setCurrentItem(" + value + ", " + smoothScroll + ");", traceCategory); // } if (this.tabStrip) { diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.d.ts b/nativescript-core/ui/bottom-navigation/bottom-navigation.d.ts index c417292ad..568935d75 100644 --- a/nativescript-core/ui/bottom-navigation/bottom-navigation.d.ts +++ b/nativescript-core/ui/bottom-navigation/bottom-navigation.d.ts @@ -1,12 +1,8 @@ -/** - * Contains the BottomNavigation class, which represents a tab navigation widget with static tabs at the bottom. - * @module "ui/tab-navigation/bottom-navigation" - */ /** */ - -import { TabNavigationBase } from "../tab-navigation-base/tab-navigation-base"; +import { TabNavigationBase } from "../tab-navigation-base/tab-navigation-base"; import { TabContentItem } from "../tab-navigation-base/tab-content-item"; import { TabStrip } from "../tab-navigation-base/tab-strip"; -import { Property, CoercibleProperty, EventData } from "../core/view"; +import { Property, CoercibleProperty } from "../core/properties"; +import { EventData } from "../../data/observable"; /** * Defines the data for the TabView.selectedIndexChanged event. diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts b/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts index 9d7eeeeff..2e8c8536a 100644 --- a/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts +++ b/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts @@ -110,8 +110,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl public tabBarControllerShouldSelectViewController(tabBarController: UITabBarController, viewController: UIViewController): boolean { // TODO - // if (traceEnabled()) { - // traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug); // } let owner = this._owner.get(); @@ -145,8 +145,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl public tabBarControllerDidSelectViewController(tabBarController: UITabBarController, viewController: UIViewController): void { // TODO - // if (traceEnabled()) { - // traceWrite("TabView.delegate.DID_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView.delegate.DID_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug); // } const owner = this._owner.get(); @@ -172,8 +172,8 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio navigationControllerWillShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void { // TODO - // if (traceEnabled()) { - // traceWrite("TabView.moreNavigationController.WILL_show(" + navigationController + ", " + viewController + ", " + animated + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView.moreNavigationController.WILL_show(" + navigationController + ", " + viewController + ", " + animated + ");", Trace.categories.Debug); // } let owner = this._owner.get(); @@ -187,8 +187,8 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio navigationControllerDidShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void { // TODO - // if (traceEnabled()) { - // traceWrite("TabView.moreNavigationController.DID_show(" + navigationController + ", " + viewController + ", " + animated + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView.moreNavigationController.DID_show(" + navigationController + ", " + viewController + ", " + animated + ");", Trace.categories.Debug); // } // We don't need Edit button in More screen. navigationController.navigationBar.topItem.rightBarButtonItem = null; @@ -454,15 +454,15 @@ export class BottomNavigation extends TabNavigationBase { public _onViewControllerShown(viewController: UIViewController) { // This method could be called with the moreNavigationController or its list controller, so we have to check. // TODO - // if (traceEnabled()) { - // traceWrite("TabView._onViewControllerShown(" + viewController + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView._onViewControllerShown(" + viewController + ");", Trace.categories.Debug); // } if (this._ios.viewControllers && this._ios.viewControllers.containsObject(viewController)) { this.selectedIndex = this._ios.viewControllers.indexOfObject(viewController); } else { // TODO - // if (traceEnabled()) { - // traceWrite("TabView._onViewControllerShown: viewController is not one of our viewControllers", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView._onViewControllerShown: viewController is not one of our viewControllers", Trace.categories.Debug); // } } } @@ -470,8 +470,8 @@ export class BottomNavigation extends TabNavigationBase { private _actionBarHiddenByTabView: boolean; public _handleTwoNavigationBars(backToMoreWillBeVisible: boolean) { // TODO - // if (traceEnabled()) { - // traceWrite(`TabView._handleTwoNavigationBars(backToMoreWillBeVisible: ${backToMoreWillBeVisible})`, traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write(`TabView._handleTwoNavigationBars(backToMoreWillBeVisible: ${backToMoreWillBeVisible})`, Trace.categories.Debug); // } // The "< Back" and "< More" navigation bars should not be visible simultaneously. @@ -489,8 +489,8 @@ export class BottomNavigation extends TabNavigationBase { this._actionBarHiddenByTabView = true; // TODO - // if (traceEnabled()) { - // traceWrite(`TabView hid action bar`, traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write(`TabView hid action bar`, Trace.categories.Debug); // } return; } @@ -502,8 +502,8 @@ export class BottomNavigation extends TabNavigationBase { this._actionBarHiddenByTabView = undefined; // TODO - // if (traceEnabled()) { - // traceWrite(`TabView restored action bar`, traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write(`TabView restored action bar`, Trace.categories.Debug); // } return; } @@ -729,8 +729,8 @@ export class BottomNavigation extends TabNavigationBase { [selectedIndexProperty.setNative](value: number) { // TODO - // if (traceEnabled()) { - // traceWrite("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", Trace.categories.Debug); // } if (value > -1) { diff --git a/nativescript-core/ui/builder/binding-builder.d.ts b/nativescript-core/ui/builder/binding-builder.d.ts index d0e14be7c..ad899f7a4 100644 --- a/nativescript-core/ui/builder/binding-builder.d.ts +++ b/nativescript-core/ui/builder/binding-builder.d.ts @@ -1,9 +1,4 @@ -/** - * @module "ui/builder/binding-builder" - * @private - */ /** */ - -//@private +//@private export module bindingConstants { export const sourceProperty: string; export const targetProperty: string; diff --git a/nativescript-core/ui/builder/builder.d.ts b/nativescript-core/ui/builder/builder.d.ts index 1737eb07d..efa9b5822 100644 --- a/nativescript-core/ui/builder/builder.d.ts +++ b/nativescript-core/ui/builder/builder.d.ts @@ -1,8 +1,4 @@ -/** - * @module "ui/builder" - */ /** */ - -import { View, Template, KeyedTemplate } from "../core/view"; +import { View, Template, KeyedTemplate } from "../core/view"; import { Page } from "../page"; import { NavigationEntry } from "../frame"; diff --git a/nativescript-core/ui/builder/component-builder/component-builder.d.ts b/nativescript-core/ui/builder/component-builder/component-builder.d.ts index 9f9855c1d..08d9b4bcc 100644 --- a/nativescript-core/ui/builder/component-builder/component-builder.d.ts +++ b/nativescript-core/ui/builder/component-builder/component-builder.d.ts @@ -1,7 +1,3 @@ -/** - * @module "ui/builder/component-builder" - */ /** */ - import { View } from "../../core/view"; export interface ComponentModule { diff --git a/nativescript-core/ui/builder/module-name-sanitizer.d.ts b/nativescript-core/ui/builder/module-name-sanitizer.d.ts index 2d3091a73..2a844296a 100644 --- a/nativescript-core/ui/builder/module-name-sanitizer.d.ts +++ b/nativescript-core/ui/builder/module-name-sanitizer.d.ts @@ -1,5 +1 @@ -/** - * @module "ui/builder/module-name-sanitizer" - */ /** */ - export function sanitizeModuleName(moduleName: string, removeExtension?: boolean): string; diff --git a/nativescript-core/ui/button/button-common.ts b/nativescript-core/ui/button/button-common.ts index a891d7c1d..f53ba70c0 100644 --- a/nativescript-core/ui/button/button-common.ts +++ b/nativescript-core/ui/button/button-common.ts @@ -1,5 +1,7 @@ import { Button as ButtonDefinition } from "."; -import { TextBase, booleanConverter, CSSType } from "../text-base"; +import { TextBase } from "../text-base"; +import { CSSType } from "../core/view"; +import { booleanConverter } from "../core/view-base"; @CSSType("Button") export abstract class ButtonBase extends TextBase implements ButtonDefinition { diff --git a/nativescript-core/ui/button/button.android.ts b/nativescript-core/ui/button/index.android.ts similarity index 100% rename from nativescript-core/ui/button/button.android.ts rename to nativescript-core/ui/button/index.android.ts diff --git a/nativescript-core/ui/button/button.d.ts b/nativescript-core/ui/button/index.d.ts similarity index 90% rename from nativescript-core/ui/button/button.d.ts rename to nativescript-core/ui/button/index.d.ts index b40f6e367..6f6ba56c0 100644 --- a/nativescript-core/ui/button/button.d.ts +++ b/nativescript-core/ui/button/index.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the Button class, which represents a standard button widget. - * @module "ui/button" - */ /** */ - -import { TextBase, EventData } from "../text-base"; +import { TextBase } from "../text-base"; +import { EventData } from "../../data/observable"; /** * Represents a standard Button widget. diff --git a/nativescript-core/ui/button/button.ios.ts b/nativescript-core/ui/button/index.ios.ts similarity index 100% rename from nativescript-core/ui/button/button.ios.ts rename to nativescript-core/ui/button/index.ios.ts diff --git a/nativescript-core/ui/button/package.json b/nativescript-core/ui/button/package.json deleted file mode 100644 index d89b3fe95..000000000 --- a/nativescript-core/ui/button/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "button", - "main": "button", - "types": "button.d.ts" -} diff --git a/nativescript-core/ui/content-view/content-view.d.ts b/nativescript-core/ui/content-view/content-view.d.ts deleted file mode 100644 index 917d8ac11..000000000 --- a/nativescript-core/ui/content-view/content-view.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * View that can host another view. - * @module "ui/content-view" - */ /** */ - -import { View, AddChildFromBuilder } from "../core/view"; - -export * from "../core/view"; - -/** - * Represents a View that has a single child - content. - * The View itself does not have visual representation and serves as a placeholder for its content in the logical tree. - */ -export class ContentView extends View implements AddChildFromBuilder { - /** - * Gets or sets the single child of the view. - */ - content: View; - - //@private - /** - * Called when the content property has changed. - * @private - * @param oldView The previous content. - * @param newView The new content. - */ - _onContentChanged(oldView: View, newView: View); - //@endprivate - - _addChildFromBuilder(name: string, value: any): void; - - layoutView: View; -} diff --git a/nativescript-core/ui/content-view/content-view.ts b/nativescript-core/ui/content-view/index.ts similarity index 81% rename from nativescript-core/ui/content-view/content-view.ts rename to nativescript-core/ui/content-view/index.ts index 4bcbfe650..3c0691b14 100644 --- a/nativescript-core/ui/content-view/content-view.ts +++ b/nativescript-core/ui/content-view/index.ts @@ -1,9 +1,18 @@ -import { ContentView as ContentViewDefinition } from "."; -import { View, CustomLayoutView, AddChildFromBuilder, layout, isIOS } from "../core/view"; +import { View, CustomLayoutView, AddChildFromBuilder } from "../core/view"; +import { layout } from "../../utils/utils"; +import { isIOS } from "../../platform"; +import { ContentView as ContentViewDefinition } from "."; +/** + * Represents a View that has a single child - content. + * The View itself does not have visual representation and serves as a placeholder for its content in the logical tree. + */ export class ContentView extends CustomLayoutView implements ContentViewDefinition, AddChildFromBuilder { private _content: View; + /** + * Gets or sets the single child of the view. + */ get content(): View { return this._content; } @@ -47,6 +56,13 @@ export class ContentView extends CustomLayoutView implements ContentViewDefiniti return this._content ? 1 : 0; } + //@private + /** + * Called when the content property has changed. + * @private + * @param oldView The previous content. + * @param newView The new content. + */ public _onContentChanged(oldView: View, newView: View) { // } diff --git a/nativescript-core/ui/content-view/package.json b/nativescript-core/ui/content-view/package.json deleted file mode 100644 index 811ae93a9..000000000 --- a/nativescript-core/ui/content-view/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "content-view", - "main": "content-view", - "types": "content-view.d.ts" -} diff --git a/nativescript-core/ui/core/bindable/bindable.d.ts b/nativescript-core/ui/core/bindable/bindable.d.ts deleted file mode 100644 index a57d48468..000000000 --- a/nativescript-core/ui/core/bindable/bindable.d.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @module "ui/core/bindable" - */ /** */ - -import { ViewBase } from "../view-base"; -import { Observable, WrappedValue, PropertyChangeData, EventData } from "../../../data/observable"; -import { - isEnabled as traceEnabled, - write as traceWrite, - error as traceError, - categories as traceCategories, - notifyEvent as traceNotifyEvent, - messageType as traceMessageType, - isCategorySet -} from "../../../trace"; - -export { - Observable, WrappedValue, PropertyChangeData, EventData, - traceEnabled, traceWrite, traceError, traceCategories, traceNotifyEvent, - traceMessageType, isCategorySet -}; - -/** - * The options object used in the Bindable.bind method. - */ -export interface BindingOptions { - /** - * The property name of the source object (typically the ViewModel) to bind to. - */ - sourceProperty: string; - /** - * The property name of the target object (that is the Bindable instance) to bind the source property to. - */ - targetProperty: string; - /** - * True to establish a two-way binding, false otherwise. A two-way binding will synchronize both the source and the target property values regardless of which one initiated the change. - */ - twoWay?: boolean; - /** - * An expression used for calculations (convertions) based on the value of the property. - */ - expression?: string; -} - -/** - * An interface which defines methods need to create binding value converter. - */ -export interface ValueConverter { - /** - * A method that will be executed when a value (of the binding property) should be converted to the observable model. - * For example: user types in a text field, but our business logic requires to store data in a different manner (e.g. in lower case). - * @param params - An array of parameters where first element is the value of the property and next elements are parameters send to converter. - */ - toModel: (...params: any[]) => any; - /** - * A method that will be executed when a value should be converted to the UI view. For example we have a date object which should be displayed to the end user in a specific date format. - * @param params - An array of parameters where first element is the value of the property and next elements are parameters send to converter. - */ - toView: (...params: any[]) => any; -} - -export class Binding { - constructor(target: ViewBase, options: BindingOptions); - public bind(source: Object): void; - public unbind(); - public sourceIsBindingContext: boolean; - public updateTwoWay(value: any); -} - -export function getEventOrGestureName(name: string): string; -export function isEventOrGesture(name: string, view: ViewBase): boolean; diff --git a/nativescript-core/ui/core/bindable/bindable.ts b/nativescript-core/ui/core/bindable/index.ts similarity index 91% rename from nativescript-core/ui/core/bindable/bindable.ts rename to nativescript-core/ui/core/bindable/index.ts index 645d5968b..aef7c5d21 100644 --- a/nativescript-core/ui/core/bindable/bindable.ts +++ b/nativescript-core/ui/core/bindable/index.ts @@ -1,5 +1,4 @@ // Types -import { BindingOptions } from "."; import { ViewBase } from "../view-base"; // Requires @@ -9,13 +8,7 @@ import { addWeakEventListener, removeWeakEventListener } from "../weak-event-lis import { bindingConstants, parentsRegex } from "../../builder/binding-builder"; import { escapeRegexSymbols } from "../../../utils/utils"; import { - isEnabled as traceEnabled, - write as traceWrite, - error as traceError, - categories as traceCategories, - notifyEvent as traceNotifyEvent, - isCategorySet, - messageType as traceMessageType + Trace } from "../../../trace"; import * as types from "../../../utils/types"; import * as bindableResources from "./bindable-resources"; @@ -59,6 +52,45 @@ function getProperties(property: string): Array { return result; } +/** + * The options object used in the Bindable.bind method. + */ +export interface BindingOptions { + /** + * The property name of the source object (typically the ViewModel) to bind to. + */ + sourceProperty: string; + /** + * The property name of the target object (that is the Bindable instance) to bind the source property to. + */ + targetProperty: string; + /** + * True to establish a two-way binding, false otherwise. A two-way binding will synchronize both the source and the target property values regardless of which one initiated the change. + */ + twoWay?: boolean; + /** + * An expression used for calculations (convertions) based on the value of the property. + */ + expression?: string; +} + +/** + * An interface which defines methods need to create binding value converter. + */ +export interface ValueConverter { + /** + * A method that will be executed when a value (of the binding property) should be converted to the observable model. + * For example: user types in a text field, but our business logic requires to store data in a different manner (e.g. in lower case). + * @param params - An array of parameters where first element is the value of the property and next elements are parameters send to converter. + */ + toModel: (...params: any[]) => any; + /** + * A method that will be executed when a value should be converted to the UI view. For example we have a date object which should be displayed to the end user in a specific date format. + * @param params - An array of parameters where first element is the value of the property and next elements are parameters send to converter. + */ + toView: (...params: any[]) => any; +} + export function getEventOrGestureName(name: string): string { return name.indexOf("on") === 0 ? name.substr(2, name.length - 2) : name; } @@ -348,7 +380,7 @@ export class Binding { let expressionValue = this._getExpressionValue(updateExpression, true, changedModel); if (expressionValue instanceof Error) { - traceWrite((expressionValue).message, traceCategories.Binding, traceMessageType.error); + Trace.write((expressionValue).message, Trace.categories.Binding, Trace.messageType.error); } newValue = expressionValue; @@ -410,7 +442,7 @@ export class Binding { if (this.options.expression) { const expressionValue = this._getExpressionValue(this.options.expression, false, undefined); if (expressionValue instanceof Error) { - traceWrite(expressionValue.message, traceCategories.Binding, traceMessageType.error); + Trace.write(expressionValue.message, Trace.categories.Binding, Trace.messageType.error); } else { this.updateTarget(expressionValue); } @@ -517,7 +549,7 @@ export class Binding { changedModel[bc.bindingValueKey] = this.source ? this.source.get() : undefined; let expressionValue = this._getExpressionValue(this.options.expression, false, changedModel); if (expressionValue instanceof Error) { - traceWrite((expressionValue).message, traceCategories.Binding, traceMessageType.error); + Trace.write((expressionValue).message, Trace.categories.Binding, Trace.messageType.error); } else { return expressionValue; @@ -534,7 +566,7 @@ export class Binding { this.sourceOptions.property in sourceOptionsInstance) { return sourceOptionsInstance[this.sourceOptions.property]; } else { - traceWrite("Property: '" + this.sourceOptions.property + "' is invalid or does not exist. SourceProperty: '" + this.options.sourceProperty + "'", traceCategories.Binding, traceMessageType.error); + Trace.write("Property: '" + this.sourceOptions.property + "' is invalid or does not exist. SourceProperty: '" + this.options.sourceProperty + "'", Trace.categories.Binding, Trace.messageType.error); } } @@ -635,9 +667,9 @@ export class Binding { optionsInstance[options.property] = value; } } catch (ex) { - traceWrite("Binding error while setting property " + options.property + " of " + optionsInstance + ": " + ex, - traceCategories.Binding, - traceMessageType.error); + Trace.write("Binding error while setting property " + options.property + " of " + optionsInstance + ": " + ex, + Trace.categories.Binding, + Trace.messageType.error); } this.updating = false; diff --git a/nativescript-core/ui/core/bindable/package.json b/nativescript-core/ui/core/bindable/package.json deleted file mode 100644 index bb0f5b88c..000000000 --- a/nativescript-core/ui/core/bindable/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "bindable", - "main": "bindable", - "types": "bindable.d.ts" -} diff --git a/nativescript-core/ui/core/control-state-change/control-state-change.d.ts b/nativescript-core/ui/core/control-state-change/control-state-change.d.ts index 5d7eb493a..2b28ef316 100644 --- a/nativescript-core/ui/core/control-state-change/control-state-change.d.ts +++ b/nativescript-core/ui/core/control-state-change/control-state-change.d.ts @@ -1,8 +1,4 @@ /** - * @module "ui/core/control-state-change" - */ /** */ - -/** * An utility class used for supporting styling infrastructure. * WARNING: This class is intended for IOS only. */ diff --git a/nativescript-core/ui/core/properties/properties.ts b/nativescript-core/ui/core/properties/index.ts similarity index 94% rename from nativescript-core/ui/core/properties/properties.ts rename to nativescript-core/ui/core/properties/index.ts index a3e2e7ad4..aa372bf01 100644 --- a/nativescript-core/ui/core/properties/properties.ts +++ b/nativescript-core/ui/core/properties/index.ts @@ -1,23 +1,55 @@ import * as reduceCSSCalc from "reduce-css-calc"; -// Definitions. -import * as definitions from "../view-base"; import { ViewBase } from "../view-base"; // Types. import { WrappedValue, PropertyChangeData } from "../../../data/observable"; import { - write as traceWrite, - categories as traceCategories, - messageType as traceMessageType, + Trace } from "../../../trace"; import { Style } from "../../styling/style"; import { profile } from "../../../profiling"; +/** + * Value specifing that Property should be set to its initial value. + */ export const unsetValue: any = new Object(); +export interface PropertyOptions { + readonly name: string; + readonly defaultValue?: U; + readonly affectsLayout?: boolean; + readonly equalityComparer?: (x: U, y: U) => boolean; + readonly valueChanged?: (target: T, oldValue: U, newValue: U) => void; + readonly valueConverter?: (value: string) => U; +} + +export interface CoerciblePropertyOptions extends PropertyOptions { + readonly coerceValue: (t: T, u: U) => U; +} + +export interface CssPropertyOptions extends PropertyOptions { + readonly cssName: string; +} + +export interface ShorthandPropertyOptions

{ + readonly name: string, + readonly cssName: string; + readonly converter: (value: string | P) => [CssProperty | CssAnimationProperty, any][], + readonly getter: (this: Style) => string | P +} + +export interface CssAnimationPropertyOptions { + readonly name: string; + readonly cssName?: string; + readonly defaultValue?: U; + readonly equalityComparer?: (x: U, y: U) => boolean; + readonly valueChanged?: (target: T, oldValue: U, newValue: U) => void; + readonly valueConverter?: (value: string) => U; +} + let cssPropertyNames: string[] = []; let symbolPropertyMap = {}; let cssSymbolPropertyMap = {}; @@ -132,7 +164,7 @@ function getPropertiesFromMap(map): Property[] | CssProperty return props; } -export class Property implements TypedPropertyDescriptor, definitions.Property { +export class Property implements TypedPropertyDescriptor, Property { private registered: boolean; public readonly name: string; @@ -152,7 +184,7 @@ export class Property implements TypedPropertyDescriptor< public enumerable: boolean = true; public configurable: boolean = true; - constructor(options: definitions.PropertyOptions) { + constructor(options: PropertyOptions) { const propertyName = options.name; this.name = propertyName; @@ -302,10 +334,10 @@ export class Property implements TypedPropertyDescriptor< } Property.prototype.isStyleProperty = false; -export class CoercibleProperty extends Property implements definitions.CoercibleProperty { +export class CoercibleProperty extends Property implements CoercibleProperty { public readonly coerce: (target: T) => void; - constructor(options: definitions.CoerciblePropertyOptions) { + constructor(options: CoerciblePropertyOptions) { super(options); const propertyName = options.name; @@ -415,11 +447,11 @@ export class CoercibleProperty extends Property imp } } -export class InheritedProperty extends Property implements definitions.InheritedProperty { +export class InheritedProperty extends Property implements InheritedProperty { public readonly sourceKey: symbol; public readonly setInheritedValue: (value: U) => void; - constructor(options: definitions.PropertyOptions) { + constructor(options: PropertyOptions) { super(options); const name = options.name; const key = this.key; @@ -488,7 +520,7 @@ export class InheritedProperty extends Property imp } } -export class CssProperty implements definitions.CssProperty { +export class CssProperty implements CssProperty { private registered: boolean; public readonly name: string; @@ -507,7 +539,7 @@ export class CssProperty implements definitions.CssProperty< public readonly defaultValueKey: symbol; public readonly defaultValue: U; - constructor(options: definitions.CssPropertyOptions) { + constructor(options: CssPropertyOptions) { const propertyName = options.name; this.name = propertyName; @@ -545,7 +577,7 @@ export class CssProperty implements definitions.CssProperty< function setLocalValue(this: T, newValue: U | string): void { const view = this.viewRef.get(); if (!view) { - traceWrite(`${newValue} not set to view because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); return; } @@ -619,7 +651,7 @@ export class CssProperty implements definitions.CssProperty< function setCssValue(this: T, newValue: U | string): void { const view = this.viewRef.get(); if (!view) { - traceWrite(`${newValue} not set to view because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); return; } @@ -736,7 +768,7 @@ export class CssProperty implements definitions.CssProperty< } CssProperty.prototype.isStyleProperty = true; -export class CssAnimationProperty implements definitions.CssAnimationProperty { +export class CssAnimationProperty implements CssAnimationProperty { public readonly name: string; public readonly cssName: string; public readonly cssLocalName: string; @@ -759,7 +791,7 @@ export class CssAnimationProperty implements definitions.Css public _valueConverter?: (value: string) => any; - constructor(options: definitions.CssAnimationPropertyOptions) { + constructor(options: CssAnimationPropertyOptions) { const { valueConverter, equalityComparer, valueChanged, defaultValue } = options; const propertyName = options.name; this.name = propertyName; @@ -809,7 +841,7 @@ export class CssAnimationProperty implements definitions.Css set(this: T, boxedValue: U | string) { const view = this.viewRef.get(); if (!view) { - traceWrite(`${boxedValue} not set to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn); + Trace.write(`${boxedValue} not set to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); return; } @@ -912,7 +944,7 @@ export class CssAnimationProperty implements definitions.Css public _initDefaultNativeValue(target: T): void { const view = target.viewRef.get(); if (!view) { - traceWrite(`_initDefaultNativeValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn); + Trace.write(`_initDefaultNativeValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); return; } @@ -939,10 +971,10 @@ export class CssAnimationProperty implements definitions.Css } CssAnimationProperty.prototype.isStyleProperty = true; -export class InheritedCssProperty extends CssProperty implements definitions.InheritedCssProperty { +export class InheritedCssProperty extends CssProperty implements InheritedCssProperty { public setInheritedValue: (value: U) => void; - constructor(options: definitions.CssPropertyOptions) { + constructor(options: CssPropertyOptions) { super(options); const propertyName = options.name; @@ -964,7 +996,7 @@ export class InheritedCssProperty extends CssProperty const setFunc = (valueSource: ValueSource) => function (this: T, boxedValue: any): void { const view = this.viewRef.get(); if (!view) { - traceWrite(`${boxedValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${boxedValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); return; } @@ -1077,7 +1109,7 @@ export class InheritedCssProperty extends CssProperty } } -export class ShorthandProperty implements definitions.ShorthandProperty { +export class ShorthandProperty implements ShorthandProperty { private registered: boolean; public readonly key: symbol; @@ -1091,7 +1123,7 @@ export class ShorthandProperty implements definitions.Shorth public readonly sourceKey: symbol; - constructor(options: definitions.ShorthandPropertyOptions

) { + constructor(options: ShorthandPropertyOptions

) { this.name = options.name; const key = Symbol(this.name + ":propertyKey"); @@ -1105,7 +1137,7 @@ export class ShorthandProperty implements definitions.Shorth function setLocalValue(this: T, value: string | P): void { const view = this.viewRef.get(); if (!view) { - traceWrite(`setLocalValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn); + Trace.write(`setLocalValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); return; } @@ -1120,7 +1152,7 @@ export class ShorthandProperty implements definitions.Shorth function setCssValue(this: T, value: string): void { const view = this.viewRef.get(); if (!view) { - traceWrite(`setCssValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn); + Trace.write(`setCssValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); return; } diff --git a/nativescript-core/ui/core/properties/package.json b/nativescript-core/ui/core/properties/package.json deleted file mode 100644 index 2b546bba1..000000000 --- a/nativescript-core/ui/core/properties/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "properties", - "main": "properties", - "types": "properties.d.ts" -} diff --git a/nativescript-core/ui/core/properties/properties.d.ts b/nativescript-core/ui/core/properties/properties.d.ts deleted file mode 100644 index e3eb425b8..000000000 --- a/nativescript-core/ui/core/properties/properties.d.ts +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @module "ui/core/properties" - */ /** */ - -import { ViewBase } from "../view-base"; -import { Style } from "../../styling/style"; - -export { Style }; - -/** - * Value specifing that Property should be set to its initial value. - */ -export const unsetValue: any; - -export interface PropertyOptions { - readonly name: string; - readonly defaultValue?: U; - readonly affectsLayout?: boolean; - readonly equalityComparer?: (x: U, y: U) => boolean; - readonly valueChanged?: (target: T, oldValue: U, newValue: U) => void; - readonly valueConverter?: (value: string) => U; -} - -export interface CoerciblePropertyOptions extends PropertyOptions { - readonly coerceValue: (t: T, u: U) => U; -} - -export interface CssPropertyOptions extends PropertyOptions { - readonly cssName: string; -} - -export interface ShorthandPropertyOptions

{ - readonly name: string, - readonly cssName: string; - readonly converter: (value: string | P) => [CssProperty | CssAnimationProperty, any][], - readonly getter: (this: Style) => string | P -} - -export interface CssAnimationPropertyOptions { - readonly name: string; - readonly cssName?: string; - readonly defaultValue?: U; - readonly equalityComparer?: (x: U, y: U) => boolean; - readonly valueChanged?: (target: T, oldValue: U, newValue: U) => void; - readonly valueConverter?: (value: string) => U; -} - -export class Property { - constructor(options: PropertyOptions); - - public readonly getDefault: symbol; - public readonly setNative: symbol; - public readonly defaultValue: U; - public register(cls: { prototype: T }): void; - public nativeValueChange(owner: T, value: U): void; - public isSet(instance: T): boolean; -} -export interface Property extends TypedPropertyDescriptor { -} - -export class CoercibleProperty extends Property { - constructor(options: CoerciblePropertyOptions); - - public readonly coerce: (target: T) => void; -} -export interface CoercibleProperty extends TypedPropertyDescriptor { -} - -export class InheritedProperty extends Property { - constructor(options: PropertyOptions); -} - -export class CssProperty { - constructor(options: CssPropertyOptions); - - public readonly getDefault: symbol; - public readonly setNative: symbol; - public readonly name: string; - public readonly cssName: string; - public readonly cssLocalName: string; - public readonly defaultValue: U; - public register(cls: { prototype: T }): void; - public isSet(instance: T): boolean; -} - -export class InheritedCssProperty extends CssProperty { - constructor(options: CssPropertyOptions); -} - -export class ShorthandProperty { - constructor(options: ShorthandPropertyOptions

); - - public readonly name: string; - public readonly cssName: string; - - public register(cls: typeof Style): void; -} - -export class CssAnimationProperty { - constructor(options: CssAnimationPropertyOptions); - - public readonly getDefault: symbol; - public readonly setNative: symbol; - - public readonly name: string; - public readonly cssName: string; - public readonly cssLocalName: string; - - readonly keyframe: string; - - public readonly defaultValue: U; - - public register(cls: { prototype: T }): void; - public isSet(instance: T): boolean; - - /** - * @private - */ - public _initDefaultNativeValue(target: T): void; - /** - * @private - */ - public _valueConverter?: (value: string) => any; - /** - * @private - */ - public static _getByCssName(name: string): CssAnimationProperty; - /** - * @private - */ - public static _getPropertyNames(): string[]; -} - -export function initNativeView(view: ViewBase): void; -export function resetNativeView(view: ViewBase): void; -export function resetCSSProperties(style: Style): void; -export function propagateInheritableProperties(view: ViewBase, childView: ViewBase): void; -export function propagateInheritableCssProperties(parentStyle: Style, childStyle: Style): void; -export function clearInheritedProperties(view: ViewBase): void; - -export function makeValidator(...values: T[]): (value: any) => value is T; -export function makeParser(isValid: (value: any) => boolean): (value: any) => T; - -export function getSetProperties(view: ViewBase): [string, any][]; -export function getComputedCssValues(view: ViewBase): [string, any][]; - -export function isCssVariable(property: string): boolean; -export function isCssCalcExpression(value: string): boolean; -export function isCssVariableExpression(value: string): boolean; - -//@private -/** - * @private get all properties defined on ViewBase - */ -export function _getProperties(): Property[]; - -/** - * @private get all properties defined on Style - */ -export function _getStyleProperties(): CssProperty[]; - -export function _evaluateCssVariableExpression(view: ViewBase, cssName: string, value: string): string; - -export function _evaluateCssCalcExpression(value: string): string; -//@endprivate diff --git a/nativescript-core/ui/core/view-base/view-base.d.ts b/nativescript-core/ui/core/view-base/view-base.d.ts index c6b0a9a24..fc84f0d14 100644 --- a/nativescript-core/ui/core/view-base/view-base.d.ts +++ b/nativescript-core/ui/core/view-base/view-base.d.ts @@ -1,26 +1,13 @@ -/** - * @module "ui/core/view-base" - */ /** */ import { Property, CssProperty, CssAnimationProperty, InheritedProperty, Style } from "../properties"; -import { BindingOptions, Observable } from "../bindable"; +import { BindingOptions } from "../bindable"; +import { Observable } from "../../../data/observable"; -import { SelectorCore } from "../../styling/css-selector"; -import { isIOS, isAndroid } from "../../../platform"; - -import { KeyframeAnimation } from "../../animation/keyframe-animation"; import { Page } from "../../page"; -import { layout } from "../../../utils/utils"; -import { Color } from "../../../color"; import { Order, FlexGrow, FlexShrink, FlexWrapBefore, AlignSelf } from "../../layouts/flexbox-layout"; import { Length } from "../../styling/style-properties"; import { DOMNode } from "../../../debugger/dom-node"; -export { isIOS, isAndroid, layout, Color }; - -export * from "../properties"; -export * from "../bindable"; - /** * Iterates through all child views (via visual tree) and executes a function. * @param view - Starting view (parent container). diff --git a/nativescript-core/ui/core/view-base/view-base.ts b/nativescript-core/ui/core/view-base/view-base.ts index 644156b9d..9b0f6e9c0 100644 --- a/nativescript-core/ui/core/view-base/view-base.ts +++ b/nativescript-core/ui/core/view-base/view-base.ts @@ -1,15 +1,17 @@ // Definitions. -import { ViewBase as ViewBaseDefinition } from "."; import { - AlignSelf, FlexGrow, FlexShrink, FlexWrapBefore, Order + AlignSelf, FlexGrow, FlexShrink, FlexWrapBefore, Order } from "../../layouts/flexbox-layout"; import { Page } from "../../page"; // Types. -import { Property, CssProperty, CssAnimationProperty, InheritedProperty, Style, clearInheritedProperties, propagateInheritableProperties, propagateInheritableCssProperties, initNativeView } from "../properties"; +import { Property, CssProperty, CssAnimationProperty, InheritedProperty, clearInheritedProperties, propagateInheritableProperties, propagateInheritableCssProperties, initNativeView } from "../properties"; import { getSystemCssClasses, MODAL_ROOT_VIEW_CSS_CLASS, ROOT_VIEW_CSS_CLASS } from "../../../css/system-classes"; import { Source } from "../../../utils/debug"; -import { Binding, BindingOptions, Observable, WrappedValue, PropertyChangeData, traceEnabled, traceWrite, traceCategories } from "../bindable"; +import { Binding, BindingOptions } from "../bindable"; +import { Trace } from "../../../trace"; +import { Observable, PropertyChangeData, WrappedValue } from "../../../data/observable"; +import { Style } from "../../styling/style"; import { isAndroid } from "../../../platform"; import { Length, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty } from "../../styling/style-properties"; @@ -20,6 +22,7 @@ import { profile } from "../../../profiling"; import * as dnm from "../../../debugger/dom-node"; import * as ssm from "../../styling/style-scope"; +import { ViewBase as ViewBaseDefinition } from "."; let domNodeModule: typeof dnm; @@ -582,8 +585,8 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition @profile public _addView(view: ViewBase, atIndex?: number) { - if (traceEnabled()) { - traceWrite(`${this}._addView(${view}, ${atIndex})`, traceCategories.ViewHierarchy); + if (Trace.isEnabled()) { + Trace.write(`${this}._addView(${view}, ${atIndex})`, Trace.categories.ViewHierarchy); } if (!view) { @@ -639,8 +642,8 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition * Core logic for removing a child view from this instance. Used by the framework to handle lifecycle events more centralized. Do not use outside the UI Stack implementation. */ public _removeView(view: ViewBase) { - if (traceEnabled()) { - traceWrite(`${this}._removeView(${view})`, traceCategories.ViewHierarchy); + if (Trace.isEnabled()) { + Trace.write(`${this}._removeView(${view})`, Trace.categories.ViewHierarchy); } if (view.parent !== this) { @@ -881,8 +884,8 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition } public _goToVisualState(state: string) { - if (traceEnabled()) { - traceWrite(this + " going to state: " + state, traceCategories.Style); + if (Trace.isEnabled()) { + Trace.write(this + " going to state: " + state, Trace.categories.Style); } if (state === this._visualState) { diff --git a/nativescript-core/ui/core/view/view-common.ts b/nativescript-core/ui/core/view/view-common.ts index 0c5da3b62..ee4b9f220 100644 --- a/nativescript-core/ui/core/view/view-common.ts +++ b/nativescript-core/ui/core/view/view-common.ts @@ -1,13 +1,19 @@ // Definitions. import { - View as ViewDefinition, Point, Size, Color, dip, + View as ViewDefinition, Point, Size, dip, ShownModallyData } from "."; import { - booleanConverter, EventData, getEventOrGestureName, InheritedProperty, layout, - Property, ShowModalOptions, traceCategories, traceEnabled, traceWrite, ViewBase + booleanConverter, + ShowModalOptions, ViewBase } from "../view-base"; +import { getEventOrGestureName } from "../bindable"; +import { layout } from "../../../utils/utils"; +import { Color } from "../../../color"; +import { Property, InheritedProperty } from "../properties"; +import { EventData } from "../../../data/observable"; +import { Trace } from "../../../trace"; import { ViewHelper } from "./view-helper"; import { HorizontalAlignment, VerticalAlignment, Visibility, Length, PercentLength } from "../../styling/style-properties"; @@ -168,8 +174,8 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { } public _onLivesync(context?: ModuleContext): boolean { - if (traceEnabled()) { - traceWrite(`${this}._onLivesync(${JSON.stringify(context)})`, traceCategories.Livesync); + if (Trace.isEnabled()) { + Trace.write(`${this}._onLivesync(${JSON.stringify(context)})`, Trace.categories.Livesync); } if (this._closeAllModalViewsInternal()) { @@ -193,14 +199,14 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { } public _handleLivesync(context?: ModuleContext): boolean { - if (traceEnabled()) { - traceWrite(`${this}._handleLivesync(${JSON.stringify(context)})`, traceCategories.Livesync); + if (Trace.isEnabled()) { + Trace.write(`${this}._handleLivesync(${JSON.stringify(context)})`, Trace.categories.Livesync); } // Handle local CSS if (viewMatchesModuleContext(this, context, ["style"])) { - if (traceEnabled()) { - traceWrite(`Change Handled: Changing CSS for ${this}`, traceCategories.Livesync); + if (Trace.isEnabled()) { + Trace.write(`Change Handled: Changing CSS for ${this}`, Trace.categories.Livesync); } // Always load styles with ".css" extension. Even when changes are in ".scss" ot ".less" files @@ -216,8 +222,8 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { this.page && this.page.frame) { - if (traceEnabled()) { - traceWrite(`Change Handled: Changing ${context.type} for ${this} inside ${this.page}`, traceCategories.Livesync); + if (Trace.isEnabled()) { + Trace.write(`Change Handled: Changing ${context.type} for ${this} inside ${this.page}`, Trace.categories.Livesync); } return this.page.frame._handleLivesync({ type: context.type, path: this.page._moduleName }); @@ -818,8 +824,8 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { public setMeasuredDimension(measuredWidth: number, measuredHeight: number): void { this._measuredWidth = measuredWidth; this._measuredHeight = measuredHeight; - if (traceEnabled()) { - traceWrite(this + " :setMeasuredDimension: " + measuredWidth + ", " + measuredHeight, traceCategories.Layout); + if (Trace.isEnabled()) { + Trace.write(this + " :setMeasuredDimension: " + measuredWidth + ", " + measuredHeight, Trace.categories.Layout); } } diff --git a/nativescript-core/ui/core/view/view-helper/view-helper.android.ts b/nativescript-core/ui/core/view/view-helper/index.android.ts similarity index 100% rename from nativescript-core/ui/core/view/view-helper/view-helper.android.ts rename to nativescript-core/ui/core/view/view-helper/index.android.ts diff --git a/nativescript-core/ui/core/view/view-helper/view-helper.d.ts b/nativescript-core/ui/core/view/view-helper/index.d.ts similarity index 99% rename from nativescript-core/ui/core/view/view-helper/view-helper.d.ts rename to nativescript-core/ui/core/view/view-helper/index.d.ts index 377b5474d..d74b04750 100644 --- a/nativescript-core/ui/core/view/view-helper/view-helper.d.ts +++ b/nativescript-core/ui/core/view/view-helper/index.d.ts @@ -33,7 +33,7 @@ export class ViewHelper { public static combineMeasuredStates(curState: number, newState): number; } -export namespace ios { +export namespace IOSHelper { /** * String value used when hooking to traitCollectionColorAppearanceChangedEvent event. */ diff --git a/nativescript-core/ui/core/view/view-helper/view-helper.ios.ts b/nativescript-core/ui/core/view/view-helper/index.ios.ts similarity index 92% rename from nativescript-core/ui/core/view/view-helper/view-helper.ios.ts rename to nativescript-core/ui/core/view/view-helper/index.ios.ts index b52f28620..8208f5485 100644 --- a/nativescript-core/ui/core/view/view-helper/view-helper.ios.ts +++ b/nativescript-core/ui/core/view/view-helper/index.ios.ts @@ -8,17 +8,14 @@ import { layout } from "../../../../utils/utils"; import { - isEnabled as traceEnabled, - messageType as traceMessageType, - categories as traceCategories, - write as traceWrite + Trace } from "../../../../trace"; export * from "./view-helper-common"; const majorVersion = iosUtils.MajorVersion; -export namespace ios { +export namespace IOSHelper { export const traitCollectionColorAppearanceChangedEvent = "traitCollectionColorAppearanceChanged"; export function getParentWithViewController(view: View): View { @@ -65,19 +62,19 @@ export namespace ios { export function layoutView(controller: UIViewController, owner: View): void { let layoutGuide = controller.view.safeAreaLayoutGuide; if (!layoutGuide) { - traceWrite(`safeAreaLayoutGuide during layout of ${owner}. Creating fallback constraints, but layout might be wrong.`, - traceCategories.Layout, traceMessageType.error); + Trace.write(`safeAreaLayoutGuide during layout of ${owner}. Creating fallback constraints, but layout might be wrong.`, + Trace.categories.Layout, Trace.messageType.error); layoutGuide = initLayoutGuide(controller); } const safeArea = layoutGuide.layoutFrame; - let position = ios.getPositionFromFrame(safeArea); + let position = IOSHelper.getPositionFromFrame(safeArea); const safeAreaSize = safeArea.size; const hasChildViewControllers = controller.childViewControllers.count > 0; if (hasChildViewControllers) { const fullscreen = controller.view.frame; - position = ios.getPositionFromFrame(fullscreen); + position = IOSHelper.getPositionFromFrame(fullscreen); } const safeAreaWidth = layout.round(layout.toDevicePixels(safeAreaSize.width)); @@ -117,11 +114,11 @@ export namespace ios { export function shrinkToSafeArea(view: View, frame: CGRect): CGRect { const insets = view.getSafeAreaInsets(); if (insets.left || insets.top) { - const position = ios.getPositionFromFrame(frame); - const adjustedFrame = ios.getFrameFromPosition(position, insets); + const position = IOSHelper.getPositionFromFrame(frame); + const adjustedFrame = IOSHelper.getFrameFromPosition(position, insets); - if (traceEnabled()) { - traceWrite(this + " :shrinkToSafeArea: " + JSON.stringify(ios.getPositionFromFrame(adjustedFrame)), traceCategories.Layout); + if (Trace.isEnabled()) { + Trace.write(this + " :shrinkToSafeArea: " + JSON.stringify(IOSHelper.getPositionFromFrame(adjustedFrame)), Trace.categories.Layout); } return adjustedFrame; @@ -136,10 +133,10 @@ export namespace ios { const fullscreen = availableSpace.fullscreen; const inWindow = availableSpace.inWindow; - const position = ios.getPositionFromFrame(frame); - const safeAreaPosition = ios.getPositionFromFrame(safeArea); - const fullscreenPosition = ios.getPositionFromFrame(fullscreen); - const inWindowPosition = ios.getPositionFromFrame(inWindow); + const position = IOSHelper.getPositionFromFrame(frame); + const safeAreaPosition = IOSHelper.getPositionFromFrame(safeArea); + const fullscreenPosition = IOSHelper.getPositionFromFrame(fullscreen); + const inWindowPosition = IOSHelper.getPositionFromFrame(inWindow); const adjustedPosition = position; @@ -161,8 +158,8 @@ export namespace ios { const adjustedFrame = CGRectMake(layout.toDeviceIndependentPixels(adjustedPosition.left), layout.toDeviceIndependentPixels(adjustedPosition.top), layout.toDeviceIndependentPixels(adjustedPosition.right - adjustedPosition.left), layout.toDeviceIndependentPixels(adjustedPosition.bottom - adjustedPosition.top)); - if (traceEnabled()) { - traceWrite(view + " :expandBeyondSafeArea: " + JSON.stringify(ios.getPositionFromFrame(adjustedFrame)), traceCategories.Layout); + if (Trace.isEnabled()) { + Trace.write(view + " :expandBeyondSafeArea: " + JSON.stringify(IOSHelper.getPositionFromFrame(adjustedFrame)), Trace.categories.Layout); } return adjustedFrame; diff --git a/nativescript-core/ui/core/view/view-helper/package.json b/nativescript-core/ui/core/view/view-helper/package.json deleted file mode 100644 index 0561420d6..000000000 --- a/nativescript-core/ui/core/view/view-helper/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "view-helper", - "main": "view-helper", - "types": "view-helper.d.ts" -} diff --git a/nativescript-core/ui/core/view/view-helper/view-helper-common.ts b/nativescript-core/ui/core/view/view-helper/view-helper-common.ts index f41213e65..c9485c4b2 100644 --- a/nativescript-core/ui/core/view/view-helper/view-helper-common.ts +++ b/nativescript-core/ui/core/view/view-helper/view-helper-common.ts @@ -8,9 +8,7 @@ import { // Requires import { layout } from "../../../../utils/utils"; import { - isEnabled as traceEnabled, - categories as traceCategories, - write as traceWrite + Trace } from "../../../../trace"; export class ViewHelper { @@ -39,8 +37,8 @@ export class ViewHelper { const childWidthMeasureSpec = ViewHelper.getMeasureSpec(widthMeasureSpec, horizontalMargins, child.effectiveWidth, style.horizontalAlignment === "stretch"); const childHeightMeasureSpec = ViewHelper.getMeasureSpec(heightMeasureSpec, verticalMargins, child.effectiveHeight, style.verticalAlignment === "stretch"); - if (traceEnabled()) { - traceWrite(`${child.parent} :measureChild: ${child} ${layout.measureSpecToString(childWidthMeasureSpec)}, ${layout.measureSpecToString(childHeightMeasureSpec)}}`, traceCategories.Layout); + if (Trace.isEnabled()) { + Trace.write(`${child.parent} :measureChild: ${child} ${layout.measureSpecToString(childWidthMeasureSpec)}, ${layout.measureSpecToString(childHeightMeasureSpec)}}`, Trace.categories.Layout); } child.measure(childWidthMeasureSpec, childHeightMeasureSpec); @@ -131,8 +129,8 @@ export class ViewHelper { childLeft = Math.round(childLeft); childTop = Math.round(childTop); - if (traceEnabled()) { - traceWrite(child.parent + " :layoutChild: " + child + " " + childLeft + ", " + childTop + ", " + childRight + ", " + childBottom, traceCategories.Layout); + if (Trace.isEnabled()) { + Trace.write(child.parent + " :layoutChild: " + child + " " + childLeft + ", " + childTop + ", " + childRight + ", " + childBottom, Trace.categories.Layout); } child.layout(childLeft, childTop, childRight, childBottom, setFrame); diff --git a/nativescript-core/ui/core/view/view.android.ts b/nativescript-core/ui/core/view/view.android.ts index 54dcd2599..94baf5bec 100644 --- a/nativescript-core/ui/core/view/view.android.ts +++ b/nativescript-core/ui/core/view/view.android.ts @@ -3,11 +3,13 @@ import { Point, CustomLayoutView as CustomLayoutViewDefinition, dip } from "."; import { GestureTypes, GestureEventData } from "../../gestures"; // Types. import { - ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty, - traceEnabled, traceWrite, traceCategories, traceNotifyEvent, + ViewCommon, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, - Color, EventData, ShowModalOptions + EventData, ShowModalOptions } from "./view-common"; +// import { layout} from "../../layouts" +import { Trace } from "../../../trace"; +import { Color } from "../../../color"; import { perspectiveProperty, Length, PercentLength, Visibility, HorizontalAlignment, VerticalAlignment, @@ -1035,8 +1037,8 @@ export class CustomLayoutView extends ContainerView implements CustomLayoutViewD super._addViewToNativeVisualTree(child); if (this.nativeViewProtected && child.nativeViewProtected) { - if (traceEnabled()) { - traceWrite(`${this}.nativeView.addView(${child}.nativeView, ${atIndex})`, traceCategories.VisualTreeEvents); + if (Trace.isEnabled()) { + Trace.write(`${this}.nativeView.addView(${child}.nativeView, ${atIndex})`, Trace.categories.VisualTreeEvents); } this.nativeViewProtected.addView(child.nativeViewProtected, atIndex); if (child instanceof View) { @@ -1068,9 +1070,9 @@ export class CustomLayoutView extends ContainerView implements CustomLayoutViewD const childView = child.nativeViewProtected; if (nativeView && childView) { nativeView.removeView(childView); - if (traceEnabled()) { - traceWrite(`${nativeView}.removeView(${childView})`, traceCategories.VisualTreeEvents); - traceNotifyEvent(child, "childInLayoutRemovedFromNativeVisualTree"); + if (Trace.isEnabled()) { + Trace.write(`${nativeView}.removeView(${childView})`, Trace.categories.VisualTreeEvents); + Trace.notifyEvent(child, "childInLayoutRemovedFromNativeVisualTree"); } } } diff --git a/nativescript-core/ui/core/view/view.d.ts b/nativescript-core/ui/core/view/view.d.ts index 560d337e8..fe860e645 100644 --- a/nativescript-core/ui/core/view/view.d.ts +++ b/nativescript-core/ui/core/view/view.d.ts @@ -1,19 +1,12 @@ -/** - * @module "ui/core/view" - */ /** */ - -/// - -import { ViewBase, Property, InheritedProperty, EventData, Color } from "../view-base"; +import { ViewBase } from "../view-base"; +import { Property, InheritedProperty } from '../properties'; +import { EventData } from '../../../data/observable'; +import { Color } from '../../../color'; import { Animation, AnimationDefinition, AnimationPromise } from "../../animation"; import { HorizontalAlignment, VerticalAlignment, Visibility, Length, PercentLength } from "../../styling/style-properties"; import { GestureTypes, GestureEventData, GesturesObserver } from "../../gestures"; import { LinearGradient } from "../../styling/gradient"; -export * from "../view-base"; -export * from "../../styling/style-properties"; -export { LinearGradient }; - export function PseudoClassHandler(...pseudoClasses: string[]): MethodDecorator; /** diff --git a/nativescript-core/ui/core/view/view.ios.ts b/nativescript-core/ui/core/view/view.ios.ts index 327bca8ef..d351eeb6f 100644 --- a/nativescript-core/ui/core/view/view.ios.ts +++ b/nativescript-core/ui/core/view/view.ios.ts @@ -3,10 +3,12 @@ import { Point, View as ViewDefinition, dip } from "."; // Requires import { - ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty, - traceEnabled, traceWrite, traceCategories, traceError, traceMessageType, ShowModalOptions + ViewCommon, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty } from "./view-common"; -import { ios } from "./view-helper"; +import { ShowModalOptions } from "../view-base"; +import { Trace } from "../../../trace"; +import { layout } from "../../../utils/utils"; +import { IOSHelper } from "./view-helper"; import { ios as iosBackground, Background } from "../../styling/background"; import { ios as iosUtils } from "../../../utils/utils"; import { ios as iosNativeHelper } from "../../../utils/native-helper"; @@ -21,7 +23,7 @@ import { import { profile } from "../../../profiling"; export * from "./view-common"; -export { ios }; +export { IOSHelper }; const PFLAG_FORCE_LAYOUT = 1; const PFLAG_MEASURED_DIMENSION_SET = 1 << 1; @@ -32,8 +34,8 @@ const majorVersion = iosUtils.MajorVersion; export class View extends ViewCommon implements ViewDefinition { nativeViewProtected: UIView; viewController: UIViewController; - private _popoverPresentationDelegate: ios.UIPopoverPresentationControllerDelegateImp; - private _adaptivePresentationDelegate: ios.UIAdaptivePresentationControllerDelegateImp; + private _popoverPresentationDelegate: IOSHelper.UIPopoverPresentationControllerDelegateImp; + private _adaptivePresentationDelegate: IOSHelper.UIAdaptivePresentationControllerDelegateImp; private _isLaidOut = false; private _hasTransfrom = false; @@ -102,7 +104,7 @@ export class View extends ViewCommon implements ViewDefinition { // on iOS 11+ it is possible to have a changed layout frame due to safe area insets // get the frame and adjust the position, so that onLayout works correctly const frame = this.nativeViewProtected.frame; - position = ios.getPositionFromFrame(frame); + position = IOSHelper.getPositionFromFrame(frame); } this.onLayout(position.left, position.top, position.right, position.bottom); @@ -161,8 +163,8 @@ export class View extends ViewCommon implements ViewDefinition { let oldFrame = this._cachedFrame || nativeView.frame; if (!CGRectEqualToRect(oldFrame, frame)) { - if (traceEnabled()) { - traceWrite(this + " :_setNativeViewFrame: " + JSON.stringify(ios.getPositionFromFrame(frame)), traceCategories.Layout); + if (Trace.isEnabled()) { + Trace.write(this + " :_setNativeViewFrame: " + JSON.stringify(IOSHelper.getPositionFromFrame(frame)), Trace.categories.Layout); } this._cachedFrame = frame; let adjustedFrame = null; @@ -215,7 +217,7 @@ export class View extends ViewCommon implements ViewDefinition { } const nativeView = this.nativeViewProtected; - const frame = ios.getFrameFromPosition({ left, top, right, bottom }); + const frame = IOSHelper.getFrameFromPosition({ left, top, right, bottom }); this._setNativeViewFrame(nativeView, frame); } @@ -250,7 +252,7 @@ export class View extends ViewCommon implements ViewDefinition { public focus(): boolean { if (this.ios) { - return this.ios.becomeFirstResponder(); + return this.IOSHelper.becomeFirstResponder(); } return false; @@ -262,9 +264,9 @@ export class View extends ViewCommon implements ViewDefinition { } if (!this.iosOverflowSafeArea || !this.iosOverflowSafeAreaEnabled) { - return ios.shrinkToSafeArea(this, frame); + return IOSHelper.shrinkToSafeArea(this, frame); } else if (this.nativeViewProtected && this.nativeViewProtected.window) { - return ios.expandBeyondSafeArea(this, frame); + return IOSHelper.expandBeyondSafeArea(this, frame); } return null; @@ -400,25 +402,25 @@ export class View extends ViewCommon implements ViewDefinition { } protected _showNativeModalView(parent: View, options: ShowModalOptions) { - const parentWithController = ios.getParentWithViewController(parent); + const parentWithController = IOSHelper.getParentWithViewController(parent); if (!parentWithController) { - traceWrite(`Could not find parent with viewController for ${parent} while showing modal view.`, - traceCategories.ViewHierarchy, traceMessageType.error); + Trace.write(`Could not find parent with viewController for ${parent} while showing modal view.`, + Trace.categories.ViewHierarchy, Trace.messageType.error); return; } const parentController = parentWithController.viewController; if (parentController.presentedViewController) { - traceWrite("Parent is already presenting view controller. Close the current modal page before showing another one!", - traceCategories.ViewHierarchy, traceMessageType.error); + Trace.write("Parent is already presenting view controller. Close the current modal page before showing another one!", + Trace.categories.ViewHierarchy, Trace.messageType.error); return; } if (!parentController.view || !parentController.view.window) { - traceWrite("Parent page is not part of the window hierarchy.", - traceCategories.ViewHierarchy, traceMessageType.error); + Trace.write("Parent page is not part of the window hierarchy.", + Trace.categories.ViewHierarchy, Trace.messageType.error); return; } @@ -429,7 +431,7 @@ export class View extends ViewCommon implements ViewDefinition { let controller = this.viewController; if (!controller) { const nativeView = this.ios || this.nativeViewProtected; - controller = ios.UILayoutViewController.initWithOwner(new WeakRef(this)); + controller = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(this)); if (nativeView instanceof UIView) { controller.view.addSubview(nativeView); @@ -444,13 +446,13 @@ export class View extends ViewCommon implements ViewDefinition { controller.modalPresentationStyle = UIModalPresentationStyle.FormSheet; //check whether both height and width is provided and are positive numbers // set it has prefered content size to the controller presenting the dialog - if (options.ios && options.ios.width > 0 && options.ios.height > 0) { - controller.preferredContentSize = CGSizeMake(options.ios.width, options.ios.height); + if (options.ios && options.IOSHelper.width > 0 && options.IOSHelper.height > 0) { + controller.preferredContentSize = CGSizeMake(options.IOSHelper.width, options.IOSHelper.height); } } - if (options.ios && options.ios.presentationStyle) { - const presentationStyle = options.ios.presentationStyle; + if (options.ios && options.IOSHelper.presentationStyle) { + const presentationStyle = options.IOSHelper.presentationStyle; controller.modalPresentationStyle = presentationStyle; if (presentationStyle === UIModalPresentationStyle.Popover) { @@ -490,7 +492,7 @@ export class View extends ViewCommon implements ViewDefinition { protected _hideNativeModalView(parent: View, whenClosedCallback: () => void) { if (!parent || !parent.viewController) { - traceError("Trying to hide modal view but no parent with viewController specified."); + Trace.error("Trying to hide modal view but no parent with viewController specified."); return; } @@ -704,7 +706,7 @@ export class View extends ViewCommon implements ViewDefinition { private _setupPopoverControllerDelegate(controller: UIViewController, parent: View) { const popoverPresentationController = controller.popoverPresentationController; - this._popoverPresentationDelegate = ios.UIPopoverPresentationControllerDelegateImp.initWithOwnerAndCallback(new WeakRef(this), this._closeModalCallback); + this._popoverPresentationDelegate = IOSHelper.UIPopoverPresentationControllerDelegateImp.initWithOwnerAndCallback(new WeakRef(this), this._closeModalCallback); popoverPresentationController.delegate = this._popoverPresentationDelegate; const view = parent.nativeViewProtected; // Note: sourceView and sourceRect are needed to specify the anchor location for the popover. @@ -714,7 +716,7 @@ export class View extends ViewCommon implements ViewDefinition { } private _setupAdaptiveControllerDelegate(controller: UIViewController) { - this._adaptivePresentationDelegate = ios.UIAdaptivePresentationControllerDelegateImp.initWithOwnerAndCallback(new WeakRef(this), this._closeModalCallback); + this._adaptivePresentationDelegate = IOSHelper.UIAdaptivePresentationControllerDelegateImp.initWithOwnerAndCallback(new WeakRef(this), this._closeModalCallback); controller.presentationController.delegate = this._adaptivePresentationDelegate; } } diff --git a/nativescript-core/ui/core/weak-event-listener/weak-event-listener.d.ts b/nativescript-core/ui/core/weak-event-listener/weak-event-listener.d.ts index 8dd444e12..c74641737 100644 --- a/nativescript-core/ui/core/weak-event-listener/weak-event-listener.d.ts +++ b/nativescript-core/ui/core/weak-event-listener/weak-event-listener.d.ts @@ -1,7 +1,3 @@ -/** - * @module "ui/core/weak-event-listener" - */ /** */ - import { Observable, EventData } from "../../../data/observable"; /** diff --git a/nativescript-core/ui/date-picker/date-picker-common.ts b/nativescript-core/ui/date-picker/date-picker-common.ts index 46d2b28da..6094fd6b4 100644 --- a/nativescript-core/ui/date-picker/date-picker-common.ts +++ b/nativescript-core/ui/date-picker/date-picker-common.ts @@ -1,5 +1,6 @@ import { DatePicker as DatePickerDefinition } from "."; -import { View, Property, CSSType } from "../core/view"; +import { View, CSSType } from "../core/view"; +import {Property } from "../core/properties"; const defaultDate = new Date(); const dateComparer = (x: Date, y: Date): boolean => (x <= y && x >= y); diff --git a/nativescript-core/ui/date-picker/date-picker.android.ts b/nativescript-core/ui/date-picker/index.android.ts similarity index 100% rename from nativescript-core/ui/date-picker/date-picker.android.ts rename to nativescript-core/ui/date-picker/index.android.ts diff --git a/nativescript-core/ui/date-picker/date-picker.d.ts b/nativescript-core/ui/date-picker/index.d.ts similarity index 91% rename from nativescript-core/ui/date-picker/date-picker.d.ts rename to nativescript-core/ui/date-picker/index.d.ts index 7a50808b6..ab1a53afe 100644 --- a/nativescript-core/ui/date-picker/date-picker.d.ts +++ b/nativescript-core/ui/date-picker/index.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the DatePicker class. - * @module "ui/date-picker" - */ /** */ - -import { View, Property } from "../core/view"; +import { View } from "../core/view"; +import { Property } from "../core/properties"; export const yearProperty: Property; export const monthProperty: Property; diff --git a/nativescript-core/ui/date-picker/date-picker.ios.ts b/nativescript-core/ui/date-picker/index.ios.ts similarity index 96% rename from nativescript-core/ui/date-picker/date-picker.ios.ts rename to nativescript-core/ui/date-picker/index.ios.ts index f60a2f9ae..09ed167cd 100644 --- a/nativescript-core/ui/date-picker/date-picker.ios.ts +++ b/nativescript-core/ui/date-picker/index.ios.ts @@ -1,7 +1,9 @@ import { DatePickerBase, yearProperty, monthProperty, dayProperty, - dateProperty, maxDateProperty, minDateProperty, colorProperty, Color + dateProperty, maxDateProperty, minDateProperty } from "./date-picker-common"; +import { colorProperty } from '../styling/style-properties' +import { Color } from '../../color' export * from "./date-picker-common"; diff --git a/nativescript-core/ui/date-picker/package.json b/nativescript-core/ui/date-picker/package.json deleted file mode 100644 index 2afd0741d..000000000 --- a/nativescript-core/ui/date-picker/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "date-picker", - "main": "date-picker", - "types": "date-picker.d.ts" -} diff --git a/nativescript-core/ui/dialogs/dialogs-common.ts b/nativescript-core/ui/dialogs/dialogs-common.ts index 802810b74..9568f498e 100644 --- a/nativescript-core/ui/dialogs/dialogs-common.ts +++ b/nativescript-core/ui/dialogs/dialogs-common.ts @@ -4,7 +4,6 @@ import { Color } from "../../color"; import { Page } from "../page"; import { isIOS } from "../../platform"; import { Frame as FrameDef } from "../frame"; -import { LoginOptions } from "./dialogs"; import { isObject, isString } from "../../utils/types"; export const STRING = "string"; @@ -15,6 +14,163 @@ export const LOGIN = "Login"; export const OK = "OK"; export const CANCEL = "Cancel"; +/** + * Provides options for the dialog. + */ +export interface CancelableOptions { + /** + * [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog. + */ + cancelable?: boolean; +} + +/** +* Provides options for the dialog. +*/ +export interface ActionOptions extends CancelableOptions { + /** + * Gets or sets the dialog title. + */ + title?: string; + + /** + * Gets or sets the dialog message. + */ + message?: string; + + /** + * Gets or sets the Cancel button text. + */ + cancelButtonText?: string; + + /** + * Gets or sets the list of available actions. + */ + actions?: Array; +} + +/** +* Provides options for the dialog. +*/ +export interface DialogOptions extends CancelableOptions { + /** + * Gets or sets the dialog title. + */ + title?: string; + + /** + * Gets or sets the dialog message. + */ + message?: string; + +} + +/** +* Provides options for the alert. +*/ +export interface AlertOptions extends DialogOptions { + /** + * Gets or sets the OK button text. + */ + okButtonText?: string; +} + +/** +* Provides options for the confirm dialog. +*/ +export interface ConfirmOptions extends AlertOptions { + /** + * Gets or sets the Cancel button text. + */ + cancelButtonText?: string; + + /** + * Gets or sets the neutral button text. + */ + neutralButtonText?: string; +} + +/** +* Provides options for the prompt dialog. +*/ +export interface PromptOptions extends ConfirmOptions { + /** + * Gets or sets the default text to display in the input box. + */ + defaultText?: string; + + /** + * Gets or sets the prompt input type (plain text, password, or email). + */ + inputType?: string; + + /** + * Gets or sets the prompt capitalizationType (none, all, sentences, or words). + */ + capitalizationType?: string; +} + +/** +* Provides result data from the prompt dialog. +*/ +export interface PromptResult { + /** + * Gets or sets the prompt dialog boolean result. + */ + result: boolean; + + /** + * Gets or sets the text entered in the prompt dialog. + */ + text: string; +} + +/** +* Provides result data from the login dialog. +*/ +export interface LoginResult { + /** + * Gets or sets the login dialog boolean result. + */ + result: boolean; + + /** + * Gets or sets the user entered in the login dialog. + */ + userName: string; + + /** + * Gets or sets the password entered in the login dialog. + */ + password: string; +} + + +/** + * Provides options for the login dialog. + */ +export interface LoginOptions extends ConfirmOptions { + /** + * Gets or sets the default text to display as hint in the user name input box. + */ + userNameHint?: string; + + /** + * Gets or sets the default text to display as hint in the password input box. + */ + passwordHint?: string; + + /** + * Gets or sets the default text to display in the user name input box. + */ + userName?: string; + + /** + * Gets or sets the default text to display in the password input box. + */ + password?: string; +} + /** * Defines the input type for prompt dialog. */ diff --git a/nativescript-core/ui/dialogs/dialogs.android.ts b/nativescript-core/ui/dialogs/index.android.ts similarity index 99% rename from nativescript-core/ui/dialogs/dialogs.android.ts rename to nativescript-core/ui/dialogs/index.android.ts index 1ea18bea0..0ffba1b2b 100644 --- a/nativescript-core/ui/dialogs/dialogs.android.ts +++ b/nativescript-core/ui/dialogs/index.android.ts @@ -1,7 +1,7 @@ /** * Android specific dialogs functions implementation. */ -import { DialogOptions, ConfirmOptions, PromptOptions, PromptResult, LoginOptions, LoginResult, ActionOptions } from "."; +import { DialogOptions, ConfirmOptions, PromptOptions, PromptResult, LoginOptions, LoginResult, ActionOptions } from "./dialogs-common"; import { getLabelColor, getButtonColors, isDialogOptions, inputType, capitalizationType, ALERT, OK, CONFIRM, CANCEL, PROMPT, parseLoginOptions } from "./dialogs-common"; import { android as androidApp } from "../../application"; diff --git a/nativescript-core/ui/dialogs/dialogs.d.ts b/nativescript-core/ui/dialogs/index.d.ts similarity index 98% rename from nativescript-core/ui/dialogs/dialogs.d.ts rename to nativescript-core/ui/dialogs/index.d.ts index 3a7da8fde..1e068b62d 100644 --- a/nativescript-core/ui/dialogs/dialogs.d.ts +++ b/nativescript-core/ui/dialogs/index.d.ts @@ -1,8 +1,4 @@ -/** - * Allows you to show different dialogs such as alerts, prompts, etc. - * @module "ui/dialogs" - */ /** */ - +import { ConfirmOptions, PromptOptions, AlertOptions, PromptResult, LoginOptions, LoginResult, ActionOptions } from "./dialogs-common"; /** * Defines the input type for prompt dialog. */ diff --git a/nativescript-core/ui/dialogs/dialogs.ios.ts b/nativescript-core/ui/dialogs/index.ios.ts similarity index 95% rename from nativescript-core/ui/dialogs/dialogs.ios.ts rename to nativescript-core/ui/dialogs/index.ios.ts index 0e535c5de..09380ddf9 100644 --- a/nativescript-core/ui/dialogs/dialogs.ios.ts +++ b/nativescript-core/ui/dialogs/index.ios.ts @@ -1,35 +1,9 @@ /** * iOS specific dialogs functions implementation. */ -import { - ios as iosView, - traceCategories, - traceWrite, - traceMessageType, -} from "../core/view"; -import { - ConfirmOptions, - PromptOptions, - PromptResult, - LoginOptions, - LoginResult, - ActionOptions, -} from "."; -import { - getCurrentPage, - getLabelColor, - getButtonColors, - getTextFieldColor, - isDialogOptions, - inputType, - capitalizationType, - ALERT, - OK, - CONFIRM, - CANCEL, - PROMPT, - parseLoginOptions, -} from "./dialogs-common"; +import { ios as iosView } from "../core/view"; +import { Trace } from "../../trace"; +import { ConfirmOptions, PromptOptions, PromptResult, LoginOptions, LoginResult, ActionOptions, getCurrentPage, getLabelColor, getButtonColors, getTextFieldColor, isDialogOptions, inputType, capitalizationType, ALERT, OK, CONFIRM, CANCEL, PROMPT, parseLoginOptions } from "./dialogs-common"; import { isString, isDefined, isFunction } from "../../utils/types"; import { getRootView, ios } from "../../application"; @@ -297,13 +271,9 @@ function showUIAlertController(alertController: UIAlertController) { } if (!viewController) { - traceWrite( - `No root controller found to open dialog.`, - traceCategories.Error, - traceMessageType.warn - ); - - return; + Trace.write(`No root controller found to open dialog.`, Trace.categories.Error, Trace.messageType.warn); + + return; } if (alertController.popoverPresentationController) { diff --git a/nativescript-core/ui/dialogs/package.json b/nativescript-core/ui/dialogs/package.json deleted file mode 100644 index 5779be298..000000000 --- a/nativescript-core/ui/dialogs/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "dialogs", - "main": "dialogs", - "types": "dialogs.d.ts" -} diff --git a/nativescript-core/ui/editable-text-base/editable-text-base-common.ts b/nativescript-core/ui/editable-text-base/editable-text-base-common.ts index c059b48eb..f436a7472 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base-common.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base-common.ts @@ -1,5 +1,10 @@ import { EditableTextBase as EditableTextBaseDefinition, KeyboardType, ReturnKeyType, UpdateTextTrigger, AutocapitalizationType } from "."; -import { TextBase, Property, CssProperty, Style, Color, booleanConverter, makeValidator, makeParser, PseudoClassHandler } from "../text-base"; +import { TextBase } from "../text-base"; +import { Property, CssProperty, makeValidator, makeParser } from "../core/properties"; +import {PseudoClassHandler } from "../core/view"; +import {booleanConverter } from "../core/view-base"; +import {Style } from "../styling/style"; +import {Color } from "../../color"; export abstract class EditableTextBase extends TextBase implements EditableTextBaseDefinition { public static blurEvent = "blur"; diff --git a/nativescript-core/ui/editable-text-base/editable-text-base.d.ts b/nativescript-core/ui/editable-text-base/editable-text-base.d.ts index ca145aa1a..0ad092f51 100644 --- a/nativescript-core/ui/editable-text-base/editable-text-base.d.ts +++ b/nativescript-core/ui/editable-text-base/editable-text-base.d.ts @@ -1,8 +1,8 @@ -/** - * @module "ui/editor-text-base" - */ /** */ - -import { TextBase, Property, CssProperty, Style, Color, FormattedString } from "../text-base"; +import { TextBase } from "../text-base"; +import { Color } from '../../color'; +import { FormattedString } from '../text-base/formatted-string'; +import { Style } from '../styling/style'; +import { Property, CssProperty } from "../core/properties"; /** * Represents the base class for all editable text views. diff --git a/nativescript-core/ui/enums/enums.d.ts b/nativescript-core/ui/enums/enums.d.ts index 2c82c99eb..03edf2736 100644 --- a/nativescript-core/ui/enums/enums.d.ts +++ b/nativescript-core/ui/enums/enums.d.ts @@ -1,8 +1,4 @@ -/** - * @module "ui/enums" - */ /** */ - -import { CubicBezierAnimationCurve } from "../animation"; +import { CubicBezierAnimationCurve } from "../animation"; import { KeyboardType as BaseKeyboardType, ReturnKeyType as BaseReturnKeyType, diff --git a/nativescript-core/ui/frame/fragment.transitions.android.ts b/nativescript-core/ui/frame/fragment.transitions.android.ts index 879c4d4a1..09a63cfeb 100644 --- a/nativescript-core/ui/frame/fragment.transitions.android.ts +++ b/nativescript-core/ui/frame/fragment.transitions.android.ts @@ -1,5 +1,3 @@ -/// - // Definitions. import { NavigationType } from "./frame-common"; import { NavigationTransition, BackstackEntry } from "../frame"; @@ -9,7 +7,7 @@ import { Transition, AndroidTransitionType } from "../transition/transition"; import { FlipTransition } from "../transition/flip-transition"; import { _resolveAnimationCurve } from "../animation"; import lazy from "../../utils/lazy"; -import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories } from "../../trace"; +import {Trace } from "../../trace"; interface TransitionListener { new(entry: ExpandedEntry, transition: androidx.transition.Transition): ExpandedTransitionListener; @@ -220,27 +218,27 @@ function getAnimationListener(): android.animation.Animator.AnimatorListener { onAnimationStart(animator: ExpandedAnimator): void { const entry = animator.entry; addToWaitingQueue(entry); - if (traceEnabled()) { - traceWrite(`START ${animator.transitionType} for ${entry.fragmentTag}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`START ${animator.transitionType} for ${entry.fragmentTag}`, Trace.categories.Transition); } } onAnimationRepeat(animator: ExpandedAnimator): void { - if (traceEnabled()) { - traceWrite(`REPEAT ${animator.transitionType} for ${animator.entry.fragmentTag}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`REPEAT ${animator.transitionType} for ${animator.entry.fragmentTag}`, Trace.categories.Transition); } } onAnimationEnd(animator: ExpandedAnimator): void { - if (traceEnabled()) { - traceWrite(`END ${animator.transitionType} for ${animator.entry.fragmentTag}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`END ${animator.transitionType} for ${animator.entry.fragmentTag}`, Trace.categories.Transition); } transitionOrAnimationCompleted(animator.entry); } onAnimationCancel(animator: ExpandedAnimator): void { - if (traceEnabled()) { - traceWrite(`CANCEL ${animator.transitionType} for ${animator.entry.fragmentTag}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`CANCEL ${animator.transitionType} for ${animator.entry.fragmentTag}`, Trace.categories.Transition); } } } @@ -258,9 +256,9 @@ function clearAnimationListener(animator: ExpandedAnimator, listener: android.an animator.removeListener(listener); - if (animator.entry && traceEnabled()) { + if (animator.entry && Trace.isEnabled()) { const entry = animator.entry; - traceWrite(`Clear ${animator.transitionType} - ${entry.transition} for ${entry.fragmentTag}`, traceCategories.Transition); + Trace.write(`Clear ${animator.transitionType} - ${entry.transition} for ${entry.fragmentTag}`, Trace.categories.Transition); } animator.entry = null; @@ -332,36 +330,36 @@ function getTransitionListener(entry: ExpandedEntry, transition: androidx.transi public onTransitionStart(transition: androidx.transition.Transition): void { const entry = this.entry; addToWaitingQueue(entry); - if (traceEnabled()) { - traceWrite(`START ${toShortString(transition)} transition for ${entry.fragmentTag}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`START ${toShortString(transition)} transition for ${entry.fragmentTag}`, Trace.categories.Transition); } } onTransitionEnd(transition: androidx.transition.Transition): void { const entry = this.entry; - if (traceEnabled()) { - traceWrite(`END ${toShortString(transition)} transition for ${entry.fragmentTag}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`END ${toShortString(transition)} transition for ${entry.fragmentTag}`, Trace.categories.Transition); } transitionOrAnimationCompleted(entry); } onTransitionResume(transition: androidx.transition.Transition): void { - if (traceEnabled()) { + if (Trace.isEnabled()) { const fragment = this.entry.fragmentTag; - traceWrite(`RESUME ${toShortString(transition)} transition for ${fragment}`, traceCategories.Transition); + Trace.write(`RESUME ${toShortString(transition)} transition for ${fragment}`, Trace.categories.Transition); } } onTransitionPause(transition: androidx.transition.Transition): void { - if (traceEnabled()) { - traceWrite(`PAUSE ${toShortString(transition)} transition for ${this.entry.fragmentTag}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`PAUSE ${toShortString(transition)} transition for ${this.entry.fragmentTag}`, Trace.categories.Transition); } } onTransitionCancel(transition: androidx.transition.Transition): void { - if (traceEnabled()) { - traceWrite(`CANCEL ${toShortString(transition)} transition for ${this.entry.fragmentTag}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`CANCEL ${toShortString(transition)} transition for ${this.entry.fragmentTag}`, Trace.categories.Transition); } } } @@ -394,8 +392,8 @@ function clearExitAndReenterTransitions(entry: ExpandedEntry, removeListener: bo } fragment.setExitTransition(null); - if (traceEnabled()) { - traceWrite(`Cleared Exit ${exitTransition.getClass().getSimpleName()} transition for ${fragment}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`Cleared Exit ${exitTransition.getClass().getSimpleName()} transition for ${fragment}`, Trace.categories.Transition); } } @@ -413,8 +411,8 @@ function clearExitAndReenterTransitions(entry: ExpandedEntry, removeListener: bo } fragment.setReenterTransition(null); - if (traceEnabled()) { - traceWrite(`Cleared Reenter ${reenterTransition.getClass().getSimpleName()} transition for ${fragment}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`Cleared Reenter ${reenterTransition.getClass().getSimpleName()} transition for ${fragment}`, Trace.categories.Transition); } } @@ -445,8 +443,8 @@ function clearEntry(entry: ExpandedEntry, removeListener: boolean): void { } fragment.setEnterTransition(null); - if (traceEnabled()) { - traceWrite(`Cleared Enter ${enterTransition.getClass().getSimpleName()} transition for ${fragment}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`Cleared Enter ${enterTransition.getClass().getSimpleName()} transition for ${fragment}`, Trace.categories.Transition); } } @@ -464,8 +462,8 @@ function clearEntry(entry: ExpandedEntry, removeListener: boolean): void { } fragment.setReturnTransition(null); - if (traceEnabled()) { - traceWrite(`Cleared Return ${returnTransition.getClass().getSimpleName()} transition for ${fragment}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`Cleared Return ${returnTransition.getClass().getSimpleName()} transition for ${fragment}`, Trace.categories.Transition); } } @@ -685,7 +683,7 @@ function toShortString(nativeTransition: androidx.transition.Transition): string } function printTransitions(entry: ExpandedEntry) { - if (entry && traceEnabled()) { + if (entry && Trace.isEnabled()) { let result = `${entry.fragmentTag} Transitions:`; if (entry.transitionName) { result += `transitionName=${entry.transitionName}, `; @@ -697,7 +695,7 @@ function printTransitions(entry: ExpandedEntry) { result += `${fragment.getReenterTransition() ? " popEnter=" + toShortString(fragment.getReenterTransition()) : ""}`; result += `${fragment.getReturnTransition() ? " popExit=" + toShortString(fragment.getReturnTransition()) : ""}`; - traceWrite(result, traceCategories.Transition); + Trace.write(result, Trace.categories.Transition); } } diff --git a/nativescript-core/ui/frame/fragment.transitions.d.ts b/nativescript-core/ui/frame/fragment.transitions.d.ts index d4e06f1e7..02fc71ed2 100644 --- a/nativescript-core/ui/frame/fragment.transitions.d.ts +++ b/nativescript-core/ui/frame/fragment.transitions.d.ts @@ -1,10 +1,4 @@ -/** - * @module "ui/transition" - */ /** */ - -import { NavigationTransition, BackstackEntry } from "../frame"; -// Types. -import { Transition, AndroidTransitionType } from "../transition/transition"; +import { NavigationTransition, BackstackEntry } from "../frame"; /** * @private diff --git a/nativescript-core/ui/frame/fragment.transitions.ios.ts b/nativescript-core/ui/frame/fragment.transitions.ios.ts index 6aa8f4c2c..8a0685c36 100644 --- a/nativescript-core/ui/frame/fragment.transitions.ios.ts +++ b/nativescript-core/ui/frame/fragment.transitions.ios.ts @@ -3,7 +3,7 @@ import { Transition } from "../transition/transition"; import { SlideTransition } from "../transition/slide-transition"; import { FadeTransition } from "../transition/fade-transition"; -import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories } from "../../trace"; +import { Trace } from "../../trace"; module UIViewControllerAnimatedTransitioningMethods { const methodSignature = NSMethodSignature.signatureWithObjCTypes("v@:c"); @@ -45,8 +45,8 @@ class AnimatedTransitioning extends NSObject implements UIViewControllerAnimated case UINavigationControllerOperation.None: this._transitionType = "none"; break; } - if (traceEnabled()) { - traceWrite(`START ${this._transition} ${this._transitionType}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`START ${this._transition} ${this._transitionType}`, Trace.categories.Transition); } this._transition.animateIOSTransition(containerView, this._fromVC.view, this._toVC.view, this._operation, completion); } @@ -57,12 +57,12 @@ class AnimatedTransitioning extends NSObject implements UIViewControllerAnimated public animationEnded(transitionCompleted: boolean): void { if (transitionCompleted) { - if (traceEnabled()) { - traceWrite(`END ${this._transition} ${this._transitionType}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`END ${this._transition} ${this._transitionType}`, Trace.categories.Transition); } } else { - if (traceEnabled()) { - traceWrite(`CANCEL ${this._transition} ${this._transitionType}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`CANCEL ${this._transition} ${this._transitionType}`, Trace.categories.Transition); } } } diff --git a/nativescript-core/ui/frame/fragment.transitions.types.ts b/nativescript-core/ui/frame/fragment.transitions.types.ts index b279b50c0..a70f97c8b 100644 --- a/nativescript-core/ui/frame/fragment.transitions.types.ts +++ b/nativescript-core/ui/frame/fragment.transitions.types.ts @@ -1,7 +1,3 @@ -/** - * @module "ui/fragment.transition.types" - * @private - */ /** */ //@private export const enum AnimationType { enterFakeResourceId = -10, diff --git a/nativescript-core/ui/frame/frame-common.ts b/nativescript-core/ui/frame/frame-common.ts index d29671b46..94d96623d 100644 --- a/nativescript-core/ui/frame/frame-common.ts +++ b/nativescript-core/ui/frame/frame-common.ts @@ -2,11 +2,15 @@ import { Frame as FrameDefinition } from "."; import { BackstackEntry, NavigationContext, NavigationEntry, NavigationTransition, NavigationType } from "./frame-interfaces"; import { Page } from "../page"; -import { View, CustomLayoutView, isIOS, isAndroid, traceEnabled, traceWrite, traceCategories, Property, CSSType } from "../core/view"; +import { View, CustomLayoutView, CSSType } from "../core/view"; +import { Property } from "../core/properties"; +import { isIOS, isAndroid } from "../../platform"; +import { Trace } from "../../trace"; // Requires. import { frameStack, topmost as frameStackTopmost, _pushInFrameStack, _popFromFrameStack, _removeFromFrameStack } from "./frame-stack"; -import { getAncestor, viewMatchesModuleContext } from "../core/view/view-common"; +import { viewMatchesModuleContext } from "../core/view/view-common"; +import { getAncestor } from "../core/view-base"; import { Builder } from "../builder"; import { sanitizeModuleName } from "../builder/module-name-sanitizer"; import { profile } from "../../profiling"; @@ -162,8 +166,8 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { * @param to The backstack entry to navigate back to. */ public goBack(backstackEntry?: BackstackEntry): void { - if (traceEnabled()) { - traceWrite(`GO BACK`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`GO BACK`, Trace.categories.Navigation); } if (!this.canGoBack()) { @@ -201,8 +205,8 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { } public navigate(param: any) { - if (traceEnabled()) { - traceWrite(`NAVIGATE`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`NAVIGATE`, Trace.categories.Navigation); } this._pushInFrameStack(); @@ -355,7 +359,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { } public _updateActionBar(page?: Page, disableNavBarAnimation?: boolean) { - //traceWrite("calling _updateActionBar on Frame", traceCategories.Navigation); + //Trace.write("calling _updateActionBar on Frame", Trace.categories.Navigation); } protected _processNextNavigationEntry() { @@ -399,14 +403,14 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { } public _goBackCore(backstackEntry: BackstackEntry) { - if (traceEnabled()) { - traceWrite(`GO BACK CORE(${this._backstackEntryTrace(backstackEntry)}); currentPage: ${this.currentPage}`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`GO BACK CORE(${this._backstackEntryTrace(backstackEntry)}); currentPage: ${this.currentPage}`, Trace.categories.Navigation); } } public _navigateCore(backstackEntry: BackstackEntry) { - if (traceEnabled()) { - traceWrite(`NAVIGATE CORE(${this._backstackEntryTrace(backstackEntry)}); currentPage: ${this.currentPage}`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`NAVIGATE CORE(${this._backstackEntryTrace(backstackEntry)}); currentPage: ${this.currentPage}`, Trace.categories.Navigation); } } @@ -617,7 +621,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { if (this.currentPage && viewMatchesModuleContext(this.currentPage, context, ["markup", "script"])) { - traceWrite(`Change Handled: Replacing page ${context.path}`, traceCategories.Livesync); + Trace.write(`Change Handled: Replacing page ${context.path}`, Trace.categories.Livesync); this.replacePage(context.path); @@ -631,8 +635,8 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { // Reset activity/window content when: // + Changes are not handled on View // + There is no ModuleContext - if (traceEnabled()) { - traceWrite(`${this}._onLivesync()`, traceCategories.Livesync); + if (Trace.isEnabled()) { + Trace.write(`${this}._onLivesync()`, Trace.categories.Livesync); } if (!this._currentEntry || !this._currentEntry.entry) { diff --git a/nativescript-core/ui/frame/frame.android.ts b/nativescript-core/ui/frame/frame.android.ts index f4c217cf6..cbe1c2267 100644 --- a/nativescript-core/ui/frame/frame.android.ts +++ b/nativescript-core/ui/frame/frame.android.ts @@ -10,9 +10,12 @@ import { Page } from "../page"; import * as application from "../../application"; import { - _stack, FrameBase, NavigationType, Observable, - traceCategories, traceEnabled, traceError, traceWrite, View, Color + _stack, FrameBase, NavigationType } from "./frame-common"; +import { Color } from "../../color"; +import { Trace } from "../../trace"; +import { View } from "../core/view"; +import { Observable } from "../../data/observable"; import { _setAndroidFragmentTransitions, _getAnimatedEntries, @@ -118,7 +121,7 @@ export class Frame extends FrameBase { callbacks.resetActivityContent(activity); } } else { - traceError(`${activity}[CALLBACKS] is null or undefined`); + Trace.error(`${activity}[CALLBACKS] is null or undefined`); } } @@ -747,8 +750,8 @@ class AndroidFrame extends Observable implements AndroidFrameDefinition { function findPageForFragment(fragment: androidx.fragment.app.Fragment, frame: Frame) { const fragmentTag = fragment.getTag(); - if (traceEnabled()) { - traceWrite(`Finding page for ${fragmentTag}.`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`Finding page for ${fragmentTag}.`, Trace.categories.NativeLifecycle); } let entry: BackstackEntry; @@ -829,8 +832,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { @profile public onHiddenChanged(fragment: androidx.fragment.app.Fragment, hidden: boolean, superFunc: Function): void { - if (traceEnabled()) { - traceWrite(`${fragment}.onHiddenChanged(${hidden})`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`${fragment}.onHiddenChanged(${hidden})`, Trace.categories.NativeLifecycle); } superFunc.call(fragment, hidden); } @@ -851,8 +854,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { @profile public onCreate(fragment: androidx.fragment.app.Fragment, savedInstanceState: android.os.Bundle, superFunc: Function): void { - if (traceEnabled()) { - traceWrite(`${fragment}.onCreate(${savedInstanceState})`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`${fragment}.onCreate(${savedInstanceState})`, Trace.categories.NativeLifecycle); } superFunc.call(fragment, savedInstanceState); @@ -872,27 +875,27 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { @profile public onCreateView(fragment: androidx.fragment.app.Fragment, inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle, superFunc: Function): android.view.View { - if (traceEnabled()) { - traceWrite(`${fragment}.onCreateView(inflater, container, ${savedInstanceState})`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`${fragment}.onCreateView(inflater, container, ${savedInstanceState})`, Trace.categories.NativeLifecycle); } const entry = this.entry; if (!entry) { - traceError(`${fragment}.onCreateView: entry is null or undefined`); + Trace.error(`${fragment}.onCreateView: entry is null or undefined`); return null; } const page = entry.resolvedPage; if (!page) { - traceError(`${fragment}.onCreateView: entry has no resolvedPage`); + Trace.error(`${fragment}.onCreateView: entry has no resolvedPage`); return null; } const frame = this.frame; if (!frame) { - traceError(`${fragment}.onCreateView: this.frame is null or undefined`); + Trace.error(`${fragment}.onCreateView: this.frame is null or undefined`); return null; } @@ -946,8 +949,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { @profile public onSaveInstanceState(fragment: androidx.fragment.app.Fragment, outState: android.os.Bundle, superFunc: Function): void { - if (traceEnabled()) { - traceWrite(`${fragment}.onSaveInstanceState(${outState})`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`${fragment}.onSaveInstanceState(${outState})`, Trace.categories.NativeLifecycle); } superFunc.call(fragment, outState); } @@ -955,8 +958,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { @profile public onDestroyView(fragment: org.nativescript.widgets.FragmentBase, superFunc: Function): void { try { - if (traceEnabled()) { - traceWrite(`${fragment}.onDestroyView()`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`${fragment}.onDestroyView()`, Trace.categories.NativeLifecycle); } const hasRemovingParent = fragment.getRemovingParentFragment(); @@ -974,15 +977,15 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { @profile public onDestroy(fragment: androidx.fragment.app.Fragment, superFunc: Function): void { - if (traceEnabled()) { - traceWrite(`${fragment}.onDestroy()`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`${fragment}.onDestroy()`, Trace.categories.NativeLifecycle); } superFunc.call(fragment); const entry = this.entry; if (!entry) { - traceError(`${fragment}.onDestroy: entry is null or undefined`); + Trace.error(`${fragment}.onDestroy: entry is null or undefined`); return null; } @@ -995,7 +998,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { const page = entry.resolvedPage; if (!page) { - traceError(`${fragment}.onDestroy: entry has no resolvedPage`); + Trace.error(`${fragment}.onDestroy: entry has no resolvedPage`); return null; } @@ -1064,8 +1067,8 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { @profile public onCreate(activity: androidx.appcompat.app.AppCompatActivity, savedInstanceState: android.os.Bundle, intentOrSuperFunc: android.content.Intent | Function, superFunc?: Function): void { - if (traceEnabled()) { - traceWrite(`Activity.onCreate(${savedInstanceState})`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`Activity.onCreate(${savedInstanceState})`, Trace.categories.NativeLifecycle); } const intent: android.content.Intent = superFunc ? intentOrSuperFunc : undefined; @@ -1135,8 +1138,8 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { public onStart(activity: any, superFunc: Function): void { superFunc.call(activity); - if (traceEnabled()) { - traceWrite("NativeScriptActivity.onStart();", traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write("NativeScriptActivity.onStart();", Trace.categories.NativeLifecycle); } const rootView = this._rootView; @@ -1149,8 +1152,8 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { public onStop(activity: any, superFunc: Function): void { superFunc.call(activity); - if (traceEnabled()) { - traceWrite("NativeScriptActivity.onStop();", traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write("NativeScriptActivity.onStop();", Trace.categories.NativeLifecycle); } const rootView = this._rootView; @@ -1163,8 +1166,8 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { public onPostResume(activity: any, superFunc: Function): void { superFunc.call(activity); - if (traceEnabled()) { - traceWrite("NativeScriptActivity.onPostResume();", traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write("NativeScriptActivity.onPostResume();", Trace.categories.NativeLifecycle); } // NOTE: activity.onPostResume() is called when activity resume is complete and we can @@ -1186,8 +1189,8 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { @profile public onDestroy(activity: any, superFunc: Function): void { try { - if (traceEnabled()) { - traceWrite("NativeScriptActivity.onDestroy();", traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write("NativeScriptActivity.onDestroy();", Trace.categories.NativeLifecycle); } const rootView = this._rootView; @@ -1204,8 +1207,8 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { @profile public onBackPressed(activity: any, superFunc: Function): void { - if (traceEnabled()) { - traceWrite("NativeScriptActivity.onBackPressed;", traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write("NativeScriptActivity.onBackPressed;", Trace.categories.NativeLifecycle); } const args = { @@ -1248,8 +1251,8 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { grantResults: Array, superFunc: Function ): void { - if (traceEnabled()) { - traceWrite("NativeScriptActivity.onRequestPermissionsResult;", traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write("NativeScriptActivity.onRequestPermissionsResult;", Trace.categories.NativeLifecycle); } application.android.notify({ @@ -1271,8 +1274,8 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { superFunc: Function ): void { superFunc.call(activity, requestCode, resultCode, data); - if (traceEnabled()) { - traceWrite(`NativeScriptActivity.onActivityResult(${requestCode}, ${resultCode}, ${data})`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`NativeScriptActivity.onActivityResult(${requestCode}, ${resultCode}, ${data})`, Trace.categories.NativeLifecycle); } application.android.notify({ @@ -1310,10 +1313,10 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { ): void { let rootView = this._rootView; - if (traceEnabled()) { - traceWrite( + if (Trace.isEnabled()) { + Trace.write( `Frame.setActivityContent rootView: ${rootView} shouldCreateRootFrame: false fireLaunchEvent: ${fireLaunchEvent}`, - traceCategories.NativeLifecycle + Trace.categories.NativeLifecycle ); } diff --git a/nativescript-core/ui/frame/frame.d.ts b/nativescript-core/ui/frame/frame.d.ts index ca40894dd..090c39619 100644 --- a/nativescript-core/ui/frame/frame.d.ts +++ b/nativescript-core/ui/frame/frame.d.ts @@ -1,14 +1,9 @@ -/** - * Contains the Frame class, which represents the logical View unit that is responsible for navigation within an application. - * @module "ui/frame" - */ /** */ - -import { NavigationType } from "./frame-common"; -import { Page, View, Observable, EventData } from "../page"; +import { NavigationType } from "./frame-common"; +import { Page } from "../page"; +import { Observable, EventData } from "../../data/observable"; +import { View } from "../core/view"; import { Transition } from "../transition"; -export * from "../page"; - /** * Represents the logical View unit that is responsible for navigation within an application. * Nested frames are supported, enabling hierarchical navigation scenarios. diff --git a/nativescript-core/ui/frame/frame.ios.ts b/nativescript-core/ui/frame/frame.ios.ts index 774c67c00..131250344 100644 --- a/nativescript-core/ui/frame/frame.ios.ts +++ b/nativescript-core/ui/frame/frame.ios.ts @@ -6,12 +6,11 @@ import { View } from "../core/view"; // Requires import { _createIOSAnimatedTransitioning } from "./fragment.transitions"; -import { ios as iosViewHelper } from "../core/view/view-helper"; +import { IOSHelper } from "../core/view/view-helper"; import { profile } from "../../profiling"; import { ios as iosUtils, layout } from "../../utils/utils"; import { - isCategorySet, isEnabled as traceEnabled, - categories as traceCategories, write as traceWrite + Trace } from "../../trace"; export * from "./frame-common"; @@ -125,8 +124,8 @@ export class Frame extends FrameBase { // Update action-bar with disabled animations before the initial navigation. this._updateActionBar(backstackEntry.resolvedPage, true); this._ios.controller.pushViewControllerAnimated(viewController, animated); - if (traceEnabled()) { - traceWrite(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, Trace.categories.Navigation); } return; @@ -145,8 +144,8 @@ export class Frame extends FrameBase { } this._ios.controller.setViewControllersAnimated(newControllers, animated); - if (traceEnabled()) { - traceWrite(`${this}.setViewControllersAnimated([${viewController}], ${animated}); depth = ${navDepth}`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`${this}.setViewControllersAnimated([${viewController}], ${animated}); depth = ${navDepth}`, Trace.categories.Navigation); } return; @@ -173,8 +172,8 @@ export class Frame extends FrameBase { // replace the controllers instead of pushing directly this._ios.controller.setViewControllersAnimated(newControllers, animated); - if (traceEnabled()) { - traceWrite(`${this}.setViewControllersAnimated([originalControllers - lastController + ${viewController}], ${animated}); depth = ${navDepth}`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`${this}.setViewControllersAnimated([originalControllers - lastController + ${viewController}], ${animated}); depth = ${navDepth}`, Trace.categories.Navigation); } return; @@ -182,8 +181,8 @@ export class Frame extends FrameBase { // General case. this._ios.controller.pushViewControllerAnimated(viewController, animated); - if (traceEnabled()) { - traceWrite(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, Trace.categories.Navigation); } } @@ -195,8 +194,8 @@ export class Frame extends FrameBase { let animated = this._currentEntry ? this._getIsAnimatedNavigation(this._currentEntry.entry) : false; this._updateActionBar(backstackEntry.resolvedPage); - if (traceEnabled()) { - traceWrite(`${this}.popToViewControllerAnimated(${controller}, ${animated}); depth = ${navDepth}`, traceCategories.Navigation); + if (Trace.isEnabled()) { + Trace.write(`${this}.popToViewControllerAnimated(${controller}, ${animated}); depth = ${navDepth}`, Trace.categories.Navigation); } this._ios.controller.popToViewControllerAnimated(controller, animated); @@ -315,20 +314,20 @@ class TransitionDelegate extends NSObject { } public animationWillStart(animationID: string, context: any): void { - if (traceEnabled()) { - traceWrite(`START ${this._id}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`START ${this._id}`, Trace.categories.Transition); } } public animationDidStop(animationID: string, finished: boolean, context: any): void { if (finished) { - if (traceEnabled()) { - traceWrite(`END ${this._id}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`END ${this._id}`, Trace.categories.Transition); } } else { - if (traceEnabled()) { - traceWrite(`CANCEL ${this._id}`, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write(`CANCEL ${this._id}`, Trace.categories.Transition); } } @@ -374,8 +373,8 @@ class UINavigationControllerAnimatedDelegate extends NSObject implements UINavig return null; } - if (traceEnabled()) { - traceWrite(`UINavigationControllerImpl.navigationControllerAnimationControllerForOperationFromViewControllerToViewController(${operation}, ${fromVC}, ${toVC}), transition: ${JSON.stringify(navigationTransition)}`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`UINavigationControllerImpl.navigationControllerAnimationControllerForOperationFromViewControllerToViewController(${operation}, ${fromVC}, ${toVC}), transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle); } let curve = _getNativeCurve(navigationTransition); @@ -427,7 +426,7 @@ class UINavigationControllerImpl extends UINavigationController { let duration = navigationTransition.duration ? navigationTransition.duration / 1000 : _defaultTransitionDuration; let curve = _getNativeCurve(navigationTransition); - let transitionTraced = isCategorySet(traceCategories.Transition); + let transitionTraced = Trace.isCategorySet(Trace.categories.Transition); let transitionDelegate: TransitionDelegate; if (transitionTraced) { let id = _getTransitionId(nativeTransition, transitionType); @@ -450,8 +449,8 @@ class UINavigationControllerImpl extends UINavigationController { @profile public pushViewControllerAnimated(viewController: UIViewController, animated: boolean): void { let navigationTransition = viewController[TRANSITION]; - if (traceEnabled()) { - traceWrite(`UINavigationControllerImpl.pushViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`UINavigationControllerImpl.pushViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle); } let nativeTransition = _getNativeTransition(navigationTransition, true); @@ -471,8 +470,8 @@ class UINavigationControllerImpl extends UINavigationController { let viewController = viewControllers.lastObject; let navigationTransition = viewController[TRANSITION]; - if (traceEnabled()) { - traceWrite(`UINavigationControllerImpl.setViewControllersAnimated(${viewControllers}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`UINavigationControllerImpl.setViewControllersAnimated(${viewControllers}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle); } let nativeTransition = _getNativeTransition(navigationTransition, true); @@ -490,8 +489,8 @@ class UINavigationControllerImpl extends UINavigationController { public popViewControllerAnimated(animated: boolean): UIViewController { let lastViewController = this.viewControllers.lastObject; let navigationTransition = lastViewController[TRANSITION]; - if (traceEnabled()) { - traceWrite(`UINavigationControllerImpl.popViewControllerAnimated(${animated}); transition: ${JSON.stringify(navigationTransition)}`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`UINavigationControllerImpl.popViewControllerAnimated(${animated}); transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle); } if (navigationTransition && navigationTransition.name === NON_ANIMATED_TRANSITION) { @@ -514,8 +513,8 @@ class UINavigationControllerImpl extends UINavigationController { public popToViewControllerAnimated(viewController: UIViewController, animated: boolean): NSArray { let lastViewController = this.viewControllers.lastObject; let navigationTransition = lastViewController[TRANSITION]; - if (traceEnabled()) { - traceWrite(`UINavigationControllerImpl.popToViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, traceCategories.NativeLifecycle); + if (Trace.isEnabled()) { + Trace.write(`UINavigationControllerImpl.popToViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle); } if (navigationTransition && navigationTransition.name === NON_ANIMATED_TRANSITION) { @@ -544,7 +543,7 @@ class UINavigationControllerImpl extends UINavigationController { if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { - owner.notify({ eventName: iosViewHelper.traitCollectionColorAppearanceChangedEvent, object: owner }); + owner.notify({ eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent, object: owner }); } } } @@ -586,36 +585,36 @@ export function _getNativeCurve(transition: NavigationTransition): UIViewAnimati if (transition.curve) { switch (transition.curve) { case "easeIn": - if (traceEnabled()) { - traceWrite("Transition curve resolved to UIViewAnimationCurve.EaseIn.", traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write("Transition curve resolved to UIViewAnimationCurve.EaseIn.", Trace.categories.Transition); } return UIViewAnimationCurve.EaseIn; case "easeOut": - if (traceEnabled()) { - traceWrite("Transition curve resolved to UIViewAnimationCurve.EaseOut.", traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write("Transition curve resolved to UIViewAnimationCurve.EaseOut.", Trace.categories.Transition); } return UIViewAnimationCurve.EaseOut; case "easeInOut": - if (traceEnabled()) { - traceWrite("Transition curve resolved to UIViewAnimationCurve.EaseInOut.", traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write("Transition curve resolved to UIViewAnimationCurve.EaseInOut.", Trace.categories.Transition); } return UIViewAnimationCurve.EaseInOut; case "linear": - if (traceEnabled()) { - traceWrite("Transition curve resolved to UIViewAnimationCurve.Linear.", traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write("Transition curve resolved to UIViewAnimationCurve.Linear.", Trace.categories.Transition); } return UIViewAnimationCurve.Linear; default: - if (traceEnabled()) { - traceWrite("Transition curve resolved to original: " + transition.curve, traceCategories.Transition); + if (Trace.isEnabled()) { + Trace.write("Transition curve resolved to original: " + transition.curve, Trace.categories.Transition); } return transition.curve; diff --git a/nativescript-core/ui/frame/transition-definitions.android.d.ts b/nativescript-core/ui/frame/transition-definitions.android.d.ts index 5773d3a0a..bbfc99289 100644 --- a/nativescript-core/ui/frame/transition-definitions.android.d.ts +++ b/nativescript-core/ui/frame/transition-definitions.android.d.ts @@ -1,8 +1,3 @@ -/** - * @module "ui/frame/transition-definitions.android - * @private - */ /** */ - // Definitions for Android API lvl 21 transitions declare module android { export module transition { diff --git a/nativescript-core/ui/gestures/gestures.d.ts b/nativescript-core/ui/gestures/gestures.d.ts index 369289b68..869ecb4df 100644 --- a/nativescript-core/ui/gestures/gestures.d.ts +++ b/nativescript-core/ui/gestures/gestures.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the GesturesObserver class, which lets you observe and respond to user gestures. - * @module "ui/gestures" - */ /** */ - - import { View, EventData } from "../core/view"; +import { View } from "../core/view"; +import { EventData } from "../../data/observable"; /** * Defines an enum with supported gesture types. diff --git a/nativescript-core/ui/html-view/html-view-common.ts b/nativescript-core/ui/html-view/html-view-common.ts index 85045bc18..7b2d1f75e 100644 --- a/nativescript-core/ui/html-view/html-view-common.ts +++ b/nativescript-core/ui/html-view/html-view-common.ts @@ -1,5 +1,7 @@ -import { Style, CssProperty } from "../core/properties"; -import { View, Property, CSSType } from "../core/view"; +import { CssProperty } from "../core/properties"; +import { View, CSSType } from "../core/view"; +import { Property } from "../core/properties"; +import { Style } from "../styling/style"; import { Color } from "../../color"; import { HtmlView as HtmlViewDefinition } from "."; diff --git a/nativescript-core/ui/html-view/html-view.android.ts b/nativescript-core/ui/html-view/index.android.ts similarity index 100% rename from nativescript-core/ui/html-view/html-view.android.ts rename to nativescript-core/ui/html-view/index.android.ts diff --git a/nativescript-core/ui/html-view/html-view.d.ts b/nativescript-core/ui/html-view/index.d.ts similarity index 85% rename from nativescript-core/ui/html-view/html-view.d.ts rename to nativescript-core/ui/html-view/index.d.ts index f553ed7b2..15028b981 100644 --- a/nativescript-core/ui/html-view/html-view.d.ts +++ b/nativescript-core/ui/html-view/index.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the HtmlView class, which represents a standard html view widget. - * @module "ui/html-view" - */ /** */ - -import { View, Property } from "../core/view"; +import { View } from "../core/view"; +import { Property } from "../core/properties"; /** * Represents a view with html content. Use this component instead WebView when you want to show just static HTML content. diff --git a/nativescript-core/ui/html-view/html-view.ios.ts b/nativescript-core/ui/html-view/index.ios.ts similarity index 97% rename from nativescript-core/ui/html-view/html-view.ios.ts rename to nativescript-core/ui/html-view/index.ios.ts index 89156326f..87bf25559 100644 --- a/nativescript-core/ui/html-view/html-view.ios.ts +++ b/nativescript-core/ui/html-view/index.ios.ts @@ -5,10 +5,11 @@ import { fontInternalProperty, } from "../styling/style-properties"; import { - HtmlViewBase, View, layout, htmlProperty, fontSizeProperty, + HtmlViewBase, htmlProperty, linkColorProperty, } from "./html-view-common"; -import { ios } from "../../utils/utils"; +import { View } from '../core/view'; +import { ios, layout } from "../../utils/utils"; export * from "./html-view-common"; diff --git a/nativescript-core/ui/html-view/package.json b/nativescript-core/ui/html-view/package.json deleted file mode 100644 index bfaca75bb..000000000 --- a/nativescript-core/ui/html-view/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "html-view", - "main": "html-view", - "types": "html-view.d.ts" -} diff --git a/nativescript-core/ui/image-cache/image-cache.d.ts b/nativescript-core/ui/image-cache/image-cache.d.ts index 60aaff08a..2d53094c1 100644 --- a/nativescript-core/ui/image-cache/image-cache.d.ts +++ b/nativescript-core/ui/image-cache/image-cache.d.ts @@ -1,9 +1,4 @@ -/** - * Contains the Cache class, which handles image download requests and caches the already downloaded images. - * @module "ui/image-cache" - */ /** */ - -import { Observable, EventData } from "../../data/observable"; +import { Observable, EventData } from "../../data/observable"; import { ImageSource } from "../../image-source"; /** diff --git a/nativescript-core/ui/image/image-common.ts b/nativescript-core/ui/image/image-common.ts index 0b4ca0b85..b26310b84 100644 --- a/nativescript-core/ui/image/image-common.ts +++ b/nativescript-core/ui/image/image-common.ts @@ -1,10 +1,15 @@ import { Image as ImageDefinition, Stretch } from "."; -import { View, Property, InheritedCssProperty, Length, Style, Color, isIOS, booleanConverter, CSSType, traceEnabled, traceWrite, traceCategories } from "../core/view"; +import { View, CSSType } from "../core/view"; +import { booleanConverter } from "../core/view-base"; import { ImageAsset } from "../../image-asset"; import { ImageSource } from "../../image-source"; import { isDataURI, isFontIconURI, isFileOrResourcePath, RESOURCE_PREFIX } from "../../utils/utils"; -export * from "../core/view"; -export { ImageSource, ImageAsset, isDataURI, isFontIconURI, isFileOrResourcePath, RESOURCE_PREFIX }; +import { Color } from "../../color"; +import { isIOS } from "../../platform"; +import { Style } from "../styling/style"; +import { Length } from "../styling/style-properties"; +import { Property, InheritedCssProperty, } from "../core/properties"; +import { Trace } from "../../trace"; @CSSType("Image") export abstract class ImageBase extends View implements ImageDefinition { @@ -89,11 +94,11 @@ export abstract class ImageBase extends View implements ImageDefinition { }, err => { // catch: Response content may not be converted to an Image this.isLoading = false; - if (traceEnabled()) { + if (Trace.isEnabled()) { if (typeof err === "object" && err.message) { err = err.message; } - traceWrite(err, traceCategories.Debug); + Trace.write(err, Trace.categories.Debug); } }); } diff --git a/nativescript-core/ui/image/image.d.ts b/nativescript-core/ui/image/image.d.ts index f64bc7b7c..a2e3402b1 100644 --- a/nativescript-core/ui/image/image.d.ts +++ b/nativescript-core/ui/image/image.d.ts @@ -1,10 +1,9 @@ -/** - * Contains the Image class, which represents an image widget. - * @module "ui/image" - */ /** */ - -import { View, Property, InheritedCssProperty, Color, Style, Length } from "../core/view"; +import { View } from "../core/view"; +import { Style } from "../styling/style" import { ImageSource } from "../../image-source"; +import { Color } from "../../color"; +import { Property, InheritedCssProperty } from "../core/properties"; +import { Length } from '../styling/style-properties'; /** * Represents a class that provides functionality for loading and streching image(s). diff --git a/nativescript-core/ui/image/image.ios.ts b/nativescript-core/ui/image/image.ios.ts index 15a4251c6..d0015a42a 100644 --- a/nativescript-core/ui/image/image.ios.ts +++ b/nativescript-core/ui/image/image.ios.ts @@ -1,7 +1,10 @@ import { - ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, srcProperty, layout, Color, - traceEnabled, traceWrite, traceCategories + ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, srcProperty } from "./image-common"; +import { ImageSource } from "../../image-source"; +import { Color } from "../../color"; +import { Trace } from "../../trace"; +import { layout } from "../../utils/utils"; export * from "./image-common"; @@ -76,10 +79,10 @@ export class Image extends ImageBase { measureWidth = finiteWidth ? Math.min(resultW, width) : resultW; measureHeight = finiteHeight ? Math.min(resultH, height) : resultH; - if (traceEnabled()) { - traceWrite("Image stretch: " + this.stretch + + if (Trace.isEnabled()) { + Trace.write("Image stretch: " + this.stretch + ", nativeWidth: " + nativeWidth + - ", nativeHeight: " + nativeHeight, traceCategories.Layout); + ", nativeHeight: " + nativeHeight, Trace.categories.Layout); } } diff --git a/nativescript-core/ui/index.ts b/nativescript-core/ui/index.ts index 75c1b5df7..f5b1be39a 100644 --- a/nativescript-core/ui/index.ts +++ b/nativescript-core/ui/index.ts @@ -7,11 +7,12 @@ export { Button } from "./button"; export { ContentView } from "./content-view"; export { ViewBase, ShowModalOptions } from "./core/view-base"; export { View, Template, KeyedTemplate, ShownModallyData } from "./core/view"; +export { Property, CoercibleProperty, InheritedProperty, CssProperty, InheritedCssProperty, ShorthandProperty, CssAnimationProperty, } from "./core/properties"; export { DatePicker } from "./date-picker"; // No need go export dialogs, they are already export exported globally -// import { action, alert, confirm, login, prompt } from "./dialogs"; -// export const nsDialogs = { action, alert, confirm, login, prompt }; +import { action, alert, confirm, login, prompt } from "./dialogs"; +export const Dialogs = { action, alert, confirm, login, prompt }; export * from "./editable-text-base"; export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry } from "./frame"; diff --git a/nativescript-core/ui/label/label.d.ts b/nativescript-core/ui/label/label.d.ts index cd6a6f2c1..2183aee89 100644 --- a/nativescript-core/ui/label/label.d.ts +++ b/nativescript-core/ui/label/label.d.ts @@ -1,9 +1,4 @@ -/** - * Contains the Label class, which represents a standard label widget. - * @module "ui/label" - */ /** */ - -import { TextBase } from "../text-base"; +import { TextBase } from "../text-base"; /** * Represents a text label. diff --git a/nativescript-core/ui/layouts/absolute-layout/absolute-layout.d.ts b/nativescript-core/ui/layouts/absolute-layout/absolute-layout.d.ts index 840993e76..53cc3ed95 100644 --- a/nativescript-core/ui/layouts/absolute-layout/absolute-layout.d.ts +++ b/nativescript-core/ui/layouts/absolute-layout/absolute-layout.d.ts @@ -1,8 +1,7 @@ -/** - * @module "ui/layouts/absolute-layout" - */ /** */ - -import { LayoutBase, View, Property, Length } from "../layout-base"; +import { LayoutBase } from "../layout-base"; +import { Property } from "../../core/properties"; +import { View } from '../../core/view'; +import { Length } from '../../styling/style-properties'; /** * A layout that lets you specify exact locations (left/top coordinates) of its children. diff --git a/nativescript-core/ui/layouts/dock-layout/dock-layout.d.ts b/nativescript-core/ui/layouts/dock-layout/dock-layout.d.ts index 8a965cf02..d628bccf5 100644 --- a/nativescript-core/ui/layouts/dock-layout/dock-layout.d.ts +++ b/nativescript-core/ui/layouts/dock-layout/dock-layout.d.ts @@ -1,8 +1,6 @@ -/** - * @module "ui/layouts/dock-layout" - */ /** */ - -import { LayoutBase, View, Property } from "../layout-base"; +import { LayoutBase } from "../layout-base"; +import { Property } from "../../core/properties"; +import { View } from '../../core/view'; /** * A Layout that arranges its children at its outer edges, and allows its last child to take up the remaining space. diff --git a/nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.d.ts b/nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.d.ts index c9d3a386b..9eb986e9f 100644 --- a/nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.d.ts +++ b/nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.d.ts @@ -1,8 +1,7 @@ -/** - * @module "ui/layouts/flexbox-layout" - */ /** */ - -import { LayoutBase, View, Style, CssProperty } from "../layout-base"; +import { LayoutBase } from "../layout-base"; +import { Style } from '../../styling/style'; +import { CssProperty } from "../../core/properties"; +import { View } from '../../core/view'; export type FlexDirection = "row" | "row-reverse" | "column" | "column-reverse"; export type FlexWrap = "nowrap" | "wrap" | "wrap-reverse"; diff --git a/nativescript-core/ui/layouts/grid-layout/grid-layout.d.ts b/nativescript-core/ui/layouts/grid-layout/grid-layout.d.ts index b1bdefa35..d28d8c657 100644 --- a/nativescript-core/ui/layouts/grid-layout/grid-layout.d.ts +++ b/nativescript-core/ui/layouts/grid-layout/grid-layout.d.ts @@ -1,8 +1,6 @@ -/** - * @module "ui/layouts/grid-layout" - */ /** */ - -import { LayoutBase, Property, View } from "../layout-base"; +import { LayoutBase } from "../layout-base"; +import { View } from '../../core/view'; +import { Property } from "../../core/properties"; /** * Defines row/column specific properties that apply to GridLayout elements. diff --git a/nativescript-core/ui/layouts/layout-base-common.ts b/nativescript-core/ui/layouts/layout-base-common.ts index 2add0b722..cf25e9d2d 100644 --- a/nativescript-core/ui/layouts/layout-base-common.ts +++ b/nativescript-core/ui/layouts/layout-base-common.ts @@ -1,7 +1,8 @@ import { LayoutBase as LayoutBaseDefinition } from "./layout-base"; -import { View, CustomLayoutView, Property, AddChildFromBuilder, getViewById, Length, booleanConverter } from "../core/view"; - -export * from "../core/view"; +import { View, CustomLayoutView, AddChildFromBuilder, } from "../core/view"; +import { booleanConverter, getViewById } from "../core/view-base"; +import { Property } from "../core/properties"; +import { Length } from "../styling/style-properties"; export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefinition, AddChildFromBuilder { diff --git a/nativescript-core/ui/layouts/layout-base.d.ts b/nativescript-core/ui/layouts/layout-base.d.ts index cbb0a9479..d0b2a79d1 100644 --- a/nativescript-core/ui/layouts/layout-base.d.ts +++ b/nativescript-core/ui/layouts/layout-base.d.ts @@ -1,10 +1,6 @@ -/** - * @module "ui/layouts/layout-base" - */ /** */ - -import { View, CustomLayoutView, Property, Length } from "../core/view"; - -export * from "../core/view"; +import { View, CustomLayoutView } from "../core/view"; +import { Property } from "../core/properties"; +import { Length } from "../styling/style-properties"; /** * Base class for all views that supports children positioning. diff --git a/nativescript-core/ui/layouts/stack-layout/stack-layout.d.ts b/nativescript-core/ui/layouts/stack-layout/stack-layout.d.ts index 644032bfc..e674c1930 100644 --- a/nativescript-core/ui/layouts/stack-layout/stack-layout.d.ts +++ b/nativescript-core/ui/layouts/stack-layout/stack-layout.d.ts @@ -1,7 +1,5 @@ -/** - * @module "ui/layouts/stack-layout" - */ /** */ -import { LayoutBase, Property } from "../layout-base"; +import { LayoutBase } from "../layout-base"; +import { Property } from "../../core/properties"; /** * A Layout that arranges its children horizontally or vertically. The direction can be set by orientation property. diff --git a/nativescript-core/ui/layouts/wrap-layout/wrap-layout.d.ts b/nativescript-core/ui/layouts/wrap-layout/wrap-layout.d.ts index e4f1ab668..6812769ea 100644 --- a/nativescript-core/ui/layouts/wrap-layout/wrap-layout.d.ts +++ b/nativescript-core/ui/layouts/wrap-layout/wrap-layout.d.ts @@ -1,8 +1,6 @@ -/** - * @module "ui/layouts/wrap-layout" - */ /** */ - -import { LayoutBase, Property, Length } from "../layout-base"; +import { LayoutBase } from "../layout-base"; +import { Length } from '../../styling/style-properties'; +import { Property } from "../../core/properties"; /** * WrapLayout position children in rows or columns depending on orientation property diff --git a/nativescript-core/ui/list-picker/list-picker.android.ts b/nativescript-core/ui/list-picker/index.android.ts similarity index 97% rename from nativescript-core/ui/list-picker/list-picker.android.ts rename to nativescript-core/ui/list-picker/index.android.ts index 81df1b80e..4d6b11d64 100644 --- a/nativescript-core/ui/list-picker/list-picker.android.ts +++ b/nativescript-core/ui/list-picker/index.android.ts @@ -1,5 +1,6 @@ -import { ListPickerBase, selectedIndexProperty, itemsProperty, colorProperty, Color } from "./list-picker-common"; -import { ItemsSource } from "."; +import { ListPickerBase, selectedIndexProperty, itemsProperty, ItemsSource } from "./list-picker-common"; +import { colorProperty } from '../styling/style-properties'; +import { Color } from '../../color'; import { device } from "../../platform"; import lazy from "../../utils/lazy"; diff --git a/nativescript-core/ui/list-picker/list-picker.d.ts b/nativescript-core/ui/list-picker/index.d.ts similarity index 83% rename from nativescript-core/ui/list-picker/list-picker.d.ts rename to nativescript-core/ui/list-picker/index.d.ts index c176caea8..674006cb2 100644 --- a/nativescript-core/ui/list-picker/list-picker.d.ts +++ b/nativescript-core/ui/list-picker/index.d.ts @@ -1,9 +1,6 @@ -/** - * Contains the ListPicker class. - * @module "ui/list-picker" - */ /** */ - -import { View, Property } from "../core/view"; +import { View } from "../core/view"; +import { Property } from "../core/properties"; +import { ItemsSource } from "./list-picker-common"; /** * Represents an list picker. @@ -31,10 +28,5 @@ export class ListPicker extends View { items: any; } -export interface ItemsSource { - length: number; - getItem(index: number): any; -} - export const selectedIndexProperty: Property; export const itemsProperty: Property; diff --git a/nativescript-core/ui/list-picker/list-picker.ios.ts b/nativescript-core/ui/list-picker/index.ios.ts similarity index 94% rename from nativescript-core/ui/list-picker/list-picker.ios.ts rename to nativescript-core/ui/list-picker/index.ios.ts index 0aa6b205b..5080877cd 100644 --- a/nativescript-core/ui/list-picker/list-picker.ios.ts +++ b/nativescript-core/ui/list-picker/index.ios.ts @@ -1,5 +1,6 @@ -import { ListPickerBase, Color, selectedIndexProperty, itemsProperty, backgroundColorProperty, colorProperty } from "./list-picker-common"; -import { ItemsSource } from "."; +import { ListPickerBase, selectedIndexProperty, itemsProperty, ItemsSource } from "./list-picker-common"; +import { Color } from "../../color"; +import { backgroundColorProperty, colorProperty } from "../styling/style-properties"; import { profile } from "../../profiling"; export * from "./list-picker-common"; diff --git a/nativescript-core/ui/list-picker/list-picker-common.ts b/nativescript-core/ui/list-picker/list-picker-common.ts index d6e44374d..ed3db3c0f 100644 --- a/nativescript-core/ui/list-picker/list-picker-common.ts +++ b/nativescript-core/ui/list-picker/list-picker-common.ts @@ -1,10 +1,13 @@ -import { ListPicker as ListPickerDefinition, ItemsSource } from "."; -import { View, Property, CoercibleProperty, CSSType } from "../core/view"; +import { View, CSSType } from "../core/view"; +import { Property, CoercibleProperty } from "../core/properties"; -export * from "../core/view"; +export interface ItemsSource { + length: number; + getItem(index: number): any; +} @CSSType("ListPicker") -export class ListPickerBase extends View implements ListPickerDefinition { +export class ListPickerBase extends View { public selectedIndex: number; public items: any[] | ItemsSource; diff --git a/nativescript-core/ui/list-picker/package.json b/nativescript-core/ui/list-picker/package.json deleted file mode 100644 index 2a7a47d1d..000000000 --- a/nativescript-core/ui/list-picker/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "list-picker", - "main": "list-picker", - "types": "list-picker.d.ts" -} diff --git a/nativescript-core/ui/list-view/list-view.android.ts b/nativescript-core/ui/list-view/index.android.ts similarity index 100% rename from nativescript-core/ui/list-view/list-view.android.ts rename to nativescript-core/ui/list-view/index.android.ts diff --git a/nativescript-core/ui/list-view/list-view.d.ts b/nativescript-core/ui/list-view/index.d.ts similarity index 95% rename from nativescript-core/ui/list-view/list-view.d.ts rename to nativescript-core/ui/list-view/index.d.ts index b73165e05..b4b51b859 100644 --- a/nativescript-core/ui/list-view/list-view.d.ts +++ b/nativescript-core/ui/list-view/index.d.ts @@ -1,9 +1,9 @@ -/** - * Contains the ListView class, which represents a standard list view widget. - * @module "ui/list-view" - */ /** */ - -import { EventData, View, Template, KeyedTemplate, Length, Property, CssProperty, Color, Style } from "../core/view"; +import { View, Template, KeyedTemplate } from "../core/view"; +import { Color } from '../../color'; +import { EventData } from '../../data/observable'; +import { Length } from '../styling/style-properties'; +import { Style } from '../styling/style'; +import { Property, CssProperty } from "../core/properties"; /** * Known template names. diff --git a/nativescript-core/ui/list-view/list-view.ios.ts b/nativescript-core/ui/list-view/index.ios.ts similarity index 97% rename from nativescript-core/ui/list-view/list-view.ios.ts rename to nativescript-core/ui/list-view/index.ios.ts index de406e7aa..c70c7ba0d 100644 --- a/nativescript-core/ui/list-view/list-view.ios.ts +++ b/nativescript-core/ui/list-view/index.ios.ts @@ -1,12 +1,17 @@ import { ItemEventData } from "."; import { - ListViewBase, View, KeyedTemplate, Length, Observable, Color, - separatorColorProperty, itemTemplatesProperty, iosEstimatedRowHeightProperty, layout, EventData + ListViewBase, + separatorColorProperty, itemTemplatesProperty, iosEstimatedRowHeightProperty } from "./list-view-common"; +import { View, KeyedTemplate } from "../core/view"; +import { Length } from "../styling/style-properties"; +import { Observable, EventData } from "../../data/observable"; +import { Color } from "../../color"; +import { layout } from "../../utils/utils"; import { StackLayout } from "../layouts/stack-layout"; import { ProxyViewContainer } from "../proxy-view-container"; import { profile } from "../../profiling"; -import * as trace from "../../trace"; +import { Trace } from "../../trace"; export * from "./list-view-common"; @@ -311,8 +316,8 @@ export class ListView extends ListViewBase { this.ios.scrollToRowAtIndexPathAtScrollPositionAnimated(NSIndexPath.indexPathForItemInSection(index, 0), UITableViewScrollPosition.Top, animated); - } else if (trace.isEnabled()) { - trace.write(`Cannot scroll listview to index ${index} when listview items not set`, trace.categories.Binding); + } else if (Trace.isEnabled()) { + Trace.write(`Cannot scroll listview to index ${index} when listview items not set`, Trace.categories.Binding); } } diff --git a/nativescript-core/ui/list-view/list-view-common.ts b/nativescript-core/ui/list-view/list-view-common.ts index 8eb6689e0..00288372c 100644 --- a/nativescript-core/ui/list-view/list-view-common.ts +++ b/nativescript-core/ui/list-view/list-view-common.ts @@ -1,12 +1,15 @@ import { ListView as ListViewDefinition, ItemsSource, ItemEventData, TemplatedItemsView } from "."; -import { CoercibleProperty, CssProperty, Style, View, ContainerView, Template, KeyedTemplate, Length, Property, Color, Observable, EventData, CSSType } from "../core/view"; +import { View, ContainerView, Template, KeyedTemplate, CSSType } from "../core/view"; +import { Property, CoercibleProperty, CssProperty } from "../core/properties"; +import { Length } from "../styling/style-properties"; +import { Style } from "../styling/style"; +import { Color } from "../../color"; import { Builder } from "../builder"; import { Label } from "../label"; +import { Observable, EventData } from "../../data/observable"; import { ObservableArray, ChangedData } from "../../data/observable-array"; import { addWeakEventListener, removeWeakEventListener } from "../core/weak-event-listener"; -export * from "../core/view"; - // TODO: Think of a way to register these instead of relying on hardcoded values. export module knownTemplates { export const itemTemplate = "itemTemplate"; diff --git a/nativescript-core/ui/list-view/package.json b/nativescript-core/ui/list-view/package.json deleted file mode 100644 index 60acd2273..000000000 --- a/nativescript-core/ui/list-view/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "list-view", - "main": "list-view", - "types": "list-view.d.ts" -} diff --git a/nativescript-core/ui/page/page.android.ts b/nativescript-core/ui/page/index.android.ts similarity index 95% rename from nativescript-core/ui/page/page.android.ts rename to nativescript-core/ui/page/index.android.ts index 715af532f..aa8bdc7ce 100644 --- a/nativescript-core/ui/page/page.android.ts +++ b/nativescript-core/ui/page/index.android.ts @@ -1,4 +1,6 @@ -import { View, PageBase, Color, actionBarHiddenProperty, statusBarStyleProperty, androidStatusBarBackgroundProperty } from "./page-common"; +import { PageBase, actionBarHiddenProperty, statusBarStyleProperty, androidStatusBarBackgroundProperty } from "./page-common"; +import { View } from "../core/view"; +import { Color } from "../../color"; import { ActionBar } from "../action-bar"; import { GridLayout } from "../layouts/grid-layout"; import { device } from "../../platform"; diff --git a/nativescript-core/ui/page/page.d.ts b/nativescript-core/ui/page/index.d.ts similarity index 94% rename from nativescript-core/ui/page/page.d.ts rename to nativescript-core/ui/page/index.d.ts index 983582826..0ede036e7 100644 --- a/nativescript-core/ui/page/page.d.ts +++ b/nativescript-core/ui/page/index.d.ts @@ -1,17 +1,11 @@ -/** - * Contains the Page class, which represents a logical unit for navigation inside a Frame. - * @module "ui/page" - */ /** */ - -/// - -import { ShownModallyData } from "../core/view"; -import { ContentView, EventData, Property, Color, CssProperty, Style } from "../content-view"; +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"; - -export * from "../content-view"; +import { Color } from "../../color"; /** * Defines the data for the page navigation events. diff --git a/nativescript-core/ui/page/page.ios.ts b/nativescript-core/ui/page/index.ios.ts similarity index 99% rename from nativescript-core/ui/page/page.ios.ts rename to nativescript-core/ui/page/index.ios.ts index e63742f2b..f98c00026 100644 --- a/nativescript-core/ui/page/page.ios.ts +++ b/nativescript-core/ui/page/index.ios.ts @@ -3,13 +3,13 @@ import { Frame, BackstackEntry } from "../frame"; import { NavigationType } from "../frame/frame-common"; // Types. -import { ios as iosView } from "../core/view"; +import { ios as iosView, View } from "../core/view"; import { - PageBase, View, layout, actionBarHiddenProperty, statusBarStyleProperty, Color + PageBase, actionBarHiddenProperty, statusBarStyleProperty } from "./page-common"; import { profile } from "../../profiling"; -import { ios as iosUtils } from "../../utils/utils"; +import { ios as iosUtils, layout } from "../../utils/utils"; export * from "./page-common"; diff --git a/nativescript-core/ui/page/package.json b/nativescript-core/ui/page/package.json deleted file mode 100644 index cb1fd7628..000000000 --- a/nativescript-core/ui/page/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "page", - "main": "page", - "types": "page.d.ts" -} diff --git a/nativescript-core/ui/placeholder/placeholder.android.ts b/nativescript-core/ui/placeholder/index.android.ts similarity index 68% rename from nativescript-core/ui/placeholder/placeholder.android.ts rename to nativescript-core/ui/placeholder/index.android.ts index 6967ff355..b5cc65882 100644 --- a/nativescript-core/ui/placeholder/placeholder.android.ts +++ b/nativescript-core/ui/placeholder/index.android.ts @@ -1,8 +1,11 @@ -import { Placeholder as PlaceholderDefinition, CreateViewEventData } from "."; -import { View, EventData, CSSType } from "../core/view"; +import { CreateViewEventData } from "./placeholder-common"; +import { View, CSSType } from "../core/view"; +import { EventData } from "../../data/observable"; + +export * from './placeholder-common'; @CSSType("Placeholder") -export class Placeholder extends View implements PlaceholderDefinition { +export class Placeholder extends View { public static creatingViewEvent = "creatingView"; public createNativeView() { diff --git a/nativescript-core/ui/placeholder/placeholder.d.ts b/nativescript-core/ui/placeholder/index.d.ts similarity index 87% rename from nativescript-core/ui/placeholder/placeholder.d.ts rename to nativescript-core/ui/placeholder/index.d.ts index 132d0335f..746ccb52e 100644 --- a/nativescript-core/ui/placeholder/placeholder.d.ts +++ b/nativescript-core/ui/placeholder/index.d.ts @@ -1,9 +1,7 @@ -/** - * Contains the Placeholder class, which is used to add a native view to the visual tree. - * @module "ui/placeholder" - */ /** */ +import { View } from "../core/view"; +import { EventData } from "../../data/observable"; -import { View, EventData } from "../core/view"; +export * from './placeholder-common'; /** * Represents a Placeholder, which is used to add a native view to the visual tree. diff --git a/nativescript-core/ui/placeholder/placeholder.ts b/nativescript-core/ui/placeholder/index.ts similarity index 67% rename from nativescript-core/ui/placeholder/placeholder.ts rename to nativescript-core/ui/placeholder/index.ts index b3d58cada..31132f90a 100644 --- a/nativescript-core/ui/placeholder/placeholder.ts +++ b/nativescript-core/ui/placeholder/index.ts @@ -1,7 +1,10 @@ -import { Placeholder as PlaceholderDefinition, CreateViewEventData } from "."; -import { View, EventData } from "../core/view"; +import { View } from "../core/view"; +import { CreateViewEventData } from "./placeholder-common"; +import { EventData } from "../../data/observable"; -export class Placeholder extends View implements PlaceholderDefinition { +export * from './placeholder-common'; + +export class Placeholder extends View { public static creatingViewEvent = "creatingView"; public createNativeView() { diff --git a/nativescript-core/ui/placeholder/package.json b/nativescript-core/ui/placeholder/package.json deleted file mode 100644 index c64db3297..000000000 --- a/nativescript-core/ui/placeholder/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "placeholder", - "main": "placeholder", - "types": "placeholder.d.ts" -} diff --git a/nativescript-core/ui/placeholder/placeholder-common.ts b/nativescript-core/ui/placeholder/placeholder-common.ts new file mode 100644 index 000000000..b64d4f4c7 --- /dev/null +++ b/nativescript-core/ui/placeholder/placeholder-common.ts @@ -0,0 +1,13 @@ +import { EventData } from "../../data/observable"; + +export interface CreateViewEventData extends EventData { + /** + * The native view that should be added to the visual tree. + */ + view: any; + + /** + * An optional context for creating the view. + */ + context?: any; +} \ No newline at end of file diff --git a/nativescript-core/ui/progress/progress.android.ts b/nativescript-core/ui/progress/index.android.ts similarity index 100% rename from nativescript-core/ui/progress/progress.android.ts rename to nativescript-core/ui/progress/index.android.ts diff --git a/nativescript-core/ui/progress/progress.d.ts b/nativescript-core/ui/progress/index.d.ts similarity index 86% rename from nativescript-core/ui/progress/progress.d.ts rename to nativescript-core/ui/progress/index.d.ts index f53c30bb8..118f8d4db 100644 --- a/nativescript-core/ui/progress/progress.d.ts +++ b/nativescript-core/ui/progress/index.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the Progress class, which represents a component capable of showing progress. - * @module "ui/progress" - */ /** */ - -import { View, Property } from "../core/view"; +import { View } from "../core/view"; +import { Property } from "../core/properties"; /** * Represents a progress component. diff --git a/nativescript-core/ui/progress/progress.ios.ts b/nativescript-core/ui/progress/index.ios.ts similarity index 100% rename from nativescript-core/ui/progress/progress.ios.ts rename to nativescript-core/ui/progress/index.ios.ts diff --git a/nativescript-core/ui/progress/package.json b/nativescript-core/ui/progress/package.json deleted file mode 100644 index e62dad2ec..000000000 --- a/nativescript-core/ui/progress/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "progress", - "main": "progress", - "types": "progress.d.ts" -} diff --git a/nativescript-core/ui/progress/progress-common.ts b/nativescript-core/ui/progress/progress-common.ts index 655b4ceb5..b5015fe09 100644 --- a/nativescript-core/ui/progress/progress-common.ts +++ b/nativescript-core/ui/progress/progress-common.ts @@ -1,7 +1,6 @@ import { Progress as ProgressDefinition } from "."; -import { View, Property, CoercibleProperty, CSSType } from "../core/view"; - -export * from "../core/view"; +import { View, CSSType } from "../core/view"; +import { Property, CoercibleProperty } from "../core/properties"; @CSSType("Progress") export class ProgressBase extends View implements ProgressDefinition { diff --git a/nativescript-core/ui/proxy-view-container/proxy-view-container.ts b/nativescript-core/ui/proxy-view-container/index.ts similarity index 84% rename from nativescript-core/ui/proxy-view-container/proxy-view-container.ts rename to nativescript-core/ui/proxy-view-container/index.ts index abc20df11..4c48d11ff 100644 --- a/nativescript-core/ui/proxy-view-container/proxy-view-container.ts +++ b/nativescript-core/ui/proxy-view-container/index.ts @@ -1,7 +1,8 @@ import { ProxyViewContainer as ProxyViewContainerDefinition } from "."; -import { LayoutBase, View, traceEnabled, traceWrite, traceCategories, CSSType } from "../layouts/layout-base"; +import { View, CSSType } from "../core/view"; +import { LayoutBase } from "../layouts/layout-base"; import { Property } from "../core/properties/properties"; -import { messageType } from "../../trace/trace"; +import { Trace } from "../../trace"; /** * Proxy view container that adds all its native children directly to the parent. @@ -65,8 +66,8 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer } public _addViewToNativeVisualTree(child: View, atIndex?: number): boolean { - if (traceEnabled()) { - traceWrite("ProxyViewContainer._addViewToNativeVisualTree for a child " + child + " ViewContainer.parent: " + this.parent, traceCategories.ViewHierarchy); + if (Trace.isEnabled()) { + Trace.write("ProxyViewContainer._addViewToNativeVisualTree for a child " + child + " ViewContainer.parent: " + this.parent, Trace.categories.ViewHierarchy); } super._addViewToNativeVisualTree(child); @@ -94,8 +95,8 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer // Add last; insideIndex = this._getNativeViewsCount(); } - if (traceEnabled()) { - traceWrite("ProxyViewContainer._addViewToNativeVisualTree at: " + atIndex + " base: " + baseIndex + " additional: " + insideIndex, traceCategories.ViewHierarchy); + if (Trace.isEnabled()) { + Trace.write("ProxyViewContainer._addViewToNativeVisualTree at: " + atIndex + " base: " + baseIndex + " additional: " + insideIndex, Trace.categories.ViewHierarchy); } return parent._addViewToNativeVisualTree(child, baseIndex + insideIndex); @@ -105,8 +106,8 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer } public _removeViewFromNativeVisualTree(child: View): void { - if (traceEnabled()) { - traceWrite("ProxyViewContainer._removeViewFromNativeVisualTree for a child " + child + " ViewContainer.parent: " + this.parent, traceCategories.ViewHierarchy); + if (Trace.isEnabled()) { + Trace.write("ProxyViewContainer._removeViewFromNativeVisualTree for a child " + child + " ViewContainer.parent: " + this.parent, Trace.categories.ViewHierarchy); } super._removeViewFromNativeVisualTree(child); @@ -167,7 +168,7 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer public _changedLayoutProperty(propName: string, value: string) { const numChildren = this._getNativeViewsCount(); if (numChildren > 1) { - traceWrite("ProxyViewContainer._changeLayoutProperty - you're setting '" + propName + "' for " + this + " with more than one child. Probably this is not what you want, consider wrapping it in a StackLayout ", traceCategories.ViewHierarchy, messageType.error); + Trace.write("ProxyViewContainer._changeLayoutProperty - you're setting '" + propName + "' for " + this + " with more than one child. Probably this is not what you want, consider wrapping it in a StackLayout ", Trace.categories.ViewHierarchy, Trace.messageType.error); } this.eachLayoutChild((child) => { @@ -187,8 +188,8 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer if (proxyPropName in child) { if (child[propName] !== child[proxyPropName]) { // Value was set directly on the child view, don't override. - if (traceEnabled()) { - traceWrite("ProxyViewContainer._applyLayoutPropertyToChild child " + child + " has its own value [" + child[propName] + "] for [" + propName + "]", traceCategories.ViewHierarchy); + if (Trace.isEnabled()) { + Trace.write("ProxyViewContainer._applyLayoutPropertyToChild child " + child + " has its own value [" + child[propName] + "] for [" + propName + "]", Trace.categories.ViewHierarchy); } return; diff --git a/nativescript-core/ui/proxy-view-container/package.json b/nativescript-core/ui/proxy-view-container/package.json deleted file mode 100644 index 9bace32c6..000000000 --- a/nativescript-core/ui/proxy-view-container/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "proxy-view-container", - "main": "proxy-view-container", - "types": "proxy-view-container.d.ts" -} diff --git a/nativescript-core/ui/proxy-view-container/proxy-view-container.d.ts b/nativescript-core/ui/proxy-view-container/proxy-view-container.d.ts deleted file mode 100644 index 92e618e12..000000000 --- a/nativescript-core/ui/proxy-view-container/proxy-view-container.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @module "ui/proxy-view-container" - */ /** */ - -import { LayoutBase } from "../layouts/layout-base"; - -export class ProxyViewContainer extends LayoutBase { -} diff --git a/nativescript-core/ui/repeater/repeater.ts b/nativescript-core/ui/repeater/index.ts similarity index 86% rename from nativescript-core/ui/repeater/repeater.ts rename to nativescript-core/ui/repeater/index.ts index 58c3db8df..f793e7c25 100644 --- a/nativescript-core/ui/repeater/repeater.ts +++ b/nativescript-core/ui/repeater/index.ts @@ -1,20 +1,28 @@ -import { Repeater as RepeaterDefinition, ItemsSource } from "."; import { Label } from "../label"; -import { LayoutBase, CustomLayoutView, View, Template, Property, layout, CSSType } from "../layouts/layout-base"; +import { LayoutBase } from "../layouts/layout-base"; +import {View, CSSType, CustomLayoutView, Template } from "../core/view"; +import {Property } from "../core/properties"; +import {layout } from "../../utils/utils"; import { StackLayout } from "../layouts/stack-layout"; import { ObservableArray, ChangedData } from "../../data/observable-array"; import { addWeakEventListener, removeWeakEventListener } from "../core/weak-event-listener"; import { Builder } from "../builder"; import { profile } from "../../profiling"; -export * from "../layouts/layout-base"; - export module knownTemplates { export const itemTemplate = "itemTemplate"; } +export interface ItemsSource { + length: number; + getItem(index: number): any; +} + +/** + * Represents a UI Repeater component. + */ @CSSType("Repeater") -export class Repeater extends CustomLayoutView implements RepeaterDefinition { +export class Repeater extends CustomLayoutView { private _isDirty = false; public ios; public android; @@ -25,8 +33,18 @@ export class Repeater extends CustomLayoutView implements RepeaterDefinition { this.itemsLayout = new StackLayout(); } + /** + * Gets or set the items collection of the Repeater. + * The items property can be set to an array or an object defining length and getItem(index) method. + */ public items: any[] | ItemsSource; + /** + * Gets or set the item template of the Repeater. + */ public itemTemplate: string | Template; + /** + * Gets or set the items layout of the Repeater. Default value is StackLayout with orientation="vertical". + */ public itemsLayout: LayoutBase; @profile @@ -45,6 +63,9 @@ export class Repeater extends CustomLayoutView implements RepeaterDefinition { } } + /** + * Forces the Repeater to reload all its items. + */ public refresh() { if (this.itemsLayout) { this.itemsLayout.removeChildren(); diff --git a/nativescript-core/ui/repeater/package.json b/nativescript-core/ui/repeater/package.json deleted file mode 100644 index c6697b465..000000000 --- a/nativescript-core/ui/repeater/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "repeater", - "main": "repeater", - "types": "repeater.d.ts" -} diff --git a/nativescript-core/ui/repeater/repeater.d.ts b/nativescript-core/ui/repeater/repeater.d.ts deleted file mode 100644 index 0a7fdf8ee..000000000 --- a/nativescript-core/ui/repeater/repeater.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Contains the Repeater class, which represents a UI Repeater component. - * @module "ui/repeater" - */ /** */ - -import { LayoutBase, CustomLayoutView, Template, Property } from "../layouts/layout-base"; - -/** - * Represents a UI Repeater component. - */ -export class Repeater extends CustomLayoutView { - /** - * Gets or set the items collection of the Repeater. - * The items property can be set to an array or an object defining length and getItem(index) method. - */ - items: any[] | ItemsSource; - - /** - * Gets or set the item template of the Repeater. - */ - itemTemplate: string | Template; - - /** - * Gets or set the items layout of the Repeater. Default value is StackLayout with orientation="vertical". - */ - itemsLayout: LayoutBase; - - /** - * Forces the Repeater to reload all its items. - */ - refresh(); -} - -export interface ItemsSource { - length: number; - getItem(index: number): any; -} - -/** - * Represents the property backing the items property. - */ -export const itemsProperty: Property; - -/** - * Represents the item template property. - */ -export const itemTemplateProperty: Property; - -/** - * Represents the items layout property of each Repeater instance. - */ -export const itemsLayoutProperty: Property; diff --git a/nativescript-core/ui/scroll-view/scroll-view.android.ts b/nativescript-core/ui/scroll-view/index.android.ts similarity index 100% rename from nativescript-core/ui/scroll-view/scroll-view.android.ts rename to nativescript-core/ui/scroll-view/index.android.ts diff --git a/nativescript-core/ui/scroll-view/scroll-view.d.ts b/nativescript-core/ui/scroll-view/index.d.ts similarity index 91% rename from nativescript-core/ui/scroll-view/scroll-view.d.ts rename to nativescript-core/ui/scroll-view/index.d.ts index 10628a202..69e265c6e 100644 --- a/nativescript-core/ui/scroll-view/scroll-view.d.ts +++ b/nativescript-core/ui/scroll-view/index.d.ts @@ -1,9 +1,6 @@ -/** - * Contains the ScrollView class, which represents a scrollable area that can have content that is larger than its bounds. - * @module "ui/scroll-view" - */ /** */ - -import { ContentView, EventData, Property } from "../content-view"; +import { ContentView } from "../content-view"; +import { Property } from "../core/properties"; +import { EventData } from "../../data/observable"; /** * Represents a scrollable area that can have content that is larger than its bounds. diff --git a/nativescript-core/ui/scroll-view/scroll-view.ios.ts b/nativescript-core/ui/scroll-view/index.ios.ts similarity index 97% rename from nativescript-core/ui/scroll-view/scroll-view.ios.ts rename to nativescript-core/ui/scroll-view/index.ios.ts index 0f42f7354..7f2c55b30 100644 --- a/nativescript-core/ui/scroll-view/scroll-view.ios.ts +++ b/nativescript-core/ui/scroll-view/index.ios.ts @@ -1,8 +1,9 @@ import { ScrollEventData } from "."; import { - View, layout, ScrollViewBase, scrollBarIndicatorVisibleProperty, isScrollEnabledProperty + ScrollViewBase, scrollBarIndicatorVisibleProperty, isScrollEnabledProperty } from "./scroll-view-common"; -import { ios as iosUtils } from "../../utils/utils"; +import { ios as iosUtils, layout } from "../../utils/utils"; +import { View } from "../core/view"; export * from "./scroll-view-common"; diff --git a/nativescript-core/ui/scroll-view/package.json b/nativescript-core/ui/scroll-view/package.json deleted file mode 100644 index 2022df245..000000000 --- a/nativescript-core/ui/scroll-view/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "scroll-view", - "main": "scroll-view", - "types": "scroll-view.d.ts" -} diff --git a/nativescript-core/ui/search-bar/search-bar-common.ts b/nativescript-core/ui/search-bar/search-bar-common.ts index fb29e0f42..08611e12d 100644 --- a/nativescript-core/ui/search-bar/search-bar-common.ts +++ b/nativescript-core/ui/search-bar/search-bar-common.ts @@ -1,7 +1,8 @@ import { SearchBar as SearchBarDefinition } from "."; -import { View, Property, Color, isIOS, CSSType } from "../core/view"; - -export * from "../core/view"; +import { View, CSSType } from "../core/view"; +import { Property } from "../core/properties"; +import { Color } from "../../color"; +import { isIOS } from "../../platform"; @CSSType("SearchBar") export abstract class SearchBarBase extends View implements SearchBarDefinition { diff --git a/nativescript-core/ui/search-bar/search-bar.android.ts b/nativescript-core/ui/search-bar/search-bar.android.ts index 8da94d515..fc397067a 100644 --- a/nativescript-core/ui/search-bar/search-bar.android.ts +++ b/nativescript-core/ui/search-bar/search-bar.android.ts @@ -1,10 +1,12 @@ import { Font } from "../styling/font"; import { - SearchBarBase, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, fontInternalProperty, - textProperty, hintProperty, textFieldHintColorProperty, textFieldBackgroundColorProperty, fontSizeProperty, - isEnabledProperty, isUserInteractionEnabledProperty + SearchBarBase, + textProperty, hintProperty, textFieldHintColorProperty, textFieldBackgroundColorProperty, } from "./search-bar-common"; +import { isUserInteractionEnabledProperty, isEnabledProperty } from "../core/view"; import { ad } from "../../utils/utils"; +import { Color } from "../../color"; +import { colorProperty, backgroundColorProperty, backgroundInternalProperty, fontInternalProperty, fontSizeProperty } from "../styling/style-properties"; export * from "./search-bar-common"; diff --git a/nativescript-core/ui/search-bar/search-bar.d.ts b/nativescript-core/ui/search-bar/search-bar.d.ts index 786a4834d..3895e1b9d 100644 --- a/nativescript-core/ui/search-bar/search-bar.d.ts +++ b/nativescript-core/ui/search-bar/search-bar.d.ts @@ -1,9 +1,7 @@ -/** - * Contains the SearchBar class, which represents a standard search bar component. - * @module "ui/search-bar" - */ /** */ - -import { View, Property, EventData, Color } from "../core/view"; +import { View } from "../core/view"; +import { Property } from "../core/properties"; +import { EventData } from "../../data/observable"; +import { Color } from "../../color"; /** * Represents a search bar component. diff --git a/nativescript-core/ui/segmented-bar/segmented-bar-common.ts b/nativescript-core/ui/segmented-bar/segmented-bar-common.ts index bbebee005..3b3d4b72f 100644 --- a/nativescript-core/ui/segmented-bar/segmented-bar-common.ts +++ b/nativescript-core/ui/segmented-bar/segmented-bar-common.ts @@ -1,10 +1,22 @@ import { SegmentedBar as SegmentedBarDefinition, SegmentedBarItem as SegmentedBarItemDefinition, SelectedIndexChangedEventData } from "."; import { - ViewBase, View, AddChildFromBuilder, AddArrayFromBuilder, - Property, CoercibleProperty, InheritedCssProperty, Color, Style, EventData, CSSType + View, AddChildFromBuilder, AddArrayFromBuilder, CSSType } from "../core/view"; - -export * from "../core/view"; +import { + ViewBase +} from "../core/view-base"; +import { + Property, CoercibleProperty, InheritedCssProperty +} from "../core/properties"; +import { + Color +} from "../../color"; +import { + Style +} from "../styling/style"; +import { + EventData +} from "../../data/observable"; export module knownCollections { export const items = "items"; diff --git a/nativescript-core/ui/segmented-bar/segmented-bar.d.ts b/nativescript-core/ui/segmented-bar/segmented-bar.d.ts index 9bad6c892..6824ee180 100644 --- a/nativescript-core/ui/segmented-bar/segmented-bar.d.ts +++ b/nativescript-core/ui/segmented-bar/segmented-bar.d.ts @@ -1,83 +1,84 @@ -/** - * @module "ui/segmented-bar" - * - * Contains the SegmentedBar class, which represents a SegmentedBar component. - */ /** */ - -import { - ViewBase, View, AddChildFromBuilder, AddArrayFromBuilder, - Property, CoercibleProperty, EventData, Color, CssProperty, Style -} from "../core/view"; +import { View, AddChildFromBuilder, AddArrayFromBuilder } from "../core/view"; +import { ViewBase } from "../core/view-base"; +import { Property, CoercibleProperty, CssProperty } from "../core/properties"; +import { EventData } from "../../data/observable"; +import { Color } from "../../color"; +import { Style } from "../styling/style"; /** * Represents a SegmentedBar item. */ export class SegmentedBarItem extends ViewBase { - /** - * Gets or sets the title of the SegmentedBarItem. - */ - public title: string; + /** + * Gets or sets the title of the SegmentedBarItem. + */ + public title: string; } /** * Defines the data for the SegmentedBar.selectedIndexChanged event. */ export interface SelectedIndexChangedEventData extends EventData { - /** - * The old selected index. - */ - oldIndex: number; + /** + * The old selected index. + */ + oldIndex: number; - /** - * The new selected index. - */ - newIndex: number; + /** + * The new selected index. + */ + newIndex: number; } /** * Represents a UI SegmentedBar component. */ -export class SegmentedBar extends View implements AddChildFromBuilder, AddArrayFromBuilder { - /** - * Gets or sets the selected index of the SegmentedBar component. - */ - selectedIndex: number; +export class SegmentedBar extends View + implements AddChildFromBuilder, AddArrayFromBuilder { + /** + * Gets or sets the selected index of the SegmentedBar component. + */ + selectedIndex: number; - /** - * Gets or sets the selected background color of the SegmentedBar component. - */ - selectedBackgroundColor: Color; + /** + * Gets or sets the selected background color of the SegmentedBar component. + */ + selectedBackgroundColor: Color; - /** - * Gets or sets the items of the SegmentedBar. - */ - items: Array; + /** + * Gets or sets the items of the SegmentedBar. + */ + items: Array; - /** - * String value used when hooking to the selectedIndexChanged event. - */ - public static selectedIndexChangedEvent: string; + /** + * String value used when hooking to the selectedIndexChanged event. + */ + public static selectedIndexChangedEvent: string; - /** - * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). - * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). - * @param callback - Callback function which will be executed when event is raised. - * @param thisArg - An optional parameter which will be used as `this` context for callback execution. - */ - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); + /** + * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). + * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change"). + * @param callback - Callback function which will be executed when event is raised. + * @param thisArg - An optional parameter which will be used as `this` context for callback execution. + */ + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - /** - * Raised when the selected index changes. - */ - on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); + /** + * Raised when the selected index changes. + */ + on( + event: "selectedIndexChanged", + callback: (args: SelectedIndexChangedEventData) => void, + thisArg?: any + ); - /** - * Called for every child element declared in xml. - * @param name - Name of the element. - * @param value - Value of the element. - */ - public _addChildFromBuilder(name: string, value: any): void; - public _addArrayFromBuilder(name: string, value: Array): void; + /** + * Called for every child element declared in xml. + * @param name - Name of the element. + * @param value - Value of the element. + */ + public _addChildFromBuilder(name: string, value: any): void; + public _addArrayFromBuilder(name: string, value: Array): void; } /** diff --git a/nativescript-core/ui/slider/slider-common.ts b/nativescript-core/ui/slider/slider-common.ts index dee24dd0b..8281d510a 100644 --- a/nativescript-core/ui/slider/slider-common.ts +++ b/nativescript-core/ui/slider/slider-common.ts @@ -1,7 +1,7 @@ import { Slider as SliderDefinition } from "."; -import { View, Property, CoercibleProperty, isIOS, CSSType } from "../core/view"; - -export * from "../core/view"; +import { View, CSSType } from "../core/view"; +import { isIOS } from "../../platform"; +import { Property, CoercibleProperty } from "../core/properties"; // TODO: Extract base Range class for slider and progress @CSSType("Slider") diff --git a/nativescript-core/ui/slider/slider.d.ts b/nativescript-core/ui/slider/slider.d.ts index f6a3298b0..f74b9961f 100644 --- a/nativescript-core/ui/slider/slider.d.ts +++ b/nativescript-core/ui/slider/slider.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the Slider class, which represents a standard slider component. - * @module "ui/slider" - */ /** */ - -import { View, Property, CoercibleProperty } from "../core/view"; +import { View } from "../core/view"; +import { Property, CoercibleProperty } from "../core/properties"; /** * Represents a slider component. diff --git a/nativescript-core/ui/styling/background.d.ts b/nativescript-core/ui/styling/background.d.ts index a41e75ff7..c1be1c358 100644 --- a/nativescript-core/ui/styling/background.d.ts +++ b/nativescript-core/ui/styling/background.d.ts @@ -1,9 +1,7 @@ -/** - * @module "ui/styling/background" - */ /** */ - import { Color } from "../../color"; -import { View, BackgroundRepeat, LinearGradient } from "../core/view"; +import { View } from "../core/view"; +import { BackgroundRepeat } from "../../css/parser"; +import { LinearGradient } from "../styling/linear-gradient"; export class Background { public static default: Background; diff --git a/nativescript-core/ui/styling/converters.d.ts b/nativescript-core/ui/styling/converters.d.ts index 3e5ee3e02..f2efc36d5 100644 --- a/nativescript-core/ui/styling/converters.d.ts +++ b/nativescript-core/ui/styling/converters.d.ts @@ -1,8 +1,2 @@ -/** - * @module "ui/styling/converters" - */ /** */ - -import { AnimationCurve } from "../enums/enums"; - export function timeConverter(value: string): number; export function animationTimingFunctionConverter(value: string): any; diff --git a/nativescript-core/ui/styling/css-animation-parser.d.ts b/nativescript-core/ui/styling/css-animation-parser.d.ts index 48985d05d..92ecfe281 100644 --- a/nativescript-core/ui/styling/css-animation-parser.d.ts +++ b/nativescript-core/ui/styling/css-animation-parser.d.ts @@ -1,16 +1,9 @@ -/** - * @module "ui/styling/css-animations-parser" - */ /** */ - import { KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo, UnparsedKeyframe, } from "../animation/keyframe-animation"; -import { timeConverter, animationTimingFunctionConverter } from "./converters"; - -import { transformConverter } from "./style-properties"; export class CssAnimationParser { public static keyframeAnimationsFromCSSDeclarations(declarations: KeyframeDeclaration[]): KeyframeAnimationInfo[]; diff --git a/nativescript-core/ui/styling/css-selector/css-selector.d.ts b/nativescript-core/ui/styling/css-selector/css-selector.d.ts deleted file mode 100644 index 3ebba8e2b..000000000 --- a/nativescript-core/ui/styling/css-selector/css-selector.d.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @module "ui/styling/css-selector" - */ /** */ - -import { Node as ParserNode } from "../../../css"; - -/** - * An interface describing the shape of a type on which the selectors may apply. - * Note, the ui/core/view.View implements Node. - */ -export interface Node { - parent?: Node; - - id?: string; - nodeName?: string; - cssType?: string; - cssClasses?: Set; - cssPseudoClasses?: Set; - getChildIndex?(node: Node): number; - getChildAt?(index: number): Node; -} - -export interface Declaration { - property: string; - value: string; -} - -export interface SelectorCore { - /** - * Dynamic selectors depend on attributes and pseudo classes. - */ - dynamic: boolean; - match(node: Node): boolean; - ruleset: RuleSet; -} - -export class RuleSet { - /** - * Gets the selectors in this ruleset's selector group. - */ - selectors: SelectorCore[]; - - /** - * Gets the key-value list of declarations for the ruleset. - */ - declarations: Declaration[]; - - /** - * Optional Tag for rules - **/ - tag: string | Number; -} - -export class SelectorsMap { - constructor(rules: RuleSet[]); - - /** - * Get a list of selectors that are likely to match the node. - */ - query(node: T): SelectorsMatch; -} - -export type ChangeMap = Map; - -export interface Changes { - attributes?: Set; - pseudoClasses?: Set; -} - -export class SelectorsMatch { - /** - * Gets the static selectors that match the queried node and the dynamic selectors that may potentially match the queried node. - */ - selectors: SelectorCore[]; - - /** - * Gets a map of nodes to attributes and pseudo classes, that may affect the state of the dynamic - */ - changeMap: ChangeMap; -} - -export function fromAstNodes(astRules: ParserNode[]): RuleSet[]; - -export function createSelector(sel: string): SelectorCore; diff --git a/nativescript-core/ui/styling/css-selector/css-selector.ts b/nativescript-core/ui/styling/css-selector/index.ts similarity index 96% rename from nativescript-core/ui/styling/css-selector/css-selector.ts rename to nativescript-core/ui/styling/css-selector/index.ts index bac516bf2..5ea2dca58 100644 --- a/nativescript-core/ui/styling/css-selector/css-selector.ts +++ b/nativescript-core/ui/styling/css-selector/index.ts @@ -1,9 +1,36 @@ -import { Node, Declaration, Changes, ChangeMap } from "."; import { isNullOrUndefined } from "../../../utils/types"; import * as cssParser from "../../../css"; import * as parser from "../../../css/parser"; +/** + * An interface describing the shape of a type on which the selectors may apply. + * Note, the ui/core/view.View implements Node. + */ +export interface Node { + parent?: Node; + + id?: string; + nodeName?: string; + cssType?: string; + cssClasses?: Set; + cssPseudoClasses?: Set; + getChildIndex?(node: Node): number; + getChildAt?(index: number): Node; +} + +export interface Declaration { + property: string; + value: string; +} + +export type ChangeMap = Map; + +export interface Changes { + attributes?: Set; + pseudoClasses?: Set; +} + const enum Specificity { Inline = 1000, Id = 100, @@ -75,6 +102,9 @@ export abstract class SelectorCore { public rarity: Rarity; public combinator: Combinator; public ruleset: RuleSet; + /** + * Dynamic selectors depend on attributes and pseudo classes. + */ public dynamic: boolean; public abstract match(node: Node): boolean; /** @@ -405,7 +435,8 @@ export namespace Selector { } export class RuleSet { - constructor(public selectors: SelectorCore[], private declarations: Declaration[]) { + tag: string | Number; + constructor(public selectors: SelectorCore[], public declarations: Declaration[]) { this.selectors.forEach(sel => sel.ruleset = this); } public toString(): string { return `${this.selectors.join(", ")} {${this.declarations.map((d, i) => `${i === 0 ? " " : ""}${d.property}: ${d.value}`).join("; ")} }`; } @@ -589,7 +620,7 @@ export class SelectorsMatch implements ChangeAccumulator { deps.pseudoClasses.add(pseudoClass); } - private properties(node: T): Changes { + public properties(node: T): Changes { let set = this.changeMap.get(node); if (!set) { this.changeMap.set(node, set = {}); diff --git a/nativescript-core/ui/styling/css-selector/package.json b/nativescript-core/ui/styling/css-selector/package.json deleted file mode 100644 index 281ba67d1..000000000 --- a/nativescript-core/ui/styling/css-selector/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "css-selector", - "main": "css-selector", - "types": "css-selector.d.ts" -} diff --git a/nativescript-core/ui/styling/font.android.ts b/nativescript-core/ui/styling/font.android.ts index f330173f7..ac34a4fde 100644 --- a/nativescript-core/ui/styling/font.android.ts +++ b/nativescript-core/ui/styling/font.android.ts @@ -1,5 +1,5 @@ import { Font as FontBase, parseFontFamily, genericFontFamilies, FontWeight } from "./font-common"; -import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories, messageType as traceMessageType } from "../../trace"; +import { Trace } from "../../trace"; import * as application from "../../application"; import * as fs from "../../file-system"; @@ -67,8 +67,8 @@ function loadFontFromFile(fontFamily: string): android.graphics.Typeface { fontAssetPath = FONTS_BASE_PATH + fontFamily + ".otf"; } else { - if (traceEnabled()) { - traceWrite("Could not find font file for " + fontFamily, traceCategories.Error, traceMessageType.error); + if (Trace.isEnabled()) { + Trace.write("Could not find font file for " + fontFamily, Trace.categories.Error, Trace.messageType.error); } } @@ -77,8 +77,8 @@ function loadFontFromFile(fontFamily: string): android.graphics.Typeface { fontAssetPath = fs.path.join(fs.knownFolders.currentApp().path, fontAssetPath); result = android.graphics.Typeface.createFromFile(fontAssetPath); } catch (e) { - if (traceEnabled()) { - traceWrite("Error loading font asset: " + fontAssetPath, traceCategories.Error, traceMessageType.error); + if (Trace.isEnabled()) { + Trace.write("Error loading font asset: " + fontAssetPath, Trace.categories.Error, Trace.messageType.error); } } } diff --git a/nativescript-core/ui/styling/font.d.ts b/nativescript-core/ui/styling/font.d.ts index 25753d884..5fca917d1 100644 --- a/nativescript-core/ui/styling/font.d.ts +++ b/nativescript-core/ui/styling/font.d.ts @@ -1,8 +1,4 @@ -/** - * @module "ui/styling/font" - */ /** */ - -export class Font { +export class Font { public static default: Font; public fontFamily: string; diff --git a/nativescript-core/ui/styling/font.ios.ts b/nativescript-core/ui/styling/font.ios.ts index 6e79e2abc..1bcc3079f 100644 --- a/nativescript-core/ui/styling/font.ios.ts +++ b/nativescript-core/ui/styling/font.ios.ts @@ -1,5 +1,5 @@ import { Font as FontBase, parseFontFamily, genericFontFamilies, FontStyle, FontWeight } from "./font-common"; -import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories, messageType as traceMessageType } from "../../trace"; +import { Trace } from "../../trace"; import { device } from "../../platform"; import * as fs from "../../file-system"; export * from "./font-common"; @@ -193,8 +193,8 @@ export module ios { const error = new interop.Reference(); if (!CTFontManagerRegisterGraphicsFont(font, error)) { - if (traceEnabled()) { - traceWrite("Error occur while registering font: " + CFErrorCopyDescription(error.value), traceCategories.Error, traceMessageType.error); + if (Trace.isEnabled()) { + Trace.write("Error occur while registering font: " + CFErrorCopyDescription(error.value), Trace.categories.Error, Trace.messageType.error); } } } diff --git a/nativescript-core/ui/styling/gradient.d.ts b/nativescript-core/ui/styling/gradient.d.ts index 58c081d53..5bd96df94 100644 --- a/nativescript-core/ui/styling/gradient.d.ts +++ b/nativescript-core/ui/styling/gradient.d.ts @@ -1,7 +1,3 @@ -/** - * @module "ui/styling/gradient" - */ /** */ - import { LengthPercentUnit } from "./style-properties"; import { Color } from "../../color"; import { LinearGradient as LinearGradientDefinition } from "../../css/parser"; diff --git a/nativescript-core/ui/styling/style-properties.d.ts b/nativescript-core/ui/styling/style-properties.d.ts index e0b907ace..714c45f9f 100644 --- a/nativescript-core/ui/styling/style-properties.d.ts +++ b/nativescript-core/ui/styling/style-properties.d.ts @@ -1,10 +1,7 @@ -/** - * @module "ui/styling/style-properties" - */ /** */ - import { TransformFunctionsInfo } from "../animation/animation"; import { Color } from "../../color"; -import { Style, CssProperty, CssAnimationProperty, ShorthandProperty, InheritedCssProperty } from "../core/properties"; +import { CssProperty, CssAnimationProperty, ShorthandProperty, InheritedCssProperty } from "../core/properties"; +import { Style } from "../styling/style"; import { Font, FontStyle, FontWeight } from "./font"; import { Background } from "./background"; import { dip, px, percent } from "../core/view"; diff --git a/nativescript-core/ui/styling/style-properties.ts b/nativescript-core/ui/styling/style-properties.ts index d2b5c3e33..af972a6e9 100644 --- a/nativescript-core/ui/styling/style-properties.ts +++ b/nativescript-core/ui/styling/style-properties.ts @@ -1,10 +1,13 @@ // Types import { - unsetValue, Style, + unsetValue, CssProperty, CssAnimationProperty, ShorthandProperty, InheritedCssProperty, makeValidator, makeParser } from "../core/properties"; +import { + Style +} from "../styling/style"; import { Transformation, TransformationValue, @@ -28,9 +31,7 @@ import { multiplyAffine2d, } from "../../matrix"; import { - write as traceWrite, - categories as traceCategories, - messageType as traceMessageType, + Trace } from "../../trace"; import * as parser from "../../css/parser"; @@ -201,7 +202,7 @@ export const minWidthProperty = new CssProperty({ if (view) { view.effectiveMinWidth = Length.toDevicePixels(newValue, 0); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } }, valueConverter: Length.parse }); @@ -214,7 +215,7 @@ export const minHeightProperty = new CssProperty({ if (view) { view.effectiveMinHeight = Length.toDevicePixels(newValue, 0); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } }, valueConverter: Length.parse }); @@ -300,7 +301,7 @@ export const paddingLeftProperty = new CssProperty({ if (view) { view.effectivePaddingLeft = Length.toDevicePixels(newValue, 0); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } }, valueConverter: Length.parse }); @@ -313,7 +314,7 @@ export const paddingRightProperty = new CssProperty({ if (view) { view.effectivePaddingRight = Length.toDevicePixels(newValue, 0); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } }, valueConverter: Length.parse }); @@ -326,7 +327,7 @@ export const paddingTopProperty = new CssProperty({ if (view) { view.effectivePaddingTop = Length.toDevicePixels(newValue, 0); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } }, valueConverter: Length.parse }); @@ -339,7 +340,7 @@ export const paddingBottomProperty = new CssProperty({ if (view) { view.effectivePaddingBottom = Length.toDevicePixels(newValue, 0); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } }, valueConverter: Length.parse }); @@ -955,7 +956,7 @@ export const borderTopWidthProperty = new CssProperty({ if (view) { view.effectiveBorderTopWidth = value; } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } const background = target.backgroundInternal.withBorderTopWidth(value); target.backgroundInternal = background; @@ -975,7 +976,7 @@ export const borderRightWidthProperty = new CssProperty({ if (view) { view.effectiveBorderRightWidth = value; } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } const background = target.backgroundInternal.withBorderRightWidth(value); target.backgroundInternal = background; @@ -995,7 +996,7 @@ export const borderBottomWidthProperty = new CssProperty({ if (view) { view.effectiveBorderBottomWidth = value; } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } const background = target.backgroundInternal.withBorderBottomWidth(value); target.backgroundInternal = background; @@ -1015,7 +1016,7 @@ export const borderLeftWidthProperty = new CssProperty({ if (view) { view.effectiveBorderLeftWidth = value; } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } const background = target.backgroundInternal.withBorderLeftWidth(value); target.backgroundInternal = background; @@ -1254,7 +1255,7 @@ export const visibilityProperty = new CssProperty({ if (view) { view.isCollapsed = (newValue === Visibility.COLLAPSE); } else { - traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } } }); diff --git a/nativescript-core/ui/styling/style-scope.d.ts b/nativescript-core/ui/styling/style-scope.d.ts index b43e2b316..4e4513237 100644 --- a/nativescript-core/ui/styling/style-scope.d.ts +++ b/nativescript-core/ui/styling/style-scope.d.ts @@ -1,9 +1,4 @@ -/** - * @module "ui/styling/style-scope" - * @private - */ /** */ - -//@private +//@private import { ViewBase } from "../core/view-base"; import { SyntaxTree } from "../../css"; import { RuleSet, Node, SelectorCore, ChangeMap } from "../styling/css-selector"; diff --git a/nativescript-core/ui/styling/style-scope.ts b/nativescript-core/ui/styling/style-scope.ts index 0f4addb6b..be1bcb684 100644 --- a/nativescript-core/ui/styling/style-scope.ts +++ b/nativescript-core/ui/styling/style-scope.ts @@ -26,9 +26,7 @@ import { Node, } from "./css-selector"; import { - write as traceWrite, - categories as traceCategories, - messageType as traceMessageType, + Trace } from "../../trace"; import { File, knownFolders, path } from "../../file-system"; import * as application from "../../application"; @@ -81,7 +79,7 @@ function evaluateCssExpressions(view: ViewBase, property: string, value: string) try { value = _evaluateCssCalcExpression(value); } catch (e) { - traceWrite(`Failed to evaluate css-calc for property [${property}] for expression [${value}] to ${view}. ${e.stack}`, traceCategories.Error, traceMessageType.error); + Trace.write(`Failed to evaluate css-calc for property [${property}] for expression [${value}] to ${view}. ${e.stack}`, Trace.categories.Error, Trace.messageType.error); return unsetValue; } @@ -135,7 +133,7 @@ class CSSSource { return CSSSource.fromDetect(cssOrAst, keyframes, resolvedModuleName); } } catch (e) { - traceWrite(`Could not load CSS from ${uri}: ${e}`, traceCategories.Error, traceMessageType.error); + Trace.write(`Could not load CSS from ${uri}: ${e}`, Trace.categories.Error, Trace.messageType.error); } return CSSSource.fromFile(appRelativeUri, keyframes); @@ -148,7 +146,7 @@ class CSSSource { const appPath = knownFolders.currentApp().path; if (!uri.startsWith(appPath)) { - traceWrite(`${uri} does not start with ${appPath}`, traceCategories.Error, traceMessageType.error); + Trace.write(`${uri} does not start with ${appPath}`, Trace.categories.Error, Trace.messageType.error); return uri; } @@ -222,7 +220,7 @@ class CSSSource { this._selectors = []; } } catch (e) { - traceWrite("Css styling failed: " + e, traceCategories.Error, traceMessageType.error); + Trace.write("Css styling failed: " + e, Trace.categories.Error, Trace.messageType.error); this._selectors = []; } } @@ -401,7 +399,7 @@ export class CssState { static emptyChangeMap: Readonly> = Object.freeze(new Map()); static emptyPropertyBag: Readonly<{}> = Object.freeze({}); static emptyAnimationArray: ReadonlyArray = Object.freeze([]); - static emptyMatch: Readonly> = { selectors: [], changeMap: new Map() }; + static emptyMatch: Readonly> = { selectors: [], changeMap: new Map(), addAttribute: () => {}, addPseudoClass: () => {}, properties: null}; _onDynamicStateChangeHandler: () => void; _appliedChangeMap: Readonly>; @@ -436,7 +434,7 @@ export class CssState { public isSelectorsLatestVersionApplied(): boolean { const view = this.viewRef.get(); if (!view) { - traceWrite(`isSelectorsLatestVersionApplied returns default value "false" because "this.viewRef" cleared.`, traceCategories.Style, traceMessageType.warn); + Trace.write(`isSelectorsLatestVersionApplied returns default value "false" because "this.viewRef" cleared.`, Trace.categories.Style, Trace.messageType.warn); return false; } @@ -473,7 +471,7 @@ export class CssState { private updateDynamicState(): void { const view = this.viewRef.get(); if (!view) { - traceWrite(`updateDynamicState not executed to view because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`updateDynamicState not executed to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); return; } @@ -505,7 +503,7 @@ export class CssState { if (this._playsKeyframeAnimations = animations.length > 0) { const view = this.viewRef.get(); if (!view) { - traceWrite(`KeyframeAnimations cannot play because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn); + Trace.write(`KeyframeAnimations cannot play because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); return; } @@ -538,7 +536,7 @@ export class CssState { view.style["keyframe:backgroundColor"] = unsetValue; view.style["keyframe:opacity"] = unsetValue; } else { - traceWrite(`KeyframeAnimations cannot be stopped because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn); + Trace.write(`KeyframeAnimations cannot be stopped because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); } this._playsKeyframeAnimations = false; @@ -553,7 +551,7 @@ export class CssState { private setPropertyValues(matchingSelectors: SelectorCore[]): void { const view = this.viewRef.get(); if (!view) { - traceWrite(`${matchingSelectors} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn); + Trace.write(`${matchingSelectors} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); return; } @@ -625,7 +623,7 @@ export class CssState { view[camelCasedProperty] = value; } } catch (e) { - traceWrite(`Failed to apply property [${property}] with value [${value}] to ${view}. ${e.stack}`, traceCategories.Error, traceMessageType.error); + Trace.write(`Failed to apply property [${property}] with value [${value}] to ${view}. ${e.stack}`, Trace.categories.Error, Trace.messageType.error); } } @@ -676,7 +674,7 @@ export class CssState { toString(): string { const view = this.viewRef.get(); if (!view) { - traceWrite(`toString() of CssState cannot execute correctly because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn); + Trace.write(`toString() of CssState cannot execute correctly because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); return ""; } @@ -691,7 +689,7 @@ CssState.prototype._matchInvalid = true; export class StyleScope { - private _selectors: SelectorsMap; + private _selectors: SelectorsMap; private _css: string = ""; private _mergedCssSelectors: RuleSet[]; private _localCssSelectors: RuleSet[] = []; @@ -932,7 +930,7 @@ export const applyInlineStyle = profile(function applyInlineStyle(view: ViewBase view[property] = value; } } catch (e) { - traceWrite(`Failed to apply property [${d.property}] with value [${d.value}] to ${view}. ${e}`, traceCategories.Error, traceMessageType.error); + Trace.write(`Failed to apply property [${d.property}] with value [${d.value}] to ${view}. ${e}`, Trace.categories.Error, Trace.messageType.error); } }); diff --git a/nativescript-core/ui/styling/style/style.ts b/nativescript-core/ui/styling/style/index.ts similarity index 93% rename from nativescript-core/ui/styling/style/style.ts rename to nativescript-core/ui/styling/style/index.ts index 751ba2f2b..554ede7c9 100644 --- a/nativescript-core/ui/styling/style/style.ts +++ b/nativescript-core/ui/styling/style/index.ts @@ -3,9 +3,18 @@ import { Color } from "../../../color"; import { Font, FontStyle, FontWeight } from "../font"; import { Background } from "../background"; import { - Length, PercentLength, ViewBase, BackgroundRepeat, Visibility, - HorizontalAlignment, VerticalAlignment, dip, LinearGradient + dip } from "../../core/view"; +import { + ViewBase +} from "../../core/view-base"; +import { + Length, PercentLength, + HorizontalAlignment, VerticalAlignment, BackgroundRepeat, Visibility +} from "../../styling/style-properties"; +import { + LinearGradient +} from "../../styling/linear-gradient"; import { Observable } from "../../../data/observable"; import { @@ -13,9 +22,7 @@ import { Order, FlexGrow, FlexShrink, FlexWrapBefore, AlignSelf } from "../../layouts/flexbox-layout"; import { - write as traceWrite, - categories as traceCategories, - messageType as traceMessageType, + Trace } from "../../../trace"; import { TextAlignment, TextDecoration, TextTransform, WhiteSpace } from "../../text-base"; @@ -74,7 +81,7 @@ export class Style extends Observable implements StyleDefinition { toString() { const view = this.viewRef.get(); if (!view) { - traceWrite(`toString() of Style cannot execute correctly because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn); + Trace.write(`toString() of Style cannot execute correctly because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); return ""; } diff --git a/nativescript-core/ui/styling/style/package.json b/nativescript-core/ui/styling/style/package.json deleted file mode 100644 index 48ea65818..000000000 --- a/nativescript-core/ui/styling/style/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "style", - "main": "style", - "types": "style.d.ts" -} diff --git a/nativescript-core/ui/styling/style/style.d.ts b/nativescript-core/ui/styling/style/style.d.ts deleted file mode 100644 index 962979ba5..000000000 --- a/nativescript-core/ui/styling/style/style.d.ts +++ /dev/null @@ -1,234 +0,0 @@ -/** - * @module "ui/styling/style" - */ /** */ - -import { Color } from "../../../color"; -import { Length, PercentLength, ViewBase, Observable, BackgroundRepeat, Visibility, HorizontalAlignment, VerticalAlignment, dip } from "../../core/view"; -import { Background } from "../background"; -import { Font, FontStyle, FontWeight } from "../font"; -import { TextAlignment, TextDecoration, TextTransform, WhiteSpace } from "../../text-base"; -import { - FlexDirection, FlexWrap, JustifyContent, AlignItems, AlignContent, - Order, FlexGrow, FlexShrink, FlexWrapBefore, AlignSelf -} from "../../layouts/flexbox-layout"; -import { LinearGradient } from "../gradient"; - -export interface Thickness { - left: number; - top: number; - right: number; - bottom: number; -} - -export interface BorderColor { - top: Color; - right: Color; - bottom: Color; - left: Color; -} - -export interface CommonLayoutParams { - width: number; - height: number; - - widthPercent: number; - heightPercent: number; - - leftMargin: number; - topMargin: number; - rightMargin: number; - bottomMargin: number; - - leftMarginPercent: number; - topMarginPercent: number; - rightMarginPercent: number; - bottomMarginPercent: number; - - horizontalAlignment: HorizontalAlignment; - verticalAlignment: VerticalAlignment; -} - -export class Style extends Observable { - public fontInternal: Font; - public backgroundInternal: Background; - - public rotate: number; - public rotateX: number; - public rotateY: number; - public perspective: number; - public scaleX: number; - public scaleY: number; - public translateX: dip; - public translateY: dip; - - public clipPath: string; - public color: Color; - public tintColor: Color; - public placeholderColor: Color; - - public background: string; - public backgroundColor: Color; - public backgroundImage: string | LinearGradient; - public backgroundRepeat: BackgroundRepeat; - public backgroundSize: string; - public backgroundPosition: string; - - public borderColor: string | Color; - public borderTopColor: Color; - public borderRightColor: Color; - public borderBottomColor: Color; - public borderLeftColor: Color; - public borderWidth: string | Length; - public borderTopWidth: Length; - public borderRightWidth: Length; - public borderBottomWidth: Length; - public borderLeftWidth: Length; - public borderRadius: string | Length; - public borderTopLeftRadius: Length; - public borderTopRightRadius: Length; - public borderBottomRightRadius: Length; - public borderBottomLeftRadius: Length; - - public fontSize: number; - public fontFamily: string; - public fontStyle: FontStyle; - public fontWeight: FontWeight; - public font: string; - - public androidElevation: number; - public androidDynamicElevationOffset: number; - public zIndex: number; - public opacity: number; - public visibility: Visibility; - - public letterSpacing: number; - public lineHeight: number; - public textAlignment: TextAlignment; - public textDecoration: TextDecoration; - public textTransform: TextTransform; - public whiteSpace: WhiteSpace; - - public minWidth: Length; - public minHeight: Length; - public width: PercentLength; - public height: PercentLength; - public margin: string | PercentLength; - public marginLeft: PercentLength; - public marginTop: PercentLength; - public marginRight: PercentLength; - public marginBottom: PercentLength; - public padding: string | Length; - public paddingLeft: Length; - public paddingTop: Length; - public paddingRight: Length; - public paddingBottom: Length; - public horizontalAlignment: HorizontalAlignment; - public verticalAlignment: VerticalAlignment; - - // TabView-specific props - public tabTextFontSize: number; - public tabTextColor: Color; - public tabBackgroundColor: Color; - public selectedTabTextColor: Color; - public androidSelectedTabHighlightColor: Color; - - // ListView-specific props - public separatorColor: Color; - - // SegmentedBar-specific props - public selectedBackgroundColor: Color; - - // Page-specific props - public statusBarStyle: "light" | "dark"; - public androidStatusBarBackground: Color; - - // Android ActionBar specific props - - /** - * Gets or sets the content inset for the android actionbar. - * The content inset affects the valid area for ActionBar content; insets can be used to effectively align ActionBar content along well-known gridlines. - * - * This property is effective on Android API level 21 or later. - */ - public androidContentInset: string | Length; - - /** - * Gets or sets the left content inset for the android actionbar. - * The content inset affects the valid area for ActionBar content; insets can be used to effectively align ActionBar content along well-known gridlines. - * - * This property is effective on Android API level 21 or later. - */ - public androidContentInsetLeft: Length; - - /** - * Gets or sets the right content inset for the android actionbar. - * The content inset affects the valid area for ActionBar content; insets can be used to effectively align ActionBar content along well-known gridlines. - * - * This property is effective on Android API level 21 or later. - */ - public androidContentInsetRight: Length; - - constructor(ownerView: ViewBase | WeakRef); - public viewRef: WeakRef; - - /** - * @deprecated use `viewRef` instead. - * - * The `ViewBase` object associated with the Style! - */ - public view: ViewBase; - - //flexbox layout properties - public flexDirection: FlexDirection; - public flexWrap: FlexWrap; - public justifyContent: JustifyContent; - public alignItems: AlignItems; - public alignContent: AlignContent; - public order: Order; - public flexGrow: FlexGrow; - public flexShrink: FlexShrink; - public flexWrapBefore: FlexWrapBefore; - public alignSelf: AlignSelf; - - /** - * The property bag is a simple class that is paired with the Style class. - * Setting regular css properties on the PropertyBag should simply preserve their values. - * Setting shorthand css properties on the PropertyBag should decompose the provided value, and set each of the shorthand composite properties. - * The shorthand properties are defined as non-enumerable so it should be safe to for-in the keys that are set in the bag. - */ - public readonly PropertyBag: PropertyBagClass; - - /** - * Set a scoped css-value. These are css-variables set from CssState - */ - public setScopedCssVariable(varName: string, value: string): void; - - /** - * Set a unscoped css-value. These are css-variables set on view.style - */ - public setUnscopedCssVariable(varName: string, value: string): void; - - /** - * Get value of the css-variable. - * If the value is not set on this style-object, try the parent view. - */ - public getCssVariable(varName: string): string | null; - - /** - * Remove all scoped css-variables - */ - public resetScopedCssVariables(): void; - - /** - * Remove all unscoped css-variables - */ - public resetUnscopedCssVariables(): void; -} - -interface PropertyBagClass { - new(): PropertyBag; - prototype: PropertyBag; -} -interface PropertyBag { - [property: string]: string; -} diff --git a/nativescript-core/ui/switch/switch-common.ts b/nativescript-core/ui/switch/switch-common.ts index 995ec41b2..2c34f786b 100644 --- a/nativescript-core/ui/switch/switch-common.ts +++ b/nativescript-core/ui/switch/switch-common.ts @@ -1,8 +1,6 @@ -import { Switch as SwitchDefinition } from "."; +import { Color } from "../../color"; import { View, Property, booleanConverter, CSSType } from "../core/view"; -import { Color } from "../../color"; - -export * from "../core/view"; +import { Switch as SwitchDefinition } from "."; @CSSType("Switch") export class SwitchBase extends View implements SwitchDefinition { diff --git a/nativescript-core/ui/switch/switch.d.ts b/nativescript-core/ui/switch/switch.d.ts index a47d0eeaa..2c09944d7 100644 --- a/nativescript-core/ui/switch/switch.d.ts +++ b/nativescript-core/ui/switch/switch.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the Switch class, which represents a standard switch component. - * @module "ui/switch" - */ /** */ - -import { View, Property } from "../core/view"; +import { View } from "../core/view"; +import { Property } from "../core/properties"; import { Color } from "../../color"; /** diff --git a/nativescript-core/ui/tab-navigation-base/tab-content-item/tab-content-item.android.ts b/nativescript-core/ui/tab-navigation-base/tab-content-item/tab-content-item.android.ts index 44061747f..f7ccd9b7d 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-content-item/tab-content-item.android.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-content-item/tab-content-item.android.ts @@ -5,7 +5,8 @@ import { GridLayout } from "../../layouts/grid-layout"; // Requires import { TabContentItemBase, traceCategory } from "./tab-content-item-common"; -import { View, traceWrite, traceMessageType } from "../../core/view"; +import { View } from "../../core/view"; +import { Trace } from "../../../trace"; export * from "./tab-content-item-common"; @@ -49,7 +50,7 @@ export class TabContentItem extends TabContentItemBase { const fragmentManager = tabView._getFragmentManager(); if (typeof this.index === "undefined") { - traceWrite(`Current TabContentItem index is not set`, traceCategory, traceMessageType.error); + Trace.write(`Current TabContentItem index is not set`, traceCategory, Trace.messageType.error); } for (let fragment of (>fragmentManager.getFragments().toArray())) { @@ -61,8 +62,8 @@ export class TabContentItem extends TabContentItemBase { // TODO: can happen in a modal tabview scenario when the modal dialog fragment is already removed if (!tabFragment) { - // if (traceEnabled()) { - // traceWrite(`Could not get child fragment manager for tab item with index ${this.index}`, traceCategory); + // if (Trace.isEnabled()) { + // Trace.write(`Could not get child fragment manager for tab item with index ${this.index}`, traceCategory); // } // TODO: fix d.ts in view module diff --git a/nativescript-core/ui/tab-navigation-base/tab-content-item/tab-content-item.d.ts b/nativescript-core/ui/tab-navigation-base/tab-content-item/tab-content-item.d.ts index e1c8a0180..0e82b0192 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-content-item/tab-content-item.d.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-content-item/tab-content-item.d.ts @@ -1,10 +1,4 @@ -/** - * Contains the TabContentItem class, which represents a content entry for tab navigation. - * @module "ui/tab-navigation/tab-content-item" - */ /** */ - -import { View, ViewBase } from "../../core/view"; -import { ContentView } from "../../content-view"; +import { ContentView } from "../../content-view"; /** * Represents a tab navigation content entry. diff --git a/nativescript-core/ui/tab-navigation-base/tab-navigation-base/tab-navigation-base.d.ts b/nativescript-core/ui/tab-navigation-base/tab-navigation-base/tab-navigation-base.d.ts index 54f9ecdf3..fd57e079c 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-navigation-base/tab-navigation-base.d.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-navigation-base/tab-navigation-base.d.ts @@ -1,15 +1,13 @@ -/** - * Contains the TabNavigationBase class, which serves as the base class for tab navigation. - * @module "ui/tab-navigation/tab-navigation-base" - */ /** */ - -import { - View, ViewBase, Property, CoercibleProperty, isIOS, AddArrayFromBuilder, AddChildFromBuilder, EventData, Color +import { + View, AddArrayFromBuilder, AddChildFromBuilder } from "../../core/view"; +import { isIOS } from "../../../platform"; import { TabStrip } from "../tab-strip"; import { TabStripItem } from "../tab-strip-item"; import { TabContentItem } from "../tab-content-item"; - +import { Property, CoercibleProperty } from "../../core/properties"; +import { EventData } from "../../../data/observable"; +import { Color } from "../../../color"; /** * Defines the data for the tab navigation selectedIndexChanged event. */ diff --git a/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.d.ts b/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.d.ts index 85fb78dc7..d4f178d72 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.d.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.d.ts @@ -1,11 +1,7 @@ -/** - * Contains the TabStripItem class, which represents a tab strip entry for tab navigation. - * @module "ui/tab-navigation/tab-strip-item" - */ /** */ - -import { View, EventData } from "../../core/view"; +import { View } from "../../core/view"; import { Image } from "../../image/image"; import { Label } from "../../label/label"; +import { EventData } from "../../../data/observable" /** * Represents a tab strip entry. diff --git a/nativescript-core/ui/tab-navigation-base/tab-strip/tab-strip.d.ts b/nativescript-core/ui/tab-navigation-base/tab-strip/tab-strip.d.ts index b21d31f97..9a29abb4a 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-strip/tab-strip.d.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-strip/tab-strip.d.ts @@ -1,10 +1,7 @@ -/** - * Contains the TabStrip class, which represents a tab strip for tab navigation. - * @module "ui/tab-navigation/tab-strip" - */ /** */ - -import { Color } from "../../../color"; -import { EventData, Property, View } from "../../core/view"; +import { Color } from "../../../color"; +import { View } from "../../core/view"; +import { EventData } from "../../../data/observable"; +import { Property } from "../../core/properties" import { TabStripItem } from "../tab-strip-item"; /** diff --git a/nativescript-core/ui/tab-view/tab-view-common.ts b/nativescript-core/ui/tab-view/tab-view-common.ts index f677b041a..c69d57135 100644 --- a/nativescript-core/ui/tab-view/tab-view-common.ts +++ b/nativescript-core/ui/tab-view/tab-view-common.ts @@ -1,12 +1,15 @@ import { TabView as TabViewDefinition, TabViewItem as TabViewItemDefinition, SelectedIndexChangedEventData } from "."; import { - View, ViewBase, Style, Property, CssProperty, CoercibleProperty, - Color, isIOS, AddArrayFromBuilder, AddChildFromBuilder, EventData, CSSType, - traceWrite, traceCategories, traceMessageType, booleanConverter + View, AddArrayFromBuilder, AddChildFromBuilder, CSSType } from "../core/view"; - -export * from "../core/view"; +import { ViewBase, booleanConverter } from "../core/view-base"; +import { Style } from "../styling/style"; +import { EventData } from "../../data/observable"; +import { Color } from "../../color"; +import { isIOS } from "../../platform"; +import { Property, CssProperty, CoercibleProperty } from "../core/properties"; import { TextTransform } from "../text-base"; +import { Trace } from "../../trace"; export const traceCategory = "TabView"; @@ -208,7 +211,7 @@ export interface TabViewBase { } export function traceMissingIcon(icon: string) { - traceWrite("Could not load tab bar icon: " + icon, traceCategories.Error, traceMessageType.error); + Trace.write("Could not load tab bar icon: " + icon, Trace.categories.Error, Trace.messageType.error); } export const selectedIndexProperty = new CoercibleProperty({ diff --git a/nativescript-core/ui/tab-view/tab-view.android.ts b/nativescript-core/ui/tab-view/tab-view.android.ts index 073afae6b..9d03ebe83 100644 --- a/nativescript-core/ui/tab-view/tab-view.android.ts +++ b/nativescript-core/ui/tab-view/tab-view.android.ts @@ -4,13 +4,14 @@ import { Font } from "../styling/font"; import { TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, tabTextColorProperty, tabBackgroundColorProperty, tabTextFontSizeProperty, selectedTabTextColorProperty, - androidSelectedTabHighlightColorProperty, androidOffscreenTabLimitProperty, - fontSizeProperty, fontInternalProperty, layout, traceCategory, traceEnabled, - traceWrite, Color, traceMissingIcon + androidSelectedTabHighlightColorProperty, androidOffscreenTabLimitProperty, traceCategory, traceMissingIcon } from "./tab-view-common"; import { textTransformProperty, TextTransform, getTransformedText } from "../text-base"; import { ImageSource } from "../../image-source"; -import { RESOURCE_PREFIX, ad } from "../../utils/utils"; +import { Trace } from "../../trace"; +import { Color } from "../../color"; +import { fontSizeProperty, fontInternalProperty } from "../styling/style-properties"; +import { RESOURCE_PREFIX, ad, layout } from "../../utils/utils"; import { Frame } from "../frame"; import * as application from "../../application"; @@ -375,8 +376,8 @@ export class TabViewItem extends TabViewItemBase { // TODO: can happen in a modal tabview scenario when the modal dialog fragment is already removed if (!tabFragment) { - if (traceEnabled()) { - traceWrite(`Could not get child fragment manager for tab item with index ${this.index}`, traceCategory); + if (Trace.isEnabled()) { + Trace.write(`Could not get child fragment manager for tab item with index ${this.index}`, traceCategory); } return (tabView)._getRootFragmentManager(); @@ -468,8 +469,8 @@ export class TabView extends TabViewBase { public createNativeView() { initializeNativeClasses(); - if (traceEnabled()) { - traceWrite("TabView._createUI(" + this + ");", traceCategory); + if (Trace.isEnabled()) { + Trace.write("TabView._createUI(" + this + ");", traceCategory); } const context: android.content.Context = this._context; @@ -711,8 +712,8 @@ export class TabView extends TabViewBase { [selectedIndexProperty.setNative](value: number) { const smoothScroll = this.androidTabsPosition === "top"; - if (traceEnabled()) { - traceWrite("TabView this._viewPager.setCurrentItem(" + value + ", " + smoothScroll + ");", traceCategory); + if (Trace.isEnabled()) { + Trace.write("TabView this._viewPager.setCurrentItem(" + value + ", " + smoothScroll + ");", traceCategory); } this._viewPager.setCurrentItem(value, smoothScroll); diff --git a/nativescript-core/ui/tab-view/tab-view.d.ts b/nativescript-core/ui/tab-view/tab-view.d.ts index 14072fb04..02ca875d2 100644 --- a/nativescript-core/ui/tab-view/tab-view.d.ts +++ b/nativescript-core/ui/tab-view/tab-view.d.ts @@ -1,9 +1,13 @@ /** * Contains the TabView class, which represents a standard content component with tabs. - * @module "ui/tab-view" - */ /** */ + */ -import { View, ViewBase, Property, CssProperty, Style, EventData, Color } from "../core/view"; +import { View } from "../core/view"; +import { ViewBase } from "../core/view-base"; +import { Property, CssProperty } from "../core/properties"; +import { EventData } from "../../data/observable"; +import { Color } from "../../color"; +import { Style } from "../styling/style"; import { TextTransform } from "../text-base"; /** * Represents a tab view entry. diff --git a/nativescript-core/ui/tab-view/tab-view.ios.ts b/nativescript-core/ui/tab-view/tab-view.ios.ts index d6d61211d..53f00cd20 100644 --- a/nativescript-core/ui/tab-view/tab-view.ios.ts +++ b/nativescript-core/ui/tab-view/tab-view.ios.ts @@ -1,12 +1,16 @@ import { TabViewItem as TabViewItemDefinition } from "."; import { Font } from "../styling/font"; -import { ios as iosView, ViewBase } from "../core/view"; +import { ios as iosView, View } from "../core/view"; +import { ViewBase } from "../core/view-base"; import { TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, - tabTextColorProperty, tabTextFontSizeProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, iosIconRenderingModeProperty, - View, fontInternalProperty, layout, traceEnabled, traceWrite, traceCategories, Color, traceMissingIcon + tabTextColorProperty, tabTextFontSizeProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, iosIconRenderingModeProperty, traceMissingIcon } from "./tab-view-common"; +import { layout } from '../../utils/utils'; +import { Color } from "../../color"; +import { Trace } from "../../trace"; +import { fontInternalProperty } from "../styling/style-properties"; import { textTransformProperty, TextTransform, getTransformedText } from "../text-base"; import { ImageSource } from "../../image-source"; import { profile } from "../../profiling"; @@ -99,8 +103,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl } public tabBarControllerShouldSelectViewController(tabBarController: UITabBarController, viewController: UIViewController): boolean { - if (traceEnabled()) { - traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug); } let owner = this._owner.get(); @@ -120,8 +124,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl } public tabBarControllerDidSelectViewController(tabBarController: UITabBarController, viewController: UIViewController): void { - if (traceEnabled()) { - traceWrite("TabView.delegate.DID_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write("TabView.delegate.DID_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug); } const owner = this._owner.get(); @@ -146,8 +150,8 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio } navigationControllerWillShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void { - if (traceEnabled()) { - traceWrite("TabView.moreNavigationController.WILL_show(" + navigationController + ", " + viewController + ", " + animated + ");", traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write("TabView.moreNavigationController.WILL_show(" + navigationController + ", " + viewController + ", " + animated + ");", Trace.categories.Debug); } let owner = this._owner.get(); @@ -160,8 +164,8 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio } navigationControllerDidShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void { - if (traceEnabled()) { - traceWrite("TabView.moreNavigationController.DID_show(" + navigationController + ", " + viewController + ", " + animated + ");", traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write("TabView.moreNavigationController.DID_show(" + navigationController + ", " + viewController + ", " + animated + ");", Trace.categories.Debug); } // We don't need Edit button in More screen. navigationController.navigationBar.topItem.rightBarButtonItem = null; @@ -352,22 +356,22 @@ export class TabView extends TabViewBase { public _onViewControllerShown(viewController: UIViewController) { // This method could be called with the moreNavigationController or its list controller, so we have to check. - if (traceEnabled()) { - traceWrite("TabView._onViewControllerShown(" + viewController + ");", traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write("TabView._onViewControllerShown(" + viewController + ");", Trace.categories.Debug); } if (this._ios.viewControllers && this._ios.viewControllers.containsObject(viewController)) { this.selectedIndex = this._ios.viewControllers.indexOfObject(viewController); } else { - if (traceEnabled()) { - traceWrite("TabView._onViewControllerShown: viewController is not one of our viewControllers", traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write("TabView._onViewControllerShown: viewController is not one of our viewControllers", Trace.categories.Debug); } } } private _actionBarHiddenByTabView: boolean; public _handleTwoNavigationBars(backToMoreWillBeVisible: boolean) { - if (traceEnabled()) { - traceWrite(`TabView._handleTwoNavigationBars(backToMoreWillBeVisible: ${backToMoreWillBeVisible})`, traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write(`TabView._handleTwoNavigationBars(backToMoreWillBeVisible: ${backToMoreWillBeVisible})`, Trace.categories.Debug); } // The "< Back" and "< More" navigation bars should not be visible simultaneously. @@ -383,8 +387,8 @@ export class TabView extends TabViewBase { page.actionBarHidden = true; page.frame.ios._disableNavBarAnimation = false; this._actionBarHiddenByTabView = true; - if (traceEnabled()) { - traceWrite(`TabView hid action bar`, traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write(`TabView hid action bar`, Trace.categories.Debug); } return; @@ -395,8 +399,8 @@ export class TabView extends TabViewBase { page.actionBarHidden = false; page.frame.ios._disableNavBarAnimation = false; this._actionBarHiddenByTabView = undefined; - if (traceEnabled()) { - traceWrite(`TabView restored action bar`, traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write(`TabView restored action bar`, Trace.categories.Debug); } return; @@ -504,8 +508,8 @@ export class TabView extends TabViewBase { } [selectedIndexProperty.setNative](value: number) { - if (traceEnabled()) { - traceWrite("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", traceCategories.Debug); + if (Trace.isEnabled()) { + Trace.write("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", Trace.categories.Debug); } if (value > -1) { diff --git a/nativescript-core/ui/tabs/tabs.android.ts b/nativescript-core/ui/tabs/tabs.android.ts index 7b85c489a..e46ea4e79 100644 --- a/nativescript-core/ui/tabs/tabs.android.ts +++ b/nativescript-core/ui/tabs/tabs.android.ts @@ -404,8 +404,8 @@ export class Tabs extends TabsBase { public createNativeView() { initializeNativeClasses(); // TODO - // if (traceEnabled()) { - // traceWrite("TabView._createUI(" + this + ");", traceCategory); + // if (Trace.isEnabled()) { + // Trace.write("TabView._createUI(" + this + ");", traceCategory); // } const context: android.content.Context = this._context; @@ -948,8 +948,8 @@ export class Tabs extends TabsBase { [selectedIndexProperty.setNative](value: number) { // TODO - // if (traceEnabled()) { - // traceWrite("TabView this._viewPager.setCurrentItem(" + value + ", " + smoothScroll + ");", traceCategory); + // if (Trace.isEnabled()) { + // Trace.write("TabView this._viewPager.setCurrentItem(" + value + ", " + smoothScroll + ");", traceCategory); // } this._viewPager.setCurrentItem(value, this.animationEnabled); } diff --git a/nativescript-core/ui/tabs/tabs.d.ts b/nativescript-core/ui/tabs/tabs.d.ts index feb397d9e..192fd267a 100644 --- a/nativescript-core/ui/tabs/tabs.d.ts +++ b/nativescript-core/ui/tabs/tabs.d.ts @@ -1,9 +1,9 @@ /** * Contains the Tabs class, which represents a tab navigation component. - * @module "ui/tabs" - */ /** */ + */ -import { EventData, Property } from "../core/view"; +import { Property } from "../core/properties"; +import { EventData } from "../../data/observable"; import { TabContentItem } from "../tab-navigation-base/tab-content-item"; import { SelectedIndexChangedEventData, TabNavigationBase diff --git a/nativescript-core/ui/tabs/tabs.ios.ts b/nativescript-core/ui/tabs/tabs.ios.ts index c0e241c4d..6c1f7c3f5 100644 --- a/nativescript-core/ui/tabs/tabs.ios.ts +++ b/nativescript-core/ui/tabs/tabs.ios.ts @@ -278,8 +278,8 @@ class UIPageViewControllerDataSourceImpl extends NSObject implements UIPageViewC public pageViewControllerViewControllerBeforeViewController(pageViewController: UIPageViewController, viewController: UIViewController): UIViewController { // TODO - // if (traceEnabled()) { - // traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug); // } const owner = this._owner.get(); @@ -305,8 +305,8 @@ class UIPageViewControllerDataSourceImpl extends NSObject implements UIPageViewC public pageViewControllerViewControllerAfterViewController(pageViewController: UIPageViewController, viewController: UIViewController): UIViewController { // TODO - // if (traceEnabled()) { - // traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug); // } const owner = this._owner.get(); @@ -333,8 +333,8 @@ class UIPageViewControllerDataSourceImpl extends NSObject implements UIPageViewC public presentationCountForPageViewController(pageViewController: UIPageViewController): number { // TODO - // if (traceEnabled()) { - // traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug); // } return 0; @@ -342,8 +342,8 @@ class UIPageViewControllerDataSourceImpl extends NSObject implements UIPageViewC public presentationIndexForPageViewController(pageViewController: UIPageViewController): number { // TODO - // if (traceEnabled()) { - // traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug); // } return 0; @@ -631,15 +631,15 @@ export class Tabs extends TabsBase { public _onViewControllerShown(viewController: UIViewController) { // This method could be called with the moreNavigationController or its list controller, so we have to check. // TODO - // if (traceEnabled()) { - // traceWrite("TabView._onViewControllerShown(" + viewController + ");", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView._onViewControllerShown(" + viewController + ");", Trace.categories.Debug); // } if (this._ios.viewControllers && this._ios.viewControllers.containsObject(viewController)) { this.selectedIndex = this._ios.viewControllers.indexOfObject(viewController); } else { // TODO - // if (traceEnabled()) { - // traceWrite("TabView._onViewControllerShown: viewController is not one of our viewControllers", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView._onViewControllerShown: viewController is not one of our viewControllers", Trace.categories.Debug); // } } } @@ -1084,8 +1084,8 @@ export class Tabs extends TabsBase { [selectedIndexProperty.setNative](value: number) { // TODO - // if (traceEnabled()) { - // traceWrite("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", traceCategories.Debug); + // if (Trace.isEnabled()) { + // Trace.write("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", Trace.categories.Debug); // } if (value > -1) { diff --git a/nativescript-core/ui/text-base/formatted-string.d.ts b/nativescript-core/ui/text-base/formatted-string.d.ts index a1891f16d..8d6b897cf 100644 --- a/nativescript-core/ui/text-base/formatted-string.d.ts +++ b/nativescript-core/ui/text-base/formatted-string.d.ts @@ -1,17 +1,14 @@ /** * Contains the FormattedString and Span classes, which are used to create a formatted (rich text) strings. - * @module "ui/text-base/formatted-string" - */ /** */ + */ import { Span } from "./span"; import { ObservableArray } from "../../data/observable-array"; -import { ViewBase } from "../core/view"; +import { ViewBase } from "../core/view-base"; import { Color } from "../../color"; import { FontStyle, FontWeight } from "../styling/font"; import { TextDecoration } from "../text-base"; -export { Span }; - /** * A class used to create a formatted (rich text) string. */ diff --git a/nativescript-core/ui/text-base/formatted-string.ts b/nativescript-core/ui/text-base/formatted-string.ts index 16c029bc7..d5a3900ee 100644 --- a/nativescript-core/ui/text-base/formatted-string.ts +++ b/nativescript-core/ui/text-base/formatted-string.ts @@ -2,13 +2,12 @@ import { FormattedString as FormattedStringDefinition } from "./formatted-string import { Span } from "./span"; import { Observable, PropertyChangeData } from "../../data/observable"; import { ObservableArray, ChangedData } from "../../data/observable-array"; -import { ViewBase, AddArrayFromBuilder, AddChildFromBuilder } from "../core/view"; +import { AddArrayFromBuilder, AddChildFromBuilder } from "../core/view"; +import { ViewBase } from "../core/view-base"; import { Color } from "../../color"; import { FontStyle, FontWeight } from "../styling/font"; import { TextDecoration } from "../text-base"; -export { Span }; - export module knownCollections { export const spans = "spans"; } @@ -106,7 +105,7 @@ export class FormattedString extends ViewBase implements FormattedStringDefiniti const span = (>eventData.object).getItem(eventData.index + i); // First add to logical tree so that inherited properties are set. - this._addView(span); + this._addView(span); // Then attach handlers - we skip the first nofitication because // we raise change for the whole instance. diff --git a/nativescript-core/ui/text-base/text-base.android.ts b/nativescript-core/ui/text-base/index.android.ts similarity index 100% rename from nativescript-core/ui/text-base/text-base.android.ts rename to nativescript-core/ui/text-base/index.android.ts diff --git a/nativescript-core/ui/text-base/text-base.d.ts b/nativescript-core/ui/text-base/index.d.ts similarity index 93% rename from nativescript-core/ui/text-base/text-base.d.ts rename to nativescript-core/ui/text-base/index.d.ts index 4b3fc76ce..fdde38488 100644 --- a/nativescript-core/ui/text-base/text-base.d.ts +++ b/nativescript-core/ui/text-base/index.d.ts @@ -1,12 +1,8 @@ -/** - * @module "ui/text-base" - */ /** */ - -import { View, AddChildFromBuilder, Property, CssProperty, InheritedCssProperty, Style, Length } from "../core/view"; +import { View, AddChildFromBuilder } from "../core/view"; import { FormattedString } from "./formatted-string"; - -export * from "../core/view"; -export { FormattedString }; +import { Style } from "../styling/style"; +import { Length } from "../styling/style-properties"; +import { Property, CssProperty, InheritedCssProperty } from "../core/properties"; export class TextBase extends View implements AddChildFromBuilder { diff --git a/nativescript-core/ui/text-base/text-base.ios.ts b/nativescript-core/ui/text-base/index.ios.ts similarity index 97% rename from nativescript-core/ui/text-base/text-base.ios.ts rename to nativescript-core/ui/text-base/index.ios.ts index 6febab0eb..42d6b4fce 100644 --- a/nativescript-core/ui/text-base/text-base.ios.ts +++ b/nativescript-core/ui/text-base/index.ios.ts @@ -1,17 +1,21 @@ // Types -import { TextDecoration, TextAlignment, TextTransform, layout, getClosestPropertyValue } from "./text-base-common"; +import { TextDecoration, TextAlignment, TextTransform, getClosestPropertyValue } from "./text-base-common"; // Requires import { Font } from "../styling/font"; import { VerticalAlignment } from "../styling/style-properties"; import { TextBaseCommon, textProperty, formattedTextProperty, textAlignmentProperty, textDecorationProperty, - textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, lineHeightProperty, - FormattedString, Span, Color, resetSymbol + textTransformProperty, letterSpacingProperty, lineHeightProperty, + resetSymbol } from "./text-base-common"; +import { Color } from "../../color"; +import { FormattedString } from "./formatted-string"; +import { Span } from "./span"; +import { colorProperty, fontInternalProperty } from "../styling/style-properties"; import { isString } from "../../utils/types"; -import { ios } from "../../utils/utils"; -import { Property } from "../core/properties/properties"; +import { ios, layout } from "../../utils/utils"; +import { Property } from "../core/properties"; export * from "./text-base-common"; diff --git a/nativescript-core/ui/text-base/package.json b/nativescript-core/ui/text-base/package.json deleted file mode 100644 index 49cb52cee..000000000 --- a/nativescript-core/ui/text-base/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "text-base", - "main": "text-base", - "types": "text-base.d.ts" -} diff --git a/nativescript-core/ui/text-base/span.d.ts b/nativescript-core/ui/text-base/span.d.ts index f648dd198..4f60f2b58 100644 --- a/nativescript-core/ui/text-base/span.d.ts +++ b/nativescript-core/ui/text-base/span.d.ts @@ -1,8 +1,4 @@ -/** - * @module "ui/text-base/span" - */ /** */ - -import { Color } from "../../color"; +import { Color } from "../../color"; import { ViewBase } from "../core/view-base"; import { FontStyle, FontWeight } from "../styling/font"; import { TextDecoration } from "../text-base"; diff --git a/nativescript-core/ui/text-base/span.ts b/nativescript-core/ui/text-base/span.ts index afce37d80..59bf5bc92 100644 --- a/nativescript-core/ui/text-base/span.ts +++ b/nativescript-core/ui/text-base/span.ts @@ -1,8 +1,9 @@ import { Color } from "../../color"; import { Span as SpanDefinition } from "./span"; -import { ViewBase } from "../core/view"; +import { ViewBase } from "../core/view-base"; import { FontStyle, FontWeight, } from "../styling/font"; -import { TextDecoration, EventData } from "../text-base"; +import { TextDecoration } from "../text-base"; +import { EventData } from "../../data/observable"; export class Span extends ViewBase implements SpanDefinition { static linkTapEvent = "linkTap"; diff --git a/nativescript-core/ui/text-base/text-base-common.ts b/nativescript-core/ui/text-base/text-base-common.ts index 57b47ddfd..d10f631f1 100644 --- a/nativescript-core/ui/text-base/text-base-common.ts +++ b/nativescript-core/ui/text-base/text-base-common.ts @@ -1,20 +1,33 @@ // Types -import { TextBase as TextBaseDefinition } from "."; -import { TextAlignment, TextDecoration, TextTransform, WhiteSpace } from "./text-base-interfaces"; -import { Length, ViewBase } from "../core/view"; -import { FontStyle, FontWeight } from "../styling/font-interfaces"; import { PropertyChangeData } from "../../data/observable/observable-interfaces"; +import { ViewBase } from "../core/view-base"; +import { FontStyle, FontWeight } from "../styling/font-interfaces"; // Requires. -import { FormattedString, Span } from "./formatted-string"; +import { FormattedString } from "./formatted-string"; +import { Span } from "./span"; import { - View, Property, CssProperty, InheritedCssProperty, Style, isAndroid, isIOS, Observable, - makeValidator, makeParser + View } from "../core/view"; +import { + Property, CssProperty, InheritedCssProperty, + makeValidator, makeParser +} from "../core/properties"; +import { + Style +} from "../styling/style"; +import { + Length +} from "../styling/style-properties"; +import { + isAndroid, isIOS, +} from "../../platform"; +import { Observable } from "../../data/observable"; + +import { TextAlignment, TextDecoration, TextTransform, WhiteSpace } from "./text-base-interfaces"; +import { TextBase as TextBaseDefinition } from "."; -export { FormattedString, Span }; export * from "./text-base-interfaces"; -export * from "../core/view"; const CHILD_SPAN = "Span"; const CHILD_FORMATTED_TEXT = "formattedText"; diff --git a/nativescript-core/ui/text-field/text-field-common.ts b/nativescript-core/ui/text-field/text-field-common.ts index 49dffe571..323ff0d6d 100644 --- a/nativescript-core/ui/text-field/text-field-common.ts +++ b/nativescript-core/ui/text-field/text-field-common.ts @@ -1,5 +1,8 @@ import { TextField as TextFieldDefinition } from "."; -import { EditableTextBase, Property, booleanConverter, CSSType } from "../editable-text-base"; +import { EditableTextBase } from "../editable-text-base"; +import { Property} from "../core/properties" +import { CSSType} from "../core/view" +import { booleanConverter} from "../core/view-base" @CSSType("TextField") export class TextFieldBase extends EditableTextBase implements TextFieldDefinition { diff --git a/nativescript-core/ui/text-field/text-field.d.ts b/nativescript-core/ui/text-field/text-field.d.ts index e6983069c..3dec13253 100644 --- a/nativescript-core/ui/text-field/text-field.d.ts +++ b/nativescript-core/ui/text-field/text-field.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the TextField class, which represents an editable single-line box. - * @module "ui/text-field" - */ /** */ - -import { EditableTextBase, Property } from "../editable-text-base"; +import { EditableTextBase } from "../editable-text-base"; +import { Property } from "../core/properties"; export const secureProperty: Property; diff --git a/nativescript-core/ui/text-view/text-view.d.ts b/nativescript-core/ui/text-view/text-view.d.ts index 9dcecb58f..d69b44755 100644 --- a/nativescript-core/ui/text-view/text-view.d.ts +++ b/nativescript-core/ui/text-view/text-view.d.ts @@ -1,10 +1,5 @@ -/** - * Contains the TextView class, which represents an editable multi-line line box. - * @module "ui/text-view" - */ /** */ - -import { EditableTextBase } from "../editable-text-base"; -import { Property } from "../text-base"; +import { EditableTextBase } from "../editable-text-base"; +import { Property } from "../core/properties"; /** * Represents an editable multiline text view. diff --git a/nativescript-core/ui/time-picker/time-picker-common.ts b/nativescript-core/ui/time-picker/time-picker-common.ts index b0c6b38fa..6c1f00e82 100644 --- a/nativescript-core/ui/time-picker/time-picker-common.ts +++ b/nativescript-core/ui/time-picker/time-picker-common.ts @@ -1,5 +1,6 @@ import { TimePicker as TimePickerDefinition } from "."; -import { View, Property, CSSType } from "../core/view"; +import { View, CSSType } from "../core/view"; +import { Property } from "../core/properties"; interface Time { hour: number; diff --git a/nativescript-core/ui/time-picker/time-picker.d.ts b/nativescript-core/ui/time-picker/time-picker.d.ts index 2dda072ef..6e76b3be9 100644 --- a/nativescript-core/ui/time-picker/time-picker.d.ts +++ b/nativescript-core/ui/time-picker/time-picker.d.ts @@ -1,9 +1,5 @@ -/** - * Contains the TimePicker class. - * @module "ui/time-picker" - */ /** */ - -import { View, Property } from "../core/view"; +import { View } from "../core/view"; +import { Property } from "../core/properties"; /** * Represents an time picker. diff --git a/nativescript-core/ui/transition/fade-transition.d.ts b/nativescript-core/ui/transition/fade-transition.d.ts index aae3f04f0..3c4c04308 100644 --- a/nativescript-core/ui/transition/fade-transition.d.ts +++ b/nativescript-core/ui/transition/fade-transition.d.ts @@ -1,8 +1,4 @@ -/** - * @module "ui/transition/fade-transition" - */ /** */ - -import { Transition } from "../transition"; +import { Transition } from "../transition"; export class FadeTransition extends Transition { constructor(duration: number, nativeCurve: any); diff --git a/nativescript-core/ui/transition/flip-transition.d.ts b/nativescript-core/ui/transition/flip-transition.d.ts index d055d18a1..57623aa97 100644 --- a/nativescript-core/ui/transition/flip-transition.d.ts +++ b/nativescript-core/ui/transition/flip-transition.d.ts @@ -1,8 +1,4 @@ -/** - * @module "ui/transition/fade-transition" - */ /** */ - -import { Transition } from "../transition"; +import { Transition } from "../transition"; export class FlipTransition extends Transition { constructor(direction: string, duration: number, curve: any); diff --git a/nativescript-core/ui/transition/slide-transition.d.ts b/nativescript-core/ui/transition/slide-transition.d.ts index 31275755b..1eb6fc135 100644 --- a/nativescript-core/ui/transition/slide-transition.d.ts +++ b/nativescript-core/ui/transition/slide-transition.d.ts @@ -1,8 +1,4 @@ -/** - * @module "ui/transition/slide-transition" - */ /** */ - -import { Transition } from "../transition"; +import { Transition } from "../transition"; export class SlideTransition extends Transition { constructor(direction: string, duration: number, nativeCurve: any); diff --git a/nativescript-core/ui/transition/transition.d.ts b/nativescript-core/ui/transition/transition.d.ts index e4f77dc7e..e6d36de9e 100644 --- a/nativescript-core/ui/transition/transition.d.ts +++ b/nativescript-core/ui/transition/transition.d.ts @@ -1,8 +1,4 @@ -/** - * @module "ui/transition" - */ /** */ - -export module AndroidTransitionType { +export module AndroidTransitionType { export const enter: string; export const exit: string; export const popEnter: string; diff --git a/nativescript-core/ui/utils.d.ts b/nativescript-core/ui/utils.d.ts index a30b9f6f3..2cefc1192 100644 --- a/nativescript-core/ui/utils.d.ts +++ b/nativescript-core/ui/utils.d.ts @@ -1,10 +1,4 @@ -/** - * @module "ui/utils" - */ - -import { View } from "./core/view"; - -export module ios { +export module ios { /** * Gets actual height of a [UIView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/) widget in device pixels. * @param uiView - An instance of UIView. diff --git a/nativescript-core/ui/web-view/web-view-common.ts b/nativescript-core/ui/web-view/web-view-common.ts index 25bcfb057..9e3fad010 100644 --- a/nativescript-core/ui/web-view/web-view-common.ts +++ b/nativescript-core/ui/web-view/web-view-common.ts @@ -1,15 +1,15 @@ -import { WebView as WebViewDefinition } from "."; import { LoadEventData, NavigationType } from "./web-view-interfaces"; -import { ContainerView, Property, EventData, CSSType } from "../core/view"; -import { File, knownFolders, path } from "../../file-system"; +import { ContainerView, CSSType } from "../core/view"; +import { Property } from "../core/properties"; +import { EventData } from "../../data/observable"; +import { knownFolders } from "../../file-system"; -export { File, knownFolders, path }; export * from "./web-view-interfaces"; export const srcProperty = new Property({ name: "src" }); @CSSType("WebView") -export abstract class WebViewBase extends ContainerView implements WebViewDefinition { +export abstract class WebViewBase extends ContainerView { public static loadStartedEvent = "loadStarted"; public static loadFinishedEvent = "loadFinished"; @@ -24,7 +24,7 @@ export abstract class WebViewBase extends ContainerView implements WebViewDefini error: error }; - this.notify(args); + this.notify(args); } public _onLoadStarted(url: string, navigationType: NavigationType) { @@ -36,7 +36,7 @@ export abstract class WebViewBase extends ContainerView implements WebViewDefini error: undefined }; - this.notify(args); + this.notify(args); } abstract _loadUrl(src: string): void; @@ -93,9 +93,9 @@ export abstract class WebViewBase extends ContainerView implements WebViewDefini // HACK: We declare all these 'on' statements, so that they can appear in the API reference // HACK: Do we need this? Is it useful? There are static fields to the WebViewBase class for the event names. export interface WebViewBase { - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - on(event: "loadFinished", callback: (args: LoadEventData) => void, thisArg?: any); - on(event: "loadStarted", callback: (args: LoadEventData) => void, thisArg?: any); + on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void; + on(event: "loadFinished", callback: (args: LoadEventData) => void, thisArg?: any): void; + on(event: "loadStarted", callback: (args: LoadEventData) => void, thisArg?: any): void; } srcProperty.register(WebViewBase); diff --git a/nativescript-core/ui/web-view/web-view.android.ts b/nativescript-core/ui/web-view/web-view.android.ts index 762538f33..513013d40 100644 --- a/nativescript-core/ui/web-view/web-view.android.ts +++ b/nativescript-core/ui/web-view/web-view.android.ts @@ -1,5 +1,7 @@ -import { WebViewBase, knownFolders, WebViewClient } from "./web-view-common"; -import { isEnabled, write, categories } from '../../trace'; +import { WebViewBase, WebViewClient } from "./web-view-common"; +import { Trace } from '../../trace'; +import { knownFolders } from "../../file-system"; + export * from "./web-view-common"; @@ -19,8 +21,8 @@ function initializeWebViewClient(): void { } public shouldOverrideUrlLoading(view: android.webkit.WebView, url: string) { - if (isEnabled()) { - write("WebViewClientClass.shouldOverrideUrlLoading(" + url + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WebViewClientClass.shouldOverrideUrlLoading(" + url + ")", Trace.categories.Debug); } return false; @@ -30,8 +32,8 @@ function initializeWebViewClient(): void { super.onPageStarted(view, url, favicon); const owner = this.owner; if (owner) { - if (isEnabled()) { - write("WebViewClientClass.onPageStarted(" + url + ", " + favicon + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WebViewClientClass.onPageStarted(" + url + ", " + favicon + ")", Trace.categories.Debug); } owner._onLoadStarted(url, undefined); } @@ -41,8 +43,8 @@ function initializeWebViewClient(): void { super.onPageFinished(view, url); const owner = this.owner; if (owner) { - if (isEnabled()) { - write("WebViewClientClass.onPageFinished(" + url + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WebViewClientClass.onPageFinished(" + url + ")", Trace.categories.Debug); } owner._onLoadFinished(url, undefined); } @@ -60,8 +62,8 @@ function initializeWebViewClient(): void { const owner = this.owner; if (owner) { - if (isEnabled()) { - write("WebViewClientClass.onReceivedError(" + errorCode + ", " + description + ", " + failingUrl + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WebViewClientClass.onReceivedError(" + errorCode + ", " + description + ", " + failingUrl + ")", Trace.categories.Debug); } owner._onLoadFinished(failingUrl, description + "(" + errorCode + ")"); } @@ -76,8 +78,8 @@ function initializeWebViewClient(): void { const owner = this.owner; if (owner) { - if (isEnabled()) { - write("WebViewClientClass.onReceivedError(" + error.getErrorCode() + ", " + error.getDescription() + ", " + (error.getUrl && error.getUrl()) + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WebViewClientClass.onReceivedError(" + error.getErrorCode() + ", " + error.getDescription() + ", " + (error.getUrl && error.getUrl()) + ")", Trace.categories.Debug); } owner._onLoadFinished(error.getUrl && error.getUrl(), error.getDescription() + "(" + error.getErrorCode() + ")"); } @@ -85,7 +87,7 @@ function initializeWebViewClient(): void { } } - WebViewClient = WebViewClientImpl; + WebViewClient = WebViewClientImpl; } export class WebView extends WebViewBase { @@ -103,7 +105,7 @@ export class WebView extends WebViewBase { super.initNativeView(); initializeWebViewClient(); const nativeView = this.nativeViewProtected; - const client = new WebViewClient(this); + const client = new WebViewClient(this); nativeView.setWebViewClient(client); (nativeView).client = client; } diff --git a/nativescript-core/ui/web-view/web-view.d.ts b/nativescript-core/ui/web-view/web-view.d.ts index e08c8156f..952c55e47 100644 --- a/nativescript-core/ui/web-view/web-view.d.ts +++ b/nativescript-core/ui/web-view/web-view.d.ts @@ -1,9 +1,10 @@ /** * Contains the WebView class, which represents a standard browser widget. - * @module "ui/web-view" - */ /** */ + */ -import { View, Property, EventData } from "../core/view"; +import { View } from "../core/view"; +import { Property } from "../core/properties"; +import { EventData } from "../../data/observable"; /** * Represents the observable property backing the Url property of each WebView instance. diff --git a/nativescript-core/ui/web-view/web-view.ios.ts b/nativescript-core/ui/web-view/web-view.ios.ts index dd93a7895..0612a8411 100644 --- a/nativescript-core/ui/web-view/web-view.ios.ts +++ b/nativescript-core/ui/web-view/web-view.ios.ts @@ -1,8 +1,9 @@ import { NavigationType } from "."; -import { WebViewBase, knownFolders } from "./web-view-common"; +import { WebViewBase } from "./web-view-common"; import { profile } from "../../profiling"; -import { isEnabled, write, categories } from '../../trace'; +import { Trace } from '../../trace'; export * from "./web-view-common"; +import { knownFolders } from "../../file-system"; class WKNavigationDelegateImpl extends NSObject implements WKNavigationDelegate { @@ -39,22 +40,22 @@ class WKNavigationDelegateImpl extends NSObject } decisionHandler(WKNavigationActionPolicy.Allow); - if (isEnabled()) { - write("WKNavigationDelegateClass.webViewDecidePolicyForNavigationActionDecisionHandler(" + navigationAction.request.URL.absoluteString + ", " + navigationAction.navigationType + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WKNavigationDelegateClass.webViewDecidePolicyForNavigationActionDecisionHandler(" + navigationAction.request.URL.absoluteString + ", " + navigationAction.navigationType + ")", Trace.categories.Debug); } owner._onLoadStarted(navigationAction.request.URL.absoluteString, navType); } } public webViewDidStartProvisionalNavigation(webView: WKWebView, navigation: WKNavigation): void { - if (isEnabled()) { - write("WKNavigationDelegateClass.webViewDidStartProvisionalNavigation(" + webView.URL + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WKNavigationDelegateClass.webViewDidStartProvisionalNavigation(" + webView.URL + ")", Trace.categories.Debug); } } public webViewDidFinishNavigation(webView: WKWebView, navigation: WKNavigation): void { - if (isEnabled()) { - write("WKNavigationDelegateClass.webViewDidFinishNavigation(" + webView.URL + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WKNavigationDelegateClass.webViewDidFinishNavigation(" + webView.URL + ")", Trace.categories.Debug); } const owner = this._owner.get(); if (owner) { @@ -73,8 +74,8 @@ class WKNavigationDelegateImpl extends NSObject if (webView.URL) { src = webView.URL.absoluteString; } - if (isEnabled()) { - write("WKNavigationDelegateClass.webViewDidFailNavigationWithError(" + error.localizedDescription + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WKNavigationDelegateClass.webViewDidFailNavigationWithError(" + error.localizedDescription + ")", Trace.categories.Debug); } owner._onLoadFinished(src, error.localizedDescription); } @@ -87,8 +88,8 @@ class WKNavigationDelegateImpl extends NSObject if (webView.URL) { src = webView.URL.absoluteString; } - if (isEnabled()) { - write("WKNavigationDelegateClass.webViewDidFailProvisionalNavigationWithError(" + error.localizedDescription + ")", categories.Debug); + if (Trace.isEnabled()) { + Trace.write("WKNavigationDelegateClass.webViewDidFailProvisionalNavigationWithError(" + error.localizedDescription + ")", Trace.categories.Debug); } owner._onLoadFinished(src, error.localizedDescription); } diff --git a/nativescript-core/utils/debug.d.ts b/nativescript-core/utils/debug.d.ts index 7e2be8d9f..fbf152729 100644 --- a/nativescript-core/utils/debug.d.ts +++ b/nativescript-core/utils/debug.d.ts @@ -1,7 +1,3 @@ -/** - * @module "utils/debug" - */ /** */ - /** * A runtime option indicating whether the build has debugging enabled. */ diff --git a/nativescript-core/utils/layout-helper/layout-helper.android.ts b/nativescript-core/utils/layout-helper/index.android.ts similarity index 100% rename from nativescript-core/utils/layout-helper/layout-helper.android.ts rename to nativescript-core/utils/layout-helper/index.android.ts diff --git a/nativescript-core/utils/layout-helper/layout-helper.d.ts b/nativescript-core/utils/layout-helper/index.d.ts similarity index 100% rename from nativescript-core/utils/layout-helper/layout-helper.d.ts rename to nativescript-core/utils/layout-helper/index.d.ts diff --git a/nativescript-core/utils/layout-helper/layout-helper.ios.ts b/nativescript-core/utils/layout-helper/index.ios.ts similarity index 100% rename from nativescript-core/utils/layout-helper/layout-helper.ios.ts rename to nativescript-core/utils/layout-helper/index.ios.ts diff --git a/nativescript-core/utils/layout-helper/package.json b/nativescript-core/utils/layout-helper/package.json deleted file mode 100644 index 4d020b6a2..000000000 --- a/nativescript-core/utils/layout-helper/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "layout-helper", - "main": "layout-helper", - "types": "layout-helper.d.ts", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/utils/lazy.d.ts b/nativescript-core/utils/lazy.d.ts index 4c1ced335..bac638454 100644 --- a/nativescript-core/utils/lazy.d.ts +++ b/nativescript-core/utils/lazy.d.ts @@ -1,7 +1,3 @@ -/** - * @module "utils/lazy" - */ /** */ - /** * A function that evaluates the action only once. * @param action The action to be evaluated to get the result. diff --git a/nativescript-core/utils/native-helper.android.ts b/nativescript-core/utils/native-helper.android.ts index 06c9cee04..8da735430 100644 --- a/nativescript-core/utils/native-helper.android.ts +++ b/nativescript-core/utils/native-helper.android.ts @@ -1,8 +1,6 @@ import { getNativeApplication, android as androidApp } from "../application"; import { - messageType as traceMessageType, - categories as traceCategories, - write as traceWrite + Trace } from "../trace"; // We are using "ad" here to avoid namespace collision with the global android object @@ -145,7 +143,7 @@ export module ad { } } catch (ex) { - traceWrite("Cannot get pallete color: " + name, traceCategories.Error, traceMessageType.error); + Trace.write("Cannot get pallete color: " + name, Trace.categories.Error, Trace.messageType.error); } attrCache.set(name, result); diff --git a/nativescript-core/utils/native-helper.ios.ts b/nativescript-core/utils/native-helper.ios.ts index 8c22fd09d..90dbaf418 100644 --- a/nativescript-core/utils/native-helper.ios.ts +++ b/nativescript-core/utils/native-helper.ios.ts @@ -1,7 +1,5 @@ import { - messageType as traceMessageType, - categories as traceCategories, - write as traceWrite + Trace } from "../trace"; declare var UIImagePickerControllerSourceType: any; @@ -24,7 +22,7 @@ function openFileAtRootModule(filePath: string): boolean { return controller.presentPreviewAnimated(true); } catch (e) { - traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error); + Trace.write("Error in openFile", Trace.categories.Error, Trace.messageType.error); } return false; diff --git a/nativescript-core/utils/package.json b/nativescript-core/utils/package.json deleted file mode 100644 index b0ab7187e..000000000 --- a/nativescript-core/utils/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nativescript": {} -} diff --git a/nativescript-core/utils/types.d.ts b/nativescript-core/utils/types.d.ts index f79b1e1a0..6eeaf3080 100644 --- a/nativescript-core/utils/types.d.ts +++ b/nativescript-core/utils/types.d.ts @@ -1,8 +1,4 @@ /** - * @module "utils/types" - */ /** */ - -/** * A function that checks if something is a valid string. * @param value The value which will be checked. * Returns true if value is a string. diff --git a/nativescript-core/utils/utils.android.ts b/nativescript-core/utils/utils.android.ts index 15f67c7c5..2cfbffe7d 100644 --- a/nativescript-core/utils/utils.android.ts +++ b/nativescript-core/utils/utils.android.ts @@ -2,9 +2,7 @@ import { ad } from "./native-helper"; import { device } from "../platform"; import { FileSystemAccess } from "../file-system/file-system-access"; import { - write as traceWrite, - categories as traceCategories, - messageType as traceMessageType, + Trace } from "../trace"; export { ad }; @@ -29,7 +27,7 @@ export function openUrl(location: string): boolean { context.startActivity(intent); } catch (e) { // We Don't do anything with an error. We just output it - traceWrite("Error in OpenURL", traceCategories.Error, traceMessageType.error); + Trace.write("Error in OpenURL", Trace.categories.Error, Trace.messageType.error); return false; } @@ -92,13 +90,13 @@ export function openFile(filePath: string): boolean { try { // Ensure external storage is available if (!isExternalStorageAvailable()) { - traceWrite( + Trace.write( ` External storage is unavailable (please check app permissions). Applications cannot access internal storage of other application on Android (see: https://developer.android.com/guide/topics/data/data-storage). `, - traceCategories.Error, - traceMessageType.error, + Trace.categories.Error, + Trace.messageType.error, ); return false; @@ -106,7 +104,7 @@ Applications cannot access internal storage of other application on Android (see // Ensure external storage is available if (isExternalStorageReadOnly()) { - traceWrite("External storage is read only", traceCategories.Error, traceMessageType.error); + Trace.write("External storage is read only", Trace.categories.Error, Trace.messageType.error); return false; } @@ -122,9 +120,9 @@ Applications cannot access internal storage of other application on Android (see // Android SDK <28 only requires starting the chooser Intent straight forwardly const sdkVersion = parseInt(device.sdkVersion, 10); if (sdkVersion && sdkVersion < MIN_URI_SHARE_RESTRICTED_APK_VERSION) { - traceWrite( + Trace.write( `detected sdk version ${sdkVersion} (< ${MIN_URI_SHARE_RESTRICTED_APK_VERSION}), using simple openFile`, - traceCategories.Debug + Trace.categories.Debug ); intent.setDataAndType(android.net.Uri.fromFile(new java.io.File(filePath)), mimeType); context.startActivity(chooserIntent); @@ -132,9 +130,9 @@ Applications cannot access internal storage of other application on Android (see return true; } - traceWrite( + Trace.write( `detected sdk version ${sdkVersion} (>= ${MIN_URI_SHARE_RESTRICTED_APK_VERSION}), using URI openFile`, - traceCategories.Debug + Trace.categories.Debug ); // Android SDK 24+ introduced file system permissions changes that disallow @@ -143,7 +141,7 @@ Applications cannot access internal storage of other application on Android (see // see: https://developer.android.com/reference/android/os/FileUriExposedException // see: https://github.com/NativeScript/NativeScript/issues/5661#issuecomment-456405380 const providerName = `${context.getPackageName()}.provider`; - traceWrite(`fully-qualified provider name [${providerName}]`, traceCategories.Debug); + Trace.write(`fully-qualified provider name [${providerName}]`, Trace.categories.Debug); const apkURI = androidx.core.content.FileProvider.getUriForFile( context, @@ -163,19 +161,19 @@ Applications cannot access internal storage of other application on Android (see return true; } catch (err) { const msg = err.message ? `: ${err.message}` : ""; - traceWrite(`Error in openFile${msg}`, traceCategories.Error, traceMessageType.error); + Trace.write(`Error in openFile${msg}`, Trace.categories.Error, Trace.messageType.error); if (msg && msg.includes("Attempt to invoke virtual method") && msg.includes("android.content.pm.ProviderInfo.loadXmlMetaData") && msg.includes("on a null object reference")) { // Alert user to possible fix - traceWrite( + Trace.write( ` Please ensure you have your manifest correctly configured with the FileProvider. (see: https://developer.android.com/reference/android/support/v4/content/FileProvider#ProviderDefinition) `, - traceCategories.Error, + Trace.categories.Error, ); } diff --git a/nativescript-core/utils/utils.d.ts b/nativescript-core/utils/utils.d.ts index 6a06237af..65d31441b 100644 --- a/nativescript-core/utils/utils.d.ts +++ b/nativescript-core/utils/utils.d.ts @@ -1,7 +1,3 @@ -/** - * @module "utils/utils" - */ /** */ - import { dip, px } from "../ui/core/view"; export * from "./mainthread-helper" diff --git a/nativescript-core/utils/utils.ios.ts b/nativescript-core/utils/utils.ios.ts index 31c013880..9f23507c8 100644 --- a/nativescript-core/utils/utils.ios.ts +++ b/nativescript-core/utils/utils.ios.ts @@ -1,6 +1,6 @@ import { ios } from "./native-helper"; import { - write as traceWrite, categories as traceCategories, messageType as traceMessageType + Trace } from "../trace"; export { ios }; @@ -17,7 +17,7 @@ export function openFile(filePath: string): boolean { return controller.presentPreviewAnimated(true); } catch (e) { - traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error); + Trace.write("Error in openFile", Trace.categories.Error, Trace.messageType.error); } return false; @@ -40,7 +40,7 @@ export function openUrl(location: string): boolean { } catch (e) { // We Don't do anything with an error. We just output it - traceWrite("Error in OpenURL", traceCategories.Error, traceMessageType.error); + Trace.write("Error in OpenURL", Trace.categories.Error, Trace.messageType.error); } return false; diff --git a/nativescript-core/xml/xml.d.ts b/nativescript-core/xml/xml.d.ts index c751746f3..9b2edda33 100644 --- a/nativescript-core/xml/xml.d.ts +++ b/nativescript-core/xml/xml.d.ts @@ -1,7 +1,6 @@ /** * Contains the XmlParser class, which is a SAX parser using the easysax implementation. - * @module "xml" - */ /** */ + */ /** * Specifies the type of parser event.