{"_id":"@animastor/vbook-runtime","_rev":"2-0d5516f06c5d850eaa8ff4aad55ee086","name":"@animastor/vbook-runtime","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@animastor/vbook-runtime","version":"0.1.0","license":"MIT","_id":"@animastor/vbook-runtime@0.1.0","maintainers":[{"name":"animastor","email":"admin@animastor.in"}],"homepage":"https://github.com/Animastor/animastor#readme","bugs":{"url":"https://github.com/Animastor/animastor/issues"},"dist":{"shasum":"35e6eeb8ab2e0bac9e1bed19e0bfb7f57c669230","tarball":"https://registry.npmjs.org/@animastor/vbook-runtime/-/vbook-runtime-0.1.0.tgz","fileCount":24,"integrity":"sha512-TAYBLLAVmf4r9bTDoZ+kWwMr/qBIk+U281DQNuqBDn81cuqH/XABtyGKku5stuBHTGJI+SKnVo2Dl2mp37lWnQ==","signatures":[{"sig":"MEUCIQDLZRexmolBwOBoPWRLd7CcvycEfwPtSDg5cdyURQYCpQIgS9N0kFgM3pu1qDVOiVQgjAASBSV+/9V9H46ot8BytoU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":205944},"main":"src/index.js","engines":{"node":">=18"},"exports":{".":"./src/index.js","./lazy-book":"./src/lazy-book/index.js","./schemas/*":"./schemas/*","./books-root":"./src/books-root.js","./snake-guard":"./src/snake-guard.js","./book-model.cjs":"./src/book-model.cjs","./lazy-book/draft":"./src/lazy-book/draft.js","./lazy-book/parse":"./src/lazy-book/parse.js","./lazy-book/paths":"./src/lazy-book/paths.js","./lazy-book/create":"./src/lazy-book/create.js","./lazy-book/parser":"./src/lazy-book/parser.js","./lazy-book/status":"./src/lazy-book/status.js","./language-detector":"./src/language-detector.js","./scene-title-utils":"./src/scene-title-utils.js","./character-identity":"./src/character-identity.js","./lazy-book/metadata":"./src/lazy-book/metadata.js","./lazy-book/constants":"./src/lazy-book/constants.js","./bundle-validator.cjs":"./src/bundle-validator.cjs","./lazy-book/appearance":"./src/lazy-book/appearance.js","./lazy-book/chapter-utils":"./src/lazy-book/chapter-utils.js"},"gitHead":"2d19d7932551566138bedeedf6f8f87883460d4d","scripts":{"test":"mocha test/*.test.js"},"_npmUser":{"name":"animastor","email":"admin@animastor.in"},"repository":{"url":"git+https://github.com/Animastor/animastor.git","type":"git","directory":"packages/animastor-vbook-runtime"},"_npmVersion":"10.9.8","description":"VBook Runtime — canonical VBook 3.1 bundle/book model: multi-file bundle CRUD, draft/import lifecycle, lazy parse windows, bundle validation, canonical id grammar and path layout. Owns bundle/book canonical state; the host owns the filesystem root (booksR","directories":{},"_nodeVersion":"22.22.3","dependencies":{"tinyld":"^1.3.4","adm-zip":"^0.5.10"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^6.2.2","mocha":"^11.7.5"},"_npmOperationalInternal":{"tmp":"tmp/vbook-runtime_0.1.0_1788798674489_0.9181281019623087","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"_id":"@animastor/vbook-runtime@0.2.0","bugs":{"url":"https://github.com/Animastor/animastor/issues"},"dist":{"shasum":"a40f30f446764391effdcf812a19ec37947d9a9c","tarball":"https://registry.npmjs.org/@animastor/vbook-runtime/-/vbook-runtime-0.2.0.tgz","fileCount":22,"integrity":"sha512-10BJuVaX580yyIYh1k9KqJH8hTXu5QM70273x05U4rMN3/G3egmkrZtX1uB0dsJ2cpbRPpztvW6XDH0PnQ7UKg==","signatures":[{"sig":"MEYCIQCEBmFH7MW7ylOjyjFqYOQMVTUFkV+DFChe8DhSUzd+IAIhAOA2NjAXXQ/QSwJ+0uWtd3loNIPXcXXdtkg6FC/xZmxZ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB+DrHvSGAuqkyGJmAqzG2Jz2vhioT4X5GY7MS+C3bSNAiAaG168hy/cvt/Iluk806JrqGCWegf5XI7OPLNv3GRoNw=="}],"unpackedSize":192668},"main":"src/index.js","name":"@animastor/vbook-runtime","engines":{"node":">=18"},"exports":{".":"./src/index.js","./lazy-book":"./src/lazy-book/index.js","./schemas/*":"./schemas/*","./books-root":"./src/books-root.js","./snake-guard":"./src/snake-guard.js","./book-model.cjs":"./src/book-model.cjs","./lazy-book/draft":"./src/lazy-book/draft.js","./lazy-book/parse":"./src/lazy-book/parse.js","./lazy-book/paths":"./src/lazy-book/paths.js","./lazy-book/create":"./src/lazy-book/create.js","./lazy-book/status":"./src/lazy-book/status.js","./scene-title-utils":"./src/scene-title-utils.js","./character-identity":"./src/character-identity.js","./lazy-book/metadata":"./src/lazy-book/metadata.js","./lazy-book/constants":"./src/lazy-book/constants.js","./bundle-validator.cjs":"./src/bundle-validator.cjs","./lazy-book/appearance":"./src/lazy-book/appearance.js","./lazy-book/chapter-utils":"./src/lazy-book/chapter-utils.js"},"gitHead":"cf2d5836fa6a545b10ab60aefebf0edce2c93656","license":"MIT","scripts":{"test":"mocha test/*.test.js"},"version":"0.2.0","_npmUser":{"name":"animastor","email":"admin@animastor.in"},"homepage":"https://github.com/Animastor/animastor#readme","repository":{"url":"git+https://github.com/Animastor/animastor.git","type":"git","directory":"packages/animastor-vbook-runtime"},"_npmVersion":"10.9.8","description":"VBook Runtime — canonical VBook 3.1 bundle/book model: multi-file bundle CRUD, draft/import lifecycle, lazy parse windows, bundle validation, canonical id grammar and path layout. Owns bundle/book canonical state; the host owns the filesystem root (booksR","directories":{},"maintainers":[{"name":"animastor","email":"admin@animastor.in"}],"_nodeVersion":"22.22.3","dependencies":{"adm-zip":"^0.5.10","@animastor/parser":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^6.2.2","mocha":"^11.7.5"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vbook-runtime_0.2.0_1790523138842_0.15873787487334345"}}},"time":{"created":"2026-09-07T16:31:14.234Z","modified":"2026-09-27T15:32:19.088Z","0.1.0":"2026-09-07T16:31:14.629Z","0.2.0":"2026-09-27T15:32:18.931Z"},"bugs":{"url":"https://github.com/Animastor/animastor/issues"},"license":"MIT","homepage":"https://github.com/Animastor/animastor#readme","repository":{"url":"git+https://github.com/Animastor/animastor.git","type":"git","directory":"packages/animastor-vbook-runtime"},"description":"VBook Runtime — canonical VBook 3.1 bundle/book model: multi-file bundle CRUD, draft/import lifecycle, lazy parse windows, bundle validation, canonical id grammar and path layout. Owns bundle/book canonical state; the host owns the filesystem root (booksR","maintainers":[{"name":"animastor","email":"admin@animastor.in"}],"readme":"# @animastor/vbook-runtime\n\nCanonical **VBook 3.1** bundle/book runtime: multi-file bundle CRUD, draft/import\nlifecycle, lazy parse windows, bundle validation, canonical id grammar and the\non-disk path layout.\n\n**Status: EXTRACTED.** The runtime physically lives in this package\n(`src/`); the host keeps one-line re-export shims at the legacy paths\n(`backend/src/book/**`, `backend/src/services/language-detector.js`,\n`backend/src/utils/{character-identity,snake-guard,scene-title-utils}.js`).\nThe composition root (`backend/src/backend.cjs`) binds both ports through the\npackage entry points. See\n[`docs/architecture/VBOOK_RUNTIME_RELOCATION_CHECKLIST.md`](../../docs/architecture/VBOOK_RUNTIME_RELOCATION_CHECKLIST.md)\n(COMPLETE) and\n[`docs/03-audit/VBOOK_EXTRACTION_READINESS_AUDIT.md`](../../docs/03-audit/VBOOK_EXTRACTION_READINESS_AUDIT.md).\n\n## Standalone use\n\n```bash\nnpm install        # deps: adm-zip + tinyld (dev: mocha + chai)\nnpm test           # package-owned suite, no host/PG/Redis\n```\n\nThe package never reads `process.env`. Before any book operation, bind the\nfilesystem root and (for parsing) a structure detector:\n\n```js\nconst { configureBooksRoot } = require('@animastor/vbook-runtime/books-root');\nconst { setStructureDetector } = require('@animastor/vbook-runtime/lazy-book/parser');\nconfigureBooksRoot('/data/books');            // string or () => string provider\nsetStructureDetector(myStructureDetector);    // { buildDeterministicMap(text) }\n\n## Ownership map (frozen)\n\n| Concern | Owner |\n|---|---|\n| Bundle/book canonical state, layout, id grammar, validator | **this package** |\n| `{booksRoot}` location (env, docker mounts) | host (injected via `configureBooksRoot`) |\n| `{booksRoot}/{bookId}.snapshot.json` files | host (`task-handler.cjs`, `book-deletion.cjs`) |\n| Deletion orchestration (Redis cancel flags, PG cascade, hub queue clear) | host (`book-deletion.cjs` — stays host-side, excluded from the package `files` allowlist) |\n| Redis / Postgres / GPU Hub (`HUB_URL`, `GPU_HUB_API_KEY`, ...) | host |\n| Text structure analysis / parser doctrine (`structure-detector`) | future Parser boundary (C13); consumed via the injectable port below |\n\n## Public API (frozen — audit §4.1)\n\nOperations only. Additive changes only from here (C2 model API is internal-v1).\n\n- **Book/bundle CRUD** (`book/index.js`): `loadBook`, `saveBookBundle`,\n  `resetBook`, `extractBookBundle`, `buildBookFromBundle`, `addDirToZip`,\n  `collectScenes`, `collectSceneList`, `collectSceneUnits`, `findSceneRuntimeData`.\n- **Book Model facade** (`book-model.cjs`): `loadBook(bookId, {mode})`,\n  `getBookIdentity`, `getBookManifest`, `BookModelError`, `MODE_FULL`, `MODE_LAZY`.\n- **Lazy-book runtime** (`lazy-book/index.js`): draft lifecycle\n  (`createDraftBook`, `loadDraftBook`, `updateBookState`), parse windows\n  (`lazyParseNextWindow`, `lazyParseChapter`), status (`getBookStatus`,\n  `getChaptersSummary`), import/create (`createFromAnalysis`, `appendToBook`,\n  `createOrAppendScenes`), metadata (`updateBookMetadata`), chapter utilities,\n  appearance helpers.\n- **Validation** (`bundle-validator.cjs`): `validateBundleObject`,\n  `validateBundleFile`. The de-facto C1 contract; mirrored rule-by-rule by\n  [`schemas/vbook-bundle-3.1.schema.json`](schemas/vbook-bundle-3.1.schema.json).\n- **Path/id grammar** (`lazy-book/paths.js`): `getBooksDir`, `getBookDir`,\n  `getSourcePath`, `getManifestPath`, `getBookMetaPath`, `getCharactersPath`,\n  `getBiblePath`, `getChapterDir`, `getChapterPath`, ... and `chapterId`,\n  `sceneId`, `unitId`, `generateBookId`.\n- **Enums** (`lazy-book/constants.js`): `BookState`, `SceneStatus`, `SourceType`,\n  `UnitType`, `DEFAULT_WINDOW_SIZE`.\n\nNOT part of the package: `book-deletion.cjs` (host:\n`backend/src/services/book-deletion.cjs`), snapshot management, Redis/PG/\norchestration access, GPU Hub env logic — all host-side.\n\n## Ports (injected by the host composition root)\n\n### `booksRoot`\n\nThe package never reads `process.env` and never imports host config. The host\nbinds the filesystem root once at startup:\n\n```js\nconst { configureBooksRoot } = require('@animastor/vbook-runtime/books-root');\nconfigureBooksRoot(() => config.BOOKS_DIR); // string or () => string\n```\n\nFail-closed: path getters throw until the root is bound. No env fallback.\n\n### `structureDetector`\n\nText-structure analysis is **Parser doctrine, not bundle format** (Parser ≠\nVBook). The package defines one port:\n\n```js\ndetector.buildDeterministicMap(sourceText)\n// → { title?, author?, hasPrologue, hasEpilogue, parts,\n//     segments: [{ type, label, title, number, headerLine,\n//                  startOffset, endOffset, source }] }\n```\n\nThe host binds its current implementation once at startup (composition root\n`backend/src/backend.cjs`):\n\n```js\nconst { setStructureDetector } = require('@animastor/vbook-runtime/lazy-book/parser');\nsetStructureDetector(require('./services/structure-detector'));\n```\n\nFail-closed: parsing throws until a detector is bound. This port is the seed of\nthe future C13 Parser contract; `services/structure-detector` stays host-side\nuntil that boundary exists.\n\n## Extraction companions\n\n`services/language-detector`, `utils/character-identity`, `utils/snake-guard`,\n`utils/scene-title-utils` move **with** the package (audit §1.1). Host consumers\nreach them through one-line re-export shims at the old paths, so migration is\nbehavior-neutral.\n\n## Dependency surface\n\nNode builtins (`fs`, `path`, `crypto`) + `adm-zip` + `tinyld`. Nothing else —\nguarded by `backend/tests/architecture/vbook-package-boundary.test.js`.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}