├── .github ├── issue_template.md └── pull_request_template.md ├── .gitignore ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── demo-server ├── package-lock.json ├── package.json └── sse.js ├── demo ├── app │ ├── App_Resources │ │ ├── Android │ │ │ ├── app.gradle │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── res │ │ │ │ ├── drawable-hdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-ldpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-mdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-nodpi │ │ │ │ └── splash_screen.xml │ │ │ │ ├── drawable-xhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-xxxhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── values-v21 │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ │ ├── values-v29 │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ └── iOS │ │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── icon-1024.png │ │ │ │ ├── icon-20.png │ │ │ │ ├── icon-20@2x.png │ │ │ │ ├── icon-20@3x.png │ │ │ │ ├── icon-29.png │ │ │ │ ├── icon-29@2x.png │ │ │ │ ├── icon-29@3x.png │ │ │ │ ├── icon-40.png │ │ │ │ ├── icon-40@2x.png │ │ │ │ ├── icon-40@3x.png │ │ │ │ ├── icon-60@2x.png │ │ │ │ ├── icon-60@3x.png │ │ │ │ ├── icon-76.png │ │ │ │ ├── icon-76@2x.png │ │ │ │ └── icon-83.5@2x.png │ │ │ ├── Contents.json │ │ │ ├── LaunchScreen.AspectFill.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchScreen-AspectFill.png │ │ │ │ ├── LaunchScreen-AspectFill@2x.png │ │ │ │ └── LaunchScreen-AspectFill@3x.png │ │ │ └── LaunchScreen.Center.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchScreen-Center.png │ │ │ │ ├── LaunchScreen-Center@2x.png │ │ │ │ └── LaunchScreen-Center@3x.png │ │ │ ├── Info.plist │ │ │ ├── LaunchScreen.storyboard │ │ │ └── build.xcconfig │ ├── app-root.xml │ ├── app.css │ ├── app.ts │ ├── home │ │ ├── home-page.ts │ │ ├── home-page.xml │ │ └── home-view-model.ts │ ├── package.json │ └── tests │ │ └── tests.js ├── karma.conf.js ├── package-lock.json ├── package.json ├── tsconfig.json ├── tsconfig.tns.json ├── tsfmt.json └── webpack.config.js ├── publish ├── pack.sh ├── package-lock.json ├── package.json └── publish.sh ├── src ├── .npmignore ├── index.d.ts ├── package-lock.json ├── package.json ├── platforms │ ├── android │ │ └── include.gradle │ └── ios │ │ ├── PodFile │ │ └── build.xconfig ├── references.d.ts ├── scripts │ └── build-native.js ├── sse.android.ts ├── sse.common.ts ├── sse.ios.ts ├── tsconfig.json └── typings │ └── objc!IKEventSource.d.ts └── tslint.json /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | ### Make sure to check the demo app(s) for sample usage 2 | 3 | ### Make sure to check the existing issues in this repository 4 | 5 | ### If the demo apps cannot help and there is no issue for your problem, tell us about it 6 | Please, ensure your title is less than 63 characters long and starts with a capital 7 | letter. 8 | 9 | ### Which platform(s) does your issue occur on? 10 | - iOS/Android/Both 11 | - iOS/Android versions 12 | - emulator or device. What type of device? 13 | 14 | ### Please, provide the following version numbers that your issue occurs with: 15 | 16 | - CLI: (run `tns --version` to fetch it) 17 | - Cross-platform modules: (check the 'version' attribute in the 18 | `node_modules/tns-core-modules/package.json` file in your project) 19 | - Runtime(s): (look for the `"tns-android"` and `"tns-ios"` properties in the `package.json` file of your project) 20 | - Plugin(s): (look for the version numbers in the `package.json` file of your 21 | project and paste your dependencies and devDependencies here) 22 | 23 | ### Please, tell us how to recreate the issue in as much detail as possible. 24 | Describe the steps to reproduce it. 25 | 26 | ### Is there any code involved? 27 | - provide a code example to recreate the problem 28 | - (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible. 29 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | ## PR Checklist 11 | 12 | - [ ] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages. 13 | - [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. 14 | - [ ] All existing tests are passing 15 | - [ ] Tests for the changes are included 16 | 17 | ## What is the current behavior? 18 | 19 | 20 | ## What is the new behavior? 21 | 22 | 23 | Fixes/Implements/Closes #[Issue Number]. 24 | 25 | 26 | 27 | 36 | 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .idea 3 | .DS_Store 4 | *.js 5 | *.esm.json 6 | *.js.map 7 | *.log 8 | src/*.d.ts 9 | !src/index.d.ts 10 | !src/references.d.ts 11 | !src/scripts/*.js 12 | !seed-tests/*.js 13 | seed-tests/seed-copy-new-git-repo/**/*.* 14 | !demo/karma.conf.js 15 | !demo/app/tests/*.js 16 | !demo-server/*.js 17 | demo/*.d.ts 18 | !demo/references.d.ts 19 | demo/lib 20 | demo/platforms 21 | demo/hooks 22 | node_modules 23 | publish/src 24 | publish/package 25 | demo/report/report.html 26 | demo/report/stats.json -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - stage: "Lint" 4 | language: node_js 5 | os: linux 6 | node_js: "10" 7 | script: cd src && npm run ci.tslint 8 | - stage: "WebPack, Build and Test" 9 | os: osx 10 | env: 11 | - WebPack="iOS" 12 | osx_image: xcode10.2 13 | language: node_js 14 | node_js: "10" 15 | jdk: oraclejdk8 16 | script: cd src && npm run build && cd ../demo && npm i && tns build ios --bundle --env.uglify 17 | - language: android 18 | os: linux 19 | env: 20 | - WebPack="Android" 21 | jdk: oraclejdk8 22 | before_install: nvm install 10 23 | script: cd src && npm run build && cd ../demo && npm i && tns build android --bundle --env.uglify --env.snapshot 24 | - language: android 25 | env: 26 | - BuildAndroid="28" 27 | os: linux 28 | jdk: oraclejdk8 29 | before_install: nvm install 10 30 | script: 31 | - cd src && npm i && npm run tsc && cd ../demo && tns build android 32 | - os: osx 33 | env: 34 | - BuildiOS="12" 35 | - Xcode="10.0" 36 | osx_image: xcode10.2 37 | language: node_js 38 | node_js: "10" 39 | jdk: oraclejdk8 40 | script: 41 | - cd src && npm i && npm run tsc && cd ../demo && tns build ios 42 | - os: linux 43 | language: android 44 | dist: precise 45 | sudo: required 46 | jdk: oraclejdk8 47 | before_script: 48 | - echo no | android create avd --force -n test -t android-21 -b armeabi-v7a 49 | - emulator -avd test -no-audio -no-window & 50 | - android-wait-for-emulator 51 | before_install: 52 | - nvm install 10 53 | script: cd src && npm run test.android 54 | - os: osx 55 | language: node_js 56 | node_js: "10" 57 | jdk: oraclejdk8 58 | osx_image: xcode10.2 59 | script: cd src && npm run test.ios 60 | 61 | android: 62 | components: 63 | - tools 64 | - platform-tools 65 | - build-tools-28.0.3 66 | - android-28 67 | - extra-android-m2repository 68 | - sys-img-armeabi-v7a-android-21 69 | 70 | before_install: 71 | - sudo pip install --upgrade pip 72 | - sudo pip install six 73 | 74 | install: 75 | - echo no | npm install -g nativescript 76 | - tns usage-reporting disable 77 | - tns error-reporting disable 78 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # NativeScript Community Code of Conduct 2 | 3 | Our community members come from all walks of life and are all at different stages of their personal and professional journeys. To support everyone, we've prepared a short code of conduct. Our mission is best served in an environment that is friendly, safe, and accepting; free from intimidation or harassment. 4 | 5 | Towards this end, certain behaviors and practices will not be tolerated. 6 | 7 | ## tl;dr 8 | 9 | - Be respectful. 10 | - We're here to help. 11 | - Abusive behavior is never tolerated. 12 | - Violations of this code may result in swift and permanent expulsion from the NativeScript community channels. 13 | 14 | ## Administrators 15 | 16 | - Dan Wilson (@DanWilson on Slack) 17 | - Jen Looper (@jen.looper on Slack) 18 | - TJ VanToll (@tjvantoll on Slack) 19 | 20 | ## Scope 21 | 22 | We expect all members of the NativeScript community, including administrators, users, facilitators, and vendors to abide by this Code of Conduct at all times in our community venues, online and in person, and in one-on-one communications pertaining to NativeScript affairs. 23 | 24 | This policy covers the usage of the NativeScript Slack community, as well as the NativeScript support forums, NativeScript GitHub repositories, the NativeScript website, and any NativeScript-related events. This Code of Conduct is in addition to, and does not in any way nullify or invalidate, any other terms or conditions related to use of NativeScript. 25 | 26 | The definitions of various subjective terms such as "discriminatory", "hateful", or "confusing" will be decided at the sole discretion of the NativeScript administrators. 27 | 28 | ## Friendly, Harassment-Free Space 29 | 30 | We are committed to providing a friendly, safe, and welcoming environment for all, regardless of gender identity, sexual orientation, disability, ethnicity, religion, age, physical appearance, body size, race, or similar personal characteristics. 31 | 32 | We ask that you please respect that people have differences of opinion regarding technical choices, and acknowledge that every design or implementation choice carries a trade-off and numerous costs. There is seldom a single right answer. A difference of technology preferences is never a license to be rude. 33 | 34 | Any spamming, trolling, flaming, baiting, or other attention-stealing behaviour is not welcome, and will not be tolerated. 35 | 36 | Harassing other users of NativeScript is never tolerated, whether via public or private media. 37 | 38 | Avoid using offensive or harassing package names, nicknames, or other identifiers that might detract from a friendly, safe, and welcoming environment for all. 39 | 40 | Harassment includes, but is not limited to: harmful or prejudicial verbal or written comments related to gender identity, sexual orientation, disability, ethnicity, religion, age, physical appearance, body size, race, or similar personal characteristics; inappropriate use of nudity, sexual images, and/or sexually explicit language in public spaces; threats of physical or non-physical harm; deliberate intimidation, stalking or following; harassing photography or recording; sustained disruption of talks or other events; inappropriate physical contact; and unwelcome sexual attention. 41 | 42 | ## Acceptable Content 43 | 44 | The NativeScript administrators reserve the right to make judgement calls about what is and isn't appropriate in published content. These are guidelines to help you be successful in our community. 45 | 46 | Content must contain something applicable to the previously stated goals of the NativeScript community. "Spamming", that is, publishing any form of content that is not applicable, is not allowed. 47 | 48 | Content must not contain illegal or infringing content. You should only publish content to NativeScript properties if you have the right to do so. This includes complying with all software license agreements or other intellectual property restrictions. For example, redistributing an MIT-licensed module with the copyright notice removed, would not be allowed. You will be responsible for any violation of laws or others’ intellectual property rights. 49 | 50 | Content must not be malware. For example, content (code, video, pictures, words, etc.) which is designed to maliciously exploit or damage computer systems, is not allowed. 51 | 52 | Content name, description, and other visible metadata must not include abusive, inappropriate, or harassing content. 53 | 54 | ## Reporting Violations of this Code of Conduct 55 | 56 | If you believe someone is harassing you or has otherwise violated this Code of Conduct, please contact the administrators and send us an abuse report. If this is the initial report of a problem, please include as much detail as possible. It is easiest for us to address issues when we have more context. 57 | 58 | ## Consequences 59 | 60 | All content published to the NativeScript community channels is hosted at the sole discretion of the NativeScript administrators. 61 | 62 | Unacceptable behavior from any community member, including sponsors, employees, customers, or others with decision-making authority, will not be tolerated. 63 | 64 | Anyone asked to stop unacceptable behavior is expected to comply immediately. 65 | 66 | If a community member engages in unacceptable behavior, the NativeScript administrators may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event or service). 67 | 68 | ## Addressing Grievances 69 | 70 | If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify the administrators. We will do our best to ensure that your grievance is handled appropriately. 71 | 72 | In general, we will choose the course of action that we judge as being most in the interest of fostering a safe and friendly community. 73 | 74 | ## Contact Info 75 | Please contact Dan Wilson @DanWilson if you need to report a problem or address a grievance related to an abuse report. 76 | 77 | You are also encouraged to contact us if you are curious about something that might be "on the line" between appropriate and inappropriate content. We are happy to provide guidance to help you be a successful part of our community. 78 | 79 | ## Credit and License 80 | 81 | This Code of Conduct borrows heavily from the WADE Code of Conduct, which is derived from the NodeBots Code of Conduct, which in turn borrows from the npm Code of Conduct, which was derived from the Stumptown Syndicate Citizen's Code of Conduct, and the Rust Project Code of Conduct. 82 | 83 | This document may be reused under a Creative Commons Attribution-ShareAlike License. -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to NativeScript Plugin Seed 2 | 3 | :+1: First of all, thank you for taking the time to contribute! :+1: 4 | 5 | Here are some guides on how to do that: 6 | 7 | 8 | 9 | - [Code of Conduct](#code-of-conduct) 10 | - [Reporting Bugs](#reporting-bugs) 11 | - [Requesting Features](#requesting-features) 12 | - [Submitting a PR](#submitting-a-pr) 13 | - [Where to Start](#where-to-start) 14 | 15 | 16 | 17 | ## Code of Conduct 18 | Help us keep a healthy and open community. We expect all participants in this project to adhere to the [NativeScript Code Of Conduct](https://github.com/NativeScript/codeofconduct). 19 | 20 | 21 | ## Reporting Bugs 22 | 23 | 1. Always update to the most recent master release; the bug may already be resolved. 24 | 2. Search for similar issues in the issues list for this repo; it may already be an identified problem. 25 | 3. If this is a bug or problem that is clear, simple, and is unlikely to require any discussion -- it is OK to open an issue on GitHub with a reproduction of the bug including workflows and screenshots. If possible, submit a Pull Request with a failing test, entire application or module. If you'd rather take matters into your own hands, fix the bug yourself (jump down to the [Submitting a PR](#submitting-a-pr) section). 26 | 27 | ## Requesting Features 28 | 29 | 1. Use Github Issues to submit feature requests. 30 | 2. First, search for a similar request and extend it if applicable. This way it would be easier for the community to track the features. 31 | 3. When requesting a new feature, please provide as much detail as possible about why you need the feature in your apps. We prefer that you explain a need rather than explain a technical solution for it. That might trigger a nice conversation on finding the best and broadest technical solution to a specific need. 32 | 33 | ## Submitting a PR 34 | 35 | Before you begin: 36 | * Make sure there is an issue for the bug or feature you will be working on. 37 | 38 | Following these steps is the best way to get your code included in the project: 39 | 40 | 1. Fork and clone the nativescript-plugin-seed repo: 41 | ```bash 42 | git clone https://github.com//nativescript-plugin-seed.git 43 | # Navigate to the newly cloned directory 44 | cd nativescript-plugin-seed 45 | # Add an "upstream" remote pointing to the original repo. 46 | git remote add upstream https://github.com/NativeScript/nativescript-plugin-seed.git 47 | ``` 48 | 2. Create a branch for your PR 49 | ```bash 50 | git checkout -b master 51 | ``` 52 | 53 | 3. The fun part! Make your code changes. Make sure you: 54 | - Follow the [code conventions guide](https://github.com/NativeScript/NativeScript/blob/master/CodingConvention.md). 55 | - Follow the [commit message guidelines](https://github.com/NativeScript/NativeScript/blob/pr-template/CONTRIBUTING.md#commit-messages) 56 | - Setup your development workflow. The seed itself is a plugin so you can follow the [development setup][https://github.com/NativeScript/nativescript-plugin-seed#development-setup] described in the README. 57 | - Write unit tests for your fix or feature. If this is not possible, explain how your change can be tested. 58 | > NOTE: For changes in the postclone step, make sure you create tests in `seed-tests/postclone.tests.js`! 59 | 60 | 4. Before you submit your PR: 61 | - Rebase your changes to the latest master: `git pull --rebase upstream master`. 62 | - Ensure all unit test are green. How? 63 | - Go to `seed-tests` 64 | - Run `npm install` 65 | - Run `npm run test.ios` or `npm run test.android` 66 | - Ensure your changes pass tslint validation. (run `npm run tslint` in the root of the repo). 67 | 68 | 6. Push your fork. If you have rebased you might have to use force-push your branch: 69 | ``` 70 | git push origin --force 71 | ``` 72 | 73 | 7. [Submit your pull request](https://github.com/NativeScript/nativescript-plugin-seed/compare) and compare to `NativeScript/nativescript-plugin-seed`. Please, fill in the Pull Request template - it will help us better understand the PR and increase the chances of it getting merged quickly. 74 | 75 | It's our turn from there on! We will review the PR and discuss changes you might have to make before merging it! Thanks! 76 | 77 | ## Where to Start 78 | 79 | If you want to contribute, but you are not sure where to start - look for issues labeled [`help wanted`](https://github.com/NativeScript/nativescript-plugin-seed/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). 80 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright (c) 2015-2018 Telerik AD 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NativeScript Server Sent Events 2 | 3 | [![npm](https://img.shields.io/npm/v/nativescript-sse.svg)](https://www.npmjs.com/package/nativescript-sse) 4 | [![npm](https://img.shields.io/npm/dt/nativescript-sse.svg?label=npm%20downloads)](https://www.npmjs.com/package/nativescript-sse) 5 | [![Build Status](https://travis-ci.org//triniwiz/nativescript-sse.svg?branch=master)](https://travis-ci.org/triniwiz/nativescript-sse) 6 | 7 | 8 | A NativeScript client for the Server Sent Events (SSE). 9 | 10 | ## Install 11 | 12 | `npm install nativescript-sse` 13 | 14 | ## Usage 15 | 16 | ```ts 17 | import { SSE } from 'nativescript-sse'; 18 | 19 | let sse = new SSE(serverApi: string, headers: object); 20 | sse.events.on('onConnect', (data) => { 21 | console.log(data.object.connected); 22 | }); 23 | sse.events.on('onMessage', (data) => { 24 | this.list.push(JSON.parse(data.object.message.data)) 25 | }); 26 | sse.events.on('onError', (data) => { 27 | console.log(data.object.error); 28 | }); 29 | see.close(); 30 | ``` 31 | -------------------------------------------------------------------------------- /demo-server/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SSE-Example", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "node-uuid": { 8 | "version": "1.4.2", 9 | "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.2.tgz", 10 | "integrity": "sha1-kH2z0Rt7aiz0+QX7cZnxSuc3m6A=" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demo-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SSE-Example", 3 | "description": "Example for iOS EventSource implementation on Swift", 4 | "author": "Andres Canal", 5 | "version": "1.0.0", 6 | "dependencies": { 7 | "node-uuid": "1.4.2" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /demo-server/sse.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var uuid = require('node-uuid'); 3 | 4 | var sendInterval = 3000; 5 | 6 | var userNames = ["John", "Monica", "Martin", "Rose", "James", "Tom"]; 7 | var randomMessages = ["I'm fine", "I'll meet you in 10 minutes", "I'll call you back later", "I'm busy"]; 8 | 9 | var intervalID = null; 10 | 11 | function sendServerSendEvent(req, res) { 12 | console.log("Connected") 13 | res.writeHead(200, { 14 | 'Content-Type' : 'text/event-stream', 15 | 'Cache-Control' : 'no-cache', 16 | 'Connection' : 'keep-alive' 17 | }); 18 | 19 | res.write('\n'); 20 | 21 | intervalID = setInterval(function() { 22 | var eventId = uuid.v1(); 23 | var eventName = null; 24 | var eventData = randomMessages[getRandom(0,randomMessages.length)] 25 | 26 | if (getRandom(0,2) == 0) { 27 | eventName = "user-connected"; 28 | eventData = userNames[getRandom(0,userNames.length)] 29 | } 30 | 31 | console.log('id: ' + eventId); 32 | console.log('event: ' + eventName); 33 | console.log('data: ' + eventData + '\n'); 34 | 35 | writeEvent(res, eventId , eventName, eventData); 36 | 37 | }, sendInterval); 38 | } 39 | 40 | function writeEvent(res, sseId, eventName, data) { 41 | var payload = "" 42 | 43 | payload = 'id: ' + sseId + '\n'; 44 | 45 | if (eventName) { 46 | payload += 'event: ' + eventName + '\n'; 47 | } 48 | 49 | payload += 'data: ' + data + '\n\n'; 50 | 51 | res.write(payload); 52 | } 53 | 54 | function getRandom(min, max) { 55 | return Math.floor(Math.random() * (max - min) + min); 56 | } 57 | 58 | http.createServer(function(req, res) { 59 | if (req.headers.accept && req.headers.accept == 'text/event-stream' && req.url.indexOf('/sse') !== -1){ 60 | req.on('close', function(){ 61 | clearInterval(intervalID); 62 | }); 63 | 64 | sendServerSendEvent(req, res); 65 | }else{ 66 | res.writeHead(404); 67 | res.end(); 68 | } 69 | }).listen(8000); 70 | 71 | console.log("Listening") 72 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/app.gradle: -------------------------------------------------------------------------------- 1 | // Add your native dependencies here: 2 | 3 | // Uncomment to add recyclerview-v7 dependency 4 | //dependencies { 5 | // implementation 'com.android.support:recyclerview-v7:+' 6 | //} 7 | 8 | // If you want to add something to be applied before applying plugins' include.gradle files 9 | // e.g. project.ext.googlePlayServicesVersion = "15.0.1" 10 | // create a file named before-plugins.gradle in the current directory and place it there 11 | 12 | android { 13 | defaultConfig { 14 | minSdkVersion 17 15 | generatedDensities = [] 16 | } 17 | aaptOptions { 18 | additionalParameters "--no-version-vectors" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values-v21/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3d5afe 4 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 13 | 14 | 15 | 18 | 19 | 20 | 23 | 24 | 28 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values-v29/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 11 | 12 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #F5F5F5 4 | #757575 5 | #33B5E5 6 | #272734 7 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | 18 | 20 | 21 | 22 | 29 | 30 | 32 | 33 | 34 | 39 | 40 | 42 | 43 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "icon-20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "icon-20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "icon-29.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "icon-29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "icon-29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "icon-40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "icon-40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "icon-60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "icon-60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "icon-20.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "icon-20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "icon-29.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "icon-29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "icon-40.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "icon-40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "icon-76.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "icon-76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "icon-83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "icon-1024.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-AspectFill.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-AspectFill@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchScreen-AspectFill@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-Center.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-Center@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchScreen-Center@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triniwiz/nativescript-sse/9f797e43fad45c7149440f19079ca858bd218624/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiresFullScreen 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | NSAppTransportSecurity 47 | 48 | NSAllowsArbitraryLoads 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/build.xcconfig: -------------------------------------------------------------------------------- 1 | // You can add custom settings here 2 | // for example you can uncomment the following line to force distribution code signing 3 | // CODE_SIGN_IDENTITY = iPhone Distribution 4 | // To build for device with XCode you need to specify your development team. 5 | // DEVELOPMENT_TEAM = YOUR_TEAM_ID; 6 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 7 | -------------------------------------------------------------------------------- /demo/app/app-root.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demo/app/app.css: -------------------------------------------------------------------------------- 1 | @import "~@nativescript/theme/css/core.css"; 2 | @import "~@nativescript/theme/css/blue.css"; 3 | 4 | /* Place any CSS rules you want to apply on both iOS and Android here. 5 | This is where the vast majority of your CSS code goes. */ 6 | .message { 7 | color: #000; 8 | font-size: 20; 9 | horizontal-align: center; 10 | padding:20; 11 | } -------------------------------------------------------------------------------- /demo/app/app.ts: -------------------------------------------------------------------------------- 1 | import * as app from "tns-core-modules/application"; 2 | 3 | app.run({ moduleName: "app-root" }); 4 | 5 | /* 6 | Do not place any code after the application has been started as it will not 7 | be executed on iOS. 8 | */ 9 | -------------------------------------------------------------------------------- /demo/app/home/home-page.ts: -------------------------------------------------------------------------------- 1 | /* 2 | In NativeScript, a file with the same name as an XML file is known as 3 | a code-behind file. The code-behind is a great place to place your view 4 | logic, and to set up your page’s data binding. 5 | */ 6 | 7 | import { NavigatedData, Page } from "tns-core-modules/ui/page"; 8 | 9 | import { HomeViewModel } from "./home-view-model"; 10 | 11 | export function onNavigatingTo(args: NavigatedData) { 12 | const page = args.object; 13 | 14 | page.bindingContext = new HomeViewModel(); 15 | } 16 | -------------------------------------------------------------------------------- /demo/app/home/home-page.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/app/home/home-view-model.ts: -------------------------------------------------------------------------------- 1 | import { Observable } from "tns-core-modules/data/observable"; 2 | import { ObservableArray } from 'tns-core-modules/data/observable-array'; 3 | import { SSE } from 'nativescript-sse'; 4 | import { isAndroid } from 'tns-core-modules/platform'; 5 | 6 | export class HomeViewModel extends Observable { 7 | list: ObservableArray; 8 | sse: SSE; 9 | constructor() { 10 | super(); 11 | this.list = new ObservableArray(); 12 | this.sse = new SSE(isAndroid ? 'http://10.0.2.2:8000/sse' : 'http://localhost:8000/sse', {'X-Token': 'Test1234'}); 13 | this.sse.events.on('onConnect', data => { 14 | console.log(data.object.connected); 15 | }); 16 | 17 | this.sse.events.on('onMessage', data => { 18 | this.list.push(data.object.message.data); 19 | console.log(data.object.message.data); 20 | }); 21 | this.sse.events.on('onError', data => { 22 | console.log(data.object.error); 23 | }); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /demo/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "app.js", 3 | "android": { 4 | "v8Flags": "--expose_gc", 5 | "markingMode": "none" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /demo/app/tests/tests.js: -------------------------------------------------------------------------------- 1 | var SSE = require("nativescript-sse").SSE; 2 | var sse = new SSE('http://localhost:8000/sse', {'X-Token': 'Test1234'}); 3 | 4 | describe("Events", function() { 5 | it("exists", function() { 6 | expect(sse.events).toBeDefined(); 7 | }); 8 | 9 | it("has on method", function() { 10 | expect(sse.events.on).toBeDefined(); 11 | }); 12 | }); -------------------------------------------------------------------------------- /demo/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | const options = { 3 | 4 | // base path that will be used to resolve all patterns (eg. files, exclude) 5 | basePath: '', 6 | 7 | 8 | // frameworks to use 9 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 10 | frameworks: ['jasmine'], 11 | 12 | 13 | // list of files / patterns to load in the browser 14 | files: ['app/tests/**/*.js'], 15 | 16 | 17 | // list of files to exclude 18 | exclude: [ 19 | ], 20 | 21 | 22 | // preprocess matching files before serving them to the browser 23 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 24 | preprocessors: { 25 | }, 26 | 27 | 28 | // test results reporter to use 29 | // possible values: 'dots', 'progress' 30 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 31 | reporters: ['progress'], 32 | 33 | 34 | // web server port 35 | port: 9876, 36 | 37 | 38 | // enable / disable colors in the output (reporters and logs) 39 | colors: true, 40 | 41 | 42 | // level of logging 43 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 44 | logLevel: config.LOG_INFO, 45 | 46 | 47 | // enable / disable watching file and executing tests whenever any file changes 48 | autoWatch: true, 49 | 50 | 51 | // start these browsers 52 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 53 | browsers: [], 54 | 55 | customLaunchers: { 56 | android: { 57 | base: 'NS', 58 | platform: 'android' 59 | }, 60 | ios: { 61 | base: 'NS', 62 | platform: 'ios' 63 | }, 64 | ios_simulator: { 65 | base: 'NS', 66 | platform: 'ios', 67 | arguments: ['--emulator'] 68 | } 69 | }, 70 | 71 | // Continuous Integration mode 72 | // if true, Karma captures browsers, runs the tests and exits 73 | singleRun: false 74 | }; 75 | 76 | setWebpackPreprocessor(config, options); 77 | setWebpack(config, options); 78 | 79 | config.set(options); 80 | } 81 | 82 | function setWebpackPreprocessor(config, options) { 83 | if (config && config.bundle) { 84 | if (!options.preprocessors) { 85 | options.preprocessors = {}; 86 | } 87 | 88 | options.files.forEach(file => { 89 | if (!options.preprocessors[file]) { 90 | options.preprocessors[file] = []; 91 | } 92 | options.preprocessors[file].push('webpack'); 93 | }); 94 | } 95 | } 96 | 97 | function setWebpack(config, options) { 98 | if (config && config.bundle) { 99 | const env = {}; 100 | env[config.platform] = true; 101 | env.sourceMap = config.debugBrk; 102 | env.appPath = config.appPath; 103 | options.webpack = require('./webpack.config')(env); 104 | delete options.webpack.entry; 105 | delete options.webpack.output.libraryTarget; 106 | const invalidPluginsForUnitTesting = ["GenerateBundleStarterPlugin", "GenerateNativeScriptEntryPointsPlugin"]; 107 | options.webpack.plugins = options.webpack.plugins.filter(p => !invalidPluginsForUnitTesting.includes(p.constructor.name)); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "nativescript": { 3 | "id": "org.nativescript.demo", 4 | "tns-android": { 5 | "version": "6.3.1" 6 | }, 7 | "tns-ios": { 8 | "version": "6.3.0" 9 | } 10 | }, 11 | "dependencies": { 12 | "@nativescript/theme": "~2.2.1", 13 | "nativescript-sse": "file:../src", 14 | "nativescript-unit-test-runner": "0.7.0", 15 | "tns-core-modules": "~6.3.0" 16 | }, 17 | "devDependencies": { 18 | "@types/jasmine": "3.5.0", 19 | "karma": "4.4.1", 20 | "karma-jasmine": "2.0.1", 21 | "karma-nativescript-launcher": "0.4.0", 22 | "karma-webpack": "3.0.5", 23 | "nativescript-dev-webpack": "~1.4.0", 24 | "typescript": "~3.5.3" 25 | }, 26 | "scripts": { 27 | "build.plugin": "cd ../src && npm run build", 28 | "ci.tslint": "npm i && tslint --config '../tslint.json' 'app/**/*.ts' --exclude '**/node_modules/**'" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "experimentalDecorators": true, 6 | "emitDecoratorMetadata": true, 7 | "noEmitHelpers": true, 8 | "noEmitOnError": true, 9 | "skipLibCheck": true, 10 | "lib": [ 11 | "es6", 12 | "dom" 13 | ], 14 | "baseUrl": ".", 15 | "paths": { 16 | "~/*": [ 17 | "app/*" 18 | ], 19 | "*": [ 20 | "./node_modules/*" 21 | ] 22 | } 23 | }, 24 | "exclude": [ 25 | "node_modules", 26 | "platforms", 27 | "../src/node_modules" 28 | ], 29 | "include": [ 30 | "../src", 31 | "**/*" 32 | ] 33 | } -------------------------------------------------------------------------------- /demo/tsconfig.tns.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "module": "esNext", 5 | "moduleResolution": "node" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /demo/tsfmt.json: -------------------------------------------------------------------------------- 1 | { 2 | "indentSize": 4, 3 | "tabSize": 4 4 | } 5 | -------------------------------------------------------------------------------- /demo/webpack.config.js: -------------------------------------------------------------------------------- 1 | const { join, relative, resolve, sep } = require("path"); 2 | 3 | const webpack = require("webpack"); 4 | const nsWebpack = require("nativescript-dev-webpack"); 5 | const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); 6 | const { getNoEmitOnErrorFromTSConfig } = require("nativescript-dev-webpack/utils/tsconfig-utils"); 7 | const CleanWebpackPlugin = require("clean-webpack-plugin"); 8 | const CopyWebpackPlugin = require("copy-webpack-plugin"); 9 | const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); 10 | const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); 11 | const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); 12 | const TerserPlugin = require("terser-webpack-plugin"); 13 | const hashSalt = Date.now().toString(); 14 | 15 | module.exports = env => { 16 | // Add your custom Activities, Services and other Android app components here. 17 | const appComponents = [ 18 | "tns-core-modules/ui/frame", 19 | "tns-core-modules/ui/frame/activity", 20 | ]; 21 | 22 | const platform = env && (env.android && "android" || env.ios && "ios"); 23 | if (!platform) { 24 | throw new Error("You need to provide a target platform!"); 25 | } 26 | 27 | const platforms = ["ios", "android"]; 28 | const projectRoot = __dirname; 29 | 30 | // Default destination inside platforms//... 31 | const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); 32 | 33 | const { 34 | // The 'appPath' and 'appResourcesPath' values are fetched from 35 | // the nsconfig.json configuration file. 36 | appPath = "app", 37 | appResourcesPath = "app/App_Resources", 38 | 39 | // You can provide the following flags when running 'tns run android|ios' 40 | snapshot, // --env.snapshot 41 | production, // --env.production 42 | uglify, // --env.uglify 43 | report, // --env.report 44 | sourceMap, // --env.sourceMap 45 | hiddenSourceMap, // --env.hiddenSourceMap 46 | hmr, // --env.hmr, 47 | unitTesting, // --env.unitTesting, 48 | verbose, // --env.verbose 49 | snapshotInDocker, // --env.snapshotInDocker 50 | skipSnapshotTools, // --env.skipSnapshotTools 51 | compileSnapshot // --env.compileSnapshot 52 | } = env; 53 | 54 | const useLibs = compileSnapshot; 55 | const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap; 56 | const externals = nsWebpack.getConvertedExternals(env.externals); 57 | 58 | const appFullPath = resolve(projectRoot, appPath); 59 | const hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot }); 60 | let coreModulesPackageName = "tns-core-modules"; 61 | const alias = { 62 | '~': appFullPath 63 | }; 64 | 65 | if (hasRootLevelScopedModules) { 66 | coreModulesPackageName = "@nativescript/core"; 67 | alias["tns-core-modules"] = coreModulesPackageName; 68 | } 69 | const appResourcesFullPath = resolve(projectRoot, appResourcesPath); 70 | 71 | const entryModule = nsWebpack.getEntryModule(appFullPath, platform); 72 | const entryPath = `.${sep}${entryModule}.ts`; 73 | const entries = { bundle: entryPath }; 74 | 75 | const tsConfigPath = resolve(projectRoot, "tsconfig.tns.json"); 76 | 77 | const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1); 78 | if (platform === "ios" && !areCoreModulesExternal) { 79 | entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules"; 80 | }; 81 | 82 | let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist); 83 | 84 | const itemsToClean = [`${dist}/**/*`]; 85 | if (platform === "android") { 86 | itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`); 87 | itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`); 88 | } 89 | 90 | const noEmitOnErrorFromTSConfig = getNoEmitOnErrorFromTSConfig(tsConfigPath); 91 | 92 | nsWebpack.processAppComponents(appComponents, platform); 93 | const config = { 94 | mode: production ? "production" : "development", 95 | context: appFullPath, 96 | externals, 97 | watchOptions: { 98 | ignored: [ 99 | appResourcesFullPath, 100 | // Don't watch hidden files 101 | "**/.*", 102 | ] 103 | }, 104 | target: nativescriptTarget, 105 | entry: entries, 106 | output: { 107 | pathinfo: false, 108 | path: dist, 109 | sourceMapFilename, 110 | libraryTarget: "commonjs2", 111 | filename: "[name].js", 112 | globalObject: "global", 113 | hashSalt 114 | }, 115 | resolve: { 116 | extensions: [".ts", ".js", ".scss", ".css"], 117 | // Resolve {N} system modules from tns-core-modules 118 | modules: [ 119 | resolve(__dirname, `node_modules/${coreModulesPackageName}`), 120 | resolve(__dirname, "node_modules"), 121 | `node_modules/${coreModulesPackageName}`, 122 | "node_modules", 123 | ], 124 | alias, 125 | // resolve symlinks to symlinked modules 126 | symlinks: true 127 | }, 128 | resolveLoader: { 129 | // don't resolve symlinks to symlinked loaders 130 | symlinks: false 131 | }, 132 | node: { 133 | // Disable node shims that conflict with NativeScript 134 | "http": false, 135 | "timers": false, 136 | "setImmediate": false, 137 | "fs": "empty", 138 | "__dirname": false, 139 | }, 140 | devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"), 141 | optimization: { 142 | runtimeChunk: "single", 143 | noEmitOnErrors: noEmitOnErrorFromTSConfig, 144 | splitChunks: { 145 | cacheGroups: { 146 | vendor: { 147 | name: "vendor", 148 | chunks: "all", 149 | test: (module, chunks) => { 150 | const moduleName = module.nameForCondition ? module.nameForCondition() : ''; 151 | return /[\\/]node_modules[\\/]/.test(moduleName) || 152 | appComponents.some(comp => comp === moduleName); 153 | 154 | }, 155 | enforce: true, 156 | }, 157 | } 158 | }, 159 | minimize: !!uglify, 160 | minimizer: [ 161 | new TerserPlugin({ 162 | parallel: true, 163 | cache: true, 164 | sourceMap: isAnySourceMapEnabled, 165 | terserOptions: { 166 | output: { 167 | comments: false, 168 | semicolons: !isAnySourceMapEnabled 169 | }, 170 | compress: { 171 | // The Android SBG has problems parsing the output 172 | // when these options are enabled 173 | 'collapse_vars': platform !== "android", 174 | sequences: platform !== "android", 175 | } 176 | } 177 | }) 178 | ], 179 | }, 180 | module: { 181 | rules: [ 182 | { 183 | include: join(appFullPath, entryPath), 184 | use: [ 185 | // Require all Android app components 186 | platform === "android" && { 187 | loader: "nativescript-dev-webpack/android-app-components-loader", 188 | options: { modules: appComponents } 189 | }, 190 | 191 | { 192 | loader: "nativescript-dev-webpack/bundle-config-loader", 193 | options: { 194 | loadCss: !snapshot, // load the application css if in debug mode 195 | unitTesting, 196 | appFullPath, 197 | projectRoot, 198 | ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform) 199 | } 200 | }, 201 | ].filter(loader => !!loader) 202 | }, 203 | 204 | { 205 | test: /\.(ts|css|scss|html|xml)$/, 206 | use: "nativescript-dev-webpack/hmr/hot-loader" 207 | }, 208 | 209 | { test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader" }, 210 | 211 | { 212 | test: /\.css$/, 213 | use: "nativescript-dev-webpack/css2json-loader" 214 | }, 215 | 216 | { 217 | test: /\.scss$/, 218 | use: [ 219 | "nativescript-dev-webpack/css2json-loader", 220 | "sass-loader" 221 | ] 222 | }, 223 | 224 | { 225 | test: /\.ts$/, 226 | use: { 227 | loader: "ts-loader", 228 | options: { 229 | configFile: tsConfigPath, 230 | // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds 231 | // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement 232 | transpileOnly: true, 233 | allowTsInNodeModules: true, 234 | compilerOptions: { 235 | sourceMap: isAnySourceMapEnabled, 236 | declaration: false 237 | } 238 | }, 239 | } 240 | }, 241 | ] 242 | }, 243 | plugins: [ 244 | // Define useful constants like TNS_WEBPACK 245 | new webpack.DefinePlugin({ 246 | "global.TNS_WEBPACK": "true", 247 | "process": "global.process", 248 | }), 249 | // Remove all files from the out dir. 250 | new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }), 251 | // Copy assets to out dir. Add your own globs as needed. 252 | new CopyWebpackPlugin([ 253 | { from: { glob: "fonts/**" } }, 254 | { from: { glob: "**/*.jpg" } }, 255 | { from: { glob: "**/*.png" } }, 256 | ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), 257 | new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"), 258 | // For instructions on how to set up workers with webpack 259 | // check out https://github.com/nativescript/worker-loader 260 | new NativeScriptWorkerPlugin(), 261 | new nsWebpack.PlatformFSPlugin({ 262 | platform, 263 | platforms, 264 | }), 265 | // Does IPC communication with the {N} CLI to notify events when running in watch mode. 266 | new nsWebpack.WatchStateLoggerPlugin(), 267 | // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds 268 | // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement 269 | new ForkTsCheckerWebpackPlugin({ 270 | tsconfig: tsConfigPath, 271 | async: false, 272 | useTypescriptIncrementalApi: true, 273 | checkSyntacticErrors: true, 274 | memoryLimit: 4096 275 | }) 276 | ], 277 | }; 278 | 279 | if (report) { 280 | // Generate report files for bundles content 281 | config.plugins.push(new BundleAnalyzerPlugin({ 282 | analyzerMode: "static", 283 | openAnalyzer: false, 284 | generateStatsFile: true, 285 | reportFilename: resolve(projectRoot, "report", `report.html`), 286 | statsFilename: resolve(projectRoot, "report", `stats.json`), 287 | })); 288 | } 289 | 290 | if (snapshot) { 291 | config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({ 292 | chunk: "vendor", 293 | requireModules: [ 294 | "tns-core-modules/bundle-entry-points", 295 | ], 296 | projectRoot, 297 | webpackConfig: config, 298 | snapshotInDocker, 299 | skipSnapshotTools, 300 | useLibs 301 | })); 302 | } 303 | 304 | if (hmr) { 305 | config.plugins.push(new webpack.HotModuleReplacementPlugin()); 306 | } 307 | 308 | 309 | return config; 310 | }; 311 | -------------------------------------------------------------------------------- /publish/pack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE_DIR=../src; 4 | TO_SOURCE_DIR=src; 5 | PACK_DIR=package; 6 | ROOT_DIR=..; 7 | PUBLISH=--publish 8 | 9 | install(){ 10 | npm i 11 | } 12 | 13 | pack() { 14 | 15 | echo 'Clearing /src and /package...' 16 | node_modules/.bin/rimraf "$TO_SOURCE_DIR" 17 | node_modules/.bin/rimraf "$PACK_DIR" 18 | 19 | # copy src 20 | echo 'Copying src...' 21 | node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR" 22 | 23 | # copy README & LICENSE to src 24 | echo 'Copying README and LICENSE to /src...' 25 | node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE 26 | node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md 27 | 28 | # compile package and copy files required by npm 29 | echo 'Building /src...' 30 | cd "$TO_SOURCE_DIR" 31 | node_modules/.bin/tsc 32 | cd .. 33 | 34 | echo 'Creating package...' 35 | # create package dir 36 | mkdir "$PACK_DIR" 37 | 38 | # create the package 39 | cd "$PACK_DIR" 40 | npm pack ../"$TO_SOURCE_DIR" 41 | 42 | # delete source directory used to create the package 43 | cd .. 44 | node_modules/.bin/rimraf "$TO_SOURCE_DIR" 45 | } 46 | 47 | install && pack -------------------------------------------------------------------------------- /publish/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-publish", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "balanced-match": { 8 | "version": "1.0.0", 9 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 10 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 11 | "dev": true 12 | }, 13 | "brace-expansion": { 14 | "version": "1.1.11", 15 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 16 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 17 | "dev": true, 18 | "requires": { 19 | "balanced-match": "1.0.0", 20 | "concat-map": "0.0.1" 21 | } 22 | }, 23 | "concat-map": { 24 | "version": "0.0.1", 25 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 26 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 27 | "dev": true 28 | }, 29 | "fs.realpath": { 30 | "version": "1.0.0", 31 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 32 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 33 | "dev": true 34 | }, 35 | "glob": { 36 | "version": "7.1.2", 37 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", 38 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", 39 | "dev": true, 40 | "requires": { 41 | "fs.realpath": "1.0.0", 42 | "inflight": "1.0.6", 43 | "inherits": "2.0.3", 44 | "minimatch": "3.0.4", 45 | "once": "1.4.0", 46 | "path-is-absolute": "1.0.1" 47 | } 48 | }, 49 | "inflight": { 50 | "version": "1.0.6", 51 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 52 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 53 | "dev": true, 54 | "requires": { 55 | "once": "1.4.0", 56 | "wrappy": "1.0.2" 57 | } 58 | }, 59 | "inherits": { 60 | "version": "2.0.3", 61 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 62 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", 63 | "dev": true 64 | }, 65 | "minimatch": { 66 | "version": "3.0.4", 67 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 68 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 69 | "dev": true, 70 | "requires": { 71 | "brace-expansion": "1.1.11" 72 | } 73 | }, 74 | "ncp": { 75 | "version": "2.0.0", 76 | "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", 77 | "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", 78 | "dev": true 79 | }, 80 | "once": { 81 | "version": "1.4.0", 82 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 83 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 84 | "dev": true, 85 | "requires": { 86 | "wrappy": "1.0.2" 87 | } 88 | }, 89 | "path-is-absolute": { 90 | "version": "1.0.1", 91 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 92 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 93 | "dev": true 94 | }, 95 | "rimraf": { 96 | "version": "2.6.2", 97 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", 98 | "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", 99 | "dev": true, 100 | "requires": { 101 | "glob": "7.1.2" 102 | } 103 | }, 104 | "wrappy": { 105 | "version": "1.0.2", 106 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 107 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 108 | "dev": true 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /publish/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-publish", 3 | "version": "1.0.0", 4 | "description": "Publish helper", 5 | "devDependencies": { 6 | "ncp": "^2.0.0", 7 | "rimraf": "^2.5.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /publish/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PACK_DIR=package; 4 | 5 | publish() { 6 | cd $PACK_DIR 7 | echo 'Publishing to npm...' 8 | npm publish *.tgz 9 | } 10 | 11 | ./pack.sh && publish -------------------------------------------------------------------------------- /src/.npmignore: -------------------------------------------------------------------------------- 1 | *.map 2 | *.ts 3 | !*.d.ts 4 | tsconfig.json 5 | scripts/* 6 | platforms/android/* 7 | !platforms/android/include.gradle 8 | !platforms/android/*.aar 9 | !platforms/android/*.jar -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | export class SSE { 2 | public close: Function; 3 | public events: Event; 4 | constructor(url: string, headers?: any) 5 | } 6 | 7 | interface Event { 8 | on(event: "onMessage", callback: (data: MessageData) => void): void; 9 | on(event: "onError", callback: (error: MessageError) => void): void; 10 | on(event: "onConnect", callback: (error: MessageConnected) => void): void; 11 | } 12 | 13 | interface MessageData { 14 | object: { 15 | event: any; 16 | message: { 17 | data: any; 18 | lastEventId: number; 19 | } 20 | }; 21 | } 22 | 23 | interface MessageError { 24 | object: { 25 | error: any; 26 | }; 27 | } 28 | 29 | interface MessageConnected { 30 | object: { 31 | connected: boolean; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /src/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-sse", 3 | "version": "4.0.2", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@babel/code-frame": { 8 | "version": "7.5.5", 9 | "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", 10 | "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", 11 | "dev": true, 12 | "requires": { 13 | "@babel/highlight": "^7.0.0" 14 | } 15 | }, 16 | "@babel/highlight": { 17 | "version": "7.5.0", 18 | "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", 19 | "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", 20 | "dev": true, 21 | "requires": { 22 | "chalk": "^2.0.0", 23 | "esutils": "^2.0.2", 24 | "js-tokens": "^4.0.0" 25 | } 26 | }, 27 | "@nativescript/core": { 28 | "version": "6.3.2", 29 | "resolved": "https://registry.npmjs.org/@nativescript/core/-/core-6.3.2.tgz", 30 | "integrity": "sha512-y4Xg0O3zEYUInt2OuzmMsopRT0nr+j/x0hInA8b7bvFnEvNtohhQkOw1c42dUUsOi2PMruZ6SuaY5Wucp/h4wg==", 31 | "dev": true, 32 | "requires": { 33 | "css-tree": "^1.0.0-alpha.37", 34 | "nativescript-hook": "0.2.5", 35 | "reduce-css-calc": "^2.1.6", 36 | "semver": "6.3.0", 37 | "tns-core-modules-widgets": "6.3.2", 38 | "tslib": "1.10.0" 39 | }, 40 | "dependencies": { 41 | "semver": { 42 | "version": "6.3.0", 43 | "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", 44 | "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", 45 | "dev": true 46 | } 47 | } 48 | }, 49 | "ansi-styles": { 50 | "version": "3.2.1", 51 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", 52 | "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", 53 | "dev": true, 54 | "requires": { 55 | "color-convert": "^1.9.0" 56 | } 57 | }, 58 | "argparse": { 59 | "version": "1.0.10", 60 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 61 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 62 | "dev": true, 63 | "requires": { 64 | "sprintf-js": "~1.0.2" 65 | } 66 | }, 67 | "async": { 68 | "version": "0.9.2", 69 | "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", 70 | "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", 71 | "dev": true 72 | }, 73 | "balanced-match": { 74 | "version": "1.0.0", 75 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 76 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 77 | "dev": true 78 | }, 79 | "brace-expansion": { 80 | "version": "1.1.11", 81 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 82 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 83 | "dev": true, 84 | "requires": { 85 | "balanced-match": "^1.0.0", 86 | "concat-map": "0.0.1" 87 | } 88 | }, 89 | "builtin-modules": { 90 | "version": "1.1.1", 91 | "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", 92 | "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", 93 | "dev": true 94 | }, 95 | "chalk": { 96 | "version": "2.4.2", 97 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", 98 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", 99 | "dev": true, 100 | "requires": { 101 | "ansi-styles": "^3.2.1", 102 | "escape-string-regexp": "^1.0.5", 103 | "supports-color": "^5.3.0" 104 | } 105 | }, 106 | "color-convert": { 107 | "version": "1.9.3", 108 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", 109 | "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", 110 | "dev": true, 111 | "requires": { 112 | "color-name": "1.1.3" 113 | } 114 | }, 115 | "color-name": { 116 | "version": "1.1.3", 117 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", 118 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", 119 | "dev": true 120 | }, 121 | "colors": { 122 | "version": "1.2.1", 123 | "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.1.tgz", 124 | "integrity": "sha512-s8+wktIuDSLffCywiwSxQOMqtPxML11a/dtHE17tMn4B1MSWw/C22EKf7M2KGUBcDaVFEGT+S8N02geDXeuNKg==", 125 | "dev": true 126 | }, 127 | "commander": { 128 | "version": "2.20.3", 129 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", 130 | "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", 131 | "dev": true 132 | }, 133 | "concat-map": { 134 | "version": "0.0.1", 135 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 136 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 137 | "dev": true 138 | }, 139 | "css-tree": { 140 | "version": "1.0.0-alpha.39", 141 | "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.39.tgz", 142 | "integrity": "sha512-7UvkEYgBAHRG9Nt980lYxjsTrCyHFN53ky3wVsDkiMdVqylqRt+Zc+jm5qw7/qyOvN2dHSYtX0e4MbCCExSvnA==", 143 | "dev": true, 144 | "requires": { 145 | "mdn-data": "2.0.6", 146 | "source-map": "^0.6.1" 147 | } 148 | }, 149 | "css-unit-converter": { 150 | "version": "1.1.1", 151 | "resolved": "https://registry.npmjs.org/css-unit-converter/-/css-unit-converter-1.1.1.tgz", 152 | "integrity": "sha1-2bkoGtz9jO2TW9urqDeGiX9k6ZY=", 153 | "dev": true 154 | }, 155 | "cycle": { 156 | "version": "1.0.3", 157 | "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", 158 | "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=", 159 | "dev": true 160 | }, 161 | "deep-equal": { 162 | "version": "0.2.2", 163 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.2.tgz", 164 | "integrity": "sha1-hLdFiW80xoTpjyzg5Cq69Du6AX0=", 165 | "dev": true 166 | }, 167 | "diff": { 168 | "version": "4.0.1", 169 | "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", 170 | "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", 171 | "dev": true 172 | }, 173 | "escape-string-regexp": { 174 | "version": "1.0.5", 175 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 176 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 177 | "dev": true 178 | }, 179 | "esprima": { 180 | "version": "4.0.1", 181 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 182 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 183 | "dev": true 184 | }, 185 | "esutils": { 186 | "version": "2.0.3", 187 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", 188 | "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", 189 | "dev": true 190 | }, 191 | "eyes": { 192 | "version": "0.1.8", 193 | "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", 194 | "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=", 195 | "dev": true 196 | }, 197 | "fs.realpath": { 198 | "version": "1.0.0", 199 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 200 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 201 | "dev": true 202 | }, 203 | "glob": { 204 | "version": "7.1.2", 205 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", 206 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", 207 | "dev": true, 208 | "requires": { 209 | "fs.realpath": "^1.0.0", 210 | "inflight": "^1.0.4", 211 | "inherits": "2", 212 | "minimatch": "^3.0.4", 213 | "once": "^1.3.0", 214 | "path-is-absolute": "^1.0.0" 215 | } 216 | }, 217 | "has-flag": { 218 | "version": "3.0.0", 219 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 220 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 221 | "dev": true 222 | }, 223 | "i": { 224 | "version": "0.3.6", 225 | "resolved": "https://registry.npmjs.org/i/-/i-0.3.6.tgz", 226 | "integrity": "sha1-2WyScyB28HJxG2sQ/X1PZa2O4j0=", 227 | "dev": true 228 | }, 229 | "inflight": { 230 | "version": "1.0.6", 231 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 232 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 233 | "dev": true, 234 | "requires": { 235 | "once": "^1.3.0", 236 | "wrappy": "1" 237 | } 238 | }, 239 | "inherits": { 240 | "version": "2.0.3", 241 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 242 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", 243 | "dev": true 244 | }, 245 | "isstream": { 246 | "version": "0.1.2", 247 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 248 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", 249 | "dev": true 250 | }, 251 | "js-tokens": { 252 | "version": "4.0.0", 253 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", 254 | "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", 255 | "dev": true 256 | }, 257 | "js-yaml": { 258 | "version": "3.13.1", 259 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", 260 | "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", 261 | "dev": true, 262 | "requires": { 263 | "argparse": "^1.0.7", 264 | "esprima": "^4.0.0" 265 | } 266 | }, 267 | "mdn-data": { 268 | "version": "2.0.6", 269 | "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.6.tgz", 270 | "integrity": "sha512-rQvjv71olwNHgiTbfPZFkJtjNMciWgswYeciZhtvWLO8bmX3TnhyA62I6sTWOyZssWHJJjY6/KiWwqQsWWsqOA==", 271 | "dev": true 272 | }, 273 | "minimatch": { 274 | "version": "3.0.4", 275 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 276 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 277 | "dev": true, 278 | "requires": { 279 | "brace-expansion": "^1.1.7" 280 | } 281 | }, 282 | "minimist": { 283 | "version": "0.0.8", 284 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 285 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 286 | "dev": true 287 | }, 288 | "mkdirp": { 289 | "version": "0.5.1", 290 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 291 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 292 | "dev": true, 293 | "requires": { 294 | "minimist": "0.0.8" 295 | } 296 | }, 297 | "mute-stream": { 298 | "version": "0.0.7", 299 | "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", 300 | "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", 301 | "dev": true 302 | }, 303 | "nativescript-hook": { 304 | "version": "0.2.5", 305 | "resolved": "https://registry.npmjs.org/nativescript-hook/-/nativescript-hook-0.2.5.tgz", 306 | "integrity": "sha512-ciGJtNbtMB2lGv8jAkUripkRjd3g8atX9VYPSt6e8PI6YPiOKeoma3xjcXoW66pFMYpHnfrbp6Mq9U/QtiQrVg==", 307 | "dev": true, 308 | "requires": { 309 | "glob": "^6.0.1", 310 | "mkdirp": "^0.5.1" 311 | }, 312 | "dependencies": { 313 | "glob": { 314 | "version": "6.0.4", 315 | "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", 316 | "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", 317 | "dev": true, 318 | "requires": { 319 | "inflight": "^1.0.4", 320 | "inherits": "2", 321 | "minimatch": "2 || 3", 322 | "once": "^1.3.0", 323 | "path-is-absolute": "^1.0.0" 324 | } 325 | } 326 | } 327 | }, 328 | "ncp": { 329 | "version": "1.0.1", 330 | "resolved": "https://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz", 331 | "integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY=", 332 | "dev": true 333 | }, 334 | "once": { 335 | "version": "1.4.0", 336 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 337 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 338 | "dev": true, 339 | "requires": { 340 | "wrappy": "1" 341 | } 342 | }, 343 | "path-is-absolute": { 344 | "version": "1.0.1", 345 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 346 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 347 | "dev": true 348 | }, 349 | "path-parse": { 350 | "version": "1.0.6", 351 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", 352 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", 353 | "dev": true 354 | }, 355 | "pkginfo": { 356 | "version": "0.4.1", 357 | "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz", 358 | "integrity": "sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=", 359 | "dev": true 360 | }, 361 | "postcss-value-parser": { 362 | "version": "3.3.1", 363 | "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", 364 | "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", 365 | "dev": true 366 | }, 367 | "prompt": { 368 | "version": "1.0.0", 369 | "resolved": "https://registry.npmjs.org/prompt/-/prompt-1.0.0.tgz", 370 | "integrity": "sha1-jlcSPDlquYiJf7Mn/Trtw+c15P4=", 371 | "dev": true, 372 | "requires": { 373 | "colors": "^1.1.2", 374 | "pkginfo": "0.x.x", 375 | "read": "1.0.x", 376 | "revalidator": "0.1.x", 377 | "utile": "0.3.x", 378 | "winston": "2.1.x" 379 | } 380 | }, 381 | "read": { 382 | "version": "1.0.7", 383 | "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", 384 | "integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=", 385 | "dev": true, 386 | "requires": { 387 | "mute-stream": "~0.0.4" 388 | } 389 | }, 390 | "reduce-css-calc": { 391 | "version": "2.1.7", 392 | "resolved": "https://registry.npmjs.org/reduce-css-calc/-/reduce-css-calc-2.1.7.tgz", 393 | "integrity": "sha512-fDnlZ+AybAS3C7Q9xDq5y8A2z+lT63zLbynew/lur/IR24OQF5x98tfNwf79mzEdfywZ0a2wpM860FhFfMxZlA==", 394 | "dev": true, 395 | "requires": { 396 | "css-unit-converter": "^1.1.1", 397 | "postcss-value-parser": "^3.3.0" 398 | } 399 | }, 400 | "resolve": { 401 | "version": "1.14.1", 402 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.1.tgz", 403 | "integrity": "sha512-fn5Wobh4cxbLzuHaE+nphztHy43/b++4M6SsGFC2gB8uYwf0C8LcarfCz1un7UTW8OFQg9iNjZ4xpcFVGebDPg==", 404 | "dev": true, 405 | "requires": { 406 | "path-parse": "^1.0.6" 407 | } 408 | }, 409 | "revalidator": { 410 | "version": "0.1.8", 411 | "resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz", 412 | "integrity": "sha1-/s5hv6DBtSoga9axgZgYS91SOjs=", 413 | "dev": true 414 | }, 415 | "rimraf": { 416 | "version": "2.6.2", 417 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", 418 | "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", 419 | "dev": true, 420 | "requires": { 421 | "glob": "^7.0.5" 422 | } 423 | }, 424 | "semver": { 425 | "version": "5.5.0", 426 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", 427 | "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", 428 | "dev": true 429 | }, 430 | "source-map": { 431 | "version": "0.6.1", 432 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 433 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 434 | "dev": true 435 | }, 436 | "sprintf-js": { 437 | "version": "1.0.3", 438 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 439 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 440 | "dev": true 441 | }, 442 | "stack-trace": { 443 | "version": "0.0.10", 444 | "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", 445 | "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", 446 | "dev": true 447 | }, 448 | "supports-color": { 449 | "version": "5.5.0", 450 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 451 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 452 | "dev": true, 453 | "requires": { 454 | "has-flag": "^3.0.0" 455 | } 456 | }, 457 | "tns-core-modules": { 458 | "version": "6.3.2", 459 | "resolved": "https://registry.npmjs.org/tns-core-modules/-/tns-core-modules-6.3.2.tgz", 460 | "integrity": "sha512-WoMslVNu8OSSjNA83xU2DIcvsXeM4zDzgMwD5JRpiw4zrCO9CylM1TZOcat9tw3zkourA/ZK7p8r4efbW9rt6A==", 461 | "dev": true, 462 | "requires": { 463 | "@nativescript/core": "6.3.2" 464 | } 465 | }, 466 | "tns-core-modules-widgets": { 467 | "version": "6.3.2", 468 | "resolved": "https://registry.npmjs.org/tns-core-modules-widgets/-/tns-core-modules-widgets-6.3.2.tgz", 469 | "integrity": "sha512-qnpPFUMvty31BoaD7lMur0BvA2yFemr2JJw/wT4fJwKT2nBlhlNnKv9oeDNQAhawZvTBR5hfkBDNVEPzErxObg==", 470 | "dev": true 471 | }, 472 | "tns-platform-declarations": { 473 | "version": "6.3.2", 474 | "resolved": "https://registry.npmjs.org/tns-platform-declarations/-/tns-platform-declarations-6.3.2.tgz", 475 | "integrity": "sha512-XD7j5LEZr/3dnrTA5eoTz0V/iWuLbiybc3Y/fGnLmrJBlxpipZxuL2tMoii1HD9L67ZWiwXDNkmOMDwTSVRU3A==", 476 | "dev": true 477 | }, 478 | "tslib": { 479 | "version": "1.10.0", 480 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", 481 | "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", 482 | "dev": true 483 | }, 484 | "tslint": { 485 | "version": "5.20.1", 486 | "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz", 487 | "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", 488 | "dev": true, 489 | "requires": { 490 | "@babel/code-frame": "^7.0.0", 491 | "builtin-modules": "^1.1.1", 492 | "chalk": "^2.3.0", 493 | "commander": "^2.12.1", 494 | "diff": "^4.0.1", 495 | "glob": "^7.1.1", 496 | "js-yaml": "^3.13.1", 497 | "minimatch": "^3.0.4", 498 | "mkdirp": "^0.5.1", 499 | "resolve": "^1.3.2", 500 | "semver": "^5.3.0", 501 | "tslib": "^1.8.0", 502 | "tsutils": "^2.29.0" 503 | } 504 | }, 505 | "tsutils": { 506 | "version": "2.29.0", 507 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", 508 | "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", 509 | "dev": true, 510 | "requires": { 511 | "tslib": "^1.8.1" 512 | } 513 | }, 514 | "typescript": { 515 | "version": "3.7.4", 516 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz", 517 | "integrity": "sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==", 518 | "dev": true 519 | }, 520 | "utile": { 521 | "version": "0.3.0", 522 | "resolved": "https://registry.npmjs.org/utile/-/utile-0.3.0.tgz", 523 | "integrity": "sha1-E1LDQOuCDk2N26A5pPv6oy7U7zo=", 524 | "dev": true, 525 | "requires": { 526 | "async": "~0.9.0", 527 | "deep-equal": "~0.2.1", 528 | "i": "0.3.x", 529 | "mkdirp": "0.x.x", 530 | "ncp": "1.0.x", 531 | "rimraf": "2.x.x" 532 | } 533 | }, 534 | "winston": { 535 | "version": "2.1.1", 536 | "resolved": "https://registry.npmjs.org/winston/-/winston-2.1.1.tgz", 537 | "integrity": "sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=", 538 | "dev": true, 539 | "requires": { 540 | "async": "~1.0.0", 541 | "colors": "1.0.x", 542 | "cycle": "1.0.x", 543 | "eyes": "0.1.x", 544 | "isstream": "0.1.x", 545 | "pkginfo": "0.3.x", 546 | "stack-trace": "0.0.x" 547 | }, 548 | "dependencies": { 549 | "async": { 550 | "version": "1.0.0", 551 | "resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", 552 | "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=", 553 | "dev": true 554 | }, 555 | "colors": { 556 | "version": "1.0.3", 557 | "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", 558 | "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", 559 | "dev": true 560 | }, 561 | "pkginfo": { 562 | "version": "0.3.1", 563 | "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", 564 | "integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=", 565 | "dev": true 566 | } 567 | } 568 | }, 569 | "wrappy": { 570 | "version": "1.0.2", 571 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 572 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 573 | "dev": true 574 | } 575 | } 576 | } 577 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-sse", 3 | "version": "4.0.2", 4 | "description": "A NativeScript client for the Server Sent Events (SSE)", 5 | "main": "sse", 6 | "typings": "index.d.ts", 7 | "nativescript": { 8 | "platforms": { 9 | "android": "4.0.0", 10 | "ios": "4.0.1" 11 | } 12 | }, 13 | "scripts": { 14 | "tsc": "npm i && tsc", 15 | "build": "npm run tsc && npm run build.native", 16 | "build.native": "node scripts/build-native.js", 17 | "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"", 18 | "ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/platforms/**'", 19 | "prepack": "npm run build.native", 20 | "demo.ios": "npm i && cd ../demo && tns run ios", 21 | "demo.android": "npm i && cd ../demo && tns run android", 22 | "demo.reset": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json", 23 | "plugin.prepare": "npm run build && cd ../demo && tns plugin remove nativescript-sse && tns plugin add ../src", 24 | "clean": "npm run demo.reset && npx rimraf -- node_modules package-lock.json && npm i", 25 | "test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch", 26 | "test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch", 27 | "plugin.link": "npm link && cd ../demo && npm link nativescript-sse && cd ../src", 28 | "plugin.tscwatch": "npm run tsc -- -w" 29 | }, 30 | "keywords": [ 31 | "NativeScript", 32 | "JavaScript", 33 | "Android", 34 | "iOS", 35 | "events", 36 | "server-sent", 37 | "sse", 38 | "eventsource" 39 | ], 40 | "author": { 41 | "name": "Osei Fortune", 42 | "email": "fortune.osei@yahoo.com" 43 | }, 44 | "bugs": { 45 | "url": "https://github.com/triniwiz/nativescript-sse/issues" 46 | }, 47 | "license": "Apache-2.0", 48 | "homepage": "https://github.com/triniwiz/nativescript-sse", 49 | "readmeFilename": "README.md", 50 | "devDependencies": { 51 | "tns-core-modules": "^6.3.2", 52 | "tns-platform-declarations": "^6.3.2", 53 | "typescript": "~3.7.4", 54 | "prompt": "^1.0.0", 55 | "rimraf": "^2.5.0", 56 | "tslint": "^5.20.1", 57 | "semver": "^5.5.0" 58 | }, 59 | "dependencies": {}, 60 | "bootstrapper": "nativescript-plugin-seed" 61 | } 62 | -------------------------------------------------------------------------------- /src/platforms/android/include.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compile 'com.tylerjroach:eventsource:1.2.11' 3 | } -------------------------------------------------------------------------------- /src/platforms/ios/PodFile: -------------------------------------------------------------------------------- 1 | pod 'IKEventSource', :git => 'https://github.com/flypapertech/EventSource', :branch => 'expose-methods-to-objc' 2 | 3 | post_install do |installer| 4 | installer.pods_project.targets.each do |target| 5 | if target.name == 'IKEventSource' 6 | target.build_configurations.each do |config| 7 | config.build_settings['SWIFT_VERSION'] = '4.0' 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /src/platforms/ios/build.xconfig: -------------------------------------------------------------------------------- 1 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES -------------------------------------------------------------------------------- /src/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | -------------------------------------------------------------------------------- /src/scripts/build-native.js: -------------------------------------------------------------------------------- 1 | const { exec } = require('child_process'); 2 | const semver = require('semver'); 3 | 4 | exec('tns --version', (err, stdout, stderr) => { 5 | if (err) { 6 | // node couldn't execute the command 7 | console.log(`tns --version err: ${err}`); 8 | return; 9 | } 10 | 11 | // In case the current Node.js version is not supported by CLI, a warning in `tns --version` output is shown. 12 | // Sample output: 13 | // 14 | /*Support for Node.js ^8.0.0 is deprecated and will be removed in one of the next releases of NativeScript. Please, upgrade to the latest Node.js LTS version. 15 | 16 | 6.0.0 17 | */ 18 | // Extract the actual version (6.0.0) from it. 19 | const tnsVersion = semver.major((stdout.match(/^(?:\d+\.){2}\d+.*?$/m) || [])[0]); 20 | 21 | // execute 'tns plugin build' for {N} version > 4. This command builds .aar in platforms/android folder. 22 | if (tnsVersion >= 4) { 23 | console.log(`executing 'tns plugin build'`); 24 | exec('tns plugin build', (err, stdout, stderr) => { 25 | if (err) { 26 | // node couldn't execute the command 27 | console.log(`${err}`); 28 | return; 29 | } 30 | }); 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /src/sse.android.ts: -------------------------------------------------------------------------------- 1 | import { BaseSSE } from './sse.common'; 2 | import { fromObject, Observable } from 'tns-core-modules/data/observable'; 3 | 4 | declare var android: any, com: any, java: any, WeakRef; 5 | 6 | export class SSE extends BaseSSE { 7 | private _sseHandler: any; 8 | private _es: any; 9 | private _headers: any; 10 | private _url: any; 11 | public events: Observable; 12 | 13 | constructor(url: string, headers: any = {}) { 14 | super(url, headers); 15 | this._url = new java.net.URI(url); 16 | this.events = fromObject({}); 17 | const that = new WeakRef(this); 18 | const handler = com.tylerjroach.eventsource.EventSourceHandler.extend({ 19 | owner: that.get(), 20 | onConnect() { 21 | this.owner.events.notify({ 22 | eventName: 'onConnect', 23 | object: fromObject({ 24 | connected: true 25 | }) 26 | }); 27 | }, 28 | onMessage(event, message) { 29 | this.owner.events.notify({ 30 | eventName: 'onMessage', 31 | object: fromObject({ 32 | event: event.toString(), 33 | message: { 34 | data: message.data, 35 | lastEventId: message.lastEventId, 36 | origin: message.origin 37 | } 38 | }) 39 | }); 40 | }, 41 | 42 | onComment(comment) { 43 | this.owner.events.notify({ 44 | eventName: 'onComment', 45 | object: fromObject({ 46 | comment: comment 47 | }) 48 | }); 49 | }, 50 | 51 | onError(e) { 52 | this.owner.events.notify({ 53 | eventName: 'onError', 54 | object: fromObject({ 55 | error: e.getMessage() 56 | }) 57 | }); 58 | }, 59 | onClosed(willReconnect) { 60 | this.owner.events.notify({ 61 | eventName: 'willReconnect', 62 | object: fromObject({ 63 | willReconnect: willReconnect 64 | }) 65 | }); 66 | } 67 | }); 68 | this._sseHandler = new handler(); 69 | this._headers = new java.util.HashMap(); 70 | const arr = Object.keys(headers); 71 | if (arr.length > 0) { 72 | arr.forEach(key => { 73 | this._headers.put(key, headers[key]); 74 | }); 75 | } 76 | 77 | this._es = new com.tylerjroach.eventsource.EventSource.Builder(url) 78 | .eventHandler(this._sseHandler) 79 | .headers(this._headers) 80 | .build(); 81 | this._es.connect(); 82 | } 83 | 84 | public addEventListener(event: string): void { 85 | } 86 | 87 | public removeEventListener(event: string): void { 88 | } 89 | 90 | public connect(): void { 91 | if (!this._es) return; 92 | this._es.connect(); 93 | } 94 | 95 | public close(): void { 96 | if (!this._es) return; 97 | this._es.close(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/sse.common.ts: -------------------------------------------------------------------------------- 1 | import { Observable } from 'tns-core-modules/data/observable'; 2 | export abstract class BaseSSE { 3 | public events: Observable; 4 | constructor(url: string, headers: any = {}) {} 5 | public abstract addEventListener(event: string): void; 6 | public abstract removeEventListener(event: string): void; 7 | public abstract connect(): void; 8 | public abstract close(): void; 9 | } 10 | -------------------------------------------------------------------------------- /src/sse.ios.ts: -------------------------------------------------------------------------------- 1 | import { BaseSSE } from './sse.common'; 2 | import { Observable, fromObject } from 'tns-core-modules/data/observable'; 3 | declare const WeakRef, EventSource; 4 | export class SSE extends BaseSSE { 5 | private _headers: NSDictionary; 6 | private _url: NSURL; 7 | private _es: any; 8 | public events: Observable; 9 | private lastEventId: string; 10 | constructor(url: string, headers: any = {}) { 11 | super(url, headers); 12 | this.events = fromObject({}); 13 | this._url = NSURL.alloc().initWithString(url); 14 | this._headers = NSDictionary.alloc().initWithDictionary(headers); 15 | this._es = EventSource.alloc().initWithUrlHeaders(this._url, this._headers); 16 | console.log(this._es); 17 | const ref = new WeakRef(this); 18 | const owner = ref.get(); 19 | this._es.onMessage((id, event, data) => { 20 | this.lastEventId = id; 21 | owner.events.notify({ 22 | eventName: 'onMessage', 23 | object: fromObject({ 24 | event: event, 25 | message: { data: data, lastEventId: id } 26 | }) 27 | }); 28 | }); 29 | this._es.onCompleteBridged((statusCode, shouldReconnect, err) => { 30 | if (err) { 31 | owner.events.notify({ 32 | eventName: 'onError', 33 | object: fromObject({ 34 | error: err.localizedDescription 35 | }) 36 | }); 37 | } 38 | 39 | // NOTE we are not using the shouldReconnect boolean here 40 | // so that we match how the android implementation works 41 | setTimeout(() => { 42 | this._es.connectWithLastEventId(this.lastEventId); 43 | }, 2000); 44 | }); 45 | this._es.onOpen(() => { 46 | owner.events.notify({ 47 | eventName: 'onConnect', 48 | object: fromObject({ 49 | connected: true 50 | }) 51 | }); 52 | }); 53 | this.connect(); 54 | } 55 | public addEventListener(event: string): void { 56 | if (!this._es) return; 57 | const ref = new WeakRef(this); 58 | const owner = ref.get(); 59 | this._es.addEventListenerHandler(event, (id, event, data) => { 60 | owner.events.notify({ 61 | eventName: 'onMessage', 62 | object: fromObject({ 63 | event: event, 64 | message: { data: data, lastEventId: id } 65 | }) 66 | }); 67 | }); 68 | } 69 | public removeEventListener(event: string): void { 70 | if (!this._es) return; 71 | this._es.removeEventListener(event); 72 | } 73 | public connect(): void { 74 | if (!this._es) return; 75 | this._es.connectWithLastEventId(""); 76 | } 77 | public close(): void { 78 | if (!this._es) return; 79 | this._es.disconnect(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "removeComments": true, 7 | "noLib": false, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "skipLibCheck": true, 11 | "lib": ["es6", "dom"], 12 | "sourceMap": true, 13 | "pretty": true, 14 | "allowUnreachableCode": false, 15 | "allowUnusedLabels": false, 16 | "noEmitHelpers": true, 17 | "noEmitOnError": false, 18 | "noImplicitAny": false, 19 | "noImplicitReturns": true, 20 | "noImplicitUseStrict": false, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "exclude": [ 24 | "node_modules" 25 | ], 26 | "compileOnSave": false 27 | } 28 | -------------------------------------------------------------------------------- /src/typings/objc!IKEventSource.d.ts: -------------------------------------------------------------------------------- 1 | 2 | declare class EventSource extends NSObject implements NSURLSessionDataDelegate { 3 | 4 | static alloc(): EventSource; // inherited from NSObject 5 | 6 | static new(): EventSource; // inherited from NSObject 7 | 8 | readonly debugDescription: string; // inherited from NSObjectProtocol 9 | 10 | readonly description: string; // inherited from NSObjectProtocol 11 | 12 | readonly hash: number; // inherited from NSObjectProtocol 13 | 14 | readonly isProxy: boolean; // inherited from NSObjectProtocol 15 | 16 | readonly superclass: typeof NSObject; // inherited from NSObjectProtocol 17 | 18 | readonly; // inherited from NSObjectProtocol 19 | 20 | constructor(o: { url: NSURL; headers: NSDictionary; }); 21 | 22 | URLSessionDataTaskDidBecomeDownloadTask(session: NSURLSession, dataTask: NSURLSessionDataTask, downloadTask: NSURLSessionDownloadTask): void; 23 | 24 | URLSessionDataTaskDidBecomeStreamTask(session: NSURLSession, dataTask: NSURLSessionDataTask, streamTask: NSURLSessionStreamTask): void; 25 | 26 | URLSessionDataTaskDidReceiveData(session: NSURLSession, dataTask: NSURLSessionDataTask, data: NSData): void; 27 | 28 | URLSessionDataTaskDidReceiveResponseCompletionHandler(session: NSURLSession, dataTask: NSURLSessionDataTask, response: NSURLResponse, completionHandler: (p1: NSURLSessionResponseDisposition) => void): void; 29 | 30 | URLSessionDataTaskWillCacheResponseCompletionHandler(session: NSURLSession, dataTask: NSURLSessionDataTask, proposedResponse: NSCachedURLResponse, completionHandler: (p1: NSCachedURLResponse) => void): void; 31 | 32 | URLSessionDidBecomeInvalidWithError(session: NSURLSession, error: NSError): void; 33 | 34 | URLSessionDidFinishEventsForBackgroundURLSession(session: NSURLSession): void; 35 | 36 | URLSessionDidReceiveChallengeCompletionHandler(session: NSURLSession, challenge: NSURLAuthenticationChallenge, completionHandler: (p1: NSURLSessionAuthChallengeDisposition, p2: NSURLCredential) => void): void; 37 | 38 | URLSessionTaskDidCompleteWithError(session: NSURLSession, task: NSURLSessionTask, error: NSError): void; 39 | 40 | URLSessionTaskDidFinishCollectingMetrics(session: NSURLSession, task: NSURLSessionTask, metrics: NSURLSessionTaskMetrics): void; 41 | 42 | URLSessionTaskDidReceiveChallengeCompletionHandler(session: NSURLSession, task: NSURLSessionTask, challenge: NSURLAuthenticationChallenge, completionHandler: (p1: NSURLSessionAuthChallengeDisposition, p2: NSURLCredential) => void): void; 43 | 44 | URLSessionTaskDidSendBodyDataTotalBytesSentTotalBytesExpectedToSend(session: NSURLSession, task: NSURLSessionTask, bytesSent: number, totalBytesSent: number, totalBytesExpectedToSend: number): void; 45 | 46 | URLSessionTaskIsWaitingForConnectivity(session: NSURLSession, task: NSURLSessionTask): void; 47 | 48 | URLSessionTaskNeedNewBodyStream(session: NSURLSession, task: NSURLSessionTask, completionHandler: (p1: NSInputStream) => void): void; 49 | 50 | URLSessionTaskWillBeginDelayedRequestCompletionHandler(session: NSURLSession, task: NSURLSessionTask, request: NSURLRequest, completionHandler: (p1: NSURLSessionDelayedRequestDisposition, p2: NSURLRequest) => void): void; 51 | 52 | URLSessionTaskWillPerformHTTPRedirectionNewRequestCompletionHandler(session: NSURLSession, task: NSURLSessionTask, response: NSHTTPURLResponse, request: NSURLRequest, completionHandler: (p1: NSURLRequest) => void): void; 53 | 54 | addEventListenerHandler(event: string, handler: (p1: string, p2: string, p3: string) => void): void; 55 | 56 | class(): typeof NSObject; 57 | 58 | conformsToProtocol(aProtocol: any /* Protocol */): boolean; 59 | 60 | connectWithLastEventId(lastEventId: string): void; 61 | 62 | disconnect(): void; 63 | 64 | events(): NSArray; 65 | 66 | initWithUrlHeaders(url: NSURL, headers: NSDictionary): this; 67 | 68 | isEqual(object: any): boolean; 69 | 70 | isKindOfClass(aClass: typeof NSObject): boolean; 71 | 72 | isMemberOfClass(aClass: typeof NSObject): boolean; 73 | 74 | onCompleteBridged(onComplete: (statusCode?: number, shouldReconnect?: boolean, error?: NSError) => void): void; 75 | 76 | onMessage(onMessageCallback: (p1?: string, p2?: string, p3?: string) => void): void; 77 | 78 | onOpen(onOpenCallback: () => void): void; 79 | 80 | performSelector(aSelector: string): any; 81 | 82 | performSelectorWithObject(aSelector: string, object: any): any; 83 | 84 | performSelectorWithObjectWithObject(aSelector: string, object1: any, object2: any): any; 85 | 86 | removeEventListener(event: string): void; 87 | 88 | respondsToSelector(aSelector: string): boolean; 89 | 90 | retainCount(): number; 91 | 92 | self(): this; 93 | } 94 | 95 | declare var IKEventSourceVersionNumber: number; 96 | 97 | declare var IKEventSourceVersionString: interop.Reference; 98 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "class-name": true, 4 | "comment-format": [ 5 | true, 6 | "check-space" 7 | ], 8 | "indent": [ 9 | true, 10 | "spaces" 11 | ], 12 | "no-duplicate-variable": true, 13 | "no-eval": true, 14 | "no-internal-module": true, 15 | "no-trailing-whitespace": true, 16 | "no-var-keyword": true, 17 | "one-line": [ 18 | true, 19 | "check-open-brace", 20 | "check-whitespace" 21 | ], 22 | "quotemark": [ 23 | false, 24 | "double" 25 | ], 26 | "semicolon": [ 27 | true, 28 | "always" 29 | ], 30 | "triple-equals": [ 31 | true, 32 | "allow-null-check" 33 | ], 34 | "typedef-whitespace": [ 35 | true, 36 | { 37 | "call-signature": "nospace", 38 | "index-signature": "nospace", 39 | "parameter": "nospace", 40 | "property-declaration": "nospace", 41 | "variable-declaration": "nospace" 42 | } 43 | ], 44 | "variable-name": [ 45 | true, 46 | "ban-keywords" 47 | ], 48 | "whitespace": [ 49 | true, 50 | "check-branch", 51 | "check-decl", 52 | "check-operator", 53 | "check-separator", 54 | "check-type" 55 | ] 56 | } 57 | } --------------------------------------------------------------------------------