diff --git a/.gitattributes b/.gitattributes index 27e475e..61784d0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,5 @@ * text=auto eol=lf *.png binary -*.ttf binary # Generated: review the source instead. lua/mistpine/palette.lua linguist-generated diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..2584b0c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: + # @mistpine/port-kit and its reusable workflow; other updates are by hand. + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + allow: + - dependency-name: "@mistpine/port-kit" + commit-message: + prefix: build + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + allow: + - dependency-name: "mistpine/port-kit*" + commit-message: + prefix: ci diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c64300..33245e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,10 +61,9 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} version: 2.5.2 args: --check . - - uses: actions/setup-node@v7 - with: - node-version: 24 - - run: corepack enable - - run: pnpm install --frozen-lockfile - - run: pnpm lint - - run: pnpm typecheck + + # The banner and render scripts: pnpm lint and typecheck. + scripts: + uses: mistpine/port-kit/.github/workflows/port.yml@v0.1.0 + with: + check: false diff --git a/README.md b/README.md index 7587385..36865bc 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,9 @@ make images # README images (pnpm install first; Node 24+, Chromium) [`palette/mistpine.json`](https://github.com/mistpine/mistpine/blob/main/palette/mistpine.json); change colors upstream, then sync. Screenshots come from a real Neovim: `pnpm render` runs an isolated LazyVim under `nvim --embed` and draws its screen in Chromium. +The banner comes from +[@mistpine/port-kit](https://github.com/mistpine/port-kit), shared by every mistpine port. ## License -[MIT](LICENSE). Outfit and JetBrains Mono (in `scripts/fonts`, for the banner) are under the -SIL Open Font License 1.1. +[MIT](LICENSE). diff --git a/biome.json b/biome.json index 102b8ae..1bf60e8 100644 --- a/biome.json +++ b/biome.json @@ -1,28 +1,7 @@ { "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", - "vcs": { - "enabled": true, - "clientKind": "git", - "useIgnoreFile": true - }, + "extends": ["@mistpine/port-kit/biome"], "files": { "includes": ["**", "!**/assets", "!**/*.md", "!**/*.lua", "!scripts/render/sample", "!.cache"] - }, - "formatter": { - "indentStyle": "space", - "indentWidth": 2, - "lineWidth": 100 - }, - "linter": { - "rules": { - "preset": "recommended" - } - }, - "assist": { - "actions": { - "source": { - "organizeImports": "on" - } - } } } diff --git a/package.json b/package.json index f84bc6e..7451b8e 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,9 @@ }, "devDependencies": { "@biomejs/biome": "^2.6.5", + "@mistpine/port-kit": "^0.1.0", "@msgpack/msgpack": "^3.1.3", "@types/node": "^26.6.6", - "harfbuzzjs": "^1.6.4", "playwright-core": "^1.64.1", "typescript": "^7.0.2" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d57dd00..8f0867b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,15 +11,15 @@ importers: '@biomejs/biome': specifier: ^2.6.5 version: 2.6.5 + '@mistpine/port-kit': + specifier: ^0.1.0 + version: 0.1.0 '@msgpack/msgpack': specifier: ^3.1.3 version: 3.1.3 '@types/node': specifier: ^26.6.6 version: 26.6.6 - harfbuzzjs: - specifier: ^1.6.4 - version: 1.6.4 playwright-core: specifier: ^1.64.1 version: 1.64.1 @@ -98,6 +98,10 @@ packages: cpu: [x64] os: [win32] + '@mistpine/port-kit@0.1.0': + resolution: {integrity: sha512-GWwnrPHejjpfC3SfmW0MVOmc4CCHuvb8Jwgeh/pHPJ+VUqT5/dPulv77a13E0Hk6RlTjT3CTUAGKxs+NQ/XpNg==} + engines: {node: '>=24'} + '@msgpack/msgpack@3.1.3': resolution: {integrity: sha512-47XIizs9XZXvuJgoaJUIE2lFoID8ugvc0jzSHP+Ptfk8nTbnR8g788wv48N03Kx0UkAv559HWRQ3yzOgzlRNUA==} engines: {node: '>= 18'} @@ -286,6 +290,11 @@ snapshots: '@biomejs/cli-win32-x64@2.6.5': optional: true + '@mistpine/port-kit@0.1.0': + dependencies: + harfbuzzjs: 1.6.4 + playwright-core: 1.64.1 + '@msgpack/msgpack@3.1.3': {} '@types/node@26.6.6': diff --git a/scripts/banner.ts b/scripts/banner.ts index be33de4..5821988 100644 --- a/scripts/banner.ts +++ b/scripts/banner.ts @@ -1,99 +1,23 @@ /** - * Writes the README banner and the GitHub social preview, after the - * "Port banner A · centered lockup" board of the mistpine logos canvas: - * the mark and `mistpine.nvim` centered on the editor background, over a - * band of the accents. + * Writes the README banner and the GitHub social preview with + * @mistpine/port-kit: the mistpine lockup with the `.nvim` suffix in + * brightGreen (docs/brand.md in mistpine/mistpine). * * pnpm banner * - * Text is outlined with HarfBuzz (scripts/lib/text.ts), so the SVGs need no - * fonts. The PNG is drawn by Chromium (CHROMIUM overrides playwright's). + * The colors come from the colorscheme itself (lib/colors.ts). The PNG is + * drawn by Chromium (CHROMIUM overrides playwright's). */ -import { writeFileSync } from "node:fs"; import { join } from "node:path"; -import { pathToFileURL } from "node:url"; -import { chromium } from "playwright-core"; +import { writeBanners } from "@mistpine/port-kit/banner"; import { loadColors, ROOT } from "./lib/colors.ts"; -import { num, shape, type TextStyle, textPath } from "./lib/text.ts"; -const { palette: p, ansi } = loadColors(); -const c = (key: string) => { - const v = p[key]; - if (!v) throw new Error(`palette has no ${key}`); - return v; -}; - -const [W, H, BAND] = [1280, 640, 10]; -const MARK = 180; -const GAP = 36; -const WORD: TextStyle = { family: "outfit", size: 104, weight: 300, tracking: -0.03 }; -const SUFFIX: TextStyle = { family: "mono", size: 80, weight: 300, tracking: -0.02 }; -/** The suffix color for mistpine.nvim (docs/brand.md in mistpine/mistpine). */ -const ACCENT = c("brightGreen"); - -/** The mark (120 × 120 units): three pines with fog between them. */ -function mark(x: number, y: number, size: number): string { - const wave = "q7 -5 14 0 t14 0 t14 0 t14 0 t14 0"; - const fog = (d: string, color: string) => - ``; - const pine = (d: string, color: string) => ``; - return `${[ - pine("M60 8 L84 76 L36 76 Z", c("fg0")), - fog(`M34 64 ${wave}`, c("bg4")), - pine("M80 30 L104 98 L56 98 Z", c("fg1")), - fog(`M44 86 ${wave}`, c("fg2")), - pine("M38 38 L64 110 L12 110 Z", c("brightCyan")), - fog(`M4 98 ${wave}`, c("fg3")), - ].join("")}`; -} - -function banner(rounded: boolean): string { - const word = shape("mistpine", WORD); - const suffix = shape(".nvim", SUFFIX); - // CSS letter spacing also follows the last letter of each run. - const wordAdvance = word.width + (WORD.tracking ?? 0) * WORD.size; - const textW = wordAdvance + suffix.width + (SUFFIX.tracking ?? 0) * SUFFIX.size; - const x0 = (W - (MARK + GAP + textW)) / 2; - const cy = (H - BAND) / 2; - // Center the line box both runs share, as flexbox does. - const ascent = Math.max(word.ascent, suffix.ascent); - const descent = Math.max(word.descent, suffix.descent); - const baseline = cy - (ascent + descent) / 2 + ascent; - const tx = x0 + MARK + GAP; - - const accents = ["red", "orange", "yellow", "green", "cyan", "blue", "purple"].map(c); - const band = [...accents, ansi[5] as string, c("pink")]; - const segment = W / band.length; - const stripes = band - .map( - (color, i) => - ``, - ) - .join(""); - - const label = "mistpine.nvim: the mistpine color scheme for Neovim"; - const card = `${stripes}`; - const body = [ - rounded - ? `${card}` - : card, - mark(x0, cy - MARK / 2, MARK), - textPath("mistpine", WORD, tx, baseline, c("fg3")), - textPath(".nvim", SUFFIX, tx + wordAdvance, baseline, ACCENT), - ].join(""); - return `${label}${body}\n`; -} - -const assets = join(ROOT, "assets"); -writeFileSync(join(assets, "banner.svg"), banner(true)); -writeFileSync(join(assets, "social-preview.svg"), banner(false)); - -const browser = await chromium.launch({ executablePath: process.env.CHROMIUM || undefined }); -try { - const page = await browser.newPage({ viewport: { width: W, height: H } }); - await page.goto(pathToFileURL(join(assets, "social-preview.svg")).href); - await page.screenshot({ path: join(assets, "social-preview.png") }); -} finally { - await browser.close(); -} +const { palette, ansi } = loadColors(); +await writeBanners(join(ROOT, "assets"), { + palette, + ansi, + suffix: ".nvim", + accent: "brightGreen", + label: "mistpine.nvim: the mistpine color scheme for Neovim", +}); console.log("wrote assets/banner.svg, assets/social-preview.svg, assets/social-preview.png"); diff --git a/scripts/fonts/JetBrainsMono-wght.ttf b/scripts/fonts/JetBrainsMono-wght.ttf deleted file mode 100644 index 4a1c09e..0000000 Binary files a/scripts/fonts/JetBrainsMono-wght.ttf and /dev/null differ diff --git a/scripts/fonts/OFL-JetBrainsMono.txt b/scripts/fonts/OFL-JetBrainsMono.txt deleted file mode 100644 index 821a3da..0000000 --- a/scripts/fonts/OFL-JetBrainsMono.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono) - -This Font Software is licensed under the SIL Open Font License, Version 1.1. - -This license is copied below, and is also available with a FAQ at: https://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/scripts/fonts/OFL-Outfit.txt b/scripts/fonts/OFL-Outfit.txt deleted file mode 100644 index 723cd44..0000000 --- a/scripts/fonts/OFL-Outfit.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright 2021 The Outfit Project Authors (https://github.com/Outfitio/Outfit-Fonts) - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -https://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/scripts/fonts/Outfit-wght.ttf b/scripts/fonts/Outfit-wght.ttf deleted file mode 100644 index 5bd8638..0000000 Binary files a/scripts/fonts/Outfit-wght.ttf and /dev/null differ diff --git a/scripts/lib/text.ts b/scripts/lib/text.ts deleted file mode 100644 index dfd775a..0000000 --- a/scripts/lib/text.ts +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Text as SVG paths: HarfBuzz shapes the string (kerning included) and the glyph - * outlines become one ``, so logos and specimens render the same everywhere, - * with no font files to load. - */ -import { readFileSync } from "node:fs"; -import { join } from "node:path"; -import * as hb from "harfbuzzjs"; -import { ROOT } from "./colors.ts"; - -export type Family = "outfit" | "mono"; - -const FILES: Record = { - outfit: "Outfit-wght.ttf", - mono: "JetBrainsMono-wght.ttf", -}; - -const faces = new Map(); -function face(family: Family): hb.Face { - let f = faces.get(family); - if (!f) { - const data = readFileSync(join(ROOT, "scripts", "fonts", FILES[family])); - f = new hb.Face(new hb.Blob(new Uint8Array(data))); - faces.set(family, f); - } - return f; -} - -export interface TextStyle { - family: Family; - size: number; - weight?: number; - /** CSS-style letter spacing in em. */ - tracking?: number; -} - -export interface Shaped { - /** Path data with the baseline at y = 0 and the text starting at x = 0. */ - d: string; - width: number; - /** Line box above and below the baseline (positive numbers), as CSS lays it out. */ - ascent: number; - descent: number; -} - -const num = (n: number) => { - const r = Math.round(n * 100) / 100; - return Object.is(r, -0) ? "0" : String(r); -}; - -export function shape(text: string, style: TextStyle): Shaped { - const font = new hb.Font(face(style.family)); - font.setVariations([new hb.Variation("wght", style.weight ?? 400)]); - const scale = style.size / face(style.family).upem; - const tracking = (style.tracking ?? 0) * style.size; - - const buffer = new hb.Buffer(); - buffer.addText(text); - buffer.guessSegmentProperties(); - hb.shape(font, buffer); - - const parts: string[] = []; - let pen = 0; - const infos = buffer.getGlyphInfos(); - const positions = buffer.getGlyphPositions(); - infos.forEach((info, i) => { - const pos = positions[i]; - if (!pos) return; - const ox = pen + pos.xOffset * scale; - const oy = -pos.yOffset * scale; - const raw = font.glyphToPath(info.codepoint); - // Commands are absolute (M L Q C Z) in font units, y up: flip and place them. - parts.push( - raw.replace(/(-?[\d.]+),?\s*(-?[\d.]+)/g, (_, x: string, y: string) => { - return `${num(ox + Number(x) * scale)} ${num(oy - Number(y) * scale)}`; - }), - ); - pen += pos.xAdvance * scale + tracking; - }); - const ext = font.hExtents(); - // CSS adds letter spacing after the last glyph too; leave it out of the ink width. - return { - d: parts.join(""), - width: pen - tracking, - ascent: ext.ascender * scale, - descent: -ext.descender * scale, - }; -} - -/** A `` with the text's baseline starting at (x, y). */ -export function textPath( - text: string, - style: TextStyle, - x: number, - y: number, - fill: string, - attrs = "", -): string { - const { d } = shape(text, style); - return ``; -} - -export { num }; diff --git a/tsconfig.json b/tsconfig.json index 81421a7..01893d3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,5 @@ { - "compilerOptions": { - "target": "ES2024", - "lib": ["ES2024", "DOM"], - "module": "NodeNext", - "moduleResolution": "NodeNext", - "strict": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true, - "erasableSyntaxOnly": true, - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "noEmit": true, - "skipLibCheck": true, - "types": ["node"] - }, + "extends": "@mistpine/port-kit/tsconfig.json", "include": ["scripts"], "exclude": ["scripts/render/sample"] }