this repo has no description
www.jonmsterling.com/01HC/
1// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers
2//
3// SPDX-License-Identifier: MPL-2.0
4
5import Foundation
6import TSCBasic
7import llbuild2fx
8
9extension Keys {
10 struct SourceCode: BuildKey {
11 struct ValueType: Codable, FXValue {
12 let code: String
13 }
14
15 enum SourceCodeError: Error {
16 case unitNotFound
17 }
18
19 let sourceTreeId: LLBDataID
20 let unitName: UnitName
21
22 static let versionDependencies: [any FXVersioning.Type] = [UnitMapOfSourceTree.self]
23
24 func computeValue(_ ctx: BuildContext<Self>) async throws -> ValueType {
25 let unitMap = try await ctx.request(UnitMapOfSourceTree(sourceTreeId: sourceTreeId))
26 guard let unitInfo = unitMap.units[unitName] else { throw SourceCodeError.unitNotFound }
27 let contents = try await ctx.load(unitInfo.blobId)
28 let code = try await String(decoding: Data(ctx.read(blob: contents.blob!)), as: UTF8.self)
29 return ValueType(code: code)
30 }
31 }
32}