├── Icons ├── Icon-128.png ├── Icon-16.png ├── Icon-19.png ├── Icon-32.png ├── Icon-38.png ├── Icon-48.png ├── favIcon_16x16.ico ├── favIcon_32x32.ico └── favIcon_48x48.ico ├── Project_Files ├── Icon-128.png ├── Icon-16.png ├── Icon-19.png ├── Icon-32.png ├── Icon-38.png ├── Icon-48.png ├── favIcon_16x16.ico ├── favIcon_32x32.ico ├── favIcon_48x48.ico ├── scripts │ ├── boot.js.map │ ├── list.data.constant.ts │ ├── boot.ts │ ├── list.data.constant.js.map │ ├── system.config.js │ ├── filewriter │ │ ├── filewriter-tests.ts │ │ ├── filewriter-tests.js.map │ │ ├── filewriter-tests.js │ │ └── filewriter.d.ts │ ├── webrtc │ │ ├── readme.md │ │ ├── MediaStream-tests.js │ │ ├── MediaStream-tests.ts │ │ ├── MediaStream-tests.js.map │ │ ├── RTCPeerConnection-tests.js.map │ │ ├── RTCPeerConnection-tests.ts │ │ ├── RTCPeerConnection-tests.js │ │ ├── MediaStream.d.ts │ │ └── RTCPeerConnection.d.ts │ ├── boot.js │ ├── list.data.constant.js │ ├── list.service.js.map │ ├── bookmark.component.js.map │ ├── list.component.js.map │ ├── eventPage.js.map │ ├── filesystem │ │ ├── filesystem-tests.js.map │ │ ├── filesystem-tests.js │ │ ├── filesystem-tests.ts │ │ └── filesystem.d.ts │ ├── list.service.ts │ ├── list.component.ts │ ├── eventPage.ts │ ├── bookmark.component.ts │ ├── list.service.js │ ├── bookmark.component.js │ ├── list.component.js │ └── eventPage.js ├── tsconfig.json ├── templates │ ├── list.html │ └── bookmark.html ├── manifest.json ├── package.json └── index.html ├── Typings ├── filewriter │ ├── filewriter-tests.ts │ ├── filewriter-tests.js.map │ ├── filewriter-tests.js │ └── filewriter.d.ts ├── webrtc │ ├── readme.md │ ├── MediaStream-tests.js │ ├── MediaStream-tests.ts │ ├── MediaStream-tests.js.map │ ├── RTCPeerConnection-tests.js.map │ ├── RTCPeerConnection-tests.ts │ ├── RTCPeerConnection-tests.js │ ├── MediaStream.d.ts │ └── RTCPeerConnection.d.ts └── filesystem │ ├── filesystem-tests.js.map │ ├── filesystem-tests.js │ ├── filesystem-tests.ts │ └── filesystem.d.ts └── README.md /Icons/Icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/Icon-128.png -------------------------------------------------------------------------------- /Icons/Icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/Icon-16.png -------------------------------------------------------------------------------- /Icons/Icon-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/Icon-19.png -------------------------------------------------------------------------------- /Icons/Icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/Icon-32.png -------------------------------------------------------------------------------- /Icons/Icon-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/Icon-38.png -------------------------------------------------------------------------------- /Icons/Icon-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/Icon-48.png -------------------------------------------------------------------------------- /Icons/favIcon_16x16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/favIcon_16x16.ico -------------------------------------------------------------------------------- /Icons/favIcon_32x32.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/favIcon_32x32.ico -------------------------------------------------------------------------------- /Icons/favIcon_48x48.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Icons/favIcon_48x48.ico -------------------------------------------------------------------------------- /Project_Files/Icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/Icon-128.png -------------------------------------------------------------------------------- /Project_Files/Icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/Icon-16.png -------------------------------------------------------------------------------- /Project_Files/Icon-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/Icon-19.png -------------------------------------------------------------------------------- /Project_Files/Icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/Icon-32.png -------------------------------------------------------------------------------- /Project_Files/Icon-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/Icon-38.png -------------------------------------------------------------------------------- /Project_Files/Icon-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/Icon-48.png -------------------------------------------------------------------------------- /Project_Files/favIcon_16x16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/favIcon_16x16.ico -------------------------------------------------------------------------------- /Project_Files/favIcon_32x32.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/favIcon_32x32.ico -------------------------------------------------------------------------------- /Project_Files/favIcon_48x48.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepoint-editors/sitepoint_projectcode_chrome-extension-angular-typescript/HEAD/Project_Files/favIcon_48x48.ico -------------------------------------------------------------------------------- /Project_Files/scripts/boot.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"boot.js","sourceRoot":"","sources":["boot.ts"],"names":[],"mappings":";;;;;;;;;;;;;YAMA,kEAAkE;YAClE,mBAAS,CAAE,8BAAa,CAAE,CAAC"} -------------------------------------------------------------------------------- /Project_Files/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "system", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | }, 12 | "exclude": [ 13 | "node_modules" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /Project_Files/scripts/list.data.constant.ts: -------------------------------------------------------------------------------- 1 | // We are using a constant here, 2 | // because we do not want to change the default data. 3 | export const BOOKMARKS = [ 4 | { 'name': 'Twitter', 'url': 'https://twitter.com' }, 5 | { 'name': 'Github', 'url': 'https://github.com' }, 6 | { 'name': 'Sitepoint', 'url': 'https://sitepoint.com' }, 7 | { 'name': 'Codepen', 'url': 'https://codepen.com' } 8 | ]; 9 | -------------------------------------------------------------------------------- /Project_Files/scripts/boot.ts: -------------------------------------------------------------------------------- 1 | // Angular's "bootstrap" function can be imported from the angular2/platform/browser module. 2 | // Since we want to bootstrap the "ListComponent", 3 | // we have to import it, too. 4 | import { bootstrap } from 'angular2/platform/browser'; 5 | import { ListComponent } from './list.component'; 6 | 7 | // We can now bootstrap the "ListComponent" as the root component. 8 | bootstrap( ListComponent ); 9 | -------------------------------------------------------------------------------- /Project_Files/scripts/list.data.constant.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"list.data.constant.js","sourceRoot":"","sources":["list.data.constant.ts"],"names":[],"mappings":";;;QAEa,SAAS;;;;YAFtB,gCAAgC;YAChC,qDAAqD;YACxC,uBAAA,SAAS,GAAG;gBACvB,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,qBAAqB,EAAE;gBACnD,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,oBAAoB,EAAE;gBACjD,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,uBAAuB,EAAE;gBACvD,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,qBAAqB,EAAE;aACpD,CAAA,CAAC"} -------------------------------------------------------------------------------- /Project_Files/scripts/system.config.js: -------------------------------------------------------------------------------- 1 | // SystemJS is the module loader for the application. 2 | // It loads the libraries and our modules and then catches and logs errors, 3 | // that may occur during the app launch. 4 | System.config({ 5 | packages: { 6 | scripts: { 7 | format: 'register', 8 | defaultExtension: 'js' 9 | } 10 | } 11 | }); 12 | System.import('scripts/boot') 13 | .then(null, console.error.bind(console)); 14 | -------------------------------------------------------------------------------- /Typings/filewriter/filewriter-tests.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | // http://www.w3.org/TR/file-writer-api/ 4 | function writeFile(writer:FileWriter): void{ 5 | function done(evt:Event): void{ 6 | alert("Write completed."); 7 | } 8 | function error(evt:Event): void{ 9 | alert("Write failed:" + evt); 10 | } 11 | 12 | var b:Blob = new Blob(); 13 | writer.onwrite = done; 14 | writer.onerror = error; 15 | writer.write(b); 16 | } -------------------------------------------------------------------------------- /Typings/filewriter/filewriter-tests.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"filewriter-tests.js","sourceRoot":"","sources":["filewriter-tests.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,wCAAwC;AACxC,mBAAmB,MAAiB;IAClC,cAAc,GAAS;QACrB,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5B,CAAC;IACD,eAAe,GAAS;QACtB,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,GAAQ,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"} -------------------------------------------------------------------------------- /Project_Files/scripts/filewriter/filewriter-tests.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | // http://www.w3.org/TR/file-writer-api/ 4 | function writeFile(writer:FileWriter): void{ 5 | function done(evt:Event): void{ 6 | alert("Write completed."); 7 | } 8 | function error(evt:Event): void{ 9 | alert("Write failed:" + evt); 10 | } 11 | 12 | var b:Blob = new Blob(); 13 | writer.onwrite = done; 14 | writer.onerror = error; 15 | writer.write(b); 16 | } -------------------------------------------------------------------------------- /Typings/filewriter/filewriter-tests.js: -------------------------------------------------------------------------------- 1 | /// 2 | // http://www.w3.org/TR/file-writer-api/ 3 | function writeFile(writer) { 4 | function done(evt) { 5 | alert("Write completed."); 6 | } 7 | function error(evt) { 8 | alert("Write failed:" + evt); 9 | } 10 | var b = new Blob(); 11 | writer.onwrite = done; 12 | writer.onerror = error; 13 | writer.write(b); 14 | } 15 | //# sourceMappingURL=filewriter-tests.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/filewriter/filewriter-tests.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"filewriter-tests.js","sourceRoot":"","sources":["filewriter-tests.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,wCAAwC;AACxC,mBAAmB,MAAiB;IAClC,cAAc,GAAS;QACrB,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5B,CAAC;IACD,eAAe,GAAS;QACtB,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,GAAQ,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"} -------------------------------------------------------------------------------- /Project_Files/scripts/filewriter/filewriter-tests.js: -------------------------------------------------------------------------------- 1 | /// 2 | // http://www.w3.org/TR/file-writer-api/ 3 | function writeFile(writer) { 4 | function done(evt) { 5 | alert("Write completed."); 6 | } 7 | function error(evt) { 8 | alert("Write failed:" + evt); 9 | } 10 | var b = new Blob(); 11 | writer.onwrite = done; 12 | writer.onerror = error; 13 | writer.write(b); 14 | } 15 | //# sourceMappingURL=filewriter-tests.js.map -------------------------------------------------------------------------------- /Typings/webrtc/readme.md: -------------------------------------------------------------------------------- 1 | # WebRTC Definition Notes 2 | 3 | ## The WebRTC specification 4 | 5 | The WebRTC specification is currently a work in progress, but it has been implemented at a basic level in recent versions of Chrome, Opera and (to a lesser extent) Firefox. 6 | The latest version of the specification can be found at http://dev.w3.org/2011/webrtc/editor/webrtc.html. 7 | 8 | This particular set of definitions has been annotated with the vendor-specific prefixes for Chrome (e.g., `webitkit`), 9 | but anyone who wants, feel free to add the Mozilla-specific prefixes. 10 | 11 | ### Adding the reference to your project 12 | 13 | /// 14 | /// -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/readme.md: -------------------------------------------------------------------------------- 1 | # WebRTC Definition Notes 2 | 3 | ## The WebRTC specification 4 | 5 | The WebRTC specification is currently a work in progress, but it has been implemented at a basic level in recent versions of Chrome, Opera and (to a lesser extent) Firefox. 6 | The latest version of the specification can be found at http://dev.w3.org/2011/webrtc/editor/webrtc.html. 7 | 8 | This particular set of definitions has been annotated with the vendor-specific prefixes for Chrome (e.g., `webitkit`), 9 | but anyone who wants, feel free to add the Mozilla-specific prefixes. 10 | 11 | ### Adding the reference to your project 12 | 13 | /// 14 | /// -------------------------------------------------------------------------------- /Project_Files/scripts/boot.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/platform/browser', './list.component'], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var browser_1, list_component_1; 5 | return { 6 | setters:[ 7 | function (browser_1_1) { 8 | browser_1 = browser_1_1; 9 | }, 10 | function (list_component_1_1) { 11 | list_component_1 = list_component_1_1; 12 | }], 13 | execute: function() { 14 | // We can now bootstrap the "ListComponent" as the root component. 15 | browser_1.bootstrap(list_component_1.ListComponent); 16 | } 17 | } 18 | }); 19 | //# sourceMappingURL=boot.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/list.data.constant.js: -------------------------------------------------------------------------------- 1 | System.register([], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var BOOKMARKS; 5 | return { 6 | setters:[], 7 | execute: function() { 8 | // We are using a constant here, 9 | // because we do not want to change the default data. 10 | exports_1("BOOKMARKS", BOOKMARKS = [ 11 | { 'name': 'Twitter', 'url': 'https://twitter.com' }, 12 | { 'name': 'Github', 'url': 'https://github.com' }, 13 | { 'name': 'Sitepoint', 'url': 'https://sitepoint.com' }, 14 | { 'name': 'Codepen', 'url': 'https://codepen.com' } 15 | ]); 16 | } 17 | } 18 | }); 19 | //# sourceMappingURL=list.data.constant.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/list.service.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"list.service.js","sourceRoot":"","sources":["list.service.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,sEAAsE;;;;;;;;;;;;;;;;;;;;;;;;YAYtE;gBAAA;oBAEE,6BAA6B;oBAC7B,8CAA8C;oBAC9C,+BAA+B;oBAC/B,8CAA8C;oBAC9C,0BAAqB,GAAG,IAAI,CAAC,KAAK,CAAG,YAAY,CAAC,OAAO,CAAE,iBAAiB,CAAE,CAAE,CAAC;oBACjF,yBAAoB,GAAG,8BAAS,CAAC;oBACjC,sBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC;gBAiBhD,CAAC;gBAfC,8EAA8E;gBAC9E,oCAAoC;gBACpC,6CAA6C;gBAC7C,kCAAY,GAAZ;oBACE,EAAE,CAAC,CAAE,IAAI,CAAC,qBAAqB,KAAK,IAAK,CAAC,CAAC,CAAC;wBAC1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC;oBACtD,CAAC;oBACD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAE,IAAI,CAAC,iBAAiB,CAAE,CAAC;gBACnD,CAAC;gBAED,oEAAoE;gBACpE,kCAAY,GAAZ,UAAc,SAAkB;oBAC9B,YAAY,CAAC,OAAO,CAAE,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAE,SAAS,CAAE,CAAE,CAAC;gBACzE,CAAC;gBAzBH;oBAAC,iBAAU,EAAE;;+BAAA;gBA2Bb,kBAAC;YAAD,CAAC,AAzBD,IAyBC;YAzBD,qCAyBC,CAAA"} -------------------------------------------------------------------------------- /Project_Files/scripts/bookmark.component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"bookmark.component.js","sourceRoot":"","sources":["bookmark.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;YAgBA,yEAAyE;YACzE,wEAAwE;YACxE,qDAAqD;YACrD,2DAA2D;YAC3D,4BAA4B;YAU5B;gBAAA;oBAME,0DAA0D;oBAC1D,cAAS,GAAG,KAAK,CAAC;oBAElB,0EAA0E;oBAChE,oBAAe,GAAuB,IAAI,mBAAY,EAAE,CAAC;oBACzD,oBAAe,GAAuB,IAAI,mBAAY,EAAE,CAAC;gBAerE,CAAC;gBAbC,6DAA6D;gBAC7D,oEAAoE;gBACpE,kEAAkE;gBAClE,oCAAQ,GAAR,UAAU,QAAmB;oBAC3B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;oBACvB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAE,QAAQ,CAAE,CAAC;gBACxC,CAAC;gBAED,mFAAmF;gBACnF,oCAAQ,GAAR,UAAU,QAAmB;oBAC3B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAE,QAAQ,CAAE,CAAC;gBACxC,CAAC;gBAdD;oBAAC,aAAM,EAAE;;0EAAA;gBACT;oBAAC,aAAM,EAAE;;0EAAA;gBApBX;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,aAAa;wBACvB,WAAW,EAAE,2BAA2B;wBACxC,MAAM,EAAG,CAAE,UAAU,CAAE;qBAC1B,CAAC;;qCAAA;gBA+BF,wBAAC;YAAD,CAAC,AA1BD,IA0BC;YA1BD,iDA0BC,CAAA"} -------------------------------------------------------------------------------- /Project_Files/templates/list.html: -------------------------------------------------------------------------------- 1 |
2 |
    3 | 4 |
  • 5 | 6 | 7 |
  • 8 |
9 |
10 | -------------------------------------------------------------------------------- /Project_Files/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "SitePoint Bookmark Extension", 4 | "short_name": "Make the most of a new tab", 5 | "description": "This extension helps you save your favorite webpages.", 6 | "version": "1.0.0", 7 | "author": "Michaela Lehr @fischaelameer", 8 | 9 | "icons": { 10 | "19": "Icon-19.png", 11 | "38": "Icon-38.png", 12 | "48": "Icon-48.png", 13 | "128": "Icon-128.png" 14 | }, 15 | 16 | "browser_action": { 17 | "default_icon": { 18 | "19": "Icon-19.png", 19 | "38": "Icon-38.png" 20 | }, 21 | "default_title": "Open a new tab to view your bookmarks." 22 | }, 23 | 24 | "chrome_url_overrides" : { 25 | "newtab": "index.html" 26 | }, 27 | 28 | "background": { 29 | "page": "index.html", 30 | "persistent": false 31 | }, 32 | 33 | "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", 34 | 35 | "permissions": ["activeTab"] 36 | } 37 | -------------------------------------------------------------------------------- /Project_Files/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SitePointBookmarkExtension", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ", 6 | "tsc": "tsc", 7 | "tsc:w": "tsc -w", 8 | "lite": "lite-server", 9 | "copy-lib": "mkdir lib && cp node_modules/{angular2/bundles/angular2-polyfills.js,systemjs/dist/system.src.js,rxjs/bundles/Rx.js,angular2/bundles/angular2.dev.js} lib/", 10 | "compress": "zip -r -X $npm_package_name-$npm_package_version.zip ./{templates/*,lib/*,css/*,scripts/*.js,*.html,manifest.json,*.png,*.ico}" 11 | }, 12 | "dependencies": { 13 | "angular2": "2.0.0-beta.7", 14 | "systemjs": "0.19.22", 15 | "es6-promise": "^3.0.2", 16 | "es6-shim": "^0.33.3", 17 | "reflect-metadata": "0.1.2", 18 | "rxjs": "5.0.0-beta.2", 19 | "zone.js": "0.5.15" 20 | }, 21 | "devDependencies": { 22 | "concurrently": "^2.0.0", 23 | "lite-server": "^2.1.0", 24 | "typescript": "^1.7.5" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Project_Files/scripts/list.component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"list.component.js","sourceRoot":"","sources":["list.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAUA,gEAAgE;YAChE,oEAAoE;YACpE,gFAAgF;YAQhF;gBAIE,uBAAqB,WAAyB,EAAU,SAAqB;oBAAxD,gBAAW,GAAX,WAAW,CAAc;oBAAU,cAAS,GAAT,SAAS,CAAY;gBAAI,CAAC;gBAElF,wEAAwE;gBACxE,+DAA+D;gBAC/D,uDAAuD;gBACvD,wCAAgB,GAAhB;oBAAA,iBAEC;oBADC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,IAAI,CAAE,UAAA,SAAS,IAAI,OAAA,KAAI,CAAC,SAAS,GAAG,SAAS,EAA1B,CAA0B,CAAE,CAAC;gBAClF,CAAC;gBAED,0EAA0E;gBAC1E,gCAAQ,GAAR;oBACE,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC1B,CAAC;gBAED,4DAA4D;gBAC5D,+BAAO,GAAP;oBACE,IAAI,CAAC,WAAW,CAAC,YAAY,CAAE,IAAI,CAAC,SAAS,CAAE,CAAC;gBAClD,CAAC;gBAED,iEAAiE;gBACjE,sCAAc,GAAd,UAAgB,QAAmB,EAAE,CAAU;oBAC7C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAE,CAAC,EAAE,CAAC,CAAE,CAAC;oBAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,CAAC;gBAlCH;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,SAAS;wBACnB,WAAW,EAAE,uBAAuB;wBACpC,UAAU,EAAE,CAAE,sCAAiB,CAAE;wBACjC,SAAS,EAAE,CAAE,0BAAW,EAAE,qBAAS,CAAE;qBACxC,CAAC;;iCAAA;gBA+BF,oBAAC;YAAD,CAAC,AA7BD,IA6BC;YA7BD,yCA6BC,CAAA"} -------------------------------------------------------------------------------- /Project_Files/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SitePoint Bookmark Extension 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Loading bookmarks... 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Project_Files/scripts/eventPage.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"eventPage.js","sourceRoot":"","sources":["eventPage.ts"],"names":[],"mappings":"AAAA,0CAA0C;;;;;;;;;;;;;;;;;;;;;;;;YAO1C;gBAEE,8EAA8E;gBAC9E,qFAAqF;gBACrF,oEAAoE;gBACpE,mBAAsB,WAAyB;oBAAzB,gBAAW,GAAX,WAAW,CAAc;oBAE7C,IAAI,aAA+B,CAAC;oBAEpC,qDAAqD;oBACrD,gDAAgD;oBAChD,4CAA4C;oBAC5C,sBAAsB;oBACtB,EAAE,CAAC,CAAE,OAAO,MAAM,CAAC,aAAa,KAAK,WAAY,CAAC,CAAC,CAAC;wBAClD,gFAAgF;wBAChF,kEAAkE;wBAClE,6EAA6E;wBAC7E,wEAAwE;wBACxE,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,WAAW,CAAE,UAAW,GAAG;4BACxD,WAAW,CAAC,YAAY,EAAE,CAAC,IAAI,CAAE,UAAA,aAAa;gCAC5C,aAAa,GAAG,aAAa,CAAC;gCAC9B,cAAc,CAAE,aAAa,CAAE,CAAC;4BAClC,CAAC,CAAC,CAAC;wBACL,CAAC,CAAC,CAAC;oBACL,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACN,OAAO,CAAC,GAAG,CAAE,uBAAuB,CAAE,CAAC;oBACzC,CAAC;oBAED,yDAAyD;oBACzD,yBAAyB;oBACzB,0CAA0C;oBAC1C,+DAA+D;oBAC/D,wBAAyB,aAAa;wBACpC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAE,IAAI,EAAE,UAAW,GAAG;4BAC3C,IAAI,WAAW,GAAY;gCACzB,IAAI,EAAG,GAAG,CAAC,KAAK;gCAChB,GAAG,EAAG,GAAG,CAAC,GAAG;6BACd,CAAC;4BACF,aAAa,CAAC,IAAI,CAAE,WAAW,CAAE,CAAC;4BAClC,WAAW,CAAC,YAAY,CAAE,aAAa,CAAE,CAAC;wBAC5C,CAAC,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBA5CH;oBAAC,iBAAU,EAAE;;6BAAA;gBA8Cb,gBAAC;YAAD,CAAC,AA5CD,IA4CC;YA5CD,iCA4CC,CAAA"} -------------------------------------------------------------------------------- /Typings/filesystem/filesystem-tests.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"filesystem-tests.js","sourceRoot":"","sources":["filesystem-tests.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,wCAAwC;AAMxC,oBAAoB,EAAa;IAC/B,0CAA0C;IAC1C,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,EAAE,UAAU,CAAC;QAEpD,kEAAkE;QAClE,GAAG;QACH,2BAA2B;QAC3B,EAAE;QACF,uDAAuD;QACvD,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEpB,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,EAAE,UAAU,CAAC;QACpD,CAAC,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC;AACD,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,UAAS,EAAa;IAC5E,UAAU,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC;AAEH,eAAe;AAEf,IAAI,MAAM,GAAkB,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;AACxF,IAAI,OAAO,GAAiB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;AAC3E,IAAI,MAAM,GAAkB,OAAO,CAAC,YAAY,EAAE,CAAC;AACnD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC3B,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAG3B,2BAA2B;AAC3B,IAAI,MAAM,GAAkB,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;AACxF,2DAA2D;AAC3D,IAAI,OAAO,GAAsB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;AAElF,yDAAyD;AACzD,IAAI,CAAC;IACH,IAAI,QAAQ,GAAiB,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;AAChG,CAAE;AAAA,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEd,CAAC"} -------------------------------------------------------------------------------- /Project_Files/scripts/filesystem/filesystem-tests.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"filesystem-tests.js","sourceRoot":"","sources":["filesystem-tests.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,wCAAwC;AAMxC,oBAAoB,EAAa;IAC/B,0CAA0C;IAC1C,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,EAAE,UAAU,CAAC;QAEpD,kEAAkE;QAClE,GAAG;QACH,2BAA2B;QAC3B,EAAE;QACF,uDAAuD;QACvD,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEpB,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,EAAE,UAAU,CAAC;QACpD,CAAC,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC;AACD,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,UAAS,EAAa;IAC5E,UAAU,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC;AAEH,eAAe;AAEf,IAAI,MAAM,GAAkB,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;AACxF,IAAI,OAAO,GAAiB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;AAC3E,IAAI,MAAM,GAAkB,OAAO,CAAC,YAAY,EAAE,CAAC;AACnD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC3B,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAG3B,2BAA2B;AAC3B,IAAI,MAAM,GAAkB,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;AACxF,2DAA2D;AAC3D,IAAI,OAAO,GAAsB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;AAElF,yDAAyD;AACzD,IAAI,CAAC;IACH,IAAI,QAAQ,GAAiB,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;AAChG,CAAE;AAAA,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEd,CAAC"} -------------------------------------------------------------------------------- /Typings/filesystem/filesystem-tests.js: -------------------------------------------------------------------------------- 1 | /// 2 | // http://www.w3.org/TR/file-system-api/ 3 | function useAsyncFS(fs) { 4 | // see getAsText example in [FILE-API-ED]. 5 | fs.root.getFile("already_there.txt", null, function (f) { 6 | // In the example of the specification, there is a following code: 7 | // 8 | // getAsText(f.file()); 9 | // 10 | // It seems wrong because f is ASYNCRONOUS file system. 11 | f.file(getAsText); 12 | }); 13 | // But now we can also write to the file; see [FILE-WRITER-ED]. 14 | fs.root.getFile("logFile", { create: true }, function (f) { 15 | f.createWriter(writeDataToLogFile); 16 | }); 17 | } 18 | window.requestFileSystem(window.TEMPORARY, 1024 * 1024, function (fs) { 19 | useAsyncFS(fs); 20 | }); 21 | // In a worker: 22 | var tempFS = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024); 23 | var logFile = tempFS.root.getFile("logFile", { create: true }); 24 | var writer = logFile.createWriter(); 25 | writer.seek(writer.length); 26 | writeDataToLogFile(writer); 27 | // 5.2 The Flags dictionary 28 | var fsSync = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024); 29 | // Get the data directory, creating it if it doesn't exist. 30 | var dataDir = fsSync.root.getDirectory("data", { create: true }); 31 | // Create the lock file, if and only if it doesn't exist. 32 | try { 33 | var lockFile = dataDir.getFile("lockfile.txt", { create: true, exclusive: true }); 34 | } 35 | catch (ex) { 36 | } 37 | //# sourceMappingURL=filesystem-tests.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/filesystem/filesystem-tests.js: -------------------------------------------------------------------------------- 1 | /// 2 | // http://www.w3.org/TR/file-system-api/ 3 | function useAsyncFS(fs) { 4 | // see getAsText example in [FILE-API-ED]. 5 | fs.root.getFile("already_there.txt", null, function (f) { 6 | // In the example of the specification, there is a following code: 7 | // 8 | // getAsText(f.file()); 9 | // 10 | // It seems wrong because f is ASYNCRONOUS file system. 11 | f.file(getAsText); 12 | }); 13 | // But now we can also write to the file; see [FILE-WRITER-ED]. 14 | fs.root.getFile("logFile", { create: true }, function (f) { 15 | f.createWriter(writeDataToLogFile); 16 | }); 17 | } 18 | window.requestFileSystem(window.TEMPORARY, 1024 * 1024, function (fs) { 19 | useAsyncFS(fs); 20 | }); 21 | // In a worker: 22 | var tempFS = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024); 23 | var logFile = tempFS.root.getFile("logFile", { create: true }); 24 | var writer = logFile.createWriter(); 25 | writer.seek(writer.length); 26 | writeDataToLogFile(writer); 27 | // 5.2 The Flags dictionary 28 | var fsSync = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024); 29 | // Get the data directory, creating it if it doesn't exist. 30 | var dataDir = fsSync.root.getDirectory("data", { create: true }); 31 | // Create the lock file, if and only if it doesn't exist. 32 | try { 33 | var lockFile = dataDir.getFile("lockfile.txt", { create: true, exclusive: true }); 34 | } 35 | catch (ex) { 36 | } 37 | //# sourceMappingURL=filesystem-tests.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/list.service.ts: -------------------------------------------------------------------------------- 1 | // We need to refence a typings file to let TypeScript recognize the Angular "promise" function 2 | /// 3 | 4 | import { BookmarkComponent } from './bookmark.component'; 5 | import { BOOKMARKS } from './list.data.constant'; 6 | 7 | // Importing the "Injectable" function from the angular2/core module 8 | // and adding the ""@Injectable" decorator lets us use dependency injection 9 | // in this service. 10 | import { Injectable } from 'angular2/core'; 11 | 12 | @Injectable() 13 | 14 | export class ListService { 15 | 16 | // We create three variables: 17 | // one for possible data in the local storage, 18 | // one for our default data and 19 | // one for the data our service should return. 20 | bookmarksLocalStorage = JSON.parse( localStorage.getItem( 'sp-bookmarklist' ) ); 21 | bookmarksDefaultData = BOOKMARKS; 22 | bookmarksToReturn = this.bookmarksDefaultData; 23 | 24 | // The "getBookmarks()" function checks if there is data in the local storage. 25 | // If there is, we return this data, 26 | // if there isn't we return the default data. 27 | getBookmarks() { 28 | if ( this.bookmarksLocalStorage !== null ) { 29 | this.bookmarksToReturn = this.bookmarksLocalStorage; 30 | } 31 | return Promise.resolve( this.bookmarksToReturn ); 32 | } 33 | 34 | // A "setBookmarks()"" function saves new data in the local storage. 35 | setBookmarks( bookmarks : Object ) { 36 | localStorage.setItem( 'sp-bookmarklist', JSON.stringify( bookmarks ) ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Build Your Own Chrome Extension Using Angular 2 & TypeScript 2 | 3 | Add new functionality to your browser! Michaela Lehr shows you how to create your own bookmark manager Chrome extension using Angular 2 and TypeScript. 4 | 5 | http://www.sitepoint.com/chrome-extension-angular-2 6 | 7 | ## Requirements 8 | 9 | * [Node.js](http://nodejs.org/) 10 | 11 | ## Installation Steps 12 | 13 | 1. Clone repo 14 | 2. Change to `Project_Files` directory 15 | 3. Run `npm install` 16 | 4. Run `npm run start` 17 | 18 | ## License 19 | 20 | The MIT License (MIT) 21 | 22 | Copyright (c) 2016 SitePoint 23 | 24 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | -------------------------------------------------------------------------------- /Typings/webrtc/MediaStream-tests.js: -------------------------------------------------------------------------------- 1 | /// 2 | var mediaStreamConstraints = { audio: true, video: true }; 3 | var mediaTrackConstraintSet = {}; 4 | var mediaTrackConstraintArray = []; 5 | var mediaTrackConstraints = mediaTrackConstraintSet; 6 | var mediaTrackConstraints2 = { advanced: mediaTrackConstraintArray }; 7 | navigator.getUserMedia(mediaStreamConstraints, function (stream) { 8 | var track = stream.getTracks()[0]; 9 | console.log('label:' + track.label); 10 | console.log('ended:' + track.readyState); 11 | track.onended = function (event) { return console.log('Track ended'); }; 12 | var objectUrl = URL.createObjectURL(stream); 13 | }, function (error) { 14 | console.log('Error message: ' + error.message); 15 | console.log('Error name: ' + error.name); 16 | }); 17 | navigator.webkitGetUserMedia(mediaStreamConstraints, function (stream) { 18 | var track = stream.getTracks()[0]; 19 | console.log('label:' + track.label); 20 | console.log('ended:' + track.readyState); 21 | track.onended = function (event) { return console.log('Track ended'); }; 22 | var objectUrl = URL.createObjectURL(stream); 23 | }, function (error) { 24 | console.log('Error message: ' + error.message); 25 | console.log('Error name: ' + error.name); 26 | }); 27 | navigator.mozGetUserMedia(mediaStreamConstraints, function (stream) { 28 | var track = stream.getTracks()[0]; 29 | console.log('label:' + track.label); 30 | console.log('ended:' + track.readyState); 31 | track.onended = function (event) { return console.log('Track ended'); }; 32 | var objectUrl = URL.createObjectURL(stream); 33 | }, function (error) { 34 | console.log('Error message: ' + error.message); 35 | console.log('Error name: ' + error.name); 36 | }); 37 | //# sourceMappingURL=MediaStream-tests.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/MediaStream-tests.js: -------------------------------------------------------------------------------- 1 | /// 2 | var mediaStreamConstraints = { audio: true, video: true }; 3 | var mediaTrackConstraintSet = {}; 4 | var mediaTrackConstraintArray = []; 5 | var mediaTrackConstraints = mediaTrackConstraintSet; 6 | var mediaTrackConstraints2 = { advanced: mediaTrackConstraintArray }; 7 | navigator.getUserMedia(mediaStreamConstraints, function (stream) { 8 | var track = stream.getTracks()[0]; 9 | console.log('label:' + track.label); 10 | console.log('ended:' + track.readyState); 11 | track.onended = function (event) { return console.log('Track ended'); }; 12 | var objectUrl = URL.createObjectURL(stream); 13 | }, function (error) { 14 | console.log('Error message: ' + error.message); 15 | console.log('Error name: ' + error.name); 16 | }); 17 | navigator.webkitGetUserMedia(mediaStreamConstraints, function (stream) { 18 | var track = stream.getTracks()[0]; 19 | console.log('label:' + track.label); 20 | console.log('ended:' + track.readyState); 21 | track.onended = function (event) { return console.log('Track ended'); }; 22 | var objectUrl = URL.createObjectURL(stream); 23 | }, function (error) { 24 | console.log('Error message: ' + error.message); 25 | console.log('Error name: ' + error.name); 26 | }); 27 | navigator.mozGetUserMedia(mediaStreamConstraints, function (stream) { 28 | var track = stream.getTracks()[0]; 29 | console.log('label:' + track.label); 30 | console.log('ended:' + track.readyState); 31 | track.onended = function (event) { return console.log('Track ended'); }; 32 | var objectUrl = URL.createObjectURL(stream); 33 | }, function (error) { 34 | console.log('Error message: ' + error.message); 35 | console.log('Error name: ' + error.name); 36 | }); 37 | //# sourceMappingURL=MediaStream-tests.js.map -------------------------------------------------------------------------------- /Typings/filesystem/filesystem-tests.ts: -------------------------------------------------------------------------------- 1 | /// 2 | // http://www.w3.org/TR/file-system-api/ 3 | 4 | // 2. Introduction 5 | declare function getAsText(file:File): void; 6 | declare function writeDataToLogFile(fileWriter:FileWriterSync): void; 7 | 8 | function useAsyncFS(fs:FileSystem):void { 9 | // see getAsText example in [FILE-API-ED]. 10 | fs.root.getFile("already_there.txt", null, function (f): void{ 11 | 12 | // In the example of the specification, there is a following code: 13 | // 14 | // getAsText(f.file()); 15 | // 16 | // It seems wrong because f is ASYNCRONOUS file system. 17 | f.file(getAsText); 18 | 19 | }); 20 | 21 | // But now we can also write to the file; see [FILE-WRITER-ED]. 22 | fs.root.getFile("logFile", {create: true}, function (f): void{ 23 | f.createWriter(writeDataToLogFile); 24 | }); 25 | } 26 | window.requestFileSystem(window.TEMPORARY, 1024 * 1024, function(fs:FileSystem): void{ 27 | useAsyncFS(fs); 28 | }); 29 | 30 | // In a worker: 31 | 32 | var tempFS:FileSystemSync = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024); 33 | var logFile:FileEntrySync = tempFS.root.getFile("logFile", {create: true}); 34 | var writer:FileWriterSync = logFile.createWriter(); 35 | writer.seek(writer.length); 36 | writeDataToLogFile(writer); 37 | 38 | 39 | // 5.2 The Flags dictionary 40 | var fsSync:FileSystemSync = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024); 41 | // Get the data directory, creating it if it doesn't exist. 42 | var dataDir:DirectoryEntrySync = fsSync.root.getDirectory("data", {create: true}); 43 | 44 | // Create the lock file, if and only if it doesn't exist. 45 | try { 46 | var lockFile:FileEntrySync = dataDir.getFile("lockfile.txt", {create: true, exclusive: true}); 47 | } catch (ex) { 48 | // It already exists, or something else went wrong. 49 | } 50 | -------------------------------------------------------------------------------- /Project_Files/scripts/filesystem/filesystem-tests.ts: -------------------------------------------------------------------------------- 1 | /// 2 | // http://www.w3.org/TR/file-system-api/ 3 | 4 | // 2. Introduction 5 | declare function getAsText(file:File): void; 6 | declare function writeDataToLogFile(fileWriter:FileWriterSync): void; 7 | 8 | function useAsyncFS(fs:FileSystem):void { 9 | // see getAsText example in [FILE-API-ED]. 10 | fs.root.getFile("already_there.txt", null, function (f): void{ 11 | 12 | // In the example of the specification, there is a following code: 13 | // 14 | // getAsText(f.file()); 15 | // 16 | // It seems wrong because f is ASYNCRONOUS file system. 17 | f.file(getAsText); 18 | 19 | }); 20 | 21 | // But now we can also write to the file; see [FILE-WRITER-ED]. 22 | fs.root.getFile("logFile", {create: true}, function (f): void{ 23 | f.createWriter(writeDataToLogFile); 24 | }); 25 | } 26 | window.requestFileSystem(window.TEMPORARY, 1024 * 1024, function(fs:FileSystem): void{ 27 | useAsyncFS(fs); 28 | }); 29 | 30 | // In a worker: 31 | 32 | var tempFS:FileSystemSync = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024); 33 | var logFile:FileEntrySync = tempFS.root.getFile("logFile", {create: true}); 34 | var writer:FileWriterSync = logFile.createWriter(); 35 | writer.seek(writer.length); 36 | writeDataToLogFile(writer); 37 | 38 | 39 | // 5.2 The Flags dictionary 40 | var fsSync:FileSystemSync = window.requestFileSystemSync(window.TEMPORARY, 1024 * 1024); 41 | // Get the data directory, creating it if it doesn't exist. 42 | var dataDir:DirectoryEntrySync = fsSync.root.getDirectory("data", {create: true}); 43 | 44 | // Create the lock file, if and only if it doesn't exist. 45 | try { 46 | var lockFile:FileEntrySync = dataDir.getFile("lockfile.txt", {create: true, exclusive: true}); 47 | } catch (ex) { 48 | // It already exists, or something else went wrong. 49 | } 50 | -------------------------------------------------------------------------------- /Project_Files/templates/bookmark.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | {{bookmark.name}} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
23 |
24 | -------------------------------------------------------------------------------- /Typings/webrtc/MediaStream-tests.ts: -------------------------------------------------------------------------------- 1 | /// 2 | var mediaStreamConstraints: MediaStreamConstraints = { audio: true, video: true }; 3 | 4 | var mediaTrackConstraintSet: MediaTrackConstraintSet = {}; 5 | var mediaTrackConstraintArray: MediaTrackConstraintSet[] = []; 6 | var mediaTrackConstraints: MediaTrackConstraints = mediaTrackConstraintSet; 7 | var mediaTrackConstraints2: MediaTrackConstraints = { advanced: mediaTrackConstraintArray }; 8 | 9 | navigator.getUserMedia(mediaStreamConstraints, 10 | stream => { 11 | var track: MediaStreamTrack = stream.getTracks()[0]; 12 | console.log('label:' + track.label); 13 | console.log('ended:' + track.readyState); 14 | track.onended = (event:Event) => console.log('Track ended'); 15 | var objectUrl = URL.createObjectURL(stream); 16 | }, 17 | error => { 18 | console.log('Error message: ' + error.message); 19 | console.log('Error name: ' + error.name); 20 | }); 21 | 22 | navigator.webkitGetUserMedia(mediaStreamConstraints, 23 | stream => { 24 | var track: MediaStreamTrack = stream.getTracks()[0]; 25 | console.log('label:' + track.label); 26 | console.log('ended:' + track.readyState); 27 | track.onended = (event:Event) => console.log('Track ended'); 28 | var objectUrl = URL.createObjectURL(stream); 29 | }, 30 | error => { 31 | console.log('Error message: ' + error.message); 32 | console.log('Error name: ' + error.name); 33 | }); 34 | 35 | 36 | navigator.mozGetUserMedia(mediaStreamConstraints, 37 | stream => { 38 | var track: MediaStreamTrack = stream.getTracks()[0]; 39 | console.log('label:' + track.label); 40 | console.log('ended:' + track.readyState); 41 | track.onended = (event:Event) => console.log('Track ended'); 42 | var objectUrl = URL.createObjectURL(stream); 43 | }, 44 | error => { 45 | console.log('Error message: ' + error.message); 46 | console.log('Error name: ' + error.name); 47 | }); 48 | -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/MediaStream-tests.ts: -------------------------------------------------------------------------------- 1 | /// 2 | var mediaStreamConstraints: MediaStreamConstraints = { audio: true, video: true }; 3 | 4 | var mediaTrackConstraintSet: MediaTrackConstraintSet = {}; 5 | var mediaTrackConstraintArray: MediaTrackConstraintSet[] = []; 6 | var mediaTrackConstraints: MediaTrackConstraints = mediaTrackConstraintSet; 7 | var mediaTrackConstraints2: MediaTrackConstraints = { advanced: mediaTrackConstraintArray }; 8 | 9 | navigator.getUserMedia(mediaStreamConstraints, 10 | stream => { 11 | var track: MediaStreamTrack = stream.getTracks()[0]; 12 | console.log('label:' + track.label); 13 | console.log('ended:' + track.readyState); 14 | track.onended = (event:Event) => console.log('Track ended'); 15 | var objectUrl = URL.createObjectURL(stream); 16 | }, 17 | error => { 18 | console.log('Error message: ' + error.message); 19 | console.log('Error name: ' + error.name); 20 | }); 21 | 22 | navigator.webkitGetUserMedia(mediaStreamConstraints, 23 | stream => { 24 | var track: MediaStreamTrack = stream.getTracks()[0]; 25 | console.log('label:' + track.label); 26 | console.log('ended:' + track.readyState); 27 | track.onended = (event:Event) => console.log('Track ended'); 28 | var objectUrl = URL.createObjectURL(stream); 29 | }, 30 | error => { 31 | console.log('Error message: ' + error.message); 32 | console.log('Error name: ' + error.name); 33 | }); 34 | 35 | 36 | navigator.mozGetUserMedia(mediaStreamConstraints, 37 | stream => { 38 | var track: MediaStreamTrack = stream.getTracks()[0]; 39 | console.log('label:' + track.label); 40 | console.log('ended:' + track.readyState); 41 | track.onended = (event:Event) => console.log('Track ended'); 42 | var objectUrl = URL.createObjectURL(stream); 43 | }, 44 | error => { 45 | console.log('Error message: ' + error.message); 46 | console.log('Error name: ' + error.name); 47 | }); 48 | -------------------------------------------------------------------------------- /Typings/webrtc/MediaStream-tests.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"MediaStream-tests.js","sourceRoot":"","sources":["MediaStream-tests.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,IAAI,sBAAsB,GAA2B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAElF,IAAI,uBAAuB,GAA4B,EAAE,CAAC;AAC1D,IAAI,yBAAyB,GAA8B,EAAE,CAAC;AAC9D,IAAI,qBAAqB,GAA0B,uBAAuB,CAAC;AAC3E,IAAI,sBAAsB,GAA0B,EAAE,QAAQ,EAAE,yBAAyB,EAAE,CAAC;AAE5F,SAAS,CAAC,YAAY,CAAC,sBAAsB,EAC3C,UAAA,MAAM;IACJ,IAAI,KAAK,GAAqB,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACzC,KAAK,CAAC,OAAO,GAAG,UAAC,KAAW,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAA1B,CAA0B,CAAC;IAC5D,IAAI,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,EACD,UAAA,KAAK;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEL,SAAS,CAAC,kBAAkB,CAAC,sBAAsB,EACjD,UAAA,MAAM;IACJ,IAAI,KAAK,GAAqB,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACzC,KAAK,CAAC,OAAO,GAAG,UAAC,KAAW,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAA1B,CAA0B,CAAC;IAC5D,IAAI,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,EACD,UAAA,KAAK;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAGL,SAAS,CAAC,eAAe,CAAC,sBAAsB,EAC9C,UAAA,MAAM;IACJ,IAAI,KAAK,GAAqB,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACzC,KAAK,CAAC,OAAO,GAAG,UAAC,KAAW,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAA1B,CAA0B,CAAC;IAC5D,IAAI,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,EACD,UAAA,KAAK;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/MediaStream-tests.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"MediaStream-tests.js","sourceRoot":"","sources":["MediaStream-tests.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,IAAI,sBAAsB,GAA2B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAElF,IAAI,uBAAuB,GAA4B,EAAE,CAAC;AAC1D,IAAI,yBAAyB,GAA8B,EAAE,CAAC;AAC9D,IAAI,qBAAqB,GAA0B,uBAAuB,CAAC;AAC3E,IAAI,sBAAsB,GAA0B,EAAE,QAAQ,EAAE,yBAAyB,EAAE,CAAC;AAE5F,SAAS,CAAC,YAAY,CAAC,sBAAsB,EAC3C,UAAA,MAAM;IACJ,IAAI,KAAK,GAAqB,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACzC,KAAK,CAAC,OAAO,GAAG,UAAC,KAAW,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAA1B,CAA0B,CAAC;IAC5D,IAAI,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,EACD,UAAA,KAAK;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEL,SAAS,CAAC,kBAAkB,CAAC,sBAAsB,EACjD,UAAA,MAAM;IACJ,IAAI,KAAK,GAAqB,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACzC,KAAK,CAAC,OAAO,GAAG,UAAC,KAAW,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAA1B,CAA0B,CAAC;IAC5D,IAAI,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,EACD,UAAA,KAAK;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAGL,SAAS,CAAC,eAAe,CAAC,sBAAsB,EAC9C,UAAA,MAAM;IACJ,IAAI,KAAK,GAAqB,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACzC,KAAK,CAAC,OAAO,GAAG,UAAC,KAAW,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAA1B,CAA0B,CAAC;IAC5D,IAAI,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,EACD,UAAA,KAAK;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /Project_Files/scripts/list.component.ts: -------------------------------------------------------------------------------- 1 | // We're importing Angular's "Component" and "OnInit" functions 2 | // from the angular2/core module. 3 | // We're also importing the "Bookmark", the "BookmarkComponent" class from our own bookmark.component, the "ListService" and "EventPage". 4 | import { Component } from 'angular2/core'; 5 | import { OnInit } from 'angular2/core'; 6 | import { Bookmark } from './bookmark.component'; 7 | import { BookmarkComponent } from './bookmark.component'; 8 | import { ListService } from './list.service'; 9 | import { EventPage } from './eventPage'; 10 | 11 | // The ListComponent meta data defines the component's selector, 12 | // the url of the template and the directives used in this template. 13 | // The provider meta data reference the ListService we're using to get the data. 14 | @Component({ 15 | selector: 'sp-list', 16 | templateUrl: './templates/list.html', 17 | directives: [ BookmarkComponent ], 18 | providers: [ ListService, EventPage ] 19 | }) 20 | 21 | export class ListComponent implements OnInit { 22 | 23 | public bookmarks : Array< Object >; 24 | 25 | constructor( private listService : ListService, private eventPage : EventPage ) {} 26 | 27 | // The function "getBookmarkLists" demands the bookmarks asynchronously. 28 | // When the promise is resolved, the callback function assignes 29 | // the bookmarks to the component's bookmarks property. 30 | getBookmarkLists() { 31 | this.listService.getBookmarks().then( bookmarks => this.bookmarks = bookmarks ); 32 | } 33 | 34 | // The "ngOnInit" function gets called, when the component gets activated. 35 | ngOnInit() { 36 | this.getBookmarkLists(); 37 | } 38 | 39 | // setList uses the "ListService" to save the complete list. 40 | setList() { 41 | this.listService.setBookmarks( this.bookmarks ); 42 | } 43 | 44 | // The function deletes the bookmark and saves the complete list. 45 | deleteBookmark( bookmark : Bookmark, i : number ) { 46 | this.bookmarks.splice( i, 1 ); 47 | this.setList(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Project_Files/scripts/eventPage.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import { Injectable } from 'angular2/core'; 4 | import { ListService } from './list.service'; 5 | 6 | @Injectable() 7 | 8 | export class EventPage { 9 | 10 | // The event listener should be set when the "EventPage" class is initialized. 11 | // Therefore we're using the constructor for adding it to the "Chrome.browserAction". 12 | // To set and get the bookmark lists, we're using the "ListService". 13 | constructor ( private listService : ListService ) { 14 | 15 | let bookmarkLists : Array< Object >; 16 | 17 | // The "Chrome.browserAction" object throws an error, 18 | // when it is not available in development mode. 19 | // This is why we're only logging a message, 20 | // if it is undefined. 21 | if ( typeof chrome.browserAction !== 'undefined' ) { 22 | // The Chrome "browserAction" is responsible for the icon in the Chrome toolbar. 23 | // Its "onClicked" function gets fired, when the icon was clicked. 24 | // This is when we're get the latest list of bookmarks from the "ListService" 25 | // and call the function "getSelectedTab" after the promise is resolved. 26 | chrome.browserAction.onClicked.addListener( function ( tab ) { 27 | listService.getBookmarks().then( bookmarkLists => { 28 | bookmarkLists = bookmarkLists; 29 | getSelectedTab( bookmarkLists ); 30 | }); 31 | }); 32 | } else { 33 | console.log( 'EventPage initialized' ); 34 | } 35 | 36 | // The Chrome tabs API gives us access to the current tab 37 | // and its title and url, 38 | // which we're using to add a new bookmark 39 | // and save the list of bookmarks again with the "ListService". 40 | function getSelectedTab( bookmarkLists ) { 41 | chrome.tabs.getSelected( null, function ( tab ) { 42 | let newBookmark : Object = { 43 | name : tab.title, 44 | url : tab.url 45 | }; 46 | bookmarkLists.push( newBookmark ); 47 | listService.setBookmarks( bookmarkLists ); 48 | }); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Project_Files/scripts/bookmark.component.ts: -------------------------------------------------------------------------------- 1 | // To create a component, we need the Angular "Component" function. 2 | // It can be imported from the angular2/core module. 3 | // We also need the Angular functions "Output" and "EventEmitter". 4 | import { Component } from 'angular2/core'; 5 | import { Output } from 'angular2/core'; 6 | import { EventEmitter } from 'angular2/core'; 7 | 8 | // We're using an interface to represent a bookmark. 9 | // A single bookmark is now strongly typed: 10 | // it has to have two properties "name" and "url", 11 | // which both must be a string. 12 | export interface Bookmark { 13 | name : string, 14 | url : string 15 | } 16 | 17 | // A component decorator tells Angular that the "BookmarkComponent" class 18 | // is a component and adds its meta data: the selector and the template. 19 | // Additionally we have to declare an input property, 20 | // because we want to use "[bookmark]" in the list template 21 | // as a data binding target. 22 | @Component({ 23 | selector: 'sp-bookmark', 24 | templateUrl: './templates/bookmark.html', 25 | inputs : [ 'bookmark' ] 26 | }) 27 | 28 | // The "BookmarkComponent" module exports the "BookmarkComponent" class, 29 | // because we will need it in other modules, 30 | // e.g. to create the bookmark list. 31 | export class BookmarkComponent { 32 | 33 | // The bookmark property is of the type "Bookmark", 34 | // defined in the interface above. 35 | bookmark : Bookmark; 36 | 37 | // Setting the default value for the "submitted" property. 38 | submitted = false; 39 | 40 | // Events flow outside the component and therefor need an output property. 41 | @Output() bookmarkChanged : EventEmitter = new EventEmitter(); 42 | @Output() bookmarkDeleted : EventEmitter = new EventEmitter(); 43 | 44 | // Whenever a user clicks on "Done" after editing a bookmark, 45 | // an event is fired, which indicates that the bookmark was changed. 46 | // To hide the form, the submitted property is set to false again. 47 | onSubmit( bookmark : Bookmark ) { 48 | this.submitted = false; 49 | this.bookmarkChanged.emit( bookmark ); 50 | } 51 | 52 | // When the "Delete" button was pressed, the event "bookmarkDeleted" will be fired. 53 | onDelete( bookmark : Bookmark ) { 54 | this.bookmarkDeleted.emit( bookmark ); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Project_Files/scripts/list.service.js: -------------------------------------------------------------------------------- 1 | // We need to refence a typings file to let TypeScript recognize the Angular "promise" function 2 | /// 3 | System.register(['./list.data.constant', 'angular2/core'], function(exports_1, context_1) { 4 | "use strict"; 5 | var __moduleName = context_1 && context_1.id; 6 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 7 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 8 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 9 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 10 | return c > 3 && r && Object.defineProperty(target, key, r), r; 11 | }; 12 | var __metadata = (this && this.__metadata) || function (k, v) { 13 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 14 | }; 15 | var list_data_constant_1, core_1; 16 | var ListService; 17 | return { 18 | setters:[ 19 | function (list_data_constant_1_1) { 20 | list_data_constant_1 = list_data_constant_1_1; 21 | }, 22 | function (core_1_1) { 23 | core_1 = core_1_1; 24 | }], 25 | execute: function() { 26 | ListService = (function () { 27 | function ListService() { 28 | // We create three variables: 29 | // one for possible data in the local storage, 30 | // one for our default data and 31 | // one for the data our service should return. 32 | this.bookmarksLocalStorage = JSON.parse(localStorage.getItem('sp-bookmarklist')); 33 | this.bookmarksDefaultData = list_data_constant_1.BOOKMARKS; 34 | this.bookmarksToReturn = this.bookmarksDefaultData; 35 | } 36 | // The "getBookmarks()" function checks if there is data in the local storage. 37 | // If there is, we return this data, 38 | // if there isn't we return the default data. 39 | ListService.prototype.getBookmarks = function () { 40 | if (this.bookmarksLocalStorage !== null) { 41 | this.bookmarksToReturn = this.bookmarksLocalStorage; 42 | } 43 | return Promise.resolve(this.bookmarksToReturn); 44 | }; 45 | // A "setBookmarks()"" function saves new data in the local storage. 46 | ListService.prototype.setBookmarks = function (bookmarks) { 47 | localStorage.setItem('sp-bookmarklist', JSON.stringify(bookmarks)); 48 | }; 49 | ListService = __decorate([ 50 | core_1.Injectable(), 51 | __metadata('design:paramtypes', []) 52 | ], ListService); 53 | return ListService; 54 | }()); 55 | exports_1("ListService", ListService); 56 | } 57 | } 58 | }); 59 | //# sourceMappingURL=list.service.js.map -------------------------------------------------------------------------------- /Typings/webrtc/RTCPeerConnection-tests.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"RTCPeerConnection-tests.js","sourceRoot":"","sources":["RTCPeerConnection-tests.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,+CAA+C;AAE/C,IAAI,MAAM,GACN,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,CAAC,EAAE,CAAC;AAC1D,IAAI,WAAW,GACX,EAAE,SAAS,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,EAAE,CAAC;AAE5E,IAAI,cAAc,GACd,IAAI,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE/C,SAAS,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EACjD,UAAA,MAAM;IACJ,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC,EACD,UAAA,KAAK;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEL,cAAc,CAAC,WAAW,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AACxD,cAAc,CAAC,aAAa,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAC1D,cAAc,CAAC,0BAA0B,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AACvE,cAAc,CAAC,mBAAmB,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAChE,cAAc,CAAC,MAAM,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AACnD,cAAc,CAAC,cAAc,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAC3D,cAAc,CAAC,cAAc,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAC3D,cAAc,CAAC,aAAa,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAE1D,cAAc,CAAC,WAAW,CACxB,UAAA,KAAK;IACH,cAAc,CAAC,mBAAmB,CAAC,KAAK,EACtC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAApC,CAAoC,EAC1C,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,mCAAmC,GAAG,KAAK,CAAC,EAAxD,CAAwD,CAAC,CAAC;AACvE,CAAC,EACD,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,wBAAwB,GAAG,KAAK,CAAC,EAA7C,CAA6C,CAAC,CAAC;AAE1D,IAAI,IAAI,GAAW,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAChD,IAAI,KAAK,GAA8B,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;AACvE,IAAI,kBAAkB,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAE1D,cAAc,CAAC,oBAAoB,CAAC,kBAAkB,EAAE;IACtD,cAAc,CAAC,YAAY,CACzB,UAAA,MAAM;QACJ,cAAc,CAAC,mBAAmB,CAAC,MAAM,EACvC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAApC,CAAoC,EAC5C,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAChB,uDAAuD,GAAG,KAAK;YAC/D,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,EAFxB,CAEwB,CAAC,CAAC;IACrC,CAAC,EACH,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,KAAK,CAAC,EAA9C,CAA8C,CAAC,CAAC;AAC3D,CAAC,EACD,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAG,KAAK;IAC7D,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,EADtB,CACsB,CAAC,CAAC;AAEjC,IAAI,wBAAwB,GAAG,IAAI,2BAA2B,CAAC,KAAK,CAAC,CAAC;AAEtE,cAAc,CAAC,oBAAoB,CAAC,wBAAwB,EAAE;IAC5D,cAAc,CAAC,YAAY,CACzB,UAAA,MAAM;QACJ,cAAc,CAAC,mBAAmB,CAAC,MAAM,EACvC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAApC,CAAoC,EAC5C,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CACjB,uDAAuD,GAAG,KAAK;YAC/D,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,EAFvB,CAEuB,CAAC,CAAC;IACpC,CAAC,EACH,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,KAAK,CAAC,EAA9C,CAA8C,CAAC,CAAC;AAC3D,CAAC,EACD,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAG,KAAK;IAC7D,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,EADtB,CACsB,CAAC,CAAC;AAEjC,IAAI,qBAAqB,GAAG,IAAI,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAEhE,cAAc,CAAC,oBAAoB,CAAC,qBAAqB,EAAE;IACzD,cAAc,CAAC,YAAY,CACzB,UAAA,MAAM;QACJ,cAAc,CAAC,mBAAmB,CAAC,MAAM,EACvC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAApC,CAAoC,EAC5C,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CACjB,uDAAuD,GAAG,KAAK;YAC/D,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,EAFvB,CAEuB,CAAC,CAAC;IACpC,CAAC,EACH,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,KAAK,CAAC,EAA9C,CAA8C,CAAC,CAAC;AAC3D,CAAC,EACD,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAG,KAAK;IAC7D,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,EADtB,CACsB,CAAC,CAAC;AAEjC,IAAI,gBAAgB,GAChB,IAAI,uBAAuB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC"} -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/RTCPeerConnection-tests.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"RTCPeerConnection-tests.js","sourceRoot":"","sources":["RTCPeerConnection-tests.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,+CAA+C;AAE/C,IAAI,MAAM,GACN,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,CAAC,EAAE,CAAC;AAC1D,IAAI,WAAW,GACX,EAAE,SAAS,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,EAAE,CAAC;AAE5E,IAAI,cAAc,GACd,IAAI,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE/C,SAAS,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EACjD,UAAA,MAAM;IACJ,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC,EACD,UAAA,KAAK;IACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEL,cAAc,CAAC,WAAW,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AACxD,cAAc,CAAC,aAAa,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAC1D,cAAc,CAAC,0BAA0B,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AACvE,cAAc,CAAC,mBAAmB,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAChE,cAAc,CAAC,MAAM,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AACnD,cAAc,CAAC,cAAc,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAC3D,cAAc,CAAC,cAAc,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAC3D,cAAc,CAAC,aAAa,GAAG,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAApB,CAAoB,CAAC;AAE1D,cAAc,CAAC,WAAW,CACxB,UAAA,KAAK;IACH,cAAc,CAAC,mBAAmB,CAAC,KAAK,EACtC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAApC,CAAoC,EAC1C,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,mCAAmC,GAAG,KAAK,CAAC,EAAxD,CAAwD,CAAC,CAAC;AACvE,CAAC,EACD,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,wBAAwB,GAAG,KAAK,CAAC,EAA7C,CAA6C,CAAC,CAAC;AAE1D,IAAI,IAAI,GAAW,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAChD,IAAI,KAAK,GAA8B,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;AACvE,IAAI,kBAAkB,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAE1D,cAAc,CAAC,oBAAoB,CAAC,kBAAkB,EAAE;IACtD,cAAc,CAAC,YAAY,CACzB,UAAA,MAAM;QACJ,cAAc,CAAC,mBAAmB,CAAC,MAAM,EACvC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAApC,CAAoC,EAC5C,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAChB,uDAAuD,GAAG,KAAK;YAC/D,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,EAFxB,CAEwB,CAAC,CAAC;IACrC,CAAC,EACH,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,KAAK,CAAC,EAA9C,CAA8C,CAAC,CAAC;AAC3D,CAAC,EACD,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAG,KAAK;IAC7D,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,EADtB,CACsB,CAAC,CAAC;AAEjC,IAAI,wBAAwB,GAAG,IAAI,2BAA2B,CAAC,KAAK,CAAC,CAAC;AAEtE,cAAc,CAAC,oBAAoB,CAAC,wBAAwB,EAAE;IAC5D,cAAc,CAAC,YAAY,CACzB,UAAA,MAAM;QACJ,cAAc,CAAC,mBAAmB,CAAC,MAAM,EACvC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAApC,CAAoC,EAC5C,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CACjB,uDAAuD,GAAG,KAAK;YAC/D,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,EAFvB,CAEuB,CAAC,CAAC;IACpC,CAAC,EACH,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,KAAK,CAAC,EAA9C,CAA8C,CAAC,CAAC;AAC3D,CAAC,EACD,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAG,KAAK;IAC7D,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,EADtB,CACsB,CAAC,CAAC;AAEjC,IAAI,qBAAqB,GAAG,IAAI,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAEhE,cAAc,CAAC,oBAAoB,CAAC,qBAAqB,EAAE;IACzD,cAAc,CAAC,YAAY,CACzB,UAAA,MAAM;QACJ,cAAc,CAAC,mBAAmB,CAAC,MAAM,EACvC,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAApC,CAAoC,EAC5C,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CACjB,uDAAuD,GAAG,KAAK;YAC/D,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,EAFvB,CAEuB,CAAC,CAAC;IACpC,CAAC,EACH,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,KAAK,CAAC,EAA9C,CAA8C,CAAC,CAAC;AAC3D,CAAC,EACD,UAAA,KAAK,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAG,KAAK;IAC7D,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,EADtB,CACsB,CAAC,CAAC;AAEjC,IAAI,gBAAgB,GAChB,IAAI,uBAAuB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC"} -------------------------------------------------------------------------------- /Typings/webrtc/RTCPeerConnection-tests.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | var config: RTCConfiguration = 5 | { iceServers: [{ urls: "stun.l.google.com:19302" }] }; 6 | var constraints: RTCMediaConstraints = 7 | { mandatory: { offerToReceiveAudio: true, offerToReceiveVideo: true } }; 8 | 9 | var peerConnection: RTCPeerConnection = 10 | new RTCPeerConnection(config, constraints); 11 | 12 | navigator.getUserMedia({ audio: true, video: true }, 13 | stream => { 14 | peerConnection.addStream(stream); 15 | }, 16 | error => { 17 | console.log('Error message: ' + error.message); 18 | console.log('Error name: ' + error.name); 19 | }); 20 | 21 | peerConnection.onaddstream = ev => console.log(ev.type); 22 | peerConnection.ondatachannel = ev => console.log(ev.type); 23 | peerConnection.oniceconnectionstatechange = ev => console.log(ev.type); 24 | peerConnection.onnegotiationneeded = ev => console.log(ev.type); 25 | peerConnection.onopen = ev => console.log(ev.type); 26 | peerConnection.onicecandidate = ev => console.log(ev.type); 27 | peerConnection.onremovestream = ev => console.log(ev.type); 28 | peerConnection.onstatechange = ev => console.log(ev.type); 29 | 30 | peerConnection.createOffer( 31 | offer => { 32 | peerConnection.setLocalDescription(offer, 33 | () => console.log("set local description"), 34 | error => console.log("Error setting local description: " + error)); 35 | }, 36 | error => console.log("Error creating offer: " + error)); 37 | 38 | var type: string = RTCSdpType[RTCSdpType.offer]; 39 | var offer: RTCSessionDescriptionInit = { type: type, sdp: "some sdp" }; 40 | var sessionDescription = new RTCSessionDescription(offer); 41 | 42 | peerConnection.setRemoteDescription(sessionDescription, () => { 43 | peerConnection.createAnswer( 44 | answer => { 45 | peerConnection.setLocalDescription(answer, 46 | () => console.log('Set local description'), 47 | error => console.log( 48 | "Error setting local description from created answer: " + error + 49 | "; answer.sdp=" + answer.sdp)); 50 | }, 51 | error => console.log("Error creating answer: " + error)); 52 | }, 53 | error => console.log('Error setting remote description: ' + error + 54 | "; offer.sdp=" + offer.sdp)); 55 | 56 | var webkitSessionDescription = new webkitRTCSessionDescription(offer); 57 | 58 | peerConnection.setRemoteDescription(webkitSessionDescription, () => { 59 | peerConnection.createAnswer( 60 | answer => { 61 | peerConnection.setLocalDescription(answer, 62 | () => console.log('Set local description'), 63 | error => console.log( 64 | "Error setting local description from created answer: " + error + 65 | "; answer.sdp=" + answer.sdp)); 66 | }, 67 | error => console.log("Error creating answer: " + error)); 68 | }, 69 | error => console.log('Error setting remote description: ' + error + 70 | "; offer.sdp=" + offer.sdp)); 71 | 72 | var mozSessionDescription = new mozRTCSessionDescription(offer); 73 | 74 | peerConnection.setRemoteDescription(mozSessionDescription, () => { 75 | peerConnection.createAnswer( 76 | answer => { 77 | peerConnection.setLocalDescription(answer, 78 | () => console.log('Set local description'), 79 | error => console.log( 80 | "Error setting local description from created answer: " + error + 81 | "; answer.sdp=" + answer.sdp)); 82 | }, 83 | error => console.log("Error creating answer: " + error)); 84 | }, 85 | error => console.log('Error setting remote description: ' + error + 86 | "; offer.sdp=" + offer.sdp)); 87 | 88 | var wkPeerConnection: webkitRTCPeerConnection = 89 | new webkitRTCPeerConnection(config, constraints); 90 | 91 | -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/RTCPeerConnection-tests.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | var config: RTCConfiguration = 5 | { iceServers: [{ urls: "stun.l.google.com:19302" }] }; 6 | var constraints: RTCMediaConstraints = 7 | { mandatory: { offerToReceiveAudio: true, offerToReceiveVideo: true } }; 8 | 9 | var peerConnection: RTCPeerConnection = 10 | new RTCPeerConnection(config, constraints); 11 | 12 | navigator.getUserMedia({ audio: true, video: true }, 13 | stream => { 14 | peerConnection.addStream(stream); 15 | }, 16 | error => { 17 | console.log('Error message: ' + error.message); 18 | console.log('Error name: ' + error.name); 19 | }); 20 | 21 | peerConnection.onaddstream = ev => console.log(ev.type); 22 | peerConnection.ondatachannel = ev => console.log(ev.type); 23 | peerConnection.oniceconnectionstatechange = ev => console.log(ev.type); 24 | peerConnection.onnegotiationneeded = ev => console.log(ev.type); 25 | peerConnection.onopen = ev => console.log(ev.type); 26 | peerConnection.onicecandidate = ev => console.log(ev.type); 27 | peerConnection.onremovestream = ev => console.log(ev.type); 28 | peerConnection.onstatechange = ev => console.log(ev.type); 29 | 30 | peerConnection.createOffer( 31 | offer => { 32 | peerConnection.setLocalDescription(offer, 33 | () => console.log("set local description"), 34 | error => console.log("Error setting local description: " + error)); 35 | }, 36 | error => console.log("Error creating offer: " + error)); 37 | 38 | var type: string = RTCSdpType[RTCSdpType.offer]; 39 | var offer: RTCSessionDescriptionInit = { type: type, sdp: "some sdp" }; 40 | var sessionDescription = new RTCSessionDescription(offer); 41 | 42 | peerConnection.setRemoteDescription(sessionDescription, () => { 43 | peerConnection.createAnswer( 44 | answer => { 45 | peerConnection.setLocalDescription(answer, 46 | () => console.log('Set local description'), 47 | error => console.log( 48 | "Error setting local description from created answer: " + error + 49 | "; answer.sdp=" + answer.sdp)); 50 | }, 51 | error => console.log("Error creating answer: " + error)); 52 | }, 53 | error => console.log('Error setting remote description: ' + error + 54 | "; offer.sdp=" + offer.sdp)); 55 | 56 | var webkitSessionDescription = new webkitRTCSessionDescription(offer); 57 | 58 | peerConnection.setRemoteDescription(webkitSessionDescription, () => { 59 | peerConnection.createAnswer( 60 | answer => { 61 | peerConnection.setLocalDescription(answer, 62 | () => console.log('Set local description'), 63 | error => console.log( 64 | "Error setting local description from created answer: " + error + 65 | "; answer.sdp=" + answer.sdp)); 66 | }, 67 | error => console.log("Error creating answer: " + error)); 68 | }, 69 | error => console.log('Error setting remote description: ' + error + 70 | "; offer.sdp=" + offer.sdp)); 71 | 72 | var mozSessionDescription = new mozRTCSessionDescription(offer); 73 | 74 | peerConnection.setRemoteDescription(mozSessionDescription, () => { 75 | peerConnection.createAnswer( 76 | answer => { 77 | peerConnection.setLocalDescription(answer, 78 | () => console.log('Set local description'), 79 | error => console.log( 80 | "Error setting local description from created answer: " + error + 81 | "; answer.sdp=" + answer.sdp)); 82 | }, 83 | error => console.log("Error creating answer: " + error)); 84 | }, 85 | error => console.log('Error setting remote description: ' + error + 86 | "; offer.sdp=" + offer.sdp)); 87 | 88 | var wkPeerConnection: webkitRTCPeerConnection = 89 | new webkitRTCPeerConnection(config, constraints); 90 | 91 | -------------------------------------------------------------------------------- /Typings/webrtc/RTCPeerConnection-tests.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | var config = { iceServers: [{ urls: "stun.l.google.com:19302" }] }; 4 | var constraints = { mandatory: { offerToReceiveAudio: true, offerToReceiveVideo: true } }; 5 | var peerConnection = new RTCPeerConnection(config, constraints); 6 | navigator.getUserMedia({ audio: true, video: true }, function (stream) { 7 | peerConnection.addStream(stream); 8 | }, function (error) { 9 | console.log('Error message: ' + error.message); 10 | console.log('Error name: ' + error.name); 11 | }); 12 | peerConnection.onaddstream = function (ev) { return console.log(ev.type); }; 13 | peerConnection.ondatachannel = function (ev) { return console.log(ev.type); }; 14 | peerConnection.oniceconnectionstatechange = function (ev) { return console.log(ev.type); }; 15 | peerConnection.onnegotiationneeded = function (ev) { return console.log(ev.type); }; 16 | peerConnection.onopen = function (ev) { return console.log(ev.type); }; 17 | peerConnection.onicecandidate = function (ev) { return console.log(ev.type); }; 18 | peerConnection.onremovestream = function (ev) { return console.log(ev.type); }; 19 | peerConnection.onstatechange = function (ev) { return console.log(ev.type); }; 20 | peerConnection.createOffer(function (offer) { 21 | peerConnection.setLocalDescription(offer, function () { return console.log("set local description"); }, function (error) { return console.log("Error setting local description: " + error); }); 22 | }, function (error) { return console.log("Error creating offer: " + error); }); 23 | var type = RTCSdpType[RTCSdpType.offer]; 24 | var offer = { type: type, sdp: "some sdp" }; 25 | var sessionDescription = new RTCSessionDescription(offer); 26 | peerConnection.setRemoteDescription(sessionDescription, function () { 27 | peerConnection.createAnswer(function (answer) { 28 | peerConnection.setLocalDescription(answer, function () { return console.log('Set local description'); }, function (error) { return console.log("Error setting local description from created answer: " + error + 29 | "; answer.sdp=" + answer.sdp); }); 30 | }, function (error) { return console.log("Error creating answer: " + error); }); 31 | }, function (error) { return console.log('Error setting remote description: ' + error + 32 | "; offer.sdp=" + offer.sdp); }); 33 | var webkitSessionDescription = new webkitRTCSessionDescription(offer); 34 | peerConnection.setRemoteDescription(webkitSessionDescription, function () { 35 | peerConnection.createAnswer(function (answer) { 36 | peerConnection.setLocalDescription(answer, function () { return console.log('Set local description'); }, function (error) { return console.log("Error setting local description from created answer: " + error + 37 | "; answer.sdp=" + answer.sdp); }); 38 | }, function (error) { return console.log("Error creating answer: " + error); }); 39 | }, function (error) { return console.log('Error setting remote description: ' + error + 40 | "; offer.sdp=" + offer.sdp); }); 41 | var mozSessionDescription = new mozRTCSessionDescription(offer); 42 | peerConnection.setRemoteDescription(mozSessionDescription, function () { 43 | peerConnection.createAnswer(function (answer) { 44 | peerConnection.setLocalDescription(answer, function () { return console.log('Set local description'); }, function (error) { return console.log("Error setting local description from created answer: " + error + 45 | "; answer.sdp=" + answer.sdp); }); 46 | }, function (error) { return console.log("Error creating answer: " + error); }); 47 | }, function (error) { return console.log('Error setting remote description: ' + error + 48 | "; offer.sdp=" + offer.sdp); }); 49 | var wkPeerConnection = new webkitRTCPeerConnection(config, constraints); 50 | //# sourceMappingURL=RTCPeerConnection-tests.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/RTCPeerConnection-tests.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | var config = { iceServers: [{ urls: "stun.l.google.com:19302" }] }; 4 | var constraints = { mandatory: { offerToReceiveAudio: true, offerToReceiveVideo: true } }; 5 | var peerConnection = new RTCPeerConnection(config, constraints); 6 | navigator.getUserMedia({ audio: true, video: true }, function (stream) { 7 | peerConnection.addStream(stream); 8 | }, function (error) { 9 | console.log('Error message: ' + error.message); 10 | console.log('Error name: ' + error.name); 11 | }); 12 | peerConnection.onaddstream = function (ev) { return console.log(ev.type); }; 13 | peerConnection.ondatachannel = function (ev) { return console.log(ev.type); }; 14 | peerConnection.oniceconnectionstatechange = function (ev) { return console.log(ev.type); }; 15 | peerConnection.onnegotiationneeded = function (ev) { return console.log(ev.type); }; 16 | peerConnection.onopen = function (ev) { return console.log(ev.type); }; 17 | peerConnection.onicecandidate = function (ev) { return console.log(ev.type); }; 18 | peerConnection.onremovestream = function (ev) { return console.log(ev.type); }; 19 | peerConnection.onstatechange = function (ev) { return console.log(ev.type); }; 20 | peerConnection.createOffer(function (offer) { 21 | peerConnection.setLocalDescription(offer, function () { return console.log("set local description"); }, function (error) { return console.log("Error setting local description: " + error); }); 22 | }, function (error) { return console.log("Error creating offer: " + error); }); 23 | var type = RTCSdpType[RTCSdpType.offer]; 24 | var offer = { type: type, sdp: "some sdp" }; 25 | var sessionDescription = new RTCSessionDescription(offer); 26 | peerConnection.setRemoteDescription(sessionDescription, function () { 27 | peerConnection.createAnswer(function (answer) { 28 | peerConnection.setLocalDescription(answer, function () { return console.log('Set local description'); }, function (error) { return console.log("Error setting local description from created answer: " + error + 29 | "; answer.sdp=" + answer.sdp); }); 30 | }, function (error) { return console.log("Error creating answer: " + error); }); 31 | }, function (error) { return console.log('Error setting remote description: ' + error + 32 | "; offer.sdp=" + offer.sdp); }); 33 | var webkitSessionDescription = new webkitRTCSessionDescription(offer); 34 | peerConnection.setRemoteDescription(webkitSessionDescription, function () { 35 | peerConnection.createAnswer(function (answer) { 36 | peerConnection.setLocalDescription(answer, function () { return console.log('Set local description'); }, function (error) { return console.log("Error setting local description from created answer: " + error + 37 | "; answer.sdp=" + answer.sdp); }); 38 | }, function (error) { return console.log("Error creating answer: " + error); }); 39 | }, function (error) { return console.log('Error setting remote description: ' + error + 40 | "; offer.sdp=" + offer.sdp); }); 41 | var mozSessionDescription = new mozRTCSessionDescription(offer); 42 | peerConnection.setRemoteDescription(mozSessionDescription, function () { 43 | peerConnection.createAnswer(function (answer) { 44 | peerConnection.setLocalDescription(answer, function () { return console.log('Set local description'); }, function (error) { return console.log("Error setting local description from created answer: " + error + 45 | "; answer.sdp=" + answer.sdp); }); 46 | }, function (error) { return console.log("Error creating answer: " + error); }); 47 | }, function (error) { return console.log('Error setting remote description: ' + error + 48 | "; offer.sdp=" + offer.sdp); }); 49 | var wkPeerConnection = new webkitRTCPeerConnection(config, constraints); 50 | //# sourceMappingURL=RTCPeerConnection-tests.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/bookmark.component.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/core'], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 5 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 6 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 7 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 8 | return c > 3 && r && Object.defineProperty(target, key, r), r; 9 | }; 10 | var __metadata = (this && this.__metadata) || function (k, v) { 11 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 12 | }; 13 | var core_1, core_2, core_3; 14 | var BookmarkComponent; 15 | return { 16 | setters:[ 17 | function (core_1_1) { 18 | core_1 = core_1_1; 19 | core_2 = core_1_1; 20 | core_3 = core_1_1; 21 | }], 22 | execute: function() { 23 | // A component decorator tells Angular that the "BookmarkComponent" class 24 | // is a component and adds its meta data: the selector and the template. 25 | // Additionally we have to declare an input property, 26 | // because we want to use "[bookmark]" in the list template 27 | // as a data binding target. 28 | BookmarkComponent = (function () { 29 | function BookmarkComponent() { 30 | // Setting the default value for the "submitted" property. 31 | this.submitted = false; 32 | // Events flow outside the component and therefor need an output property. 33 | this.bookmarkChanged = new core_3.EventEmitter(); 34 | this.bookmarkDeleted = new core_3.EventEmitter(); 35 | } 36 | // Whenever a user clicks on "Done" after editing a bookmark, 37 | // an event is fired, which indicates that the bookmark was changed. 38 | // To hide the form, the submitted property is set to false again. 39 | BookmarkComponent.prototype.onSubmit = function (bookmark) { 40 | this.submitted = false; 41 | this.bookmarkChanged.emit(bookmark); 42 | }; 43 | // When the "Delete" button was pressed, the event "bookmarkDeleted" will be fired. 44 | BookmarkComponent.prototype.onDelete = function (bookmark) { 45 | this.bookmarkDeleted.emit(bookmark); 46 | }; 47 | __decorate([ 48 | core_2.Output(), 49 | __metadata('design:type', core_3.EventEmitter) 50 | ], BookmarkComponent.prototype, "bookmarkChanged", void 0); 51 | __decorate([ 52 | core_2.Output(), 53 | __metadata('design:type', core_3.EventEmitter) 54 | ], BookmarkComponent.prototype, "bookmarkDeleted", void 0); 55 | BookmarkComponent = __decorate([ 56 | core_1.Component({ 57 | selector: 'sp-bookmark', 58 | templateUrl: './templates/bookmark.html', 59 | inputs: ['bookmark'] 60 | }), 61 | __metadata('design:paramtypes', []) 62 | ], BookmarkComponent); 63 | return BookmarkComponent; 64 | }()); 65 | exports_1("BookmarkComponent", BookmarkComponent); 66 | } 67 | } 68 | }); 69 | //# sourceMappingURL=bookmark.component.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/list.component.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/core', './bookmark.component', './list.service', './eventPage'], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 5 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 6 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 7 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 8 | return c > 3 && r && Object.defineProperty(target, key, r), r; 9 | }; 10 | var __metadata = (this && this.__metadata) || function (k, v) { 11 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 12 | }; 13 | var core_1, bookmark_component_1, list_service_1, eventPage_1; 14 | var ListComponent; 15 | return { 16 | setters:[ 17 | function (core_1_1) { 18 | core_1 = core_1_1; 19 | }, 20 | function (bookmark_component_1_1) { 21 | bookmark_component_1 = bookmark_component_1_1; 22 | }, 23 | function (list_service_1_1) { 24 | list_service_1 = list_service_1_1; 25 | }, 26 | function (eventPage_1_1) { 27 | eventPage_1 = eventPage_1_1; 28 | }], 29 | execute: function() { 30 | // The ListComponent meta data defines the component's selector, 31 | // the url of the template and the directives used in this template. 32 | // The provider meta data reference the ListService we're using to get the data. 33 | ListComponent = (function () { 34 | function ListComponent(listService, eventPage) { 35 | this.listService = listService; 36 | this.eventPage = eventPage; 37 | } 38 | // The function "getBookmarkLists" demands the bookmarks asynchronously. 39 | // When the promise is resolved, the callback function assignes 40 | // the bookmarks to the component's bookmarks property. 41 | ListComponent.prototype.getBookmarkLists = function () { 42 | var _this = this; 43 | this.listService.getBookmarks().then(function (bookmarks) { return _this.bookmarks = bookmarks; }); 44 | }; 45 | // The "ngOnInit" function gets called, when the component gets activated. 46 | ListComponent.prototype.ngOnInit = function () { 47 | this.getBookmarkLists(); 48 | }; 49 | // setList uses the "ListService" to save the complete list. 50 | ListComponent.prototype.setList = function () { 51 | this.listService.setBookmarks(this.bookmarks); 52 | }; 53 | // The function deletes the bookmark and saves the complete list. 54 | ListComponent.prototype.deleteBookmark = function (bookmark, i) { 55 | this.bookmarks.splice(i, 1); 56 | this.setList(); 57 | }; 58 | ListComponent = __decorate([ 59 | core_1.Component({ 60 | selector: 'sp-list', 61 | templateUrl: './templates/list.html', 62 | directives: [bookmark_component_1.BookmarkComponent], 63 | providers: [list_service_1.ListService, eventPage_1.EventPage] 64 | }), 65 | __metadata('design:paramtypes', [list_service_1.ListService, eventPage_1.EventPage]) 66 | ], ListComponent); 67 | return ListComponent; 68 | }()); 69 | exports_1("ListComponent", ListComponent); 70 | } 71 | } 72 | }); 73 | //# sourceMappingURL=list.component.js.map -------------------------------------------------------------------------------- /Project_Files/scripts/eventPage.js: -------------------------------------------------------------------------------- 1 | /// 2 | System.register(['angular2/core', './list.service'], function(exports_1, context_1) { 3 | "use strict"; 4 | var __moduleName = context_1 && context_1.id; 5 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 6 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 7 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 8 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 9 | return c > 3 && r && Object.defineProperty(target, key, r), r; 10 | }; 11 | var __metadata = (this && this.__metadata) || function (k, v) { 12 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 13 | }; 14 | var core_1, list_service_1; 15 | var EventPage; 16 | return { 17 | setters:[ 18 | function (core_1_1) { 19 | core_1 = core_1_1; 20 | }, 21 | function (list_service_1_1) { 22 | list_service_1 = list_service_1_1; 23 | }], 24 | execute: function() { 25 | EventPage = (function () { 26 | // The event listener should be set when the "EventPage" class is initialized. 27 | // Therefore we're using the constructor for adding it to the "Chrome.browserAction". 28 | // To set and get the bookmark lists, we're using the "ListService". 29 | function EventPage(listService) { 30 | this.listService = listService; 31 | var bookmarkLists; 32 | // The "Chrome.browserAction" object throws an error, 33 | // when it is not available in development mode. 34 | // This is why we're only logging a message, 35 | // if it is undefined. 36 | if (typeof chrome.browserAction !== 'undefined') { 37 | // The Chrome "browserAction" is responsible for the icon in the Chrome toolbar. 38 | // Its "onClicked" function gets fired, when the icon was clicked. 39 | // This is when we're get the latest list of bookmarks from the "ListService" 40 | // and call the function "getSelectedTab" after the promise is resolved. 41 | chrome.browserAction.onClicked.addListener(function (tab) { 42 | listService.getBookmarks().then(function (bookmarkLists) { 43 | bookmarkLists = bookmarkLists; 44 | getSelectedTab(bookmarkLists); 45 | }); 46 | }); 47 | } 48 | else { 49 | console.log('EventPage initialized'); 50 | } 51 | // The Chrome tabs API gives us access to the current tab 52 | // and its title and url, 53 | // which we're using to add a new bookmark 54 | // and save the list of bookmarks again with the "ListService". 55 | function getSelectedTab(bookmarkLists) { 56 | chrome.tabs.getSelected(null, function (tab) { 57 | var newBookmark = { 58 | name: tab.title, 59 | url: tab.url 60 | }; 61 | bookmarkLists.push(newBookmark); 62 | listService.setBookmarks(bookmarkLists); 63 | }); 64 | } 65 | } 66 | EventPage = __decorate([ 67 | core_1.Injectable(), 68 | __metadata('design:paramtypes', [list_service_1.ListService]) 69 | ], EventPage); 70 | return EventPage; 71 | }()); 72 | exports_1("EventPage", EventPage); 73 | } 74 | } 75 | }); 76 | //# sourceMappingURL=eventPage.js.map -------------------------------------------------------------------------------- /Typings/webrtc/MediaStream.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for WebRTC 2 | // Project: http://dev.w3.org/2011/webrtc/ 3 | // Definitions by: Ken Smith 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | // Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html 7 | // version: W3C Editor's Draft 29 June 2015 8 | 9 | interface ConstrainBooleanParameters { 10 | exact?: boolean; 11 | ideal?: boolean; 12 | } 13 | 14 | interface NumberRange { 15 | max?: number; 16 | min?: number; 17 | } 18 | 19 | interface ConstrainNumberRange extends NumberRange { 20 | exact?: number; 21 | ideal?: number; 22 | } 23 | 24 | interface ConstrainStringParameters { 25 | exact?: string | string[]; 26 | ideal?: string | string[]; 27 | } 28 | 29 | interface MediaStreamConstraints { 30 | video?: boolean | MediaTrackConstraints; 31 | audio?: boolean | MediaTrackConstraints; 32 | } 33 | 34 | declare module W3C { 35 | type LongRange = NumberRange; 36 | type DoubleRange = NumberRange; 37 | type ConstrainBoolean = boolean | ConstrainBooleanParameters; 38 | type ConstrainNumber = number | ConstrainNumberRange; 39 | type ConstrainLong = ConstrainNumber; 40 | type ConstrainDouble = ConstrainNumber; 41 | type ConstrainString = string | string[] | ConstrainStringParameters; 42 | } 43 | 44 | interface MediaTrackConstraints extends MediaTrackConstraintSet { 45 | advanced?: MediaTrackConstraintSet[]; 46 | } 47 | 48 | interface MediaTrackConstraintSet { 49 | width?: W3C.ConstrainLong; 50 | height?: W3C.ConstrainLong; 51 | aspectRatio?: W3C.ConstrainDouble; 52 | frameRate?: W3C.ConstrainDouble; 53 | facingMode?: W3C.ConstrainString; 54 | volume?: W3C.ConstrainDouble; 55 | sampleRate?: W3C.ConstrainLong; 56 | sampleSize?: W3C.ConstrainLong; 57 | echoCancellation?: W3C.ConstrainBoolean; 58 | latency?: W3C.ConstrainDouble; 59 | deviceId?: W3C.ConstrainString; 60 | groupId?: W3C.ConstrainString; 61 | } 62 | 63 | interface MediaTrackSupportedConstraints { 64 | width?: boolean; 65 | height?: boolean; 66 | aspectRatio?: boolean; 67 | frameRate?: boolean; 68 | facingMode?: boolean; 69 | volume?: boolean; 70 | sampleRate?: boolean; 71 | sampleSize?: boolean; 72 | echoCancellation?: boolean; 73 | latency?: boolean; 74 | deviceId?: boolean; 75 | groupId?: boolean; 76 | } 77 | 78 | interface MediaStream extends EventTarget { 79 | id: string; 80 | active: boolean; 81 | 82 | onactive: EventListener; 83 | oninactive: EventListener; 84 | onaddtrack: (event: MediaStreamTrackEvent) => any; 85 | onremovetrack: (event: MediaStreamTrackEvent) => any; 86 | 87 | clone(): MediaStream; 88 | stop(): void; 89 | 90 | getAudioTracks(): MediaStreamTrack[]; 91 | getVideoTracks(): MediaStreamTrack[]; 92 | getTracks(): MediaStreamTrack[]; 93 | 94 | getTrackById(trackId: string): MediaStreamTrack; 95 | 96 | addTrack(track: MediaStreamTrack): void; 97 | removeTrack(track: MediaStreamTrack): void; 98 | } 99 | 100 | interface MediaStreamTrackEvent extends Event { 101 | track: MediaStreamTrack; 102 | } 103 | 104 | declare enum MediaStreamTrackState { 105 | "live", 106 | "ended" 107 | } 108 | 109 | interface MediaStreamTrack extends EventTarget { 110 | id: string; 111 | kind: string; 112 | label: string; 113 | enabled: boolean; 114 | muted: boolean; 115 | remote: boolean; 116 | readyState: MediaStreamTrackState; 117 | 118 | onmute: EventListener; 119 | onunmute: EventListener; 120 | onended: EventListener; 121 | onoverconstrained: EventListener; 122 | 123 | clone(): MediaStreamTrack; 124 | 125 | stop(): void; 126 | 127 | getCapabilities(): MediaTrackCapabilities; 128 | getConstraints(): MediaTrackConstraints; 129 | getSettings(): MediaTrackSettings; 130 | applyConstraints(constraints: MediaTrackConstraints): Promise; 131 | } 132 | 133 | interface MediaTrackCapabilities { 134 | width: number | W3C.LongRange; 135 | height: number | W3C.LongRange; 136 | aspectRatio: number | W3C.DoubleRange; 137 | frameRate: number | W3C.DoubleRange; 138 | facingMode: string; 139 | volume: number | W3C.DoubleRange; 140 | sampleRate: number | W3C.LongRange; 141 | sampleSize: number | W3C.LongRange; 142 | echoCancellation: boolean[]; 143 | latency: number | W3C.DoubleRange; 144 | deviceId: string; 145 | groupId: string; 146 | } 147 | 148 | interface MediaTrackSettings { 149 | width: number; 150 | height: number; 151 | aspectRatio: number; 152 | frameRate: number; 153 | facingMode: string; 154 | volume: number; 155 | sampleRate: number; 156 | sampleSize: number; 157 | echoCancellation: boolean; 158 | latency: number; 159 | deviceId: string; 160 | groupId: string; 161 | } 162 | 163 | interface MediaStreamError { 164 | name: string; 165 | message: string; 166 | constraintName: string; 167 | } 168 | 169 | interface NavigatorGetUserMedia { 170 | (constraints: MediaStreamConstraints, 171 | successCallback: (stream: MediaStream) => void, 172 | errorCallback: (error: MediaStreamError) => void): void; 173 | } 174 | 175 | // to use with adapter.js, see: https://github.com/webrtc/adapter 176 | declare var getUserMedia: NavigatorGetUserMedia; 177 | 178 | interface Navigator { 179 | getUserMedia: NavigatorGetUserMedia; 180 | 181 | webkitGetUserMedia: NavigatorGetUserMedia; 182 | 183 | mozGetUserMedia: NavigatorGetUserMedia; 184 | 185 | msGetUserMedia: NavigatorGetUserMedia; 186 | 187 | mediaDevices: MediaDevices; 188 | } 189 | 190 | interface MediaDevices { 191 | getSupportedConstraints(): MediaTrackSupportedConstraints; 192 | 193 | getUserMedia(constraints: MediaStreamConstraints): Promise; 194 | enumerateDevices(): Promise; 195 | } 196 | 197 | interface MediaDeviceInfo { 198 | label: string; 199 | deviceId: string; 200 | kind: string; 201 | groupId: string; 202 | } 203 | -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/MediaStream.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for WebRTC 2 | // Project: http://dev.w3.org/2011/webrtc/ 3 | // Definitions by: Ken Smith 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | // Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html 7 | // version: W3C Editor's Draft 29 June 2015 8 | 9 | interface ConstrainBooleanParameters { 10 | exact?: boolean; 11 | ideal?: boolean; 12 | } 13 | 14 | interface NumberRange { 15 | max?: number; 16 | min?: number; 17 | } 18 | 19 | interface ConstrainNumberRange extends NumberRange { 20 | exact?: number; 21 | ideal?: number; 22 | } 23 | 24 | interface ConstrainStringParameters { 25 | exact?: string | string[]; 26 | ideal?: string | string[]; 27 | } 28 | 29 | interface MediaStreamConstraints { 30 | video?: boolean | MediaTrackConstraints; 31 | audio?: boolean | MediaTrackConstraints; 32 | } 33 | 34 | declare module W3C { 35 | type LongRange = NumberRange; 36 | type DoubleRange = NumberRange; 37 | type ConstrainBoolean = boolean | ConstrainBooleanParameters; 38 | type ConstrainNumber = number | ConstrainNumberRange; 39 | type ConstrainLong = ConstrainNumber; 40 | type ConstrainDouble = ConstrainNumber; 41 | type ConstrainString = string | string[] | ConstrainStringParameters; 42 | } 43 | 44 | interface MediaTrackConstraints extends MediaTrackConstraintSet { 45 | advanced?: MediaTrackConstraintSet[]; 46 | } 47 | 48 | interface MediaTrackConstraintSet { 49 | width?: W3C.ConstrainLong; 50 | height?: W3C.ConstrainLong; 51 | aspectRatio?: W3C.ConstrainDouble; 52 | frameRate?: W3C.ConstrainDouble; 53 | facingMode?: W3C.ConstrainString; 54 | volume?: W3C.ConstrainDouble; 55 | sampleRate?: W3C.ConstrainLong; 56 | sampleSize?: W3C.ConstrainLong; 57 | echoCancellation?: W3C.ConstrainBoolean; 58 | latency?: W3C.ConstrainDouble; 59 | deviceId?: W3C.ConstrainString; 60 | groupId?: W3C.ConstrainString; 61 | } 62 | 63 | interface MediaTrackSupportedConstraints { 64 | width?: boolean; 65 | height?: boolean; 66 | aspectRatio?: boolean; 67 | frameRate?: boolean; 68 | facingMode?: boolean; 69 | volume?: boolean; 70 | sampleRate?: boolean; 71 | sampleSize?: boolean; 72 | echoCancellation?: boolean; 73 | latency?: boolean; 74 | deviceId?: boolean; 75 | groupId?: boolean; 76 | } 77 | 78 | interface MediaStream extends EventTarget { 79 | id: string; 80 | active: boolean; 81 | 82 | onactive: EventListener; 83 | oninactive: EventListener; 84 | onaddtrack: (event: MediaStreamTrackEvent) => any; 85 | onremovetrack: (event: MediaStreamTrackEvent) => any; 86 | 87 | clone(): MediaStream; 88 | stop(): void; 89 | 90 | getAudioTracks(): MediaStreamTrack[]; 91 | getVideoTracks(): MediaStreamTrack[]; 92 | getTracks(): MediaStreamTrack[]; 93 | 94 | getTrackById(trackId: string): MediaStreamTrack; 95 | 96 | addTrack(track: MediaStreamTrack): void; 97 | removeTrack(track: MediaStreamTrack): void; 98 | } 99 | 100 | interface MediaStreamTrackEvent extends Event { 101 | track: MediaStreamTrack; 102 | } 103 | 104 | declare enum MediaStreamTrackState { 105 | "live", 106 | "ended" 107 | } 108 | 109 | interface MediaStreamTrack extends EventTarget { 110 | id: string; 111 | kind: string; 112 | label: string; 113 | enabled: boolean; 114 | muted: boolean; 115 | remote: boolean; 116 | readyState: MediaStreamTrackState; 117 | 118 | onmute: EventListener; 119 | onunmute: EventListener; 120 | onended: EventListener; 121 | onoverconstrained: EventListener; 122 | 123 | clone(): MediaStreamTrack; 124 | 125 | stop(): void; 126 | 127 | getCapabilities(): MediaTrackCapabilities; 128 | getConstraints(): MediaTrackConstraints; 129 | getSettings(): MediaTrackSettings; 130 | applyConstraints(constraints: MediaTrackConstraints): Promise; 131 | } 132 | 133 | interface MediaTrackCapabilities { 134 | width: number | W3C.LongRange; 135 | height: number | W3C.LongRange; 136 | aspectRatio: number | W3C.DoubleRange; 137 | frameRate: number | W3C.DoubleRange; 138 | facingMode: string; 139 | volume: number | W3C.DoubleRange; 140 | sampleRate: number | W3C.LongRange; 141 | sampleSize: number | W3C.LongRange; 142 | echoCancellation: boolean[]; 143 | latency: number | W3C.DoubleRange; 144 | deviceId: string; 145 | groupId: string; 146 | } 147 | 148 | interface MediaTrackSettings { 149 | width: number; 150 | height: number; 151 | aspectRatio: number; 152 | frameRate: number; 153 | facingMode: string; 154 | volume: number; 155 | sampleRate: number; 156 | sampleSize: number; 157 | echoCancellation: boolean; 158 | latency: number; 159 | deviceId: string; 160 | groupId: string; 161 | } 162 | 163 | interface MediaStreamError { 164 | name: string; 165 | message: string; 166 | constraintName: string; 167 | } 168 | 169 | interface NavigatorGetUserMedia { 170 | (constraints: MediaStreamConstraints, 171 | successCallback: (stream: MediaStream) => void, 172 | errorCallback: (error: MediaStreamError) => void): void; 173 | } 174 | 175 | // to use with adapter.js, see: https://github.com/webrtc/adapter 176 | declare var getUserMedia: NavigatorGetUserMedia; 177 | 178 | interface Navigator { 179 | getUserMedia: NavigatorGetUserMedia; 180 | 181 | webkitGetUserMedia: NavigatorGetUserMedia; 182 | 183 | mozGetUserMedia: NavigatorGetUserMedia; 184 | 185 | msGetUserMedia: NavigatorGetUserMedia; 186 | 187 | mediaDevices: MediaDevices; 188 | } 189 | 190 | interface MediaDevices { 191 | getSupportedConstraints(): MediaTrackSupportedConstraints; 192 | 193 | getUserMedia(constraints: MediaStreamConstraints): Promise; 194 | enumerateDevices(): Promise; 195 | } 196 | 197 | interface MediaDeviceInfo { 198 | label: string; 199 | deviceId: string; 200 | kind: string; 201 | groupId: string; 202 | } 203 | -------------------------------------------------------------------------------- /Typings/filewriter/filewriter.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for File API: Writer 2 | // Project: http://www.w3.org/TR/file-writer-api/ 3 | // Definitions by: Kon 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /** 7 | * This interface provides methods to monitor the asynchronous writing of blobs to disk using progress events [PROGRESS-EVENTS] and event handler attributes. 8 | * This interface is specified to be used within the context of the global object (Window [HTML5]) and within Web Workers (WorkerUtils [WEBWORKERS-ED]). 9 | */ 10 | interface FileSaver extends EventTarget { 11 | /** 12 | * When the abort method is called, user agents must run the steps below: 13 | *
    14 | *
  1. If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything else.
  2. 15 | *
  3. Set readyState to DONE.
  4. 16 | *
  5. If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those tasks.
  6. 17 | *
  7. Terminate the write algorithm being processed.
  8. 18 | *
  9. Set the error attribute to a DOMError object of type "AbortError".
  10. 19 | *
  11. Fire a progress event called abort
  12. 20 | *
  13. Fire a progress event called writeend
  14. 21 | *
  15. Terminate this algorithm.
  16. 22 | *
23 | */ 24 | abort():void; 25 | 26 | /** 27 | * The blob is being written. 28 | * @readonly 29 | */ 30 | INIT:number; 31 | 32 | /** 33 | * The object has been constructed, but there is no pending write. 34 | * @readonly 35 | */ 36 | WRITING:number; 37 | 38 | /** 39 | * The entire Blob has been written to the file, an error occurred during the write, or the write was aborted using abort(). The FileSaver is no longer writing the blob. 40 | * @readonly 41 | */ 42 | DONE:number; 43 | 44 | /** 45 | * The FileSaver object can be in one of 3 states. The readyState attribute, on getting, must return the current state, which must be one of the following values: 46 | *
    47 | *
  • INIT
  • 48 | *
  • WRITING
  • 49 | *
  • DONE
  • 50 | *
      51 | * @readonly 52 | */ 53 | readyState:number; 54 | 55 | /** 56 | * The last error that occurred on the FileSaver. 57 | * @readonly 58 | */ 59 | error:DOMError; 60 | 61 | /** 62 | * Handler for writestart events 63 | */ 64 | onwritestart:Function; 65 | 66 | /** 67 | * Handler for progress events. 68 | */ 69 | onprogress:Function; 70 | 71 | /** 72 | * Handler for write events. 73 | */ 74 | onwrite:Function; 75 | 76 | /** 77 | * Handler for abort events. 78 | */ 79 | onabort:Function; 80 | 81 | /** 82 | * Handler for error events. 83 | */ 84 | onerror:Function; 85 | 86 | /** 87 | * Handler for writeend events. 88 | */ 89 | onwriteend:Function; 90 | } 91 | 92 | declare var FileSaver: { 93 | /** 94 | * When the FileSaver constructor is called, the user agent must return a new FileSaver object with readyState set to INIT. 95 | * This constructor must be visible when the script's global object is either a Window object or an object implementing the WorkerUtils interface. 96 | */ 97 | new(data:Blob): FileSaver; 98 | } 99 | 100 | /** 101 | * This interface expands on the FileSaver interface to allow for multiple write actions, rather than just saving a single Blob. 102 | */ 103 | interface FileWriter extends FileSaver { 104 | /** 105 | * The byte offset at which the next write to the file will occur. This must be no greater than length. 106 | * A newly-created FileWriter must have position set to 0. 107 | */ 108 | position:number; 109 | 110 | /** 111 | * The length of the file. If the user does not have read access to the file, this must be the highest byte offset at which the user has written. 112 | */ 113 | length:number; 114 | 115 | /** 116 | * Write the supplied data to the file at position. 117 | * @param data The blob to write. 118 | */ 119 | write(data:Blob):void; 120 | 121 | /** 122 | * Seek sets the file position at which the next write will occur. 123 | * @param offset If nonnegative, an absolute byte offset into the file. If negative, an offset back from the end of the file. 124 | */ 125 | seek(offset:number):void; 126 | 127 | /** 128 | * Changes the length of the file to that specified. If shortening the file, data beyond the new length must be discarded. If extending the file, the existing data must be zero-padded up to the new length. 129 | * @param size The size to which the length of the file is to be adjusted, measured in bytes. 130 | */ 131 | truncate(size:number):void; 132 | } 133 | 134 | /** 135 | * This interface lets users write, truncate, and append to files using simple synchronous calls. 136 | * This interface is specified to be used only within Web Workers (WorkerUtils [WEBWORKERS]). 137 | */ 138 | interface FileWriterSync { 139 | /** 140 | * The byte offset at which the next write to the file will occur. This must be no greater than length. 141 | */ 142 | position:number; 143 | 144 | /** 145 | * The length of the file. If the user does not have read access to the file, this must be the highest byte offset at which the user has written. 146 | */ 147 | length:number; 148 | 149 | /** 150 | * Write the supplied data to the file at position. Upon completion, position will increase by data.size. 151 | * @param data The blob to write. 152 | */ 153 | write(data:Blob):void; 154 | 155 | /** 156 | * Seek sets the file position at which the next write will occur. 157 | * @param offset An absolute byte offset into the file. If offset is greater than length, length is used instead. If offset is less than zero, length is added to it, so that it is treated as an offset back from the end of the file. If it is still less than zero, zero is used. 158 | */ 159 | seek(offset:number):void; 160 | 161 | /** 162 | * Changes the length of the file to that specified. If shortening the file, data beyond the new length must be discarded. If extending the file, the existing data must be zero-padded up to the new length. 163 | * Upon successful completion: 164 | *
        165 | *
      • length must be equal to size.
      • 166 | *
      • position must be the lesser of 167 | *
          168 | *
        • its pre-truncate value,
        • 169 | *
        • size.
        • 170 | *
        171 | *
      • 172 | *
      173 | * @param size The size to which the length of the file is to be adjusted, measured in bytes. 174 | */ 175 | truncate(size:number):void; 176 | } 177 | -------------------------------------------------------------------------------- /Project_Files/scripts/filewriter/filewriter.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for File API: Writer 2 | // Project: http://www.w3.org/TR/file-writer-api/ 3 | // Definitions by: Kon 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /** 7 | * This interface provides methods to monitor the asynchronous writing of blobs to disk using progress events [PROGRESS-EVENTS] and event handler attributes. 8 | * This interface is specified to be used within the context of the global object (Window [HTML5]) and within Web Workers (WorkerUtils [WEBWORKERS-ED]). 9 | */ 10 | interface FileSaver extends EventTarget { 11 | /** 12 | * When the abort method is called, user agents must run the steps below: 13 | *
        14 | *
      1. If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything else.
      2. 15 | *
      3. Set readyState to DONE.
      4. 16 | *
      5. If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those tasks.
      6. 17 | *
      7. Terminate the write algorithm being processed.
      8. 18 | *
      9. Set the error attribute to a DOMError object of type "AbortError".
      10. 19 | *
      11. Fire a progress event called abort
      12. 20 | *
      13. Fire a progress event called writeend
      14. 21 | *
      15. Terminate this algorithm.
      16. 22 | *
      23 | */ 24 | abort():void; 25 | 26 | /** 27 | * The blob is being written. 28 | * @readonly 29 | */ 30 | INIT:number; 31 | 32 | /** 33 | * The object has been constructed, but there is no pending write. 34 | * @readonly 35 | */ 36 | WRITING:number; 37 | 38 | /** 39 | * The entire Blob has been written to the file, an error occurred during the write, or the write was aborted using abort(). The FileSaver is no longer writing the blob. 40 | * @readonly 41 | */ 42 | DONE:number; 43 | 44 | /** 45 | * The FileSaver object can be in one of 3 states. The readyState attribute, on getting, must return the current state, which must be one of the following values: 46 | *
        47 | *
      • INIT
      • 48 | *
      • WRITING
      • 49 | *
      • DONE
      • 50 | *
          51 | * @readonly 52 | */ 53 | readyState:number; 54 | 55 | /** 56 | * The last error that occurred on the FileSaver. 57 | * @readonly 58 | */ 59 | error:DOMError; 60 | 61 | /** 62 | * Handler for writestart events 63 | */ 64 | onwritestart:Function; 65 | 66 | /** 67 | * Handler for progress events. 68 | */ 69 | onprogress:Function; 70 | 71 | /** 72 | * Handler for write events. 73 | */ 74 | onwrite:Function; 75 | 76 | /** 77 | * Handler for abort events. 78 | */ 79 | onabort:Function; 80 | 81 | /** 82 | * Handler for error events. 83 | */ 84 | onerror:Function; 85 | 86 | /** 87 | * Handler for writeend events. 88 | */ 89 | onwriteend:Function; 90 | } 91 | 92 | declare var FileSaver: { 93 | /** 94 | * When the FileSaver constructor is called, the user agent must return a new FileSaver object with readyState set to INIT. 95 | * This constructor must be visible when the script's global object is either a Window object or an object implementing the WorkerUtils interface. 96 | */ 97 | new(data:Blob): FileSaver; 98 | } 99 | 100 | /** 101 | * This interface expands on the FileSaver interface to allow for multiple write actions, rather than just saving a single Blob. 102 | */ 103 | interface FileWriter extends FileSaver { 104 | /** 105 | * The byte offset at which the next write to the file will occur. This must be no greater than length. 106 | * A newly-created FileWriter must have position set to 0. 107 | */ 108 | position:number; 109 | 110 | /** 111 | * The length of the file. If the user does not have read access to the file, this must be the highest byte offset at which the user has written. 112 | */ 113 | length:number; 114 | 115 | /** 116 | * Write the supplied data to the file at position. 117 | * @param data The blob to write. 118 | */ 119 | write(data:Blob):void; 120 | 121 | /** 122 | * Seek sets the file position at which the next write will occur. 123 | * @param offset If nonnegative, an absolute byte offset into the file. If negative, an offset back from the end of the file. 124 | */ 125 | seek(offset:number):void; 126 | 127 | /** 128 | * Changes the length of the file to that specified. If shortening the file, data beyond the new length must be discarded. If extending the file, the existing data must be zero-padded up to the new length. 129 | * @param size The size to which the length of the file is to be adjusted, measured in bytes. 130 | */ 131 | truncate(size:number):void; 132 | } 133 | 134 | /** 135 | * This interface lets users write, truncate, and append to files using simple synchronous calls. 136 | * This interface is specified to be used only within Web Workers (WorkerUtils [WEBWORKERS]). 137 | */ 138 | interface FileWriterSync { 139 | /** 140 | * The byte offset at which the next write to the file will occur. This must be no greater than length. 141 | */ 142 | position:number; 143 | 144 | /** 145 | * The length of the file. If the user does not have read access to the file, this must be the highest byte offset at which the user has written. 146 | */ 147 | length:number; 148 | 149 | /** 150 | * Write the supplied data to the file at position. Upon completion, position will increase by data.size. 151 | * @param data The blob to write. 152 | */ 153 | write(data:Blob):void; 154 | 155 | /** 156 | * Seek sets the file position at which the next write will occur. 157 | * @param offset An absolute byte offset into the file. If offset is greater than length, length is used instead. If offset is less than zero, length is added to it, so that it is treated as an offset back from the end of the file. If it is still less than zero, zero is used. 158 | */ 159 | seek(offset:number):void; 160 | 161 | /** 162 | * Changes the length of the file to that specified. If shortening the file, data beyond the new length must be discarded. If extending the file, the existing data must be zero-padded up to the new length. 163 | * Upon successful completion: 164 | *
            165 | *
          • length must be equal to size.
          • 166 | *
          • position must be the lesser of 167 | *
              168 | *
            • its pre-truncate value,
            • 169 | *
            • size.
            • 170 | *
            171 | *
          • 172 | *
          173 | * @param size The size to which the length of the file is to be adjusted, measured in bytes. 174 | */ 175 | truncate(size:number):void; 176 | } 177 | -------------------------------------------------------------------------------- /Typings/webrtc/RTCPeerConnection.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for WebRTC 2 | // Project: http://dev.w3.org/2011/webrtc/ 3 | // Definitions by: Ken Smith 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | // 6 | // Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html 7 | // 8 | // For example code see: 9 | // https://code.google.com/p/webrtc/source/browse/stable/samples/js/apprtc/js/main.js 10 | // 11 | // For a generic implementation see that deals with browser differences, see: 12 | // https://code.google.com/p/webrtc/source/browse/stable/samples/js/base/adapter.js 13 | 14 | /// 15 | 16 | // TODO(1): Get Typescript to have string-enum types as WebRtc is full of string 17 | // enums. 18 | // https://typescript.codeplex.com/discussions/549207 19 | 20 | // TODO(2): get Typescript to have union types as WebRtc uses them. 21 | // https://typescript.codeplex.com/workitem/1364 22 | 23 | interface RTCConfiguration { 24 | iceServers: RTCIceServer[]; 25 | } 26 | declare var RTCConfiguration: { 27 | prototype: RTCConfiguration; 28 | new (): RTCConfiguration; 29 | }; 30 | 31 | interface RTCIceServer { 32 | urls: string; 33 | credential?: string; 34 | } 35 | declare var RTCIceServer: { 36 | prototype: RTCIceServer; 37 | new (): RTCIceServer; 38 | }; 39 | 40 | // moz (Firefox) specific prefixes. 41 | interface mozRTCPeerConnection extends RTCPeerConnection { 42 | } 43 | declare var mozRTCPeerConnection: { 44 | prototype: mozRTCPeerConnection; 45 | new (settings: RTCPeerConnectionConfig, 46 | constraints?:RTCMediaConstraints): mozRTCPeerConnection; 47 | }; 48 | // webkit (Chrome) specific prefixes. 49 | interface webkitRTCPeerConnection extends RTCPeerConnection { 50 | } 51 | declare var webkitRTCPeerConnection: { 52 | prototype: webkitRTCPeerConnection; 53 | new (settings: RTCPeerConnectionConfig, 54 | constraints?:RTCMediaConstraints): webkitRTCPeerConnection; 55 | }; 56 | 57 | // For Chrome, look at the code here: 58 | // https://code.google.com/p/chromium/codesearch#chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsession.cc&sq=package:chromium&dr=C&l=63 59 | interface RTCOptionalMediaConstraint { 60 | // When true, will use DTLS/SCTP data channels 61 | DtlsSrtpKeyAgreement?: boolean; 62 | // When true will use Rtp-based data channels (depreicated) 63 | RtpDataChannels?: boolean; 64 | } 65 | 66 | // ks 12/20/12 - There's more here that doesn't seem to be documented very well yet. 67 | // http://www.w3.org/TR/2013/WD-webrtc-20130910/ 68 | interface RTCMediaConstraints { 69 | mandatory?: RTCMediaOfferConstraints; 70 | optional?: RTCOptionalMediaConstraint[] 71 | } 72 | 73 | interface RTCMediaOfferConstraints { 74 | offerToReceiveAudio: boolean; 75 | offerToReceiveVideo: boolean; 76 | } 77 | 78 | interface RTCSessionDescriptionInit { 79 | type: string; // RTCSdpType; See TODO(1) 80 | sdp: string; 81 | } 82 | 83 | interface RTCSessionDescription { 84 | type?: string; // RTCSdpType; See TODO(1) 85 | sdp?: string; 86 | } 87 | declare var RTCSessionDescription: { 88 | prototype: RTCSessionDescription; 89 | new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; 90 | // TODO: Add serializer. 91 | // See: http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSdpType) 92 | }; 93 | 94 | interface webkitRTCSessionDescription extends RTCSessionDescription{ 95 | type?: string; 96 | sdp?: string; 97 | } 98 | declare var webkitRTCSessionDescription: { 99 | prototype: webkitRTCSessionDescription; 100 | new (descriptionInitDict?: RTCSessionDescriptionInit): webkitRTCSessionDescription; 101 | }; 102 | 103 | interface mozRTCSessionDescription extends RTCSessionDescription{ 104 | type?: string; 105 | sdp?: string; 106 | } 107 | declare var mozRTCSessionDescription: { 108 | prototype: mozRTCSessionDescription; 109 | new (descriptionInitDict?: RTCSessionDescriptionInit): mozRTCSessionDescription; 110 | }; 111 | 112 | 113 | 114 | interface RTCDataChannelInit { 115 | ordered ?: boolean; // messages must be sent in-order. 116 | maxPacketLifeTime ?: number; // unsigned short 117 | maxRetransmits ?: number; // unsigned short 118 | protocol ?: string; // default = '' 119 | negotiated ?: boolean; // default = false; 120 | id ?: number; // unsigned short 121 | } 122 | 123 | // TODO(1) 124 | declare enum RTCSdpType { 125 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcsdptype 126 | 'offer', 127 | 'pranswer', 128 | 'answer' 129 | } 130 | 131 | interface RTCMessageEvent { 132 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#event-datachannel-message 133 | // At present, this can be an: ArrayBuffer, a string, or a Blob. 134 | // See TODO(2) 135 | data: any; 136 | } 137 | 138 | // TODO(1) 139 | declare enum RTCDataChannelState { 140 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelState 141 | 'connecting', 142 | 'open', 143 | 'closing', 144 | 'closed' 145 | } 146 | 147 | interface RTCDataChannel extends EventTarget { 148 | label: string; 149 | reliable: boolean; 150 | readyState: string; // RTCDataChannelState; see TODO(1) 151 | bufferedAmount: number; 152 | binaryType: string; 153 | 154 | onopen: (event: Event) => void; 155 | onerror: (event: Event) => void; 156 | onclose: (event: Event) => void; 157 | onmessage: (event: RTCMessageEvent) => void; 158 | 159 | close(): void; 160 | 161 | send(data: string): void ; 162 | send(data: ArrayBuffer): void; 163 | send(data: ArrayBufferView): void; 164 | send(data: Blob): void; 165 | } 166 | declare var RTCDataChannel: { 167 | prototype: RTCDataChannel; 168 | new (): RTCDataChannel; 169 | }; 170 | 171 | interface RTCDataChannelEvent extends Event { 172 | channel: RTCDataChannel; 173 | } 174 | declare var RTCDataChannelEvent: { 175 | prototype: RTCDataChannelEvent; 176 | new (eventInitDict: RTCDataChannelEventInit): RTCDataChannelEvent; 177 | }; 178 | 179 | interface RTCIceCandidateEvent extends Event { 180 | candidate: RTCIceCandidate; 181 | } 182 | 183 | interface RTCMediaStreamEvent extends Event { 184 | stream: MediaStream; 185 | } 186 | 187 | interface EventInit { 188 | } 189 | 190 | interface RTCDataChannelEventInit extends EventInit { 191 | channel: RTCDataChannel; 192 | } 193 | 194 | interface RTCVoidCallback { 195 | (): void; 196 | } 197 | interface RTCSessionDescriptionCallback { 198 | (sdp: RTCSessionDescription): void; 199 | } 200 | interface RTCPeerConnectionErrorCallback { 201 | (errorInformation: DOMError): void; 202 | } 203 | 204 | // TODO(1) 205 | declare enum RTCIceGatheringState { 206 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcicegatheringstate-enum 207 | 'new', 208 | 'gathering', 209 | 'complete' 210 | } 211 | 212 | // TODO(1) 213 | declare enum RTCIceConnectionState { 214 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceConnectionState 215 | 'new', 216 | 'checking', 217 | 'connected', 218 | 'completed', 219 | 'failed', 220 | 'disconnected', 221 | 'closed' 222 | } 223 | 224 | // TODO(1) 225 | declare enum RTCSignalingState { 226 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSignalingState 227 | 'stable', 228 | 'have-local-offer', 229 | 'have-remote-offer', 230 | 'have-local-pranswer', 231 | 'have-remote-pranswer', 232 | 'closed' 233 | } 234 | 235 | // This is based on the current implementation of WebRtc in Chrome; the spec is 236 | // a little unclear on this. 237 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCStatsReport 238 | interface RTCStatsReport { 239 | stat(id: string): string; 240 | } 241 | 242 | interface RTCStatsCallback { 243 | (report: RTCStatsReport): void; 244 | } 245 | 246 | interface RTCPeerConnection { 247 | createOffer(successCallback: RTCSessionDescriptionCallback, 248 | failureCallback?: RTCPeerConnectionErrorCallback, 249 | constraints?: RTCMediaConstraints): void; 250 | createAnswer(successCallback: RTCSessionDescriptionCallback, 251 | failureCallback?: RTCPeerConnectionErrorCallback, 252 | constraints?: RTCMediaConstraints): void; 253 | setLocalDescription(description: RTCSessionDescription, 254 | successCallback?: RTCVoidCallback, 255 | failureCallback?: RTCPeerConnectionErrorCallback): void; 256 | localDescription: RTCSessionDescription; 257 | setRemoteDescription(description: RTCSessionDescription, 258 | successCallback?: RTCVoidCallback, 259 | failureCallback?: RTCPeerConnectionErrorCallback): void; 260 | remoteDescription: RTCSessionDescription; 261 | signalingState: string; // RTCSignalingState; see TODO(1) 262 | updateIce(configuration?: RTCConfiguration, 263 | constraints?: RTCMediaConstraints): void; 264 | addIceCandidate(candidate:RTCIceCandidate, 265 | successCallback:() => void, 266 | failureCallback:RTCPeerConnectionErrorCallback): void; 267 | iceGatheringState: string; // RTCIceGatheringState; see TODO(1) 268 | iceConnectionState: string; // RTCIceConnectionState; see TODO(1) 269 | getLocalStreams(): MediaStream[]; 270 | getRemoteStreams(): MediaStream[]; 271 | createDataChannel(label?: string, 272 | dataChannelDict?: RTCDataChannelInit): RTCDataChannel; 273 | ondatachannel: (event: Event) => void; 274 | addStream(stream: MediaStream, constraints?: RTCMediaConstraints): void; 275 | removeStream(stream: MediaStream): void; 276 | close(): void; 277 | onnegotiationneeded: (event: Event) => void; 278 | onconnecting: (event: Event) => void; 279 | onopen: (event: Event) => void; 280 | onaddstream: (event: RTCMediaStreamEvent) => void; 281 | onremovestream: (event: RTCMediaStreamEvent) => void; 282 | onstatechange: (event: Event) => void; 283 | oniceconnectionstatechange: (event: Event) => void; 284 | onicecandidate: (event: RTCIceCandidateEvent) => void; 285 | onidentityresult: (event: Event) => void; 286 | onsignalingstatechange: (event: Event) => void; 287 | getStats: (successCallback: RTCStatsCallback, 288 | failureCallback: RTCPeerConnectionErrorCallback) => void; 289 | } 290 | declare var RTCPeerConnection: { 291 | prototype: RTCPeerConnection; 292 | new (configuration: RTCConfiguration, 293 | constraints?: RTCMediaConstraints): RTCPeerConnection; 294 | }; 295 | 296 | interface RTCIceCandidate { 297 | candidate?: string; 298 | sdpMid?: string; 299 | sdpMLineIndex?: number; 300 | } 301 | declare var RTCIceCandidate: { 302 | prototype: RTCIceCandidate; 303 | new (candidateInitDict?: RTCIceCandidate): RTCIceCandidate; 304 | }; 305 | 306 | interface webkitRTCIceCandidate extends RTCIceCandidate { 307 | candidate?: string; 308 | sdpMid?: string; 309 | sdpMLineIndex?: number; 310 | } 311 | declare var webkitRTCIceCandidate: { 312 | prototype: webkitRTCIceCandidate; 313 | new (candidateInitDict?: webkitRTCIceCandidate): webkitRTCIceCandidate; 314 | }; 315 | 316 | interface mozRTCIceCandidate extends RTCIceCandidate { 317 | candidate?: string; 318 | sdpMid?: string; 319 | sdpMLineIndex?: number; 320 | } 321 | declare var mozRTCIceCandidate: { 322 | prototype: mozRTCIceCandidate; 323 | new (candidateInitDict?: mozRTCIceCandidate): mozRTCIceCandidate; 324 | }; 325 | 326 | interface RTCIceCandidateInit { 327 | candidate: string; 328 | sdpMid: string; 329 | sdpMLineIndex: number; 330 | } 331 | declare var RTCIceCandidateInit:{ 332 | prototype: RTCIceCandidateInit; 333 | new (): RTCIceCandidateInit; 334 | }; 335 | 336 | interface PeerConnectionIceEvent { 337 | peer: RTCPeerConnection; 338 | candidate: RTCIceCandidate; 339 | } 340 | declare var PeerConnectionIceEvent: { 341 | prototype: PeerConnectionIceEvent; 342 | new (): PeerConnectionIceEvent; 343 | }; 344 | 345 | interface RTCPeerConnectionConfig { 346 | iceServers: RTCIceServer[]; 347 | } 348 | declare var RTCPeerConnectionConfig: { 349 | prototype: RTCPeerConnectionConfig; 350 | new (): RTCPeerConnectionConfig; 351 | }; 352 | 353 | interface Window{ 354 | RTCPeerConnection: RTCPeerConnection; 355 | webkitRTCPeerConnection: webkitRTCPeerConnection; 356 | mozRTCPeerConnection: mozRTCPeerConnection; 357 | RTCSessionDescription: RTCSessionDescription; 358 | webkitRTCSessionDescription: webkitRTCSessionDescription; 359 | mozRTCSessionDescription: mozRTCSessionDescription; 360 | RTCIceCandidate: RTCIceCandidate; 361 | webkitRTCIceCandidate: webkitRTCIceCandidate; 362 | mozRTCIceCandidate: mozRTCIceCandidate; 363 | } 364 | -------------------------------------------------------------------------------- /Project_Files/scripts/webrtc/RTCPeerConnection.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for WebRTC 2 | // Project: http://dev.w3.org/2011/webrtc/ 3 | // Definitions by: Ken Smith 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | // 6 | // Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html 7 | // 8 | // For example code see: 9 | // https://code.google.com/p/webrtc/source/browse/stable/samples/js/apprtc/js/main.js 10 | // 11 | // For a generic implementation see that deals with browser differences, see: 12 | // https://code.google.com/p/webrtc/source/browse/stable/samples/js/base/adapter.js 13 | 14 | /// 15 | 16 | // TODO(1): Get Typescript to have string-enum types as WebRtc is full of string 17 | // enums. 18 | // https://typescript.codeplex.com/discussions/549207 19 | 20 | // TODO(2): get Typescript to have union types as WebRtc uses them. 21 | // https://typescript.codeplex.com/workitem/1364 22 | 23 | interface RTCConfiguration { 24 | iceServers: RTCIceServer[]; 25 | } 26 | declare var RTCConfiguration: { 27 | prototype: RTCConfiguration; 28 | new (): RTCConfiguration; 29 | }; 30 | 31 | interface RTCIceServer { 32 | urls: string; 33 | credential?: string; 34 | } 35 | declare var RTCIceServer: { 36 | prototype: RTCIceServer; 37 | new (): RTCIceServer; 38 | }; 39 | 40 | // moz (Firefox) specific prefixes. 41 | interface mozRTCPeerConnection extends RTCPeerConnection { 42 | } 43 | declare var mozRTCPeerConnection: { 44 | prototype: mozRTCPeerConnection; 45 | new (settings: RTCPeerConnectionConfig, 46 | constraints?:RTCMediaConstraints): mozRTCPeerConnection; 47 | }; 48 | // webkit (Chrome) specific prefixes. 49 | interface webkitRTCPeerConnection extends RTCPeerConnection { 50 | } 51 | declare var webkitRTCPeerConnection: { 52 | prototype: webkitRTCPeerConnection; 53 | new (settings: RTCPeerConnectionConfig, 54 | constraints?:RTCMediaConstraints): webkitRTCPeerConnection; 55 | }; 56 | 57 | // For Chrome, look at the code here: 58 | // https://code.google.com/p/chromium/codesearch#chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsession.cc&sq=package:chromium&dr=C&l=63 59 | interface RTCOptionalMediaConstraint { 60 | // When true, will use DTLS/SCTP data channels 61 | DtlsSrtpKeyAgreement?: boolean; 62 | // When true will use Rtp-based data channels (depreicated) 63 | RtpDataChannels?: boolean; 64 | } 65 | 66 | // ks 12/20/12 - There's more here that doesn't seem to be documented very well yet. 67 | // http://www.w3.org/TR/2013/WD-webrtc-20130910/ 68 | interface RTCMediaConstraints { 69 | mandatory?: RTCMediaOfferConstraints; 70 | optional?: RTCOptionalMediaConstraint[] 71 | } 72 | 73 | interface RTCMediaOfferConstraints { 74 | offerToReceiveAudio: boolean; 75 | offerToReceiveVideo: boolean; 76 | } 77 | 78 | interface RTCSessionDescriptionInit { 79 | type: string; // RTCSdpType; See TODO(1) 80 | sdp: string; 81 | } 82 | 83 | interface RTCSessionDescription { 84 | type?: string; // RTCSdpType; See TODO(1) 85 | sdp?: string; 86 | } 87 | declare var RTCSessionDescription: { 88 | prototype: RTCSessionDescription; 89 | new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; 90 | // TODO: Add serializer. 91 | // See: http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSdpType) 92 | }; 93 | 94 | interface webkitRTCSessionDescription extends RTCSessionDescription{ 95 | type?: string; 96 | sdp?: string; 97 | } 98 | declare var webkitRTCSessionDescription: { 99 | prototype: webkitRTCSessionDescription; 100 | new (descriptionInitDict?: RTCSessionDescriptionInit): webkitRTCSessionDescription; 101 | }; 102 | 103 | interface mozRTCSessionDescription extends RTCSessionDescription{ 104 | type?: string; 105 | sdp?: string; 106 | } 107 | declare var mozRTCSessionDescription: { 108 | prototype: mozRTCSessionDescription; 109 | new (descriptionInitDict?: RTCSessionDescriptionInit): mozRTCSessionDescription; 110 | }; 111 | 112 | 113 | 114 | interface RTCDataChannelInit { 115 | ordered ?: boolean; // messages must be sent in-order. 116 | maxPacketLifeTime ?: number; // unsigned short 117 | maxRetransmits ?: number; // unsigned short 118 | protocol ?: string; // default = '' 119 | negotiated ?: boolean; // default = false; 120 | id ?: number; // unsigned short 121 | } 122 | 123 | // TODO(1) 124 | declare enum RTCSdpType { 125 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcsdptype 126 | 'offer', 127 | 'pranswer', 128 | 'answer' 129 | } 130 | 131 | interface RTCMessageEvent { 132 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#event-datachannel-message 133 | // At present, this can be an: ArrayBuffer, a string, or a Blob. 134 | // See TODO(2) 135 | data: any; 136 | } 137 | 138 | // TODO(1) 139 | declare enum RTCDataChannelState { 140 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelState 141 | 'connecting', 142 | 'open', 143 | 'closing', 144 | 'closed' 145 | } 146 | 147 | interface RTCDataChannel extends EventTarget { 148 | label: string; 149 | reliable: boolean; 150 | readyState: string; // RTCDataChannelState; see TODO(1) 151 | bufferedAmount: number; 152 | binaryType: string; 153 | 154 | onopen: (event: Event) => void; 155 | onerror: (event: Event) => void; 156 | onclose: (event: Event) => void; 157 | onmessage: (event: RTCMessageEvent) => void; 158 | 159 | close(): void; 160 | 161 | send(data: string): void ; 162 | send(data: ArrayBuffer): void; 163 | send(data: ArrayBufferView): void; 164 | send(data: Blob): void; 165 | } 166 | declare var RTCDataChannel: { 167 | prototype: RTCDataChannel; 168 | new (): RTCDataChannel; 169 | }; 170 | 171 | interface RTCDataChannelEvent extends Event { 172 | channel: RTCDataChannel; 173 | } 174 | declare var RTCDataChannelEvent: { 175 | prototype: RTCDataChannelEvent; 176 | new (eventInitDict: RTCDataChannelEventInit): RTCDataChannelEvent; 177 | }; 178 | 179 | interface RTCIceCandidateEvent extends Event { 180 | candidate: RTCIceCandidate; 181 | } 182 | 183 | interface RTCMediaStreamEvent extends Event { 184 | stream: MediaStream; 185 | } 186 | 187 | interface EventInit { 188 | } 189 | 190 | interface RTCDataChannelEventInit extends EventInit { 191 | channel: RTCDataChannel; 192 | } 193 | 194 | interface RTCVoidCallback { 195 | (): void; 196 | } 197 | interface RTCSessionDescriptionCallback { 198 | (sdp: RTCSessionDescription): void; 199 | } 200 | interface RTCPeerConnectionErrorCallback { 201 | (errorInformation: DOMError): void; 202 | } 203 | 204 | // TODO(1) 205 | declare enum RTCIceGatheringState { 206 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcicegatheringstate-enum 207 | 'new', 208 | 'gathering', 209 | 'complete' 210 | } 211 | 212 | // TODO(1) 213 | declare enum RTCIceConnectionState { 214 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceConnectionState 215 | 'new', 216 | 'checking', 217 | 'connected', 218 | 'completed', 219 | 'failed', 220 | 'disconnected', 221 | 'closed' 222 | } 223 | 224 | // TODO(1) 225 | declare enum RTCSignalingState { 226 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSignalingState 227 | 'stable', 228 | 'have-local-offer', 229 | 'have-remote-offer', 230 | 'have-local-pranswer', 231 | 'have-remote-pranswer', 232 | 'closed' 233 | } 234 | 235 | // This is based on the current implementation of WebRtc in Chrome; the spec is 236 | // a little unclear on this. 237 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCStatsReport 238 | interface RTCStatsReport { 239 | stat(id: string): string; 240 | } 241 | 242 | interface RTCStatsCallback { 243 | (report: RTCStatsReport): void; 244 | } 245 | 246 | interface RTCPeerConnection { 247 | createOffer(successCallback: RTCSessionDescriptionCallback, 248 | failureCallback?: RTCPeerConnectionErrorCallback, 249 | constraints?: RTCMediaConstraints): void; 250 | createAnswer(successCallback: RTCSessionDescriptionCallback, 251 | failureCallback?: RTCPeerConnectionErrorCallback, 252 | constraints?: RTCMediaConstraints): void; 253 | setLocalDescription(description: RTCSessionDescription, 254 | successCallback?: RTCVoidCallback, 255 | failureCallback?: RTCPeerConnectionErrorCallback): void; 256 | localDescription: RTCSessionDescription; 257 | setRemoteDescription(description: RTCSessionDescription, 258 | successCallback?: RTCVoidCallback, 259 | failureCallback?: RTCPeerConnectionErrorCallback): void; 260 | remoteDescription: RTCSessionDescription; 261 | signalingState: string; // RTCSignalingState; see TODO(1) 262 | updateIce(configuration?: RTCConfiguration, 263 | constraints?: RTCMediaConstraints): void; 264 | addIceCandidate(candidate:RTCIceCandidate, 265 | successCallback:() => void, 266 | failureCallback:RTCPeerConnectionErrorCallback): void; 267 | iceGatheringState: string; // RTCIceGatheringState; see TODO(1) 268 | iceConnectionState: string; // RTCIceConnectionState; see TODO(1) 269 | getLocalStreams(): MediaStream[]; 270 | getRemoteStreams(): MediaStream[]; 271 | createDataChannel(label?: string, 272 | dataChannelDict?: RTCDataChannelInit): RTCDataChannel; 273 | ondatachannel: (event: Event) => void; 274 | addStream(stream: MediaStream, constraints?: RTCMediaConstraints): void; 275 | removeStream(stream: MediaStream): void; 276 | close(): void; 277 | onnegotiationneeded: (event: Event) => void; 278 | onconnecting: (event: Event) => void; 279 | onopen: (event: Event) => void; 280 | onaddstream: (event: RTCMediaStreamEvent) => void; 281 | onremovestream: (event: RTCMediaStreamEvent) => void; 282 | onstatechange: (event: Event) => void; 283 | oniceconnectionstatechange: (event: Event) => void; 284 | onicecandidate: (event: RTCIceCandidateEvent) => void; 285 | onidentityresult: (event: Event) => void; 286 | onsignalingstatechange: (event: Event) => void; 287 | getStats: (successCallback: RTCStatsCallback, 288 | failureCallback: RTCPeerConnectionErrorCallback) => void; 289 | } 290 | declare var RTCPeerConnection: { 291 | prototype: RTCPeerConnection; 292 | new (configuration: RTCConfiguration, 293 | constraints?: RTCMediaConstraints): RTCPeerConnection; 294 | }; 295 | 296 | interface RTCIceCandidate { 297 | candidate?: string; 298 | sdpMid?: string; 299 | sdpMLineIndex?: number; 300 | } 301 | declare var RTCIceCandidate: { 302 | prototype: RTCIceCandidate; 303 | new (candidateInitDict?: RTCIceCandidate): RTCIceCandidate; 304 | }; 305 | 306 | interface webkitRTCIceCandidate extends RTCIceCandidate { 307 | candidate?: string; 308 | sdpMid?: string; 309 | sdpMLineIndex?: number; 310 | } 311 | declare var webkitRTCIceCandidate: { 312 | prototype: webkitRTCIceCandidate; 313 | new (candidateInitDict?: webkitRTCIceCandidate): webkitRTCIceCandidate; 314 | }; 315 | 316 | interface mozRTCIceCandidate extends RTCIceCandidate { 317 | candidate?: string; 318 | sdpMid?: string; 319 | sdpMLineIndex?: number; 320 | } 321 | declare var mozRTCIceCandidate: { 322 | prototype: mozRTCIceCandidate; 323 | new (candidateInitDict?: mozRTCIceCandidate): mozRTCIceCandidate; 324 | }; 325 | 326 | interface RTCIceCandidateInit { 327 | candidate: string; 328 | sdpMid: string; 329 | sdpMLineIndex: number; 330 | } 331 | declare var RTCIceCandidateInit:{ 332 | prototype: RTCIceCandidateInit; 333 | new (): RTCIceCandidateInit; 334 | }; 335 | 336 | interface PeerConnectionIceEvent { 337 | peer: RTCPeerConnection; 338 | candidate: RTCIceCandidate; 339 | } 340 | declare var PeerConnectionIceEvent: { 341 | prototype: PeerConnectionIceEvent; 342 | new (): PeerConnectionIceEvent; 343 | }; 344 | 345 | interface RTCPeerConnectionConfig { 346 | iceServers: RTCIceServer[]; 347 | } 348 | declare var RTCPeerConnectionConfig: { 349 | prototype: RTCPeerConnectionConfig; 350 | new (): RTCPeerConnectionConfig; 351 | }; 352 | 353 | interface Window{ 354 | RTCPeerConnection: RTCPeerConnection; 355 | webkitRTCPeerConnection: webkitRTCPeerConnection; 356 | mozRTCPeerConnection: mozRTCPeerConnection; 357 | RTCSessionDescription: RTCSessionDescription; 358 | webkitRTCSessionDescription: webkitRTCSessionDescription; 359 | mozRTCSessionDescription: mozRTCSessionDescription; 360 | RTCIceCandidate: RTCIceCandidate; 361 | webkitRTCIceCandidate: webkitRTCIceCandidate; 362 | mozRTCIceCandidate: mozRTCIceCandidate; 363 | } 364 | -------------------------------------------------------------------------------- /Typings/filesystem/filesystem.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for File System API 2 | // Project: http://www.w3.org/TR/file-system-api/ 3 | // Definitions by: Kon 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /// 7 | 8 | interface LocalFileSystem { 9 | 10 | /** 11 | * Used for storage with no guarantee of persistence. 12 | */ 13 | TEMPORARY:number; 14 | 15 | /** 16 | * Used for storage that should not be removed by the user agent without application or user permission. 17 | */ 18 | PERSISTENT:number; 19 | 20 | /** 21 | * Requests a filesystem in which to store application data. 22 | * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT. 23 | * @param size This is an indicator of how much storage space, in bytes, the application expects to need. 24 | * @param successCallback The callback that is called when the user agent provides a filesystem. 25 | * @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is denied. 26 | */ 27 | requestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void; 28 | 29 | /** 30 | * Allows the user to look up the Entry for a file or directory referred to by a local URL. 31 | * @param url A URL referring to a local file in a filesystem accessable via this API. 32 | * @param successCallback A callback that is called to report the Entry to which the supplied URL refers. 33 | * @param errorCallback A callback that is called when errors happen, or when the request to obtain the Entry is denied. 34 | */ 35 | resolveLocalFileSystemURL(url:string, successCallback:EntryCallback, errorCallback?:ErrorCallback):void; 36 | 37 | /** 38 | * see requestFileSystem. 39 | */ 40 | webkitRequestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void; 41 | } 42 | 43 | interface LocalFileSystemSync { 44 | /** 45 | * Used for storage with no guarantee of persistence. 46 | */ 47 | TEMPORARY:number; 48 | 49 | /** 50 | * Used for storage that should not be removed by the user agent without application or user permission. 51 | */ 52 | PERSISTENT:number; 53 | 54 | /** 55 | * Requests a filesystem in which to store application data. 56 | * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT. 57 | * @param size This is an indicator of how much storage space, in bytes, the application expects to need. 58 | */ 59 | requestFileSystemSync(type:number, size:number):FileSystemSync; 60 | 61 | /** 62 | * Allows the user to look up the Entry for a file or directory referred to by a local URL. 63 | * @param url A URL referring to a local file in a filesystem accessable via this API. 64 | */ 65 | resolveLocalFileSystemSyncURL(url:string):EntrySync; 66 | 67 | /** 68 | * see requestFileSystemSync 69 | */ 70 | webkitRequestFileSystemSync(type:number, size:number):FileSystemSync; 71 | } 72 | 73 | interface Metadata { 74 | /** 75 | * This is the time at which the file or directory was last modified. 76 | * @readonly 77 | */ 78 | modificationTime:Date; 79 | 80 | /** 81 | * The size of the file, in bytes. This must return 0 for directories. 82 | * @readonly 83 | */ 84 | size:number; 85 | } 86 | 87 | interface Flags { 88 | /** 89 | * Used to indicate that the user wants to create a file or directory if it was not previously there. 90 | */ 91 | create?:boolean; 92 | 93 | /** 94 | * By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists. 95 | */ 96 | exclusive?:boolean; 97 | } 98 | 99 | /** 100 | * This interface represents a file system. 101 | */ 102 | interface FileSystem{ 103 | /** 104 | * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems. 105 | * @readonly 106 | */ 107 | name: string; 108 | 109 | /** 110 | * The root directory of the file system. 111 | * @readonly 112 | */ 113 | root: DirectoryEntry; 114 | } 115 | 116 | interface Entry { 117 | 118 | /** 119 | * Entry is a file. 120 | */ 121 | isFile:boolean; 122 | 123 | /** 124 | * Entry is a directory. 125 | */ 126 | isDirectory:boolean; 127 | 128 | /** 129 | * Look up metadata about this entry. 130 | * @param successCallback A callback that is called with the time of the last modification. 131 | * @param errorCallback ErrorCallback A callback that is called when errors happen. 132 | */ 133 | getMetadata(successCallback:MetadataCallback, errorCallback?:ErrorCallback):void; 134 | 135 | /** 136 | * The name of the entry, excluding the path leading to it. 137 | */ 138 | name:string; 139 | 140 | /** 141 | * The full absolute path from the root to the entry. 142 | */ 143 | fullPath:string; 144 | 145 | /** 146 | * The file system on which the entry resides. 147 | */ 148 | filesystem:FileSystem; 149 | 150 | /** 151 | * Move an entry to a different location on the file system. It is an error to try to: 152 | * 153 | * 154 | *
        • move a directory inside itself or to any child at any depth;
        • 155 | *
        • move an entry into its parent if a name different from its current one isn't provided;
        • 156 | *
        • move a file to a path occupied by a directory;
        • 157 | *
        • move a directory to a path occupied by a file;
        • 158 | *
        • move any element to a path occupied by a directory which is not empty.
        • 159 | *
            160 | * 161 | * A move of a file on top of an existing file must attempt to delete and replace that file. 162 | * A move of a directory on top of an existing empty directory must attempt to delete and replace that directory. 163 | */ 164 | moveTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void; 165 | 166 | /** 167 | * Copy an entry to a different location on the file system. It is an error to try to: 168 | * 169 | *
              170 | *
            • copy a directory inside itself or to any child at any depth;
            • 171 | *
            • copy an entry into its parent if a name different from its current one isn't provided;
            • 172 | *
            • copy a file to a path occupied by a directory;
            • 173 | *
            • copy a directory to a path occupied by a file;
            • 174 | *
            • copy any element to a path occupied by a directory which is not empty.
            • 175 | *
            • A copy of a file on top of an existing file must attempt to delete and replace that file.
            • 176 | *
            • A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory.
            • 177 | *
            178 | * 179 | * Directory copies are always recursive--that is, they copy all contents of the directory. 180 | */ 181 | copyTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void; 182 | 183 | /** 184 | * Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists. 185 | */ 186 | toURL():string; 187 | 188 | /** 189 | * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem. 190 | * @param successCallback A callback that is called on success. 191 | * @param errorCallback A callback that is called when errors happen. 192 | */ 193 | remove(successCallback:VoidCallback, errorCallback?:ErrorCallback):void; 194 | 195 | /** 196 | * Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself. 197 | * @param successCallback A callback that is called to return the parent Entry. 198 | * @param errorCallback A callback that is called when errors happen. 199 | */ 200 | getParent(successCallback:DirectoryEntryCallback, errorCallback?:ErrorCallback):void; 201 | } 202 | 203 | /** 204 | * This interface represents a directory on a file system. 205 | */ 206 | interface DirectoryEntry extends Entry { 207 | /** 208 | * Creates a new DirectoryReader to read Entries from this Directory. 209 | */ 210 | createReader():DirectoryReader; 211 | 212 | /** 213 | * Creates or looks up a file. 214 | * @param path Either an absolute path or a relative path from this DirectoryEntry to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist. 215 | * @param options 216 | *
              217 | *
            • If create and exclusive are both true, and the path already exists, getFile must fail.
            • 218 | *
            • If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
            • 219 | *
            • If create is not true and the path doesn't exist, getFile must fail.
            • 220 | *
            • If create is not true and the path exists, but is a directory, getFile must fail.
            • 221 | *
            • Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.
            • 222 | *
            223 | * @param successCallback A callback that is called to return the File selected or created. 224 | * @param errorCallback A callback that is called when errors happen. 225 | */ 226 | getFile(path:string, options?:Flags, successCallback?:FileEntryCallback, errorCallback?:ErrorCallback):void; 227 | 228 | /** 229 | * Creates or looks up a directory. 230 | * @param path Either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist. 231 | * @param options 232 | *
              233 | *
            • If create and exclusive are both true and the path already exists, getDirectory must fail.
            • 234 | *
            • If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
            • 235 | *
            • If create is not true and the path doesn't exist, getDirectory must fail.
            • 236 | *
            • If create is not true and the path exists, but is a file, getDirectory must fail.
            • 237 | *
            • Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.
            • 238 | *
            239 | * @param successCallback A callback that is called to return the DirectoryEntry selected or created. 240 | * @param errorCallback A callback that is called when errors happen. 241 | * 242 | */ 243 | getDirectory(path:string, options?:Flags, successCallback?:DirectoryEntryCallback, errorCallback?:ErrorCallback):void; 244 | 245 | /** 246 | * Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem. 247 | * @param successCallback A callback that is called on success. 248 | * @param errorCallback A callback that is called when errors happen. 249 | */ 250 | removeRecursively(successCallback:VoidCallback, errorCallback?:ErrorCallback):void; 251 | } 252 | 253 | /** 254 | * This interface lets a user list files and directories in a directory. If there are no additions to or deletions from a directory between the first and last call to readEntries, and no errors occur, then: 255 | *
              256 | *
            • A series of calls to readEntries must return each entry in the directory exactly once.
            • 257 | *
            • Once all entries have been returned, the next call to readEntries must produce an empty array.
            • 258 | *
            • If not all entries have been returned, the array produced by readEntries must not be empty.
            • 259 | *
            • The entries produced by readEntries must not include the directory itself ["."] or its parent [".."].
            • 260 | *
            261 | */ 262 | interface DirectoryReader { 263 | /** 264 | * Read the next block of entries from this directory. 265 | * @param successCallback Called once per successful call to readEntries to deliver the next previously-unreported set of Entries in the associated Directory. If all Entries have already been returned from previous invocations of readEntries, successCallback must be called with a zero-length array as an argument. 266 | * @param errorCallback A callback indicating that there was an error reading from the Directory. 267 | */ 268 | readEntries(successCallback:EntriesCallback, errorCallback?:ErrorCallback):void; 269 | } 270 | 271 | /** 272 | * This interface represents a file on a file system. 273 | */ 274 | interface FileEntry extends Entry { 275 | /** 276 | * Creates a new FileWriter associated with the file that this FileEntry represents. 277 | * @param successCallback A callback that is called with the new FileWriter. 278 | * @param errorCallback A callback that is called when errors happen. 279 | */ 280 | createWriter(successCallback:FileWriterCallback, errorCallback?:ErrorCallback):void; 281 | 282 | /** 283 | * Returns a File that represents the current state of the file that this FileEntry represents. 284 | * @param successCallback A callback that is called with the File. 285 | * @param errorCallback A callback that is called when errors happen. 286 | */ 287 | file(successCallback:FileCallback, errorCallback?:ErrorCallback):void; 288 | } 289 | 290 | /** 291 | * When requestFileSystem() succeeds, the following callback is made. 292 | */ 293 | interface FileSystemCallback { 294 | /** 295 | * @param filesystem The file systems to which the app is granted access. 296 | */ 297 | (filesystem:FileSystem):void; 298 | } 299 | 300 | /** 301 | * This interface is the callback used to look up Entry objects. 302 | */ 303 | interface EntryCallback { 304 | /** 305 | * @param entry 306 | */ 307 | (entry:Entry):void; 308 | } 309 | 310 | /** 311 | * This interface is the callback used to look up FileEntry objects. 312 | */ 313 | interface FileEntryCallback { 314 | /** 315 | * @param entry 316 | */ 317 | (entry:FileEntry):void; 318 | } 319 | 320 | /** 321 | * This interface is the callback used to look up DirectoryEntry objects. 322 | */ 323 | interface DirectoryEntryCallback { 324 | /** 325 | * @param entry 326 | */ 327 | (entry:DirectoryEntry):void; 328 | } 329 | 330 | /** 331 | * When readEntries() succeeds, the following callback is made. 332 | */ 333 | interface EntriesCallback { 334 | (entries:Entry[]):void; 335 | } 336 | 337 | /** 338 | * This interface is the callback used to look up file and directory metadata. 339 | */ 340 | interface MetadataCallback { 341 | (metadata:Metadata):void; 342 | } 343 | 344 | /** 345 | * This interface is the callback used to create a FileWriter. 346 | */ 347 | interface FileWriterCallback { 348 | (fileWriter:FileWriter):void; 349 | } 350 | 351 | /** 352 | * This interface is the callback used to obtain a File. 353 | */ 354 | interface FileCallback { 355 | (file:File):void; 356 | } 357 | 358 | /** 359 | * This interface is the generic callback used to indicate success of an asynchronous method. 360 | */ 361 | interface VoidCallback { 362 | ():void; 363 | } 364 | 365 | /** 366 | * When an error occurs, the following callback is made. 367 | */ 368 | interface ErrorCallback { 369 | (err:DOMError):void; 370 | } 371 | 372 | 373 | /** 374 | * This interface represents a file system. 375 | */ 376 | interface FileSystemSync { 377 | /** 378 | * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems. 379 | */ 380 | name:string; 381 | 382 | /** 383 | * root The root directory of the file system. 384 | */ 385 | root:DirectoryEntrySync; 386 | } 387 | 388 | /** 389 | * An abstract interface representing entries in a file system, each of which may be a FileEntrySync or DirectoryEntrySync. 390 | */ 391 | interface EntrySync{ 392 | /** 393 | * EntrySync is a file. 394 | * @readonly 395 | */ 396 | isFile:boolean; 397 | 398 | /** 399 | * EntrySync is a directory. 400 | * @readonly 401 | */ 402 | isDirectory:boolean; 403 | 404 | /** 405 | * Look up metadata about this entry. 406 | */ 407 | getMetadata():Metadata; 408 | 409 | /** 410 | * The name of the entry, excluding the path leading to it. 411 | */ 412 | name:string; 413 | 414 | /** 415 | * The full absolute path from the root to the entry. 416 | */ 417 | fullPath:string; 418 | 419 | /** 420 | * The file system on which the entry resides. 421 | */ 422 | filesystem:FileSystemSync; 423 | 424 | /** 425 | * Move an entry to a different location on the file system. It is an error to try to: 426 | *
              427 | *
            • move a directory inside itself or to any child at any depth;
            • 428 | *
            • move an entry into its parent if a name different from its current one isn't provided;
            • 429 | *
            • move a file to a path occupied by a directory;
            • 430 | *
            • move a directory to a path occupied by a file;
            • 431 | *
            • move any element to a path occupied by a directory which is not empty.
            • 432 | * 433 | * A move of a file on top of an existing file must attempt to delete and replace that file. A move of a directory on top of an existing empty directory must attempt to delete and replace that directory. 434 | * @param parent The directory to which to move the entry. 435 | * @param newName The new name of the entry. Defaults to the EntrySync's current name if unspecified. 436 | */ 437 | moveTo(parent:DirectoryEntrySync, newName?:string):EntrySync; 438 | 439 | /** 440 | * Copy an entry to a different location on the file system. It is an error to try to: 441 | *
                442 | *
              • copy a directory inside itself or to any child at any depth;
              • 443 | *
              • copy an entry into its parent if a name different from its current one isn't provided;
              • 444 | *
              • copy a file to a path occupied by a directory;
              • 445 | *
              • copy a directory to a path occupied by a file;
              • 446 | *
              • copy any element to a path occupied by a directory which is not empty.
              • 447 | * 448 | * A copy of a file on top of an existing file must attempt to delete and replace that file. 449 | * A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory. 450 | * Directory copies are always recursive--that is, they copy all contents of the directory. 451 | */ 452 | copyTo(parent:DirectoryEntrySync, newName?:string):EntrySync; 453 | 454 | /** 455 | * Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists. 456 | */ 457 | toURL():string; 458 | 459 | /** 460 | * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem. 461 | */ 462 | remove ():void; 463 | 464 | /** 465 | * Look up the parent DirectoryEntrySync containing this Entry. If this EntrySync is the root of its filesystem, its parent is itself. 466 | */ 467 | getParent():DirectoryEntrySync; 468 | } 469 | 470 | /** 471 | * This interface represents a directory on a file system. 472 | */ 473 | interface DirectoryEntrySync extends EntrySync { 474 | /** 475 | * Creates a new DirectoryReaderSync to read EntrySyncs from this DirectorySync. 476 | */ 477 | createReader():DirectoryReaderSync; 478 | 479 | /** 480 | * Creates or looks up a directory. 481 | * @param path Either an absolute path or a relative path from this DirectoryEntrySync to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist. 482 | * @param options 483 | *
                  484 | *
                • If create and exclusive are both true and the path already exists, getFile must fail.
                • 485 | *
                • If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
                • 486 | *
                • If create is not true and the path doesn't exist, getFile must fail.
                • 487 | *
                • If create is not true and the path exists, but is a directory, getFile must fail.
                • 488 | *
                • Otherwise, if no other error occurs, getFile must return a FileEntrySync corresponding to path.
                • 489 | *
                490 | */ 491 | getFile(path:string, options?:Flags):FileEntrySync; 492 | 493 | /** 494 | * Creates or looks up a directory. 495 | * @param path Either an absolute path or a relative path from this DirectoryEntrySync to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist. 496 | * @param options 497 | *
                  498 | *
                • If create and exclusive are both true and the path already exists, getDirectory must fail.
                • 499 | *
                • If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
                • 500 | *
                • If create is not true and the path doesn't exist, getDirectory must fail.
                • 501 | *
                • If create is not true and the path exists, but is a file, getDirectory must fail.
                • 502 | *
                • Otherwise, if no other error occurs, getDirectory must return a DirectoryEntrySync corresponding to path.
                • 503 | *
                504 | */ 505 | getDirectory(path:string, options?:Flags):DirectoryEntrySync; 506 | 507 | /** 508 | * Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem. 509 | */ 510 | removeRecursively():void; 511 | } 512 | 513 | /** 514 | * This interface lets a user list files and directories in a directory. If there are no additions to or deletions from a directory between the first and last call to readEntries, and no errors occur, then: 515 | *
                  516 | *
                • A series of calls to readEntries must return each entry in the directory exactly once.
                • 517 | *
                • Once all entries have been returned, the next call to readEntries must produce an empty array.
                • 518 | *
                • If not all entries have been returned, the array produced by readEntries must not be empty.
                • 519 | *
                • The entries produced by readEntries must not include the directory itself ["."] or its parent [".."].
                • 520 | *
                521 | */ 522 | interface DirectoryReaderSync { 523 | /** 524 | * Read the next block of entries from this directory. 525 | */ 526 | readEntries():EntrySync[]; 527 | } 528 | 529 | /** 530 | * This interface represents a file on a file system. 531 | */ 532 | interface FileEntrySync extends EntrySync { 533 | /** 534 | * Creates a new FileWriterSync associated with the file that this FileEntrySync represents. 535 | */ 536 | createWriter():FileWriterSync; 537 | 538 | /** 539 | * Returns a File that represents the current state of the file that this FileEntrySync represents. 540 | */ 541 | file():File; 542 | } 543 | 544 | interface Window extends LocalFileSystem, LocalFileSystemSync{ 545 | } 546 | 547 | interface WorkerGlobalScope extends LocalFileSystem, LocalFileSystemSync{ 548 | } 549 | -------------------------------------------------------------------------------- /Project_Files/scripts/filesystem/filesystem.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for File System API 2 | // Project: http://www.w3.org/TR/file-system-api/ 3 | // Definitions by: Kon 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /// 7 | 8 | interface LocalFileSystem { 9 | 10 | /** 11 | * Used for storage with no guarantee of persistence. 12 | */ 13 | TEMPORARY:number; 14 | 15 | /** 16 | * Used for storage that should not be removed by the user agent without application or user permission. 17 | */ 18 | PERSISTENT:number; 19 | 20 | /** 21 | * Requests a filesystem in which to store application data. 22 | * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT. 23 | * @param size This is an indicator of how much storage space, in bytes, the application expects to need. 24 | * @param successCallback The callback that is called when the user agent provides a filesystem. 25 | * @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is denied. 26 | */ 27 | requestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void; 28 | 29 | /** 30 | * Allows the user to look up the Entry for a file or directory referred to by a local URL. 31 | * @param url A URL referring to a local file in a filesystem accessable via this API. 32 | * @param successCallback A callback that is called to report the Entry to which the supplied URL refers. 33 | * @param errorCallback A callback that is called when errors happen, or when the request to obtain the Entry is denied. 34 | */ 35 | resolveLocalFileSystemURL(url:string, successCallback:EntryCallback, errorCallback?:ErrorCallback):void; 36 | 37 | /** 38 | * see requestFileSystem. 39 | */ 40 | webkitRequestFileSystem(type:number, size:number, successCallback:FileSystemCallback, errorCallback?:ErrorCallback):void; 41 | } 42 | 43 | interface LocalFileSystemSync { 44 | /** 45 | * Used for storage with no guarantee of persistence. 46 | */ 47 | TEMPORARY:number; 48 | 49 | /** 50 | * Used for storage that should not be removed by the user agent without application or user permission. 51 | */ 52 | PERSISTENT:number; 53 | 54 | /** 55 | * Requests a filesystem in which to store application data. 56 | * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT. 57 | * @param size This is an indicator of how much storage space, in bytes, the application expects to need. 58 | */ 59 | requestFileSystemSync(type:number, size:number):FileSystemSync; 60 | 61 | /** 62 | * Allows the user to look up the Entry for a file or directory referred to by a local URL. 63 | * @param url A URL referring to a local file in a filesystem accessable via this API. 64 | */ 65 | resolveLocalFileSystemSyncURL(url:string):EntrySync; 66 | 67 | /** 68 | * see requestFileSystemSync 69 | */ 70 | webkitRequestFileSystemSync(type:number, size:number):FileSystemSync; 71 | } 72 | 73 | interface Metadata { 74 | /** 75 | * This is the time at which the file or directory was last modified. 76 | * @readonly 77 | */ 78 | modificationTime:Date; 79 | 80 | /** 81 | * The size of the file, in bytes. This must return 0 for directories. 82 | * @readonly 83 | */ 84 | size:number; 85 | } 86 | 87 | interface Flags { 88 | /** 89 | * Used to indicate that the user wants to create a file or directory if it was not previously there. 90 | */ 91 | create?:boolean; 92 | 93 | /** 94 | * By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists. 95 | */ 96 | exclusive?:boolean; 97 | } 98 | 99 | /** 100 | * This interface represents a file system. 101 | */ 102 | interface FileSystem{ 103 | /** 104 | * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems. 105 | * @readonly 106 | */ 107 | name: string; 108 | 109 | /** 110 | * The root directory of the file system. 111 | * @readonly 112 | */ 113 | root: DirectoryEntry; 114 | } 115 | 116 | interface Entry { 117 | 118 | /** 119 | * Entry is a file. 120 | */ 121 | isFile:boolean; 122 | 123 | /** 124 | * Entry is a directory. 125 | */ 126 | isDirectory:boolean; 127 | 128 | /** 129 | * Look up metadata about this entry. 130 | * @param successCallback A callback that is called with the time of the last modification. 131 | * @param errorCallback ErrorCallback A callback that is called when errors happen. 132 | */ 133 | getMetadata(successCallback:MetadataCallback, errorCallback?:ErrorCallback):void; 134 | 135 | /** 136 | * The name of the entry, excluding the path leading to it. 137 | */ 138 | name:string; 139 | 140 | /** 141 | * The full absolute path from the root to the entry. 142 | */ 143 | fullPath:string; 144 | 145 | /** 146 | * The file system on which the entry resides. 147 | */ 148 | filesystem:FileSystem; 149 | 150 | /** 151 | * Move an entry to a different location on the file system. It is an error to try to: 152 | * 153 | * 154 | *
              • move a directory inside itself or to any child at any depth;
              • 155 | *
              • move an entry into its parent if a name different from its current one isn't provided;
              • 156 | *
              • move a file to a path occupied by a directory;
              • 157 | *
              • move a directory to a path occupied by a file;
              • 158 | *
              • move any element to a path occupied by a directory which is not empty.
              • 159 | *
                  160 | * 161 | * A move of a file on top of an existing file must attempt to delete and replace that file. 162 | * A move of a directory on top of an existing empty directory must attempt to delete and replace that directory. 163 | */ 164 | moveTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void; 165 | 166 | /** 167 | * Copy an entry to a different location on the file system. It is an error to try to: 168 | * 169 | *
                    170 | *
                  • copy a directory inside itself or to any child at any depth;
                  • 171 | *
                  • copy an entry into its parent if a name different from its current one isn't provided;
                  • 172 | *
                  • copy a file to a path occupied by a directory;
                  • 173 | *
                  • copy a directory to a path occupied by a file;
                  • 174 | *
                  • copy any element to a path occupied by a directory which is not empty.
                  • 175 | *
                  • A copy of a file on top of an existing file must attempt to delete and replace that file.
                  • 176 | *
                  • A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory.
                  • 177 | *
                  178 | * 179 | * Directory copies are always recursive--that is, they copy all contents of the directory. 180 | */ 181 | copyTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void; 182 | 183 | /** 184 | * Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists. 185 | */ 186 | toURL():string; 187 | 188 | /** 189 | * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem. 190 | * @param successCallback A callback that is called on success. 191 | * @param errorCallback A callback that is called when errors happen. 192 | */ 193 | remove(successCallback:VoidCallback, errorCallback?:ErrorCallback):void; 194 | 195 | /** 196 | * Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself. 197 | * @param successCallback A callback that is called to return the parent Entry. 198 | * @param errorCallback A callback that is called when errors happen. 199 | */ 200 | getParent(successCallback:DirectoryEntryCallback, errorCallback?:ErrorCallback):void; 201 | } 202 | 203 | /** 204 | * This interface represents a directory on a file system. 205 | */ 206 | interface DirectoryEntry extends Entry { 207 | /** 208 | * Creates a new DirectoryReader to read Entries from this Directory. 209 | */ 210 | createReader():DirectoryReader; 211 | 212 | /** 213 | * Creates or looks up a file. 214 | * @param path Either an absolute path or a relative path from this DirectoryEntry to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist. 215 | * @param options 216 | *
                    217 | *
                  • If create and exclusive are both true, and the path already exists, getFile must fail.
                  • 218 | *
                  • If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
                  • 219 | *
                  • If create is not true and the path doesn't exist, getFile must fail.
                  • 220 | *
                  • If create is not true and the path exists, but is a directory, getFile must fail.
                  • 221 | *
                  • Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.
                  • 222 | *
                  223 | * @param successCallback A callback that is called to return the File selected or created. 224 | * @param errorCallback A callback that is called when errors happen. 225 | */ 226 | getFile(path:string, options?:Flags, successCallback?:FileEntryCallback, errorCallback?:ErrorCallback):void; 227 | 228 | /** 229 | * Creates or looks up a directory. 230 | * @param path Either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist. 231 | * @param options 232 | *
                    233 | *
                  • If create and exclusive are both true and the path already exists, getDirectory must fail.
                  • 234 | *
                  • If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
                  • 235 | *
                  • If create is not true and the path doesn't exist, getDirectory must fail.
                  • 236 | *
                  • If create is not true and the path exists, but is a file, getDirectory must fail.
                  • 237 | *
                  • Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.
                  • 238 | *
                  239 | * @param successCallback A callback that is called to return the DirectoryEntry selected or created. 240 | * @param errorCallback A callback that is called when errors happen. 241 | * 242 | */ 243 | getDirectory(path:string, options?:Flags, successCallback?:DirectoryEntryCallback, errorCallback?:ErrorCallback):void; 244 | 245 | /** 246 | * Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem. 247 | * @param successCallback A callback that is called on success. 248 | * @param errorCallback A callback that is called when errors happen. 249 | */ 250 | removeRecursively(successCallback:VoidCallback, errorCallback?:ErrorCallback):void; 251 | } 252 | 253 | /** 254 | * This interface lets a user list files and directories in a directory. If there are no additions to or deletions from a directory between the first and last call to readEntries, and no errors occur, then: 255 | *
                    256 | *
                  • A series of calls to readEntries must return each entry in the directory exactly once.
                  • 257 | *
                  • Once all entries have been returned, the next call to readEntries must produce an empty array.
                  • 258 | *
                  • If not all entries have been returned, the array produced by readEntries must not be empty.
                  • 259 | *
                  • The entries produced by readEntries must not include the directory itself ["."] or its parent [".."].
                  • 260 | *
                  261 | */ 262 | interface DirectoryReader { 263 | /** 264 | * Read the next block of entries from this directory. 265 | * @param successCallback Called once per successful call to readEntries to deliver the next previously-unreported set of Entries in the associated Directory. If all Entries have already been returned from previous invocations of readEntries, successCallback must be called with a zero-length array as an argument. 266 | * @param errorCallback A callback indicating that there was an error reading from the Directory. 267 | */ 268 | readEntries(successCallback:EntriesCallback, errorCallback?:ErrorCallback):void; 269 | } 270 | 271 | /** 272 | * This interface represents a file on a file system. 273 | */ 274 | interface FileEntry extends Entry { 275 | /** 276 | * Creates a new FileWriter associated with the file that this FileEntry represents. 277 | * @param successCallback A callback that is called with the new FileWriter. 278 | * @param errorCallback A callback that is called when errors happen. 279 | */ 280 | createWriter(successCallback:FileWriterCallback, errorCallback?:ErrorCallback):void; 281 | 282 | /** 283 | * Returns a File that represents the current state of the file that this FileEntry represents. 284 | * @param successCallback A callback that is called with the File. 285 | * @param errorCallback A callback that is called when errors happen. 286 | */ 287 | file(successCallback:FileCallback, errorCallback?:ErrorCallback):void; 288 | } 289 | 290 | /** 291 | * When requestFileSystem() succeeds, the following callback is made. 292 | */ 293 | interface FileSystemCallback { 294 | /** 295 | * @param filesystem The file systems to which the app is granted access. 296 | */ 297 | (filesystem:FileSystem):void; 298 | } 299 | 300 | /** 301 | * This interface is the callback used to look up Entry objects. 302 | */ 303 | interface EntryCallback { 304 | /** 305 | * @param entry 306 | */ 307 | (entry:Entry):void; 308 | } 309 | 310 | /** 311 | * This interface is the callback used to look up FileEntry objects. 312 | */ 313 | interface FileEntryCallback { 314 | /** 315 | * @param entry 316 | */ 317 | (entry:FileEntry):void; 318 | } 319 | 320 | /** 321 | * This interface is the callback used to look up DirectoryEntry objects. 322 | */ 323 | interface DirectoryEntryCallback { 324 | /** 325 | * @param entry 326 | */ 327 | (entry:DirectoryEntry):void; 328 | } 329 | 330 | /** 331 | * When readEntries() succeeds, the following callback is made. 332 | */ 333 | interface EntriesCallback { 334 | (entries:Entry[]):void; 335 | } 336 | 337 | /** 338 | * This interface is the callback used to look up file and directory metadata. 339 | */ 340 | interface MetadataCallback { 341 | (metadata:Metadata):void; 342 | } 343 | 344 | /** 345 | * This interface is the callback used to create a FileWriter. 346 | */ 347 | interface FileWriterCallback { 348 | (fileWriter:FileWriter):void; 349 | } 350 | 351 | /** 352 | * This interface is the callback used to obtain a File. 353 | */ 354 | interface FileCallback { 355 | (file:File):void; 356 | } 357 | 358 | /** 359 | * This interface is the generic callback used to indicate success of an asynchronous method. 360 | */ 361 | interface VoidCallback { 362 | ():void; 363 | } 364 | 365 | /** 366 | * When an error occurs, the following callback is made. 367 | */ 368 | interface ErrorCallback { 369 | (err:DOMError):void; 370 | } 371 | 372 | 373 | /** 374 | * This interface represents a file system. 375 | */ 376 | interface FileSystemSync { 377 | /** 378 | * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems. 379 | */ 380 | name:string; 381 | 382 | /** 383 | * root The root directory of the file system. 384 | */ 385 | root:DirectoryEntrySync; 386 | } 387 | 388 | /** 389 | * An abstract interface representing entries in a file system, each of which may be a FileEntrySync or DirectoryEntrySync. 390 | */ 391 | interface EntrySync{ 392 | /** 393 | * EntrySync is a file. 394 | * @readonly 395 | */ 396 | isFile:boolean; 397 | 398 | /** 399 | * EntrySync is a directory. 400 | * @readonly 401 | */ 402 | isDirectory:boolean; 403 | 404 | /** 405 | * Look up metadata about this entry. 406 | */ 407 | getMetadata():Metadata; 408 | 409 | /** 410 | * The name of the entry, excluding the path leading to it. 411 | */ 412 | name:string; 413 | 414 | /** 415 | * The full absolute path from the root to the entry. 416 | */ 417 | fullPath:string; 418 | 419 | /** 420 | * The file system on which the entry resides. 421 | */ 422 | filesystem:FileSystemSync; 423 | 424 | /** 425 | * Move an entry to a different location on the file system. It is an error to try to: 426 | *
                    427 | *
                  • move a directory inside itself or to any child at any depth;
                  • 428 | *
                  • move an entry into its parent if a name different from its current one isn't provided;
                  • 429 | *
                  • move a file to a path occupied by a directory;
                  • 430 | *
                  • move a directory to a path occupied by a file;
                  • 431 | *
                  • move any element to a path occupied by a directory which is not empty.
                  • 432 | * 433 | * A move of a file on top of an existing file must attempt to delete and replace that file. A move of a directory on top of an existing empty directory must attempt to delete and replace that directory. 434 | * @param parent The directory to which to move the entry. 435 | * @param newName The new name of the entry. Defaults to the EntrySync's current name if unspecified. 436 | */ 437 | moveTo(parent:DirectoryEntrySync, newName?:string):EntrySync; 438 | 439 | /** 440 | * Copy an entry to a different location on the file system. It is an error to try to: 441 | *
                      442 | *
                    • copy a directory inside itself or to any child at any depth;
                    • 443 | *
                    • copy an entry into its parent if a name different from its current one isn't provided;
                    • 444 | *
                    • copy a file to a path occupied by a directory;
                    • 445 | *
                    • copy a directory to a path occupied by a file;
                    • 446 | *
                    • copy any element to a path occupied by a directory which is not empty.
                    • 447 | * 448 | * A copy of a file on top of an existing file must attempt to delete and replace that file. 449 | * A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory. 450 | * Directory copies are always recursive--that is, they copy all contents of the directory. 451 | */ 452 | copyTo(parent:DirectoryEntrySync, newName?:string):EntrySync; 453 | 454 | /** 455 | * Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists. 456 | */ 457 | toURL():string; 458 | 459 | /** 460 | * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem. 461 | */ 462 | remove ():void; 463 | 464 | /** 465 | * Look up the parent DirectoryEntrySync containing this Entry. If this EntrySync is the root of its filesystem, its parent is itself. 466 | */ 467 | getParent():DirectoryEntrySync; 468 | } 469 | 470 | /** 471 | * This interface represents a directory on a file system. 472 | */ 473 | interface DirectoryEntrySync extends EntrySync { 474 | /** 475 | * Creates a new DirectoryReaderSync to read EntrySyncs from this DirectorySync. 476 | */ 477 | createReader():DirectoryReaderSync; 478 | 479 | /** 480 | * Creates or looks up a directory. 481 | * @param path Either an absolute path or a relative path from this DirectoryEntrySync to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist. 482 | * @param options 483 | *
                        484 | *
                      • If create and exclusive are both true and the path already exists, getFile must fail.
                      • 485 | *
                      • If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
                      • 486 | *
                      • If create is not true and the path doesn't exist, getFile must fail.
                      • 487 | *
                      • If create is not true and the path exists, but is a directory, getFile must fail.
                      • 488 | *
                      • Otherwise, if no other error occurs, getFile must return a FileEntrySync corresponding to path.
                      • 489 | *
                      490 | */ 491 | getFile(path:string, options?:Flags):FileEntrySync; 492 | 493 | /** 494 | * Creates or looks up a directory. 495 | * @param path Either an absolute path or a relative path from this DirectoryEntrySync to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist. 496 | * @param options 497 | *
                        498 | *
                      • If create and exclusive are both true and the path already exists, getDirectory must fail.
                      • 499 | *
                      • If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
                      • 500 | *
                      • If create is not true and the path doesn't exist, getDirectory must fail.
                      • 501 | *
                      • If create is not true and the path exists, but is a file, getDirectory must fail.
                      • 502 | *
                      • Otherwise, if no other error occurs, getDirectory must return a DirectoryEntrySync corresponding to path.
                      • 503 | *
                      504 | */ 505 | getDirectory(path:string, options?:Flags):DirectoryEntrySync; 506 | 507 | /** 508 | * Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem. 509 | */ 510 | removeRecursively():void; 511 | } 512 | 513 | /** 514 | * This interface lets a user list files and directories in a directory. If there are no additions to or deletions from a directory between the first and last call to readEntries, and no errors occur, then: 515 | *
                        516 | *
                      • A series of calls to readEntries must return each entry in the directory exactly once.
                      • 517 | *
                      • Once all entries have been returned, the next call to readEntries must produce an empty array.
                      • 518 | *
                      • If not all entries have been returned, the array produced by readEntries must not be empty.
                      • 519 | *
                      • The entries produced by readEntries must not include the directory itself ["."] or its parent [".."].
                      • 520 | *
                      521 | */ 522 | interface DirectoryReaderSync { 523 | /** 524 | * Read the next block of entries from this directory. 525 | */ 526 | readEntries():EntrySync[]; 527 | } 528 | 529 | /** 530 | * This interface represents a file on a file system. 531 | */ 532 | interface FileEntrySync extends EntrySync { 533 | /** 534 | * Creates a new FileWriterSync associated with the file that this FileEntrySync represents. 535 | */ 536 | createWriter():FileWriterSync; 537 | 538 | /** 539 | * Returns a File that represents the current state of the file that this FileEntrySync represents. 540 | */ 541 | file():File; 542 | } 543 | 544 | interface Window extends LocalFileSystem, LocalFileSystemSync{ 545 | } 546 | 547 | interface WorkerGlobalScope extends LocalFileSystem, LocalFileSystemSync{ 548 | } 549 | --------------------------------------------------------------------------------