{"_id":"@digahash/metadata-vue","name":"@digahash/metadata-vue","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@digahash/metadata-vue","version":"1.0.0","description":"Vue 3 composables for Digahash metadata.","license":"MIT","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"sideEffects":false,"dependencies":{"@digahash/metadata-core":"1.0.0"},"peerDependencies":{"vue":"^3.5.0"},"devDependencies":{"@vitejs/plugin-vue":"^5.2.4","vue":"^3.5.13"},"scripts":{"build":"vite build","dev":"vite build --watch","test":"vitest run","lint":"echo 'No lint configured for metadata-vue'","typecheck":"tsc --noEmit"},"_id":"@digahash/metadata-vue@1.0.0","_integrity":"sha512-I3yGZQB5bMmW4101CvE7lC3+NsR0OmnjTM4sn/8d4rs5QSCurrtCX6xRWY/lwHgulwQHkg9Od3PNQvcrqcHPjA==","_resolved":"/tmp/8ffaf0576a5bc6c5a340443489aed908/digahash-metadata-vue-1.0.0.tgz","_from":"file:digahash-metadata-vue-1.0.0.tgz","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-I3yGZQB5bMmW4101CvE7lC3+NsR0OmnjTM4sn/8d4rs5QSCurrtCX6xRWY/lwHgulwQHkg9Od3PNQvcrqcHPjA==","shasum":"ad596d1cc388b7d60f9ac67c4eea692866e678e8","tarball":"https://registry.npmjs.org/@digahash/metadata-vue/-/metadata-vue-1.0.0.tgz","fileCount":6,"unpackedSize":11437,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGSXL6MmWl8i+03iaY7K0F5qg6HSTVxFzFKDRV42cwKoAiA9tKxs4Dd4aJCrRm159OO4SWSZX09vw2FICPohjk/S4A=="}]},"_npmUser":{"name":"kidsysco","email":"kidsysco@gmail.com"},"directories":{},"maintainers":[{"name":"kidsysco","email":"kidsysco@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/metadata-vue_1.0.0_1774671750393_0.6786291578227861"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-28T04:22:30.295Z","1.0.0":"2026-03-28T04:22:30.537Z","modified":"2026-03-28T04:22:30.778Z"},"maintainers":[{"name":"kidsysco","email":"kidsysco@gmail.com"}],"description":"Vue 3 composables for Digahash metadata.","license":"MIT","readme":"# @digahash/metadata-vue\n\nVue 3 composable wrapper around @digahash/metadata-core. Used to publish web content from simple hosted JSON files, often eliminating the need for a more expensive database.\n\n![digahash-metadata-vue](https://images.dig-a-hash.com/dig-a-hash/digahash-metadata-vue.webp)\n\n## Install\n\n```bash\nnpm install @digahash/metadata-vue\npnpm add @digahash/metadata-vue\nyarn add @digahash/metadata-vue\n```\n\n## Peer Dependencies\n\n- vue ^3.5.0\n\n## Quick Start\n\n```ts\nimport { useMetadata } from '@digahash/metadata-vue';\n\nconst metadata = useMetadata({\n  user: 'wgoqc',\n  folder: 'news',\n  totalSupply: 90,\n  batchSize: 10,\n  isAscending: true,\n  startTokenId: 0,\n  baseUrl: 'https://nft.dig-a-hash.com/profiles',\n  chainId: 137\n});\n\nawait metadata.fetchBatch();\n```\n\n## API\n\n- useMetadata(options)\n- getMetadataAttributeValue(metadata, attributeName)\n\n## TypeScript\n\n```ts\nimport type { Metadata } from '@digahash/metadata-vue';\n```\n\n## ESM and CJS Imports\n\n```ts\nimport { useMetadata } from '@digahash/metadata-vue';\n```\n\n```js\nconst { useMetadata } = require('@digahash/metadata-vue');\n```\n\n## Docker Development\n\n```bash\ndocker run --rm -it -v \"$(pwd):/app\" -w /app node:24-slim sh -lc \"corepack enable && pnpm --filter @digahash/metadata-vue build\"\n```\n\n## Compatibility\n\nVue 3.5+ and modern runtimes.\n## Project orientation and legacy `chainId`\n\nThis project was originally inspired by NFTs on Ethereum, which is why a `chainId` field appears in some APIs and data models. Dig-A-Hash has since adopted a Bitcoin-first ethos rooted in Bitcoin-first principles. As a result, on-chain support implemented via Ethers.js has been removed and is not maintained.\n\n### Data URL and required `meta-data` folder\n\nMetadata files are expected to be stored as sequentially numbered JSON files under a required `meta-data` folder. The fetch URL used by the underlying implementation follows this template:\n\n`${baseUrl}/${user}/meta-data/${chainId}/${folder}/${tokenId}.json`\n\nThe `meta-data` path segment is required. Default `baseUrl` is `https://nft.dig-a-hash.com/profiles` and the legacy `chainId` default is `137` (use `0` as a neutral placeholder for Bitcoin-first items).\n\n### Options (useMetadata)\n\nThe composable accepts these options (mapped into the underlying state factory):\n\n- `user` (string) — collection owner or profile identifier (required). [used in URL]\n- `folder` (string) — collection folder name (required). [used in URL]\n- `totalSupply` (number) — size of the collection (required).\n- `batchSize` (number) — how many items to request per fetch (required).\n- `isAscending` (boolean) — whether token IDs increment (required).\n- `startTokenId` (number, default `0`) — starting token id for ascending flows.\n- `baseUrl` (string, default `https://nft.dig-a-hash.com/profiles`) — base host for metadata files. [used in URL]\n- `chainId` (number, default `137`) — legacy chain id; use `0` when a placeholder is required. [used in URL]\n- `groupSize` (number, default `4`) — number of items per `groupedItems` row.\n- `fetcher` (function, default `fetch`) — custom fetch function for testing or polyfills.\n\nURL template used by the implementation:\n\n`${baseUrl}/${user}/meta-data/${chainId}/${folder}/${tokenId}.json`\n\n(`meta-data` is required; `tokenId` is provided at request time.)\n\n### Returned API\n\nThe composable returns the `MetadataState` surface (getters for `items`, `isLoading`, `nextTokenId`, `allLoaded`, `downloadedCount`, `groupedItems`, and async methods `fetchMetadata`, `fetchMetadataBatch`, `fetchBatch`, `fetchAllRemainingMetadata`).\n\nDetailed return values and usage:\n\n- `items`: loaded `Metadata` objects with `tokenId`, `metaData`, `metaDataUrl`, `owner`, and `privateData`.\n- `isLoading`: boolean for active network operations.\n- `nextTokenId`: next id to be requested.\n- `allLoaded`: whether fetching has completed for the collection.\n- `downloadedCount`: convenience count equal to `items.length`.\n- `groupedItems`: `items` partitioned into rows of `groupSize` for UI layouts.\n- `fetchMetadata(tokenId)`: returns `Metadata | null`; `metaDataUrl` shows the resolved URL.\n- `fetchMetadataBatch(tokenIds)`: returns `(Metadata | null)[]`.\n- `fetchBatch()`: requests the next `batchSize` items.\n- `fetchAllRemainingMetadata()`: fetches until `allLoaded`.\n\n## SupplyCount payload and migration notes\n\nSupplyCounts are JSON endpoints that list total supply for one or many metadata collections. Keep counts for multiple collections in a single file (for example `counts2.json`) so consumers can retrieve supply data for all collections in one request. An accurate total supply is critical because metadata files are sequentially numbered; knowing the total enables correct paging, prevents fetching beyond available files, and supports efficient UI pagination.\n\nPreferred payload fields returned by the counts endpoint are an array of objects with the following shape:\n\n- `user`: string — profile user id (preferred over legacy `contractOwner`)\n- `folder`: string — folder name (preferred over legacy `contractAddress`)\n- `chainId`: number\n- `count`: number\n\nLegacy aliases supported by `fetchSupplyCounts()`:\n\n- `contractOwner` -> `user`\n- `contractAddress` -> `folder`\n\nExample usage (core helper):\n\n```ts\nimport { fetchSupplyCounts } from '@digahash/metadata-core';\n\nconst counts = await fetchSupplyCounts('https://.../counts2.json');\nconst news = counts.find((c) => c.folder === 'news');\nconst totalSupply = news?.count ?? 0;\n```\n\nMigration notes for consumers:\n\n- Use the `user` and `folder` fields when available.\n- `fetchSupplyCounts()` normalizes legacy shapes and will skip invalid entries instead of throwing.\n- If a counts endpoint is unavailable or malformed, code should fall back to a sensible default (for example `0`).\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-c53c15dbcf1f68ce21e04e3adfce2e12"}