inital commit
This commit is contained in:
1 parent
d812e8f4a7
commit
7b45a854fe
1672 files changed
+298536
-1
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Diga Systems
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
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.
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
# ipp-browser
|
||||
IPP-browser is a powerful library that brings the power of Internet Printing Protocol (IPP) directly into the browser.
|
||||
Inspired by the work of [William Kapke](https:///github.com/williamkapke/ipp), this library extends the use of IPP to the browser.
|
||||
With this library, you can easily integrate printing to IPP-compatible network devices directly from your web applications without having to rely on additional plugins or software.
|
||||
## Installation
|
||||
|
||||
#### npm
|
||||
```sh
|
||||
$ npm install ipp-browser --save
|
||||
```
|
||||
|
||||
#### yarn
|
||||
```sh
|
||||
$ yarn add ipp-browser
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
|
||||
### Printer(url [,options])
|
||||
To interact with a printer, create a `Printer` object.
|
||||
|
||||
**options:**
|
||||
* `charset` - Specifies the value for the 'attributes-charset' attribute of requests. Defaults to `utf-8`.
|
||||
* `language` - Specifies the value for the 'attributes-natural-language' attribute of requests. Defaults to `en-us`.
|
||||
* `uri` - Specifies the value for the 'printer-uri' attribute of requests. Defaults to `ipp://+url.host+url.path`.
|
||||
* `version` - Specifies the value for the 'version' attribute of requests. Defaults to `2.0`.
|
||||
|
||||
|
||||
### Printer.encodeMsg(operation, msg)
|
||||
Converts an IPP message object to IPP binary.
|
||||
|
||||
* 'operation' - There are many operations defined by IPP. See: [/lib/types.ts](https://github.com/digasystems/ipp-browser/blob/main/lib/types.ts#L1).
|
||||
* 'message - A javascript object to be serealized into an IPP binary message.
|
||||
|
||||
|
||||
### Printer.getHeaders(headers?)
|
||||
Returns the heades to be included in your request
|
||||
|
||||
* 'headers' - The headers you want to add to the request.
|
||||
|
||||
|
||||
## Usage/Example
|
||||
#### Create a print request
|
||||
|
||||
```javascript
|
||||
import Printer from '@digasystems/ipp-browser';
|
||||
import axios from 'axios';
|
||||
|
||||
let url ="http://192.168.x.y:631/ipp/print"
|
||||
let printer = new Printer(url);
|
||||
let msg = {
|
||||
"operation-attributes-tag": {
|
||||
"document-format": "image/jpeg",
|
||||
},
|
||||
data: Buffer.from(imgBuff) ,
|
||||
};
|
||||
|
||||
axios
|
||||
.post(url, printer.encodeMsg("Print-Job",msg), {
|
||||
headers: printer.getHeaders(),
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response)
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+5023
File diff suppressed because it is too large.
Load diff
+6
@@ -0,0 +1,6 @@
|
||||
(function(re,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(re=typeof globalThis<"u"?globalThis:re||self,V(re["@digasystems/ipp-browser"]={}))})(this,function(re){"use strict";var Nt=Object.defineProperty;var Pt=(re,V,pe)=>V in re?Nt(re,V,{enumerable:!0,configurable:!0,writable:!0,value:pe}):re[V]=pe;var Be=(re,V,pe)=>(Pt(re,typeof V!="symbol"?V+"":V,pe),pe);var V={},pe={};pe.byteLength=ut,pe.toByteArray=pt,pe.fromByteArray=mt;for(var le=[],oe=[],at=typeof Uint8Array<"u"?Uint8Array:Array,Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_e=0,st=Ce.length;_e<st;++_e)le[_e]=Ce[_e],oe[Ce.charCodeAt(_e)]=_e;oe["-".charCodeAt(0)]=62,oe["_".charCodeAt(0)]=63;function Ge(c){var m=c.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var h=c.indexOf("=");h===-1&&(h=m);var x=h===m?0:4-h%4;return[h,x]}function ut(c){var m=Ge(c),h=m[0],x=m[1];return(h+x)*3/4-x}function ct(c,m,h){return(m+h)*3/4-h}function pt(c){var m,h=Ge(c),x=h[0],w=h[1],j=new at(ct(c,x,w)),_=0,u=w>0?x-4:x,C;for(C=0;C<u;C+=4)m=oe[c.charCodeAt(C)]<<18|oe[c.charCodeAt(C+1)]<<12|oe[c.charCodeAt(C+2)]<<6|oe[c.charCodeAt(C+3)],j[_++]=m>>16&255,j[_++]=m>>8&255,j[_++]=m&255;return w===2&&(m=oe[c.charCodeAt(C)]<<2|oe[c.charCodeAt(C+1)]>>4,j[_++]=m&255),w===1&&(m=oe[c.charCodeAt(C)]<<10|oe[c.charCodeAt(C+1)]<<4|oe[c.charCodeAt(C+2)]>>2,j[_++]=m>>8&255,j[_++]=m&255),j}function lt(c){return le[c>>18&63]+le[c>>12&63]+le[c>>6&63]+le[c&63]}function dt(c,m,h){for(var x,w=[],j=m;j<h;j+=3)x=(c[j]<<16&16711680)+(c[j+1]<<8&65280)+(c[j+2]&255),w.push(lt(x));return w.join("")}function mt(c){for(var m,h=c.length,x=h%3,w=[],j=16383,_=0,u=h-x;_<u;_+=j)w.push(dt(c,_,_+j>u?u:_+j));return x===1?(m=c[h-1],w.push(le[m>>2]+le[m<<4&63]+"==")):x===2&&(m=(c[h-2]<<8)+c[h-1],w.push(le[m>>10]+le[m>>4&63]+le[m<<2&63]+"=")),w.join("")}var Re={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Re.read=function(c,m,h,x,w){var j,_,u=w*8-x-1,C=(1<<u)-1,Q=C>>1,G=-7,M=h?w-1:0,ie=h?-1:1,W=c[m+M];for(M+=ie,j=W&(1<<-G)-1,W>>=-G,G+=u;G>0;j=j*256+c[m+M],M+=ie,G-=8);for(_=j&(1<<-G)-1,j>>=-G,G+=x;G>0;_=_*256+c[m+M],M+=ie,G-=8);if(j===0)j=1-Q;else{if(j===C)return _?NaN:(W?-1:1)*(1/0);_=_+Math.pow(2,x),j=j-Q}return(W?-1:1)*_*Math.pow(2,j-x)},Re.write=function(c,m,h,x,w,j){var _,u,C,Q=j*8-w-1,G=(1<<Q)-1,M=G>>1,ie=w===23?Math.pow(2,-24)-Math.pow(2,-77):0,W=x?0:j-1,fe=x?1:-1,ce=m<0||m===0&&1/m<0?1:0;for(m=Math.abs(m),isNaN(m)||m===1/0?(u=isNaN(m)?1:0,_=G):(_=Math.floor(Math.log(m)/Math.LN2),m*(C=Math.pow(2,-_))<1&&(_--,C*=2),_+M>=1?m+=ie/C:m+=ie*Math.pow(2,1-M),m*C>=2&&(_++,C/=2),_+M>=G?(u=0,_=G):_+M>=1?(u=(m*C-1)*Math.pow(2,w),_=_+M):(u=m*Math.pow(2,M-1)*Math.pow(2,w),_=0));w>=8;c[h+W]=u&255,W+=fe,u/=256,w-=8);for(_=_<<w|u,Q+=w;Q>0;c[h+W]=_&255,W+=fe,_/=256,Q-=8);c[h+W-fe]|=ce*128};/*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <https://feross.org>
|
||||
* @license MIT
|
||||
*/(function(c){const m=pe,h=Re,x=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;c.Buffer=u,c.SlowBuffer=y,c.INSPECT_MAX_BYTES=50;const w=2147483647;c.kMaxLength=w,u.TYPED_ARRAY_SUPPORT=j(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function j(){try{const r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function _(r){if(r>w)throw new RangeError('The value "'+r+'" is invalid for option "size"');const e=new Uint8Array(r);return Object.setPrototypeOf(e,u.prototype),e}function u(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(r)}return C(r,e,t)}u.poolSize=8192;function C(r,e,t){if(typeof r=="string")return ie(r,e);if(ArrayBuffer.isView(r))return fe(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(be(r,ArrayBuffer)||r&&be(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(be(r,SharedArrayBuffer)||r&&be(r.buffer,SharedArrayBuffer)))return ce(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return u.from(i,e,t);const s=he(r);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return u.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}u.from=function(r,e,t){return C(r,e,t)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function Q(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function G(r,e,t){return Q(r),r<=0?_(r):e!==void 0?typeof t=="string"?_(r).fill(e,t):_(r).fill(e):_(r)}u.alloc=function(r,e,t){return G(r,e,t)};function M(r){return Q(r),_(r<0?0:F(r)|0)}u.allocUnsafe=function(r){return M(r)},u.allocUnsafeSlow=function(r){return M(r)};function ie(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const t=k(r,e)|0;let i=_(t);const s=i.write(r,e);return s!==t&&(i=i.slice(0,s)),i}function W(r){const e=r.length<0?0:F(r.length)|0,t=_(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function fe(r){if(be(r,Uint8Array)){const e=new Uint8Array(r);return ce(e.buffer,e.byteOffset,e.byteLength)}return W(r)}function ce(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,u.prototype),i}function he(r){if(u.isBuffer(r)){const e=F(r.length)|0,t=_(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||$e(r.length)?_(0):W(r);if(r.type==="Buffer"&&Array.isArray(r.data))return W(r.data)}function F(r){if(r>=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return r|0}function y(r){return+r!=r&&(r=0),u.alloc(+r)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(be(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),be(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,s=t.length;for(let l=0,f=Math.min(i,s);l<f;++l)if(e[l]!==t[l]){i=e[l],s=t[l];break}return i<s?-1:s<i?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return u.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;const s=u.allocUnsafe(t);let l=0;for(i=0;i<e.length;++i){let f=e[i];if(be(f,Uint8Array))l+f.length>s.length?(u.isBuffer(f)||(f=u.from(f)),f.copy(s,l)):Uint8Array.prototype.Line truncated
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "@digasystems/ipp-browser",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/ipp-browser.umd.cjs",
|
||||
"module": "./dist/ipp-browser.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/ipp-browser.js",
|
||||
"require": "./dist/ipp-browser.umd.cjs"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/digasystems/ipp-browser.git"
|
||||
},
|
||||
"version": "1.0.2",
|
||||
"description": "ipp-browser is a powerful library that brings the power of Internet Printing Protocol (IPP) directly into the browser. With this library, you can easily integrate printing to IPP-compatible network devices directly from your web applications without having to rely on additional plugins or software.",
|
||||
"scripts": {
|
||||
"build": "npx vite build",
|
||||
"start": "npx vite"
|
||||
},
|
||||
"author": "Cristian Della Monica",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"buffer": "^6.0.3",
|
||||
"lodash": "^4.17.21",
|
||||
"react": "^18.2.0",
|
||||
"ua-parser-js": "^1.0.35",
|
||||
"vite": "^4.4.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.196",
|
||||
"@types/react": "^18.2.19",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"@types/ua-parser-js": "^0.7.36",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/digasystems/ipp-browser/issues"
|
||||
},
|
||||
"homepage": "https://github.com/digasystems/ipp-browser#readme",
|
||||
"directories": {
|
||||
"lib": "lib"
|
||||
},
|
||||
"keywords": [
|
||||
"ipp",
|
||||
"ipp-browser",
|
||||
"print",
|
||||
"web-print",
|
||||
"web",
|
||||
"browser"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user