bare-collabora
Advanced tools
+31
| # bare-collabora | ||
| Collabora bindings for Bare. | ||
| ``` | ||
| npm i bare-collabora | ||
| ``` | ||
| ## Usage | ||
| ```js | ||
| const { Document } = require('bare-collabora') | ||
| const document = new Document('/path/to/sample.md') | ||
| document.saveAs('/path/to/sample.pdf') | ||
| ``` | ||
| ## API | ||
| #### `const document = new Document(url)` | ||
| Loads the document at `url`. The `url` is a local file path or a `file:` URL pointing to a document in any format supported by Collabora. Throws if the document cannot be opened. | ||
| #### `document.saveAs(url[, format[, options]])` | ||
| Saves `document` to `url` in the given `format`. If `format` is omitted, it is inferred from the extension of `url`. `options` is a comma-separated string of filter options forwarded to Collabora; see the Collabora documentation for the filters available for a given format. Throws if the document cannot be saved. | ||
| ## License | ||
| Apache-2.0 |
+4
-0
@@ -54,5 +54,9 @@ cmake_minimum_required(VERSION 4.0) | ||
| PATTERN "bootstraprc" | ||
| PATTERN "bootstrap.ini" | ||
| PATTERN "fundamentalrc" | ||
| PATTERN "fundamental.ini" | ||
| PATTERN "lounorc" | ||
| PATTERN "louno.ini" | ||
| PATTERN "unorc" | ||
| PATTERN "uno.ini" | ||
@@ -59,0 +63,0 @@ # UNO services |
+54
-2
@@ -0,1 +1,2 @@ | ||
| const { pathToFileURL } = require('bare-url') | ||
| const binding = require('../binding') | ||
@@ -5,7 +6,7 @@ | ||
| constructor(url) { | ||
| this._handle = binding.documentOpen(url) | ||
| this._handle = binding.documentOpen(toFileURL(url).href) | ||
| } | ||
| saveAs(url, format, options) { | ||
| binding.documentSaveAs(this._handle, url, format, options) | ||
| binding.documentSaveAs(this._handle, toFileURL(url).href, format, options) | ||
| } | ||
@@ -19,1 +20,52 @@ | ||
| } | ||
| function toFileURL(path) { | ||
| let url | ||
| if (startsWithWindowsDriveLetter(path)) { | ||
| url = null | ||
| } else { | ||
| url = URL.parse(path) | ||
| } | ||
| if (url === null) url = pathToFileURL(path) | ||
| return url | ||
| } | ||
| // https://infra.spec.whatwg.org/#ascii-upper-alpha | ||
| function isASCIIUpperAlpha(c) { | ||
| return c >= 0x41 && c <= 0x5a | ||
| } | ||
| // https://infra.spec.whatwg.org/#ascii-lower-alpha | ||
| function isASCIILowerAlpha(c) { | ||
| return c >= 0x61 && c <= 0x7a | ||
| } | ||
| // https://infra.spec.whatwg.org/#ascii-alpha | ||
| function isASCIIAlpha(c) { | ||
| return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c) | ||
| } | ||
| // https://url.spec.whatwg.org/#windows-drive-letter | ||
| function isWindowsDriveLetter(input) { | ||
| return ( | ||
| input.length >= 2 && | ||
| isASCIIAlpha(input.charCodeAt(0)) && | ||
| (input.charCodeAt(1) === 0x3a || input.charCodeAt(1) === 0x7c) | ||
| ) | ||
| } | ||
| // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter | ||
| function startsWithWindowsDriveLetter(input) { | ||
| return ( | ||
| input.length >= 2 && | ||
| isWindowsDriveLetter(input) && | ||
| (input.length === 2 || | ||
| input.charCodeAt(2) === 0x2f || | ||
| input.charCodeAt(2) === 0x5c || | ||
| input.charCodeAt(2) === 0x3f || | ||
| input.charCodeAt(2) === 0x23) | ||
| ) | ||
| } |
+20
-14
| { | ||
| "name": "bare-collabora", | ||
| "version": "0.1.0", | ||
| "version": "0.1.1", | ||
| "description": "Collabora bindings for Bare", | ||
@@ -36,2 +36,6 @@ "exports": { | ||
| "x64": "bare-collabora-linux-x64" | ||
| }, | ||
| "win32": { | ||
| "arm64": "bare-collabora-win32-arm64", | ||
| "x64": "bare-collabora-win32-x64" | ||
| } | ||
@@ -69,15 +73,2 @@ } | ||
| "dependencies": { | ||
| "bare-collabora-android-arm": "^0.1.0", | ||
| "bare-collabora-android-arm64": "^0.1.0", | ||
| "bare-collabora-android-ia32": "^0.1.0", | ||
| "bare-collabora-android-x64": "^0.1.0", | ||
| "bare-collabora-darwin-arm64": "^0.1.0", | ||
| "bare-collabora-darwin-x64": "^0.1.0", | ||
| "bare-collabora-ios-arm64": "^0.1.0", | ||
| "bare-collabora-ios-arm64-simulator": "^0.1.0", | ||
| "bare-collabora-ios-x64-simulator": "^0.1.0", | ||
| "bare-collabora-linux-arm64": "^0.1.0", | ||
| "bare-collabora-linux-x64": "^0.1.0", | ||
| "bare-collabora-win32-arm64": "^0.1.0", | ||
| "bare-collabora-win32-x64": "^0.1.0", | ||
| "bare-env": "^3.0.0", | ||
@@ -87,2 +78,17 @@ "bare-path": "^3.0.0", | ||
| }, | ||
| "optionalDependencies": { | ||
| "bare-collabora-android-arm": "0.1.1", | ||
| "bare-collabora-android-arm64": "0.1.1", | ||
| "bare-collabora-android-ia32": "0.1.1", | ||
| "bare-collabora-android-x64": "0.1.1", | ||
| "bare-collabora-darwin-arm64": "0.1.1", | ||
| "bare-collabora-darwin-x64": "0.1.1", | ||
| "bare-collabora-ios-arm64": "0.1.1", | ||
| "bare-collabora-ios-arm64-simulator": "0.1.1", | ||
| "bare-collabora-ios-x64-simulator": "0.1.1", | ||
| "bare-collabora-linux-arm64": "0.1.1", | ||
| "bare-collabora-linux-x64": "0.1.1", | ||
| "bare-collabora-win32-arm64": "0.1.1", | ||
| "bare-collabora-win32-x64": "0.1.1" | ||
| }, | ||
| "devDependencies": { | ||
@@ -89,0 +95,0 @@ "bare-lief": "^0.2.3", |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
22463
11.72%10
11.11%66
186.96%0
-100%32
Infinity%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed