notations 0.0.67 → 0.0.69

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.
Files changed (53) hide show
  1. package/README.md +56 -26
  2. package/dist/NotationView.css +107 -0
  3. package/dist/NotationView.css.map +1 -0
  4. package/dist/NotationView.min.css +1 -0
  5. package/dist/NotationView.min.css.map +1 -0
  6. package/dist/notations.umd.js +35875 -0
  7. package/dist/notations.umd.min.js +112 -0
  8. package/dist/notations.umd.min.js.LICENSE.txt +24 -0
  9. package/dist/notations.umd.min.js.map +1 -0
  10. package/lib/cjs/beats.js.map +1 -1
  11. package/lib/cjs/beatutils.js.map +1 -1
  12. package/lib/cjs/beatview.js.map +1 -1
  13. package/lib/cjs/carnatic/LineView.js.map +1 -1
  14. package/lib/cjs/carnatic/NotationView.js.map +1 -1
  15. package/lib/cjs/carnatic/embelishments.js +3 -8
  16. package/lib/cjs/carnatic/embelishments.js.map +1 -1
  17. package/lib/cjs/carnatic/gamakas.js.map +1 -1
  18. package/lib/cjs/commands.js.map +1 -1
  19. package/lib/cjs/core.js.map +1 -1
  20. package/lib/cjs/cycle.js.map +1 -1
  21. package/lib/cjs/entity.js.map +1 -1
  22. package/lib/cjs/grids.js.map +1 -1
  23. package/lib/cjs/iterators.js.map +1 -1
  24. package/lib/cjs/layouts.js.map +1 -1
  25. package/lib/cjs/loader.js.map +1 -1
  26. package/lib/cjs/notation.js.map +1 -1
  27. package/lib/cjs/parser.js.map +1 -1
  28. package/lib/cjs/shapes.js +1 -1
  29. package/lib/cjs/shapes.js.map +1 -1
  30. package/lib/cjs/utils.js.map +1 -1
  31. package/lib/esm/beats.js.map +1 -1
  32. package/lib/esm/beatutils.js.map +1 -1
  33. package/lib/esm/beatview.js.map +1 -1
  34. package/lib/esm/carnatic/LineView.js.map +1 -1
  35. package/lib/esm/carnatic/NotationView.js.map +1 -1
  36. package/lib/esm/carnatic/embelishments.js +3 -8
  37. package/lib/esm/carnatic/embelishments.js.map +1 -1
  38. package/lib/esm/carnatic/gamakas.js.map +1 -1
  39. package/lib/esm/commands.js.map +1 -1
  40. package/lib/esm/core.js.map +1 -1
  41. package/lib/esm/cycle.js.map +1 -1
  42. package/lib/esm/entity.js.map +1 -1
  43. package/lib/esm/grids.js.map +1 -1
  44. package/lib/esm/iterators.js.map +1 -1
  45. package/lib/esm/layouts.js.map +1 -1
  46. package/lib/esm/loader.js.map +1 -1
  47. package/lib/esm/notation.js.map +1 -1
  48. package/lib/esm/parser.js.map +1 -1
  49. package/lib/esm/shapes.js +1 -1
  50. package/lib/esm/shapes.js.map +1 -1
  51. package/lib/esm/utils.js.map +1 -1
  52. package/package.json +22 -15
  53. package/styles/NotationView.scss +81 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAQ,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACrC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAajC,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,QAAQ;SACZ,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC;AAQD,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,IAAI,KAAK,CAAC;QACf,IAAI,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAA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I,CAAC,IAAI,EAAE,CAAC;YACjC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAWD,OAAO,CAAC,KAAa,EAAE,OAAmB;QACxC,IAAI,GAAG,GAAG,IAAI,CAAC;QACf,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;YAE3B,GAAG,GAAG,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IASD,KAAK,CAAC,KAAa,EAAE,GAAG,MAAoB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;IACtD,CAAC;IASD,QAAQ,CAAC,KAAa,EAAE,KAAK,GAAG,CAAC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAUD,MAAM,CAAC,KAAa,EAAE,WAAmB,EAAE,GAAG,cAA4B;QAExE,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Space, Group, Syllable } from \"./core\";\nimport { Cycle, Bar } from \"./cycle\";\nconst ONE = TSU.Num.Fraction.ONE;\n\n/**\n * Converts a cycle string into an array of bar strings.\n * \n * A cycle is specified by a \"|\" delimited string in the format:\n * <bar1>|<bar2>|<bar3>....|<barN>\n * \n * Empty bars are ignored.\n * \n * @param cycleStr The cycle string to convert\n * @returns An array of bar strings\n */\nexport function cycleStrToBarsStrs(cycleStr: string): string[] {\n return cycleStr\n .replace(/\\|+/g, \"|\")\n .split(\"|\")\n .map((x) => x.trim())\n .filter((x) => x.length > 0);\n}\n\n/**\n * Parses a tala pattern string into a Cycle object.\n * \n * @param cycleStr The cycle string to parse\n * @returns A new Cycle object\n */\nexport function parseCycle(cycleStr: string): Cycle {\n return new Cycle({\n bars: cycleStrToBarsStrs(cycleStr).map(parseBar),\n });\n}\n\n/**\n * Parses a bar string into a Bar object.\n * \n * A bar string is a space delimited string in the following format:\n * \"<beat1> <spaces> <beat2> .... <beatN>\"\n * \n * beatX substring cannot contain \"|\" or spaces.\n * \n * Each Beat string is in the following format:\n * \"<length>(:<count>)?\" or \"<length>?:<count>\"\n * \n * Both length and count are optional but at least one of them must be specified.\n * When not specified the other defaults to 1.\n * Length can also be a fraction of the form <num>\"/\"<den> (without spaces).\n * \n * @param barStr The bar string to parse\n * @returns A new Bar object\n */\nexport function parseBar(barStr: string): Bar {\n const bars = barStr.replace(/\\s+/g, \" \").split(\" \");\n const cp = new Bar();\n if (bars.length == 1) {\n for (let i = 0; i < barStr.length; i++) {\n let count = 0;\n const ch = barStr[i];\n if (ch == \",\") {\n count = 1;\n } else {\n const num = parseInt(ch);\n if (num) {\n count = num;\n }\n }\n while (count > 0) {\n cp.beatLengths.push(ONE);\n count--;\n }\n }\n } else {\n for (let i = 0; i < bars.length; i++) {\n const comps = bars[i].split(\":\");\n const length = comps[0];\n const count = comps[1] || \"\";\n if (length.length == 0) {\n cp.beatLengths.push(TSU.Num.Frac(1));\n } else if (/^,+$/.test(length)) {\n cp.beatLengths.push(TSU.Num.Frac(length.length));\n } else {\n // parse length as a number or as a fraction\n cp.beatLengths.push(TSU.Num.Fraction.parse(length));\n }\n\n // Now the count\n const beatCount = parseInt(count);\n if (isNaN(beatCount)) {\n cp.beatCounts.push(1);\n } else {\n cp.beatCounts.push(beatCount);\n }\n }\n }\n return cp;\n}\n\n/**\n * Parses a string into a syllable atom structure.\n * \n * @param value The string to parse\n * @returns An atom representing the syllable structure\n */\nexport function parseSyllable(value: string): Atom {\n const notes = [] as Atom[];\n // Only \"_\" make a difference here\n for (let i = 0; i < value.length; ) {\n let ch = value[i];\n if (ch == \"_\") {\n notes.push(new Space(ONE, true));\n i++;\n } else if (ch == \",\") {\n notes.push(new Space(ONE, false));\n i++;\n } else {\n let syll = \"\";\n while (i < value.length && ch != \",\" && ch != \"_\") {\n syll += ch;\n i++;\n ch = value[i];\n }\n notes.push(new Syllable(syll));\n }\n }\n if (notes.length == 1) return notes[0];\n return new Group(...notes);\n}\n\n/**\n * Parses a property string in the format \"key = value\".\n * \n * @param line The property string to parse\n * @returns A tuple containing the key and value\n * @throws Error if the property string is invalid\n */\nexport function parseProperty(line: string): [string, string] {\n const bars = line.split(\"=\").map((x) => x.trim());\n if (bars.length < 2) {\n throw new Error(\"Properties must be of type <key> = <value>\");\n }\n const key = bars[0];\n const value = bars[1];\n return [key, value];\n}\n\n/**\n * NOT YET IMPLEMENTED\n * A sparse array type which is optimized for \"holes\" while not penalizing\n * runs of values.\n */\nexport class SparseArray<T> {\n runs: [number, T[]][] = [];\n\n /**\n * Gets the total length of this sparse array.\n */\n get length(): number {\n let out = 0;\n for (const [, vals] of this.runs) {\n out += vals.length;\n }\n return out;\n }\n\n /**\n * Returns the value at a given index.\n * If the value does not exist an optional creator method can be passed\n * to ensure that this value is also created and set at the given index.\n * \n * @param index The index to get the value at\n * @param creator Optional function to create a value if none exists\n * @returns The value at the index\n */\n valueAt(index: number, creator?: () => any): any {\n let out = null;\n if (out == null && creator) {\n // wasnt found\n out = creator();\n this.setAt(index, out);\n }\n return out;\n }\n\n /**\n * Sets values at a specific index.\n * \n * @param index The index to set values at\n * @param values The values to set\n * @returns This array instance for method chaining\n */\n setAt(index: number, ...values: (T | null)[]): this {\n return this.splice(index, values.length, ...values);\n }\n\n /**\n * Removes values at a specific index.\n * \n * @param index The index to remove values at\n * @param count The number of values to remove, defaults to 1\n * @returns This array instance for method chaining\n */\n removeAt(index: number, count = 1): this {\n return this.splice(index, count);\n }\n\n /**\n * Splices values at a specific index.\n * \n * @param index The index to splice at\n * @param numToDelete The number of values to delete\n * @param valuesToInsert The values to insert\n * @returns This array instance for method chaining\n */\n splice(index: number, numToDelete: number, ...valuesToInsert: (T |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C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;IACtD,CAAC;IASD,QAAQ,CAAC,KAAa,EAAE,KAAK,GAAG,CAAC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAUD,MAAM,CAAC,KAAa,EAAE,WAAmB,EAAE,GAAG,cAA4B;QAExE,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Space, Group, Syllable } from \"./core\";\nimport { Cycle, Bar } from \"./cycle\";\nconst ONE = TSU.Num.Fraction.ONE;\n\n/**\n * Converts a cycle string into an array of bar strings.\n *\n * A cycle is specified by a \"|\" delimited string in the format:\n * <bar1>|<bar2>|<bar3>....|<barN>\n *\n * Empty bars are ignored.\n *\n * @param cycleStr The cycle string to convert\n * @returns An array of bar strings\n */\nexport function cycleStrToBarsStrs(cycleStr: string): string[] {\n return cycleStr\n .replace(/\\|+/g, \"|\")\n .split(\"|\")\n .map((x) => x.trim())\n .filter((x) => x.length > 0);\n}\n\n/**\n * Parses a tala pattern string into a Cycle object.\n *\n * @param cycleStr The cycle string to parse\n * @returns A new Cycle object\n */\nexport function parseCycle(cycleStr: string): Cycle {\n return new Cycle({\n bars: cycleStrToBarsStrs(cycleStr).map(parseBar),\n });\n}\n\n/**\n * Parses a bar string into a Bar object.\n *\n * A bar string is a space delimited string in the following format:\n * \"<beat1> <spaces> <beat2> .... <beatN>\"\n *\n * beatX substring cannot contain \"|\" or spaces.\n *\n * Each Beat string is in the following format:\n * \"<length>(:<count>)?\" or \"<length>?:<count>\"\n *\n * Both length and count are optional but at least one of them must be specified.\n * When not specified the other defaults to 1.\n * Length can also be a fraction of the form <num>\"/\"<den> (without spaces).\n *\n * @param barStr The bar string to parse\n * @returns A new Bar object\n */\nexport function parseBar(barStr: string): Bar {\n const bars = barStr.replace(/\\s+/g, \" \").split(\" \");\n const cp = new Bar();\n if (bars.length == 1) {\n for (let i = 0; i < barStr.length; i++) {\n let count = 0;\n const ch = barStr[i];\n if (ch == \",\") {\n count = 1;\n } else {\n const num = parseInt(ch);\n if (num) {\n count = num;\n }\n }\n while (count > 0) {\n cp.beatLengths.push(ONE);\n count--;\n }\n }\n } else {\n for (let i = 0; i < bars.length; i++) {\n const comps = bars[i].split(\":\");\n const length = comps[0];\n const count = comps[1] || \"\";\n if (length.length == 0) {\n cp.beatLengths.push(TSU.Num.Frac(1));\n } else if (/^,+$/.test(length)) {\n cp.beatLengths.push(TSU.Num.Frac(length.length));\n } else {\n // parse length as a number or as a fraction\n cp.beatLengths.push(TSU.Num.Fraction.parse(length));\n }\n\n // Now the count\n const beatCount = parseInt(count);\n if (isNaN(beatCount)) {\n cp.beatCounts.push(1);\n } else {\n cp.beatCounts.push(beatCount);\n }\n }\n }\n return cp;\n}\n\n/**\n * Parses a string into a syllable atom structure.\n *\n * @param value The string to parse\n * @returns An atom representing the syllable structure\n */\nexport function parseSyllable(value: string): Atom {\n const notes = [] as Atom[];\n // Only \"_\" make a difference here\n for (let i = 0; i < value.length; ) {\n let ch = value[i];\n if (ch == \"_\") {\n notes.push(new Space(ONE, true));\n i++;\n } else if (ch == \",\") {\n notes.push(new Space(ONE, false));\n i++;\n } else {\n let syll = \"\";\n while (i < value.length && ch != \",\" && ch != \"_\") {\n syll += ch;\n i++;\n ch = value[i];\n }\n notes.push(new Syllable(syll));\n }\n }\n if (notes.length == 1) return notes[0];\n return new Group(...notes);\n}\n\n/**\n * Parses a property string in the format \"key = value\".\n *\n * @param line The property string to parse\n * @returns A tuple containing the key and value\n * @throws Error if the property string is invalid\n */\nexport function parseProperty(line: string): [string, string] {\n const bars = line.split(\"=\").map((x) => x.trim());\n if (bars.length < 2) {\n throw new Error(\"Properties must be of type <key> = <value>\");\n }\n const key = bars[0];\n const value = bars[1];\n return [key, value];\n}\n\n/**\n * NOT YET IMPLEMENTED\n * A sparse array type which is optimized for \"holes\" while not penalizing\n * runs of values.\n */\nexport class SparseArray<T> {\n runs: [number, T[]][] = [];\n\n /**\n * Gets the total length of this sparse array.\n */\n get length(): number {\n let out = 0;\n for (const [, vals] of this.runs) {\n out += vals.length;\n }\n return out;\n }\n\n /**\n * Returns the value at a given index.\n * If the value does not exist an optional creator method can be passed\n * to ensure that this value is also created and set at the given index.\n *\n * @param index The index to get the value at\n * @param creator Optional function to create a value if none exists\n * @returns The value at the index\n */\n valueAt(index: number, creator?: () => any): any {\n let out = null;\n if (out == null && creator) {\n // wasnt found\n out = creator();\n this.setAt(index, out);\n }\n return out;\n }\n\n /**\n * Sets values at a specific index.\n *\n * @param index The index to set values at\n * @param values The values to set\n * @returns This array instance for method chaining\n */\n setAt(index: number, ...values: (T | null)[]): this {\n return this.splice(index, values.length, ...values);\n }\n\n /**\n * Removes values at a specific index.\n *\n * @param index The index to remove values at\n * @param count The number of values to remove, defaults to 1\n * @returns This array instance for method chaining\n */\n removeAt(index: number, count = 1): this {\n return this.splice(index, count);\n }\n\n /**\n * Splices values at a specific index.\n *\n * @param index The index to splice at\n * @param numToDelete The number of values to delete\n * @param valuesToInsert The values to insert\n * @returns This array instance for method chaining\n */\n splice(index: number, numToDelete: number, ...valuesToInsert: (T | null)[]) {\n //\n return this;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notations",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "author": "Sriram Panyam",
5
5
  "description": "A package for modelling, parsing, laying out carnatic musical notation",
6
6
  "homepage": "https://github.com/panyam/notations#readme",
@@ -10,7 +10,8 @@
10
10
  "types": "lib/cjs/index.d.ts",
11
11
  "files": [
12
12
  "lib/",
13
- "styles/"
13
+ "styles/",
14
+ "dist/"
14
15
  ],
15
16
  "repository": {
16
17
  "type": "git",
@@ -36,11 +37,12 @@
36
37
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
37
38
  "@babel/preset-flow": "^7.25.9",
38
39
  "@babel/preset-typescript": "^7.27.0",
40
+ "@eslint/js": "^9.39.2",
39
41
  "@types/ace": "^0.0.52",
40
42
  "@types/jest": "^29.5.14",
41
43
  "@types/request": "^2.48.12",
42
- "@typescript-eslint/eslint-plugin": "^8.29.1",
43
- "@typescript-eslint/parser": "^8.29.1",
44
+ "@typescript-eslint/eslint-plugin": "^8.51.0",
45
+ "@typescript-eslint/parser": "^8.51.0",
44
46
  "autoprefixer": "^10.4.21",
45
47
  "babel-core": "^6.26.3",
46
48
  "babel-jest": "^29.7.0",
@@ -48,9 +50,9 @@
48
50
  "babel-preset-env": "^1.7.0",
49
51
  "browserify": "17.0.1",
50
52
  "codecov": "^3.8.3",
51
- "eslint": "^9.24.0",
52
- "eslint-config-prettier": "^10.1.1",
53
- "eslint-plugin-prettier": "^5.2.6",
53
+ "eslint": "^9.39.2",
54
+ "eslint-config-prettier": "^10.1.8",
55
+ "eslint-plugin-prettier": "^5.5.4",
54
56
  "highlight.js": "11.11.1",
55
57
  "jest": "^29.7.0",
56
58
  "jest-each": "^29.7.0",
@@ -61,9 +63,11 @@
61
63
  "postcss-cli": "^11.0.1",
62
64
  "pre-commit": "^1.2.2",
63
65
  "prettier": "^3.5.3",
66
+ "sass": "^1.97.1",
64
67
  "ts-jest": "^29.3.1",
65
68
  "typedoc": "^0.28.2",
66
69
  "typescript": "^5.8.3",
70
+ "typescript-eslint": "^8.51.0",
67
71
  "typescript-tslint-plugin": "^1.0.2",
68
72
  "webpack": "^5.99.3",
69
73
  "webpack-cli": "^6.0.1"
@@ -75,22 +79,25 @@
75
79
  "lintfix",
76
80
  "test"
77
81
  ],
78
- "directories": {
79
- "lib": "lib"
80
- },
81
82
  "scripts": {
82
83
  "clean": "rm -Rf lib && jest --clearCache && rm -rf static/lib",
83
84
  "builddocs": "npx typedoc",
84
85
  "buildbase": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
85
- "buildumd": "npm run builddocs && npm run buildbase && webpack --mode=development",
86
- "build": "npm run builddocs && npm run buildbase",
86
+ "build:css": "mkdir -p dist && sass styles/NotationView.scss dist/NotationView.css --style=expanded && sass styles/NotationView.scss dist/NotationView.min.css --style=compressed",
87
+ "build:umd": "webpack --mode=development && webpack --mode=production",
88
+ "build": "npm run builddocs && npm run buildbase && npm run build:css && npm run build:umd",
87
89
  "test": "jest --coverage --runInBand",
88
- "lint": "eslint './src' --quiet --ext .ts --resolve-plugins-relative-to .",
89
- "lintfix": "eslint 'src/**/*.ts' --quiet --fix --resolve-plugins-relative-to .",
90
+ "lint": "eslint src --quiet",
91
+ "lintfix": "eslint src --quiet --fix",
90
92
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
91
93
  "precommit-msg": "echo 'Pre-commit checks...' && exit 0",
94
+ "prepare": "npm run build",
95
+ "prepublishOnly": "echo prepublishOnly...",
92
96
  "preversion": "npm run build && npm run lintfix",
93
97
  "version": "git add -A src",
94
98
  "postversion": "git push && git push --tags"
99
+ },
100
+ "directories": {
101
+ "lib": "lib"
95
102
  }
96
- }
103
+ }
@@ -1,3 +1,83 @@
1
+ /* ========================================
2
+ CSS Custom Properties (Theme Variables)
3
+ ======================================== */
4
+
5
+ :root {
6
+ /* Colors */
7
+ --notation-stroke-color: black;
8
+ --notation-fill-color: transparent;
9
+ --notation-text-color: #1a1a1a;
10
+ --notation-border-color: gray;
11
+
12
+ /* Strokes */
13
+ --notation-stroke-width: 1;
14
+ --notation-bar-line-width: 1;
15
+
16
+ /* Spacing (can be overridden) */
17
+ --notation-line-padding: 5px;
18
+ --notation-annotation-padding: 10px;
19
+ }
20
+
21
+ /* Dark mode */
22
+ :root.dark,
23
+ [data-theme="dark"] {
24
+ --notation-stroke-color: #e5e5e5;
25
+ --notation-fill-color: transparent;
26
+ --notation-text-color: #f0f0f0;
27
+ --notation-border-color: #555;
28
+ }
29
+
30
+ /* System preference fallback */
31
+ @media (prefers-color-scheme: dark) {
32
+ :root:not(.light):not([data-theme="light"]) {
33
+ --notation-stroke-color: #e5e5e5;
34
+ --notation-fill-color: transparent;
35
+ --notation-text-color: #f0f0f0;
36
+ --notation-border-color: #555;
37
+ }
38
+ }
39
+
40
+ /* ========================================
41
+ SVG Element Styles
42
+ ======================================== */
43
+
44
+ /* Octave indicator dots */
45
+ .notation-octave-dot {
46
+ stroke: var(--notation-stroke-color);
47
+ stroke-width: var(--notation-stroke-width);
48
+ }
49
+
50
+ /* Bar lines (start and end) */
51
+ .bar-start-line,
52
+ .bar-end-line {
53
+ stroke: var(--notation-stroke-color);
54
+ stroke-width: var(--notation-bar-line-width);
55
+ }
56
+
57
+ /* Jaaru (glide) paths */
58
+ .notation-jaaru-path {
59
+ stroke: var(--notation-stroke-color);
60
+ fill: var(--notation-fill-color);
61
+ }
62
+
63
+ /* Text elements - target all SVG text within notation */
64
+ .notationsContentRootTable text,
65
+ .atomViewTextRoot,
66
+ .notation-embelishment-label {
67
+ fill: var(--notation-text-color);
68
+ }
69
+
70
+ /* HTML text elements (metadata, headings, markdown content) */
71
+ .notationsContentRootTable,
72
+ .rawBlockContentCell,
73
+ .rawBlockContentCell * {
74
+ color: var(--notation-text-color);
75
+ }
76
+
77
+ /* ========================================
78
+ Layout Styles
79
+ ======================================== */
80
+
1
81
  .lineRow {
2
82
  border: none;
3
83
  }
@@ -30,6 +110,6 @@
30
110
  }
31
111
 
32
112
  .notationsContentRootTable {
33
- border-top: solid 1px gray;
113
+ border-top: solid 1px var(--notation-border-color);
34
114
  width: 100%;
35
115
  }