diff --git a/.github/set-macos-marketing-version.rb b/.github/set-macos-marketing-version.rb deleted file mode 100644 index 4fdac3d9..00000000 --- a/.github/set-macos-marketing-version.rb +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# Updates only the build configurations belonging to the macOS Textream target. -# Keeping this scoped prevents a macOS release tag from changing the independent -# marketing version of the TextreamiOS app and its test bundle. - -version = ARGV.fetch(0) do - abort "Usage: #{$PROGRAM_NAME} [project.pbxproj]" -end - -unless version.match?(/\A\d+(?:\.\d+){0,2}\z/) - abort "Invalid Apple marketing version: #{version.inspect}" -end - -project_path = ARGV[1] || File.expand_path( - "../Textream/Textream.xcodeproj/project.pbxproj", - __dir__ -) -source = File.binread(project_path) - -native_targets = source[/\/\* Begin PBXNativeTarget section \*\/.*?\/\* End PBXNativeTarget section \*\//m] -abort "PBXNativeTarget section not found" unless native_targets - -target = native_targets.match( - /^\s*[0-9A-F]+ \/\* Textream \*\/ = \{(?.*?)^\s*\};/m -) -abort 'macOS target "Textream" not found' unless target - -configuration_list_id = target[:body][ - /buildConfigurationList = ([0-9A-F]+) \/\* Build configuration list for PBXNativeTarget "Textream" \*\//, - 1 -] -abort "macOS target configuration list not found" unless configuration_list_id - -configuration_lists = source[/\/\* Begin XCConfigurationList section \*\/.*?\/\* End XCConfigurationList section \*\//m] -abort "XCConfigurationList section not found" unless configuration_lists - -configuration_list = configuration_lists.match( - /^\s*#{Regexp.escape(configuration_list_id)} \/\*.*?\*\/ = \{(?.*?)^\s*\};/m -) -abort "macOS target configuration list block not found" unless configuration_list - -configuration_ids_match = configuration_list[:body].match( - /buildConfigurations = \((?.*?)\);/m -) -configuration_ids = configuration_ids_match&.[](:ids) - &.scan(/^\s*([0-9A-F]+) \/\*/)&.flatten - -unless configuration_ids&.length == 3 - abort "Expected 3 macOS target configurations, found #{configuration_ids&.length || 0}" -end - -updated = source.dup -configuration_ids.each do |configuration_id| - block_pattern = /^\s*#{Regexp.escape(configuration_id)} \/\*.*?\*\/ = \{.*?^\s*\};/m - block = updated[block_pattern] - abort "Configuration #{configuration_id} not found" unless block - - settings = block.scan(/^\s*MARKETING_VERSION = [^;]+;/) - unless settings.length == 1 - abort "Expected one MARKETING_VERSION in #{configuration_id}, found #{settings.length}" - end - - replacement = block.sub( - /^(\s*MARKETING_VERSION = )[^;]+;/, - "\\1#{version};" - ) - updated.sub!(block, replacement) -end - -File.binwrite(project_path, updated) -puts "Set macOS Textream marketing version to #{version} in #{configuration_ids.length} configurations." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ec30e072..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,291 +0,0 @@ -name: Build & Release - -on: - push: - tags: - - 'v*' - -permissions: - contents: write - -concurrency: - group: textream-release - cancel-in-progress: false - -jobs: - version: - runs-on: macos-15 - outputs: - tag: ${{ steps.version.outputs.tag }} - number: ${{ steps.version.outputs.number }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: master - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Get version from tag - id: version - run: | - TAG="${GITHUB_REF#refs/tags/}" - VERSION="${TAG#v}" - echo "tag=${TAG}" >> "$GITHUB_OUTPUT" - echo "number=${VERSION}" >> "$GITHUB_OUTPUT" - - - name: Update macOS app version in Xcode project - run: | - ruby .github/set-macos-marketing-version.rb "${{ steps.version.outputs.number }}" - - - name: Commit version bump - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add Textream/Textream.xcodeproj/project.pbxproj - git commit -m "Bump version to ${{ steps.version.outputs.number }}" || echo "No changes to commit" - git push origin HEAD:refs/heads/master - - build: - needs: version - strategy: - fail-fast: false - matrix: - include: - - runner: macos-15 - xcode: /Applications/Xcode_16.2.app/Contents/Developer - suffix: "-macos15" - - runner: macos-26 - xcode: /Applications/Xcode_26.0.app/Contents/Developer - suffix: "" - runs-on: ${{ matrix.runner }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.ref }} - - - name: Update macOS app version - run: | - ruby .github/set-macos-marketing-version.rb "${{ needs.version.outputs.number }}" - - - name: Select Xcode - run: sudo xcode-select -s ${{ matrix.xcode }} - - - name: Import Developer ID certificate - env: - DEVELOPER_ID_P12_BASE64: ${{ secrets.DEVELOPER_ID_P12_BASE64 }} - DEVELOPER_ID_P12_PASSWORD: ${{ secrets.DEVELOPER_ID_P12_PASSWORD }} - run: | - CERTIFICATE_PATH="$RUNNER_TEMP/developer-id.p12" - INTERMEDIATE_PATH="$RUNNER_TEMP/DeveloperIDG2CA.cer" - KEYCHAIN_PATH="$RUNNER_TEMP/textream-signing.keychain-db" - KEYCHAIN_PASSWORD="$(openssl rand -hex 24)" - - printf '%s' "$DEVELOPER_ID_P12_BASE64" | base64 --decode > "$CERTIFICATE_PATH" - chmod 600 "$CERTIFICATE_PATH" - curl --fail --silent --show-error \ - https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer \ - --output "$INTERMEDIATE_PATH" - - security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH" - security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - security import "$INTERMEDIATE_PATH" -k "$KEYCHAIN_PATH" - security import "$CERTIFICATE_PATH" \ - -k "$KEYCHAIN_PATH" \ - -P "$DEVELOPER_ID_P12_PASSWORD" \ - -f pkcs12 \ - -T /usr/bin/codesign - security set-key-partition-list \ - -S apple-tool:,apple:,codesign: \ - -s \ - -k "$KEYCHAIN_PASSWORD" \ - "$KEYCHAIN_PATH" - security list-keychains -d user -s "$KEYCHAIN_PATH" - - SIGNING_IDENTITY="$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" \ - | awk '/Developer ID Application:/{print $2; exit}')" - test -n "$SIGNING_IDENTITY" - - echo "SIGNING_IDENTITY=$SIGNING_IDENTITY" >> "$GITHUB_ENV" - - - name: Build universal app - working-directory: Textream - run: | - chmod +x build.sh - ./build.sh - - - name: Rename DMG - if: matrix.suffix != '' - run: mv Textream/build/release/Textream.dmg Textream/build/release/Textream${{ matrix.suffix }}.dmg - - - name: Notarize and validate DMG - env: - APPLE_API_ISSUER_ID: ${{ secrets.APPLE_API_ISSUER_ID }} - APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} - APPLE_API_KEY_P8_BASE64: ${{ secrets.APPLE_API_KEY_P8_BASE64 }} - run: | - DMG_PATH="Textream/build/release/Textream${{ matrix.suffix }}.dmg" - NOTARY_KEY_PATH="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8" - NOTARY_RESULT_PATH="$RUNNER_TEMP/notary-result.json" - NOTARY_LOG_PATH="$RUNNER_TEMP/notary-log.json" - - printf '%s' "$APPLE_API_KEY_P8_BASE64" | base64 --decode > "$NOTARY_KEY_PATH" - chmod 600 "$NOTARY_KEY_PATH" - - set +e - xcrun notarytool submit "$DMG_PATH" \ - --key "$NOTARY_KEY_PATH" \ - --key-id "$APPLE_API_KEY_ID" \ - --issuer "$APPLE_API_ISSUER_ID" \ - --wait \ - --timeout 30m \ - --output-format json > "$NOTARY_RESULT_PATH" - NOTARY_EXIT="$?" - set -e - cat "$NOTARY_RESULT_PATH" - - SUBMISSION_ID="$(plutil -extract id raw -o - "$NOTARY_RESULT_PATH" 2>/dev/null || true)" - STATUS="$(plutil -extract status raw -o - "$NOTARY_RESULT_PATH" 2>/dev/null || true)" - if [ -n "$SUBMISSION_ID" ]; then - xcrun notarytool log "$SUBMISSION_ID" "$NOTARY_LOG_PATH" \ - --key "$NOTARY_KEY_PATH" \ - --key-id "$APPLE_API_KEY_ID" \ - --issuer "$APPLE_API_ISSUER_ID" || true - if [ -f "$NOTARY_LOG_PATH" ]; then - cat "$NOTARY_LOG_PATH" - fi - fi - if [ "$NOTARY_EXIT" -ne 0 ] || [ "$STATUS" != "Accepted" ]; then - exit 1 - fi - - xcrun stapler staple "$DMG_PATH" - xcrun stapler validate "$DMG_PATH" - hdiutil verify "$DMG_PATH" - codesign --verify --strict --verbose=2 "$DMG_PATH" - spctl --assess \ - --type open \ - --context context:primary-signature \ - --verbose=4 \ - "$DMG_PATH" - - MOUNT_DIR="$(mktemp -d)" - cleanup_mount() { - hdiutil detach "$MOUNT_DIR" -quiet 2>/dev/null || true - rmdir "$MOUNT_DIR" 2>/dev/null || true - } - trap cleanup_mount EXIT - hdiutil attach "$DMG_PATH" -nobrowse -readonly -mountpoint "$MOUNT_DIR" -quiet - codesign --verify --deep --strict --verbose=2 "$MOUNT_DIR/Textream.app" - spctl --assess --type execute --verbose=4 "$MOUNT_DIR/Textream.app" - hdiutil detach "$MOUNT_DIR" -quiet - rmdir "$MOUNT_DIR" - trap - EXIT - - - name: Upload DMG artifact - uses: actions/upload-artifact@v4 - with: - name: dmg${{ matrix.suffix }} - path: Textream/build/release/Textream${{ matrix.suffix }}.dmg - - - name: Remove signing credentials - if: always() - env: - APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} - run: | - security delete-keychain \ - "$RUNNER_TEMP/textream-signing.keychain-db" 2>/dev/null || true - rm -f \ - "$RUNNER_TEMP/developer-id.p12" \ - "$RUNNER_TEMP/DeveloperIDG2CA.cer" \ - "$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8" \ - "$RUNNER_TEMP/notary-result.json" \ - "$RUNNER_TEMP/notary-log.json" - - release: - needs: [version, build] - runs-on: macos-15 - steps: - - name: Download all DMGs - uses: actions/download-artifact@v4 - with: - path: artifacts - merge-multiple: true - - - name: Upload DMGs to GitHub Release - uses: softprops/action-gh-release@v2 - with: - files: | - artifacts/Textream.dmg - artifacts/Textream-macos15.dmg - name: Textream ${{ needs.version.outputs.tag }} - draft: false - prerelease: false - generate_release_notes: true - body: | - ## Installation - - - **Textream.dmg** — for macOS 26 Tahoe and later (recommended, includes Liquid Glass effects) - - **Textream-macos15.dmg** — for macOS 15 Sequoia - - 1. Download the DMG for your macOS version - 2. Open the DMG and drag **Textream** to Applications - 3. Open Textream normally. The app is signed and notarized by Apple. - - Or install via Homebrew: - - ``` - brew install textream - ``` - - - name: Compute DMG SHA256 - id: sha - run: | - echo "sha256_26=$(shasum -a 256 artifacts/Textream.dmg | awk '{print $1}')" >> "$GITHUB_OUTPUT" - echo "sha256_15=$(shasum -a 256 artifacts/Textream-macos15.dmg | awk '{print $1}')" >> "$GITHUB_OUTPUT" - - - name: Update Homebrew Cask tap - env: - TAP_REPO_TOKEN: ${{ secrets.TAP_REPO_TOKEN }} - VERSION: ${{ needs.version.outputs.tag }} - SHA256_26: ${{ steps.sha.outputs.sha256_26 }} - SHA256_15: ${{ steps.sha.outputs.sha256_15 }} - run: | - VERSION_NUM="${VERSION#v}" - git clone https://x-access-token:${TAP_REPO_TOKEN}@github.com/f/homebrew-textream.git tap - mkdir -p tap/Casks - cat > tap/Casks/textream.rb << CASKEOF - cask "textream" do - version "${VERSION_NUM}" - - on_sequoia do - sha256 "${SHA256_15}" - url "https://github.com/f/textream/releases/download/v#{version}/Textream-macos15.dmg" - end - - on_tahoe :or_newer do - sha256 "${SHA256_26}" - url "https://github.com/f/textream/releases/download/v#{version}/Textream.dmg" - end - - name "Textream" - desc "Teleprompter that highlights scripts in real time as you speak" - homepage "https://textream.net/" - - depends_on macos: :sequoia - - app "Textream.app" - - zap trash: [ - "~/Library/Preferences/dev.fka.textream.plist", - "~/Library/Saved Application State/dev.fka.textream.savedState", - ] - end - CASKEOF - cd tap - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add Casks/textream.rb - git commit -m "Update Textream to ${VERSION}" - git push diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..3f01e362 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,24 @@ +# Runs the core tests on every push and pull request, on a Mac: script splitting, word tracking, retake and +# command phrases, imports and session files; then builds the Mac app, unsigned. +# No microphone, speech model or Apple Intelligence needed. +name: Tests + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + tests: + runs-on: macos-26 + timeout-minutes: 30 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Core tests + run: swift test --package-path TakelineCore + - name: Mac app builds + run: xcodebuild build -project Textream/Textream.xcodeproj -scheme Textream -configuration Debug -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO -quiet diff --git a/README.md b/README.md index e20eb94c..cd1935bc 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Based on Textream by Fatih Kadir Akın.

+

Tests

+ --- Takeline shows your script right below the MacBook notch, in a floating window, fullscreen or on another display, and highlights each word as you say it. It keeps everything Textream does and adds what you need to record videos in one go: diff --git a/TakelineCore/Sources/TakelineCore/Intents.swift b/TakelineCore/Sources/TakelineCore/Intents.swift index 4347670c..76e6f92a 100644 --- a/TakelineCore/Sources/TakelineCore/Intents.swift +++ b/TakelineCore/Sources/TakelineCore/Intents.swift @@ -175,7 +175,12 @@ public actor CueJudge { What the speaker just said: \(cue.utterance.joined(separator: " ")) Phrase spotted: \(cue.phrase) """ - let verdict = try await session.respond(to: prompt, generating: Verdict.self, options: GenerationOptions(samplingMode: .greedy)).content + #if compiler(>=6.4) + let options = GenerationOptions(samplingMode: .greedy) + #else + let options = GenerationOptions(sampling: .greedy) // the label before the macOS 27 SDK + #endif + let verdict = try await session.respond(to: prompt, generating: Verdict.self, options: options).content switch verdict.kind { case .speech: return nil case .retake: return .retake diff --git a/TakelineCore/Tests/TakelineCoreTests/ImportTests.swift b/TakelineCore/Tests/TakelineCoreTests/ImportTests.swift index 3b5e8079..f0ae4f27 100644 --- a/TakelineCore/Tests/TakelineCoreTests/ImportTests.swift +++ b/TakelineCore/Tests/TakelineCoreTests/ImportTests.swift @@ -24,6 +24,15 @@ import AppKit #expect(pages == ["Intro\nHello world, see the site.\nfirst point", "Second page with code."]) } + @Test func readsTextFilesFromWindowsToo() throws { + let utf8 = FileManager.default.temporaryDirectory.appending(path: "takeline-test.txt") + try Data("\u{FEFF}Première page.\r\nDeuxième ligne.\u{0C}\r\nPage deux.".utf8).write(to: utf8) + #expect(try ScriptImport.pages(from: utf8) == ["Première page.\nDeuxième ligne.", "Page deux."]) + let utf16 = FileManager.default.temporaryDirectory.appending(path: "takeline-test-utf16.txt") + try #require("Été".data(using: .utf16)).write(to: utf16) // with a byte order mark, as Notepad saves "Unicode" + #expect(try ScriptImport.pages(from: utf16) == ["Été"]) + } + @Test func readsWordFiles() throws { #if canImport(AppKit) let url = FileManager.default.temporaryDirectory.appending(path: "takeline-test.docx") diff --git a/TakelineCore/Tests/TakelineCoreTests/SessionTests.swift b/TakelineCore/Tests/TakelineCoreTests/SessionTests.swift index dda88725..4be9da44 100644 --- a/TakelineCore/Tests/TakelineCoreTests/SessionTests.swift +++ b/TakelineCore/Tests/TakelineCoreTests/SessionTests.swift @@ -27,6 +27,30 @@ import Testing #expect(decoded == session) } + @Test func endsTakesOnJumpsBackAndKeepsLateRetakesApart() { + let start = Date(timeIntervalSince1970: 1_000) + var session = Session(app: "", title: "", pages: [bakery], languages: [], startedAt: start) + session.reading(2, at: start) + session.reading(1, at: start.addingTimeInterval(5)) + session.retake(1, trigger: .phrase, at: start.addingTimeInterval(6)) + session.retake(1, trigger: .reread, at: start.addingTimeInterval(20)) + session.reading(1, at: start.addingTimeInterval(20)) + session.finish(at: start.addingTimeInterval(30), finishedScript: true) + + #expect(session.takes.map(\.status) == [.abandoned, .abandoned, .completed]) + #expect(session.retakes.map(\.trigger) == [.phrase, .reread]) + } + + /// Editors such as Roughcut read session files as docs/session-format.md describes them. + @Test func writesTheDocumentedFormat() throws { + let doc = try String(contentsOf: URL(filePath: "../../../docs/session-format.md", relativeTo: URL(filePath: #filePath)), encoding: .utf8) + let example = Data(try #require(doc.components(separatedBy: "```json\n").dropFirst().first?.components(separatedBy: "```").first).utf8) + let session = try Session.decoded(from: example) + #expect(session.format == "takeline.session" && session.version == 1) + let written = try JSONSerialization.jsonObject(with: session.encoded()) as? NSDictionary + #expect(written == (try JSONSerialization.jsonObject(with: example) as? NSDictionary)) + } + @Test func numbersSentencesAcrossPages() { let session = Session(app: "", title: "", pages: ["One. Two.", "Three."], languages: [], startedAt: .now) #expect(session.sentenceID(page: 1, sentence: 0) == 2)