Comparing version 0.2.1 to 0.3.0
{ | ||
"name": "pb", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"author": "SheetJS", | ||
"description": "Node interface to OSX Pasteboard", | ||
"keywords": [ | ||
"osx", | ||
"mac", | ||
"clipboard" | ||
], | ||
"description": "Interface to OSX Pasteboard", | ||
"keywords": [ "osx", "mac", "pasteboard", "clipboard" ], | ||
"bin": { | ||
"pb": "./pboard.njs" | ||
"pb": "./bin/pboard.njs" | ||
}, | ||
"main": "./pb", | ||
"main": "pb.js", | ||
"dependencies": { | ||
"NodObjC": "0.0.15" | ||
"nodobjc": "", | ||
"commander": "" | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/SheetJS/pb.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/SheetJS/pb/issues" | ||
}, | ||
"preferGlobal": "true" | ||
"repository": { "type": "git", "url": "git://github.com/SheetJS/pb.git" }, | ||
"preferGlobal": "true", | ||
"bugs": { "url": "https://github.com/SheetJS/pb/issues" }, | ||
"license": "Apache-2.0", | ||
"engines": { "node": ">=0.8" } | ||
} |
46
pb.js
@@ -1,16 +0,33 @@ | ||
var $ = require('nodobjc'); | ||
/* pb.js -- (C) 2013-2015 SheetJS -- http://sheetjs.com */ | ||
/* vim: set ts=2: */ | ||
/*jshint node:true */ | ||
var $ = require('nodobj'+'c'); | ||
$.framework('AppKit'); | ||
var pool = $.NSAutoreleasePool('alloc')('init'); | ||
$.NSAutoreleasePool('alloc')('init'); | ||
var mytype = exports.mytype = function(type) { | ||
if(!type) return [$.NSStringPboardType, 's']; | ||
switch(type) { | ||
case 'HTML': case 'html': return [$.NSHTMLPboardType, 's']; | ||
case 'PNG': case 'png': return [$.NSHTMLPboardType, 'i']; | ||
case 'TEXT': case 'text': return [$.NSStringPboardType, 's']; | ||
var basetypes = [ 'HTML', 'PNG', 'TEXT' ]; | ||
var alltypes; | ||
var mytype = exports.mytype = function mytype(type/*:string*/)/*:Array<any>*/ { | ||
if(!type) return [$.NSStringPboardType, 's']; | ||
switch(type.toUpperCase()) { | ||
case 'HTML': return [$.NSHTMLPboardType, 's']; | ||
case 'PNG': return [$.NSHTMLPboardType, 'i']; | ||
case 'TEXT': return [$.NSStringPboardType, 's']; | ||
} | ||
return [$[type], 's']; | ||
} | ||
}; | ||
exports.get = function(type) { | ||
exports.gettypes = function gettypes()/*:Array<any>*/ { | ||
if(!alltypes) { | ||
var filterfunc = function(x) { return x.match(/^NS.*PboardType$/); }; | ||
var nstypes = Object.keys($).filter(filterfunc); | ||
alltypes = basetypes.concat(nstypes); | ||
} | ||
return alltypes; | ||
}; | ||
exports.version = '0.3.0'; | ||
exports.get = function get(type/*:string*/)/*:any*/ { | ||
var x = $.NSPasteboard('generalPasteboard'); | ||
@@ -23,8 +40,9 @@ var tt = mytype(type); | ||
case 'i': { | ||
var y = $.NSImage('alloc')('initWithPasteboard', x) | ||
var y = $.NSImage('alloc')('initWithPasteboard', x); | ||
return y; | ||
} | ||
} | ||
} | ||
}; | ||
exports.set = function(type, str) { | ||
exports.set = function set(type/*:string*/, str/*:string*/)/*:void*/ { | ||
var x = $.NSPasteboard('generalPasteboard'); | ||
@@ -39,2 +57,2 @@ var tt = mytype(type); | ||
} | ||
} | ||
}; |
@@ -5,20 +5,37 @@ # pb | ||
The standard pbcopy and pbpaste utilities can manipulate the plaintext clipboard | ||
but have no easy way of accessing the HTML pasteboard. This module and CLI tool | ||
provide a more convenient way to access the pasteboard from node. | ||
## Installation | ||
`npm install pb` | ||
With [npm](https://www.npmjs.org/package/pb), global installation is easiest: | ||
## Usage | ||
$ npm install -g pb | ||
``` | ||
$ pb [type] | ||
$ get_data | pb -s [type] | ||
``` | ||
Depending on your system configuration, you may need to run as root: | ||
For example, to grab the contents of the html pasteboard and put it on the | ||
$ sudo npm install -g pb | ||
## Command-Line Tool Usage | ||
To get data from a specific pasteboard: | ||
$ pb [type] | ||
$ pb -m <type> | ||
To set a specific pasteboard, be sure to pipe data into pb: | ||
$ get_data | pb -s [type] | ||
To list available pasteboards: | ||
$ pb -l | ||
For example, to grab the contents of the HTML pasteboard and put it on the | ||
plaintext pasteboard: | ||
$ pb -m html | pb -s | ||
```bash | ||
$ pb html | pb -s | ||
``` | ||
## Library Usage | ||
@@ -29,3 +46,7 @@ From node, `pb` exposes: | ||
- `set(type, data)`: set pasteboard data (overwrites other pasteboards) | ||
- `gettypes()`: enumerate available pasteboards | ||
For example, to grab the contents of the HTML pasteboard and put it on the | ||
plaintext pasteboard: | ||
``` | ||
@@ -39,3 +60,10 @@ var pb = require('pb'); | ||
- `NSStringPboardType` (plaintext) | ||
- `NSHTMLPboardType` (HTML) | ||
- `NSStringPboardType` (plaintext) | ||
- `NSHTMLPboardType` (HTML) | ||
## License | ||
Please consult the attached LICENSE file for details. All rights not explicitly | ||
granted by the Apache 2.0 license are reserved by the Original Author. | ||
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/pb?pixel)](https://github.com/SheetJS/pb) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5835
10
54
67
2
3
1
+ Addedcommander@
+ Addednodobjc@
+ Addedbindings@1.2.1(transitive)
+ Addedcommander@12.1.0(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedffi@2.3.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addednan@2.22.0(transitive)
+ Addednodobjc@2.1.0(transitive)
+ Addedref@1.1.3(transitive)
+ Addedref-struct@1.0.2(transitive)
- RemovedNodObjC@0.0.15
- RemovedNodObjC@0.0.15(transitive)
- Removedbindings@1.0.0(transitive)
- Removedlibxmljs@0.7.1(transitive)
- Removednode-ffi@0.5.7(transitive)