11## @cosense/types
22
33[ ![ JSR] ( https://jsr.io/badges/@cosense/types )] ( https://jsr.io/@cosense/types )
4+ [ ![ npm] ( https://img.shields.io/npm/v/@cosense/types )] ( https://www.npmjs.com/package/@cosense/types )
45[ ![ test] ( https://github.com/scrapbox-jp/types/workflows/ci/badge.svg )] ( https://github.com/scrapbox-jp/types/actions?query=workflow%3Aci )
56
7+ > ** Node.js & npm Notice (since 0.11.1)**
8+ >
9+ > Now also published on ** [ npm] ( https://www.npmjs.com/package/@cosense/types ) ** .
10+ >
11+ > Node.js support is ** experimental** : I mainly target Deno and browsers, so I
12+ > don't actively maintain Node.js compatibility. Some tests run, but there may
13+ > still be runtime or type gaps remaining. Please use it with that
14+ > understanding.
15+ >
16+ > That said, ** issues / PRs to improve Node support are very welcome!**
17+ >
18+ > If you don't need a public npm package, you can consume the JSR version
19+ > directly—` npm ` via a custom registry in ` .npmrc ` ; ` yarn ` or ` pnpm ` need no
20+ > extra config. See the
21+ > [ JSR docs] ( https://jsr.io/docs/using-packages#adding-a-package ) .
22+
623Type definitions for [ cosense] ( https://cosen.se )
724
825## Getting Started
926
27+ This library provides TypeScript type definitions for Scrapbox/Cosense and
28+ supports both JSR (JavaScript Registry) and npm installation methods.
29+
30+ ### Installation
31+
32+ #### Option 1: JSR (Recommended for Deno projects)
33+
1034If you want to use type definitions for REST API, run
1135
1236``` bash
@@ -18,3 +42,51 @@ If you want to use type definitions for UserScript, run
1842``` bash
1943deno add jsr:@cosense/types/userscript
2044```
45+
46+ #### Option 2: npm (For Node.js projects)
47+
48+ Install via npm:
49+
50+ ``` bash
51+ npm install @cosense/types
52+ ```
53+
54+ Import the library:
55+
56+ ``` typescript ignore
57+ // ESM syntax
58+ import type { PageList } from " @cosense/types/rest" ;
59+ import type { Scrapbox } from " @cosense/types/userscript" ;
60+ ```
61+
62+ ### Usage Examples
63+
64+ ``` typescript ignore
65+ // Example for JSR (Deno)
66+ import type { PageList } from " jsr:@cosense/types/rest" ;
67+
68+ const pages: PageList = {
69+ projectName: " example-project" ,
70+ skip: 0 ,
71+ limit: 100 ,
72+ count: 42 ,
73+ pages: [],
74+ };
75+ ```
76+
77+ For npm users:
78+
79+ ``` typescript ignore
80+ // Example for npm (Node.js)
81+ import type { PageList } from " @cosense/types/rest" ;
82+ import type { Scrapbox } from " @cosense/types/userscript" ;
83+
84+ // Use the types in your Node.js application
85+ const pageData: PageList = {
86+ projectName: " my-project" ,
87+ skip: 0 ,
88+ limit: 50 ,
89+ count: 10 ,
90+ pages: [],
91+ };
92+ ```
0 commit comments