astro-lilypond 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -32
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -1
- package/dist/loader.js +1 -1
- package/dist/plugins/remark.js +1 -1
- package/dist/plugins/satteri.js +1 -1
- package/dist/plugins/types.d.ts +1 -0
- package/dist/state.d.ts +1 -0
- package/dist/utils/includePathsFor.d.ts +5 -4
- package/dist/utils/includePathsFor.js +7 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,42 +9,12 @@ An [Astro](https://astro.build) integration for rendering [LilyPond](https://lil
|
|
|
9
9
|
- Use the content loader to pass in a folder full of `.ly` files and get back an Astro content collection.
|
|
10
10
|
- Works with all LilyPond syntax.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## Quick Start
|
|
15
|
-
|
|
16
|
-
### 1. Install `astro-lilypond`
|
|
12
|
+
## Quick start
|
|
17
13
|
|
|
18
14
|
```sh
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### 2. Add the integration to your Astro config
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
// astro.config.mjs
|
|
26
|
-
import { defineConfig } from 'astro/config';
|
|
27
|
-
import lilypond from 'astro-lilypond';
|
|
28
|
-
|
|
29
|
-
export default defineConfig({
|
|
30
|
-
integrations: [lilypond()]
|
|
31
|
-
});
|
|
15
|
+
npx astro add astro-lilypond
|
|
32
16
|
```
|
|
33
17
|
|
|
34
|
-
### 3. Write your music
|
|
35
|
-
|
|
36
|
-
Write LilyPond code within fenced code blocks with the `lilypond`, `ly`, or `ily` language tag.
|
|
37
|
-
|
|
38
|
-
````md
|
|
39
|
-
```lilypond
|
|
40
|
-
\\score ...
|
|
41
|
-
```
|
|
42
|
-
````
|
|
43
|
-
|
|
44
|
-
Your score will be built to `.svg` or `.png` and display alongside the rest of your content.
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
18
|
For more info, refer to the docs: https://lilypond.ky.fyi
|
|
49
19
|
|
|
50
20
|
Happy notating!
|
package/dist/index.d.ts
CHANGED
|
@@ -94,5 +94,11 @@ export interface LilypondOptions extends PluginOptions {
|
|
|
94
94
|
* @default true
|
|
95
95
|
*/
|
|
96
96
|
autoInstall?: boolean | AutoInstallOptions;
|
|
97
|
+
/**
|
|
98
|
+
* Extra directories to search for `\include`d files, in addition to each
|
|
99
|
+
* score's own directory. Relative paths resolve against the project root.
|
|
100
|
+
* @default []
|
|
101
|
+
*/
|
|
102
|
+
includePaths?: string[];
|
|
97
103
|
}
|
|
98
104
|
export default function lilypond(options?: LilypondOptions): AstroIntegration;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
1
2
|
import { createComponent, renderComponent, renderTemplate, unescapeHTML, } from "astro/runtime/server/index.js";
|
|
2
3
|
import emitAssetIntegration from "astro-emit-asset";
|
|
3
4
|
import { resolveAutoInstallOption, resolveLilypondBinary, } from "./binary/index.js";
|
|
@@ -114,7 +115,7 @@ function lyFilePlugin(options) {
|
|
|
114
115
|
return;
|
|
115
116
|
const { version } = resolveDefaults(options.defaults);
|
|
116
117
|
const src = version ? prependVersion(source, version) : source;
|
|
117
|
-
const includePaths = includePathsFor(id);
|
|
118
|
+
const includePaths = includePathsFor(id, options.includePaths);
|
|
118
119
|
const sourceName = sourceNameFor(id);
|
|
119
120
|
const assetTitle = titleFor(sourceName);
|
|
120
121
|
const meta = toLilypondMetadata(parseLyHeaderFields(source));
|
|
@@ -147,12 +148,15 @@ export default function lilypond(options = {}) {
|
|
|
147
148
|
warn: (message) => logger.warn(message),
|
|
148
149
|
});
|
|
149
150
|
options.binaryPath = binaryPath;
|
|
151
|
+
const includePaths = (options.includePaths ?? []).map((path) => fileURLToPath(new URL(path, config.root)));
|
|
152
|
+
options.includePaths = includePaths;
|
|
150
153
|
setLilypondState({
|
|
151
154
|
binaryPath,
|
|
152
155
|
defaults: options.defaults,
|
|
153
156
|
timeout: options.timeout,
|
|
154
157
|
isDev,
|
|
155
158
|
logger,
|
|
159
|
+
includePaths,
|
|
156
160
|
});
|
|
157
161
|
updateConfig({
|
|
158
162
|
integrations: [emitAssetIntegration()],
|
package/dist/loader.js
CHANGED
|
@@ -80,7 +80,7 @@ export function lilypondLoader({ pattern = DEFAULT_PATTERN, base, generateId = d
|
|
|
80
80
|
const id = generateId({ entry, base: baseUrl, header: headerFields });
|
|
81
81
|
const digest = generateDigest(source);
|
|
82
82
|
const src = prependVersion(source, version);
|
|
83
|
-
const includePaths = includePathsFor(filePath);
|
|
83
|
+
const includePaths = includePathsFor(filePath, getLilypondState().includePaths);
|
|
84
84
|
const sourceName = sourceNameFor(filePath);
|
|
85
85
|
const assetTitle = titleFor(sourceName);
|
|
86
86
|
const meta = toLilypondMetadata(headerFields);
|
package/dist/plugins/remark.js
CHANGED
|
@@ -9,7 +9,7 @@ export const remarkPlugin = (options) => {
|
|
|
9
9
|
const renderOptions = { ...options, logger };
|
|
10
10
|
return async (tree, file) => {
|
|
11
11
|
const promises = [];
|
|
12
|
-
const includePaths = includePathsFor(file?.path);
|
|
12
|
+
const includePaths = includePathsFor(file?.path, options.includePaths);
|
|
13
13
|
const sourceName = sourceNameFor(file?.path);
|
|
14
14
|
const title = titleFor(sourceName);
|
|
15
15
|
visit(tree, "code", (node, index, parent) => {
|
package/dist/plugins/satteri.js
CHANGED
|
@@ -16,7 +16,7 @@ export function satteriPlugin(options) {
|
|
|
16
16
|
title: titleFor(sourceName),
|
|
17
17
|
value: node.value,
|
|
18
18
|
meta: node.meta,
|
|
19
|
-
includePaths: includePathsFor(ctx.fileURL),
|
|
19
|
+
includePaths: includePathsFor(ctx.fileURL, options.includePaths),
|
|
20
20
|
sourceName,
|
|
21
21
|
});
|
|
22
22
|
return { rawHtml };
|
package/dist/plugins/types.d.ts
CHANGED
package/dist/state.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface LilypondState {
|
|
|
6
6
|
timeout: number | undefined;
|
|
7
7
|
isDev: boolean;
|
|
8
8
|
logger: Pick<AstroIntegrationLogger, "warn" | "error">;
|
|
9
|
+
includePaths: string[];
|
|
9
10
|
}
|
|
10
11
|
export declare function setLilypondState(state: LilypondState): void;
|
|
11
12
|
export declare function getLilypondState(): LilypondState;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Make sure that any `\include` definitions resolve correctly when
|
|
3
|
+
* LilyPond compiles the score. `source` is the current directory or URL
|
|
4
|
+
* of the .ly file; `extra` is for user-defined locations from the
|
|
5
|
+
* config setting `includePaths`.
|
|
5
6
|
*/
|
|
6
|
-
export declare function includePathsFor(source: string | URL | null | undefined): string[];
|
|
7
|
+
export declare function includePathsFor(source: string | URL | null | undefined, extra?: string[]): string[];
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Make sure that any `\include` definitions resolve correctly when
|
|
5
|
+
* LilyPond compiles the score. `source` is the current directory or URL
|
|
6
|
+
* of the .ly file; `extra` is for user-defined locations from the
|
|
7
|
+
* config setting `includePaths`.
|
|
7
8
|
*/
|
|
8
|
-
export function includePathsFor(source) {
|
|
9
|
+
export function includePathsFor(source, extra = []) {
|
|
9
10
|
if (!source)
|
|
10
|
-
return
|
|
11
|
+
return extra;
|
|
11
12
|
const path = typeof source === "string" ? source : fileURLToPath(source);
|
|
12
|
-
return [dirname(path)];
|
|
13
|
+
return [dirname(path), ...extra];
|
|
13
14
|
}
|