From 8f2900ad0bfa71773cd31d4352cb9c230a60e919 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sun, 5 Jul 2020 14:53:34 -0700 Subject: [PATCH] chore: cleanup reexports --- .prettierignore | 13 + .prettierrc.json | 6 + apps/package.json | 2 +- build/clear-private-definitions.ts | 2 +- e2e/animation/package.json | 2 +- e2e/cuteness.io/package.json | 2 +- e2e/file-qualifiers/package.json | 2 +- e2e/modal-navigation/package.json | 2 +- e2e/nested-frame-navigation/package.json | 2 +- e2e/scoped-packages/package.json | 2 +- e2e/ui-tests-app/package.json | 2 +- ...n-settings.android.ts => index.android.ts} | 0 .../{application-settings.d.ts => index.d.ts} | 0 ...plication-settings.ios.ts => index.ios.ts} | 0 .../application-settings/package.json | 6 - ...pplication.android.ts => index.android.ts} | 26 +- .../{application.d.ts => index.d.ts} | 0 .../{application.ios.ts => index.ios.ts} | 16 +- nativescript-core/application/package.json | 6 - nativescript-core/bundle-entry-points.ts | 3 +- .../cli-hooks/before-checkForChanges.js | 2 +- nativescript-core/cli-hooks/postinstall.js | 2 +- nativescript-core/cli-hooks/preuninstall.js | 2 +- .../{color.android.ts => index.android.ts} | 0 .../color/{color.d.ts => index.d.ts} | 0 .../color/{color.ios.ts => index.ios.ts} | 0 nativescript-core/color/package.json | 6 - ...nnectivity.android.ts => index.android.ts} | 0 .../{connectivity.d.ts => index.d.ts} | 0 .../{connectivity.ios.ts => index.ios.ts} | 0 nativescript-core/connectivity/package.json | 6 - .../console/{console.ts => index.ts} | 0 nativescript-core/console/package.json | 5 - nativescript-core/css/css-tree-parser.js | 131 +++++++++ nativescript-core/css/css-tree-parser.js.map | 1 + .../{observable-array.ts => index.ts} | 68 ++++- .../observable-array/observable-array.d.ts | 239 ---------------- .../data/observable-array/package.json | 5 - .../{observable.d.ts => index.d.ts} | 0 .../observable/{observable.ts => index.ts} | 0 .../data/observable/package.json | 5 - nativescript-core/data/package.json | 3 - nativescript-core/data/virtual-array/index.ts | 226 ++++++++++++++++ .../data/virtual-array/package.json | 5 - .../data/virtual-array/virtual-array.d.ts | 77 ------ .../data/virtual-array/virtual-array.ts | 165 ------------ nativescript-core/debugger/dom-node.d.ts | 7 +- nativescript-core/debugger/dom-node.ts | 2 +- .../debugger/{debugger.ts => index.ts} | 0 nativescript-core/debugger/package.json | 5 - .../debugger/webinspector-css.ios.ts | 2 +- .../debugger/webinspector-dom.ios.ts | 2 +- .../debugger/webinspector-network.ios.ts | 2 +- .../fetch/{fetch.js => index.js} | 0 nativescript-core/fetch/package.json | 5 - .../file-name-resolver.d.ts | 10 - .../{file-name-resolver.ts => index.ts} | 13 +- .../file-name-resolver/package.json | 5 - .../{file-system.d.ts => index.d.ts} | 0 .../file-system/{file-system.ts => index.ts} | 2 +- nativescript-core/file-system/package.json | 6 - .../fps-meter/{fps-meter.d.ts => index.d.ts} | 0 .../fps-meter/{fps-meter.ts => index.ts} | 0 nativescript-core/fps-meter/package.json | 6 - nativescript-core/globals/index.d.ts | 8 +- ...tp-request.android.ts => index.android.ts} | 2 +- .../{http-request.d.ts => index.d.ts} | 0 .../{http-request.ios.ts => index.ios.ts} | 2 +- .../http/http-request/package.json | 6 - .../http/{http.d.ts => index.d.ts} | 0 nativescript-core/http/{http.ts => index.ts} | 98 +++++++ nativescript-core/http/package.json | 6 - ...mage-asset.android.ts => index.android.ts} | 0 .../{image-asset.d.ts => index.d.ts} | 0 .../{image-asset.ios.ts => index.ios.ts} | 0 nativescript-core/image-asset/package.json | 6 - ...age-source.android.ts => index.android.ts} | 0 .../{image-source.d.ts => index.d.ts} | 0 .../{image-source.ios.ts => index.ios.ts} | 0 nativescript-core/image-source/package.json | 6 - nativescript-core/index.d.ts | 19 +- nativescript-core/index.ts | 17 +- .../matrix/{matrix.d.ts => index.d.ts} | 2 +- .../matrix/{matrix.ts => index.ts} | 2 +- nativescript-core/matrix/package.json | 6 - .../{module-name-resolver.d.ts => index.d.ts} | 0 .../{module-name-resolver.ts => index.ts} | 6 +- .../non-bundle-workflow-compat.ts | 2 +- .../module-name-resolver/package.json | 5 - .../{qualifier-matcher.d.ts => index.d.ts} | 0 .../{qualifier-matcher.ts => index.ts} | 8 +- .../qualifier-matcher/package.json | 5 - nativescript-core/module.d.ts | 2 +- .../{platform.android.ts => index.android.ts} | 0 .../platform/{platform.d.ts => index.d.ts} | 0 .../{platform.ios.ts => index.ios.ts} | 0 nativescript-core/platform/package.json | 6 - .../profiling/{profiling.d.ts => index.d.ts} | 0 .../profiling/{profiling.ts => index.ts} | 8 +- nativescript-core/profiling/package.json | 6 - .../{text.android.ts => index.android.ts} | 0 .../text/{text.d.ts => index.d.ts} | 0 .../text/{text.ios.ts => index.ios.ts} | 0 nativescript-core/text/package.json | 6 - .../{timer.android.ts => index.android.ts} | 0 .../timer/{timer.d.ts => index.d.ts} | 0 .../timer/{timer.ios.ts => index.ios.ts} | 0 nativescript-core/timer/package.json | 6 - nativescript-core/trace/index.ts | 20 +- .../ui/action-bar/action-bar-common.ts | 2 +- ...action-bar.android.ts => index.android.ts} | 2 +- .../{action-bar.d.ts => index.d.ts} | 0 .../{action-bar.ios.ts => index.ios.ts} | 11 +- nativescript-core/ui/action-bar/package.json | 5 - .../activity-indicator-common.ts | 4 +- ...-indicator.android.ts => index.android.ts} | 4 +- .../{activity-indicator.d.ts => index.d.ts} | 0 ...activity-indicator.ios.ts => index.ios.ts} | 7 +- .../ui/activity-indicator/package.json | 5 - ...{animation.android.ts => index.android.ts} | 0 .../animation/{animation.d.ts => index.d.ts} | 0 .../{animation.ios.ts => index.ios.ts} | 0 .../ui/animation/keyframe-animation.ts | 2 +- nativescript-core/ui/animation/package.json | 5 - nativescript-core/ui/border/border.d.ts | 11 - .../ui/border/{border.ts => index.ts} | 4 +- nativescript-core/ui/border/package.json | 5 - ...navigation.android.ts => index.android.ts} | 0 .../{bottom-navigation.d.ts => index.d.ts} | 0 ...{bottom-navigation.ios.ts => index.ios.ts} | 0 .../ui/bottom-navigation/package.json | 5 - .../component-builder/component-builder.ts | 6 +- .../ui/builder/{builder.d.ts => index.d.ts} | 0 .../ui/builder/{builder.ts => index.ts} | 17 +- nativescript-core/ui/builder/package.json | 5 - nativescript-core/ui/button/index.android.ts | 15 +- nativescript-core/ui/button/index.ios.ts | 17 +- .../view-base/{view-base.d.ts => index.d.ts} | 11 +- .../core/view-base/{view-base.ts => index.ts} | 76 +++++- .../ui/core/view-base/package.json | 5 - .../{view.android.ts => index.android.ts} | 16 +- .../ui/core/view/{view.d.ts => index.d.ts} | 0 .../core/view/{view.ios.ts => index.ios.ts} | 15 +- nativescript-core/ui/core/view/package.json | 5 - .../ui/dialogs/dialogs-common.ts | 6 +- .../editable-text-base.android.ts | 7 +- .../editable-text-base.ios.ts | 3 +- nativescript-core/ui/enums/enums.d.ts | 8 +- nativescript-core/ui/enums/enums.ts | 8 +- .../ui/frame/activity.android.ts | 2 +- .../ui/frame/fragment.transitions.android.ts | 2 +- .../ui/frame/fragment.transitions.ios.ts | 2 +- nativescript-core/ui/frame/frame-common.ts | 6 +- nativescript-core/ui/frame/frame.android.ts | 46 ++-- nativescript-core/ui/frame/frame.ios.ts | 10 +- .../{gestures.android.ts => index.android.ts} | 3 +- .../ui/gestures/{gestures.d.ts => index.d.ts} | 0 .../{gestures.ios.ts => index.ios.ts} | 3 +- nativescript-core/ui/gestures/package.json | 5 - ...mage-cache.android.ts => index.android.ts} | 4 +- .../{image-cache.d.ts => index.d.ts} | 0 .../{image-cache.ios.ts => index.ios.ts} | 14 +- nativescript-core/ui/image-cache/package.json | 5 - .../{image.android.ts => index.android.ts} | 8 +- .../ui/image/{image.d.ts => index.d.ts} | 0 .../ui/image/{image.ios.ts => index.ios.ts} | 0 nativescript-core/ui/image/package.json | 5 - .../{label.android.ts => index.android.ts} | 6 +- .../ui/label/{label.d.ts => index.d.ts} | 0 .../ui/label/{label.ios.ts => index.ios.ts} | 13 +- nativescript-core/ui/label/package.json | 5 - .../absolute-layout/absolute-layout-common.ts | 5 +- ...ute-layout.android.ts => index.android.ts} | 4 +- .../{absolute-layout.d.ts => index.d.ts} | 0 .../{absolute-layout.ios.ts => index.ios.ts} | 5 +- .../ui/layouts/absolute-layout/package.json | 5 - .../layouts/dock-layout/dock-layout-common.ts | 6 +- ...ock-layout.android.ts => index.android.ts} | 3 +- .../{dock-layout.d.ts => index.d.ts} | 0 .../{dock-layout.ios.ts => index.ios.ts} | 4 +- .../ui/layouts/dock-layout/package.json | 5 - .../flexbox-layout/flexbox-layout-common.ts | 8 +- ...box-layout.android.ts => index.android.ts} | 10 +- .../{flexbox-layout.d.ts => index.d.ts} | 0 .../{flexbox-layout.ios.ts => index.ios.ts} | 4 +- .../ui/layouts/flexbox-layout/package.json | 5 - .../layouts/grid-layout/grid-layout-common.ts | 7 +- ...rid-layout.android.ts => index.android.ts} | 4 +- .../{grid-layout.d.ts => index.d.ts} | 0 .../{grid-layout.ios.ts => index.ios.ts} | 4 +- .../ui/layouts/grid-layout/package.json | 5 - .../ui/layouts/layout-base.android.ts | 4 +- .../ui/layouts/layout-base.ios.ts | 3 +- nativescript-core/ui/layouts/package.json | 5 - ...ack-layout.android.ts => index.android.ts} | 0 .../{stack-layout.d.ts => index.d.ts} | 0 .../{stack-layout.ios.ts => index.ios.ts} | 9 +- .../ui/layouts/stack-layout/package.json | 5 - .../stack-layout/stack-layout-common.ts | 7 +- ...rap-layout.android.ts => index.android.ts} | 3 +- .../{wrap-layout.d.ts => index.d.ts} | 0 .../{wrap-layout.ios.ts => index.ios.ts} | 4 +- .../ui/layouts/wrap-layout/package.json | 5 - .../layouts/wrap-layout/wrap-layout-common.ts | 6 +- nativescript-core/ui/list-picker/index.ios.ts | 2 +- .../ui/list-view/index.android.ts | 11 +- nativescript-core/ui/list-view/index.ios.ts | 2 +- .../ui/list-view/list-view-common.ts | 2 +- nativescript-core/ui/package.json | 8 - nativescript-core/ui/page/index.android.ts | 2 +- nativescript-core/ui/page/index.ios.ts | 6 +- nativescript-core/ui/page/page-common.ts | 22 +- .../ui/progress/index.android.ts | 5 +- nativescript-core/ui/progress/index.ios.ts | 5 +- .../ui/proxy-view-container/index.ts | 2 +- nativescript-core/ui/repeater/index.ts | 2 +- .../ui/scroll-view/index.android.ts | 6 +- .../ui/scroll-view/scroll-view-common.ts | 10 +- ...search-bar.android.ts => index.android.ts} | 0 .../{search-bar.d.ts => index.d.ts} | 0 .../{search-bar.ios.ts => index.ios.ts} | 7 +- nativescript-core/ui/search-bar/package.json | 5 - ...mented-bar.android.ts => index.android.ts} | 6 +- .../{segmented-bar.d.ts => index.d.ts} | 0 .../{segmented-bar.ios.ts => index.ios.ts} | 5 +- .../ui/segmented-bar/package.json | 5 - .../{slider.android.ts => index.android.ts} | 5 +- .../ui/slider/{slider.d.ts => index.d.ts} | 0 .../ui/slider/{slider.ios.ts => index.ios.ts} | 6 +- nativescript-core/ui/slider/package.json | 5 - .../ui/styling/background-common.ts | 2 +- .../ui/styling/background.android.ts | 4 +- .../ui/styling/css-animation-parser.ts | 14 +- .../ui/styling/style-properties.ts | 20 +- nativescript-core/ui/styling/style-scope.ts | 42 +-- nativescript-core/ui/styling/style/index.ts | 21 ++ .../{switch.android.ts => index.android.ts} | 4 +- .../ui/switch/{switch.d.ts => index.d.ts} | 0 .../ui/switch/{switch.ios.ts => index.ios.ts} | 5 +- nativescript-core/ui/switch/package.json | 5 - nativescript-core/ui/switch/switch-common.ts | 4 +- ...ntent-item.android.ts => index.android.ts} | 0 .../{tab-content-item.d.ts => index.d.ts} | 0 .../{tab-content-item.ios.ts => index.ios.ts} | 0 .../tab-content-item/package.json | 5 - .../tab-content-item-common.ts | 3 +- .../{tab-navigation-base.d.ts => index.d.ts} | 0 .../{tab-navigation-base.ts => index.ts} | 25 +- .../tab-navigation-base/package.json | 5 - .../{tab-strip-item.d.ts => index.d.ts} | 4 +- .../{tab-strip-item.ts => index.ts} | 13 +- .../tab-strip-item/package.json | 5 - .../tab-strip/{tab-strip.d.ts => index.d.ts} | 0 .../tab-strip/{tab-strip.ts => index.ts} | 25 +- .../tab-strip/package.json | 5 - .../{tab-view.android.ts => index.android.ts} | 0 .../ui/tab-view/{tab-view.d.ts => index.d.ts} | 0 .../{tab-view.ios.ts => index.ios.ts} | 6 +- nativescript-core/ui/tab-view/package.json | 5 - .../{tabs.android.ts => index.android.ts} | 2 +- .../ui/tabs/{tabs.d.ts => index.d.ts} | 0 .../ui/tabs/{tabs.ios.ts => index.ios.ts} | 5 +- nativescript-core/ui/tabs/package.json | 5 - nativescript-core/ui/tabs/tabs-common.ts | 3 +- .../ui/text-base/index.android.ts | 20 +- nativescript-core/ui/text-base/index.d.ts | 4 + nativescript-core/ui/text-base/index.ios.ts | 6 +- .../ui/text-base/text-base-interfaces.ts | 9 +- ...text-field.android.ts => index.android.ts} | 4 +- .../{text-field.d.ts => index.d.ts} | 0 .../{text-field.ios.ts => index.ios.ts} | 10 +- nativescript-core/ui/text-field/package.json | 5 - ...{text-view.android.ts => index.android.ts} | 2 +- .../text-view/{text-view.d.ts => index.d.ts} | 0 .../{text-view.ios.ts => index.ios.ts} | 18 +- nativescript-core/ui/text-view/package.json | 5 - .../ui/text-view/text-view-common.ts | 2 +- ...ime-picker.android.ts => index.android.ts} | 0 .../{time-picker.d.ts => index.d.ts} | 0 .../{time-picker.ios.ts => index.ios.ts} | 4 +- nativescript-core/ui/time-picker/package.json | 5 - .../ui/transition/fade-transition.android.ts | 2 +- .../ui/transition/fade-transition.d.ts | 2 +- .../ui/transition/fade-transition.ios.ts | 2 +- .../ui/transition/flip-transition.android.ts | 2 +- .../ui/transition/flip-transition.d.ts | 2 +- ...transition.android.ts => index.android.ts} | 7 +- .../{transition.d.ts => index.d.ts} | 0 .../{transition.ios.ts => index.ios.ts} | 6 +- nativescript-core/ui/transition/package.json | 5 - .../ui/transition/slide-transition.android.ts | 2 +- .../ui/transition/slide-transition.d.ts | 2 +- .../ui/transition/slide-transition.ios.ts | 2 +- .../{web-view.android.ts => index.android.ts} | 0 .../ui/web-view/{web-view.d.ts => index.d.ts} | 0 .../{web-view.ios.ts => index.ios.ts} | 2 +- nativescript-core/ui/web-view/package.json | 5 - .../ui/web-view/web-view-interfaces.ts | 2 +- nativescript-core/xhr/{xhr.ts => index.ts} | 0 nativescript-core/xhr/package.json | 5 - .../xml/{xml.d.ts => index.d.ts} | 0 nativescript-core/xml/{xml.ts => index.ts} | 23 +- nativescript-core/xml/package.json | 6 - nativescript-core/xml/xml.js | 254 ------------------ package.json | 3 + tests/package.json | 2 +- 306 files changed, 1197 insertions(+), 1534 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.json rename nativescript-core/application-settings/{application-settings.android.ts => index.android.ts} (100%) rename nativescript-core/application-settings/{application-settings.d.ts => index.d.ts} (100%) rename nativescript-core/application-settings/{application-settings.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/application-settings/package.json rename nativescript-core/application/{application.android.ts => index.android.ts} (92%) rename nativescript-core/application/{application.d.ts => index.d.ts} (100%) rename nativescript-core/application/{application.ios.ts => index.ios.ts} (97%) delete mode 100644 nativescript-core/application/package.json rename nativescript-core/color/{color.android.ts => index.android.ts} (100%) rename nativescript-core/color/{color.d.ts => index.d.ts} (100%) rename nativescript-core/color/{color.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/color/package.json rename nativescript-core/connectivity/{connectivity.android.ts => index.android.ts} (100%) rename nativescript-core/connectivity/{connectivity.d.ts => index.d.ts} (100%) rename nativescript-core/connectivity/{connectivity.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/connectivity/package.json rename nativescript-core/console/{console.ts => index.ts} (100%) delete mode 100644 nativescript-core/console/package.json create mode 100644 nativescript-core/css/css-tree-parser.js create mode 100644 nativescript-core/css/css-tree-parser.js.map rename nativescript-core/data/observable-array/{observable-array.ts => index.ts} (87%) delete mode 100644 nativescript-core/data/observable-array/observable-array.d.ts delete mode 100644 nativescript-core/data/observable-array/package.json rename nativescript-core/data/observable/{observable.d.ts => index.d.ts} (100%) rename nativescript-core/data/observable/{observable.ts => index.ts} (100%) delete mode 100644 nativescript-core/data/observable/package.json delete mode 100644 nativescript-core/data/package.json create mode 100644 nativescript-core/data/virtual-array/index.ts delete mode 100644 nativescript-core/data/virtual-array/package.json delete mode 100644 nativescript-core/data/virtual-array/virtual-array.d.ts delete mode 100644 nativescript-core/data/virtual-array/virtual-array.ts rename nativescript-core/debugger/{debugger.ts => index.ts} (100%) delete mode 100644 nativescript-core/debugger/package.json rename nativescript-core/fetch/{fetch.js => index.js} (100%) delete mode 100644 nativescript-core/fetch/package.json delete mode 100644 nativescript-core/file-system/file-name-resolver/file-name-resolver.d.ts rename nativescript-core/file-system/file-name-resolver/{file-name-resolver.ts => index.ts} (86%) delete mode 100644 nativescript-core/file-system/file-name-resolver/package.json rename nativescript-core/file-system/{file-system.d.ts => index.d.ts} (100%) rename nativescript-core/file-system/{file-system.ts => index.ts} (99%) delete mode 100644 nativescript-core/file-system/package.json rename nativescript-core/fps-meter/{fps-meter.d.ts => index.d.ts} (100%) rename nativescript-core/fps-meter/{fps-meter.ts => index.ts} (100%) delete mode 100644 nativescript-core/fps-meter/package.json rename nativescript-core/http/http-request/{http-request.android.ts => index.android.ts} (99%) rename nativescript-core/http/http-request/{http-request.d.ts => index.d.ts} (100%) rename nativescript-core/http/http-request/{http-request.ios.ts => index.ios.ts} (99%) delete mode 100644 nativescript-core/http/http-request/package.json rename nativescript-core/http/{http.d.ts => index.d.ts} (100%) rename nativescript-core/http/{http.ts => index.ts} (58%) delete mode 100644 nativescript-core/http/package.json rename nativescript-core/image-asset/{image-asset.android.ts => index.android.ts} (100%) rename nativescript-core/image-asset/{image-asset.d.ts => index.d.ts} (100%) rename nativescript-core/image-asset/{image-asset.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/image-asset/package.json rename nativescript-core/image-source/{image-source.android.ts => index.android.ts} (100%) rename nativescript-core/image-source/{image-source.d.ts => index.d.ts} (100%) rename nativescript-core/image-source/{image-source.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/image-source/package.json rename nativescript-core/matrix/{matrix.d.ts => index.d.ts} (94%) rename nativescript-core/matrix/{matrix.ts => index.ts} (97%) delete mode 100644 nativescript-core/matrix/package.json rename nativescript-core/module-name-resolver/{module-name-resolver.d.ts => index.d.ts} (100%) rename nativescript-core/module-name-resolver/{module-name-resolver.ts => index.ts} (95%) delete mode 100644 nativescript-core/module-name-resolver/package.json rename nativescript-core/module-name-resolver/qualifier-matcher/{qualifier-matcher.d.ts => index.d.ts} (100%) rename nativescript-core/module-name-resolver/qualifier-matcher/{qualifier-matcher.ts => index.ts} (98%) delete mode 100644 nativescript-core/module-name-resolver/qualifier-matcher/package.json rename nativescript-core/platform/{platform.android.ts => index.android.ts} (100%) rename nativescript-core/platform/{platform.d.ts => index.d.ts} (100%) rename nativescript-core/platform/{platform.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/platform/package.json rename nativescript-core/profiling/{profiling.d.ts => index.d.ts} (100%) rename nativescript-core/profiling/{profiling.ts => index.ts} (98%) delete mode 100644 nativescript-core/profiling/package.json rename nativescript-core/text/{text.android.ts => index.android.ts} (100%) rename nativescript-core/text/{text.d.ts => index.d.ts} (100%) rename nativescript-core/text/{text.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/text/package.json rename nativescript-core/timer/{timer.android.ts => index.android.ts} (100%) rename nativescript-core/timer/{timer.d.ts => index.d.ts} (100%) rename nativescript-core/timer/{timer.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/timer/package.json rename nativescript-core/ui/action-bar/{action-bar.android.ts => index.android.ts} (99%) rename nativescript-core/ui/action-bar/{action-bar.d.ts => index.d.ts} (100%) rename nativescript-core/ui/action-bar/{action-bar.ios.ts => index.ios.ts} (97%) delete mode 100644 nativescript-core/ui/action-bar/package.json rename nativescript-core/ui/activity-indicator/{activity-indicator.android.ts => index.android.ts} (90%) rename nativescript-core/ui/activity-indicator/{activity-indicator.d.ts => index.d.ts} (100%) rename nativescript-core/ui/activity-indicator/{activity-indicator.ios.ts => index.ios.ts} (89%) delete mode 100644 nativescript-core/ui/activity-indicator/package.json rename nativescript-core/ui/animation/{animation.android.ts => index.android.ts} (100%) rename nativescript-core/ui/animation/{animation.d.ts => index.d.ts} (100%) rename nativescript-core/ui/animation/{animation.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/ui/animation/package.json delete mode 100644 nativescript-core/ui/border/border.d.ts rename nativescript-core/ui/border/{border.ts => index.ts} (93%) delete mode 100644 nativescript-core/ui/border/package.json rename nativescript-core/ui/bottom-navigation/{bottom-navigation.android.ts => index.android.ts} (100%) rename nativescript-core/ui/bottom-navigation/{bottom-navigation.d.ts => index.d.ts} (100%) rename nativescript-core/ui/bottom-navigation/{bottom-navigation.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/ui/bottom-navigation/package.json rename nativescript-core/ui/builder/{builder.d.ts => index.d.ts} (100%) rename nativescript-core/ui/builder/{builder.ts => index.ts} (98%) delete mode 100644 nativescript-core/ui/builder/package.json rename nativescript-core/ui/core/view-base/{view-base.d.ts => index.d.ts} (97%) rename nativescript-core/ui/core/view-base/{view-base.ts => index.ts} (94%) delete mode 100644 nativescript-core/ui/core/view-base/package.json rename nativescript-core/ui/core/view/{view.android.ts => index.android.ts} (99%) rename nativescript-core/ui/core/view/{view.d.ts => index.d.ts} (100%) rename nativescript-core/ui/core/view/{view.ios.ts => index.ios.ts} (98%) delete mode 100644 nativescript-core/ui/core/view/package.json rename nativescript-core/ui/gestures/{gestures.android.ts => index.android.ts} (99%) rename nativescript-core/ui/gestures/{gestures.d.ts => index.d.ts} (100%) rename nativescript-core/ui/gestures/{gestures.ios.ts => index.ios.ts} (99%) delete mode 100644 nativescript-core/ui/gestures/package.json rename nativescript-core/ui/image-cache/{image-cache.android.ts => index.android.ts} (94%) rename nativescript-core/ui/image-cache/{image-cache.d.ts => index.d.ts} (100%) rename nativescript-core/ui/image-cache/{image-cache.ios.ts => index.ios.ts} (86%) delete mode 100644 nativescript-core/ui/image-cache/package.json rename nativescript-core/ui/image/{image.android.ts => index.android.ts} (94%) rename nativescript-core/ui/image/{image.d.ts => index.d.ts} (100%) rename nativescript-core/ui/image/{image.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/ui/image/package.json rename nativescript-core/ui/label/{label.android.ts => index.android.ts} (88%) rename nativescript-core/ui/label/{label.d.ts => index.d.ts} (100%) rename nativescript-core/ui/label/{label.ios.ts => index.ios.ts} (95%) delete mode 100644 nativescript-core/ui/label/package.json rename nativescript-core/ui/layouts/absolute-layout/{absolute-layout.android.ts => index.android.ts} (85%) rename nativescript-core/ui/layouts/absolute-layout/{absolute-layout.d.ts => index.d.ts} (100%) rename nativescript-core/ui/layouts/absolute-layout/{absolute-layout.ios.ts => index.ios.ts} (93%) delete mode 100644 nativescript-core/ui/layouts/absolute-layout/package.json rename nativescript-core/ui/layouts/dock-layout/{dock-layout.android.ts => index.android.ts} (91%) rename nativescript-core/ui/layouts/dock-layout/{dock-layout.d.ts => index.d.ts} (100%) rename nativescript-core/ui/layouts/dock-layout/{dock-layout.ios.ts => index.ios.ts} (97%) delete mode 100644 nativescript-core/ui/layouts/dock-layout/package.json rename nativescript-core/ui/layouts/flexbox-layout/{flexbox-layout.android.ts => index.android.ts} (96%) rename nativescript-core/ui/layouts/flexbox-layout/{flexbox-layout.d.ts => index.d.ts} (100%) rename nativescript-core/ui/layouts/flexbox-layout/{flexbox-layout.ios.ts => index.ios.ts} (99%) delete mode 100644 nativescript-core/ui/layouts/flexbox-layout/package.json rename nativescript-core/ui/layouts/grid-layout/{grid-layout.android.ts => index.android.ts} (96%) rename nativescript-core/ui/layouts/grid-layout/{grid-layout.d.ts => index.d.ts} (100%) rename nativescript-core/ui/layouts/grid-layout/{grid-layout.ios.ts => index.ios.ts} (99%) delete mode 100644 nativescript-core/ui/layouts/grid-layout/package.json delete mode 100644 nativescript-core/ui/layouts/package.json rename nativescript-core/ui/layouts/stack-layout/{stack-layout.android.ts => index.android.ts} (100%) rename nativescript-core/ui/layouts/stack-layout/{stack-layout.d.ts => index.d.ts} (100%) rename nativescript-core/ui/layouts/stack-layout/{stack-layout.ios.ts => index.ios.ts} (95%) delete mode 100644 nativescript-core/ui/layouts/stack-layout/package.json rename nativescript-core/ui/layouts/wrap-layout/{wrap-layout.android.ts => index.android.ts} (88%) rename nativescript-core/ui/layouts/wrap-layout/{wrap-layout.d.ts => index.d.ts} (100%) rename nativescript-core/ui/layouts/wrap-layout/{wrap-layout.ios.ts => index.ios.ts} (98%) delete mode 100644 nativescript-core/ui/layouts/wrap-layout/package.json delete mode 100644 nativescript-core/ui/package.json rename nativescript-core/ui/search-bar/{search-bar.android.ts => index.android.ts} (100%) rename nativescript-core/ui/search-bar/{search-bar.d.ts => index.d.ts} (100%) rename nativescript-core/ui/search-bar/{search-bar.ios.ts => index.ios.ts} (96%) delete mode 100644 nativescript-core/ui/search-bar/package.json rename nativescript-core/ui/segmented-bar/{segmented-bar.android.ts => index.android.ts} (97%) rename nativescript-core/ui/segmented-bar/{segmented-bar.d.ts => index.d.ts} (100%) rename nativescript-core/ui/segmented-bar/{segmented-bar.ios.ts => index.ios.ts} (96%) delete mode 100644 nativescript-core/ui/segmented-bar/package.json rename nativescript-core/ui/slider/{slider.android.ts => index.android.ts} (96%) rename nativescript-core/ui/slider/{slider.d.ts => index.d.ts} (100%) rename nativescript-core/ui/slider/{slider.ios.ts => index.ios.ts} (94%) delete mode 100644 nativescript-core/ui/slider/package.json rename nativescript-core/ui/switch/{switch.android.ts => index.android.ts} (94%) rename nativescript-core/ui/switch/{switch.d.ts => index.d.ts} (100%) rename nativescript-core/ui/switch/{switch.ios.ts => index.ios.ts} (93%) delete mode 100644 nativescript-core/ui/switch/package.json rename nativescript-core/ui/tab-navigation-base/tab-content-item/{tab-content-item.android.ts => index.android.ts} (100%) rename nativescript-core/ui/tab-navigation-base/tab-content-item/{tab-content-item.d.ts => index.d.ts} (100%) rename nativescript-core/ui/tab-navigation-base/tab-content-item/{tab-content-item.ios.ts => index.ios.ts} (100%) delete mode 100644 nativescript-core/ui/tab-navigation-base/tab-content-item/package.json rename nativescript-core/ui/tab-navigation-base/tab-navigation-base/{tab-navigation-base.d.ts => index.d.ts} (100%) rename nativescript-core/ui/tab-navigation-base/tab-navigation-base/{tab-navigation-base.ts => index.ts} (92%) delete mode 100644 nativescript-core/ui/tab-navigation-base/tab-navigation-base/package.json rename nativescript-core/ui/tab-navigation-base/tab-strip-item/{tab-strip-item.d.ts => index.d.ts} (95%) rename nativescript-core/ui/tab-navigation-base/tab-strip-item/{tab-strip-item.ts => index.ts} (96%) delete mode 100644 nativescript-core/ui/tab-navigation-base/tab-strip-item/package.json rename nativescript-core/ui/tab-navigation-base/tab-strip/{tab-strip.d.ts => index.d.ts} (100%) rename nativescript-core/ui/tab-navigation-base/tab-strip/{tab-strip.ts => index.ts} (88%) delete mode 100644 nativescript-core/ui/tab-navigation-base/tab-strip/package.json rename nativescript-core/ui/tab-view/{tab-view.android.ts => index.android.ts} (100%) rename nativescript-core/ui/tab-view/{tab-view.d.ts => index.d.ts} (100%) rename nativescript-core/ui/tab-view/{tab-view.ios.ts => index.ios.ts} (99%) delete mode 100644 nativescript-core/ui/tab-view/package.json rename nativescript-core/ui/tabs/{tabs.android.ts => index.android.ts} (99%) rename nativescript-core/ui/tabs/{tabs.d.ts => index.d.ts} (100%) rename nativescript-core/ui/tabs/{tabs.ios.ts => index.ios.ts} (99%) delete mode 100644 nativescript-core/ui/tabs/package.json rename nativescript-core/ui/text-field/{text-field.android.ts => index.android.ts} (95%) rename nativescript-core/ui/text-field/{text-field.d.ts => index.d.ts} (100%) rename nativescript-core/ui/text-field/{text-field.ios.ts => index.ios.ts} (95%) delete mode 100644 nativescript-core/ui/text-field/package.json rename nativescript-core/ui/text-view/{text-view.android.ts => index.android.ts} (95%) rename nativescript-core/ui/text-view/{text-view.d.ts => index.d.ts} (100%) rename nativescript-core/ui/text-view/{text-view.ios.ts => index.ios.ts} (96%) delete mode 100644 nativescript-core/ui/text-view/package.json rename nativescript-core/ui/time-picker/{time-picker.android.ts => index.android.ts} (100%) rename nativescript-core/ui/time-picker/{time-picker.d.ts => index.d.ts} (100%) rename nativescript-core/ui/time-picker/{time-picker.ios.ts => index.ios.ts} (97%) delete mode 100644 nativescript-core/ui/time-picker/package.json rename nativescript-core/ui/transition/{transition.android.ts => index.android.ts} (90%) rename nativescript-core/ui/transition/{transition.d.ts => index.d.ts} (100%) rename nativescript-core/ui/transition/{transition.ios.ts => index.ios.ts} (86%) delete mode 100644 nativescript-core/ui/transition/package.json rename nativescript-core/ui/web-view/{web-view.android.ts => index.android.ts} (100%) rename nativescript-core/ui/web-view/{web-view.d.ts => index.d.ts} (100%) rename nativescript-core/ui/web-view/{web-view.ios.ts => index.ios.ts} (99%) delete mode 100644 nativescript-core/ui/web-view/package.json rename nativescript-core/xhr/{xhr.ts => index.ts} (100%) delete mode 100644 nativescript-core/xhr/package.json rename nativescript-core/xml/{xml.d.ts => index.d.ts} (100%) rename nativescript-core/xml/{xml.ts => index.ts} (95%) delete mode 100644 nativescript-core/xml/package.json delete mode 100644 nativescript-core/xml/xml.js diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..28862af86 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +# Ignore artifacts: +build +coverage +dist +e2e +js-libs +platforms +tests +tns-core-modules-package +tns-core-modules-widgets +tns-platform-declarations +temp +unit-tests \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..045aa41e3 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "extends": [ + "tslint:latest", + "tslint-config-prettier" + ] +} \ No newline at end of file diff --git a/apps/package.json b/apps/package.json index 605616833..0d6b24748 100644 --- a/apps/package.json +++ b/apps/package.json @@ -15,7 +15,7 @@ "tns-core-modules": "file:../tns-core-modules" }, "devDependencies": { - "nativescript-dev-webpack": "next", + "@nativescript/webpack": "^2.0.0-alpha.3", "node-sass": "^4.12.0", "typescript": "~3.4.1" }, diff --git a/build/clear-private-definitions.ts b/build/clear-private-definitions.ts index 933ff0235..cf039b6cc 100644 --- a/build/clear-private-definitions.ts +++ b/build/clear-private-definitions.ts @@ -41,7 +41,7 @@ readdirp(inputFolder, { } else if (shouldReplace) { console.log("[Cleared]", fullPath); try { - fs.writeFileSync(fullPath, newContent, "utf8"); + fs.writeFileSync(fullPath, newContent || '', "utf8"); } catch (error) { console.log("ERROR writing file: " + fullPath, error); process.exit(1); diff --git a/e2e/animation/package.json b/e2e/animation/package.json index 0580eb7fc..af7e265c9 100644 --- a/e2e/animation/package.json +++ b/e2e/animation/package.json @@ -28,7 +28,7 @@ "mocha": "~5.2.0", "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", - "nativescript-dev-webpack": "next", + "@nativescript/webpack": "^2.0.0-alpha.3", "typescript": "~3.4.1" }, "scripts": { diff --git a/e2e/cuteness.io/package.json b/e2e/cuteness.io/package.json index 8d2e118d2..2b971735a 100644 --- a/e2e/cuteness.io/package.json +++ b/e2e/cuteness.io/package.json @@ -17,7 +17,7 @@ "tns-core-modules": "file:../../dist/tns-core-modules" }, "devDependencies": { - "nativescript-dev-webpack": "next", + "@nativescript/webpack": "^2.0.0-alpha.3", "typescript": "3.4.5" }, "gitHead": "8c1a4866a66daab09bf5ef8e5a96472687192373", diff --git a/e2e/file-qualifiers/package.json b/e2e/file-qualifiers/package.json index 3a0ccdebd..f0f1679aa 100644 --- a/e2e/file-qualifiers/package.json +++ b/e2e/file-qualifiers/package.json @@ -18,7 +18,7 @@ "tns-core-modules": "file:../../dist/tns-core-modules" }, "devDependencies": { - "nativescript-dev-webpack": "next", + "@nativescript/webpack": "^2.0.0-alpha.3", "typescript": "3.4.5" } } diff --git a/e2e/modal-navigation/package.json b/e2e/modal-navigation/package.json index f0d64fbf0..e39af3701 100644 --- a/e2e/modal-navigation/package.json +++ b/e2e/modal-navigation/package.json @@ -24,7 +24,7 @@ "mocha": "~5.2.0", "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", - "nativescript-dev-webpack": "next", + "@nativescript/webpack": "^2.0.0-alpha.3", "rimraf": "^2.6.2", "tns-platform-declarations": "file:../../tns-platform-declarations", "typescript": "~3.4.1" diff --git a/e2e/nested-frame-navigation/package.json b/e2e/nested-frame-navigation/package.json index 9d44b303d..4c00607fa 100644 --- a/e2e/nested-frame-navigation/package.json +++ b/e2e/nested-frame-navigation/package.json @@ -24,7 +24,7 @@ "mocha": "~5.2.0", "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", - "nativescript-dev-webpack": "next", + "@nativescript/webpack": "^2.0.0-alpha.3", "rimraf": "^2.6.2", "typescript": "~3.4.1" }, diff --git a/e2e/scoped-packages/package.json b/e2e/scoped-packages/package.json index bd4a487aa..d700b6e99 100644 --- a/e2e/scoped-packages/package.json +++ b/e2e/scoped-packages/package.json @@ -18,7 +18,7 @@ "tns-core-modules": "file:../../dist/tns-core-modules-6.6.0.tgz" }, "devDependencies": { - "nativescript-dev-webpack": "~1.2.0", + "@nativescript/webpack": "^2.0.0-alpha.3", "typescript": "~3.5.3" }, "gitHead": "5fa096231ded5351b53700f0d111d60160e52ebc", diff --git a/e2e/ui-tests-app/package.json b/e2e/ui-tests-app/package.json index caf6f5d4e..086c744af 100644 --- a/e2e/ui-tests-app/package.json +++ b/e2e/ui-tests-app/package.json @@ -28,7 +28,7 @@ "mocha-typescript": "^1.1.17", "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", - "nativescript-dev-webpack": "next", + "@nativescript/webpack": "^2.0.0-alpha.3", "tns-platform-declarations": "file:../../tns-platform-declarations", "typescript": "~3.4.1" }, diff --git a/nativescript-core/application-settings/application-settings.android.ts b/nativescript-core/application-settings/index.android.ts similarity index 100% rename from nativescript-core/application-settings/application-settings.android.ts rename to nativescript-core/application-settings/index.android.ts diff --git a/nativescript-core/application-settings/application-settings.d.ts b/nativescript-core/application-settings/index.d.ts similarity index 100% rename from nativescript-core/application-settings/application-settings.d.ts rename to nativescript-core/application-settings/index.d.ts diff --git a/nativescript-core/application-settings/application-settings.ios.ts b/nativescript-core/application-settings/index.ios.ts similarity index 100% rename from nativescript-core/application-settings/application-settings.ios.ts rename to nativescript-core/application-settings/index.ios.ts diff --git a/nativescript-core/application-settings/package.json b/nativescript-core/application-settings/package.json deleted file mode 100644 index 3cefc662a..000000000 --- a/nativescript-core/application-settings/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "application-settings", - "main": "application-settings", - "types": "application-settings.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/application/application.android.ts b/nativescript-core/application/index.android.ts similarity index 92% rename from nativescript-core/application/application.android.ts rename to nativescript-core/application/index.android.ts index bf45c01c1..2a15225d5 100644 --- a/nativescript-core/application/application.android.ts +++ b/nativescript-core/application/index.android.ts @@ -333,21 +333,21 @@ function initLifecycleCallbacks() { }); const lifecycleCallbacks = new android.app.Application.ActivityLifecycleCallbacks({ - onActivityCreated: profile("onActivityCreated", function (activity: androidx.appcompat.app.AppCompatActivity, savedInstanceState: android.os.Bundle) { - setThemeOnLaunch(activity); + onActivityCreated: profile("onActivityCreated", function (activity: androidx.appcompat.app.AppCompatActivity, savedInstanceState: android.os.Bundle) { + setThemeOnLaunch(activity, undefined, undefined); if (!androidApp.startActivity) { androidApp.startActivity = activity; } - notifyActivityCreated(activity, savedInstanceState); + notifyActivityCreated(activity, savedInstanceState, undefined); if (hasListeners(displayedEvent)) { - subscribeForGlobalLayout(activity); + subscribeForGlobalLayout(activity, undefined, undefined); } }), - onActivityDestroyed: profile("onActivityDestroyed", function (activity: androidx.appcompat.app.AppCompatActivity) { + onActivityDestroyed: profile("onActivityDestroyed", function (activity: androidx.appcompat.app.AppCompatActivity) { if (activity === androidApp.foregroundActivity) { androidApp.foregroundActivity = undefined; } @@ -361,7 +361,7 @@ function initLifecycleCallbacks() { gc(); }), - onActivityPaused: profile("onActivityPaused", function (activity: androidx.appcompat.app.AppCompatActivity) { + onActivityPaused: profile("onActivityPaused", function (activity: androidx.appcompat.app.AppCompatActivity) { if ((activity).isNativeScriptActivity) { androidApp.paused = true; notify({ eventName: suspendEvent, object: androidApp, android: activity }); @@ -370,21 +370,21 @@ function initLifecycleCallbacks() { androidApp.notify({ eventName: ActivityPaused, object: androidApp, activity: activity }); }), - onActivityResumed: profile("onActivityResumed", function (activity: androidx.appcompat.app.AppCompatActivity) { + onActivityResumed: profile("onActivityResumed", function (activity: androidx.appcompat.app.AppCompatActivity) { androidApp.foregroundActivity = activity; androidApp.notify({ eventName: ActivityResumed, object: androidApp, activity: activity }); }), - onActivitySaveInstanceState: profile("onActivitySaveInstanceState", function (activity: androidx.appcompat.app.AppCompatActivity, outState: android.os.Bundle) { + onActivitySaveInstanceState: profile("onActivitySaveInstanceState", function (activity: androidx.appcompat.app.AppCompatActivity, outState: android.os.Bundle) { androidApp.notify({ eventName: SaveActivityState, object: androidApp, activity: activity, bundle: outState }); }), - onActivityStarted: profile("onActivityStarted", function (activity: androidx.appcompat.app.AppCompatActivity) { + onActivityStarted: profile("onActivityStarted", function (activity: androidx.appcompat.app.AppCompatActivity) { androidApp.notify({ eventName: ActivityStarted, object: androidApp, activity: activity }); }), - onActivityStopped: profile("onActivityStopped", function (activity: androidx.appcompat.app.AppCompatActivity) { + onActivityStopped: profile("onActivityStopped", function (activity: androidx.appcompat.app.AppCompatActivity) { androidApp.notify({ eventName: ActivityStopped, object: androidApp, activity: activity }); }) }); @@ -394,17 +394,17 @@ function initLifecycleCallbacks() { function initComponentCallbacks() { let componentCallbacks = new android.content.ComponentCallbacks2({ - onLowMemory: profile("onLowMemory", function () { + onLowMemory: profile("onLowMemory", function () { gc(); java.lang.System.gc(); notify({ eventName: lowMemoryEvent, object: this, android: this }); }), - onTrimMemory: profile("onTrimMemory", function (level: number) { + onTrimMemory: profile("onTrimMemory", function (level: number) { // TODO: This is skipped for now, test carefully for OutOfMemory exceptions }), - onConfigurationChanged: profile("onConfigurationChanged", function (newConfiguration: android.content.res.Configuration) { + onConfigurationChanged: profile("onConfigurationChanged", function (newConfiguration: android.content.res.Configuration) { const rootView = getRootView(); const newOrientation = getOrientationValue(newConfiguration); diff --git a/nativescript-core/application/application.d.ts b/nativescript-core/application/index.d.ts similarity index 100% rename from nativescript-core/application/application.d.ts rename to nativescript-core/application/index.d.ts diff --git a/nativescript-core/application/application.ios.ts b/nativescript-core/application/index.ios.ts similarity index 97% rename from nativescript-core/application/application.ios.ts rename to nativescript-core/application/index.ios.ts index f156cda3d..2f8a47167 100644 --- a/nativescript-core/application/application.ios.ts +++ b/nativescript-core/application/index.ios.ts @@ -28,8 +28,8 @@ import { pushToSystemCssClasses, ROOT_VIEW_CSS_CLASS } from "../css/system-classes"; -import { ios as iosViewHelper } from "../ui/core/view/view-helper"; -import { device } from "../platform/platform"; +import { IOSHelper } from "../ui/core/view/view-helper"; +import { device } from "../platform"; import { profile } from "../profiling"; import { ios } from "../utils/utils"; @@ -176,7 +176,7 @@ export class iOSApplication implements iOSApplicationDefinition { } } - @profile + @profile() private didFinishLaunchingWithOptions(notification: NSNotification) { if (!displayedOnce) { displayedLinkTarget = CADisplayLinkTarget.new(); @@ -210,7 +210,7 @@ export class iOSApplication implements iOSApplicationDefinition { } } - @profile + @profile() private didBecomeActive(notification: NSNotification) { const ios = UIApplication.sharedApplication; const object = this; @@ -310,7 +310,7 @@ export class iOSApplication implements iOSApplicationDefinition { this._window.makeKeyAndVisible(); } - rootView.on(iosViewHelper.traitCollectionColorAppearanceChangedEvent, () => { + rootView.on(IOSHelper.traitCollectionColorAppearanceChangedEvent, () => { const userInterfaceStyle = controller.traitCollection.userInterfaceStyle; const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle); @@ -396,7 +396,7 @@ export function run(entry?: string | NavigationEntry) { // Mind root view CSS classes in future work // on embedding NativeScript applications setRootViewsSystemAppearanceCssClass(rootView); - rootView.on(iosViewHelper.traitCollectionColorAppearanceChangedEvent, () => { + rootView.on(IOSHelper.traitCollectionColorAppearanceChangedEvent, () => { const userInterfaceStyle = controller.traitCollection.userInterfaceStyle; const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle); @@ -453,7 +453,7 @@ function getViewController(rootView: View): UIViewController { if (!(viewController instanceof UIViewController)) { // We set UILayoutViewController dynamically to the root view if it doesn't have a view controller // At the moment the root view doesn't have its native view created. We set it in the setViewControllerView func - viewController = iosViewHelper.UILayoutViewController.initWithOwner(new WeakRef(rootView)) as UIViewController; + viewController = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(rootView)) as UIViewController; rootView.viewController = viewController; } @@ -468,7 +468,7 @@ function setViewControllerView(view: View): void { throw new Error("Root should be either UIViewController or UIView"); } - if (viewController instanceof iosViewHelper.UILayoutViewController) { + if (viewController instanceof IOSHelper.UILayoutViewController) { viewController.view.addSubview(nativeView); } } diff --git a/nativescript-core/application/package.json b/nativescript-core/application/package.json deleted file mode 100644 index a13fb136b..000000000 --- a/nativescript-core/application/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "application", - "main": "application", - "types": "application.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/bundle-entry-points.ts b/nativescript-core/bundle-entry-points.ts index b5eb080be..481e218e2 100644 --- a/nativescript-core/bundle-entry-points.ts +++ b/nativescript-core/bundle-entry-points.ts @@ -1,5 +1,6 @@ if (global.TNS_WEBPACK) { - require("./globals"); + const g = require("./globals"); + g.initGlobal(); // Register "dynamically" loaded module that need to be resolved by the // XML/component builders. diff --git a/nativescript-core/cli-hooks/before-checkForChanges.js b/nativescript-core/cli-hooks/before-checkForChanges.js index ada6a55fe..79f5be491 100644 --- a/nativescript-core/cli-hooks/before-checkForChanges.js +++ b/nativescript-core/cli-hooks/before-checkForChanges.js @@ -1,6 +1,6 @@ const semver = require("semver"); -const webpackPackageName = "nativescript-dev-webpack"; +const webpackPackageName = "@nativescript/webpack"; module.exports = function ($staticConfig, hookArgs) { const cliVersion = semver.parse($staticConfig.version); diff --git a/nativescript-core/cli-hooks/postinstall.js b/nativescript-core/cli-hooks/postinstall.js index edb7e56fe..01b05b46a 100644 --- a/nativescript-core/cli-hooks/postinstall.js +++ b/nativescript-core/cli-hooks/postinstall.js @@ -1,2 +1,2 @@ const path = require('path'); -require('nativescript-hook')(path.join(__dirname, "..")).postinstall(); \ No newline at end of file +require('@nativescript/hook')(path.join(__dirname, "..")).postinstall(); \ No newline at end of file diff --git a/nativescript-core/cli-hooks/preuninstall.js b/nativescript-core/cli-hooks/preuninstall.js index f3cff5272..90f31ba7d 100644 --- a/nativescript-core/cli-hooks/preuninstall.js +++ b/nativescript-core/cli-hooks/preuninstall.js @@ -1,2 +1,2 @@ const path = require('path'); -require('nativescript-hook')(path.join(__dirname, "..")).preuninstall(); \ No newline at end of file +require('@nativescript/hook')(path.join(__dirname, "..")).preuninstall(); \ No newline at end of file diff --git a/nativescript-core/color/color.android.ts b/nativescript-core/color/index.android.ts similarity index 100% rename from nativescript-core/color/color.android.ts rename to nativescript-core/color/index.android.ts diff --git a/nativescript-core/color/color.d.ts b/nativescript-core/color/index.d.ts similarity index 100% rename from nativescript-core/color/color.d.ts rename to nativescript-core/color/index.d.ts diff --git a/nativescript-core/color/color.ios.ts b/nativescript-core/color/index.ios.ts similarity index 100% rename from nativescript-core/color/color.ios.ts rename to nativescript-core/color/index.ios.ts diff --git a/nativescript-core/color/package.json b/nativescript-core/color/package.json deleted file mode 100644 index ce6dee20e..000000000 --- a/nativescript-core/color/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "color", - "main": "color", - "types": "color.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/connectivity/connectivity.android.ts b/nativescript-core/connectivity/index.android.ts similarity index 100% rename from nativescript-core/connectivity/connectivity.android.ts rename to nativescript-core/connectivity/index.android.ts diff --git a/nativescript-core/connectivity/connectivity.d.ts b/nativescript-core/connectivity/index.d.ts similarity index 100% rename from nativescript-core/connectivity/connectivity.d.ts rename to nativescript-core/connectivity/index.d.ts diff --git a/nativescript-core/connectivity/connectivity.ios.ts b/nativescript-core/connectivity/index.ios.ts similarity index 100% rename from nativescript-core/connectivity/connectivity.ios.ts rename to nativescript-core/connectivity/index.ios.ts diff --git a/nativescript-core/connectivity/package.json b/nativescript-core/connectivity/package.json deleted file mode 100644 index 3d4583a81..000000000 --- a/nativescript-core/connectivity/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "connectivity", - "main": "connectivity", - "types": "connectivity.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/console/console.ts b/nativescript-core/console/index.ts similarity index 100% rename from nativescript-core/console/console.ts rename to nativescript-core/console/index.ts diff --git a/nativescript-core/console/package.json b/nativescript-core/console/package.json deleted file mode 100644 index d8c80ade0..000000000 --- a/nativescript-core/console/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "console", - "main": "console", - "nativescript": {} -} diff --git a/nativescript-core/css/css-tree-parser.js b/nativescript-core/css/css-tree-parser.js new file mode 100644 index 000000000..b0d183bd5 --- /dev/null +++ b/nativescript-core/css/css-tree-parser.js @@ -0,0 +1,131 @@ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.cssTreeParse = void 0; +var css_tree_1 = require("css-tree"); +function mapSelectors(selector) { + if (!selector) { + return []; + } + return selector.split(/\s*(?![^(]*\)),\s*/).map(function (s) { return s.replace(/\u200C/g, ","); }); +} +function mapPosition(node, css) { + var res = { + start: { + line: node.loc.start.line, + column: node.loc.start.column + }, + end: { + line: node.loc.end.line, + column: node.loc.end.column + }, + content: css + }; + if (node.loc.source && node.loc.source !== "") { + res.source = node.loc.source; + } + return res; +} +function transformAst(node, css, type) { + if (type === void 0) { type = null; } + if (!node) { + return; + } + if (node.type === "StyleSheet") { + return { + type: "stylesheet", + stylesheet: { + rules: node.children.map(function (child) { return transformAst(child, css); }).filter(function (child) { return child !== null; }).toArray(), + parsingErrors: [] + } + }; + } + if (node.type === "Atrule") { + var atrule = { + type: node.name, + }; + if (node.name === "supports" || node.name === "media") { + atrule[node.name] = node.prelude.value; + atrule.rules = transformAst(node.block, css); + } + else if (node.name === "page") { + atrule.selectors = node.prelude ? mapSelectors(node.prelude.value) : []; + atrule.declarations = transformAst(node.block, css); + } + else if (node.name === "document") { + atrule.document = node.prelude ? node.prelude.value : ""; + atrule.vendor = ""; + atrule.rules = transformAst(node.block, css); + } + else if (node.name === "font-face") { + atrule.declarations = transformAst(node.block, css); + } + else if (node.name === "import" || node.name === "charset" || node.name === "namespace") { + atrule[node.name] = node.prelude ? node.prelude.value : ""; + } + else if (node.name === "keyframes") { + atrule.name = node.prelude ? node.prelude.value : ""; + atrule.keyframes = transformAst(node.block, css, "keyframe"); + atrule.vendor = undefined; + } + else { + atrule.rules = transformAst(node.block, css); + } + atrule.position = mapPosition(node, css); + return atrule; + } + if (node.type === "Block") { + return node.children.map(function (child) { return transformAst(child, css, type); }).filter(function (child) { return child !== null; }).toArray(); + } + if (node.type === "Rule") { + var value = node.prelude.value; + var res = { + type: type != null ? type : "rule", + declarations: transformAst(node.block, css), + position: mapPosition(node, css) + }; + if (type === "keyframe") { + res.values = mapSelectors(value); + } + else { + res.selectors = mapSelectors(value); + } + return res; + } + if (node.type === "Comment") { + return { + type: "comment", + comment: node.value, + position: mapPosition(node, css) + }; + } + if (node.type === "Declaration") { + return { + type: "declaration", + property: node.property, + value: node.value.value ? node.value.value.trim() : "", + position: mapPosition(node, css) + }; + } + if (node.type === "Raw") { + return null; + } + throw Error("Unknown node type " + node.type); +} +function cssTreeParse(css, source) { + var errors = []; + var ast = css_tree_1.parse(css, { + parseValue: false, + parseAtrulePrelude: false, + parseRulePrelude: false, + positions: true, + filename: source, + onParseError: function (error) { + errors.push(source + ":" + error.line + ":" + error.column + ": " + error.formattedMessage); + } + }); + if (errors.length > 0) { + throw new Error(errors[0]); + } + return transformAst(ast, css); +} +exports.cssTreeParse = cssTreeParse; +//# sourceMappingURL=css-tree-parser.js.map \ No newline at end of file diff --git a/nativescript-core/css/css-tree-parser.js.map b/nativescript-core/css/css-tree-parser.js.map new file mode 100644 index 000000000..5df22a86e --- /dev/null +++ b/nativescript-core/css/css-tree-parser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"css-tree-parser.js","sourceRoot":"","sources":["css-tree-parser.ts"],"names":[],"mappings":";;AAAA,qCAEkB;AAElB,SAAS,YAAY,CAAC,QAAgB;IAClC,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,EAAE,CAAC;KACb;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,EAAzB,CAAyB,CAAC,CAAC;AACpF,CAAC;AAED,SAAS,WAAW,CAAC,IAAI,EAAE,GAAG;IAC1B,IAAI,GAAG,GAAQ;QACX,KAAK,EAAE;YACH,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI;YACzB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM;SAChC;QACD,GAAG,EAAE;YACD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;YACvB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM;SAC9B;QACD,OAAO,EAAE,GAAG;KACf,CAAC;IAEF,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,WAAW,EAAE;QACpD,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;KAChC;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,IAAW;IAAX,qBAAA,EAAA,WAAW;IACxC,IAAI,CAAC,IAAI,EAAE;QACP,OAAO;KACV;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE;QAC5B,OAAO;YACH,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE;gBACR,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,EAAxB,CAAwB,CAAC,CAAC,MAAM,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,KAAK,IAAI,EAAd,CAAc,CAAC,CAAC,OAAO,EAAE;gBACrG,aAAa,EAAE,EAAE;aACpB;SACJ,CAAC;KACL;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;QACxB,IAAI,MAAM,GAAQ;YACd,IAAI,EAAE,IAAI,CAAC,IAAI;SAClB,CAAC;QAEF,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;YACnD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YACvC,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAChD;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;YAC7B,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACxE,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SACvD;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YACjC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACzD,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;YACnB,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAChD;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE;YAClC,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SACvD;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE;YACvF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9D;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE;YAClC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;YAC7D,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;SAC7B;aAAM;YACH,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAChD;QAED,MAAM,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAEzC,OAAO,MAAM,CAAC;KACjB;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,EAA9B,CAA8B,CAAC,CAAC,MAAM,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,KAAK,IAAI,EAAd,CAAc,CAAC,CAAC,OAAO,EAAE,CAAC;KAC/G;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAE/B,IAAI,GAAG,GAAQ;YACX,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;YAClC,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC;YAC3C,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC;SACnC,CAAC;QAEF,IAAI,IAAI,KAAK,UAAU,EAAE;YACrB,GAAG,CAAC,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;SACpC;aAAM;YACH,GAAG,CAAC,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;SACvC;QAED,OAAO,GAAG,CAAC;KACd;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QACzB,OAAO;YACH,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI,CAAC,KAAK;YACnB,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC;SACnC,CAAC;KACL;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE;QAC7B,OAAO;YACH,IAAI,EAAE,aAAa;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;YACtD,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC;SACnC,CAAC;KACL;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;QACrB,OAAO,IAAI,CAAC;KACf;IAED,MAAM,KAAK,CAAC,uBAAqB,IAAI,CAAC,IAAM,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,YAAY,CAAC,GAAG,EAAE,MAAM;IACpC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,GAAG,GAAG,gBAAK,CAAC,GAAG,EAAE;QACjB,UAAU,EAAE,KAAK;QACjB,kBAAkB,EAAE,KAAK;QACzB,gBAAgB,EAAE,KAAK;QACvB,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,MAAM;QAChB,YAAY,EAAE,UAAA,KAAK;YACf,MAAM,CAAC,IAAI,CAAI,MAAM,SAAI,KAAK,CAAC,IAAI,SAAI,KAAK,CAAC,MAAM,UAAK,KAAK,CAAC,gBAAkB,CAAC,CAAC;QACtF,CAAC;KACJ,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KAC9B;IAED,OAAO,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAlBD,oCAkBC"} \ No newline at end of file diff --git a/nativescript-core/data/observable-array/observable-array.ts b/nativescript-core/data/observable-array/index.ts similarity index 87% rename from nativescript-core/data/observable-array/observable-array.ts rename to nativescript-core/data/observable-array/index.ts index 95ca5b3d6..966664f95 100644 --- a/nativescript-core/data/observable-array/observable-array.ts +++ b/nativescript-core/data/observable-array/index.ts @@ -1,25 +1,59 @@ -import * as observable from "../observable"; -import * as observableArrayDef from "."; +import { Observable, EventData } from "../observable"; import * as types from "../../utils/types"; -export class ChangeType implements observableArrayDef.ChangeType { +export class ChangeType { static Add = "add"; static Delete = "delete"; static Update = "update"; static Splice = "splice"; + static Change = "change"; +} + +/** + * Event args for "changed" event. + */ +export interface ChangedData extends EventData { + /** + * Change type. + */ + action: string; + + /** + * Start index. + */ + index: number; + + /** + * Removed items. + */ + removed: Array; + + /** + * Number of added items. + */ + addedCount: number; } const CHANGE = "change"; -export class ObservableArray extends observable.Observable implements observableArrayDef.ObservableArray { // implements Array { +/** + * Advanced array like class used when you want to be notified when a change occurs. + */ +export class ObservableArray extends Observable { + /** + * String value used when hooking to change event. + */ public static changeEvent = CHANGE; private _array: Array; - private _addArgs: observableArrayDef.ChangedData; - private _deleteArgs: observableArrayDef.ChangedData; + private _addArgs: ChangedData; + private _deleteArgs: ChangedData; - constructor(_args?: any) { + /** + * Create ObservableArray with specified length or from source Array. + */ + constructor(_args?: number | T[]) { super(); if (arguments.length === 1 && Array.isArray(arguments[0])) { @@ -46,15 +80,21 @@ export class ObservableArray extends observable.Observable implements observa }; } + /** + * Returns item at specified index. + */ getItem(index: number): T { return this._array[index]; } + /** + * Sets item at specified index. + */ setItem(index: number, value: T) { let oldValue = this._array[index]; this._array[index] = value; - this.notify(>{ + this.notify(>{ eventName: CHANGE, object: this, action: ChangeType.Update, index: index, @@ -202,7 +242,7 @@ export class ObservableArray extends observable.Observable implements observa const length = this._array.length; const result = this._array.splice.apply(this._array, arguments); - this.notify(>{ + this.notify(>{ eventName: CHANGE, object: this, action: ChangeType.Splice, index: start, @@ -331,7 +371,13 @@ export class ObservableArray extends observable.Observable implements observa } export interface ObservableArray { - on(eventNames: string, callback: (data: observable.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): void; - on(event: "change", callback: (args: observableArrayDef.ChangedData) => void, thisArg?: any); + on(event: "change", callback: (args: ChangedData) => void, thisArg?: any): void; } diff --git a/nativescript-core/data/observable-array/observable-array.d.ts b/nativescript-core/data/observable-array/observable-array.d.ts deleted file mode 100644 index 72fcf99e7..000000000 --- a/nativescript-core/data/observable-array/observable-array.d.ts +++ /dev/null @@ -1,239 +0,0 @@ -// Test: http://jsperf.com/array-vs-observable-array-vs-array-observe -import { Observable, EventData } from "../observable"; - -/** - * Event args for "changed" event. - */ -export interface ChangedData extends EventData { - /** - * Change type. - */ - action: string; - - /** - * Start index. - */ - index: number; - - /** - * Removed items. - */ - removed: Array; - - /** - * Number of added items. - */ - addedCount: number; -} - -/** - * Change types. - */ -export class ChangeType { - static Add: string; - static Delete: string; - static Update: string; - static Splice: string; -} - -/** - * Advanced array like class used when you want to be notified when a change occurs. - */ -export class ObservableArray extends Observable { - /** - * String value used when hooking to change event. - */ - public static changeEvent: 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); - - /** - * Raised when a change occurs. - */ - on(event: "change", callback: (args: ChangedData) => void, thisArg?: any); - - /** - * Create ObservableArray with specified length. - */ - constructor(arrayLength?: number); - - /** - * Create ObservableArray from source Array. - */ - constructor(items: T[]); - - /** - * Create ObservableArray from T items. - */ - constructor(...items: T[]); - - /** - * Returns item at specified index. - */ - getItem(index: number): T; - /** - * Sets item at specified index. - */ - setItem(index: number, value: T): void; - /** - * Returns a string representation of an array. - */ - toString(): string; - toLocaleString(): string; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** - * Removes the last element from an array and returns it. - */ - pop(): T; - /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ - push(items: T[]): number; - /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ - push(...items: T[]): number; - - /** - * Reverses the elements in an Array. - */ - reverse(): T[]; - /** - * Removes the first element from an array and returns it. - */ - shift(): T; - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): T[]; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - */ - splice(start: number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ - splice(start: number, deleteCount: number, ...items: T[]): T[]; - - /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ - unshift(...items: T[]): number; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ - indexOf(searchElement: T, fromIndex?: number): number; - - /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ - lastIndexOf(searchElement: T, fromIndex?: number): number; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; - - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ - length: number; -} diff --git a/nativescript-core/data/observable-array/package.json b/nativescript-core/data/observable-array/package.json deleted file mode 100644 index d6e4dcdbc..000000000 --- a/nativescript-core/data/observable-array/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "types": "observable-array.d.ts", - "name": "observable-array", - "main": "observable-array" -} diff --git a/nativescript-core/data/observable/observable.d.ts b/nativescript-core/data/observable/index.d.ts similarity index 100% rename from nativescript-core/data/observable/observable.d.ts rename to nativescript-core/data/observable/index.d.ts diff --git a/nativescript-core/data/observable/observable.ts b/nativescript-core/data/observable/index.ts similarity index 100% rename from nativescript-core/data/observable/observable.ts rename to nativescript-core/data/observable/index.ts diff --git a/nativescript-core/data/observable/package.json b/nativescript-core/data/observable/package.json deleted file mode 100644 index bd02460b2..000000000 --- a/nativescript-core/data/observable/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "types": "observable.d.ts", - "name": "observable", - "main": "observable" -} diff --git a/nativescript-core/data/package.json b/nativescript-core/data/package.json deleted file mode 100644 index 58fcaa43b..000000000 --- a/nativescript-core/data/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nativescript": {} -} diff --git a/nativescript-core/data/virtual-array/index.ts b/nativescript-core/data/virtual-array/index.ts new file mode 100644 index 000000000..d5b873cd4 --- /dev/null +++ b/nativescript-core/data/virtual-array/index.ts @@ -0,0 +1,226 @@ +import { Observable, EventData } from "../observable"; +import { ObservableArray, ChangedData, ChangeType } from "../observable-array"; + +/** + * Event args for "itemsLoading" event. + */ +export interface ItemsLoading extends EventData { + /** + * Start index. + */ + index: number; + + /** + * Number of items to load. + */ + count: number; +} + +/** + * Advanced array like class that helps loading items on demand. + */ +export class VirtualArray extends Observable { + /** + * String value used when hooking to change event. + */ + public static changeEvent = ChangeType.Change; + /** + * String value used when hooking to itemsLoading event. + */ + public static itemsLoadingEvent = "itemsLoading"; + + private _requestedIndexes: Array; + private _loadedIndexes: Array; + private _length: number; + private _cache: {}; + + constructor(length = 0) { + super(); + + this._length = length; + this._cache = {}; + + this._requestedIndexes = []; + this._loadedIndexes = []; + } + + /** + * Gets or sets length for the virtual array. + */ + get length(): number { + return this._length; + } + set length(value: number) { + if (this._length !== value) { + const index = this._length; + const count = value - this._length; + + this._length = value; + + this.notify({ + eventName: ChangeType.Change, + object: this, + action: count > 0 ? ChangeType.Add : ChangeType.Delete, + index: index, + removed: new Array(count < 0 ? Math.abs(count) : 0), + addedCount: count > 0 ? count : 0, + }); + } + } + + /** + * Gets or sets load size for the virtual array. + */ + private _loadSize: number; + get loadSize(): number { + return this._loadSize; + } + set loadSize(value: number) { + this._loadSize = value; + } + + getItem(index: number): T { + const item = this._cache[index]; + + if (item === undefined) { + if ( + index >= 0 && + index < this.length && + this._requestedIndexes.indexOf(index) < 0 && + this._loadedIndexes.indexOf(index) < 0 + ) { + this.requestItems(index); + } + } + + return item; + } + + setItem(index: number, value: T) { + if (this._cache[index] !== value) { + this.load(index, [value]); + } + } + + /** + * Loads items from an array starting at index. + */ + load(index: number, items: T[]): void { + for (let i = 0; i < items.length; i++) { + const itemIndex = index + i; + + this._cache[itemIndex] = items[i]; + + this._requestedIndexes.splice( + this._requestedIndexes.indexOf(itemIndex), + 1 + ); + + if (this._loadedIndexes.indexOf(itemIndex) < 0) { + this._loadedIndexes.push(itemIndex); + } + } + + // Remove requested but never loaded indexes. + if (this._requestedIndexes.length > 0) { + for (let i = 0; i < this.loadSize - items.length; i++) { + this._requestedIndexes.splice( + this._requestedIndexes.indexOf(index + i), + 1 + ); + } + } + + this.notify({ + eventName: ChangeType.Change, + object: this, + action: ChangeType.Update, + index: index, + removed: new Array(items.length), + addedCount: items.length, + }); + } + + private requestItems(index: number): void { + const indexesToLoad = []; + + const pageIndex = + this._loadSize > 0 + ? this._loadSize * Math.floor(index / this._loadSize) + : index; + let count = 0; + let start = -1; + + for (let i = 0; i < this.loadSize; i++) { + const itemIndex = pageIndex + i; + + if (itemIndex >= this._length) { + break; + } + + if (this._loadedIndexes.indexOf(itemIndex) < 0) { + if (start < 0) { + start = itemIndex; + } + + indexesToLoad.push(itemIndex); + + if (this._requestedIndexes.indexOf(itemIndex) < 0) { + this._requestedIndexes.push(itemIndex); + } + + count++; + } else { + if (count > 0) { + this.notify({ + eventName: VirtualArray.itemsLoadingEvent, + object: this, + index: start, + count: count, + }); + } + + start = -1; + count = 0; + } + } + + if (start >= 0 && count > 0) { + this.notify({ + eventName: VirtualArray.itemsLoadingEvent, + object: this, + index: start, + count: count, + }); + } + } +} +export interface VirtualArray { + /** + * 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 + ): void; + /** + * Raised when still not loaded items are requested. + */ + on( + event: "itemsLoading", + callback: (args: ItemsLoading) => void, + thisArg?: any + ): void; + /** + * Raised when a change occurs. + */ + on( + event: "change", + callback: (args: ChangedData) => void, + thisArg?: any + ): void; +} diff --git a/nativescript-core/data/virtual-array/package.json b/nativescript-core/data/virtual-array/package.json deleted file mode 100644 index 3207cc6cc..000000000 --- a/nativescript-core/data/virtual-array/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "virtual-array", - "types": "virtual-array.d.ts", - "main": "virtual-array" -} diff --git a/nativescript-core/data/virtual-array/virtual-array.d.ts b/nativescript-core/data/virtual-array/virtual-array.d.ts deleted file mode 100644 index 9c832db52..000000000 --- a/nativescript-core/data/virtual-array/virtual-array.d.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { Observable, EventData } from "../observable"; -import { ObservableArray, ChangedData, ChangeType } from "../observable-array"; - -/** - * Advanced array like class that helps loading items on demand. - */ -export class VirtualArray extends Observable { - /** - * String value used when hooking to change event. - */ - public static changeEvent: string; - - /** - * String value used when hooking to itemsLoading event. - */ - public static itemsLoadingEvent: string; - - constructor(arrayLength?: number); - - /** - * Gets or sets length for the virtual array. - */ - length: number; - - /** - * Gets or sets load size for the virtual array. - */ - loadSize: number; - - /** - * Returns item at specified index. - */ - getItem(index: number): T; - - /** - * Sets item at specified index. - */ - setItem(index: number, value: T): void; - - /** - * Loads items from an array starting at index. - */ - load(index: number, items: T[]): void; - - /** - * 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 still not loaded items are requested. - */ - on(event: "itemsLoading", callback: (args: ItemsLoading) => void, thisArg?: any); - - /** - * Raised when a change occurs. - */ - on(event: "change", callback: (args: ChangedData) => void, thisArg?: any); -} - -/** - * Event args for "itemsLoading" event. - */ -export interface ItemsLoading extends EventData { - /** - * Start index. - */ - index: number; - - /** - * Number of items to load. - */ - count: number; -} diff --git a/nativescript-core/data/virtual-array/virtual-array.ts b/nativescript-core/data/virtual-array/virtual-array.ts deleted file mode 100644 index 67a4c8da0..000000000 --- a/nativescript-core/data/virtual-array/virtual-array.ts +++ /dev/null @@ -1,165 +0,0 @@ -import { Observable, EventData } from "../observable"; -import * as virtualArrayDef from "."; - -const CHANGE = "change"; -const UPDATE = "update"; -const DELETE = "delete"; -const ADD = "add"; - -export class ChangeType implements virtualArrayDef.ChangeType { - static Add = ADD; - static Delete = DELETE; - static Update = UPDATE; - static Splice = CHANGE; -} - -export class VirtualArray extends Observable implements virtualArrayDef.VirtualArray { - public static changeEvent = CHANGE; - public static itemsLoadingEvent = "itemsLoading"; - - private _requestedIndexes: Array; - private _loadedIndexes: Array; - private _length: number; - private _cache: {}; - - constructor(length = 0) { - super(); - - this._length = length; - this._cache = {}; - - this._requestedIndexes = []; - this._loadedIndexes = []; - } - - get length(): number { - return this._length; - } - set length(value: number) { - if (this._length !== value) { - - const index = this._length; - const count = value - this._length; - - this._length = value; - - this.notify({ - eventName: CHANGE, object: this, - action: count > 0 ? ADD : DELETE, - index: index, - removed: new Array(count < 0 ? Math.abs(count) : 0), - addedCount: count > 0 ? count : 0 - }); - } - } - - private _loadSize: number; - get loadSize(): number { - return this._loadSize; - } - set loadSize(value: number) { - this._loadSize = value; - } - - getItem(index: number): T { - const item = this._cache[index]; - - if (item === undefined) { - if (index >= 0 && index < this.length && this._requestedIndexes.indexOf(index) < 0 && this._loadedIndexes.indexOf(index) < 0) { - this.requestItems(index); - } - } - - return item; - } - - setItem(index: number, value: T) { - if (this._cache[index] !== value) { - this.load(index, [value]); - } - } - - load(index: number, items: T[]): void { - for (let i = 0; i < items.length; i++) { - - const itemIndex = index + i; - - this._cache[itemIndex] = items[i]; - - this._requestedIndexes.splice(this._requestedIndexes.indexOf(itemIndex), 1); - - if (this._loadedIndexes.indexOf(itemIndex) < 0) { - this._loadedIndexes.push(itemIndex); - } - } - - // Remove requested but never loaded indexes. - if (this._requestedIndexes.length > 0) { - for (let i = 0; i < this.loadSize - items.length; i++) { - this._requestedIndexes.splice(this._requestedIndexes.indexOf(index + i), 1); - } - } - - this.notify({ - eventName: CHANGE, object: this, - action: UPDATE, - index: index, - removed: new Array(items.length), - addedCount: items.length - }); - } - - private requestItems(index: number): void { - const indexesToLoad = []; - - const pageIndex = this._loadSize > 0 ? this._loadSize * Math.floor(index / this._loadSize) : index; - let count = 0; - let start = -1; - - for (let i = 0; i < this.loadSize; i++) { - const itemIndex = pageIndex + i; - - if (itemIndex >= this._length) { - break; - } - - if (this._loadedIndexes.indexOf(itemIndex) < 0) { - if (start < 0) { - start = itemIndex; - } - - indexesToLoad.push(itemIndex); - - if (this._requestedIndexes.indexOf(itemIndex) < 0) { - this._requestedIndexes.push(itemIndex); - } - - count++; - } else { - if (count > 0) { - this.notify({ - eventName: VirtualArray.itemsLoadingEvent, object: this, - index: start, - count: count - }); - } - - start = -1; - count = 0; - } - } - - if (start >= 0 && count > 0) { - this.notify({ - eventName: VirtualArray.itemsLoadingEvent, object: this, - index: start, - count: count - }); - } - } -} -export interface VirtualArray { - on(eventNames: string, callback: (data: EventData) => void, thisArg?: any); - on(event: "itemsLoading", callback: (args: virtualArrayDef.ItemsLoading) => void, thisArg?: any); - on(event: "change", callback: (args: virtualArrayDef.ChangedData) => void, thisArg?: any); -} diff --git a/nativescript-core/debugger/dom-node.d.ts b/nativescript-core/debugger/dom-node.d.ts index dfc287be1..6f69f611c 100644 --- a/nativescript-core/debugger/dom-node.d.ts +++ b/nativescript-core/debugger/dom-node.d.ts @@ -1,6 +1,11 @@ -import { ViewBase } from "../ui/core/view"; +import { ViewBase } from "../ui/core/view-base"; import { CSSComputedStyleProperty } from "./css-agent"; export declare function getNodeById(id: number): DOMNode; +declare class WeakRef { + constructor(obj: T); + get(): T; + clear(): void; +} export declare class DOMNode { nodeId: any; nodeType: any; diff --git a/nativescript-core/debugger/dom-node.ts b/nativescript-core/debugger/dom-node.ts index 9966ac0ed..84af7267c 100644 --- a/nativescript-core/debugger/dom-node.ts +++ b/nativescript-core/debugger/dom-node.ts @@ -2,7 +2,7 @@ import { CSSComputedStyleProperty } from "./css-agent"; import { InspectorEvents } from "./devtools-elements-interfaces"; // Needed for typings only -import { ViewBase } from "../ui/core/view"; +import { ViewBase } from "../ui/core/view-base"; const registeredDomNodes = {}; const ELEMENT_NODE_TYPE = 1; diff --git a/nativescript-core/debugger/debugger.ts b/nativescript-core/debugger/index.ts similarity index 100% rename from nativescript-core/debugger/debugger.ts rename to nativescript-core/debugger/index.ts diff --git a/nativescript-core/debugger/package.json b/nativescript-core/debugger/package.json deleted file mode 100644 index ef8db346a..000000000 --- a/nativescript-core/debugger/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "debugger", - "main": "debugger", - "nativescript": {} -} \ No newline at end of file diff --git a/nativescript-core/debugger/webinspector-css.ios.ts b/nativescript-core/debugger/webinspector-css.ios.ts index 6fe9d7aa6..314d10def 100644 --- a/nativescript-core/debugger/webinspector-css.ios.ts +++ b/nativescript-core/debugger/webinspector-css.ios.ts @@ -1,7 +1,7 @@ import * as inspectorCommandTypes from "./InspectorBackendCommands.ios"; const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands"); -import * as debuggerDomains from "./debugger"; +import * as debuggerDomains from "."; import { attachCSSInspectorCommandCallbacks } from "./devtools-elements"; diff --git a/nativescript-core/debugger/webinspector-dom.ios.ts b/nativescript-core/debugger/webinspector-dom.ios.ts index 76bc27688..08f648f48 100644 --- a/nativescript-core/debugger/webinspector-dom.ios.ts +++ b/nativescript-core/debugger/webinspector-dom.ios.ts @@ -1,7 +1,7 @@ import * as inspectorCommandTypes from "./InspectorBackendCommands.ios"; const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands"); -import * as debuggerDomains from "./debugger"; +import * as debuggerDomains from "."; import { attachDOMInspectorEventCallbacks, attachDOMInspectorCommandCallbacks } from "./devtools-elements"; diff --git a/nativescript-core/debugger/webinspector-network.ios.ts b/nativescript-core/debugger/webinspector-network.ios.ts index ddf2c6b97..21244e8a1 100644 --- a/nativescript-core/debugger/webinspector-network.ios.ts +++ b/nativescript-core/debugger/webinspector-network.ios.ts @@ -1,7 +1,7 @@ import * as inspectorCommandTypes from "./InspectorBackendCommands.ios"; const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands"); -import * as debuggerDomains from "./debugger"; +import * as debuggerDomains from "."; declare var __inspectorSendEvent; diff --git a/nativescript-core/fetch/fetch.js b/nativescript-core/fetch/index.js similarity index 100% rename from nativescript-core/fetch/fetch.js rename to nativescript-core/fetch/index.js diff --git a/nativescript-core/fetch/package.json b/nativescript-core/fetch/package.json deleted file mode 100644 index cff423401..000000000 --- a/nativescript-core/fetch/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "fetch", - "main": "fetch", - "nativescript": {} -} 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 deleted file mode 100644 index 454e5e88b..000000000 --- a/nativescript-core/file-system/file-name-resolver/file-name-resolver.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PlatformContext } from "../../module-name-resolver/qualifier-matcher"; - -export class FileNameResolver { - constructor(context: PlatformContext); - resolveFileName(path: string, ext: string): string; - clearCache(): void; -} - -export function resolveFileName(path: string, ext: string): string; -export function clearCache(): void; diff --git a/nativescript-core/file-system/file-name-resolver/file-name-resolver.ts b/nativescript-core/file-system/file-name-resolver/index.ts similarity index 86% rename from nativescript-core/file-system/file-name-resolver/file-name-resolver.ts rename to nativescript-core/file-system/file-name-resolver/index.ts index 6634cd9d8..68cde23f6 100644 --- a/nativescript-core/file-system/file-name-resolver/file-name-resolver.ts +++ b/nativescript-core/file-system/file-name-resolver/index.ts @@ -1,10 +1,11 @@ -import { PlatformContext, FileNameResolver as FileNameResolverDefinition } from "."; +import { FileNameResolver as FileNameResolverDefinition } from "."; +import { PlatformContext } from "../../module-name-resolver/qualifier-matcher"; import { screen, device } from "../../platform"; -import { path as fsPath, Folder, File } from "../file-system"; -import * as trace from "../../trace"; +import { path as fsPath, Folder, File } from ".."; +import { Trace } from "../../trace"; import * as appCommonModule from "../../application/application-common"; -import { findMatch, stripQualifiers } from "../../module-name-resolver/qualifier-matcher/qualifier-matcher"; +import { findMatch, stripQualifiers } from "../../module-name-resolver/qualifier-matcher"; export class FileNameResolver implements FileNameResolverDefinition { private _context: PlatformContext; @@ -63,8 +64,8 @@ export class FileNameResolver implements FileNameResolverDefinition { }); } else { - if (trace.isEnabled()) { - trace.write("Could not find folder " + folderPath + " when loading " + path + ext, trace.categories.Navigation); + if (Trace.isEnabled()) { + Trace.write("Could not find folder " + folderPath + " when loading " + path + ext, Trace.categories.Navigation); } } diff --git a/nativescript-core/file-system/file-name-resolver/package.json b/nativescript-core/file-system/file-name-resolver/package.json deleted file mode 100644 index 1bb18e1ed..000000000 --- a/nativescript-core/file-system/file-name-resolver/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "file-name_resolver", - "main": "file-name-resolver", - "types": "file-name-resolver.d.ts" -} diff --git a/nativescript-core/file-system/file-system.d.ts b/nativescript-core/file-system/index.d.ts similarity index 100% rename from nativescript-core/file-system/file-system.d.ts rename to nativescript-core/file-system/index.d.ts diff --git a/nativescript-core/file-system/file-system.ts b/nativescript-core/file-system/index.ts similarity index 99% rename from nativescript-core/file-system/file-system.ts rename to nativescript-core/file-system/index.ts index 24ada6e62..c4d20bd1d 100644 --- a/nativescript-core/file-system/file-system.ts +++ b/nativescript-core/file-system/index.ts @@ -323,7 +323,7 @@ export class File extends FileSystemEntity { }); } - @profile + @profile() public readTextSync(onError?: (error: any) => any, encoding?: string): string { this.checkAccess(); diff --git a/nativescript-core/file-system/package.json b/nativescript-core/file-system/package.json deleted file mode 100644 index f9725c020..000000000 --- a/nativescript-core/file-system/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "file-system", - "main": "file-system", - "types": "file-system.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/fps-meter/fps-meter.d.ts b/nativescript-core/fps-meter/index.d.ts similarity index 100% rename from nativescript-core/fps-meter/fps-meter.d.ts rename to nativescript-core/fps-meter/index.d.ts diff --git a/nativescript-core/fps-meter/fps-meter.ts b/nativescript-core/fps-meter/index.ts similarity index 100% rename from nativescript-core/fps-meter/fps-meter.ts rename to nativescript-core/fps-meter/index.ts diff --git a/nativescript-core/fps-meter/package.json b/nativescript-core/fps-meter/package.json deleted file mode 100644 index 3cef426f2..000000000 --- a/nativescript-core/fps-meter/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "fps-meter", - "main": "fps-meter", - "types": "fps-meter.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/globals/index.d.ts b/nativescript-core/globals/index.d.ts index 97bebc2cb..81170e65b 100644 --- a/nativescript-core/globals/index.d.ts +++ b/nativescript-core/globals/index.d.ts @@ -1,4 +1,4 @@ -/** - * Register globals such as setTimeout, setInterval, console etc. - */ -export function initGlobal(); +export declare var hasInitGlobal: boolean; +export function installPolyfills(moduleName: string, exportNames: string[]): void; +export function initGlobal(): void; + diff --git a/nativescript-core/http/http-request/http-request.android.ts b/nativescript-core/http/http-request/index.android.ts similarity index 99% rename from nativescript-core/http/http-request/http-request.android.ts rename to nativescript-core/http/http-request/index.android.ts index b9be9098b..f2ccd805c 100644 --- a/nativescript-core/http/http-request/http-request.android.ts +++ b/nativescript-core/http/http-request/index.android.ts @@ -5,7 +5,7 @@ import * as platformModule from "../../platform"; import * as fsModule from "../../file-system"; import { getFilenameFromUrl } from "./http-request-common"; -import { NetworkAgent } from "../../debugger/debugger"; +import { NetworkAgent } from "../../debugger"; export enum HttpResponseEncoding { UTF8, diff --git a/nativescript-core/http/http-request/http-request.d.ts b/nativescript-core/http/http-request/index.d.ts similarity index 100% rename from nativescript-core/http/http-request/http-request.d.ts rename to nativescript-core/http/http-request/index.d.ts diff --git a/nativescript-core/http/http-request/http-request.ios.ts b/nativescript-core/http/http-request/index.ios.ts similarity index 99% rename from nativescript-core/http/http-request/http-request.ios.ts rename to nativescript-core/http/http-request/index.ios.ts index 3f524c4cd..846a7aadd 100644 --- a/nativescript-core/http/http-request/http-request.ios.ts +++ b/nativescript-core/http/http-request/index.ios.ts @@ -4,7 +4,7 @@ import * as imageSourceModule from "../../image-source"; import * as fsModule from "../../file-system"; import * as types from "../../utils/types"; -import * as domainDebugger from "../../debugger/debugger"; +import * as domainDebugger from "../../debugger"; import { getFilenameFromUrl } from "./http-request-common"; export enum HttpResponseEncoding { diff --git a/nativescript-core/http/http-request/package.json b/nativescript-core/http/http-request/package.json deleted file mode 100644 index e516bf603..000000000 --- a/nativescript-core/http/http-request/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "http-request", - "main": "http-request", - "types": "http-request.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/http/http.d.ts b/nativescript-core/http/index.d.ts similarity index 100% rename from nativescript-core/http/http.d.ts rename to nativescript-core/http/index.d.ts diff --git a/nativescript-core/http/http.ts b/nativescript-core/http/index.ts similarity index 58% rename from nativescript-core/http/http.ts rename to nativescript-core/http/index.ts index f2e391adf..cacecfe34 100644 --- a/nativescript-core/http/http.ts +++ b/nativescript-core/http/index.ts @@ -1,7 +1,105 @@ import { ImageSource } from "../image-source"; +import { File } from "../file-system"; import * as httpRequest from "./http-request"; export * from "./http-request"; +/** + * Provides options for the http requests. + */ +export interface HttpRequestOptions { + /** + * Gets or sets the request url. + */ + url: string; + + /** + * Gets or sets the request method. + */ + method: string; + + /** + * Gets or sets the request headers in JSON format. + */ + headers?: any; + + /** + * Gets or sets the request body. + */ + content?: string | FormData | ArrayBuffer; + + /** + * Gets or sets the request timeout in milliseconds. + */ + timeout?: number; + + /** + * Gets or sets wether to *not* follow server's redirection responses. + */ + dontFollowRedirects?: boolean; +} + +/** + * Encapsulates HTTP-response information from an HTTP-request. + */ +export interface HttpResponse { + /** + * Gets the response status code. + */ + statusCode: number; + + /** + * Gets the response headers. + */ + headers: Headers; + + /** + * Gets the response content. + */ + content?: HttpContent; +} + +export type Headers = { [key: string]: string | string[] }; + +export enum HttpResponseEncoding { + UTF8, + GBK +} +/** + * Encapsulates the content of an HttpResponse. + */ +export interface HttpContent { + /** + * Gets the response body as raw data. + */ + raw: any; + + /** + * Gets the response body as ArrayBuffer + */ + toArrayBuffer: () => ArrayBuffer; + + /** + * Gets the response body as string. + */ + toString: (encoding?: HttpResponseEncoding) => string; + + /** + * Gets the response body as JSON object. + */ + toJSON: (encoding?: HttpResponseEncoding) => any; + + /** + * Gets the response body as ImageSource. + */ + toImage: () => Promise; + + /** + * Gets the response body as file. + */ + toFile: (destinationFilePath?: string) => File; +} + + export function getString(arg: any): Promise { return new Promise((resolve, reject) => { httpRequest.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg) diff --git a/nativescript-core/http/package.json b/nativescript-core/http/package.json deleted file mode 100644 index a55c22f2e..000000000 --- a/nativescript-core/http/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "http", - "main": "http", - "types": "http.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/image-asset/image-asset.android.ts b/nativescript-core/image-asset/index.android.ts similarity index 100% rename from nativescript-core/image-asset/image-asset.android.ts rename to nativescript-core/image-asset/index.android.ts diff --git a/nativescript-core/image-asset/image-asset.d.ts b/nativescript-core/image-asset/index.d.ts similarity index 100% rename from nativescript-core/image-asset/image-asset.d.ts rename to nativescript-core/image-asset/index.d.ts diff --git a/nativescript-core/image-asset/image-asset.ios.ts b/nativescript-core/image-asset/index.ios.ts similarity index 100% rename from nativescript-core/image-asset/image-asset.ios.ts rename to nativescript-core/image-asset/index.ios.ts diff --git a/nativescript-core/image-asset/package.json b/nativescript-core/image-asset/package.json deleted file mode 100644 index dff1261cd..000000000 --- a/nativescript-core/image-asset/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "image-asset", - "main": "image-asset", - "types": "image-asset.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/image-source/image-source.android.ts b/nativescript-core/image-source/index.android.ts similarity index 100% rename from nativescript-core/image-source/image-source.android.ts rename to nativescript-core/image-source/index.android.ts diff --git a/nativescript-core/image-source/image-source.d.ts b/nativescript-core/image-source/index.d.ts similarity index 100% rename from nativescript-core/image-source/image-source.d.ts rename to nativescript-core/image-source/index.d.ts diff --git a/nativescript-core/image-source/image-source.ios.ts b/nativescript-core/image-source/index.ios.ts similarity index 100% rename from nativescript-core/image-source/image-source.ios.ts rename to nativescript-core/image-source/index.ios.ts diff --git a/nativescript-core/image-source/package.json b/nativescript-core/image-source/package.json deleted file mode 100644 index 1b78e0e46..000000000 --- a/nativescript-core/image-source/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "image-source", - "main": "image-source", - "types": "image-source.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/index.d.ts b/nativescript-core/index.d.ts index b31f3d53a..e4c1ca103 100644 --- a/nativescript-core/index.d.ts +++ b/nativescript-core/index.d.ts @@ -80,23 +80,8 @@ export declare const Profiling: { stopCPUProfile: typeof stopCPUProfile; }; export { encoding } from "./text"; -export { DefaultErrorHandler, ErrorHandler, TraceWriter } from "./trace"; -import { messageType, categories, setCategories, addCategories, addWriter, removeWriter, clearWriters, setErrorHandler, write, error, enable, disable, isEnabled } from "./trace"; -export declare const Trace: { - messageType: typeof messageType; - categories: typeof categories; - setCategories: typeof setCategories; - addCategories: typeof addCategories; - addWriter: typeof addWriter; - removeWriter: typeof removeWriter; - clearWriters: typeof clearWriters; - setErrorHandler: typeof setErrorHandler; - write: typeof write; - error: typeof error; - enable: typeof enable; - disable: typeof disable; - isEnabled: typeof isEnabled; -}; +export * from "./trace"; + export * from "./ui"; import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, ios as iosUtils } from "./utils/utils"; export declare const Utils: { diff --git a/nativescript-core/index.ts b/nativescript-core/index.ts index b06cd5359..09627e631 100644 --- a/nativescript-core/index.ts +++ b/nativescript-core/index.ts @@ -80,22 +80,9 @@ export const Profiling = { export { encoding } from "./text"; -export { DefaultErrorHandler, ErrorHandler, TraceWriter } from "./trace"; -import { - messageType, categories, setCategories, addCategories, - addWriter, removeWriter, clearWriters, - setErrorHandler, - write, error, enable, disable, isEnabled -} from "./trace"; +export * from "./trace"; -export const Trace = { - messageType, categories, setCategories, addCategories, - addWriter, removeWriter, clearWriters, - setErrorHandler, - write, error, enable, disable, isEnabled -}; - -export * from "./ui"; // Barrel export +export * from "./ui"; import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, diff --git a/nativescript-core/matrix/matrix.d.ts b/nativescript-core/matrix/index.d.ts similarity index 94% rename from nativescript-core/matrix/matrix.d.ts rename to nativescript-core/matrix/index.d.ts index e292f4baa..03be1e65d 100644 --- a/nativescript-core/matrix/matrix.d.ts +++ b/nativescript-core/matrix/index.d.ts @@ -4,7 +4,7 @@ * may be changed in a non-major version. */ -import { TransformFunctionsInfo } from "../ui/animation/animation"; +import { TransformFunctionsInfo } from "../ui/animation"; /** * Returns the affine matrix representation of the transformation. diff --git a/nativescript-core/matrix/matrix.ts b/nativescript-core/matrix/index.ts similarity index 97% rename from nativescript-core/matrix/matrix.ts rename to nativescript-core/matrix/index.ts index 4494d3d7d..6b83cb1f5 100644 --- a/nativescript-core/matrix/matrix.ts +++ b/nativescript-core/matrix/index.ts @@ -1,4 +1,4 @@ -import { TransformFunctionsInfo } from "../ui/animation/animation"; +import { TransformFunctionsInfo } from "../ui/animation"; import { radiansToDegrees, degreesToRadians } from "../utils/number-utils"; diff --git a/nativescript-core/matrix/package.json b/nativescript-core/matrix/package.json deleted file mode 100644 index f61f46260..000000000 --- a/nativescript-core/matrix/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "matrix", - "main": "matrix", - "types": "matrix.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/module-name-resolver/module-name-resolver.d.ts b/nativescript-core/module-name-resolver/index.d.ts similarity index 100% rename from nativescript-core/module-name-resolver/module-name-resolver.d.ts rename to nativescript-core/module-name-resolver/index.d.ts diff --git a/nativescript-core/module-name-resolver/module-name-resolver.ts b/nativescript-core/module-name-resolver/index.ts similarity index 95% rename from nativescript-core/module-name-resolver/module-name-resolver.ts rename to nativescript-core/module-name-resolver/index.ts index 58ccc9b64..691238a17 100644 --- a/nativescript-core/module-name-resolver/module-name-resolver.ts +++ b/nativescript-core/module-name-resolver/index.ts @@ -1,5 +1,5 @@ -import { ModuleNameResolver as ModuleNameResolverDefinition, ModuleListProvider } from "./"; -import { screen, device } from "../platform/platform"; +import { ModuleNameResolver as ModuleNameResolverDefinition } from "./"; +import { screen, device } from "../platform"; import * as appCommonModule from "../application/application-common"; import { PlatformContext, findMatch, stripQualifiers } from "./qualifier-matcher"; import { registerModulesFromFileSystem } from "./non-bundle-workflow-compat"; @@ -7,6 +7,8 @@ import { Trace } from "../trace"; +export type ModuleListProvider = () => string[]; + export class ModuleNameResolver implements ModuleNameResolverDefinition { private _cache = {}; 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 7cac5f0be..2a69a41ae 100644 --- a/nativescript-core/module-name-resolver/non-bundle-workflow-compat.ts +++ b/nativescript-core/module-name-resolver/non-bundle-workflow-compat.ts @@ -1,4 +1,4 @@ -import * as fs from "../file-system/file-system"; +import * as fs from "../file-system"; import * as appCommonModule from "../application/application-common"; import { Trace diff --git a/nativescript-core/module-name-resolver/package.json b/nativescript-core/module-name-resolver/package.json deleted file mode 100644 index 02bc0cdd9..000000000 --- a/nativescript-core/module-name-resolver/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "module-name-resolver", - "main": "module-name-resolver", - "types": "module-name-resolver.d.ts" -} diff --git a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts b/nativescript-core/module-name-resolver/qualifier-matcher/index.d.ts similarity index 100% rename from nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.d.ts rename to nativescript-core/module-name-resolver/qualifier-matcher/index.d.ts diff --git a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.ts b/nativescript-core/module-name-resolver/qualifier-matcher/index.ts similarity index 98% rename from nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.ts rename to nativescript-core/module-name-resolver/qualifier-matcher/index.ts index 28b641d14..a0c6de09a 100644 --- a/nativescript-core/module-name-resolver/qualifier-matcher/qualifier-matcher.ts +++ b/nativescript-core/module-name-resolver/qualifier-matcher/index.ts @@ -1,9 +1,15 @@ -import { PlatformContext } from "./"; const MIN_WH: string = "minWH"; const MIN_W: string = "minW"; const MIN_H: string = "minH"; const PRIORITY_STEP = 10000; +export interface PlatformContext { + width: number; + height: number; + os: string; + deviceType: string; +} + interface QualifierSpec { isMatch(path: string): boolean; getMatchOccurences(path: string): Array; diff --git a/nativescript-core/module-name-resolver/qualifier-matcher/package.json b/nativescript-core/module-name-resolver/qualifier-matcher/package.json deleted file mode 100644 index 91818c758..000000000 --- a/nativescript-core/module-name-resolver/qualifier-matcher/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "qualifier-matcher", - "main": "qualifier-matcher", - "types": "qualifier-matcher.d.ts" -} diff --git a/nativescript-core/module.d.ts b/nativescript-core/module.d.ts index 5783ed49d..a9f977571 100644 --- a/nativescript-core/module.d.ts +++ b/nativescript-core/module.d.ts @@ -1,4 +1,4 @@ -declare var global: NodeJS.Global; +declare var global: NodeJS.Global & typeof globalThis; interface ModuleResolver { /** diff --git a/nativescript-core/platform/platform.android.ts b/nativescript-core/platform/index.android.ts similarity index 100% rename from nativescript-core/platform/platform.android.ts rename to nativescript-core/platform/index.android.ts diff --git a/nativescript-core/platform/platform.d.ts b/nativescript-core/platform/index.d.ts similarity index 100% rename from nativescript-core/platform/platform.d.ts rename to nativescript-core/platform/index.d.ts diff --git a/nativescript-core/platform/platform.ios.ts b/nativescript-core/platform/index.ios.ts similarity index 100% rename from nativescript-core/platform/platform.ios.ts rename to nativescript-core/platform/index.ios.ts diff --git a/nativescript-core/platform/package.json b/nativescript-core/platform/package.json deleted file mode 100644 index 7d1b0934e..000000000 --- a/nativescript-core/platform/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "platform", - "main": "platform", - "types": "platform.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/profiling/profiling.d.ts b/nativescript-core/profiling/index.d.ts similarity index 100% rename from nativescript-core/profiling/profiling.d.ts rename to nativescript-core/profiling/index.d.ts diff --git a/nativescript-core/profiling/profiling.ts b/nativescript-core/profiling/index.ts similarity index 98% rename from nativescript-core/profiling/profiling.ts rename to nativescript-core/profiling/index.ts index 485a28b37..d507282c1 100644 --- a/nativescript-core/profiling/profiling.ts +++ b/nativescript-core/profiling/index.ts @@ -1,8 +1,6 @@ declare var __startCPUProfiler: any; declare var __stopCPUProfiler: any; -import { TimerInfo as TimerInfoDefinition, InstrumentationMode } from "."; - export function uptime() { return global.android ? (org).nativescript.Process.getUpTime() : (global).__tns_uptime(); } @@ -14,7 +12,9 @@ export function log(message: string): void { console.log(message); } -interface TimerInfo extends TimerInfoDefinition { +export type InstrumentationMode = "counters" | "timeline" | "lifecycle"; + +export interface TimerInfo { totalTime: number; lastTime?: number; count: number; @@ -239,7 +239,7 @@ const voidMethodDecorator = () => { // no op }; -export function profile(nameFnOrTarget?: string | Function | Object, fnOrKey?: Function | string | symbol, descriptor?: PropertyDescriptor): Function | MethodDecorator { +export function profile(nameFnOrTarget?: string | Function | Object, fnOrKey?: Function | string | symbol, descriptor?: PropertyDescriptor, attrs?: any): Function | MethodDecorator { if (typeof nameFnOrTarget === "object" && (typeof fnOrKey === "string" || typeof fnOrKey === "symbol")) { if (!profileFunctionFactory) { return; diff --git a/nativescript-core/profiling/package.json b/nativescript-core/profiling/package.json deleted file mode 100644 index acfc32716..000000000 --- a/nativescript-core/profiling/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "profiling", - "main": "profiling", - "types": "profiling.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/text/text.android.ts b/nativescript-core/text/index.android.ts similarity index 100% rename from nativescript-core/text/text.android.ts rename to nativescript-core/text/index.android.ts diff --git a/nativescript-core/text/text.d.ts b/nativescript-core/text/index.d.ts similarity index 100% rename from nativescript-core/text/text.d.ts rename to nativescript-core/text/index.d.ts diff --git a/nativescript-core/text/text.ios.ts b/nativescript-core/text/index.ios.ts similarity index 100% rename from nativescript-core/text/text.ios.ts rename to nativescript-core/text/index.ios.ts diff --git a/nativescript-core/text/package.json b/nativescript-core/text/package.json deleted file mode 100644 index 7672ddaa1..000000000 --- a/nativescript-core/text/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "text", - "main": "text", - "types": "text.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/timer/timer.android.ts b/nativescript-core/timer/index.android.ts similarity index 100% rename from nativescript-core/timer/timer.android.ts rename to nativescript-core/timer/index.android.ts diff --git a/nativescript-core/timer/timer.d.ts b/nativescript-core/timer/index.d.ts similarity index 100% rename from nativescript-core/timer/timer.d.ts rename to nativescript-core/timer/index.d.ts diff --git a/nativescript-core/timer/timer.ios.ts b/nativescript-core/timer/index.ios.ts similarity index 100% rename from nativescript-core/timer/timer.ios.ts rename to nativescript-core/timer/index.ios.ts diff --git a/nativescript-core/timer/package.json b/nativescript-core/timer/package.json deleted file mode 100644 index e331454b2..000000000 --- a/nativescript-core/timer/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "timer", - "main": "timer", - "types": "timer.d.ts", - "nativescript": {} -} diff --git a/nativescript-core/trace/index.ts b/nativescript-core/trace/index.ts index 8247f3d20..d6d98c147 100644 --- a/nativescript-core/trace/index.ts +++ b/nativescript-core/trace/index.ts @@ -8,7 +8,7 @@ export interface TraceWriter { /** * An interface used to trace information about specific event. */ -export interface EventListener { +export interface TraceEventListener { filter: string; on(object: Object, name: string, data?: any): void; } @@ -16,15 +16,15 @@ export interface EventListener { /** * An interface used to for handling trace error */ -export interface ErrorHandler { +export interface TraceErrorHandler { handlerError(error: Error): any; } let enabled = false; let _categories = {}; let _writers: Array = []; -let _eventListeners: Array = []; -let _errorHandler: ErrorHandler; +let _eventListeners: Array = []; +let _errorHandler: TraceErrorHandler; export namespace Trace { /** @@ -147,7 +147,7 @@ export namespace Trace { return; } - let i, listener: EventListener, filters: Array; + let i, listener: TraceEventListener, filters: Array; for (i = 0; i < _eventListeners.length; i++) { listener = _eventListeners[i]; if (listener.filter) { @@ -163,11 +163,11 @@ export namespace Trace { } } - export function addEventListener(listener: EventListener) { + export function addEventListener(listener: TraceEventListener) { _eventListeners.push(listener); } - export function removeEventListener(listener: EventListener) { + export function removeEventListener(listener: TraceEventListener) { const index = _eventListeners.indexOf(listener); if (index >= 0) { _eventListeners.splice(index, 1); @@ -266,18 +266,18 @@ export namespace Trace { // register a ConsoleWriter by default addWriter(new ConsoleWriter()); - export class DefaultErrorHandler implements ErrorHandler { + export class DefaultErrorHandler implements TraceErrorHandler { handlerError(error) { throw error; } } setErrorHandler(new DefaultErrorHandler()); - export function getErrorHandler(): ErrorHandler { + export function getErrorHandler(): TraceErrorHandler { return _errorHandler; } - export function setErrorHandler(handler: ErrorHandler) { + export function setErrorHandler(handler: TraceErrorHandler) { _errorHandler = handler; } diff --git a/nativescript-core/ui/action-bar/action-bar-common.ts b/nativescript-core/ui/action-bar/action-bar-common.ts index 627a02eb1..243aebdd8 100644 --- a/nativescript-core/ui/action-bar/action-bar-common.ts +++ b/nativescript-core/ui/action-bar/action-bar-common.ts @@ -319,7 +319,7 @@ export class ActionItemBase extends ViewBase implements ActionItemDefinition { } } - @profile + @profile() public onLoaded() { if (this._actionView) { this._actionView.style[horizontalAlignmentProperty.cssName] = "center"; diff --git a/nativescript-core/ui/action-bar/action-bar.android.ts b/nativescript-core/ui/action-bar/index.android.ts similarity index 99% rename from nativescript-core/ui/action-bar/action-bar.android.ts rename to nativescript-core/ui/action-bar/index.android.ts index fe59fb8e2..e43a77f5a 100644 --- a/nativescript-core/ui/action-bar/action-bar.android.ts +++ b/nativescript-core/ui/action-bar/index.android.ts @@ -7,7 +7,7 @@ import { import { View} from '../core/view'; import { Color} from '../../color'; import { layout} from '../../utils/utils'; -import { colorProperty} from '../core/bindable'; +import { colorProperty} from '../styling/style-properties'; 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/index.d.ts similarity index 100% rename from nativescript-core/ui/action-bar/action-bar.d.ts rename to nativescript-core/ui/action-bar/index.d.ts diff --git a/nativescript-core/ui/action-bar/action-bar.ios.ts b/nativescript-core/ui/action-bar/index.ios.ts similarity index 97% rename from nativescript-core/ui/action-bar/action-bar.ios.ts rename to nativescript-core/ui/action-bar/index.ios.ts index 97a8aa143..3abc096dc 100644 --- a/nativescript-core/ui/action-bar/action-bar.ios.ts +++ b/nativescript-core/ui/action-bar/index.ios.ts @@ -1,10 +1,13 @@ import { IOSActionItemSettings, ActionItem as ActionItemDefinition } from "."; import { - ActionItemBase, ActionBarBase, isVisible, View, - colorProperty, backgroundColorProperty, - backgroundInternalProperty, flatProperty, iosIconRenderingModeProperty, - layout, Color, traceMissingIcon + ActionItemBase, ActionBarBase, isVisible, + flatProperty, iosIconRenderingModeProperty, + traceMissingIcon } from "./action-bar-common"; +import { View} from '../core/view'; +import { Color} from '../../color'; +import { layout} from '../../utils/utils'; +import { colorProperty, backgroundColorProperty, backgroundInternalProperty } from '../styling/style-properties'; import { ImageSource } from "../../image-source"; import { ios as iosUtils, isFontIconURI } from "../../utils/utils"; diff --git a/nativescript-core/ui/action-bar/package.json b/nativescript-core/ui/action-bar/package.json deleted file mode 100644 index fb5389b1b..000000000 --- a/nativescript-core/ui/action-bar/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "action-bar", - "main": "action-bar", - "types": "action-bar.d.ts" -} diff --git a/nativescript-core/ui/activity-indicator/activity-indicator-common.ts b/nativescript-core/ui/activity-indicator/activity-indicator-common.ts index 046120f26..151fa468e 100644 --- a/nativescript-core/ui/activity-indicator/activity-indicator-common.ts +++ b/nativescript-core/ui/activity-indicator/activity-indicator-common.ts @@ -1,5 +1,7 @@ import { ActivityIndicator as ActivityIndicatorDefinition } from "."; -import { View, Property, booleanConverter, CSSType } from "../core/view"; +import { View, CSSType } from "../core/view"; +import { booleanConverter } from "../core/view-base"; +import { Property } from "../core/properties"; @CSSType("ActivityIndicator") export class ActivityIndicatorBase extends View implements ActivityIndicatorDefinition { diff --git a/nativescript-core/ui/activity-indicator/activity-indicator.android.ts b/nativescript-core/ui/activity-indicator/index.android.ts similarity index 90% rename from nativescript-core/ui/activity-indicator/activity-indicator.android.ts rename to nativescript-core/ui/activity-indicator/index.android.ts index ebb998999..eb1cdba35 100644 --- a/nativescript-core/ui/activity-indicator/activity-indicator.android.ts +++ b/nativescript-core/ui/activity-indicator/index.android.ts @@ -1,4 +1,6 @@ -import { ActivityIndicatorBase, busyProperty, colorProperty, visibilityProperty, Visibility, Color } from "./activity-indicator-common"; +import { ActivityIndicatorBase, busyProperty} from "./activity-indicator-common"; +import { colorProperty, visibilityProperty, Visibility } from '../styling/style-properties'; +import { Color } from '../../color'; export * from "./activity-indicator-common"; diff --git a/nativescript-core/ui/activity-indicator/activity-indicator.d.ts b/nativescript-core/ui/activity-indicator/index.d.ts similarity index 100% rename from nativescript-core/ui/activity-indicator/activity-indicator.d.ts rename to nativescript-core/ui/activity-indicator/index.d.ts diff --git a/nativescript-core/ui/activity-indicator/activity-indicator.ios.ts b/nativescript-core/ui/activity-indicator/index.ios.ts similarity index 89% rename from nativescript-core/ui/activity-indicator/activity-indicator.ios.ts rename to nativescript-core/ui/activity-indicator/index.ios.ts index 153e45673..82868371a 100644 --- a/nativescript-core/ui/activity-indicator/activity-indicator.ios.ts +++ b/nativescript-core/ui/activity-indicator/index.ios.ts @@ -1,9 +1,10 @@ -import { ActivityIndicatorBase, busyProperty, colorProperty, Color } from "./activity-indicator-common"; +import { ActivityIndicatorBase, busyProperty } from "./activity-indicator-common"; +import { colorProperty } from '../styling/style-properties'; +import { Color } from '../../color'; +import { ios } from "../../utils/utils"; export * from "./activity-indicator-common"; -import { ios } from "../../utils/utils"; - const majorVersion = ios.MajorVersion; export class ActivityIndicator extends ActivityIndicatorBase { diff --git a/nativescript-core/ui/activity-indicator/package.json b/nativescript-core/ui/activity-indicator/package.json deleted file mode 100644 index 456428e71..000000000 --- a/nativescript-core/ui/activity-indicator/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "activity-indicator", - "main": "activity-indicator", - "types": "activity-indicator.d.ts" -} diff --git a/nativescript-core/ui/animation/animation.android.ts b/nativescript-core/ui/animation/index.android.ts similarity index 100% rename from nativescript-core/ui/animation/animation.android.ts rename to nativescript-core/ui/animation/index.android.ts diff --git a/nativescript-core/ui/animation/animation.d.ts b/nativescript-core/ui/animation/index.d.ts similarity index 100% rename from nativescript-core/ui/animation/animation.d.ts rename to nativescript-core/ui/animation/index.d.ts diff --git a/nativescript-core/ui/animation/animation.ios.ts b/nativescript-core/ui/animation/index.ios.ts similarity index 100% rename from nativescript-core/ui/animation/animation.ios.ts rename to nativescript-core/ui/animation/index.ios.ts diff --git a/nativescript-core/ui/animation/keyframe-animation.ts b/nativescript-core/ui/animation/keyframe-animation.ts index b00db38ae..5b9aa4807 100644 --- a/nativescript-core/ui/animation/keyframe-animation.ts +++ b/nativescript-core/ui/animation/keyframe-animation.ts @@ -17,7 +17,7 @@ import { Trace } from "../../trace"; // Types. import { unsetValue } from "../core/properties"; -import { Animation } from "./animation"; +import { Animation } from "."; import { backgroundColorProperty, scaleXProperty, scaleYProperty, diff --git a/nativescript-core/ui/animation/package.json b/nativescript-core/ui/animation/package.json deleted file mode 100644 index df2c00e60..000000000 --- a/nativescript-core/ui/animation/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "animation", - "main": "animation", - "types": "animation.d.ts" -} diff --git a/nativescript-core/ui/border/border.d.ts b/nativescript-core/ui/border/border.d.ts deleted file mode 100644 index df3212c6e..000000000 --- a/nativescript-core/ui/border/border.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ContentView } from "../content-view"; - -/** - * Represents a UI border component. - */ -export class Border extends ContentView { - /** - * Gets or sets the corner radius of the border component. - */ - cornerRadius: number; -} diff --git a/nativescript-core/ui/border/border.ts b/nativescript-core/ui/border/index.ts similarity index 93% rename from nativescript-core/ui/border/border.ts rename to nativescript-core/ui/border/index.ts index 676b03257..29299b4fb 100644 --- a/nativescript-core/ui/border/border.ts +++ b/nativescript-core/ui/border/index.ts @@ -1,5 +1,7 @@ import { Border as BorderDefinition } from "."; -import { ContentView, View, layout, CSSType } from "../content-view"; +import { ContentView } from "../content-view"; +import { View, CSSType } from "../core/view"; +import { layout } from "../../utils/utils"; @Deprecated @CSSType("Border") diff --git a/nativescript-core/ui/border/package.json b/nativescript-core/ui/border/package.json deleted file mode 100644 index 6dd554f39..000000000 --- a/nativescript-core/ui/border/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "border", - "main": "border", - "types": "border.d.ts" -} diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts b/nativescript-core/ui/bottom-navigation/index.android.ts similarity index 100% rename from nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts rename to nativescript-core/ui/bottom-navigation/index.android.ts diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.d.ts b/nativescript-core/ui/bottom-navigation/index.d.ts similarity index 100% rename from nativescript-core/ui/bottom-navigation/bottom-navigation.d.ts rename to nativescript-core/ui/bottom-navigation/index.d.ts diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts b/nativescript-core/ui/bottom-navigation/index.ios.ts similarity index 100% rename from nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts rename to nativescript-core/ui/bottom-navigation/index.ios.ts diff --git a/nativescript-core/ui/bottom-navigation/package.json b/nativescript-core/ui/bottom-navigation/package.json deleted file mode 100644 index 2656dc70f..000000000 --- a/nativescript-core/ui/bottom-navigation/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "bottom-navigation", - "main": "bottom-navigation", - "types": "bottom-navigation.d.ts" -} diff --git a/nativescript-core/ui/builder/component-builder/component-builder.ts b/nativescript-core/ui/builder/component-builder/component-builder.ts index b140aa170..af316e150 100644 --- a/nativescript-core/ui/builder/component-builder/component-builder.ts +++ b/nativescript-core/ui/builder/component-builder/component-builder.ts @@ -140,13 +140,13 @@ export function getComponentModule(elementName: string, namespace: string, attri // Support lower-case-dashed component declaration in the XML (https://github.com/NativeScript/NativeScript/issues/309). elementName = elementName.split("-").map(s => s[0].toUpperCase() + s.substring(1)).join(""); - const { instance, instanceModule } = createComponentInstance(elementName, namespace); - moduleExports = getComponentModuleExports(instance, moduleExports, attributes); + const { instance, instanceModule } = createComponentInstance(elementName, namespace, null); + moduleExports = getComponentModuleExports(instance, moduleExports, attributes); if (isRootComponent) { applyComponentCss(instance, moduleNamePath, attributes); } - applyComponentAttributes(instance, instanceModule, moduleExports, attributes); + applyComponentAttributes(instance, instanceModule, moduleExports); let componentModule; if (instance && instanceModule) { diff --git a/nativescript-core/ui/builder/builder.d.ts b/nativescript-core/ui/builder/index.d.ts similarity index 100% rename from nativescript-core/ui/builder/builder.d.ts rename to nativescript-core/ui/builder/index.d.ts diff --git a/nativescript-core/ui/builder/builder.ts b/nativescript-core/ui/builder/index.ts similarity index 98% rename from nativescript-core/ui/builder/builder.ts rename to nativescript-core/ui/builder/index.ts index 12c8bd5ec..ad32b7950 100644 --- a/nativescript-core/ui/builder/builder.ts +++ b/nativescript-core/ui/builder/index.ts @@ -1,7 +1,8 @@ // Definitions. -import { LoadOptions } from "."; -import { View, ViewBase, Template, KeyedTemplate } from "../core/view"; +import { View, Template, KeyedTemplate } from "../core/view"; +import { ViewBase } from "../core/view-base"; import { ViewEntry } from "../frame"; +import { Page } from "../page"; // Types. import { debug, ScopeError, SourceError, Source } from "../../utils/debug"; @@ -17,6 +18,14 @@ const ios = platformNames.ios.toLowerCase(); const android = platformNames.android.toLowerCase(); const defaultNameSpaceMatcher = /tns\.xsd$/i; +export interface LoadOptions { + path: string; + name: string; + attributes?: any; + exports?: any; + page?: Page; +} + export class Builder { static createViewFromEntry(entry: ViewEntry): View { if (entry.create) { @@ -482,7 +491,7 @@ namespace xml2ui { const context = this._context; const errorFormat = this._templateProperty.errorFormat; const sourceTracker = this._templateProperty.sourceTracker; - const template: Template = profile("Template()", () => { + const template: Template =