1.0.231 • Published 2 years ago

staff-code v1.0.231

Weekly downloads
409
License
MIT
Repository
github
Last release
2 years ago

StaffCode

Convert simple text codes into Unicode, which in a specialized font displays as sheet music.

For questions or feedback, visit https://forum.sagittal.org/viewforum.php?f=22.

ston trcl ; d5 /|\ ; nt;

use

StaffCode can be used in three ways:

1) on phpBB forums with BBCode, 2) as an npm package, e.g. installed in a web application, 3) or with the StaffCode web app, running at https://staffcode.org.

BBCode

  • Download the .zip file from GitHub release page.
  • Follow the instructions in the README.txt file contained there.

package

npm install staff-code

Example usage:

import {setupPackageRoot, loadFonts, StaffCodeOptions} from "staff-code"

const callback = (inputSentence: string, unicodeSentence: string): any => {
    console.warn("user input:", inputSentence, "output unicode:", unicodeSentence)
}

const options: Partial<StaffCodeOptions> = {
    ui: {
        inline: true,           // default: false (whether the display appears as a <span> or a <div>)
        interactive: false,     // default: true (whether a textarea input for instantly changing the display appears)
        downloadButton: false,  // default: true (whether a download button for a vectorized SVG appears)
        imageSelect: false,     // default: true (whether radio buttons to choose between SVG and PNG format appears)
        copyLinkButton: false,  // default: true (whether a button to add query params to the URL for the current codes and then copy the link)
        sizeSpinner: false,     // default: true (whether a numeric spinner appears to adjust the size)
        lineSpinner: false,     // default: true (whether a numeric spinner appears to adjust the line height)
        reference: false,       // default: true (whether an expandable reference which you can click to insert codes appears)
    },
    initial: {
        size: 1.3,              // default: 1 (the overall scaling, via the font-size attribute)
        line: 1.5,              // default: 2 (affects the spacing of staves, via the line-height attribute)
        codes: "ston bscl ; ",  // default: "ston trcl ; "
        referenceOpen: true,    // default: false
        imageType: "png",       // default: "svg"
    },
    font: "Petaluma",           // default: "Bravura Text SC" (you'll have to move a custom font to assets/fonts)
    callback,                   // default: undefined
}

loadFonts().then((): void => {
    const root: HTMLSpanElement = setupPackageRoot(options)
    document.body.appendChild(root)
})

The WOFF and OTF variants of the Bravura Text SC font are included in the package. You should serve them at assets/fonts/* for them to be automatically picked up.

The download button, reference, copy link button, size spinner, line spinner, and interactive mode are not made available in the bbCode variant.

The copy link button only writes the query params to the URL bar if it detects that it's running in the StaffCode web app. It still copies the link to the web app to your clipboard in either case.

app

Visit https://staffcode.org and have fun!

development

After cloning, don't forget to cd into dist and git checkout main. There's probably a way I could do a recursive submodule initiation, like I did on other big projects, but I'm too lazy.

Use npm start to run a local version of the web app.

If using JetBrains IDE, you can Alt+Enter inside the strings of CSS and choose "Inject Language > CSS".

deployment

npm run deploy builds both the bbCode and package variants of StaffCode, as well as the web app, before deploying all three of these.

The web app and the bbCode variant are bundled by webpack, while tsc is used to simply transpile the package.

The BBCode variant is published to GitHub as a release, with the contents of the dist/bbCode folder archived and uploaded as an asset thereof.

The app is a GitHub page. Note that dist/app is a submodule for that.

You may need to install wget and jq in order to deploy. Chocolatey is good for this sort of thing. I used choco install wget while running my terminal as an administrator.

Additional dependencies (besides node_modules) are located in the vendor directory. These are on key JSON data files from Bravura and SMuFL. As a first step of each deploy, these dependencies are updated. The code in the bin directory then processes this data into a form where it can be consumed by StaffCode's src code.

npm run build builds two versions of the package: one with CJS modules and one with ESM modules; otherwise exactly the same. This is so the project can be used isomorphically (in both Node and the browser). The two packages are exposed as main and module, respectively. sideEffects: false has been marked in package.json to allow the ESM version to be tree-shaken by consumers.

1.0.228

2 years ago

1.0.229

2 years ago

1.0.231

2 years ago

1.0.230

2 years ago

1.0.227

3 years ago

1.0.226

3 years ago

1.0.225

3 years ago

1.0.224

3 years ago

1.0.223

3 years ago

1.0.222

3 years ago

1.0.221

3 years ago

1.0.219

3 years ago

1.0.218

3 years ago

1.0.217

3 years ago

1.0.216

3 years ago

1.0.215

3 years ago

1.0.213

3 years ago

1.0.214

3 years ago

1.0.211

3 years ago

1.0.212

3 years ago

1.0.210

3 years ago

1.0.209

3 years ago

1.0.208

3 years ago

1.0.206

3 years ago

1.0.205

3 years ago

1.0.204

3 years ago

1.0.202

3 years ago

1.0.203

3 years ago

1.0.201

3 years ago

1.0.200

3 years ago

1.0.197

3 years ago

1.0.199

3 years ago

1.0.193

3 years ago

1.0.196

3 years ago

1.0.195

3 years ago

1.0.192

3 years ago

1.0.191

3 years ago

1.0.190

3 years ago

1.0.189

3 years ago

1.0.188

3 years ago

1.0.187

3 years ago

1.0.186

3 years ago

1.0.185

3 years ago

1.0.184

3 years ago

1.0.183

3 years ago

1.0.182

3 years ago

1.0.181

3 years ago

1.0.180

3 years ago

1.0.179

3 years ago

1.0.178

3 years ago

1.0.177

3 years ago

1.0.176

3 years ago

1.0.175

3 years ago

1.0.174

3 years ago

1.0.173

3 years ago

1.0.172

3 years ago

1.0.171

3 years ago

1.0.169

3 years ago

1.0.170

3 years ago

1.0.167

3 years ago

1.0.168

3 years ago

1.0.166

3 years ago

1.0.165

3 years ago

1.0.164

3 years ago

1.0.163

3 years ago

1.0.162

3 years ago

1.0.161

3 years ago

1.0.160

3 years ago

1.0.154

3 years ago

1.0.153

3 years ago

1.0.156

3 years ago

1.0.155

3 years ago

1.0.152

3 years ago

1.0.151

3 years ago

1.0.158

3 years ago

1.0.157

3 years ago

1.0.159

3 years ago

1.0.149

3 years ago

1.0.148

3 years ago

1.0.150

3 years ago

1.0.147

3 years ago

1.0.146

3 years ago

1.0.145

3 years ago

1.0.144

3 years ago

1.0.143

3 years ago

1.0.142

3 years ago

1.0.141

3 years ago

1.0.140

3 years ago

1.0.132

3 years ago

1.0.134

3 years ago

1.0.133

3 years ago

1.0.130

3 years ago

1.0.139

3 years ago

1.0.138

3 years ago

1.0.137

3 years ago

1.0.129

3 years ago

1.0.128

3 years ago

1.0.127

3 years ago

1.0.126

3 years ago

1.0.125

3 years ago

1.0.124

3 years ago

1.0.123

3 years ago

1.0.122

3 years ago

1.0.121

3 years ago

1.0.120

3 years ago

1.0.119

3 years ago

1.0.118

3 years ago

1.0.117

3 years ago

1.0.116

3 years ago

1.0.115

3 years ago

1.0.113

3 years ago

1.0.110

3 years ago

1.0.112

3 years ago

1.0.111

3 years ago

1.0.107

3 years ago

1.0.106

3 years ago

1.0.105

3 years ago

1.0.104

3 years ago

1.0.103

3 years ago

1.0.101

3 years ago

1.0.100

3 years ago

1.0.102

3 years ago

1.0.99

3 years ago

1.0.98

3 years ago

1.0.97

3 years ago

1.0.96

3 years ago

1.0.95

3 years ago

1.0.93

3 years ago

1.0.91

3 years ago

1.0.92

3 years ago

1.0.90

3 years ago

1.0.89

3 years ago

1.0.88

3 years ago

1.0.87

3 years ago

1.0.86

3 years ago

1.0.84

3 years ago

1.0.83

3 years ago

1.0.82

3 years ago

1.0.85

3 years ago

1.0.81

3 years ago

1.0.79

3 years ago

1.0.80

3 years ago

1.0.78

3 years ago

1.0.77

3 years ago

1.0.73

3 years ago

1.0.72

3 years ago

1.0.76

3 years ago

1.0.75

3 years ago

1.0.74

3 years ago

1.0.71

3 years ago

1.0.69

3 years ago

1.0.70

3 years ago

1.0.68

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.67

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.55

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.49

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.41

3 years ago

1.0.40

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.33

3 years ago

1.0.34

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.26

3 years ago

1.0.27

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.23

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago