EddyVerbruggen / EddyVerbruggen/nativescript-nodeify

DOM document

Open
#56 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
93
Forks
27
PR merge metrics
No merged PRs in 30d

Description

I would like to use `node-vibrant` is there a shim for `document` planned? https://github.com/akfish/node-vibrant/search?q=document&unscoped_q=document
Currently, I'm running into the error:

`Can't find variable: document`

Code example:

```
import { Component, OnInit } from '@angular/core';
require("nativescript-nodeify")
const Vibrant = require('node-vibrant');
import * as camera from "nativescript-camera";
import { fromAsset } from "image-source";
import { knownFolders, path} from "file-system"
const VERSION = "v2"

@Component({
selector: 'ns-snapshot',
templateUrl: './snapshot.component.html',
styleUrls: ['./snapshot.component.css'],
moduleId: module.id,
})
export class SnapshotComponent implements OnInit {
result: string;
image: any = null;
version = VERSION;

constructor() { }

ngOnInit() {
console.log("checking camera")
camera.requestPermissions()
}

getColor(imgSrc) {
console.log("filepath", imgSrc)
console.log("Analyzing color");
Vibrant.from(imgSrc).getPalette((err, palette) => {
console.log("err", err);
console.log("palette", palette);
this.result = palette.toString();
})
}

takeSnapshot() {
console.log("taking snapshot" + VERSION)
const cameraOptions = { saveToGallery: false }
camera.takePicture(cameraOptions)
.then( (imageAsset) => {
fromAsset(imageAsset)
.then((imageSource) => {
const folder = knownFolders.temp();
const filePath = path.join(folder.path, "test" + ".png");
console.log('saving to', filePath)
if (imageSource.saveToFile(filePath, "png", 90)) {
this.getColor(filePath);
}
});
}).catch( (err) => {
console.log("Error -> " + err.message);
});
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.