Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webmscore

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webmscore - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

global.d.ts

3

package.json
{
"name": "webmscore",
"version": "0.1.0",
"version": "0.2.0",
"description": "MuseScore's libmscore in WebAssembly! Read mscz data, and generate MIDI/MusicXML/SVG/PNG/PDF sheets right in browsers",

@@ -14,2 +14,3 @@ "type": "module",

"src",
"global.d.ts",
"schemas.ts",

@@ -16,0 +17,0 @@ "webmscore.js",

@@ -14,2 +14,3 @@

* Generate position information of measures or segments on the generated sheets
* Run inside a Web Worker thread

@@ -102,5 +103,5 @@ ## Installation

All modern browsers
All modern browsers which support [WebAssembly](https://caniuse.com/#feat=wasm) and [Async Functions](https://caniuse.com/#feat=async-functions)
| Name | [Minimum Version](https://caniuse.com/#feat=wasm) |
| Name | Minimum Version |
|---|---|

@@ -107,0 +108,0 @@ | Chrome | 57 |

import LibMscore from '../webmscore.lib.js'
import { IS_NODE, getSelfURL } from './utils.js'
const IS_NODE = typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === 'string'
const moduleOptions = IS_NODE

@@ -20,10 +19,5 @@ ? {

// fix loading the preload pack in Browsers and WebWorkers
let prefix = import.meta.url // transforms to "" in the generated bundle
if (!prefix) {
if (typeof document !== "undefined") {
prefix = document.currentScript && document.currentScript.src || document.baseURI
} else if (typeof location !== "undefined") {
prefix = location.href
}
}
const prefix = typeof MSCORE_SCRIPT_URL == "string"
? MSCORE_SCRIPT_URL // to use like an environment variable
: getSelfURL()
return new URL(path, prefix).href

@@ -33,4 +27,2 @@ }

typeof importScripts === "function"
const Module = LibMscore(moduleOptions)

@@ -37,0 +29,0 @@ export { Module }

// @ts-check
import {

@@ -23,8 +25,8 @@ Module,

/**
* The MSCZ/MSCX file format version (e.g. `301`)
* @returns {Promise<number>}
* The maximum MSCZ/MSCX file format version supported by webmscore
* @returns {Promise<number>} e.g. `301`
*/
static async version() {
await WebMscore.ready
return Module.ccall('version', null, ['number'])
return Module.ccall('version', 'number')
}

@@ -61,2 +63,3 @@

constructor(scoreptr) {
/** @private */
this.scoreptr = scoreptr

@@ -67,5 +70,5 @@ }

* Get the score title
* @returns {string}
* @returns {Promise<string>}
*/
title() {
async title() {
const strptr = Module.ccall('title', 'number', ['number'], [this.scoreptr])

@@ -80,4 +83,5 @@ const str = Module.UTF8ToString(strptr + 8) // 8 bytes of padding

*/
titleFilenameSafe() {
return this.title().replace(/[\s<>:{}"/\\|?*~.\0\cA-\cZ]+/g, "_")
async titleFilenameSafe() {
const title = await this.title()
return title.replace(/[\s<>:{}"/\\|?*~.\0\cA-\cZ]+/g, '_')
}

@@ -87,5 +91,5 @@

* Get the number of pages in the score
* @returns {number}
* @returns {Promise<number>}
*/
npages() {
async npages() {
return Module.ccall('npages', 'number', ['number'], [this.scoreptr])

@@ -96,6 +100,6 @@ }

* Get score metadata
* @returns {import("../schemas").ScoreMetadata}
* @returns {Promise<import('../schemas').ScoreMetadata>}
*/
metadata() {
return JSON.parse(this.saveMetadata())
async metadata() {
return JSON.parse(await this.saveMetadata())
}

@@ -105,6 +109,6 @@

* Get the positions of measures
* @returns {import("../schemas").Positions}
* @returns {Promise<import('../schemas').Positions>}
*/
measurePositions() {
return JSON.parse(this.savePositions(false))
async measurePositions() {
return JSON.parse(await this.savePositions(false))
}

@@ -114,6 +118,6 @@

* Get the positions of segments
* @returns {import("../schemas").Positions}
* @returns {Promise<import('../schemas').Positions>}
*/
segmentPositions() {
return JSON.parse(this.savePositions(true))
async segmentPositions() {
return JSON.parse(await this.savePositions(true))
}

@@ -123,5 +127,5 @@

* Export score as MusicXML file
* @returns {string} contents of the MusicXML file (plain text)
* @returns {Promise<string>} contents of the MusicXML file (plain text)
*/
saveXml() {
async saveXml() {
const dataptr = Module.ccall('saveXml', 'number', ['number'], [this.scoreptr])

@@ -138,5 +142,5 @@

* Export score as compressed MusicXML file
* @returns {Uint8Array}
* @returns {Promise<Uint8Array>}
*/
saveMxl() {
async saveMxl() {
const dataptr = Module.ccall('saveMxl', 'number', ['number'], [this.scoreptr])

@@ -150,5 +154,5 @@ return readData(dataptr)

* @param {boolean} drawPageBackground
* @returns {string} contents of the SVG file (plain text)
* @returns {Promise<string>} contents of the SVG file (plain text)
*/
saveSvg(pageNumber = 0, drawPageBackground = false) {
async saveSvg(pageNumber = 0, drawPageBackground = false) {
const dataptr = Module.ccall('saveSvg',

@@ -168,15 +172,2 @@ 'number',

/**
* Iteratively export score as SVG files of each page
* @param {boolean=} drawPageBackground
* @returns {Generator<[number, string]>} [index, svg contents]
*/
* saveSvgIt(drawPageBackground) {
const pagesN = this.npages()
for (let i = 0; i < pagesN; i++) {
yield [i, this.saveSvg(i, drawPageBackground)]
}
}
/**
* Export score as the PNG file of one page

@@ -186,5 +177,5 @@ * @param {number} pageNumber integer

* @param {boolean} transparent
* @returns {ArrayBuffer}
* @returns {Promise<Uint8Array>}
*/
savePng(pageNumber = 0, drawPageBackground = false, transparent = true) {
async savePng(pageNumber = 0, drawPageBackground = false, transparent = true) {
const dataptr = Module.ccall('savePng',

@@ -200,5 +191,5 @@ 'number',

* Export score as PDF file
* @returns {Uint8Array}
* @returns {Promise<Uint8Array>}
*/
savePdf() {
async savePdf() {
const dataptr = Module.ccall('savePdf', 'number', ['number'], [this.scoreptr])

@@ -212,5 +203,5 @@ return readData(dataptr)

* @param {boolean} exportRPNs
* @returns {Uint8Array}
* @returns {Promise<Uint8Array>}
*/
saveMidi(midiExpandRepeats = true, exportRPNs = true) {
async saveMidi(midiExpandRepeats = true, exportRPNs = true) {
const dataptr = Module.ccall('saveMidi',

@@ -228,5 +219,5 @@ 'number',

* @also `score.measurePositions()` and `score.segmentPositions()`
* @returns {string}
* @returns {Promise<string>}
*/
savePositions(ofSegments) {
async savePositions(ofSegments) {
const dataptr = Module.ccall('savePositions',

@@ -248,5 +239,5 @@ 'number',

* @also `score.metadata()`
* @returns {string} contents of the JSON file
* @returns {Promise<string>} contents of the JSON file
*/
saveMetadata() {
async saveMetadata() {
const dataptr = Module.ccall('saveMetadata', 'number', ['number'], [this.scoreptr])

@@ -253,0 +244,0 @@

@@ -5,5 +5,4 @@

import { fileURLToPath } from 'url'
import { IS_NODE, shimDom } from './utils.js'
const IS_NODE = typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === 'string'
if (IS_NODE) {

@@ -21,10 +20,3 @@

// mock dom objects
global.window = global.window || {
addEventListener() { },
location: new URL("../", import.meta.url),
encodeURIComponent,
}
global.navigator = global.navigator || {}
shimDom()
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc