mirror of
https://github.com/penpot/penpot.git
synced 2025-07-24 10:17:19 +02:00
♻️ Move library to its own directory
This commit is contained in:
parent
6803c78e80
commit
2da8747485
13 changed files with 1763 additions and 61 deletions
48
library/playground/sample1.js
Normal file
48
library/playground/sample1.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
import * as penpot from "../target/library/penpot.js";
|
||||
import { writeFile } from 'fs/promises';
|
||||
import { createWriteStream } from 'fs';
|
||||
import { Writable } from "stream";
|
||||
|
||||
console.log(penpot);
|
||||
|
||||
(async function() {
|
||||
const file = penpot.createFile({name: "Test"});
|
||||
|
||||
file.addPage({name: "Foo Page"})
|
||||
const boardId = file.addArtboard({name: "Foo Board"})
|
||||
const rectId = file.addRect({name: "Foo Rect", width:100, height: 200})
|
||||
|
||||
file.addLibraryColor({color: "#fabada", opacity: 0.5})
|
||||
|
||||
// console.log("created board", boardId);
|
||||
// console.log("created rect", rectId);
|
||||
|
||||
// const board = file.getShape(boardId);
|
||||
// console.log("=========== BOARD =============")
|
||||
// console.dir(board, {depth: 10});
|
||||
|
||||
// const rect = file.getShape(rectId);
|
||||
// console.log("=========== RECT =============")
|
||||
// console.dir(rect, {depth: 10});
|
||||
|
||||
{
|
||||
let result = await penpot.exportAsBytes(file)
|
||||
await writeFile("sample-sync.zip", result);
|
||||
}
|
||||
|
||||
{
|
||||
// Create a file stream to write the zip to
|
||||
const output = createWriteStream('sample-stream.zip');
|
||||
|
||||
// Wrap Node's stream in a WHATWG WritableStream
|
||||
const writable = Writable.toWeb(output);
|
||||
|
||||
await penpot.exportStream(file, writable);
|
||||
}
|
||||
|
||||
})().catch((cause) => {
|
||||
console.log(cause);
|
||||
process.exit(-1);
|
||||
}).finally(() => {
|
||||
process.exit(0);
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue