├── .angular-cli.json ├── .editorconfig ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── e2e ├── app.e2e-spec.ts ├── app.po.ts └── tsconfig.json ├── karma.conf.js ├── package.json ├── protractor.conf.js ├── server ├── app.js ├── cert.pem ├── data.js ├── getPuns.js ├── key.pem ├── keytmp.pem ├── server.csr ├── server.key └── suggestKeywords.js ├── src ├── app │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── dialog-suggestion │ │ ├── dialog-suggestion.component.css │ │ ├── dialog-suggestion.component.html │ │ ├── dialog-suggestion.component.spec.ts │ │ └── dialog-suggestion.component.ts │ ├── google-vision.service.spec.ts │ ├── google-vision.service.ts │ ├── pun-lookup │ │ ├── pun-lookup.component.html │ │ └── pun-lookup.component.ts │ ├── pun-service.service.spec.ts │ ├── pun-service.service.ts │ ├── snapshot-camera │ │ ├── snapshot-camera.component.css │ │ ├── snapshot-camera.component.html │ │ ├── snapshot-camera.component.spec.ts │ │ └── snapshot-camera.component.ts │ ├── speech.service.spec.ts │ └── speech.service.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.css ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── typings.d.ts ├── tsconfig.json └── tslint.json /.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "rxjs-test" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "assets": [ 11 | "assets", 12 | "favicon.ico" 13 | ], 14 | "index": "index.html", 15 | "main": "main.ts", 16 | "polyfills": "polyfills.ts", 17 | "test": "test.ts", 18 | "tsconfig": "tsconfig.app.json", 19 | "testTsconfig": "tsconfig.spec.json", 20 | "prefix": "app", 21 | "styles": [ 22 | "styles.css" 23 | ], 24 | "scripts": [], 25 | "environmentSource": "environments/environment.ts", 26 | "environments": { 27 | "dev": "environments/environment.ts", 28 | "prod": "environments/environment.prod.ts" 29 | } 30 | } 31 | ], 32 | "e2e": { 33 | "protractor": { 34 | "config": "./protractor.conf.js" 35 | } 36 | }, 37 | "lint": [ 38 | { 39 | "project": "src/tsconfig.app.json", 40 | "exclude": "**/node_modules/**" 41 | }, 42 | { 43 | "project": "src/tsconfig.spec.json", 44 | "exclude": "**/node_modules/**" 45 | }, 46 | { 47 | "project": "e2e/tsconfig.e2e.json", 48 | "exclude": "**/node_modules/**" 49 | } 50 | ], 51 | "test": { 52 | "karma": { 53 | "config": "./karma.conf.js" 54 | } 55 | }, 56 | "defaults": { 57 | "styleExt": "css", 58 | "component": {} 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /dist-server 6 | /tmp 7 | /out-tsc 8 | 9 | # dependencies 10 | /node_modules 11 | 12 | # IDEs and editors 13 | /.idea 14 | .project 15 | .classpath 16 | .c9/ 17 | *.launch 18 | .settings/ 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | testem.log 34 | /typings 35 | 36 | # e2e 37 | /e2e/*.js 38 | /e2e/*.map 39 | 40 | #System Files 41 | .DS_Store 42 | Thumbs.db 43 | 44 | #API Key File 45 | /src/app/api.key.ts -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "./node_modules/typescript/lib" 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RxjsTest 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.7.0. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { RxjsTestPage } from './app.po'; 2 | 3 | describe('rxjs-test App', function() { 4 | let page: RxjsTestPage; 5 | 6 | beforeEach(() => { 7 | page = new RxjsTestPage(); 8 | }); 9 | 10 | it('should display message saying app works', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('app works!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, element, by } from 'protractor'; 2 | 3 | export class RxjsTestPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "declaration": false, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "module": "commonjs", 8 | "moduleResolution": "node", 9 | "outDir": "../dist/out-tsc-e2e", 10 | "sourceMap": true, 11 | "target": "es5", 12 | "typeRoots": [ 13 | "../node_modules/@types" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular/cli'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular/cli/plugins/karma') 14 | ], 15 | client:{ 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | reports: [ 'html', 'lcovonly' ], 20 | fixWebpackSourcePaths: true 21 | }, 22 | angularCli: { 23 | environment: 'dev' 24 | }, 25 | reporters: ['progress', 'kjhtml'], 26 | port: 9876, 27 | colors: true, 28 | logLevel: config.LOG_INFO, 29 | autoWatch: true, 30 | browsers: ['Chrome'], 31 | singleRun: false 32 | }); 33 | }; 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjs-test", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build --prod", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "^5.2.0", 16 | "@angular/cdk": "^5.2.1", 17 | "@angular/common": "^5.2.0", 18 | "@angular/compiler": "^5.2.0", 19 | "@angular/core": "^5.2.0", 20 | "@angular/forms": "^5.2.0", 21 | "@angular/http": "^5.2.0", 22 | "@angular/material": "^5.2.1", 23 | "@angular/platform-browser": "^5.2.0", 24 | "@angular/platform-browser-dynamic": "^5.2.0", 25 | "@angular/router": "^5.2.0", 26 | "core-js": "^2.4.1", 27 | "cors": "^2.8.4", 28 | "express": "^4.16.2", 29 | "hammerjs": "^2.0.8", 30 | "rxjs": "^5.5.6", 31 | "zone.js": "^0.8.19" 32 | }, 33 | "devDependencies": { 34 | "@angular/cli": "~1.7.0", 35 | "@angular/compiler-cli": "^5.2.0", 36 | "@angular/language-service": "^5.2.0", 37 | "@types/jasmine": "~2.8.3", 38 | "@types/jasminewd2": "~2.0.2", 39 | "@types/node": "~6.0.60", 40 | "codelyzer": "^4.0.1", 41 | "jasmine-core": "~2.8.0", 42 | "jasmine-spec-reporter": "~4.2.1", 43 | "karma": "~2.0.0", 44 | "karma-chrome-launcher": "~2.2.0", 45 | "karma-coverage-istanbul-reporter": "^1.2.1", 46 | "karma-jasmine": "~1.1.0", 47 | "karma-jasmine-html-reporter": "^0.2.2", 48 | "protractor": "~5.1.2", 49 | "ts-node": "~4.1.0", 50 | "tslint": "~5.9.1", 51 | "typescript": "~2.5.3" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './e2e/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: 'e2e/tsconfig.e2e.json' 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /server/app.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const https = require('https'); 3 | const path = require('path'); 4 | const privateKey = fs.readFileSync(path.join(__dirname, './key.pem'), 'utf8'); 5 | const certificate = fs.readFileSync(path.join(__dirname, './cert.pem'), 'utf8'); 6 | const credentials = {key: privateKey, cert: certificate}; 7 | const cors = require('cors'); 8 | const express = require('express'); 9 | const app = express(); 10 | const { Observable } = require('rxjs'); 11 | const getPuns = require('./getPuns'); 12 | const suggestKeywords = require('./suggestKeywords'); 13 | 14 | app.use(cors()); 15 | 16 | app.get('/suggest-keywords', (req, res) => { 17 | const q = req.query.q; 18 | const keywords = suggestKeywords(q); 19 | res.send(keywords); 20 | }); 21 | 22 | app.get('/puns', (req, res) => { 23 | const keywords = req.query.q ? req.query.q.split(',') : null; 24 | const puns = getPuns(keywords); 25 | res.send(puns); 26 | }); 27 | 28 | 29 | const httpsServer = https.createServer(credentials, app); 30 | 31 | httpsServer.listen(4201); -------------------------------------------------------------------------------- /server/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEVzCCAz+gAwIBAgIJALanIPw4+44cMA0GCSqGSIb3DQEBBQUAMHoxCzAJBgNV 3 | BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMREwDwYDVQQHEwhTYW4gSm9zZTEQ 4 | MA4GA1UEChMHVGhpc0RvdDERMA8GA1UEAxMIQmVuIExlc2gxHjAcBgkqhkiG9w0B 5 | CQEWD2JlbkBiZW5sZXNoLmNvbTAeFw0xNzAzMjQwNzI3NDNaFw0xODAzMjQwNzI3 6 | NDNaMHoxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMREwDwYDVQQH 7 | EwhTYW4gSm9zZTEQMA4GA1UEChMHVGhpc0RvdDERMA8GA1UEAxMIQmVuIExl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ScSwtDAmjzxox0Z29LkrtriJRwfLeidt 24 | PmxF0oMyJUi6FXUlae0SUjsnoz7wl8EX7LW7XU/rVAauoxcocbRJbmqTh9vgBtsh 25 | VL+MyxoD94CVG4U= 26 | -----END CERTIFICATE----- 27 | -------------------------------------------------------------------------------- /server/data.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | keywords: { 3 | 'banana': [0, 13, 14, 15, 16], 4 | 'cheese': [3, 4, 5, 6, 7, 8, 12, 17, 23], 5 | 'bird': [3, 11, 12, 1, 20], 6 | 'hotel': [4, 9, 10, 11], 7 | 'mexican': [6, 17, 21, 22, 23, 24, 25], 8 | 'cow': [12, 26, 27, 28, 29, 30, 31], 9 | 'egg': [18, 19, 20, 32, 33], 10 | 'food': [0, 13, 14, 15, 16, 3, 4, 5, 6, 7, 8, 12, 23, 18, 19, 20, 32, 33] 11 | }, 12 | 13 | puns: { 14 | '0': { 15 | pun: 'My wife has banana diet', 16 | answer: 'She hasnt lost weight, but you should see her climb trees now!' 17 | }, 18 | '1': { 19 | pun: 'Id make a pun about a chicken...', 20 | answer: 'But it would be fowl.' 21 | }, 22 | '2': { 23 | pun: 'this is a pun about a pickle and a hat', 24 | answer: 'answer' 25 | }, 26 | '3': { 27 | pun: 'What kind of cheese can fly?', 28 | answer: 'Curds of Prey.' 29 | }, 30 | '4': { 31 | pun: 'What hotel did the cheese stay at?', 32 | answer: 'The Stilton.' 33 | }, 34 | '5': { 35 | pun: 'What is the saddest cheese?', answer: 'Blue Cheese.' 36 | }, 37 | '6': { 38 | pun: 'What do you call a cheese that isnt yours?', 39 | answer: 'Nacho Cheese.' 40 | }, 41 | '7': { 42 | pun: 'What music does cheese listen to?', answer: 'R & Brie.' 43 | }, 44 | '8': { 45 | pun: 'Whats always the last piece of cheese left?', 46 | answer: 'Forever Provolone.' 47 | }, 48 | '9': { 49 | pun: 'I used to be a hotel clerk', 50 | answer: 'But then I had reservations.' 51 | }, 52 | '10': { 53 | pun: 'Im staying at a really trend new hotel', 54 | answer: 'Its the inn thing to do.' 55 | }, 56 | '11': { 57 | pun: 'A bird doctor checked into a hotel.', 58 | answer: 'He said, "This is the best place I feather stayed at".' 59 | }, 60 | '12': { 61 | pun: 'A bird and a cow go shopping for cheese. The cow, knowing he can produce the milk says to the bird, "this place is robin you blind!".', 62 | answer: 'The bird says, "I like my cheese cheep cheep!' 63 | }, 64 | '13': { 65 | pun: 'Why dont bananas snore?', 66 | answer: 'They dont want to wake up the rest of the bunch!' 67 | }, 68 | '14': { 69 | pun: 'Why do bananas wear sunscreen?', 70 | answer: 'Because they peel.' 71 | }, 72 | '15': { 73 | pun: 'What do you call two banana skins?', 74 | answer: 'A pair of slippers.' 75 | }, 76 | '16': { 77 | pun: 'Why are bananas never lonely?', 78 | answer: 'Because they hang around in bunches.' 79 | }, 80 | '17': { 81 | pun: 'A chef asked a tomato about to be diced into salsa how it was feeling.', 82 | answer: 'He had a chip on his shoulders and said "its nacho business".' 83 | }, 84 | '18': { 85 | pun: 'We saw Kanye the other day at breakfast.', 86 | answer: 'Someone said "Om-a-lette you finish, but I hope that omelette is good!"' 87 | }, 88 | '19': { 89 | pun: 'Was on a diet with my sister. She fed me one egg for lunch.', 90 | answer: 'That had me bEGGing for more food!' 91 | }, 92 | '20': { 93 | pun: 'How to roosters flirt with chickens?', 94 | answer: 'They wish chickens an egg-stra special day.' 95 | }, 96 | '21': { 97 | pun: 'How to tacos handle disputes?', 98 | answer: 'They taco-ver coffee.' 99 | }, 100 | '22': { 101 | pun: 'If youre hungry for mexican food, what is the worst thing you could do?', 102 | answer: 'Burrito around the bush about it.' 103 | }, 104 | '23': { 105 | pun: 'Our local Mexican restaurant was closed the other day.', 106 | answer: 'They said it was a queso the flu.' 107 | }, 108 | '24': { 109 | pun: 'Bunch of avocados decided to run a marathon.', 110 | answer: 'They figure theyve guac what it takes.' 111 | }, 112 | '25': { 113 | pun: 'Anyone been exposed to a cheesy mexican pun?', 114 | answer: 'Que, so avocado say, weve all bean there, but lets not taco about it.' 115 | }, 116 | '26': { 117 | pun: 'The cow told everyone his grandfather was a knight', 118 | answer: 'And that his name was sir loin. I laughed so hard I had to rib my eyes.' 119 | }, 120 | '27': { 121 | pun: 'Why was the cow afraid?', 122 | answer: 'He was a cow-herd.' 123 | }, 124 | '28': { 125 | pun: 'What do you call a cow with a twitch?', 126 | answer: 'Beef jerky.' 127 | }, 128 | '29': { 129 | pun: 'How do you count cows?', 130 | answer: 'With a cow-culator.' 131 | }, 132 | '30': { 133 | pun: 'What do you call a cow with 3 legs?', 134 | answer: 'Lean beef.' 135 | }, 136 | '31': { 137 | pun: 'Why did the cow get arrested?', 138 | answer: 'He was using cow-nterfeit money.' 139 | }, 140 | '32': { 141 | pun: 'This egg was egg-cellent at cracking me up.', 142 | answer: 'He was making a lot of pun yolks.' 143 | }, 144 | '33': { 145 | pun: 'The egg was egg-stremely happy.', 146 | answer: 'But you couldnt really tell from his egg-spression.' 147 | } 148 | } 149 | }; -------------------------------------------------------------------------------- /server/getPuns.js: -------------------------------------------------------------------------------- 1 | const data = require('./data'); 2 | 3 | module.exports = function getPuns(kwds) { 4 | if (!kwds || kwds.length === 0) { 5 | return []; 6 | } 7 | 8 | const found = kwds.reduce((found, keyword) => { 9 | const ids = data.keywords[keyword]; 10 | if (ids) { 11 | return ids.reduce((found, id) => { 12 | found[id] = data.puns[id]; 13 | return found; 14 | }, found); 15 | } 16 | return found; 17 | }, {}); 18 | 19 | return Object.keys(found).map(key => found[key]); 20 | }; -------------------------------------------------------------------------------- /server/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpQIBAAKCAQEAvb5nWT2DzLVGm73L8+33tKJovlAd5lxhMPNZy3eCAz+2dKTa 3 | ap8suvRpA69iWCDUDf1eTQV55y97n3yjeC7bQdrItVzF9MMhb3PZ2wOgpZhk9vRr 4 | IT7goKgSI+7iVcpcNaLXIvJ8qj/1LvSs68UBCaKAHQh+bBtAWBx2waSD9MVpdzh3 5 | s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q0KCarlFjLQgmcadfRcuHyFYIBy0m 21 | UoRGVXseQQdageivqP0UoYT1AoGADVr7bpLZZsvG3jj8RcqxDTjvag7IoDV8tGP4 22 | u7zYtK0RVCvXqkatZw/zu+EavZ+x4JyxUmjH+ga8kRmvlQVVCS6BrHNh68q9bVcJ 23 | GGAJxa4So+XaScvgNGsEAPgOVPTcD6vf5oSZ3LUF+bvwre3Qgao6LimrguA3qJcc 24 | NGSRDAUCgYEAmhGMyaPXliiP5jidJ0BE4KkaVgthXWil+cn4GErQdWrU3/EkVMOE 25 | QTn1pu9qogpXJru32JS3N7qE68ZS4z0Yd5oHzS3v/Ok5gkP3u7cgLhiGS3cTj2xo 26 | WllASoLkh/XSNxVosXNkiGR2lztjmeHid/I7QPdpj2Wrq/sH51fruTc= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /server/keytmp.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,D7E9E7AEEA30C7B2 4 | 5 | I21MOoX7W1rg16wBrcWMJzMFDr/bdoQm+RwEx/E3FuhElV6hj1U3pM7cI0SqU8fQ 6 | pzaxkK3AGqfaDEI9s6qwPYONcaYI/sAIgP8N77RvC8ADAgs+KCewsmG7M+JCY77F 7 | lN+1yTz71+Eiqlybh97lOPwFcNw8E7OzgdeuwNruYC+yb+xlNDoNXd/o3Htz+FoZ 8 | sKmbJbi3w9Uvmmnk2bRavEijxMWIlH13Re7ppwdKaeTlCOKWIZTroM6KDUHEtG5f 9 | Jf4SOgxUflrkabr1hsNyknRj91qGT7NvEw2gwnrNaJDevMRsLCS7TBKFjyOx8mIf 10 | fSg+MOrgv6mDB+4f07kmSgFiWAxlAujwO9qZeGHZHAwyzt+k2xsQG1XukjYMvidK 11 | GjCp7mGfhWaL7foX8iMkvmcYj/eOD+BBl4mY+FIeJYsGyxHQ4NV9yQiyzm7KO2qz 12 | ZyS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c7byDwl21iH3RC86ZzFbftIS3 28 | xeUs5uBAadXHTj/kWbTP7cHFf1ohBXLS2eM1vQVI72NZ7ej+guxM7Osx6D8QVdSP 29 | U09p0R8taeVehIcUXsODcK5+a5Mmmhy1w3LRl6d+sLRZEb1C3hG2gYQHucIXKY0/ 30 | -----END RSA PRIVATE KEY----- 31 | -------------------------------------------------------------------------------- /server/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICwTCCAakCAQAwfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWEx 3 | ETAPBgNVBAcTCFNhbiBKb3NlMRAwDgYDVQQKEwdUaGlzRG90MRMwEQYDVQQDEwpE 4 | ZW1vU2VydmVyMR4wHAYJKoZIhvcNAQkBFg9iZW5AYmVubGVzaC5jb20wggEiMA0G 5 | CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC+jV1FKOBMfRwLl48zsekTSR59JLna 6 | wOjEg0caV0K1MmT2zAya3gDFAjO85ocYmbOzqqm4GXocitOWWc6ta2TnzrFjKV3J 7 | /xGKNmlhU4QKjov8u8eXYL9AsSjRWpMTyEhYuPwOk5NbYl3g/PIYOmXSqEkWQA9d 8 | //+EkRIsFyQp+vIXFvz/DhuQUl6C1Nog507Whx7eW9Z2SiqALBOfscklEaBl1hrL 9 | H0iCFUmjSosg2v/OS00iAc+Ki4N7RCASblI5NXcX6Vg09FzKu1ahW9iVUgRXRclm 10 | GT9NjgN4KdwJudAQip19peOeLCYbMS1Px9DexMOIG2NqyaKxI0iZG+QbAgMBAAGg 11 | ADANBgkqhkiG9w0BAQUFAAOCAQEAZmfdz9X2/hxvrZA4CssySY3JbxpCYxn5Njlv 12 | GUJmlkpGxDJqKDK+oy4YZdilANDEH7Y7HprMoGwR6mbiJ2lZrchi3Sy72d6L1g41 13 | PR+opQLB9T3C6wNmqqZZnHxvar2bc2WzpMS8jfFq3EBW4MdVOqnwF9d3hXPHze6m 14 | beBtoyNTGdthlr93bXhlnNavh2xT/sPNReBMv7PyH4fH0tk2eLbwPm3mHx28a0V8 15 | 9PA4CwXGnGLil7uPqfVaSGchfMDBb2erDfumCsVuxu8+7n3kgZg5yH6sfmpCFJrN 16 | 7e/PlLu1vsrjyPVI+8io2Z8KKMs66oQTayRmFu22tkURG9bt6A== 17 | -----END CERTIFICATE REQUEST----- 18 | -------------------------------------------------------------------------------- /server/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpQIBAAKCAQEAvo1dRSjgTH0cC5ePM7HpE0kefSS52sDoxINHGldCtTJk9swM 3 | mt4AxQIzvOaHGJmzs6qpuBl6HIrTllnOrWtk586xYyldyf8RijZpYVOECo6L/LvH 4 | l2C/QLEo0VqTE8hIWLj8DpOTW2Jd4PzyGDpl0qhJFkAPXf//hJESLBckKfryFxb8 5 | /w4bkFJegtTaIOdO1oce3lvWdkoqgCwTn7HJJRGgZdYayx9IghVJo0qLINr/zktN 6 | IgHPiouDe0QgEm5SOTV3F+lYNPRcyrtWoVvYlVIEV0XJZhk/TY4DeCncCbnQEIqd 7 | faXjniwmGzEtT8fQ3sTDiBtjasmisSNImRvkGwIDAQABAoIBAQC8oVwvVmOT1FWq 8 | 9AGCfx/nQ363C2AgOM8zmXENlkwm6xgfZ6cit5mzbJai7OHXbHAD73HLGQ1Uq+kA 9 | 8S4zZhihkG7xZsW9bI6Eb5CqE+6mNK5HJexS4ibxd26csDjgYGedzKFYHKbG0/1y 10 | 93MAoO6jNowDRq7vsrfTF3kRxGa8VkO5niwt86bJCRn84xg9QxdUxj16OC2Ky4Ni 11 | xmPV1BhiO87K9fJr5IwP3YIEvgKfZpy0tErBKwLwY4ptSoLvHU+pj/oEz37Cd+0c 12 | m2X/7awIbhXzcxfYK6/YDrnnUtWr2HPTuI8Q0PgkBJ0ayrYKqQvm31DwKtBb76k9 13 | 5a/zsXoBAoGBAPGyUvUerbAj6PM/t5/eijKcymu9ECy04Yt3myRReBE9KHJgbM8d 14 | t3h4WdoWvthD57+GWr3SaESkkVBXOYibjfStDBcCp/NrIRIpaAkGnxK2NOiHKMBD 15 | HJg6GGjmZsJXddmAfh+0w50fk/hSByHbtyCmYb3hk6g4CXzZIbGIUl/bAoGBAMnU 16 | NXJ7F3aYh0Uy/pYi4JqjyIdgB77k7yeynZFDjke0T/X6J4jBB2+cuNLuhEBMLMR1 17 | ZL9mHdPWoCQkivInDlVH+fI5PKT5VxrhsLvfsuRv0Aq+ksVhCRcgmOeeWtPfkqW/ 18 | hoGRQtZ81uZdoP1GIzFda0cf2L+LNCvJxfeABuDBAoGAc3KCPaNRw3jjpI0i4LIj 19 | wNkztxKvzyr3MO8Io+hmOZXE5B063BONt3WFNa73qcWFxO4gGduPAnq5Dm8bhC0J 20 | OX4O8E7MenEJcutkTitjgESYMRmeVXe5CN13G2QyYVH1cNb3Z52ocjzLKSnFTl7s 21 | siPHPDOrnAZoQcJVXb+H2VECgYEAuh3h558RJQFFBJAg6yxgeNn+KrBolCWjULVK 22 | zlFA3GivsAIuANMYW1lnqsPe2zgjtEsZS9MMQHRUGuBD7UgM1KHaIP+dJ/jy1Uw4 23 | YRfJbRSbAb15tWBlNJmPx09lLKqoHga/L65Xt1lKBwdiVQ0fmP8v1VfN1dy1kIex 24 | 8ilyrkECgYEApONLED2H5kfE1rpB+v1GQ0hV9u0at8vrylJb5hS0v3RIzTgiG6OT 25 | vfzGNZB+Vqexg0PdIXEajcjYd9IZCJdNQkYLVJ2sW7SOpMDi/AS9UeNzjFG4OIf7 26 | cul6wf3M03JwLeQQCeYryd5OzZ+GkL4IwPPNeGbATj5DidEy2VqVmF4= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /server/suggestKeywords.js: -------------------------------------------------------------------------------- 1 | const data = require('./data'); 2 | 3 | module.exports = function suggestKeywords(partial) { 4 | if (!partial) { 5 | return []; 6 | } 7 | 8 | return Object.keys(data.keywords) 9 | .filter(keyword => keyword.indexOf(partial) === 0) 10 | }; -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladyleet/rxjs-test/cb0c5263b91d4da97f1fd56f4f31fa6ba627ed2d/src/app/app.component.css -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Github 10 | 11 | 12 | RxJS Docs 13 | 14 | 15 | Learn RxJS 16 | 17 | 18 | RxJS Pun App 19 | 20 | 21 |
22 | 23 |
24 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | describe('AppComponent', () => { 4 | beforeEach(async(() => { 5 | TestBed.configureTestingModule({ 6 | declarations: [ 7 | AppComponent 8 | ], 9 | }).compileComponents(); 10 | })); 11 | it('should create the app', async(() => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.debugElement.componentInstance; 14 | expect(app).toBeTruthy(); 15 | })); 16 | it(`should have as title 'app'`, async(() => { 17 | const fixture = TestBed.createComponent(AppComponent); 18 | const app = fixture.debugElement.componentInstance; 19 | expect(app.title).toEqual('app'); 20 | })); 21 | it('should render title in a h1 tag', async(() => { 22 | const fixture = TestBed.createComponent(AppComponent); 23 | fixture.detectChanges(); 24 | const compiled = fixture.debugElement.nativeElement; 25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); 26 | })); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent { 9 | title = 'app'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { HttpModule } from '@angular/http'; 5 | 6 | import { MatToolbarModule, MatIconModule, MatMenuModule, MatDialogModule, MatCardModule, MatInputModule, MatButtonModule } from '@angular/material'; 7 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 8 | 9 | import { AppComponent } from './app.component'; 10 | 11 | import { PunLookupComponent } from './pun-lookup/pun-lookup.component'; 12 | import { SnapshotCameraComponent } from './snapshot-camera/snapshot-camera.component'; 13 | import { DialogSuggestionComponent } from './dialog-suggestion/dialog-suggestion.component'; 14 | 15 | 16 | @NgModule({ 17 | declarations: [ 18 | AppComponent, 19 | PunLookupComponent, 20 | SnapshotCameraComponent, 21 | DialogSuggestionComponent 22 | ], 23 | imports: [ 24 | BrowserModule, 25 | FormsModule, 26 | HttpModule, 27 | MatToolbarModule, 28 | MatIconModule, 29 | MatMenuModule, 30 | MatDialogModule, 31 | MatCardModule, 32 | MatInputModule, 33 | MatButtonModule, 34 | BrowserAnimationsModule 35 | ], 36 | entryComponents: [DialogSuggestionComponent], 37 | providers: [], 38 | bootstrap: [AppComponent] 39 | }) 40 | export class AppModule { } 41 | -------------------------------------------------------------------------------- /src/app/dialog-suggestion/dialog-suggestion.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladyleet/rxjs-test/cb0c5263b91d4da97f1fd56f4f31fa6ba627ed2d/src/app/dialog-suggestion/dialog-suggestion.component.css -------------------------------------------------------------------------------- /src/app/dialog-suggestion/dialog-suggestion.component.html: -------------------------------------------------------------------------------- 1 |

2 | Suggested Inputs 3 |

4 | 5 | Some ideas for search! Try banana, cheese, bird, hotel, mexican, cow, egg, or food! 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/app/dialog-suggestion/dialog-suggestion.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { DialogSuggestionComponent } from './dialog-suggestion.component'; 4 | 5 | describe('DialogSuggestionComponent', () => { 6 | let component: DialogSuggestionComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ DialogSuggestionComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(DialogSuggestionComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/dialog-suggestion/dialog-suggestion.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-dialog-suggestion', 5 | templateUrl: './dialog-suggestion.component.html', 6 | styleUrls: ['./dialog-suggestion.component.css'] 7 | }) 8 | export class DialogSuggestionComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/google-vision.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { GoogleVisionService } from './google-vision.service'; 4 | 5 | describe('GoogleVisionService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [GoogleVisionService] 9 | }); 10 | }); 11 | 12 | it('should ...', inject([GoogleVisionService], (service: GoogleVisionService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /src/app/google-vision.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Http } from '@angular/http'; 3 | import { apiKey } from './api.key'; 4 | import { Observable } from 'rxjs/Observable'; 5 | 6 | @Injectable() 7 | export class GoogleVisionService { 8 | 9 | constructor(private http: Http) { } 10 | 11 | 12 | annotateImage(imgBase64: string): Observable { 13 | const body = JSON.stringify({ 14 | requests: [ 15 | { 16 | image: { 17 | content: imgBase64 18 | }, 19 | features: [ 20 | { 21 | type: 'LABEL_DETECTION' 22 | } 23 | ] 24 | } 25 | ] 26 | }); 27 | const headers = new Headers(); 28 | headers.set('Content-Type', 'application/json'); 29 | headers.set('Content-Length', body.length.toString()); 30 | 31 | return this.http.post( 32 | `https://vision.googleapis.com/v1/images:annotate?key=${apiKey}`, 33 | body 34 | ) 35 | .map(res => res.json()) 36 | .map(e => { 37 | if (!e.responses) { 38 | return []; 39 | } else { 40 | const results = e.responses.reduce((results, response) => { 41 | if (!response.labelAnnotations) { 42 | return results; 43 | } 44 | return results.concat(response.labelAnnotations.map(a => a.description).filter(a => !!a)); 45 | }, []); 46 | 47 | const s = new Set(results); 48 | return Array.from(s.values()); 49 | } 50 | }); 51 | } 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/app/pun-lookup/pun-lookup.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Search for Puns

3 |
4 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 |
20 | 21 |

Suggested Keywords

22 | 23 | 24 | {{keyword}} 25 | 26 | 27 | 28 |

Puns Found

29 | 30 | 31 | {{pun.pun}} 32 | {{pun.answer}} 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/app/pun-lookup/pun-lookup.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Subject } from 'rxjs/Subject'; 3 | import { Observable } from 'rxjs/Observable'; 4 | import { PunService } from '../pun-service.service'; 5 | import { SpeechService } from '../speech.service'; 6 | import { GoogleVisionService } from '../google-vision.service'; 7 | import { MatDialog } from '@angular/material'; 8 | import { DialogSuggestionComponent } from '../dialog-suggestion/dialog-suggestion.component'; 9 | 10 | import 'rxjs/add/observable/merge'; 11 | import 'rxjs/add/operator/switchMap'; 12 | import 'rxjs/add/operator/share'; 13 | 14 | @Component({ 15 | selector: 'app-pun-lookup', 16 | templateUrl: './pun-lookup.component.html', 17 | styles: [], 18 | providers: [ 19 | PunService, 20 | SpeechService, 21 | GoogleVisionService 22 | ] 23 | }) 24 | export class PunLookupComponent { 25 | 26 | openDialog(){ 27 | this.dialog.open(DialogSuggestionComponent) 28 | } 29 | 30 | keywordsInputChange$ = new Subject(); 31 | 32 | listenClick$ = new Subject(); 33 | 34 | snapshot$ = new Subject<{ dataURL: string }>(); 35 | 36 | googleVision$ = this.snapshot$ 37 | .map(e => { 38 | const dataURLHeader = 'data:image/png;base64,'; 39 | const base64Image = e.dataURL.substr(dataURLHeader.length); 40 | return base64Image; 41 | }) 42 | .switchMap(base64Image => this.googleVision.annotateImage(base64Image)); 43 | 44 | spokenKeyword$ = this.listenClick$ 45 | .switchMap(() => this.speech.listen()) 46 | 47 | typedKeyword$ = this.keywordsInputChange$ 48 | .switchMap(text => this.puns.suggestKeywords(text)); 49 | 50 | keyword$ = Observable.merge( 51 | this.typedKeyword$, 52 | this.spokenKeyword$, 53 | this.googleVision$ 54 | ).share(); 55 | 56 | punsFound$ = this.keyword$ 57 | .switchMap(keywords => this.puns.getPuns(keywords)) 58 | 59 | constructor( 60 | private puns: PunService, 61 | private speech: SpeechService, 62 | private googleVision: GoogleVisionService, 63 | public dialog : MatDialog 64 | ) {} 65 | } 66 | -------------------------------------------------------------------------------- /src/app/pun-service.service.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | 3 | import { TestBed, async, inject } from '@angular/core/testing'; 4 | import { PunService } from './pun-service.service'; 5 | 6 | describe('PunService', () => { 7 | beforeEach(() => { 8 | TestBed.configureTestingModule({ 9 | providers: [PunService] 10 | }); 11 | }); 12 | 13 | it('should ...', inject([PunService], (service: PunService) => { 14 | expect(service).toBeTruthy(); 15 | })); 16 | }); 17 | -------------------------------------------------------------------------------- /src/app/pun-service.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Observable } from 'rxjs/Observable'; 3 | import 'rxjs/add/operator/map'; 4 | import 'rxjs/add/operator/catch'; 5 | import 'rxjs/add/observable/empty'; 6 | import { asap } from 'rxjs/scheduler/asap'; 7 | import { Http } from '@angular/http'; 8 | 9 | export interface Pun { 10 | pun: string, 11 | answer: string 12 | }; 13 | 14 | @Injectable() 15 | export class PunService { 16 | 17 | constructor(private http: Http) { } 18 | 19 | getPuns(kwds: string[]): Observable { 20 | const serialized = kwds.join(','); 21 | return this.http.get(`https://localhost:4201/puns?q=${serialized}`) 22 | .map(res => res.json()) 23 | .catch(err => { 24 | console.error(err); 25 | return Observable.empty(); 26 | }); 27 | } 28 | 29 | suggestKeywords(partial: string): Observable { 30 | return this.http.get(`https://localhost:4201/suggest-keywords?q=${partial}`) 31 | .map(res => res.json()) 32 | .catch(err => { 33 | console.error(err); 34 | return Observable.empty(); 35 | });; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/app/snapshot-camera/snapshot-camera.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladyleet/rxjs-test/cb0c5263b91d4da97f1fd56f4f31fa6ba627ed2d/src/app/snapshot-camera/snapshot-camera.component.css -------------------------------------------------------------------------------- /src/app/snapshot-camera/snapshot-camera.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
-------------------------------------------------------------------------------- /src/app/snapshot-camera/snapshot-camera.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { SnapshotCameraComponent } from './snapshot-camera.component'; 4 | 5 | describe('SnapshotCameraComponent', () => { 6 | let component: SnapshotCameraComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ SnapshotCameraComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(SnapshotCameraComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/snapshot-camera/snapshot-camera.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit, ElementRef, EventEmitter, Output, OnDestroy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-snapshot-camera', 5 | templateUrl: './snapshot-camera.component.html', 6 | styleUrls: ['./snapshot-camera.component.css'] 7 | }) 8 | export class SnapshotCameraComponent implements OnInit, OnDestroy { 9 | 10 | video: HTMLVideoElement; 11 | 12 | canvas: HTMLCanvasElement; 13 | 14 | stream: MediaStream; 15 | 16 | @Input() width: number; 17 | 18 | @Input() height: number; 19 | 20 | @Output() snapshot = new EventEmitter(); 21 | 22 | constructor(private elementRef: ElementRef) { 23 | } 24 | 25 | ngOnInit() { 26 | const elem = this.elementRef.nativeElement; 27 | 28 | this.video = elem.querySelector('video'); 29 | this.canvas = elem.querySelector('canvas'); 30 | 31 | this.startSnapshot(); 32 | } 33 | 34 | ngOnDestroy() { 35 | this.stopSnapshot(); 36 | } 37 | 38 | startSnapshot() { 39 | const { video, canvas } = this; 40 | canvas.width = canvas.height = 0; 41 | 42 | canvas.hidden = true; 43 | video.hidden = false; 44 | 45 | navigator.getUserMedia({ 46 | audio: false, 47 | video: { 48 | width: this.width, 49 | height: this.height 50 | } 51 | }, 52 | (stream: MediaStream) => { 53 | this.stream = stream; 54 | video.src = URL.createObjectURL(stream); 55 | video.onloadedmetadata = (e) => { 56 | video.play(); 57 | }; 58 | }, 59 | (err: MediaStreamError) => { 60 | console.error(err); 61 | }); 62 | } 63 | 64 | stopSnapshot() { 65 | if (this.stream) { 66 | this.stream.getTracks().forEach(track => track.stop()); 67 | this.stream = null; 68 | } 69 | this.video.src = null; 70 | } 71 | 72 | takeSnapshot() { 73 | const { canvas, video, width, height } = this; 74 | const { videoWidth, videoHeight } = video; 75 | 76 | canvas.hidden = false; 77 | video.hidden = true; 78 | 79 | const scale = width / videoWidth; 80 | 81 | canvas.width = videoWidth * scale; 82 | canvas.height = videoHeight * scale; 83 | 84 | canvas.onclick = () => this.startSnapshot(); 85 | 86 | const context = canvas.getContext('2d'); 87 | context.drawImage(video, 0, 0, canvas.width, canvas.height); 88 | 89 | this.snapshot.emit({ 90 | width: canvas.width, 91 | height: canvas.height, 92 | dataURL: canvas.toDataURL() 93 | }); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/app/speech.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { SpeechService } from './speech.service'; 4 | 5 | describe('SpeechService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [SpeechService] 9 | }); 10 | }); 11 | 12 | it('should ...', inject([SpeechService], (service: SpeechService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /src/app/speech.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Inject } from '@angular/core'; 2 | import { Observable } from 'rxjs/Observable'; 3 | 4 | // TODO: get this injected properly 5 | const SpeechRecognition = window && ( 6 | (window).SpeechRecognition || (window).webkitSpeechRecognition || 7 | (window).mozSpeechRecognition || (window).msSpeechRecogntion 8 | ); 9 | 10 | @Injectable() 11 | export class SpeechService { 12 | constructor() { 13 | } 14 | 15 | listen(): Observable { 16 | return new Observable(observer => { 17 | const speech = new SpeechRecognition(); 18 | 19 | const resultHandler = (e: any) => { 20 | console.log(e); 21 | const results: string[] = this.cleanSpeechResults(e.results); 22 | observer.next(results); 23 | observer.complete(); 24 | }; 25 | 26 | const errorHandler = (err) => { 27 | observer.error(err); 28 | }; 29 | 30 | speech.addEventListener('result', resultHandler); 31 | speech.addEventListener('error', errorHandler); 32 | speech.start(); 33 | 34 | return () => { 35 | speech.removeEventListener('result', resultHandler); 36 | speech.removeEventListener('error', errorHandler); 37 | speech.abort(); 38 | }; 39 | }); 40 | } 41 | 42 | private cleanSpeechResults(results: any): string[] { 43 | return ( 44 | Array.from(results) 45 | .reduce( 46 | (final: string[], result: any) => 47 | final.concat(Array.from(result, (x: any) => x.transcript)), 48 | [] 49 | ) 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladyleet/rxjs-test/cb0c5263b91d4da97f1fd56f4f31fa6ba627ed2d/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladyleet/rxjs-test/cb0c5263b91d4da97f1fd56f4f31fa6ba627ed2d/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | RxJS Pun App 6 | 7 | 8 | 9 | 10 | 11 | 12 | Loading... 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | 44 | /** Evergreen browsers require these. **/ 45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 46 | import 'core-js/es7/reflect'; 47 | 48 | 49 | /** 50 | * Required to support Web Animations `@angular/platform-browser/animations`. 51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 52 | **/ 53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 54 | 55 | /** 56 | * By default, zone.js will patch all possible macroTask and DomEvents 57 | * user can disable parts of macroTask/DomEvents patch by setting following flags 58 | */ 59 | 60 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 61 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 62 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 63 | 64 | /* 65 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 66 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 67 | */ 68 | // (window as any).__Zone_enable_cross_context_check = true; 69 | 70 | /*************************************************************************************************** 71 | * Zone JS is required by default for Angular itself. 72 | */ 73 | import 'zone.js/dist/zone'; // Included with Angular CLI. 74 | 75 | 76 | 77 | /*************************************************************************************************** 78 | * APPLICATION IMPORTS 79 | */ 80 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import url("https://fonts.googleapis.com/icon?family=Material+Icons"); 3 | @import url("https://fonts.googleapis.com/icon?family=Roboto"); 4 | @import "~@angular/material/prebuilt-themes/indigo-pink.css"; 5 | 6 | body { 7 | font-family: Roboto; 8 | margin: 0px; 9 | } 10 | 11 | .body-margin { 12 | margin: 50px; 13 | } 14 | 15 | .primary-color { 16 | color: #3F51B5; 17 | } 18 | 19 | .accent-color { 20 | color: #FF4081; 21 | } 22 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015", 7 | "types": [] 8 | }, 9 | "exclude": [ 10 | "test.ts", 11 | "**/*.spec.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "types": [ 8 | "jasmine", 9 | "node" 10 | ] 11 | }, 12 | "files": [ 13 | "test.ts" 14 | ], 15 | "include": [ 16 | "**/*.spec.ts", 17 | "**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "typeRoots": [ 12 | "node_modules/@types" 13 | ], 14 | "lib": [ 15 | "es2017", 16 | "dom" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs", 22 | "rxjs/Rx" 23 | ], 24 | "import-spacing": true, 25 | "indent": [ 26 | true, 27 | "spaces" 28 | ], 29 | "interface-over-type-literal": true, 30 | "label-position": true, 31 | "max-line-length": [ 32 | true, 33 | 140 34 | ], 35 | "member-access": false, 36 | "member-ordering": [ 37 | true, 38 | { 39 | "order": [ 40 | "static-field", 41 | "instance-field", 42 | "static-method", 43 | "instance-method" 44 | ] 45 | } 46 | ], 47 | "no-arg": true, 48 | "no-bitwise": true, 49 | "no-console": [ 50 | true, 51 | "debug", 52 | "info", 53 | "time", 54 | "timeEnd", 55 | "trace" 56 | ], 57 | "no-construct": true, 58 | "no-debugger": true, 59 | "no-duplicate-super": true, 60 | "no-empty": false, 61 | "no-empty-interface": true, 62 | "no-eval": true, 63 | "no-inferrable-types": [ 64 | true, 65 | "ignore-params" 66 | ], 67 | "no-misused-new": true, 68 | "no-non-null-assertion": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "typedef-whitespace": [ 101 | true, 102 | { 103 | "call-signature": "nospace", 104 | "index-signature": "nospace", 105 | "parameter": "nospace", 106 | "property-declaration": "nospace", 107 | "variable-declaration": "nospace" 108 | } 109 | ], 110 | "unified-signatures": true, 111 | "variable-name": false, 112 | "whitespace": [ 113 | true, 114 | "check-branch", 115 | "check-decl", 116 | "check-operator", 117 | "check-separator", 118 | "check-type" 119 | ], 120 | "directive-selector": [ 121 | true, 122 | "attribute", 123 | "app", 124 | "camelCase" 125 | ], 126 | "component-selector": [ 127 | true, 128 | "element", 129 | "app", 130 | "kebab-case" 131 | ], 132 | "no-output-on-prefix": true, 133 | "use-input-property-decorator": true, 134 | "use-output-property-decorator": true, 135 | "use-host-property-decorator": true, 136 | "no-input-rename": true, 137 | "no-output-rename": true, 138 | "use-life-cycle-interface": true, 139 | "use-pipe-transform-interface": true, 140 | "component-class-suffix": true, 141 | "directive-class-suffix": true 142 | } 143 | } 144 | --------------------------------------------------------------------------------