diff --git a/dist/index.d.mts b/dist/index.d.mts new file mode 100644 index 0000000..660c581 --- /dev/null +++ b/dist/index.d.mts @@ -0,0 +1,115 @@ +declare class Book { + private static gedeId; + /** 获取类别列表 */ + static getCategories(): Promise<{ + id: number; + name: string; + }[]>; + /** + * 获取指定类别的图书列表 + * @param catagoryId 图书类别编号 + * @param page 页码 + * @param pageSize 返回数据条数 + * @returns + */ + static getList(catagoryId: number, page?: number, pageSize?: number): Promise; + /** + * 获取图书详情 + * @param id 图书编号 + * @returns + */ + static getInfo(id: string): Promise; + /** + * 获取图书正文和目录数据 + * @param id 图书编号 + * @param page 页码 + * @param pageSize 数据条数 + * @param width 阅读器宽度像素,影响计算单页字数 + * @param height 阅读器高度像素,影响计算单页字数 + * @returns + */ + static getData(id: string, page?: number, pageSize?: number, width?: number, height?: number): Promise; + /** 获取图书目录数据 */ + static getCatalog(id: string): Promise; +} +/** 图书列表项 */ +type BookItem = { + name: string; + author: string; + id: string; + publish: string; + summary: string; + bigCover: string; + smallCover: string; + surl: string; + price: string; + /** 网页阅读器 */ + webReader: string; + type: 'HY' | 'GD'; + isbn: string; +}; +/** 图书详情 */ +type BookInfo = BookItem & { + /** EPUB 文件地址 */ + epub: string; + /** 发布时间 */ + publishTime: string; +}; + +declare class Magazine { + private static gedeId; + /** 获取类别列表 */ + static getCategories(): Promise<{ + id: number; + name: string; + }[]>; + /** 加载指定类别的期刊列表 */ + static getList(catagoryId: number, page?: number, pageSize?: number): Promise; + /** + * 获取期刊的分期列表 + * @param id 期刊编号 + * @returns + */ + static getIssues(id: number): Promise; + /** + * 获取期刊正文和目录数据 + * @param surl 某期的 `surl` + * @param issueId 某期编号 + * @param page 页码 + * @param pageSize 数据条数 + * @param width 阅读器宽度像素,影响计算单页字数 + * @param height 阅读器高度像素,影响计算单页字数 + * @returns + */ + static getData(surl: string, issueId: string, page?: number, pageSize?: number, width?: number, height?: number): Promise; + /** 获取期刊目录数据 */ + static getCatalog(surl: string, issueId: string): Promise; + private static getDetailURL; +} +type MagazineItem = { + /** 期刊名称 */ + name: string; + /** 在线阅读器所需参数 */ + surl: string; + /** 期刊编号 */ + id: number; + /** 国内刊号 */ + cn: string; + /** 国际刊号 */ + issn: string; + /** 期刊介绍 */ + summary: string; + /** 封面地址 */ + cover: string; +}; +type IssueItem = { + issueId: string; + magazineName: string; + cover: string; + name: string; + qrCode: string; + surl: string; + webReader: string; +}; + +export { Book, Magazine }; diff --git a/dist/index.mjs b/dist/index.mjs new file mode 100644 index 0000000..0aedcce --- /dev/null +++ b/dist/index.mjs @@ -0,0 +1,2 @@ +var p=Object.defineProperty;var i=(d,e)=>p(d,"name",{value:e,configurable:!0});class h{static{i(this,"Book")}static gedeId=847516381;static async getCategories(){const e=i(async r=>{const s=`https://gede.5read.com/apis/touchBook/bookCata.jspx${typeof r>"u"?"":`?gedeid=${r}`}`,n=await fetch(s).then(o=>o.json());if(!n.result)throw new Error(n.errorMsg);return n.msg.map(o=>({id:o.id,name:o.cataname}))},"getData");return(await Promise.all([e(this.gedeId),e()])).flat()}static async getList(e,r=0,t=72){const n=`https://gede.5read.com/apis/touchBook/books.jspx?${new URLSearchParams({cataid:e.toString(),page:(r+1).toString(),pageSize:t.toString()}).toString()}`,o=await fetch(n).then(a=>a.json());if(!o.result)throw new Error(o.errorMsg);return o.msg.list.map(a=>({name:a.title,author:a.author,bigCover:a.bcover,smallCover:a.cover,id:a.bookNum,price:a.price,publish:a.publish,summary:a.summary,surl:a.surl,webReader:`http://gede.5read.com/other/epub/read4tm.jsp?a=GEDE:${a.surl}`,type:a.type,isbn:a.isbn}))}static async getInfo(e){const r=`http://gede.5read.com/apis/touchBook/book.jspx?bookNum=${e}`,t=await fetch(r).then(s=>s.json());if(!t.result)throw new Error(t.errorMsg);return{name:t.msg.title,author:t.msg.author,bigCover:t.msg.bcover,smallCover:t.msg.cover,id:t.msg.bookNum,price:t.msg.price,publish:t.msg.publish,summary:t.msg.summary,surl:t.msg.surl,epub:t.msg.path,publishTime:t.msg.pubTime,webReader:`http://gede.5read.com/other/epub/read4tm.jsp?a=GEDE:${t.msg.surl}`,type:t.msg.type,isbn:t.msg.isbn}}static async getData(e,r=0,t=36,s=1500,n=1500){const a=`http://gede.5read.com/other/epub_epubRead_read.jspx?${new URLSearchParams({page:(r+1).toString(),psize:t.toString(),sid:e,w:s.toString(),h:n.toString(),detailUrl:`http://gede.5read.com/apis/touchBook/book.jspx?bookNum=${e}`,from:"4"}).toString()}`,c=await fetch(a).then(u=>u.json());if(!c.result)throw new Error(c.errorMsg);return{catalogs:c.msg.catalogs,contents:c.msg.contents}}static async getCatalog(e){return await this.getData(e,1,0)}}class l{static{i(this,"Magazine")}static gedeId=847516381;static async getCategories(){const e=`https://gede.5read.com/apis/magazine/magazineCatas.jspx?gedeid=${this.gedeId}`,r=await fetch(e).then(t=>t.json());if(!r.result)throw new Error(r.errorMsg);return r.msg.map(t=>({id:t.id,name:t.cataName}))}static async getList(e,r=0,t=72){const n=`http://gede.5read.com/apis/magazine/magazines.jspx?${new URLSearchParams({gedeid:"847516381",cataid:e.toString(),page:(r+1).toString(),pageSize:t.toString()}).toString()}`,o=await fetch(n).then(a=>a.json());if(!o.result)throw new Error(o.errorMsg);return o.msg.list.map(a=>({name:a.name,id:a.id,surl:a.surl,summary:a.summary,cover:a.coverPath,cn:a.cN,issn:a.iSSN}))}static async getIssues(e){const r=`http://gede.5read.com/apis/magazine/magazineItems.jspx?magazineid=${e}`,t=await fetch(r).then(s=>s.json());if(!t.result)throw new Error(t.errorMsg);return t.msg.itemList.map(s=>({issueId:s.magazineItemNum,name:s.issue,cover:s.coverPath,magazineName:s.name,qrCode:s.codeImg,surl:s.surl,webReader:`http://gede.5read.com/other/epub/read4tm.jsp?a=GEDE:${s.surl}`}))}static async getData(e,r,t=0,s=36,n=1500,o=1500){const a=await this.getDetailURL(e),u=`http://gede.5read.com/other/epub_epubRead_read.jspx?${new URLSearchParams({page:(t+1).toString(),psize:s.toString(),sid:r,w:n.toString(),h:o.toString(),detailUrl:a,from:"5"}).toString()}`,g=await fetch(u).then(m=>m.json());if(!g.result)throw new Error(g.errorMsg);return{catalogs:g.msg.catalogs,contents:g.msg.contents}}static async getCatalog(e,r){return await this.getData(e,r,1,0)}static async getDetailURL(e){const r=`http://gede.5read.com/other/epub/read4tm.jsp?a=GEDE:${e}`,s=(await fetch(r).then(n=>n.text())).match(/var\s*detailUrl\s*=\s*"([^"]+)"/);if(!s)throw new Error("\u83B7\u53D6 detailUrl \u5931\u8D25");return s[1]}}export{h as Book,l as Magazine}; +//# sourceMappingURL=index.mjs.map diff --git a/dist/index.mjs.map b/dist/index.mjs.map new file mode 100644 index 0000000..44d7422 --- /dev/null +++ b/dist/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../src/book.ts","../src/magazine.ts"],"sourcesContent":["/// \r\n\r\nexport class Book {\r\n private static gedeId = 847516381\r\n /** 获取类别列表 */\r\n static async getCategories(): Promise<{ id: number, name: string }[]> {\r\n const getData = async (gedeId?: number) => {\r\n const end = typeof gedeId == 'undefined' ? '' : `?gedeid=${gedeId}`\r\n const url = `https://gede.5read.com/apis/touchBook/bookCata.jspx${end}`\r\n const data = await fetch(url).then(res => res.json()) as ResData\r\n if (!data.result) throw new Error(data.errorMsg)\r\n return data.msg.map(item => ({\r\n id: item.id,\r\n name: item.cataname\r\n }))\r\n }\r\n return (await Promise.all([\r\n getData(this.gedeId),\r\n getData()\r\n ])).flat()\r\n }\r\n\r\n /**\r\n * 获取指定类别的图书列表\r\n * @param catagoryId 图书类别编号\r\n * @param page 页码\r\n * @param pageSize 返回数据条数\r\n * @returns \r\n */\r\n static async getList(catagoryId: number, page = 0, pageSize = 72): Promise {\r\n const params = new URLSearchParams({\r\n cataid: catagoryId.toString(),\r\n page: (page + 1).toString(),\r\n pageSize: pageSize.toString()\r\n }).toString()\r\n const url = `https://gede.5read.com/apis/touchBook/books.jspx?${params}`\r\n const data = await fetch(url).then(res => res.json()) as ResData<{\r\n allCount: number\r\n list: ResBookItem[],\r\n page: number,\r\n pageCount: number\r\n pageSize: number\r\n }>\r\n if (!data.result) throw new Error(data.errorMsg)\r\n return data.msg.list.map(item => ({\r\n name: item.title,\r\n author: item.author,\r\n bigCover: item.bcover,\r\n smallCover: item.cover,\r\n id: item.bookNum,\r\n price: item.price,\r\n publish: item.publish,\r\n summary: item.summary,\r\n surl: item.surl,\r\n webReader: `http://gede.5read.com/other/epub/read4tm.jsp?a=GEDE:${item.surl}`,\r\n type: item.type,\r\n isbn: item.isbn\r\n }))\r\n }\r\n\r\n /**\r\n * 获取图书详情\r\n * @param id 图书编号\r\n * @returns \r\n */\r\n static async getInfo(id: string): Promise {\r\n const url = `http://gede.5read.com/apis/touchBook/book.jspx?bookNum=${id}`\r\n const data = await fetch(url).then(res => res.json()) as ResData\r\n if (!data.result) throw new Error(data.errorMsg)\r\n return {\r\n name: data.msg.title,\r\n author: data.msg.author,\r\n bigCover: data.msg.bcover,\r\n smallCover: data.msg.cover,\r\n id: data.msg.bookNum,\r\n price: data.msg.price,\r\n publish: data.msg.publish,\r\n summary: data.msg.summary,\r\n surl: data.msg.surl,\r\n epub: data.msg.path,\r\n publishTime: data.msg.pubTime,\r\n webReader: `http://gede.5read.com/other/epub/read4tm.jsp?a=GEDE:${data.msg.surl}`,\r\n type: data.msg.type,\r\n isbn: data.msg.isbn\r\n }\r\n }\r\n\r\n /**\r\n * 获取图书正文和目录数据\r\n * @param id 图书编号\r\n * @param page 页码\r\n * @param pageSize 数据条数\r\n * @param width 阅读器宽度像素,影响计算单页字数\r\n * @param height 阅读器高度像素,影响计算单页字数\r\n * @returns\r\n */\r\n static async getData(id: string, page = 0, pageSize = 36, width = 1500, height = 1500): Promise {\r\n const params = new URLSearchParams({\r\n page: (page + 1).toString(),\r\n psize: pageSize.toString(),\r\n sid: id,\r\n w: width.toString(),\r\n h: height.toString(),\r\n detailUrl: `http://gede.5read.com/apis/touchBook/book.jspx?bookNum=${id}`,\r\n from: '4'\r\n }).toString()\r\n const url = `http://gede.5read.com/other/epub_epubRead_read.jspx?${params}`\r\n const data = await fetch(url).then(res => res.json()) as ResData\r\n if (!data.result) throw new Error(data.errorMsg)\r\n return {\r\n catalogs: data.msg.catalogs,\r\n contents: data.msg.contents\r\n }\r\n }\r\n\r\n /** 获取图书目录数据 */\r\n static async getCatalog(id: string) {\r\n return await this.getData(id, 1, 0)\r\n }\r\n}\r\n\r\n/** HTTP 响应中的图书目录数据 */\r\ntype ResCategory = {\r\n cataid: string\r\n cataname: string\r\n id: number\r\n dataversion: string\r\n}\r\n\r\n/** HTTP 响应中的图书列表项 */\r\ntype ResBookItem = {\r\n author: string\r\n /** 大图封面 */\r\n bcover: string\r\n /** 小图封面 */\r\n cover: string\r\n bookNum: string\r\n /** 出版社 */\r\n publish: string\r\n /** 内容摘要 */\r\n summary: string\r\n surl: string\r\n /** 图书名称 */\r\n title: string\r\n /** 总页数 */\r\n pageNum: number\r\n /** 图书价格 */\r\n price: string\r\n type: BookItem['type']\r\n isbn: string\r\n}\r\n\r\n/** HTTP 响应中的图书详情信息 */\r\ntype ResBookInfo = ResBookItem & {\r\n /** EPUB 文件地址 */\r\n path: string\r\n /** 发布时间 */\r\n pubTime: string\r\n}\r\n\r\n/** 图书列表项 */\r\nexport type BookItem = {\r\n name: string\r\n author: string\r\n id: string\r\n publish: string\r\n summary: string\r\n bigCover: string\r\n smallCover: string\r\n surl: string\r\n price: string\r\n /** 网页阅读器 */\r\n webReader: string\r\n type: 'HY' | 'GD'\r\n isbn: string\r\n}\r\n\r\n/** 图书详情 */\r\nexport type BookInfo = BookItem & {\r\n /** EPUB 文件地址 */\r\n epub: string\r\n /** 发布时间 */\r\n publishTime: string\r\n}","/// \r\n\r\nexport class Magazine {\r\n private static gedeId = 847516381\r\n /** 获取类别列表 */\r\n static async getCategories(): Promise<{ id: number, name: string }[]> {\r\n const url = `https://gede.5read.com/apis/magazine/magazineCatas.jspx?gedeid=${this.gedeId}`\r\n const data = await fetch(url).then(res => res.json()) as ResData\r\n if (!data.result) throw new Error(data.errorMsg)\r\n return data.msg.map(item => ({\r\n id: item.id,\r\n name: item.cataName\r\n }))\r\n }\r\n\r\n /** 加载指定类别的期刊列表 */\r\n static async getList(catagoryId: number, page = 0, pageSize = 72): Promise {\r\n const params = new URLSearchParams({\r\n gedeid: '847516381',\r\n cataid: catagoryId.toString(),\r\n page: (page + 1).toString(),\r\n pageSize: pageSize.toString()\r\n }).toString()\r\n const url = `http://gede.5read.com/apis/magazine/magazines.jspx?${params}`\r\n const data = await fetch(url).then(res => res.json()) as ResData<{\r\n allCount: number\r\n list: ResMagazineItem[]\r\n }>\r\n if (!data.result) throw new Error(data.errorMsg)\r\n return data.msg.list.map(item => ({\r\n name: item.name,\r\n id: item.id,\r\n surl: item.surl,\r\n summary: item.summary,\r\n cover: item.coverPath,\r\n cn: item.cN,\r\n issn: item.iSSN\r\n }))\r\n }\r\n\r\n /**\r\n * 获取期刊的分期列表\r\n * @param id 期刊编号\r\n * @returns \r\n */\r\n static async getIssues(id: number): Promise {\r\n const url = `http://gede.5read.com/apis/magazine/magazineItems.jspx?magazineid=${id}`\r\n const data = await fetch(url).then(res => res.json()) as ResData<{\r\n itemList: ResIssueItem[],\r\n magazine: ResMagazineItem\r\n }>\r\n if (!data.result) throw new Error(data.errorMsg)\r\n return data.msg.itemList.map(item => ({\r\n issueId: item.magazineItemNum,\r\n name: item.issue,\r\n cover: item.coverPath,\r\n magazineName: item.name,\r\n qrCode: item.codeImg,\r\n surl: item.surl,\r\n webReader: `http://gede.5read.com/other/epub/read4tm.jsp?a=GEDE:${item.surl}`\r\n }))\r\n }\r\n\r\n /**\r\n * 获取期刊正文和目录数据\r\n * @param surl 某期的 `surl`\r\n * @param issueId 某期编号\r\n * @param page 页码\r\n * @param pageSize 数据条数\r\n * @param width 阅读器宽度像素,影响计算单页字数\r\n * @param height 阅读器高度像素,影响计算单页字数\r\n * @returns\r\n */\r\n static async getData(surl: string, issueId: string, page = 0, pageSize = 36, width = 1500, height = 1500): Promise {\r\n const detailURL = await this.getDetailURL(surl)\r\n const params = new URLSearchParams({\r\n page: (page + 1).toString(),\r\n psize: pageSize.toString(),\r\n sid: issueId,\r\n w: width.toString(),\r\n h: height.toString(),\r\n /** 从在线阅读器 HTML 动态获取 */\r\n detailUrl: detailURL,\r\n /** 必填固定值 */\r\n from: '5'\r\n }).toString()\r\n const url = `http://gede.5read.com/other/epub_epubRead_read.jspx?${params}`\r\n const data = await fetch(url).then(res => res.json()) as ResData\r\n if (!data.result) throw new Error(data.errorMsg)\r\n return {\r\n catalogs: data.msg.catalogs,\r\n contents: data.msg.contents\r\n }\r\n }\r\n\r\n /** 获取期刊目录数据 */\r\n static async getCatalog(surl: string, issueId: string) {\r\n return await this.getData(surl, issueId, 1, 0)\r\n }\r\n\r\n private static async getDetailURL(surl: string) {\r\n const url = `http://gede.5read.com/other/epub/read4tm.jsp?a=GEDE:${surl}`\r\n const data = await fetch(url).then(res => res.text())\r\n const detailUrlMatch = data.match(/var\\s*detailUrl\\s*=\\s*\"([^\"]+)\"/)\r\n if (!detailUrlMatch) throw new Error('获取 detailUrl 失败')\r\n return detailUrlMatch[1]\r\n }\r\n\r\n}\r\n\r\ntype ResIssueItem = {\r\n coverPath: string\r\n issue: string\r\n codeImg: string\r\n name: string\r\n surl: string\r\n id: number\r\n sort: string\r\n magazineid: number\r\n urlid: number\r\n magazineItemNum: string\r\n}\r\n\r\n/** HTTP 响应中的期刊列表项 */\r\ntype ResMagazineItem = {\r\n /** 期刊介绍 */\r\n summary: string\r\n /** 封面地址 */\r\n coverPath: string\r\n magazineNum: string\r\n iSSN: string\r\n /** 期刊名称 */\r\n name: string\r\n surl: string\r\n cN: string\r\n /** 期刊编号,用于获取分期列表 */\r\n id: number\r\n urlid: number\r\n}\r\n\r\nexport type MagazineItem = {\r\n /** 期刊名称 */\r\n name: string\r\n /** 在线阅读器所需参数 */\r\n surl: string\r\n /** 期刊编号 */\r\n id: number\r\n /** 国内刊号 */\r\n cn: string\r\n /** 国际刊号 */\r\n issn: string\r\n /** 期刊介绍 */\r\n summary: string\r\n /** 封面地址 */\r\n cover: string\r\n}\r\n\r\nexport type IssueItem = {\r\n issueId: string\r\n magazineName: string\r\n cover: string\r\n name: string\r\n qrCode: string\r\n surl: string\r\n webReader: string\r\n}\r\n\r\ntype ResCategory = {\r\n id: number\r\n cataName: string\r\n version: string\r\n}"],"names":[],"mappings":"AACO,MAAM,IAAI,CAAC;AAClB,EAAE,OAAO,MAAM,GAAG,SAAS,CAAC;AAC5B;AACA,EAAE,aAAa,aAAa,GAAG;AAC/B,IAAI,MAAM,OAAO,GAAG,OAAO,MAAM,KAAK;AACtC,MAAM,MAAM,GAAG,GAAG,OAAO,MAAM,IAAI,WAAW,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1E,MAAM,MAAM,GAAG,GAAG,CAAC,mDAAmD,EAAE,GAAG,CAAC,CAAC,CAAC;AAC9E,MAAM,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AAC9D,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACvD,MAAM,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM;AACrC,QAAQ,EAAE,EAAE,IAAI,CAAC,EAAE;AACnB,QAAQ,IAAI,EAAE,IAAI,CAAC,QAAQ;AAC3B,OAAO,CAAC,CAAC,CAAC;AACV,KAAK,CAAC;AACN,IAAI,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC;AAC9B,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;AAC1B,MAAM,OAAO,EAAE;AACf,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;AACf,GAAG;AACH;AACA;AACA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AC,CAAC;AACrD,IAAI,OAAO;AACX,MAAM,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ;AACjC,MAAM,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ;AACjC,KAAK,CAAC;AACN,GAAG;AACH;AACA,EAAE,aAAa,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE;AACzC,IAAI,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACnD,GAAG;AACH,EAAE,aAAa,YAAY,CAAC,IAAI,EAAE;AAClC,IAAI,MAAM,GAAG,GAAG,CAAC,oDAAoD,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9E,IAAI,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5D,IAAI,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACzE,IAAI,IAAI,CAAC,cAAc,EAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;AAChF,IAAI,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;AAC7B,GAAG;AACH;;;;"} \ No newline at end of file diff --git a/package.json b/package.json index 07b4717..2fc7302 100644 --- a/package.json +++ b/package.json @@ -3,21 +3,22 @@ "typescript": "^5.4.5" }, "scripts": { - "dev": "tsc -w" + "build": "pkgroll --minify --clean-dist --sourcemap" }, "name": "gede-book-api", "description": "> 歌德电子书借阅机 API", - "version": "1.0.15", - "main": "js/main.mjs", - "types": "src/main.mts", + "version": "1.0.16", + "types": "./dist/index.d.mts", + "exports": "./dist/index.mjs", "repository": { "type": "git", "url": "git+https://github.com/iuroc/gede-book-api.git" }, + "type": "module", "author": "iuroc", "license": "ISC", "bugs": { "url": "https://github.com/iuroc/gede-book-api/issues" }, "homepage": "https://github.com/iuroc/gede-book-api#readme" -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..043b309 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,24 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + typescript: + specifier: ^5.4.5 + version: 5.5.4 + +packages: + + typescript@5.5.4: + resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} + engines: {node: '>=14.17'} + hasBin: true + +snapshots: + + typescript@5.5.4: {} diff --git a/src/book.mts b/src/book.ts similarity index 99% rename from src/book.mts rename to src/book.ts index 46fcbd9..9630b85 100644 --- a/src/book.mts +++ b/src/book.ts @@ -1,4 +1,4 @@ -/// +/// export class Book { private static gedeId = 847516381 diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..3a70785 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,11 @@ +import { + Book, +} from './book.js' +import { + Magazine, +} from './magazine.js' + +export { + Book, + Magazine, +} \ No newline at end of file diff --git a/src/magazine.mts b/src/magazine.ts similarity index 99% rename from src/magazine.mts rename to src/magazine.ts index 63b2a27..83551c6 100644 --- a/src/magazine.mts +++ b/src/magazine.ts @@ -1,4 +1,4 @@ -/// +/// export class Magazine { private static gedeId = 847516381 diff --git a/src/main.mts b/src/main.mts deleted file mode 100644 index 90b3508..0000000 --- a/src/main.mts +++ /dev/null @@ -1,19 +0,0 @@ -import { - Book, - BookInfo, - BookItem -} from './book.mjs' -import { - Magazine, - MagazineItem, - IssueItem -} from './magazine.mjs' - -export { - Book, - Magazine, - BookInfo, - BookItem, - MagazineItem, - IssueItem -} \ No newline at end of file diff --git a/src/types.d.mts b/src/types.d.ts similarity index 100% rename from src/types.d.mts rename to src/types.d.ts diff --git a/tsconfig.json b/tsconfig.json index b399057..8e405f1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,12 +2,7 @@ "compilerOptions": { "target": "ESNext", "strict": true, - "outDir": "js", - "lib": [ - "ESNext", - "DOM" - ], - "module": "ESNext", - "moduleResolution": "Bundler" + "module": "NodeNext", + "moduleResolution": "NodeNext" }, } \ No newline at end of file