Comparing version 0.2.1 to 0.3.0
{ | ||
"name": "webmscore", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "MuseScore's libmscore in WebAssembly! Read mscz data, and generate MIDI/MusicXML/SVG/PNG/PDF sheets right in browsers", | ||
"type": "module", | ||
"types": "global.d.ts", | ||
"main": "./webmscore.js", | ||
@@ -7,0 +8,0 @@ "module": "./webmscore.mjs", |
@@ -39,2 +39,19 @@ | ||
interface ScoreExcerptData { | ||
/** | ||
* excerpt id | ||
*/ | ||
id: number; | ||
/** | ||
* title of the excerpt | ||
*/ | ||
title: string; | ||
/** | ||
* linked parts in the excerpt | ||
*/ | ||
parts: ScorePartData[]; | ||
} | ||
/** | ||
@@ -101,2 +118,7 @@ * The score metadata | ||
/** | ||
* excerpts (linked parts) | ||
*/ | ||
excerpts: ScoreExcerptData[]; | ||
parts: ScorePartData[]; | ||
@@ -103,0 +125,0 @@ |
@@ -64,5 +64,21 @@ | ||
this.scoreptr = scoreptr | ||
/** @private */ | ||
this.excerptId = -1 | ||
} | ||
/** | ||
* Only save this excerpt (linked parts) of the score | ||
* (-1 means the full score) | ||
* @param {number} id | ||
*/ | ||
async setExcerptId(id) { | ||
this.excerptId = id | ||
} | ||
async getExcerptId() { | ||
return this.excerptId | ||
} | ||
/** | ||
* Get the score title | ||
@@ -87,7 +103,7 @@ * @returns {Promise<string>} | ||
/** | ||
* Get the number of pages in the score | ||
* Get the number of pages in the score (or the excerpt if `excerptId` is set) | ||
* @returns {Promise<number>} | ||
*/ | ||
async npages() { | ||
return Module.ccall('npages', 'number', ['number'], [this.scoreptr]) | ||
return Module.ccall('npages', 'number', ['number', 'number'], [this.scoreptr, this.excerptId]) | ||
} | ||
@@ -124,3 +140,3 @@ | ||
async saveXml() { | ||
const dataptr = Module.ccall('saveXml', 'number', ['number'], [this.scoreptr]) | ||
const dataptr = Module.ccall('saveXml', 'number', ['number', 'number'], [this.scoreptr, this.excerptId]) | ||
@@ -139,3 +155,3 @@ // MusicXML is plain text | ||
async saveMxl() { | ||
const dataptr = Module.ccall('saveMxl', 'number', ['number'], [this.scoreptr]) | ||
const dataptr = Module.ccall('saveMxl', 'number', ['number', 'number'], [this.scoreptr, this.excerptId]) | ||
return readData(dataptr) | ||
@@ -153,4 +169,4 @@ } | ||
'number', | ||
['number', 'number', 'boolean'], | ||
[this.scoreptr, pageNumber, drawPageBackground] | ||
['number', 'number', 'boolean', 'number'], | ||
[this.scoreptr, pageNumber, drawPageBackground, this.excerptId] | ||
) | ||
@@ -175,4 +191,4 @@ | ||
'number', | ||
['number', 'number', 'boolean', 'boolean'], | ||
[this.scoreptr, pageNumber, drawPageBackground, transparent] | ||
['number', 'number', 'boolean', 'boolean', 'number'], | ||
[this.scoreptr, pageNumber, drawPageBackground, transparent, this.excerptId] | ||
) | ||
@@ -187,3 +203,3 @@ return readData(dataptr) | ||
async savePdf() { | ||
const dataptr = Module.ccall('savePdf', 'number', ['number'], [this.scoreptr]) | ||
const dataptr = Module.ccall('savePdf', 'number', ['number', 'number'], [this.scoreptr, this.excerptId]) | ||
return readData(dataptr) | ||
@@ -201,4 +217,4 @@ } | ||
'number', | ||
['number', 'boolean', 'boolean'], | ||
[this.scoreptr, midiExpandRepeats, exportRPNs] | ||
['number', 'boolean', 'boolean', 'number'], | ||
[this.scoreptr, midiExpandRepeats, exportRPNs, this.excerptId] | ||
) | ||
@@ -217,4 +233,4 @@ return readData(dataptr) | ||
'number', | ||
['number', 'boolean'], | ||
[this.scoreptr, ofSegments] | ||
['number', 'boolean', 'number'], | ||
[this.scoreptr, ofSegments, this.excerptId] | ||
) | ||
@@ -221,0 +237,0 @@ |
@@ -92,2 +92,15 @@ // @ts-check | ||
/** | ||
* Only save this excerpt (linked parts) of the score | ||
* (-1 means the full score) | ||
* @param {number} id | ||
*/ | ||
async setExcerptId(id) { | ||
return this.rpc('setExcerptId', [id]) | ||
} | ||
async getExcerptId() { | ||
return this.rpc('getExcerptId') | ||
} | ||
/** | ||
* Get the score title | ||
@@ -109,3 +122,3 @@ * @returns {Promise<string>} | ||
/** | ||
* Get the number of pages in the score | ||
* Get the number of pages in the score (or the excerpt if `excerptId` is set) | ||
* @returns {Promise<number>} | ||
@@ -112,0 +125,0 @@ */ |
@@ -10,3 +10,3 @@ | ||
/** | ||
* @typedef {{ id: number; method: Exclude<keyof import('./index').default, 'scoreptr'> | 'load' | 'ready'; params: any[]; }} RPCReq | ||
* @typedef {{ id: number; method: Exclude<keyof import('./index').default, 'scoreptr' | 'excerptId'> | 'load' | 'ready'; params: any[]; }} RPCReq | ||
* @typedef {{ id: number; result?: any; error?: any; }} RPCRes | ||
@@ -13,0 +13,0 @@ * @param {number} id |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41662203
4854
19