From e70ae6c7c92c689f26071e542f16606240300a7e Mon Sep 17 00:00:00 2001 From: Kapten boneng Date: Sat, 10 Jan 2026 15:14:47 +0700 Subject: [PATCH 01/13] Initialize production-grade React SDK structure --- production-grade React SDK | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 production-grade React SDK diff --git a/production-grade React SDK b/production-grade React SDK new file mode 100644 index 0000000..135a202 --- /dev/null +++ b/production-grade React SDK @@ -0,0 +1,18 @@ +src/ +├── core/ +│ ├── pi-loader.ts +│ ├── error.ts +│ └── payment-validator.ts +├── provider/ +│ └── PiProvider.tsx +├── hooks/ +│ ├── usePiConnection.ts +│ ├── usePiAuth.ts +│ ├── usePiPayment.ts +│ └── usePiServerHandshake.ts +├── components/ +│ ├── PiPayButton.tsx +│ └── PiAuthGuard.tsx +├── mock/ +│ └── mockPi.ts +└── index.ts From b0315c9ae604e7b67a44198cd022a801116fef43 Mon Sep 17 00:00:00 2001 From: Kapten boneng Date: Sat, 10 Jan 2026 15:15:30 +0700 Subject: [PATCH 02/13] Add PiSdkErrorCode enum and PiSdkError class --- core/error.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 core/error.ts diff --git a/core/error.ts b/core/error.ts new file mode 100644 index 0000000..f3d6703 --- /dev/null +++ b/core/error.ts @@ -0,0 +1,16 @@ +export enum PiSdkErrorCode { + SDK_NOT_LOADED = "SDK_NOT_LOADED", + NOT_READY = "NOT_READY", + USER_REJECTED = "USER_REJECTED", + INVALID_PAYMENT = "INVALID_PAYMENT", + NETWORK_ERROR = "NETWORK_ERROR", + UNKNOWN = "UNKNOWN" +} + +export class PiSdkError extends Error { + code: PiSdkErrorCode + constructor(code: PiSdkErrorCode, message?: string) { + super(message ?? code) + this.code = code + } +} From c2ec18bda14955b509528d644fdd2bc01e37d5ed Mon Sep 17 00:00:00 2001 From: Kapten boneng Date: Sat, 10 Jan 2026 15:16:13 +0700 Subject: [PATCH 03/13] Add Pi SDK readiness check functions --- core/core/pi-loader.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 core/core/pi-loader.ts diff --git a/core/core/pi-loader.ts b/core/core/pi-loader.ts new file mode 100644 index 0000000..597f7e8 --- /dev/null +++ b/core/core/pi-loader.ts @@ -0,0 +1,9 @@ +export function isPiReady(): boolean { + return typeof window !== "undefined" && !!window.Pi +} + +export function assertPiReady() { + if (!isPiReady()) { + throw new Error("Pi SDK not loaded. Ensure