Drop the web app; the macOS app is byre's only client
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
// Code generated by go generate ./mac from web/style.css. DO NOT EDIT.
|
||||
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
|
||||
+2
-3
@@ -1,10 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
mac=$(cd "$(dirname "$0")" && pwd)
|
||||
root=$(dirname "$mac")
|
||||
build=$mac/.build
|
||||
app=$build/byre.app
|
||||
svg=$root/web/favicon-tile.svg
|
||||
svg=$mac/icon.svg
|
||||
icns=$build/byre.icns
|
||||
swift build --package-path "$mac" --configuration release
|
||||
if [ ! "$icns" -nt "$svg" ]; then
|
||||
@@ -21,7 +20,7 @@ rm -rf "$app"
|
||||
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources/fonts"
|
||||
cp "$build/release/Byre" "$app/Contents/MacOS/Byre"
|
||||
cp "$mac/Info.plist" "$app/Contents/Info.plist"
|
||||
cp "$root"/web/fonts/*.woff2 "$app/Contents/Resources/fonts/"
|
||||
cp "$mac"/fonts/*.woff2 "$app/Contents/Resources/fonts/"
|
||||
cp "$icns" "$app/Contents/Resources/byre.icns"
|
||||
cp "$mac/byre.provisionprofile" "$app/Contents/embedded.provisionprofile"
|
||||
codesign --force --sign "Apple Development" --entitlements "$mac/byre.entitlements" "$app"
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2020-2024 The Atkinson Hyperlegible Mono Project Authors (https://github.com/googlefonts/atkinson-hyperlegible-next-mono) AtkinsonHyperlegibleMono-Italic[wght].ttf: Copyright 2020-2024 The Atkinson Hyperlegible Mono Project Authors (https://github.com/googlefonts/atkinson-hyperlegible-next-mono)
|
||||
|
||||
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:
|
||||
http://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.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
package mac
|
||||
|
||||
//go:generate go run ./palette
|
||||
@@ -0,0 +1,18 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36">
|
||||
<rect width="36" height="36" fill="#1c1f23"/>
|
||||
<g transform="translate(2 2.5)" stroke="#a9b1bc" stroke-width="1.5">
|
||||
<line x1="16" y1="16" x2="16" y2="4"/>
|
||||
<line x1="16" y1="16" x2="27.4" y2="12.3"/>
|
||||
<line x1="16" y1="16" x2="23.1" y2="25.7"/>
|
||||
<line x1="16" y1="16" x2="8.9" y2="25.7"/>
|
||||
<line x1="16" y1="16" x2="4.6" y2="12.3"/>
|
||||
</g>
|
||||
<g transform="translate(2 2.5)">
|
||||
<circle fill="#3d7dff" cx="16" cy="16" r="6"/>
|
||||
<circle fill="#ff3b4e" cx="16" cy="4" r="3.5"/>
|
||||
<circle fill="#ff9500" cx="27.4" cy="12.3" r="3.5"/>
|
||||
<circle fill="#34d058" cx="23.1" cy="25.7" r="3.5"/>
|
||||
<circle fill="#b05cff" cx="8.9" cy="25.7" r="3.5"/>
|
||||
<circle fill="#00d5f0" cx="4.6" cy="12.3" r="3.5"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 744 B |
@@ -1,95 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
property = regexp.MustCompile(`^\s*--([a-z0-9-]+):\s*#([0-9a-f]{6});\s*$`)
|
||||
darkOpen = regexp.MustCompile(`^@media \(prefers-color-scheme: dark\) \{$`)
|
||||
)
|
||||
|
||||
func block(lines []string, start int) (map[string]string, []string) {
|
||||
colors := map[string]string{}
|
||||
order := []string{}
|
||||
for _, line := range lines[start+1:] {
|
||||
if strings.TrimSpace(line) == "}" {
|
||||
return colors, order
|
||||
}
|
||||
m := property.FindStringSubmatch(line)
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
colors[m[1]] = m[2]
|
||||
order = append(order, m[1])
|
||||
}
|
||||
log.Fatalf("unterminated block at line %d", start+1)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func swiftName(prop string) string {
|
||||
parts := strings.Split(prop, "-")
|
||||
for i := 1; i < len(parts); i++ {
|
||||
parts[i] = strings.ToUpper(parts[i][:1]) + parts[i][1:]
|
||||
}
|
||||
return strings.Join(parts, "")
|
||||
}
|
||||
|
||||
func main() {
|
||||
css, err := os.ReadFile("../web/style.css")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
lines := strings.Split(string(css), "\n")
|
||||
lightAt, darkAt := -1, -1
|
||||
for i, line := range lines {
|
||||
if line == ":root {" && lightAt < 0 {
|
||||
lightAt = i
|
||||
}
|
||||
if darkOpen.MatchString(line) && i+1 < len(lines) && strings.TrimSpace(lines[i+1]) == ":root {" {
|
||||
darkAt = i + 1
|
||||
}
|
||||
}
|
||||
if lightAt < 0 || darkAt < 0 {
|
||||
log.Fatal("web/style.css has no :root block or no prefers-color-scheme: dark :root block")
|
||||
}
|
||||
light, order := block(lines, lightAt)
|
||||
dark, _ := block(lines, darkAt)
|
||||
|
||||
var b strings.Builder
|
||||
b.WriteString("// Code generated by go generate ./mac from web/style.css. DO NOT EDIT.\n\n")
|
||||
b.WriteString("import AppKit\nimport SwiftUI\n\n")
|
||||
b.WriteString("enum Palette {\n")
|
||||
for _, prop := range order {
|
||||
d, ok := dark[prop]
|
||||
if !ok {
|
||||
log.Fatalf("--%s has no dark value", prop)
|
||||
}
|
||||
fmt.Fprintf(&b, " static let %s = dynamic(0x%s, 0x%s)\n", swiftName(prop), light[prop], d)
|
||||
}
|
||||
for prop := range dark {
|
||||
if _, ok := light[prop]; !ok {
|
||||
log.Fatalf("--%s has no light value", prop)
|
||||
}
|
||||
}
|
||||
b.WriteString(`
|
||||
private static func rgb(_ hex: UInt32) -> NSColor {
|
||||
NSColor(srgbRed: CGFloat(hex >> 16 & 0xff) / 255, green: CGFloat(hex >> 8 & 0xff) / 255, blue: CGFloat(hex & 0xff) / 255, alpha: 1)
|
||||
}
|
||||
|
||||
private static func dynamic(_ light: UInt32, _ dark: UInt32) -> Color {
|
||||
Color(nsColor: NSColor(name: nil) { appearance in
|
||||
appearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua ? rgb(dark) : rgb(light)
|
||||
})
|
||||
}
|
||||
}
|
||||
`)
|
||||
err = os.WriteFile("Sources/Byre/Palette.swift", []byte(b.String()), 0o644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user