@zipbul/shared 0.0.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.
package/README.ko.md ADDED
@@ -0,0 +1,64 @@
1
+ # @zipbul/shared
2
+
3
+ [English](./README.md) | **한국어**
4
+
5
+ `@zipbul` 툴킷의 공유 라이브러리입니다.
6
+ 여러 `@zipbul` 패키지에서 공통으로 사용하는 열거형(enum), 상수, 타입, 유틸리티 등을 제공합니다.
7
+
8
+ <br>
9
+
10
+ ## 📦 설치
11
+
12
+ ```bash
13
+ bun add @zipbul/shared
14
+ ```
15
+
16
+ <br>
17
+
18
+ ## 📚 구성 요소
19
+
20
+ ### HTTP 열거형
21
+
22
+ HTTP 메서드, 헤더, 상태 코드에 대한 타입 안전한 `const enum` 선언으로 매직 스트링을 제거합니다.
23
+
24
+ ```typescript
25
+ import { HttpMethod, HttpHeader, HttpStatus } from '@zipbul/shared';
26
+
27
+ if (request.method === HttpMethod.Get) {
28
+ headers.set(HttpHeader.AccessControlAllowOrigin, '*');
29
+ return new Response('OK', { status: HttpStatus.Ok });
30
+ }
31
+ ```
32
+
33
+ | Export | 설명 |
34
+ |:-------------|:--------------------------------------|
35
+ | `HttpMethod` | 표준 HTTP 메서드 (`Get`, `Post`, `Put`, `Patch`, `Delete`, …) |
36
+ | `HttpHeader` | CORS 관련 HTTP 헤더 (Fetch Standard, 소문자 값) |
37
+ | `HttpStatus` | 공통 HTTP 상태 코드 (`Ok`, `NoContent`, …) |
38
+
39
+ > 열거형은 `const enum`입니다 — `isolatedModules: false` 환경에서는 컴파일 타임에 값이 **인라인**되어 런타임 비용이 없습니다. 툴체인별 동작은 [`const enum`에 대하여](#-const-enum에-대하여)를 참고하세요.
40
+
41
+ <br>
42
+
43
+ ## 🔬 `const enum`에 대하여
44
+
45
+ 모든 열거형은 `const enum`으로 선언되어 있으며, 툴체인에 따라 동작이 다릅니다:
46
+
47
+ | 환경 | 동작 |
48
+ |:-----|:-----|
49
+ | TypeScript (`isolatedModules: false`) | 컴파일 타임에 값이 **인라인** — 런타임 객체 없음 |
50
+ | 번들러 (Bun, esbuild, Vite) | **일반 enum** 취급 — 런타임 객체가 생성됨 |
51
+ | `isolatedModules: true` / `verbatimModuleSyntax: true` | import가 보존되며, 번들러가 빌드 타임에 해소 |
52
+
53
+ 이것이 의미하는 바:
54
+ - **Bun 소비자**는 열거형을 정상적으로 사용 가능 — `bun build`가 해소를 처리
55
+ - **TypeScript 라이브러리 소비자**는 컴파일 타임 인라인의 이점을 누림 (런타임 비용 제로)
56
+ - `.d.ts` 파일은 `const enum` 선언을 보존하여 다운스트림 소비자에게 전달
57
+
58
+ > **참고:** `verbatimModuleSyntax: true`와 `emitDeclarationOnly`로 빌드할 때 TS2748 오류를 방지하려면 `tsconfig.build.json`에서 `verbatimModuleSyntax: false`를 설정해야 합니다. 빌드 설정에 이미 반영되어 있습니다.
59
+
60
+ <br>
61
+
62
+ ## 📄 라이선스
63
+
64
+ MIT
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @zipbul/shared
2
+
3
+ **English** | [한국어](./README.ko.md)
4
+
5
+ Shared library for the `@zipbul` toolkit.
6
+ Provides common definitions — enums, constants, types, and utilities — used across multiple `@zipbul` packages.
7
+
8
+ <br>
9
+
10
+ ## 📦 Installation
11
+
12
+ ```bash
13
+ bun add @zipbul/shared
14
+ ```
15
+
16
+ <br>
17
+
18
+ ## 📚 What's Inside
19
+
20
+ ### HTTP Enums
21
+
22
+ Type-safe `const enum` declarations that eliminate magic strings for HTTP methods, headers, and status codes.
23
+
24
+ ```typescript
25
+ import { HttpMethod, HttpHeader, HttpStatus } from '@zipbul/shared';
26
+
27
+ if (request.method === HttpMethod.Get) {
28
+ headers.set(HttpHeader.AccessControlAllowOrigin, '*');
29
+ return new Response('OK', { status: HttpStatus.Ok });
30
+ }
31
+ ```
32
+
33
+ | Export | Description |
34
+ |:-------------|:-------------------------------------|
35
+ | `HttpMethod` | Standard HTTP methods (`Get`, `Post`, `Put`, `Patch`, `Delete`, …) |
36
+ | `HttpHeader` | CORS-related HTTP headers (Fetch Standard, lowercase values) |
37
+ | `HttpStatus` | Common HTTP status codes (`Ok`, `NoContent`, …) |
38
+
39
+ > Enums are `const enum` — with `isolatedModules: false`, values are **inlined at compile time** with zero runtime footprint. See [About `const enum`](#-about-const-enum) for toolchain-specific behavior.
40
+
41
+ <br>
42
+
43
+ ## 🔬 About `const enum`
44
+
45
+ All enums are declared as `const enum`, which has different behavior depending on your toolchain:
46
+
47
+ | Environment | Behavior |
48
+ |:------------|:---------|
49
+ | TypeScript (`isolatedModules: false`) | Values are **inlined** at compile time — no runtime object |
50
+ | Bundlers (Bun, esbuild, Vite) | Treated as **regular enums** — runtime object is emitted |
51
+ | `isolatedModules: true` / `verbatimModuleSyntax: true` | Import is preserved; the bundler resolves it at build time |
52
+
53
+ This means:
54
+ - **Bun consumers** can use the enums normally — `bun build` handles the resolution
55
+ - **TypeScript library consumers** get the benefit of compile-time inlining (zero runtime cost)
56
+ - The `.d.ts` files preserve the `const enum` declarations for downstream consumers
57
+
58
+ > **Note:** When building with `verbatimModuleSyntax: true` and `emitDeclarationOnly`, you may need to set `verbatimModuleSyntax: false` in `tsconfig.build.json` to avoid TS2748. This is already handled in the build configuration.
59
+
60
+ <br>
61
+
62
+ ## 📄 License
63
+
64
+ MIT
@@ -0,0 +1 @@
1
+ export * from './src/enums';
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ // @bun
2
+ // src/enums/http-method.ts
3
+ var HttpMethod;
4
+ ((HttpMethod2) => {
5
+ HttpMethod2["Get"] = "GET";
6
+ HttpMethod2["Head"] = "HEAD";
7
+ HttpMethod2["Post"] = "POST";
8
+ HttpMethod2["Put"] = "PUT";
9
+ HttpMethod2["Patch"] = "PATCH";
10
+ HttpMethod2["Delete"] = "DELETE";
11
+ HttpMethod2["Options"] = "OPTIONS";
12
+ })(HttpMethod ||= {});
13
+ // src/enums/http-header.ts
14
+ var HttpHeader;
15
+ ((HttpHeader2) => {
16
+ HttpHeader2["Origin"] = "origin";
17
+ HttpHeader2["Vary"] = "vary";
18
+ HttpHeader2["AccessControlAllowOrigin"] = "access-control-allow-origin";
19
+ HttpHeader2["AccessControlAllowMethods"] = "access-control-allow-methods";
20
+ HttpHeader2["AccessControlAllowHeaders"] = "access-control-allow-headers";
21
+ HttpHeader2["AccessControlAllowCredentials"] = "access-control-allow-credentials";
22
+ HttpHeader2["AccessControlExposeHeaders"] = "access-control-expose-headers";
23
+ HttpHeader2["AccessControlMaxAge"] = "access-control-max-age";
24
+ HttpHeader2["AccessControlRequestMethod"] = "access-control-request-method";
25
+ HttpHeader2["AccessControlRequestHeaders"] = "access-control-request-headers";
26
+ })(HttpHeader ||= {});
27
+ // src/enums/http-status.ts
28
+ var HttpStatus;
29
+ ((HttpStatus2) => {
30
+ HttpStatus2[HttpStatus2["Ok"] = 200] = "Ok";
31
+ HttpStatus2[HttpStatus2["NoContent"] = 204] = "NoContent";
32
+ })(HttpStatus ||= {});
33
+ export {
34
+ HttpStatus,
35
+ HttpMethod,
36
+ HttpHeader
37
+ };
38
+
39
+ //# debugId=5DF757687905BEE364756E2164756E21
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/enums/http-method.ts", "../src/enums/http-header.ts", "../src/enums/http-status.ts"],
4
+ "sourcesContent": [
5
+ "export const enum HttpMethod {\n Get = 'GET',\n Head = 'HEAD',\n Post = 'POST',\n Put = 'PUT',\n Patch = 'PATCH',\n Delete = 'DELETE',\n Options = 'OPTIONS',\n}\n",
6
+ "export const enum HttpHeader {\n Origin = 'origin',\n Vary = 'vary',\n AccessControlAllowOrigin = 'access-control-allow-origin',\n AccessControlAllowMethods = 'access-control-allow-methods',\n AccessControlAllowHeaders = 'access-control-allow-headers',\n AccessControlAllowCredentials = 'access-control-allow-credentials',\n AccessControlExposeHeaders = 'access-control-expose-headers',\n AccessControlMaxAge = 'access-control-max-age',\n AccessControlRequestMethod = 'access-control-request-method',\n AccessControlRequestHeaders = 'access-control-request-headers',\n}\n",
7
+ "export const enum HttpStatus {\n Ok = 200,\n NoContent = 204,\n}\n"
8
+ ],
9
+ "mappings": ";;AAAO,IAAW;AAAA,CAAX,CAAW,gBAAX;AAAA,EACL,qBAAM;AAAA,EACN,sBAAO;AAAA,EACP,sBAAO;AAAA,EACP,qBAAM;AAAA,EACN,uBAAQ;AAAA,EACR,wBAAS;AAAA,EACT,yBAAU;AAAA,GAPM;;ACAX,IAAW;AAAA,CAAX,CAAW,gBAAX;AAAA,EACL,wBAAS;AAAA,EACT,sBAAO;AAAA,EACP,0CAA2B;AAAA,EAC3B,2CAA4B;AAAA,EAC5B,2CAA4B;AAAA,EAC5B,+CAAgC;AAAA,EAChC,4CAA6B;AAAA,EAC7B,qCAAsB;AAAA,EACtB,4CAA6B;AAAA,EAC7B,6CAA8B;AAAA,GAVd;;ACAX,IAAW;AAAA,CAAX,CAAW,gBAAX;AAAA,EACL,gCAAK,OAAL;AAAA,EACA,uCAAY,OAAZ;AAAA,GAFgB;",
10
+ "debugId": "5DF757687905BEE364756E2164756E21",
11
+ "names": []
12
+ }
@@ -0,0 +1,12 @@
1
+ export declare const enum HttpHeader {
2
+ Origin = "origin",
3
+ Vary = "vary",
4
+ AccessControlAllowOrigin = "access-control-allow-origin",
5
+ AccessControlAllowMethods = "access-control-allow-methods",
6
+ AccessControlAllowHeaders = "access-control-allow-headers",
7
+ AccessControlAllowCredentials = "access-control-allow-credentials",
8
+ AccessControlExposeHeaders = "access-control-expose-headers",
9
+ AccessControlMaxAge = "access-control-max-age",
10
+ AccessControlRequestMethod = "access-control-request-method",
11
+ AccessControlRequestHeaders = "access-control-request-headers"
12
+ }
@@ -0,0 +1,9 @@
1
+ export declare const enum HttpMethod {
2
+ Get = "GET",
3
+ Head = "HEAD",
4
+ Post = "POST",
5
+ Put = "PUT",
6
+ Patch = "PATCH",
7
+ Delete = "DELETE",
8
+ Options = "OPTIONS"
9
+ }
@@ -0,0 +1,4 @@
1
+ export declare const enum HttpStatus {
2
+ Ok = 200,
3
+ NoContent = 204
4
+ }
@@ -0,0 +1,3 @@
1
+ export * from './http-method';
2
+ export * from './http-header';
3
+ export * from './http-status';
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@zipbul/shared",
3
+ "version": "0.0.1",
4
+ "description": "Shared library for the @zipbul toolkit",
5
+ "license": "MIT",
6
+ "author": "Junhyung Park (https://github.com/parkrevil)",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/zipbul/toolkit",
10
+ "directory": "packages/shared"
11
+ },
12
+ "bugs": "https://github.com/zipbul/toolkit/issues",
13
+ "homepage": "https://github.com/zipbul/toolkit/tree/main/packages/shared#readme",
14
+ "keywords": ["enum", "constants", "shared", "typescript", "zipbul"],
15
+ "engines": {
16
+ "bun": ">=1.0.0"
17
+ },
18
+ "type": "module",
19
+ "module": "dist/index.js",
20
+ "types": "dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ }
26
+ },
27
+ "files": ["dist"],
28
+ "scripts": {
29
+ "build": "bun build index.ts --outdir dist --target bun --format esm --sourcemap=linked && tsc -p tsconfig.build.json"
30
+ }
31
+ }