@buoy-gg/benchmark 1.7.7 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BenchmarkStorage=void 0,exports.createAsyncStorageAdapter=createAsyncStorageAdapter,exports.createMemoryStorageAdapter=createMemoryStorageAdapter,exports.default=void 0;const STORAGE_PREFIX="@buoy-gg/benchmark",INDEX_KEY=`${STORAGE_PREFIX}/index`,REPORT_KEY_PREFIX=`${STORAGE_PREFIX}/report/`;function getReportKey(e){return`${REPORT_KEY_PREFIX}${e}`}function extractMetadata(e){return{id:e.id,name:e.name,description:e.description,createdAt:e.createdAt,duration:e.duration,batchCount:e.stats.batchCount}}class BenchmarkStorage{constructor(e){this.storage=e}async saveReport(e){const t=await this.loadIndex(),r=t.findIndex(t=>t.id===e.id);return r>=0?t[r]=extractMetadata(e):t.push(extractMetadata(e)),await Promise.all([this.storage.setItem(getReportKey(e.id),JSON.stringify(e)),this.storage.setItem(INDEX_KEY,JSON.stringify(t))]),console.log(`[BenchmarkStorage] Saved report: ${e.name} (${e.id})`),extractMetadata(e)}async loadReport(e){try{const t=await this.storage.getItem(getReportKey(e));return t?JSON.parse(t):null}catch(t){return console.error(`[BenchmarkStorage] Error loading report ${e}:`,t),null}}async listReports(){return(await this.loadIndex()).sort((e,t)=>t.createdAt-e.createdAt)}async deleteReport(e){const t=await this.loadIndex(),r=t.findIndex(t=>t.id===e);return!(r<0||(t.splice(r,1),await Promise.all([this.storage.removeItem(getReportKey(e)),this.storage.setItem(INDEX_KEY,JSON.stringify(t))]),console.log(`[BenchmarkStorage] Deleted report: ${e}`),0))}async clearAll(){const e=await this.loadIndex();await Promise.all([...e.map(e=>this.storage.removeItem(getReportKey(e.id))),this.storage.removeItem(INDEX_KEY)]),console.log(`[BenchmarkStorage] Cleared ${e.length} reports`)}async updateReport(e,t){const r=await this.loadReport(e);return!!r&&(void 0!==t.name&&(r.name=t.name),void 0!==t.description&&(r.description=t.description),await this.saveReport(r),console.log(`[BenchmarkStorage] Updated report: ${e}`),!0)}async getMostRecent(){const e=await this.listReports();return 0===e.length?null:this.loadReport(e[0].id)}async getReportsByName(e){return(await this.loadIndex()).filter(t=>t.name===e).sort((e,t)=>t.createdAt-e.createdAt)}async loadIndex(){try{const e=await this.storage.getItem(INDEX_KEY);return e?JSON.parse(e):[]}catch(e){return console.error("[BenchmarkStorage] Error loading index:",e),[]}}}function createAsyncStorageAdapter(){try{const e=require("@react-native-async-storage/async-storage").default;return{getItem:t=>e.getItem(t),setItem:(t,r)=>e.setItem(t,r),removeItem:t=>e.removeItem(t)}}catch{return console.warn("[BenchmarkStorage] @react-native-async-storage/async-storage not available. Provide a custom storage adapter."),null}}function createMemoryStorageAdapter(){const e=new Map;return{getItem:async t=>e.get(t)??null,setItem:async(t,r)=>{e.set(t,r)},removeItem:async t=>{e.delete(t)}}}exports.BenchmarkStorage=BenchmarkStorage;var _default=exports.default=BenchmarkStorage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BenchmarkStorage=void 0,exports.createAsyncStorageAdapter=createAsyncStorageAdapter,exports.createMemoryStorageAdapter=createMemoryStorageAdapter,exports.default=void 0;const STORAGE_PREFIX="@buoy-gg/benchmark",INDEX_KEY=`${STORAGE_PREFIX}/index`,REPORT_KEY_PREFIX=`${STORAGE_PREFIX}/report/`;function getReportKey(e){return`${REPORT_KEY_PREFIX}${e}`}function extractMetadata(e){return{id:e.id,name:e.name,description:e.description,createdAt:e.createdAt,duration:e.duration,batchCount:e.stats.batchCount}}class BenchmarkStorage{constructor(e){this.storage=e}async saveReport(e){const t=await this.loadIndex(),r=t.findIndex(t=>t.id===e.id);return r>=0?t[r]=extractMetadata(e):t.push(extractMetadata(e)),await Promise.all([this.storage.setItem(getReportKey(e.id),JSON.stringify(e)),this.storage.setItem(INDEX_KEY,JSON.stringify(t))]),extractMetadata(e)}async loadReport(e){try{const t=await this.storage.getItem(getReportKey(e));return t?JSON.parse(t):null}catch(t){return console.error(`[BenchmarkStorage] Error loading report ${e}:`,t),null}}async listReports(){return(await this.loadIndex()).sort((e,t)=>t.createdAt-e.createdAt)}async deleteReport(e){const t=await this.loadIndex(),r=t.findIndex(t=>t.id===e);return!(r<0||(t.splice(r,1),await Promise.all([this.storage.removeItem(getReportKey(e)),this.storage.setItem(INDEX_KEY,JSON.stringify(t))]),0))}async clearAll(){const e=await this.loadIndex();await Promise.all([...e.map(e=>this.storage.removeItem(getReportKey(e.id))),this.storage.removeItem(INDEX_KEY)])}async updateReport(e,t){const r=await this.loadReport(e);return!!r&&(void 0!==t.name&&(r.name=t.name),void 0!==t.description&&(r.description=t.description),await this.saveReport(r),!0)}async getMostRecent(){const e=await this.listReports();return 0===e.length?null:this.loadReport(e[0].id)}async getReportsByName(e){return(await this.loadIndex()).filter(t=>t.name===e).sort((e,t)=>t.createdAt-e.createdAt)}async loadIndex(){try{const e=await this.storage.getItem(INDEX_KEY);return e?JSON.parse(e):[]}catch(e){return console.error("[BenchmarkStorage] Error loading index:",e),[]}}}function createAsyncStorageAdapter(){try{const e=require("@react-native-async-storage/async-storage").default;return{getItem:t=>e.getItem(t),setItem:(t,r)=>e.setItem(t,r),removeItem:t=>e.removeItem(t)}}catch{return console.warn("[BenchmarkStorage] @react-native-async-storage/async-storage not available. Provide a custom storage adapter."),null}}function createMemoryStorageAdapter(){const e=new Map;return{getItem:async t=>e.get(t)??null,setItem:async(t,r)=>{e.set(t,r)},removeItem:async t=>{e.delete(t)}}}exports.BenchmarkStorage=BenchmarkStorage;var _default=exports.default=BenchmarkStorage;
@@ -1 +1 @@
1
- "use strict";const STORAGE_PREFIX="@buoy-gg/benchmark",INDEX_KEY=`${STORAGE_PREFIX}/index`,REPORT_KEY_PREFIX=`${STORAGE_PREFIX}/report/`;function getReportKey(e){return`${REPORT_KEY_PREFIX}${e}`}function extractMetadata(e){return{id:e.id,name:e.name,description:e.description,createdAt:e.createdAt,duration:e.duration,batchCount:e.stats.batchCount}}export class BenchmarkStorage{constructor(e){this.storage=e}async saveReport(e){const t=await this.loadIndex(),r=t.findIndex(t=>t.id===e.id);return r>=0?t[r]=extractMetadata(e):t.push(extractMetadata(e)),await Promise.all([this.storage.setItem(getReportKey(e.id),JSON.stringify(e)),this.storage.setItem(INDEX_KEY,JSON.stringify(t))]),console.log(`[BenchmarkStorage] Saved report: ${e.name} (${e.id})`),extractMetadata(e)}async loadReport(e){try{const t=await this.storage.getItem(getReportKey(e));return t?JSON.parse(t):null}catch(t){return console.error(`[BenchmarkStorage] Error loading report ${e}:`,t),null}}async listReports(){return(await this.loadIndex()).sort((e,t)=>t.createdAt-e.createdAt)}async deleteReport(e){const t=await this.loadIndex(),r=t.findIndex(t=>t.id===e);return!(r<0||(t.splice(r,1),await Promise.all([this.storage.removeItem(getReportKey(e)),this.storage.setItem(INDEX_KEY,JSON.stringify(t))]),console.log(`[BenchmarkStorage] Deleted report: ${e}`),0))}async clearAll(){const e=await this.loadIndex();await Promise.all([...e.map(e=>this.storage.removeItem(getReportKey(e.id))),this.storage.removeItem(INDEX_KEY)]),console.log(`[BenchmarkStorage] Cleared ${e.length} reports`)}async updateReport(e,t){const r=await this.loadReport(e);return!!r&&(void 0!==t.name&&(r.name=t.name),void 0!==t.description&&(r.description=t.description),await this.saveReport(r),console.log(`[BenchmarkStorage] Updated report: ${e}`),!0)}async getMostRecent(){const e=await this.listReports();return 0===e.length?null:this.loadReport(e[0].id)}async getReportsByName(e){return(await this.loadIndex()).filter(t=>t.name===e).sort((e,t)=>t.createdAt-e.createdAt)}async loadIndex(){try{const e=await this.storage.getItem(INDEX_KEY);return e?JSON.parse(e):[]}catch(e){return console.error("[BenchmarkStorage] Error loading index:",e),[]}}}export function createAsyncStorageAdapter(){try{const e=require("@react-native-async-storage/async-storage").default;return{getItem:t=>e.getItem(t),setItem:(t,r)=>e.setItem(t,r),removeItem:t=>e.removeItem(t)}}catch{return console.warn("[BenchmarkStorage] @react-native-async-storage/async-storage not available. Provide a custom storage adapter."),null}}export function createMemoryStorageAdapter(){const e=new Map;return{getItem:async t=>e.get(t)??null,setItem:async(t,r)=>{e.set(t,r)},removeItem:async t=>{e.delete(t)}}}export default BenchmarkStorage;
1
+ "use strict";const STORAGE_PREFIX="@buoy-gg/benchmark",INDEX_KEY=`${STORAGE_PREFIX}/index`,REPORT_KEY_PREFIX=`${STORAGE_PREFIX}/report/`;function getReportKey(t){return`${REPORT_KEY_PREFIX}${t}`}function extractMetadata(t){return{id:t.id,name:t.name,description:t.description,createdAt:t.createdAt,duration:t.duration,batchCount:t.stats.batchCount}}export class BenchmarkStorage{constructor(t){this.storage=t}async saveReport(t){const e=await this.loadIndex(),a=e.findIndex(e=>e.id===t.id);return a>=0?e[a]=extractMetadata(t):e.push(extractMetadata(t)),await Promise.all([this.storage.setItem(getReportKey(t.id),JSON.stringify(t)),this.storage.setItem(INDEX_KEY,JSON.stringify(e))]),extractMetadata(t)}async loadReport(t){try{const e=await this.storage.getItem(getReportKey(t));return e?JSON.parse(e):null}catch(e){return console.error(`[BenchmarkStorage] Error loading report ${t}:`,e),null}}async listReports(){return(await this.loadIndex()).sort((t,e)=>e.createdAt-t.createdAt)}async deleteReport(t){const e=await this.loadIndex(),a=e.findIndex(e=>e.id===t);return!(a<0||(e.splice(a,1),await Promise.all([this.storage.removeItem(getReportKey(t)),this.storage.setItem(INDEX_KEY,JSON.stringify(e))]),0))}async clearAll(){const t=await this.loadIndex();await Promise.all([...t.map(t=>this.storage.removeItem(getReportKey(t.id))),this.storage.removeItem(INDEX_KEY)])}async updateReport(t,e){const a=await this.loadReport(t);return!!a&&(void 0!==e.name&&(a.name=e.name),void 0!==e.description&&(a.description=e.description),await this.saveReport(a),!0)}async getMostRecent(){const t=await this.listReports();return 0===t.length?null:this.loadReport(t[0].id)}async getReportsByName(t){return(await this.loadIndex()).filter(e=>e.name===t).sort((t,e)=>e.createdAt-t.createdAt)}async loadIndex(){try{const t=await this.storage.getItem(INDEX_KEY);return t?JSON.parse(t):[]}catch(t){return console.error("[BenchmarkStorage] Error loading index:",t),[]}}}export function createAsyncStorageAdapter(){try{const t=require("@react-native-async-storage/async-storage").default;return{getItem:e=>t.getItem(e),setItem:(e,a)=>t.setItem(e,a),removeItem:e=>t.removeItem(e)}}catch{return console.warn("[BenchmarkStorage] @react-native-async-storage/async-storage not available. Provide a custom storage adapter."),null}}export function createMemoryStorageAdapter(){const t=new Map;return{getItem:async e=>t.get(e)??null,setItem:async(e,a)=>{t.set(e,a)},removeItem:async e=>{t.delete(e)}}}export default BenchmarkStorage;
package/package.json CHANGED
@@ -1,18 +1,32 @@
1
1
  {
2
2
  "name": "@buoy-gg/benchmark",
3
- "version": "1.7.7",
3
+ "version": "2.1.1",
4
4
  "description": "Performance benchmarking system for React Native dev tools",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
7
  "types": "lib/typescript/index.d.ts",
8
8
  "react-native": "lib/module/index.js",
9
9
  "source": "src/index.tsx",
10
+ "exports": {
11
+ ".": {
12
+ "react-native": "./lib/module/index.js",
13
+ "import": {
14
+ "default": "./lib/module/index.js",
15
+ "types": "./lib/typescript/index.d.ts"
16
+ },
17
+ "require": {
18
+ "default": "./lib/commonjs/index.js",
19
+ "types": "./lib/typescript/index.d.ts"
20
+ }
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
10
24
  "files": [
11
25
  "lib"
12
26
  ],
13
27
  "sideEffects": false,
14
28
  "dependencies": {
15
- "@buoy-gg/shared-ui": "1.7.7"
29
+ "@buoy-gg/shared-ui": "2.1.1"
16
30
  },
17
31
  "peerDependencies": {
18
32
  "@react-native-async-storage/async-storage": "*",