From 8146e7613524ae3c5a6090bf73b00ccb41d7a82e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 31 Dec 2025 22:22:38 +0000 Subject: [PATCH 1/5] chore: prepare for v1.0.1 release --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b8d3fe..45e13d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,3 +45,5 @@ [未リリース]: https://github.com/no-problem-dev/swift-statable/compare/v1.0.0...HEAD [1.0.0]: https://github.com/no-problem-dev/swift-statable/releases/tag/v1.0.0 + + From b48935e7bd78e41c5ab5404452477183b4e49498 Mon Sep 17 00:00:00 2001 From: no-problem-kyoichi Date: Thu, 1 Jan 2026 07:52:55 +0900 Subject: [PATCH 2/5] =?UTF-8?q?refactor:=20@Statable=20=E3=83=9E=E3=82=AF?= =?UTF-8?q?=E3=83=AD=E3=81=8B=E3=82=89=20public=20init()=20=E3=81=AE?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E7=94=9F=E6=88=90=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Observable マクロとの相互作用問題を回避するため、init の自動生成を削除。 ユーザーが明示的に `public init() {}` を定義する形に変更。 変更内容: - StatableMacro.swift: init 生成ロジックを削除 - Macros.swift: named(init) を macro declaration から削除 - テストを新しい動作に合わせて更新 - README に public init() {} のサンプルを追加 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CHANGELOG.md | 7 +++++- README.md | 4 ++-- README_EN.md | 5 ++-- Sources/Statable/Macros.swift | 4 ++-- Sources/StatableMacros/StatableMacro.swift | 24 +++---------------- .../StatableMacroTests.swift | 19 +++------------ 6 files changed, 18 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e13d2..47f5706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,12 @@ ## [未リリース] - +### 変更 + +- **@Statable マクロ**: `public init()` の自動生成を削除 + - `@Observable` マクロとの相互作用問題を回避するため + - ユーザーが明示的に `public init() {}` を定義する必要あり + - 依存性注入などカスタム初期化が可能に ## [1.0.0] - 2025-01-01 diff --git a/README.md b/README.md index fe4aac6..f205f31 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ import Statable @Statable(MetabolicProfile.self) @MainActor @Observable final class ProfileStore { - // マクロが value, state, isLoading などを自動生成 + public init() {} // カスタムcomputed properties var currentAge: Int { value?.age() ?? 0 } @@ -41,7 +41,7 @@ enum WorkoutOperation: String, CaseIterable, Sendable { @Statable([WorkoutActivity].self, operations: WorkoutOperation.self) @MainActor @Observable final class WorkoutStore { - // value, state, operations などが自動生成 + public init() {} var isRecording: Bool { operations.isActive(.recordStrength) || operations.isActive(.recordCardio) diff --git a/README_EN.md b/README_EN.md index eb94a63..a741449 100644 --- a/README_EN.md +++ b/README_EN.md @@ -27,9 +27,8 @@ import Statable @Statable(MetabolicProfile.self) @MainActor @Observable final class ProfileStore { - // Macro auto-generates value, state, isLoading, etc. + public init() {} - // Custom computed properties var currentAge: Int { value?.age() ?? 0 } } @@ -41,7 +40,7 @@ enum WorkoutOperation: String, CaseIterable, Sendable { @Statable([WorkoutActivity].self, operations: WorkoutOperation.self) @MainActor @Observable final class WorkoutStore { - // Auto-generates value, state, operations, etc. + public init() {} var isRecording: Bool { operations.isActive(.recordStrength) || operations.isActive(.recordCardio) diff --git a/Sources/Statable/Macros.swift b/Sources/Statable/Macros.swift index fb8cd1c..b4a3049 100644 --- a/Sources/Statable/Macros.swift +++ b/Sources/Statable/Macros.swift @@ -77,14 +77,14 @@ /// try await api.record(workout) /// } /// ``` -@attached(member, names: named(_asyncValue), named(_operations), named(init), named(value), named(state), named(isLoading), named(isIdle), named(isFailed), named(hasValue), named(error), named(operations), named(set), named(setError), named(startLoading), named(reset), named(load), named(loadIfNeeded), named(reload)) +@attached(member, names: named(_asyncValue), named(_operations), named(value), named(state), named(isLoading), named(isIdle), named(isFailed), named(hasValue), named(error), named(operations), named(set), named(setError), named(startLoading), named(reset), named(load), named(loadIfNeeded), named(reload)) @attached(extension, conformances: Statable, Sendable) public macro Statable( _ valueType: T.Type ) = #externalMacro(module: "StatableMacros", type: "StatableMacro") /// 操作トラッキング付きの@Statable -@attached(member, names: named(_asyncValue), named(_operations), named(init), named(value), named(state), named(isLoading), named(isIdle), named(isFailed), named(hasValue), named(error), named(operations), named(set), named(setError), named(startLoading), named(reset), named(load), named(loadIfNeeded), named(reload)) +@attached(member, names: named(_asyncValue), named(_operations), named(value), named(state), named(isLoading), named(isIdle), named(isFailed), named(hasValue), named(error), named(operations), named(set), named(setError), named(startLoading), named(reset), named(load), named(loadIfNeeded), named(reload)) @attached(extension, conformances: Statable, Sendable) public macro Statable( _ valueType: T.Type, diff --git a/Sources/StatableMacros/StatableMacro.swift b/Sources/StatableMacros/StatableMacro.swift index d7e6f3c..80da648 100644 --- a/Sources/StatableMacros/StatableMacro.swift +++ b/Sources/StatableMacros/StatableMacro.swift @@ -33,14 +33,6 @@ public struct StatableMacro: MemberMacro, ExtensionMacro { let valueType = args.valueType let operationType = args.operationType - // 既存のinitがあるか確認 - let hasExistingInit = declaration.memberBlock.members.contains { member in - if let initDecl = member.decl.as(InitializerDeclSyntax.self) { - return initDecl.signature.parameterClause.parameters.isEmpty - } - return false - } - var members: [DeclSyntax] = [] // 1. 内部 AsyncValue ストレージ @@ -61,17 +53,7 @@ public struct StatableMacro: MemberMacro, ExtensionMacro { ) } - // 3. init(既存がなければ生成) - if !hasExistingInit { - members.append( - """ - public init() { - } - """ - ) - } - - // 4. Computed Properties (パススルー) + // 3. Computed Properties (パススルー) members.append(contentsOf: [ """ /// 現在の値 @@ -117,7 +99,7 @@ public struct StatableMacro: MemberMacro, ExtensionMacro { """, ]) - // 5. Operations プロパティ(operationType指定時のみ) + // 4. Operations プロパティ(operationType指定時のみ) if let opType = operationType { members.append( """ @@ -129,7 +111,7 @@ public struct StatableMacro: MemberMacro, ExtensionMacro { ) } - // 6. Methods (パススルー) + // 5. Methods (パススルー) members.append(contentsOf: [ """ /// 値を設定(loaded状態に遷移) diff --git a/Tests/StatableMacrosTests/StatableMacroTests.swift b/Tests/StatableMacrosTests/StatableMacroTests.swift index e55c17b..cf0322c 100644 --- a/Tests/StatableMacrosTests/StatableMacroTests.swift +++ b/Tests/StatableMacrosTests/StatableMacroTests.swift @@ -26,9 +26,6 @@ final class StatableMacroTests: XCTestCase { @ObservationIgnored private let _asyncValue = AsyncValue() - public init() { - } - /// 現在の値 public var value: Profile? { _asyncValue.value @@ -107,22 +104,18 @@ final class StatableMacroTests: XCTestCase { ) } - func testStatableDoesNotGenerateInitIfExists() throws { + func testStatablePreservesUserDefinedInit() throws { assertMacroExpansion( """ @Statable(Profile.self) final class ProfileStore { - init() { - print("custom init") - } + public init() {} } """, expandedSource: """ final class ProfileStore { - init() { - print("custom init") - } + public init() {} @ObservationIgnored private let _asyncValue = AsyncValue() @@ -219,9 +212,6 @@ final class StatableMacroTests: XCTestCase { @ObservationIgnored private let _asyncValue = AsyncValue() - public init() { - } - /// 現在の値 public var value: Module.Profile? { _asyncValue.value @@ -317,9 +307,6 @@ final class StatableMacroTests: XCTestCase { @ObservationIgnored private let _operations = OperationTracker() - public init() { - } - /// 現在の値 public var value: [Activity]? { _asyncValue.value From a89a4755a461a8a86501d6a8231ed5065af696dd Mon Sep 17 00:00:00 2001 From: no-problem-kyoichi Date: Thu, 1 Jan 2026 07:55:22 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20TrackMacroTests=20=E3=81=AB=20@Obser?= =?UTF-8?q?vationIgnored=20=E3=81=AE=E6=9C=9F=E5=BE=85=E5=80=A4=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TrackMacro が生成する @ObservationIgnored アトリビュートが テストの期待値に含まれていなかった問題を修正。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- Tests/StatableMacrosTests/TrackMacroTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/StatableMacrosTests/TrackMacroTests.swift b/Tests/StatableMacrosTests/TrackMacroTests.swift index c1bffad..c525e5c 100644 --- a/Tests/StatableMacrosTests/TrackMacroTests.swift +++ b/Tests/StatableMacrosTests/TrackMacroTests.swift @@ -24,6 +24,7 @@ final class TrackMacroTests: XCTestCase { } } + @ObservationIgnored private let _operations = OperationTracker() """, macros: trackMacros @@ -42,6 +43,7 @@ final class TrackMacroTests: XCTestCase { } } + @ObservationIgnored private let _ops = OperationTracker() """, macros: trackMacros From 59c4fe9486ca89d075a67b7eec2acc0cc81c87e0 Mon Sep 17 00:00:00 2001 From: no-problem-kyoichi Date: Thu, 1 Jan 2026 07:57:34 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20swift-docc-plugin=20=E4=BE=9D?= =?UTF-8?q?=E5=AD=98=E9=96=A2=E4=BF=82=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DocC ドキュメント生成に必要な swift-docc-plugin を Package.swift の依存関係に追加。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 1e12ffe..8333339 100644 --- a/Package.swift +++ b/Package.swift @@ -18,6 +18,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.0"), + .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.4.0"), ], targets: [ // MARK: - Macro Implementation From abad927ec69dbae0d12be4f945e9f9d5a59acb8b Mon Sep 17 00:00:00 2001 From: no-problem-kyoichi Date: Thu, 1 Jan 2026 08:01:03 +0900 Subject: [PATCH 5/5] chore: prepare for v1.0.1 release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47f5706..8ae8956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## [未リリース] +## [1.0.1] - 2026-01-01 + ### 変更 - **@Statable マクロ**: `public init()` の自動生成を削除 @@ -48,7 +50,8 @@ - README.md(日本語・英語) - RELEASE_PROCESS.md -[未リリース]: https://github.com/no-problem-dev/swift-statable/compare/v1.0.0...HEAD +[未リリース]: https://github.com/no-problem-dev/swift-statable/compare/v1.0.1...HEAD +[1.0.1]: https://github.com/no-problem-dev/swift-statable/compare/v1.0.0...v1.0.1 [1.0.0]: https://github.com/no-problem-dev/swift-statable/releases/tag/v1.0.0