├── .node-version ├── .gitignore ├── .gitattributes ├── assets ├── img │ ├── about.png │ ├── diagram.png │ ├── intro.png │ ├── loading.gif │ ├── about@2x.png │ ├── programming.png │ ├── ui-terminology.png │ └── icons.svg ├── app-icon │ ├── png │ │ ├── 128.png │ │ ├── 16.png │ │ ├── 24.png │ │ ├── 256.png │ │ ├── 32.png │ │ ├── 48.png │ │ ├── 512.png │ │ ├── 64.png │ │ └── 1024.png │ ├── win │ │ └── app.ico │ └── mac │ │ └── app.icns ├── tiles │ ├── SampleAppx.44x44.png │ ├── SampleAppx.50x50.png │ ├── SampleAppx.150x150.png │ └── SampleAppx.310x150.png ├── css │ ├── fonts │ │ ├── SourceSansPro-It.otf │ │ ├── SourceSansPro-Bold.otf │ │ ├── SourceCodePro-Regular.ttf │ │ ├── SourceSansPro-Black.otf │ │ ├── SourceSansPro-BlackIt.otf │ │ ├── SourceSansPro-BoldIt.otf │ │ ├── SourceSansPro-Light.otf │ │ ├── SourceSansPro-LightIt.otf │ │ ├── SourceSansPro-Regular.otf │ │ ├── SourceSansPro-Semibold.otf │ │ ├── SourceSansPro-ExtraLight.otf │ │ ├── SourceSansPro-ExtraLightIt.otf │ │ └── SourceSansPro-SemiboldIt.otf │ ├── print.css │ ├── variables.css │ ├── nativize.css │ ├── section.css │ ├── github.css │ ├── nav.css │ ├── global.css │ ├── about.css │ └── demo.css ├── normalize-shortcuts.js ├── mac │ ├── child.plist │ ├── parent.plist │ └── info.plist ├── ex-links.js ├── index.js ├── imports.js ├── code-blocks.js ├── demo-btns.js └── nav.js ├── README.md ├── cli.js ├── sections └── print │ ├── print1.js │ ├── print2.js │ ├── print1.html │ └── print2.html ├── .travis.yml ├── index.html ├── script ├── windows-store.js ├── installer.js ├── mas.sh └── release.js ├── license.md ├── renderer-process └── print │ └── index.js ├── package.json ├── main.js └── LICENSE /.node-version: -------------------------------------------------------------------------------- 1 | v8.9.3 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | out 3 | npm-debug.log 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /assets/img/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/img/about.png -------------------------------------------------------------------------------- /assets/img/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/img/diagram.png -------------------------------------------------------------------------------- /assets/img/intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/img/intro.png -------------------------------------------------------------------------------- /assets/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/img/loading.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # electron-print-demo 2 | electron打印示例 3 | 4 | run 5 | ``` 6 | $ npm install 7 | $ npm start 8 | ``` -------------------------------------------------------------------------------- /assets/img/about@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/img/about@2x.png -------------------------------------------------------------------------------- /assets/app-icon/png/128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/128.png -------------------------------------------------------------------------------- /assets/app-icon/png/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/16.png -------------------------------------------------------------------------------- /assets/app-icon/png/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/24.png -------------------------------------------------------------------------------- /assets/app-icon/png/256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/256.png -------------------------------------------------------------------------------- /assets/app-icon/png/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/32.png -------------------------------------------------------------------------------- /assets/app-icon/png/48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/48.png -------------------------------------------------------------------------------- /assets/app-icon/png/512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/512.png -------------------------------------------------------------------------------- /assets/app-icon/png/64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/64.png -------------------------------------------------------------------------------- /assets/app-icon/win/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/win/app.ico -------------------------------------------------------------------------------- /assets/img/programming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/img/programming.png -------------------------------------------------------------------------------- /assets/app-icon/mac/app.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/mac/app.icns -------------------------------------------------------------------------------- /assets/app-icon/png/1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/app-icon/png/1024.png -------------------------------------------------------------------------------- /assets/img/ui-terminology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/img/ui-terminology.png -------------------------------------------------------------------------------- /assets/tiles/SampleAppx.44x44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/tiles/SampleAppx.44x44.png -------------------------------------------------------------------------------- /assets/tiles/SampleAppx.50x50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/tiles/SampleAppx.50x50.png -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-It.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-It.otf -------------------------------------------------------------------------------- /assets/tiles/SampleAppx.150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/tiles/SampleAppx.150x150.png -------------------------------------------------------------------------------- /assets/tiles/SampleAppx.310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/tiles/SampleAppx.310x150.png -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-Bold.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceCodePro-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceCodePro-Regular.ttf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-Black.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-Black.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-BlackIt.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-BlackIt.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-BoldIt.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-BoldIt.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-Light.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-Light.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-LightIt.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-LightIt.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-Regular.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-Semibold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-Semibold.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-ExtraLight.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-ExtraLight.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-ExtraLightIt.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-ExtraLightIt.otf -------------------------------------------------------------------------------- /assets/css/fonts/SourceSansPro-SemiboldIt.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConardLi/electron-print-demo/HEAD/assets/css/fonts/SourceSansPro-SemiboldIt.otf -------------------------------------------------------------------------------- /assets/normalize-shortcuts.js: -------------------------------------------------------------------------------- 1 | const normalize = require('electron-shortcut-normalizer') 2 | let shortcuts = document.querySelectorAll('kbd.normalize-to-platform') 3 | 4 | Array.prototype.forEach.call(shortcuts, (shortcut) => { 5 | shortcut.innerText = normalize(shortcut.innerText, process.platform) 6 | }) 7 | -------------------------------------------------------------------------------- /assets/mac/child.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.inherit 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const {spawn} = require('child_process') 4 | const electron = require('electron') 5 | const path = require('path') 6 | 7 | const appPath = path.join(__dirname, 'main.js') 8 | const args = [appPath].concat(process.argv.slice(2)) 9 | const proc = spawn(electron, args, {stdio: 'inherit'}) 10 | 11 | proc.on('close', (code) => process.exit(code)) 12 | -------------------------------------------------------------------------------- /assets/ex-links.js: -------------------------------------------------------------------------------- 1 | const shell = require('electron').shell 2 | 3 | const links = document.querySelectorAll('a[href]') 4 | 5 | Array.prototype.forEach.call(links, (link) => { 6 | const url = link.getAttribute('href') 7 | if (url.indexOf('http') === 0) { 8 | link.addEventListener('click', (e) => { 9 | e.preventDefault() 10 | shell.openExternal(url) 11 | }) 12 | } 13 | }) 14 | -------------------------------------------------------------------------------- /sections/print/print1.js: -------------------------------------------------------------------------------- 1 | const { ipcRenderer, BrowserWindow } = require('electron'); 2 | 3 | ipcRenderer.on('print-edit', (event, deviceName) => { 4 | let html = ''; 5 | for (let index = 0; index < 2; index++) { 6 | html+=`

${deviceName}hahahah

` 7 | } 8 | document.getElementById('bd').innerHTML = html; 9 | ipcRenderer.send('do', deviceName); 10 | }) 11 | 12 | -------------------------------------------------------------------------------- /sections/print/print2.js: -------------------------------------------------------------------------------- 1 | const {ipcRenderer} = require('electron') 2 | 3 | 4 | ipcRenderer.on('webview-print-render', (event,deviceName) => { 5 | console.log('收到'); 6 | //执行渲染 7 | let html = ''; 8 | for (let index = 0; index < 5; index++) { 9 | html+=`

${deviceName}hahahah

` 10 | } 11 | document.getElementById('bd').innerHTML = html; 12 | ipcRenderer.sendToHost('webview-print-do') 13 | }) 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "node" 5 | - "lts/*" 6 | 7 | before_script: 8 | - export DISPLAY=:99.0 9 | - sh -e /etc/init.d/xvfb start 10 | - sleep 3 11 | 12 | script: 13 | - npm test 14 | - npm run package:linux 15 | 16 | branches: 17 | only: 18 | - master 19 | 20 | cache: 21 | directories: 22 | - node_modules 23 | 24 | notifications: 25 | email: 26 | on_success: never 27 | on_failure: change 28 | -------------------------------------------------------------------------------- /assets/index.js: -------------------------------------------------------------------------------- 1 | const { BrowserWindow } = require('electron').remote 2 | const path = require('path') 3 | 4 | let demoWindow = null; 5 | 6 | document.getElementById('openDemo').addEventListener('click', () => { 7 | const windowOptions = { 8 | width: 1080, 9 | minWidth: 680, 10 | height: 840, 11 | title: 'api示例' 12 | } 13 | demoWindow = new BrowserWindow(windowOptions); 14 | demoWindow.loadURL(path.join('file://', __dirname, '../demo.html')) 15 | 16 | }) -------------------------------------------------------------------------------- /assets/imports.js: -------------------------------------------------------------------------------- 1 | const links = document.querySelectorAll('link[rel="import"]') 2 | 3 | // Import and add each page to the DOM 4 | Array.prototype.forEach.call(links, (link) => { 5 | let template = link.import.querySelector('.task-template') 6 | let clone = document.importNode(template.content, true) 7 | if (link.href.match('about.html')) { 8 | document.querySelector('body').appendChild(clone) 9 | } else { 10 | document.querySelector('.content').appendChild(clone) 11 | } 12 | }) 13 | -------------------------------------------------------------------------------- /assets/mac/parent.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.application-groups 8 | VEKTX9H2N7.com.github.electron-api-demos 9 | com.apple.security.files.user-selected.read-write 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /assets/mac/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleURLTypes 6 | 7 | 8 | CFBundleURLSchemes 9 | 10 | electron-api-demos 11 | 12 | CFBundleURLName 13 | Electron API Demos Protocol 14 | 15 | 16 | ElectronTeamID 17 | VEKTX9H2N7 18 | 19 | 20 | -------------------------------------------------------------------------------- /assets/css/print.css: -------------------------------------------------------------------------------- 1 | @media print { 2 | body { 3 | background: none; 4 | color: black !important; 5 | font-size: 70%; 6 | margin: 0; padding: 0; 7 | } 8 | 9 | .div1{ 10 | height: 30px; 11 | } 12 | p{ 13 | font-size: 30px; 14 | } 15 | 16 | h1 { 17 | font-size: 22px; 18 | } 19 | 20 | .nav, button, .demo-box:before, 21 | #pdf-path, header p { 22 | display: none; 23 | } 24 | 25 | .demo-box, h2, 26 | pre, code { 27 | padding: 0 !important; 28 | margin: 0 !important; 29 | } 30 | 31 | header { 32 | padding: 0 0 10px 0; 33 | } 34 | 35 | code, .support { 36 | font-size: 10px; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sections/print/print1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | -------------------------------------------------------------------------------- /sections/print/print2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 26 | 27 | 28 | 29 | 初始 30 | 31 | 32 | 35 | 36 | -------------------------------------------------------------------------------- /assets/code-blocks.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const path = require('path') 3 | 4 | const codeBlocksWithPaths = document.querySelectorAll('code[data-path]') 5 | 6 | Array.prototype.forEach.call(codeBlocksWithPaths, (code) => { 7 | const codePath = path.join(__dirname, '..', code.dataset.path) 8 | const extension = path.extname(codePath) 9 | code.classList.add(`language-${extension.substring(1)}`) 10 | code.textContent = fs.readFileSync(codePath) 11 | }) 12 | 13 | document.addEventListener('DOMContentLoaded', () => { 14 | const highlight = require('highlight.js') 15 | const codeBlocks = document.querySelectorAll('pre code') 16 | Array.prototype.forEach.call(codeBlocks, (code) => { 17 | highlight.highlightBlock(code) 18 | }) 19 | }) 20 | -------------------------------------------------------------------------------- /assets/css/variables.css: -------------------------------------------------------------------------------- 1 | 2 | /* Custom Properties */ 3 | 4 | :root { 5 | --color: hsl(0,0%,22%); 6 | --color-subtle: hsl(0,0%,44%); 7 | --color-strong: hsl(0,0%,11%); 8 | --color-link: hsl(0,0%,22%); 9 | 10 | --color-border: hsl(0,0%,88%); 11 | --color-bg: hsl(0,0%,96%); 12 | 13 | --color-accent: black; /* Fallback */ 14 | } 15 | 16 | 17 | /* Category Colors */ 18 | 19 | .u-category-windows { --color-accent: hsl(116, 30%, 36%); } 20 | .u-category-menu { --color-accent: hsl(194, 60%, 36%); } 21 | .u-category-native-ui { --color-accent: hsl(222, 53%, 50%); } 22 | .u-category-communication { --color-accent: hsl(285, 47%, 46%); } 23 | .u-category-system { --color-accent: hsl(330, 65%, 48%); } 24 | .u-category-media { --color-accent: hsl( 36, 77%, 34%); } 25 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 |
16 |
17 | 18 |
19 |
20 | 21 |
22 | 23 |
24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /script/windows-store.js: -------------------------------------------------------------------------------- 1 | const ChildProcess = require('child_process') 2 | const path = require('path') 3 | 4 | const metadata = require('../package') 5 | 6 | const command = path.join(__dirname, '..', 'node_modules', '.bin', 'electron-windows-store.cmd') 7 | const args = [ 8 | '--input-directory', 9 | path.join(__dirname, '..', 'out', 'ElectronAPIDemos-win32-ia32'), 10 | '--output-directory', 11 | path.join(__dirname, '..', 'out', 'windows-store'), 12 | '--flatten', 13 | true, 14 | '--package-version', 15 | metadata.version + '.0', 16 | '--package-name', 17 | metadata.name, 18 | '--package-display-name', 19 | metadata.productName, 20 | '--assets', 21 | path.join(__dirname, '..', 'assets', 'tiles'), 22 | '--package-description', 23 | metadata.description 24 | ] 25 | 26 | const windowsStore = ChildProcess.spawn(command, args, {stdio: 'inherit'}) 27 | windowsStore.on('close', (code) => { 28 | process.exit(code) 29 | }) 30 | -------------------------------------------------------------------------------- /assets/demo-btns.js: -------------------------------------------------------------------------------- 1 | const settings = require('electron-settings') 2 | 3 | const demoBtns = document.querySelectorAll('.js-container-target') 4 | // Listen for demo button clicks 5 | Array.prototype.forEach.call(demoBtns, (btn) => { 6 | btn.addEventListener('click', (event) => { 7 | const parent = event.target.parentElement 8 | 9 | // Toggles the "is-open" class on the demo's parent element. 10 | parent.classList.toggle('is-open') 11 | 12 | // Saves the active demo if it is open, or clears it if the demo was user 13 | // collapsed by the user 14 | if (parent.classList.contains('is-open')) { 15 | settings.set('activeDemoButtonId', event.target.getAttribute('id')) 16 | } else { 17 | settings.delete('activeDemoButtonId') 18 | } 19 | }) 20 | }) 21 | 22 | // Default to the demo that was active the last time the app was open 23 | const buttonId = settings.get('activeDemoButtonId') 24 | if (buttonId) { 25 | document.getElementById(buttonId).click() 26 | } 27 | -------------------------------------------------------------------------------- /assets/css/nativize.css: -------------------------------------------------------------------------------- 1 | /* 2 | ** nativize.css 3 | ** Makes the UI feel more native 4 | */ 5 | 6 | html { 7 | font-family: sans-serif; 8 | -webkit-user-select: none; /* disable selection */ 9 | -webkit-user-drag: none; /* disable dragging */ 10 | cursor: default; /* use default cursor */ 11 | } 12 | 13 | body { 14 | margin: 0; /* remove default margin */ 15 | } 16 | 17 | 18 | /* enable text selection */ 19 | 20 | .is-selectable, 21 | pre, 22 | code { 23 | -webkit-user-select: auto; 24 | cursor: auto; 25 | } 26 | 27 | 28 | /* Buttons and links */ 29 | 30 | button{ 31 | cursor: default; 32 | } 33 | 34 | /* Internal links */ 35 | a { 36 | cursor: pointer; 37 | text-decoration: none; 38 | border-bottom: 1px dashed; 39 | outline: none; 40 | } 41 | 42 | /* New window (target) + external links */ 43 | a[target], 44 | a[href^="https://"], 45 | a[href^="http://"] { 46 | border-bottom: 1px solid; 47 | } 48 | 49 | a:hover, 50 | a:focus { 51 | border-bottom: none; 52 | } 53 | 54 | 55 | /* Images */ 56 | 57 | img { 58 | -webkit-user-drag: none; /* disable dragging */ 59 | } 60 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2018 GitHub Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /renderer-process/print/index.js: -------------------------------------------------------------------------------- 1 | const { ipcRenderer } = require('electron'); 2 | 3 | const openPrintGT800 = document.getElementById('openPrintgt800'); 4 | const openPrintGK420 = document.getElementById('openPrintgk420'); 5 | const openPrintwebView = document.getElementById('openPrintwebView'); 6 | 7 | openPrintGT800.addEventListener('click', (event) => { 8 | ipcRenderer.send('print-start', 'GT800') 9 | }) 10 | 11 | openPrintwebView.addEventListener('click', (event) => { 12 | console.time('webview'); 13 | //告诉渲染进程,开始渲染打印内容 14 | const webview = document.querySelector('#printWebview') 15 | webview.send('webview-print-render', 'GT800') 16 | }) 17 | 18 | ipcRenderer.on('print-error', (event, err) => { 19 | alert(err); 20 | }) 21 | 22 | onload = () => { 23 | const webview = document.querySelector('#printWebview') 24 | webview.addEventListener('ipc-message', () => { 25 | if (event.channel === 'webview-print-do') { 26 | console.timeEnd('webview'); 27 | webview.print({ silent: true, printBackground: true, deviceName: 'GT800' }, 28 | (data) => { 29 | console.log("webview success", data); 30 | }) 31 | } 32 | }) 33 | } 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /assets/css/section.css: -------------------------------------------------------------------------------- 1 | /* Section ------------------ */ 2 | 3 | .section { 4 | position: absolute; 5 | top: 0; 6 | left: 0; 7 | right: 0; 8 | bottom: 0; 9 | overflow-x: hidden; 10 | overflow-y: auto; 11 | color: var(--color-accent); 12 | 13 | /* Hide */ 14 | pointer-events: none; 15 | visibility: hidden; 16 | opacity: 0; 17 | transform: translateX(-20px); 18 | transition: visibility 0s .12s linear , opacity .12s ease-in, transform .12s ease-in; 19 | } 20 | .section.is-shown { 21 | pointer-events: auto; 22 | visibility: visible; 23 | opacity: 1; 24 | transform: translateX(0); 25 | transition: visibility 0s 0s linear , opacity .36s ease-out, transform .36s ease-out; 26 | } 27 | 28 | .section h3, 29 | .section p { 30 | color: var(--color); 31 | } 32 | 33 | .section-wrapper { 34 | position: relative; 35 | max-width: 740px; 36 | margin: 0 auto; 37 | padding: 2rem 2rem 1rem 2rem; 38 | border-bottom: 1px solid var(--color-border); 39 | } 40 | @media (min-width: 940px) { 41 | .section-wrapper { 42 | padding-top: 4rem; 43 | } 44 | } 45 | 46 | .section-icon { 47 | width: 32px; 48 | height: 32px; 49 | vertical-align: middle; 50 | margin-right: .5em; 51 | } 52 | -------------------------------------------------------------------------------- /script/installer.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const createWindowsInstaller = require('electron-winstaller').createWindowsInstaller 4 | const path = require('path') 5 | const rimraf = require('rimraf') 6 | 7 | deleteOutputFolder() 8 | .then(getInstallerConfig) 9 | .then(createWindowsInstaller) 10 | .catch((error) => { 11 | console.error(error.message || error) 12 | process.exit(1) 13 | }) 14 | 15 | function getInstallerConfig () { 16 | const rootPath = path.join(__dirname, '..') 17 | const outPath = path.join(rootPath, 'out') 18 | 19 | return Promise.resolve({ 20 | appDirectory: path.join(outPath, 'Electron API Demos-win32-ia32'), 21 | exe: 'Electron API Demos.exe', 22 | iconUrl: 'https://raw.githubusercontent.com/electron/electron-api-demos/master/assets/app-icon/win/app.ico', 23 | loadingGif: path.join(rootPath, 'assets', 'img', 'loading.gif'), 24 | noMsi: true, 25 | outputDirectory: path.join(outPath, 'windows-installer'), 26 | setupExe: 'ElectronAPIDemosSetup.exe', 27 | setupIcon: path.join(rootPath, 'assets', 'app-icon', 'win', 'app.ico'), 28 | skipUpdateIcon: true 29 | }) 30 | } 31 | 32 | function deleteOutputFolder () { 33 | return new Promise((resolve, reject) => { 34 | rimraf(path.join(__dirname, '..', 'out', 'windows-installer'), (error) => { 35 | error ? reject(error) : resolve() 36 | }) 37 | }) 38 | } 39 | -------------------------------------------------------------------------------- /assets/css/github.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | github.com style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | color: #333; 12 | background: #f8f8f8; 13 | } 14 | 15 | .hljs-comment, 16 | .hljs-quote { 17 | color: #998; 18 | font-style: italic; 19 | } 20 | 21 | .hljs-keyword, 22 | .hljs-selector-tag, 23 | .hljs-subst { 24 | color: #333; 25 | font-weight: bold; 26 | } 27 | 28 | .hljs-number, 29 | .hljs-literal, 30 | .hljs-variable, 31 | .hljs-template-variable, 32 | .hljs-tag .hljs-attr { 33 | color: #008080; 34 | } 35 | 36 | .hljs-string, 37 | .hljs-doctag { 38 | color: #d14; 39 | } 40 | 41 | .hljs-title, 42 | .hljs-section, 43 | .hljs-selector-id { 44 | color: #900; 45 | font-weight: bold; 46 | } 47 | 48 | .hljs-subst { 49 | font-weight: normal; 50 | } 51 | 52 | .hljs-type, 53 | .hljs-class .hljs-title { 54 | color: #458; 55 | font-weight: bold; 56 | } 57 | 58 | .hljs-tag, 59 | .hljs-name, 60 | .hljs-attribute { 61 | color: #000080; 62 | font-weight: normal; 63 | } 64 | 65 | .hljs-regexp, 66 | .hljs-link { 67 | color: #009926; 68 | } 69 | 70 | .hljs-symbol, 71 | .hljs-bullet { 72 | color: #990073; 73 | } 74 | 75 | .hljs-built_in, 76 | .hljs-builtin-name { 77 | color: #0086b3; 78 | } 79 | 80 | .hljs-meta { 81 | color: #999; 82 | font-weight: bold; 83 | } 84 | 85 | .hljs-deletion { 86 | background: #fdd; 87 | } 88 | 89 | .hljs-addition { 90 | background: #dfd; 91 | } 92 | 93 | .hljs-emphasis { 94 | font-style: italic; 95 | } 96 | 97 | .hljs-strong { 98 | font-weight: bold; 99 | } 100 | -------------------------------------------------------------------------------- /script/mas.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | # App Store does not allow the word "demos" in the app's name 6 | APP="Electron APIs" 7 | 8 | electron-packager . \ 9 | "$APP" \ 10 | --asar \ 11 | --asar-unpack=protocol-link.html \ 12 | --overwrite \ 13 | --platform=mas \ 14 | --app-bundle-id=com.github.electron-api-demos \ 15 | --app-version="$npm_package_version" \ 16 | --build-version="1.1.0" \ 17 | --arch=x64 \ 18 | --icon=assets/app-icon/mac/app.icns \ 19 | --prune=true \ 20 | --out=out \ 21 | --extend-info=assets/mac/info.plist 22 | 23 | APP_PATH="./out/$APP-mas-x64/$APP.app" 24 | RESULT_PATH="./out/$APP.pkg" 25 | APP_KEY="3rd Party Mac Developer Application: GitHub (VEKTX9H2N7)" 26 | INSTALLER_KEY="3rd Party Mac Developer Installer: GitHub (VEKTX9H2N7)" 27 | FRAMEWORKS_PATH="$APP_PATH/Contents/Frameworks" 28 | CHILD_PLIST="./assets/mac/child.plist" 29 | PARENT_PLIST="./assets/mac/parent.plist" 30 | 31 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Electron Framework" 32 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib" 33 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Libraries/libnode.dylib" 34 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework" 35 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/Contents/MacOS/$APP Helper" 36 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/" 37 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper EH.app/Contents/MacOS/$APP Helper EH" 38 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper EH.app/" 39 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper NP.app/Contents/MacOS/$APP Helper NP" 40 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper NP.app/" 41 | codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$APP_PATH/Contents/MacOS/$APP" 42 | 43 | codesign -s "$APP_KEY" -f --entitlements "$PARENT_PLIST" "$APP_PATH" 44 | 45 | productbuild --component "$APP_PATH" /Applications --sign "$INSTALLER_KEY" "$RESULT_PATH" 46 | -------------------------------------------------------------------------------- /assets/nav.js: -------------------------------------------------------------------------------- 1 | const settings = require('electron-settings') 2 | 3 | document.body.addEventListener('click', (event) => { 4 | if (event.target.dataset.section) { 5 | handleSectionTrigger(event) 6 | } else if (event.target.dataset.modal) { 7 | handleModalTrigger(event) 8 | } else if (event.target.classList.contains('modal-hide')) { 9 | hideAllModals() 10 | } 11 | }) 12 | 13 | function handleSectionTrigger(event) { 14 | hideAllSectionsAndDeselectButtons() 15 | 16 | // Highlight clicked button and show view 17 | event.target.classList.add('is-selected') 18 | 19 | // Display the current section 20 | const sectionId = `${event.target.dataset.section}-section` 21 | document.getElementById(sectionId).classList.add('is-shown') 22 | 23 | // Save currently active button in localStorage 24 | const buttonId = event.target.getAttribute('id') 25 | settings.set('activeSectionButtonId', buttonId) 26 | } 27 | 28 | function activateDefaultSection() { 29 | document.getElementById('button-windows').click() 30 | } 31 | 32 | function showMainContent() { 33 | document.querySelector('.js-nav').classList.add('is-shown') 34 | document.querySelector('.js-content').classList.add('is-shown') 35 | } 36 | 37 | function handleModalTrigger(event) { 38 | hideAllModals() 39 | const modalId = `${event.target.dataset.modal}-modal` 40 | document.getElementById(modalId).classList.add('is-shown') 41 | } 42 | 43 | function hideAllModals() { 44 | const modals = document.querySelectorAll('.modal.is-shown') 45 | Array.prototype.forEach.call(modals, (modal) => { 46 | modal.classList.remove('is-shown') 47 | }) 48 | showMainContent() 49 | } 50 | 51 | function hideAllSectionsAndDeselectButtons() { 52 | const sections = document.querySelectorAll('.js-section.is-shown') 53 | Array.prototype.forEach.call(sections, (section) => { 54 | section.classList.remove('is-shown') 55 | }) 56 | 57 | const buttons = document.querySelectorAll('.nav-button.is-selected') 58 | Array.prototype.forEach.call(buttons, (button) => { 59 | button.classList.remove('is-selected') 60 | }) 61 | } 62 | 63 | function displayAbout() { 64 | document.querySelector('#about-modal').classList.add('is-shown') 65 | } 66 | 67 | // Default to the view that was active the last time the app was open 68 | const sectionId = settings.get('activeSectionButtonId') 69 | if (sectionId) { 70 | showMainContent() 71 | const section = document.getElementById(sectionId) 72 | if (section) section.click() 73 | } else { 74 | activateDefaultSection() 75 | displayAbout() 76 | } 77 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "electron-api-demos", 3 | "productName": "Electron API 示例", 4 | "version": "1.5.1", 5 | "description": "Electron interactive API demos", 6 | "main": "main.js", 7 | "bin": "cli.js", 8 | "scripts": { 9 | "start": "electron .", 10 | "dev": "electron . --debug", 11 | "test": "mocha && standard", 12 | "package": "npm-run-all package:*", 13 | "package:mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --out=out --icon=assets/app-icon/mac/app.icns --osx-sign.identity='Developer ID Application: GitHub' --extend-info=assets/mac/info.plist", 14 | "package:win": "electron-packager . --overwrite --platform=win32 --arch=ia32 --out=out --icon=assets/app-icon/win/app.ico", 15 | "package:linux": "electron-packager . --overwrite --platform=linux --arch=x64 --out=out", 16 | "package:sign-exe": "signcode './out/Electron API Demos-win32-ia32/Electron API Demos.exe' --cert ~/electron-api-demos.p12 --prompt --name 'Electron API Demos' --url 'http://electron.atom.io'", 17 | "package:installer": "node ./script/installer.js", 18 | "package:sign-installer": "signcode './out/windows-installer/ElectronAPIDemosSetup.exe' --cert ~/electron-api-demos.p12 --prompt --name 'Electron API Demos' --url 'http://electron.atom.io'", 19 | "xpackage:mas": "./script/mas.sh", 20 | "windows-store": "node ./script/windows-store.js", 21 | "release": "node ./script/release.js", 22 | "prepack": "check-for-leaks", 23 | "prepush": "check-for-leaks" 24 | }, 25 | "repository": "https://github.com/electron/electron-api-demos", 26 | "keywords": [ 27 | "Electron", 28 | "API", 29 | "demo" 30 | ], 31 | "author": "GitHub", 32 | "license": "MIT", 33 | "devDependencies": { 34 | "chai": "^3.4.1", 35 | "chai-as-promised": "^6.0.0", 36 | "check-for-leaks": "^1.2.0", 37 | "devtron": "^1.3.0", 38 | "electron-packager": "^12.1.0", 39 | "electron-winstaller": "^2.2.0", 40 | "husky": "^0.14.3", 41 | "mocha": "^5.2.0", 42 | "npm-run-all": "^4.0.2", 43 | "request": "^2.70.0", 44 | "rimraf": "^2.5.2", 45 | "signcode": "^0.5.0", 46 | "spectron": "^3.8.0", 47 | "standard": "^8.2.0" 48 | }, 49 | "dependencies": { 50 | "electron": "^2.0.0", 51 | "electron-log": "^2.2.14", 52 | "electron-settings": "^3.0.7", 53 | "electron-shortcut-normalizer": "^1.0.0", 54 | "glob": "^7.1.0", 55 | "highlight.js": "^9.3.0", 56 | "update-electron-app": "^1.1.1" 57 | }, 58 | "standard": { 59 | "env": { 60 | "mocha": true 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /assets/css/nav.css: -------------------------------------------------------------------------------- 1 | /* Nav */ 2 | 3 | .nav { 4 | width: 340px; 5 | overflow-x: hidden; 6 | overflow-y: auto; 7 | color: var(--color-subtle); 8 | border-right: 1px solid var(--color-border); 9 | background-color: var(--color-bg); 10 | visibility: hidden; 11 | opacity: 0; 12 | } 13 | .nav.is-shown { 14 | visibility: visible;; 15 | opacity: 1; 16 | } 17 | 18 | .nav-header { 19 | position: relative; 20 | padding: 2rem; 21 | margin-bottom: 1rem; 22 | border-bottom: 1px solid var(--color-border); 23 | } 24 | 25 | .nav-title { 26 | text-transform: uppercase; 27 | font-weight: 300; 28 | line-height: 1; 29 | margin: 0; 30 | } 31 | 32 | .nav-title strong { 33 | font-weight: 600; 34 | color: var(--color-strong); 35 | } 36 | 37 | .nav-header-icon { 38 | position: absolute; 39 | width: 36px; 40 | height: 36px; 41 | top: 1.5rem; /* magic */ 42 | right: 1.75rem; /* magic */ 43 | } 44 | 45 | 46 | 47 | .nav-item { 48 | padding: .5em 0; 49 | } 50 | 51 | .nav-icon { 52 | width: 16px; 53 | height: 16px; 54 | vertical-align: top; 55 | margin-right: .25rem; 56 | } 57 | 58 | .nav-category { 59 | margin: .2em 0; 60 | padding-left: 2rem; 61 | font-size: 11px; 62 | font-weight: normal; 63 | text-transform: uppercase; 64 | } 65 | 66 | .nav-button { 67 | display: block; 68 | width: 100%; 69 | padding: .3rem; 70 | padding-left: calc(2rem + 16px + .5rem); /* padding + icon + magic */ 71 | line-height: 2; 72 | text-align: left; 73 | font: inherit; 74 | font-size: 13px; 75 | color: inherit; 76 | border: none; 77 | background-color: transparent; 78 | cursor: default; 79 | outline: none; 80 | } 81 | .nav-button:hover, 82 | .nav-button:focus:not(.is-selected) { 83 | background-color: hsla(0,0%,0%,.1); 84 | } 85 | .nav-button.is-selected { 86 | background-color: var(--color-accent); 87 | } 88 | .nav-button.is-selected, 89 | .nav-button.is-selected em { 90 | color: #fff; 91 | } 92 | .nav-button.is-selected:focus { 93 | opacity: .8; 94 | } 95 | 96 | .nav-button em { 97 | font-style: normal; 98 | font-weight: 600; 99 | color: var(--color-strong); 100 | pointer-events: none; /* makes it invisible to clicks */ 101 | } 102 | 103 | .nav-footer { 104 | margin-top: 1rem; 105 | padding: 2rem; 106 | border-top: 1px solid var(--color-border); 107 | text-align: center; 108 | } 109 | 110 | .nav-footer-icon { 111 | width: calc(770px / 6.5); 112 | height: calc(88px / 6.5); 113 | } 114 | 115 | .nav-footer a { 116 | outline: none; 117 | } 118 | 119 | .nav-footer-button { 120 | display: block; 121 | width: 100%; 122 | padding: 0; 123 | margin-bottom: .75rem; 124 | line-height: 2; 125 | text-align: left; 126 | font: inherit; 127 | font-size: 13px; 128 | color: inherit; 129 | border: none; 130 | background-color: transparent; 131 | cursor: default; 132 | outline: none; 133 | text-align: center; 134 | } 135 | .nav-footer-button:focus { 136 | color: var(--color-strong); 137 | } 138 | 139 | .nav-footer-logo { 140 | color: hsl(0,0%,66%); 141 | } 142 | .nav-footer-logo:focus { 143 | color: hsl(0,0%,33%); 144 | } 145 | 146 | /* Remove border on the logo */ 147 | .nav-footer-logo.nav-footer-logo { 148 | border-bottom: none; 149 | } 150 | -------------------------------------------------------------------------------- /assets/css/global.css: -------------------------------------------------------------------------------- 1 | /* Fonts ---------------------------- */ 2 | 3 | @font-face { 4 | font-family: 'Source Code Pro'; 5 | font-style: normal; 6 | font-weight: 400; 7 | src: local('Source Code Pro'), local('SourceCodePro'), url(fonts/SourceCodePro-Regular.ttf) format('truetype'); 8 | } 9 | 10 | 11 | /* Global ---------------------------- */ 12 | 13 | * { 14 | box-sizing: border-box; 15 | } 16 | 17 | html { 18 | height: 100%; 19 | font-family: 'BlinkMacSystemFont', 'Lucida Grande', 'Segoe UI', Ubuntu, Cantarell, sans-serif; 20 | font-size: 14px; 21 | line-height: 1.5; 22 | overflow: hidden; /* Prevents rubber-band scrolling of the whole "page" */ 23 | color: var(--color); 24 | background-color: #fff; /* To cover OSes with no default background color */ 25 | } 26 | 27 | body { 28 | margin: 0; 29 | height: 100%; 30 | display: flex; 31 | } 32 | 33 | a { 34 | color: var(--color-link); 35 | } 36 | 37 | h1, 38 | h2, 39 | h3 { 40 | margin-top: 0; 41 | line-height: 1.5; 42 | } 43 | 44 | h1 { 45 | font-size: 1.5em; 46 | font-weight: 600; 47 | } 48 | 49 | h2 { 50 | font-size: 1.3em; 51 | font-weight: normal; 52 | } 53 | 54 | h3 { 55 | font-size: 1.12em; 56 | font-weight: 600; 57 | } 58 | 59 | table { 60 | width: 100%; 61 | border-spacing: 0; 62 | border: 1px solid hsla(0,0%,0%,.08); 63 | border-width: 0 1px 1px 0; 64 | } 65 | th { 66 | background-color: hsla(0,0%,50%,.06); 67 | } 68 | th, 69 | td { 70 | text-align: center; 71 | border: 1px solid hsla(0,0%,0%,.08); 72 | border-width: 1px 0 0 1px; 73 | } 74 | 75 | svg { 76 | fill: currentColor; 77 | } 78 | 79 | /* Code */ 80 | 81 | code, kbd { 82 | font-family: 'Source Code Pro', monospace; 83 | border-radius: 4px; 84 | padding: 1px 4px; 85 | white-space: nowrap; 86 | color: hsl(0,0%,36%); 87 | background-color: hsla(0,0%,60%,.15); 88 | } 89 | 90 | pre, kbd { 91 | font-size: 13px; 92 | overflow: auto; 93 | padding: 1em; 94 | margin: 0; 95 | border-radius: 4px; 96 | border: 1px solid; 97 | border-color: var(--color-border); 98 | background-color: white; 99 | } 100 | 101 | pre code { 102 | white-space: pre; 103 | } 104 | 105 | pre > .hljs { 106 | color: var(--color-subtle); 107 | background-color: white; 108 | } 109 | 110 | kbd { 111 | padding: 0.5em; 112 | } 113 | 114 | 115 | /* Utilities ---------------------------- */ 116 | 117 | .u-avoid-clicks { 118 | pointer-events: none; 119 | } 120 | 121 | /* Visually hidden, but will be read by screen readers */ 122 | .u-visible-to-screen-reader { 123 | position: absolute; 124 | width: 1px; 125 | height: 1px; 126 | padding: 0; 127 | margin: -1px; 128 | overflow: hidden; 129 | clip: rect(0, 0, 0, 0); 130 | border: 0; 131 | } 132 | 133 | .no-display { 134 | display: none; 135 | } 136 | 137 | 138 | /* Content ------------------ */ 139 | 140 | .content { 141 | flex: 1; 142 | position: relative; 143 | overflow: hidden; 144 | visibility: hidden; 145 | opacity: 0; 146 | } 147 | .content.is-shown { 148 | visibility: visible;; 149 | opacity: 1; 150 | } 151 | 152 | 153 | /* Hacks ---------------------------- */ 154 | 155 | /* Fixes horizontal scrolling in code blocks on OS X El Cap (10.11.3), retina screen 156 | * 157 | * By adding an invisible outline property, it will force a repaint 158 | * which enables the scrolling. 159 | */ 160 | 161 | .hljs:hover, 162 | .hljs:active { 163 | outline: 1px solid transparent; 164 | } 165 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | require('update-electron-app')({ 2 | logger: require('electron-log') 3 | }) 4 | 5 | const path = require('path') 6 | const glob = require('glob') 7 | const { app, BrowserWindow, ipcMain } = require('electron') 8 | 9 | const debug = /--debug/.test(process.argv[2]) 10 | 11 | if (process.mas) app.setName('Electron APIs') 12 | 13 | let mainWindow = null 14 | let demoWindow = null; 15 | 16 | function initialize() { 17 | const shouldQuit = makeSingleInstance() 18 | if (shouldQuit) return app.quit() 19 | 20 | loadDemos() 21 | 22 | function createWindow() { 23 | const windowOptions = { 24 | width: 1080, 25 | minWidth: 680, 26 | height: 840, 27 | title: app.getName(), 28 | } 29 | 30 | if (process.platform === 'linux') { 31 | windowOptions.icon = path.join(__dirname, '/assets/app-icon/png/512.png') 32 | } 33 | 34 | mainWindow = new BrowserWindow(windowOptions) 35 | mainWindow.loadURL(path.join('file://', __dirname, '/index.html')) 36 | 37 | // Launch fullscreen with DevTools open, usage: npm run debug 38 | if (debug) { 39 | mainWindow.webContents.openDevTools() 40 | mainWindow.maximize() 41 | require('devtron').install() 42 | } 43 | 44 | mainWindow.on('closed', () => { 45 | mainWindow = null 46 | }) 47 | 48 | console.log(BrowserWindow.fromId(1)); 49 | } 50 | 51 | function createPrintWindow() { 52 | const windowOptions = { 53 | width: 100, 54 | height: 100, 55 | title: '打印页', 56 | show: false, 57 | } 58 | demoWindow = new BrowserWindow(windowOptions); 59 | demoWindow.loadURL(path.join('file://', __dirname, './sections/print/print1.html')); 60 | 61 | initPrintEvent(); 62 | } 63 | 64 | function initPrintEvent() { 65 | ipcMain.on('print-start', (event, deviceName) => { 66 | console.log('print-start'); 67 | demoWindow.webContents.send('print-edit', deviceName); 68 | }) 69 | 70 | ipcMain.on('do', (event, deviceName) => { 71 | const printers = demoWindow.webContents.getPrinters(); 72 | printers.forEach(element => { 73 | if (element.name === deviceName) { 74 | console.log(element); 75 | } 76 | if (element.name === deviceName && element.status != 0) { 77 | mainWindow.send('print-error', deviceName + '打印机异常'); 78 | return; 79 | } 80 | }); 81 | demoWindow.webContents.print({ silent: true, printBackground: true, deviceName: deviceName }, 82 | (data) => { 83 | console.log("回调", data); 84 | event.sender.send('print-successs') 85 | }) 86 | }) 87 | } 88 | 89 | app.on('ready', () => { 90 | createWindow() 91 | createPrintWindow() 92 | }) 93 | 94 | app.on('window-all-closed', () => { 95 | if (process.platform !== 'darwin') { 96 | app.quit() 97 | } 98 | }) 99 | 100 | app.on('activate', () => { 101 | if (mainWindow === null) { 102 | createWindow() 103 | } 104 | }) 105 | } 106 | 107 | // Make this app a single instance app. 108 | // 109 | // The main window will be restored and focused instead of a second window 110 | // opened when a person attempts to launch a second instance. 111 | // 112 | // Returns true if the current version of the app should quit instead of 113 | // launching. 114 | function makeSingleInstance() { 115 | if (process.mas) return false 116 | 117 | return app.makeSingleInstance(() => { 118 | if (mainWindow) { 119 | if (mainWindow.isMinimized()) mainWindow.restore() 120 | mainWindow.focus() 121 | } 122 | }) 123 | } 124 | 125 | // Require each JS file in the main-process dir 126 | function loadDemos() { 127 | const files = glob.sync(path.join(__dirname, 'main-process/**/*.js')) 128 | files.forEach((file) => { require(file) }) 129 | } 130 | 131 | initialize() 132 | -------------------------------------------------------------------------------- /assets/css/about.css: -------------------------------------------------------------------------------- 1 | /* Welcome ------------------------ */ 2 | 3 | .about { 4 | --about-space: 4rem; 5 | 6 | position: absolute; 7 | display: flex; 8 | top: 0; 9 | left: 0; 10 | right: 0; 11 | bottom: 0; 12 | z-index: 1; 13 | overflow-x: hidden; 14 | overflow-y: auto; 15 | padding: 0; 16 | background-color: hsl(0,0%,98%); 17 | pointer-events: none; 18 | visibility: hidden; 19 | opacity: 0; 20 | transform: scale(1.1); 21 | transition: visibility 0s .12s linear , opacity .12s ease-in, transform .12s ease-in; 22 | } 23 | .about.is-shown { 24 | pointer-events: auto; 25 | visibility: visible; 26 | opacity: 1; 27 | transform: scale(1); 28 | transition: visibility 0s 0s linear , opacity .24s ease-out, transform .24s ease-out; 29 | } 30 | 31 | .about-wrapper { 32 | margin: auto; 33 | } 34 | 35 | .about-header { 36 | padding: var(--about-space) 0; 37 | border-bottom: 1px solid hsl(0,0%,88%); 38 | } 39 | 40 | .about-logo { 41 | display: block; 42 | margin: 0 auto; 43 | width: 320px; /* TODO: Adjust asset to this size */ 44 | max-width: 100%; 45 | } 46 | 47 | .about-sections { 48 | max-width: 680px; 49 | padding: 0 var(--about-space); 50 | } 51 | 52 | .about-section { 53 | margin: var(--about-space) 0; 54 | } 55 | 56 | .about h2 { 57 | text-align: center; 58 | margin: 0 0 1em 0; 59 | font-size: 1.5em; 60 | color: hsl(0, 0%, 55%); 61 | } 62 | 63 | .about .about-code h2 { 64 | color: hsl(330, 65%, 55%); 65 | } 66 | 67 | .about .play-along h2 { 68 | color: hsl(222, 53%, 50%); 69 | } 70 | 71 | .about-button { 72 | display: block; 73 | margin: 0 auto; 74 | padding: .4em 1.2em; 75 | font: inherit; 76 | font-size: 1.6em; 77 | color: inherit; 78 | border: 2px solid; 79 | border-radius: 4px; 80 | background-color: transparent; 81 | } 82 | .about-button:focus { 83 | outline: none; 84 | border-color: hsl(0,0%,88%); 85 | } 86 | 87 | footer.about-section { 88 | text-align: center; 89 | } 90 | 91 | .rainbow-button-wrapper { 92 | --rainbow-button-width: 170px; 93 | --rainbow-button-height: 50px; 94 | --rainbow-button-width-inner: 164px; 95 | --rainbow-button-height-inner: 44px; 96 | --rainbow-color-1: hsl(116, 30%, 36%); 97 | --rainbow-color-2: hsl(194, 60%, 36%); 98 | --rainbow-color-3: hsl(222, 53%, 50%); 99 | --rainbow-color-4: hsl(285, 47%, 46%); 100 | --rainbow-color-5: hsl(330, 65%, 48%); 101 | --rainbow-color-6: hsl(32, 79%, 49%); 102 | --rainbow-color-7: hsl(53, 84%, 50%); 103 | 104 | display: inline-block; 105 | width: var(--rainbow-button-width); 106 | height: var(--rainbow-button-height); 107 | position: relative; 108 | overflow: hidden; 109 | border-radius: 5px; 110 | } 111 | 112 | .rainbow-button-wrapper:before { 113 | display: block; 114 | position: absolute; 115 | z-index: 2; 116 | top: 0; 117 | left: 0; 118 | width: 600px; 119 | height: var(--rainbow-button-height); 120 | background: #CCC; 121 | background: linear-gradient(to right, var(--rainbow-color-1) 0%, var(--rainbow-color-2) 14%, var(--rainbow-color-3) 28%, var(--rainbow-color-4) 42%, var(--rainbow-color-5) 56%, var(--rainbow-color-6) 70%, var(--rainbow-color-7) 84%, var(--rainbow-color-1) 100%); 122 | background-position: -200px 0; 123 | transition: all 0.5s; 124 | content: ""; 125 | } 126 | 127 | .rainbow-button-wrapper button { 128 | display: block; 129 | width: var(--rainbow-button-width-inner); 130 | height: var(--rainbow-button-height-inner); 131 | position: absolute; 132 | z-index: 3; 133 | top: 3px; 134 | left: 3px; 135 | border: none; 136 | background: white; 137 | color: black; 138 | font-size: 1.3rem; 139 | } 140 | 141 | .rainbow-button-wrapper:hover:before { 142 | background-position: 200px 0; 143 | } 144 | 145 | @media (min-width: 940px) { 146 | .about-header { 147 | align-self: center; 148 | padding: var(--about-space); 149 | border-right: 1px solid hsl(0,0%,88%); 150 | border-bottom: none; 151 | } 152 | .about-wrapper { 153 | display: flex; 154 | } 155 | } 156 | 157 | .container{ 158 | margin-top: 20px; 159 | } -------------------------------------------------------------------------------- /assets/css/demo.css: -------------------------------------------------------------------------------- 1 | /* Demo */ 2 | 3 | .demo:first-of-type { 4 | margin-top: 2rem; 5 | } 6 | .demo:last-of-type { 7 | margin-bottom: 2rem; 8 | } 9 | @media (min-width: 940px) { 10 | .demo:last-of-type { 11 | margin-bottom: 4rem; 12 | } 13 | } 14 | 15 | .demo-wrapper { 16 | position: relative; 17 | max-width: 740px; 18 | margin: 0 auto; 19 | padding: 0 2rem; 20 | } 21 | 22 | 23 | /* Toggle Button ----------------------------- */ 24 | 25 | .demo-toggle-button { 26 | position: relative; 27 | display: block; 28 | margin: 0; 29 | padding: .5em 1.5em; 30 | line-height: 1.5; 31 | font: inherit; 32 | font-weight: 600; 33 | font-size: 1.2em; 34 | text-align: left; 35 | border: none; 36 | color: inherit; 37 | background-color: transparent; 38 | transition: border-color .12s; 39 | outline: none; 40 | } 41 | 42 | .demo-toggle-button:before, 43 | .demo-toggle-button:after { 44 | content: ""; 45 | position: absolute; 46 | left: 0; 47 | width: 2px; 48 | height: 50%; 49 | background-color: hsl(0,0%,88%); 50 | transition: transform .2s cubic-bezier(.4,.1,0,1); 51 | } 52 | .demo-toggle-button:before { 53 | top: 0; 54 | transform-origin: bottom center; 55 | transform: translateX(.7em) rotate(-30deg) scale(.75); 56 | } 57 | .demo-toggle-button:after { 58 | bottom: 0; 59 | transform-origin: top center; 60 | transform: translateX(.7em) rotate(30deg) scale(.75); 61 | } 62 | .is-open .demo-toggle-button:before, 63 | .is-open .demo-toggle-button:after { 64 | transform: rotate(0deg); 65 | } 66 | .demo-toggle-button:focus:before, 67 | .demo-toggle-button:focus:after { 68 | background-color: currentColor; 69 | } 70 | 71 | /* Meta info */ 72 | 73 | .demo-meta { 74 | margin-top: .2em; 75 | font-size: 11px; 76 | font-weight: 300; 77 | text-transform: uppercase; 78 | color: var(--color-subtle); 79 | } 80 | .demo-meta-divider { 81 | margin: 0 .5em; 82 | } 83 | 84 | 85 | /* Demo Box ----------------------------- */ 86 | 87 | .demo-box { 88 | display: none; 89 | position: relative; 90 | padding: 2em; 91 | margin-top: 1em; 92 | margin-bottom: 2em; 93 | border-radius: 6px; 94 | border: 1px solid var(--color-border); 95 | background-color: var(--color-bg); 96 | } 97 | .demo-box:before { 98 | content: ""; 99 | position: absolute; 100 | top: -11px; 101 | width: 20px; 102 | height: 20px; 103 | background-color: inherit; 104 | border-top: inherit; 105 | border-right: inherit; 106 | border-top-right-radius: 3px; 107 | transform: rotate(-45deg); 108 | } 109 | 110 | .is-open .demo-box { 111 | display: block; 112 | animation: demo-box-fade-in .2s cubic-bezier(0, .20, .20, .96); 113 | } 114 | @keyframes demo-box-fade-in { 115 | 0% { opacity: 0; transform: translateY(-20px); } 116 | 100% { opacity: 1; transform: translateY(0); } 117 | } 118 | 119 | .demo-box > p:first-child { 120 | margin-top: 0; 121 | } 122 | 123 | .demo-box h5 { 124 | font-size: 1em; 125 | margin-bottom: .6em; 126 | } 127 | 128 | 129 | /* Demo Controls ----------------------------- */ 130 | 131 | .demo-controls { 132 | display: flex; 133 | align-items: center; 134 | } 135 | 136 | .demo-button { 137 | align-self: flex-start; 138 | margin-right: 1em; 139 | border: 2px solid; 140 | border-radius: 4px; 141 | font: inherit; 142 | font-size: 1.2em; 143 | padding: .4em 1.2em; 144 | color: inherit; 145 | background-color: transparent; 146 | } 147 | .demo-button:focus { 148 | outline: none; 149 | background-color: white; 150 | } 151 | .demo-button:active { 152 | border-color: var(--color-border); 153 | } 154 | 155 | .demo-input { 156 | flex: 1; 157 | border: 2px solid var(--color-border); 158 | border-radius: 4px; 159 | font: inherit; 160 | font-size: 1.2em; 161 | padding: .4em .8em; 162 | color: inherit; 163 | background-color: transparent; 164 | } 165 | .demo-input:focus { 166 | outline: none; 167 | border-color: hsl(0,0%,80%); 168 | background-color: white; 169 | } 170 | 171 | .demo-response { 172 | flex: 1; 173 | word-break: break-word; 174 | } 175 | 176 | .smooth-appear { 177 | opacity: 1; 178 | transition: opacity .5s ease-in-out; 179 | } 180 | 181 | .disappear { 182 | opacity: 0; 183 | } 184 | .demo-button.smooth-disappear:focus { 185 | outline: inherit; 186 | border-color: inherit; 187 | background-color: inherit; 188 | } 189 | 190 | /* ProTip ----------------------------- */ 191 | 192 | .demo-protip { 193 | margin-top: 2rem; 194 | padding: 1.5rem 2rem 2rem 2rem; 195 | border: 1px solid hsla(0,0%,0%,.06); 196 | border-radius: 6px; 197 | background: var(--color-accent) linear-gradient(hsla(0,0%,100%,.85), hsla(0,0%,100%,.85)); 198 | } 199 | .demo-protip h2 { 200 | margin: 0 0 .5rem 0; 201 | } 202 | .demo-protip strong { 203 | font-weight: 600; 204 | } 205 | 206 | -------------------------------------------------------------------------------- /script/release.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const childProcess = require('child_process') 4 | const fs = require('fs') 5 | const path = require('path') 6 | const request = require('request') 7 | const util = require('util') 8 | 9 | const token = process.env.ELECTRON_API_DEMO_GITHUB_TOKEN 10 | const version = require('../package').version 11 | 12 | checkToken() 13 | .then(zipAssets) 14 | .then(createRelease) 15 | .then(uploadAssets) 16 | .then(publishRelease) 17 | .catch((error) => { 18 | console.error(error.message || error) 19 | process.exit(1) 20 | }) 21 | 22 | function checkToken () { 23 | if (!token) { 24 | return Promise.reject('ELECTRON_API_DEMO_GITHUB_TOKEN environment variable not set\nSet it to a token with repo scope created from https://github.com/settings/tokens/new') 25 | } else { 26 | return Promise.resolve(token) 27 | } 28 | } 29 | 30 | function zipAsset (asset) { 31 | return new Promise((resolve, reject) => { 32 | const assetBase = path.basename(asset.path) 33 | const assetDirectory = path.dirname(asset.path) 34 | console.log(`Zipping ${assetBase} to ${asset.name}`) 35 | 36 | if (!fs.existsSync(asset.path)) { 37 | return reject(new Error(`${asset.path} does not exist`)) 38 | } 39 | 40 | const zipCommand = `zip --recurse-paths --symlinks '${asset.name}' '${assetBase}'` 41 | const options = {cwd: assetDirectory, maxBuffer: Infinity} 42 | childProcess.exec(zipCommand, options, (error) => { 43 | if (error) { 44 | reject(error) 45 | } else { 46 | asset.path = path.join(assetDirectory, asset.name) 47 | resolve(asset) 48 | } 49 | }) 50 | }) 51 | } 52 | 53 | function zipAssets () { 54 | const outPath = path.join(__dirname, '..', 'out') 55 | 56 | const zipAssets = [{ 57 | name: 'electron-api-demos-mac.zip', 58 | path: path.join(outPath, 'Electron API Demos-darwin-x64', 'Electron API Demos.app') 59 | }, { 60 | name: 'electron-api-demos-windows.zip', 61 | path: path.join(outPath, 'Electron API Demos-win32-ia32') 62 | }, { 63 | name: 'electron-api-demos-linux.zip', 64 | path: path.join(outPath, 'Electron API Demos-linux-x64') 65 | }] 66 | 67 | return Promise.all(zipAssets.map(zipAsset)).then((zipAssets) => { 68 | return zipAssets.concat([{ 69 | name: 'RELEASES', 70 | path: path.join(outPath, 'windows-installer', 'RELEASES') 71 | }, { 72 | name: 'ElectronAPIDemosSetup.exe', 73 | path: path.join(outPath, 'windows-installer', 'ElectronAPIDemosSetup.exe') 74 | }, { 75 | name: `electron-api-demos-${version}-full.nupkg`, 76 | path: path.join(outPath, 'windows-installer', `electron-api-demos-${version}-full.nupkg`) 77 | }]) 78 | }) 79 | } 80 | 81 | function createRelease (assets) { 82 | const options = { 83 | uri: 'https://api.github.com/repos/electron/electron-api-demos/releases', 84 | headers: { 85 | Authorization: `token ${token}`, 86 | 'User-Agent': `node/${process.versions.node}` 87 | }, 88 | json: { 89 | tag_name: `v${version}`, 90 | target_commitish: 'master', 91 | name: version, 92 | body: 'An awesome new release :tada:', 93 | draft: true, 94 | prerelease: false 95 | } 96 | } 97 | 98 | return new Promise((resolve, reject) => { 99 | console.log('Creating new draft release') 100 | 101 | request.post(options, (error, response, body) => { 102 | if (error) { 103 | return reject(Error(`Request failed: ${error.message || error}`)) 104 | } 105 | if (response.statusCode !== 201) { 106 | return reject(Error(`Non-201 response: ${response.statusCode}\n${util.inspect(body)}`)) 107 | } 108 | 109 | resolve({assets: assets, draft: body}) 110 | }) 111 | }) 112 | } 113 | 114 | function uploadAsset (release, asset) { 115 | const options = { 116 | uri: release.upload_url.replace(/\{.*$/, `?name=${asset.name}`), 117 | headers: { 118 | Authorization: `token ${token}`, 119 | 'Content-Type': 'application/zip', 120 | 'Content-Length': fs.statSync(asset.path).size, 121 | 'User-Agent': `node/${process.versions.node}` 122 | } 123 | } 124 | 125 | return new Promise((resolve, reject) => { 126 | console.log(`Uploading ${asset.name} as release asset`) 127 | 128 | const assetRequest = request.post(options, (error, response, body) => { 129 | if (error) { 130 | return reject(Error(`Uploading asset failed: ${error.message || error}`)) 131 | } 132 | if (response.statusCode >= 400) { 133 | return reject(Error(`400+ response: ${response.statusCode}\n${util.inspect(body)}`)) 134 | } 135 | 136 | resolve(asset) 137 | }) 138 | fs.createReadStream(asset.path).pipe(assetRequest) 139 | }) 140 | } 141 | 142 | function uploadAssets (release) { 143 | return Promise.all(release.assets.map((asset) => { 144 | return uploadAsset(release.draft, asset) 145 | })).then(() => release) 146 | } 147 | 148 | function publishRelease (release) { 149 | const options = { 150 | uri: release.draft.url, 151 | headers: { 152 | Authorization: `token ${token}`, 153 | 'User-Agent': `node/${process.versions.node}` 154 | }, 155 | json: { 156 | draft: false 157 | } 158 | } 159 | 160 | return new Promise((resolve, reject) => { 161 | console.log('Publishing release') 162 | 163 | request.post(options, (error, response, body) => { 164 | if (error) { 165 | return reject(Error(`Request failed: ${error.message || error}`)) 166 | } 167 | if (response.statusCode !== 200) { 168 | return reject(Error(`Non-200 response: ${response.statusCode}\n${util.inspect(body)}`)) 169 | } 170 | 171 | resolve(body) 172 | }) 173 | }) 174 | } 175 | -------------------------------------------------------------------------------- /assets/img/icons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------