@bstage-sdk/bridge 0.0.0-stage → 0.9.0

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.
@@ -0,0 +1,32 @@
1
+ export { B as BRIDGE_ERROR_CODES, a as BRIDGE_SURFACES, b as BridgeError, c as BridgeErrorCode, d as BridgeErrorLike, e as BridgeEventMap, f as BridgeHostEventType, g as BridgeInit, h as BridgeLimits, i as BridgeRequestMap, j as BridgeRequestType, k as BridgeResult, l as BridgeSurface, m as BridgeTranslations, F as FetchRequest, n as FetchResult, H as HOST_EVENT_TYPES, I as IFRAME_ATTRIBUTES, o as INIT_RESPONSE, L as LogLevel, M as MemberState, R as READY_EVENT, p as REQUEST_TIMEOUT_MS, q as REQUEST_TYPES, S as SlotState, r as StorageOp, T as ThemeState, s as ToastKind, W as WithSession, t as isBridgeErrorCode, u as isBridgeErrorLike, v as isBridgeSurface, w as isHostEventType, x as isRequestType } from './messages-9N0GFq5b.cjs';
2
+ export { C as CreateSrcdocOptions, M as MAX_ELEMENT_NAME_LENGTH, a as MAX_MEDIA_ORIGINS, b as buildFrameCsp, c as createNonce, d as createSession, e as createSrcdoc, i as isValidNonce, f as isValidSession } from './createSrcdoc-bOoxttPz.cjs';
3
+
4
+ /** 봉투 버전. 형식이 하위 호환되지 않게 바뀔 때만 올린다. */
5
+ declare const BRIDGE_VERSION = 1;
6
+ /** 봉투 네임스페이스 — 같은 창에 오가는 다른 postMessage와 구분한다. */
7
+ declare const BRIDGE_NAMESPACE = "bstage-bridge";
8
+ /** 봉투 id 최대 길이. 프레임이 만든 id를 호스트가 그대로 되돌려 주므로 상한을 둔다. */
9
+ declare const MAX_ENVELOPE_ID_LENGTH = 64;
10
+ /** 봉투 type 최대 길이. */
11
+ declare const MAX_ENVELOPE_TYPE_LENGTH = 32;
12
+ /** 봉투 종류 — 요청·응답·이벤트. */
13
+ type EnvelopeKind = 'req' | 'res' | 'evt';
14
+ /** 브리지 메시지 봉투. */
15
+ interface BridgeEnvelope<P = unknown> {
16
+ readonly v: typeof BRIDGE_VERSION;
17
+ readonly ns: typeof BRIDGE_NAMESPACE;
18
+ readonly id: string;
19
+ readonly kind: EnvelopeKind;
20
+ readonly type: string;
21
+ readonly payload: P;
22
+ }
23
+ /**
24
+ * 값이 브리지 봉투인지 검사한다. 모양만 본다 — 발신자 확인(source·session)은 호출자 몫이다.
25
+ */
26
+ declare function isBridgeEnvelope(value: unknown): value is BridgeEnvelope;
27
+ /** 봉투를 만든다. */
28
+ declare function createEnvelope<P>(kind: EnvelopeKind, type: string, id: string, payload: P): BridgeEnvelope<P>;
29
+ /** payload가 객체이고 `session`이 기대값과 같은지 검사한다(호스트 측 발신자 확인). */
30
+ declare function hasSession(payload: unknown, session: string): boolean;
31
+
32
+ export { BRIDGE_NAMESPACE, BRIDGE_VERSION, type BridgeEnvelope, type EnvelopeKind, MAX_ENVELOPE_ID_LENGTH, MAX_ENVELOPE_TYPE_LENGTH, createEnvelope, hasSession, isBridgeEnvelope };
@@ -0,0 +1,32 @@
1
+ export { B as BRIDGE_ERROR_CODES, a as BRIDGE_SURFACES, b as BridgeError, c as BridgeErrorCode, d as BridgeErrorLike, e as BridgeEventMap, f as BridgeHostEventType, g as BridgeInit, h as BridgeLimits, i as BridgeRequestMap, j as BridgeRequestType, k as BridgeResult, l as BridgeSurface, m as BridgeTranslations, F as FetchRequest, n as FetchResult, H as HOST_EVENT_TYPES, I as IFRAME_ATTRIBUTES, o as INIT_RESPONSE, L as LogLevel, M as MemberState, R as READY_EVENT, p as REQUEST_TIMEOUT_MS, q as REQUEST_TYPES, S as SlotState, r as StorageOp, T as ThemeState, s as ToastKind, W as WithSession, t as isBridgeErrorCode, u as isBridgeErrorLike, v as isBridgeSurface, w as isHostEventType, x as isRequestType } from './messages-9N0GFq5b.js';
2
+ export { C as CreateSrcdocOptions, M as MAX_ELEMENT_NAME_LENGTH, a as MAX_MEDIA_ORIGINS, b as buildFrameCsp, c as createNonce, d as createSession, e as createSrcdoc, i as isValidNonce, f as isValidSession } from './createSrcdoc-bOoxttPz.js';
3
+
4
+ /** 봉투 버전. 형식이 하위 호환되지 않게 바뀔 때만 올린다. */
5
+ declare const BRIDGE_VERSION = 1;
6
+ /** 봉투 네임스페이스 — 같은 창에 오가는 다른 postMessage와 구분한다. */
7
+ declare const BRIDGE_NAMESPACE = "bstage-bridge";
8
+ /** 봉투 id 최대 길이. 프레임이 만든 id를 호스트가 그대로 되돌려 주므로 상한을 둔다. */
9
+ declare const MAX_ENVELOPE_ID_LENGTH = 64;
10
+ /** 봉투 type 최대 길이. */
11
+ declare const MAX_ENVELOPE_TYPE_LENGTH = 32;
12
+ /** 봉투 종류 — 요청·응답·이벤트. */
13
+ type EnvelopeKind = 'req' | 'res' | 'evt';
14
+ /** 브리지 메시지 봉투. */
15
+ interface BridgeEnvelope<P = unknown> {
16
+ readonly v: typeof BRIDGE_VERSION;
17
+ readonly ns: typeof BRIDGE_NAMESPACE;
18
+ readonly id: string;
19
+ readonly kind: EnvelopeKind;
20
+ readonly type: string;
21
+ readonly payload: P;
22
+ }
23
+ /**
24
+ * 값이 브리지 봉투인지 검사한다. 모양만 본다 — 발신자 확인(source·session)은 호출자 몫이다.
25
+ */
26
+ declare function isBridgeEnvelope(value: unknown): value is BridgeEnvelope;
27
+ /** 봉투를 만든다. */
28
+ declare function createEnvelope<P>(kind: EnvelopeKind, type: string, id: string, payload: P): BridgeEnvelope<P>;
29
+ /** payload가 객체이고 `session`이 기대값과 같은지 검사한다(호스트 측 발신자 확인). */
30
+ declare function hasSession(payload: unknown, session: string): boolean;
31
+
32
+ export { BRIDGE_NAMESPACE, BRIDGE_VERSION, type BridgeEnvelope, type EnvelopeKind, MAX_ENVELOPE_ID_LENGTH, MAX_ENVELOPE_TYPE_LENGTH, createEnvelope, hasSession, isBridgeEnvelope };
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ import {
2
+ BRIDGE_ERROR_CODES,
3
+ BRIDGE_NAMESPACE,
4
+ BRIDGE_SURFACES,
5
+ BRIDGE_VERSION,
6
+ BridgeError,
7
+ HOST_EVENT_TYPES,
8
+ IFRAME_ATTRIBUTES,
9
+ INIT_RESPONSE,
10
+ MAX_ELEMENT_NAME_LENGTH,
11
+ MAX_ENVELOPE_ID_LENGTH,
12
+ MAX_ENVELOPE_TYPE_LENGTH,
13
+ MAX_MEDIA_ORIGINS,
14
+ READY_EVENT,
15
+ REQUEST_TIMEOUT_MS,
16
+ REQUEST_TYPES,
17
+ buildFrameCsp,
18
+ createEnvelope,
19
+ createNonce,
20
+ createSession,
21
+ createSrcdoc,
22
+ hasSession,
23
+ isBridgeEnvelope,
24
+ isBridgeErrorCode,
25
+ isBridgeErrorLike,
26
+ isBridgeSurface,
27
+ isHostEventType,
28
+ isRequestType,
29
+ isValidNonce,
30
+ isValidSession
31
+ } from "./chunk-6LV7HEN4.js";
32
+ import "./chunk-KQMJY4ZH.js";
33
+ export {
34
+ BRIDGE_ERROR_CODES,
35
+ BRIDGE_NAMESPACE,
36
+ BRIDGE_SURFACES,
37
+ BRIDGE_VERSION,
38
+ BridgeError,
39
+ HOST_EVENT_TYPES,
40
+ IFRAME_ATTRIBUTES,
41
+ INIT_RESPONSE,
42
+ MAX_ELEMENT_NAME_LENGTH,
43
+ MAX_ENVELOPE_ID_LENGTH,
44
+ MAX_ENVELOPE_TYPE_LENGTH,
45
+ MAX_MEDIA_ORIGINS,
46
+ READY_EVENT,
47
+ REQUEST_TIMEOUT_MS,
48
+ REQUEST_TYPES,
49
+ buildFrameCsp,
50
+ createEnvelope,
51
+ createNonce,
52
+ createSession,
53
+ createSrcdoc,
54
+ hasSession,
55
+ isBridgeEnvelope,
56
+ isBridgeErrorCode,
57
+ isBridgeErrorLike,
58
+ isBridgeSurface,
59
+ isHostEventType,
60
+ isRequestType,
61
+ isValidNonce,
62
+ isValidSession
63
+ };
@@ -0,0 +1,186 @@
1
+ /** 브리지 오류 코드. */
2
+ declare const BRIDGE_ERROR_CODES: readonly ["FORBIDDEN_DESTINATION", "FORBIDDEN_METHOD", "BODY_TOO_LARGE", "RATE_LIMITED", "BAD_REQUEST", "TIMEOUT", "NETWORK_ERROR", "UNSUPPORTED"];
3
+ type BridgeErrorCode = (typeof BRIDGE_ERROR_CODES)[number];
4
+ /** 코드가 붙은 브리지 오류. 호스트는 이 코드만 프레임에 돌려준다(내부 예외 메시지는 싣지 않는다). */
5
+ declare class BridgeError extends Error {
6
+ readonly code: BridgeErrorCode;
7
+ constructor(code: BridgeErrorCode, message: string);
8
+ }
9
+ declare function isBridgeErrorCode(value: unknown): value is BridgeErrorCode;
10
+ /**
11
+ * 프레임 쪽에서 요청이 거절됐을 때 받는 오류의 모양. 프레임 런타임은 자기완결 함수라
12
+ * `BridgeError` 클래스를 쓰지 못하므로 `Error`에 `code`를 붙여 던진다.
13
+ */
14
+ interface BridgeErrorLike extends Error {
15
+ readonly code: BridgeErrorCode;
16
+ }
17
+ declare function isBridgeErrorLike(value: unknown): value is BridgeErrorLike;
18
+
19
+ /** 프레임 요청 타임아웃. */
20
+ declare const REQUEST_TIMEOUT_MS = 15000;
21
+ /** 프레임 → 호스트 요청 종류(브리지 프로토콜 표). */
22
+ declare const REQUEST_TYPES: readonly ["fetch", "navigate", "back", "openExternal", "toast", "resize", "track", "storage", "log"];
23
+ type BridgeRequestType = (typeof REQUEST_TYPES)[number];
24
+ /** 호스트 → 프레임 이벤트 종류. */
25
+ declare const HOST_EVENT_TYPES: readonly ["slot.context", "locale", "member", "theme", "visibility"];
26
+ type BridgeHostEventType = (typeof HOST_EVENT_TYPES)[number];
27
+ /** 프레임 → 호스트 핸드셰이크 이벤트. */
28
+ declare const READY_EVENT = "ready";
29
+ /** 호스트 → 프레임 핸드셰이크 응답 type. */
30
+ declare const INIT_RESPONSE = "init";
31
+ /** 프레임이 보내는 모든 payload에 붙는 세션. */
32
+ type WithSession<T> = T & {
33
+ readonly session: string;
34
+ };
35
+ interface ThemeState {
36
+ readonly dark: boolean;
37
+ }
38
+ interface MemberState {
39
+ readonly signedIn: boolean;
40
+ readonly nickname?: string;
41
+ }
42
+ interface SlotState {
43
+ readonly id: string;
44
+ readonly context: unknown;
45
+ }
46
+ interface BridgeLimits {
47
+ readonly maxBodyBytes: number;
48
+ readonly maxRequestsPerMinute: number;
49
+ }
50
+ /** 격리 템플릿이 놓인 자리 — 커스텀 페이지 또는 슬롯 위젯. */
51
+ declare const BRIDGE_SURFACES: readonly ["page", "slot"];
52
+ type BridgeSurface = (typeof BRIDGE_SURFACES)[number];
53
+ declare function isBridgeSurface(value: unknown): value is BridgeSurface;
54
+ /** 번역 사전 — 키 → 문자열(flat). core `TranslationDict`와 같은 모양. */
55
+ type BridgeTranslations = Readonly<Record<string, string>>;
56
+ /**
57
+ * `res:init` payload. 회원 id·이메일·토큰은 넣지 않는다.
58
+ * `translations`는 현재 locale 사전(선택, 브리지 프로토콜) — core i18n이 CDN 대신 이 값을 쓴다.
59
+ * `placementId`는 호스트가 만든 스코프 키다(예: `page:{경로}|{url}`, `slot:{id}|{url}`).
60
+ */
61
+ interface BridgeInit {
62
+ readonly placementId: string;
63
+ readonly surface: BridgeSurface;
64
+ readonly phase: string;
65
+ readonly spaceId: string;
66
+ readonly hostOrigin: string;
67
+ readonly gatewayBase: string;
68
+ readonly locale: string;
69
+ readonly theme: ThemeState;
70
+ readonly slot?: SlotState;
71
+ readonly member: MemberState;
72
+ readonly limits: BridgeLimits;
73
+ readonly partnerOrigins: readonly string[];
74
+ readonly translations?: BridgeTranslations;
75
+ }
76
+ interface FetchRequest {
77
+ readonly url: string;
78
+ readonly method?: string;
79
+ readonly headers?: Readonly<Record<string, string>>;
80
+ readonly body?: string | null;
81
+ }
82
+ interface FetchResult {
83
+ readonly status: number;
84
+ readonly statusText: string;
85
+ readonly headers: {
86
+ readonly 'content-type'?: string;
87
+ };
88
+ readonly bodyText: string;
89
+ }
90
+ type ToastKind = 'info' | 'success' | 'warning' | 'error';
91
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
92
+ type StorageOp = 'get' | 'set' | 'remove';
93
+ /** 요청 type별 payload·결과 타입. */
94
+ interface BridgeRequestMap {
95
+ fetch: {
96
+ req: FetchRequest;
97
+ res: FetchResult;
98
+ };
99
+ navigate: {
100
+ req: {
101
+ readonly path: string;
102
+ };
103
+ res: Record<string, never>;
104
+ };
105
+ back: {
106
+ req: Record<string, never>;
107
+ res: Record<string, never>;
108
+ };
109
+ openExternal: {
110
+ req: {
111
+ readonly url: string;
112
+ };
113
+ res: Record<string, never>;
114
+ };
115
+ toast: {
116
+ req: {
117
+ readonly message: string;
118
+ readonly kind?: ToastKind;
119
+ };
120
+ res: Record<string, never>;
121
+ };
122
+ resize: {
123
+ req: {
124
+ readonly height: number;
125
+ };
126
+ res: Record<string, never>;
127
+ };
128
+ track: {
129
+ req: {
130
+ readonly name: string;
131
+ readonly params?: Readonly<Record<string, unknown>>;
132
+ };
133
+ res: Record<string, never>;
134
+ };
135
+ storage: {
136
+ req: {
137
+ readonly op: StorageOp;
138
+ readonly key: string;
139
+ readonly value?: string;
140
+ };
141
+ res: {
142
+ readonly value: string | null;
143
+ };
144
+ };
145
+ log: {
146
+ req: {
147
+ readonly level: LogLevel;
148
+ readonly message: string;
149
+ };
150
+ res: Record<string, never>;
151
+ };
152
+ }
153
+ /** 이벤트 type별 payload. */
154
+ interface BridgeEventMap {
155
+ 'slot.context': SlotState;
156
+ locale: {
157
+ readonly locale: string;
158
+ readonly translations?: BridgeTranslations;
159
+ };
160
+ member: MemberState;
161
+ theme: ThemeState;
162
+ visibility: {
163
+ readonly visible: boolean;
164
+ };
165
+ }
166
+ /** `res` payload — 성공이면 `data`, 실패면 코드만 담긴 `error`. */
167
+ type BridgeResult<T> = {
168
+ readonly ok: true;
169
+ readonly data: T;
170
+ } | {
171
+ readonly ok: false;
172
+ readonly error: {
173
+ readonly code: BridgeErrorCode;
174
+ readonly message: string;
175
+ };
176
+ };
177
+ /** 격리 iframe 속성. 호스트(플랫폼·미리보기)가 iframe을 만들 때 그대로 쓴다. */
178
+ declare const IFRAME_ATTRIBUTES: {
179
+ readonly sandbox: "allow-scripts";
180
+ readonly allow: "autoplay; fullscreen; picture-in-picture; encrypted-media; clipboard-write";
181
+ readonly referrerpolicy: "no-referrer";
182
+ };
183
+ declare function isRequestType(value: unknown): value is BridgeRequestType;
184
+ declare function isHostEventType(value: unknown): value is BridgeHostEventType;
185
+
186
+ export { BRIDGE_ERROR_CODES as B, type FetchRequest as F, HOST_EVENT_TYPES as H, IFRAME_ATTRIBUTES as I, type LogLevel as L, type MemberState as M, READY_EVENT as R, type SlotState as S, type ThemeState as T, type WithSession as W, BRIDGE_SURFACES as a, BridgeError as b, type BridgeErrorCode as c, type BridgeErrorLike as d, type BridgeEventMap as e, type BridgeHostEventType as f, type BridgeInit as g, type BridgeLimits as h, type BridgeRequestMap as i, type BridgeRequestType as j, type BridgeResult as k, type BridgeSurface as l, type BridgeTranslations as m, type FetchResult as n, INIT_RESPONSE as o, REQUEST_TIMEOUT_MS as p, REQUEST_TYPES as q, type StorageOp as r, type ToastKind as s, isBridgeErrorCode as t, isBridgeErrorLike as u, isBridgeSurface as v, isHostEventType as w, isRequestType as x };
@@ -0,0 +1,186 @@
1
+ /** 브리지 오류 코드. */
2
+ declare const BRIDGE_ERROR_CODES: readonly ["FORBIDDEN_DESTINATION", "FORBIDDEN_METHOD", "BODY_TOO_LARGE", "RATE_LIMITED", "BAD_REQUEST", "TIMEOUT", "NETWORK_ERROR", "UNSUPPORTED"];
3
+ type BridgeErrorCode = (typeof BRIDGE_ERROR_CODES)[number];
4
+ /** 코드가 붙은 브리지 오류. 호스트는 이 코드만 프레임에 돌려준다(내부 예외 메시지는 싣지 않는다). */
5
+ declare class BridgeError extends Error {
6
+ readonly code: BridgeErrorCode;
7
+ constructor(code: BridgeErrorCode, message: string);
8
+ }
9
+ declare function isBridgeErrorCode(value: unknown): value is BridgeErrorCode;
10
+ /**
11
+ * 프레임 쪽에서 요청이 거절됐을 때 받는 오류의 모양. 프레임 런타임은 자기완결 함수라
12
+ * `BridgeError` 클래스를 쓰지 못하므로 `Error`에 `code`를 붙여 던진다.
13
+ */
14
+ interface BridgeErrorLike extends Error {
15
+ readonly code: BridgeErrorCode;
16
+ }
17
+ declare function isBridgeErrorLike(value: unknown): value is BridgeErrorLike;
18
+
19
+ /** 프레임 요청 타임아웃. */
20
+ declare const REQUEST_TIMEOUT_MS = 15000;
21
+ /** 프레임 → 호스트 요청 종류(브리지 프로토콜 표). */
22
+ declare const REQUEST_TYPES: readonly ["fetch", "navigate", "back", "openExternal", "toast", "resize", "track", "storage", "log"];
23
+ type BridgeRequestType = (typeof REQUEST_TYPES)[number];
24
+ /** 호스트 → 프레임 이벤트 종류. */
25
+ declare const HOST_EVENT_TYPES: readonly ["slot.context", "locale", "member", "theme", "visibility"];
26
+ type BridgeHostEventType = (typeof HOST_EVENT_TYPES)[number];
27
+ /** 프레임 → 호스트 핸드셰이크 이벤트. */
28
+ declare const READY_EVENT = "ready";
29
+ /** 호스트 → 프레임 핸드셰이크 응답 type. */
30
+ declare const INIT_RESPONSE = "init";
31
+ /** 프레임이 보내는 모든 payload에 붙는 세션. */
32
+ type WithSession<T> = T & {
33
+ readonly session: string;
34
+ };
35
+ interface ThemeState {
36
+ readonly dark: boolean;
37
+ }
38
+ interface MemberState {
39
+ readonly signedIn: boolean;
40
+ readonly nickname?: string;
41
+ }
42
+ interface SlotState {
43
+ readonly id: string;
44
+ readonly context: unknown;
45
+ }
46
+ interface BridgeLimits {
47
+ readonly maxBodyBytes: number;
48
+ readonly maxRequestsPerMinute: number;
49
+ }
50
+ /** 격리 템플릿이 놓인 자리 — 커스텀 페이지 또는 슬롯 위젯. */
51
+ declare const BRIDGE_SURFACES: readonly ["page", "slot"];
52
+ type BridgeSurface = (typeof BRIDGE_SURFACES)[number];
53
+ declare function isBridgeSurface(value: unknown): value is BridgeSurface;
54
+ /** 번역 사전 — 키 → 문자열(flat). core `TranslationDict`와 같은 모양. */
55
+ type BridgeTranslations = Readonly<Record<string, string>>;
56
+ /**
57
+ * `res:init` payload. 회원 id·이메일·토큰은 넣지 않는다.
58
+ * `translations`는 현재 locale 사전(선택, 브리지 프로토콜) — core i18n이 CDN 대신 이 값을 쓴다.
59
+ * `placementId`는 호스트가 만든 스코프 키다(예: `page:{경로}|{url}`, `slot:{id}|{url}`).
60
+ */
61
+ interface BridgeInit {
62
+ readonly placementId: string;
63
+ readonly surface: BridgeSurface;
64
+ readonly phase: string;
65
+ readonly spaceId: string;
66
+ readonly hostOrigin: string;
67
+ readonly gatewayBase: string;
68
+ readonly locale: string;
69
+ readonly theme: ThemeState;
70
+ readonly slot?: SlotState;
71
+ readonly member: MemberState;
72
+ readonly limits: BridgeLimits;
73
+ readonly partnerOrigins: readonly string[];
74
+ readonly translations?: BridgeTranslations;
75
+ }
76
+ interface FetchRequest {
77
+ readonly url: string;
78
+ readonly method?: string;
79
+ readonly headers?: Readonly<Record<string, string>>;
80
+ readonly body?: string | null;
81
+ }
82
+ interface FetchResult {
83
+ readonly status: number;
84
+ readonly statusText: string;
85
+ readonly headers: {
86
+ readonly 'content-type'?: string;
87
+ };
88
+ readonly bodyText: string;
89
+ }
90
+ type ToastKind = 'info' | 'success' | 'warning' | 'error';
91
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
92
+ type StorageOp = 'get' | 'set' | 'remove';
93
+ /** 요청 type별 payload·결과 타입. */
94
+ interface BridgeRequestMap {
95
+ fetch: {
96
+ req: FetchRequest;
97
+ res: FetchResult;
98
+ };
99
+ navigate: {
100
+ req: {
101
+ readonly path: string;
102
+ };
103
+ res: Record<string, never>;
104
+ };
105
+ back: {
106
+ req: Record<string, never>;
107
+ res: Record<string, never>;
108
+ };
109
+ openExternal: {
110
+ req: {
111
+ readonly url: string;
112
+ };
113
+ res: Record<string, never>;
114
+ };
115
+ toast: {
116
+ req: {
117
+ readonly message: string;
118
+ readonly kind?: ToastKind;
119
+ };
120
+ res: Record<string, never>;
121
+ };
122
+ resize: {
123
+ req: {
124
+ readonly height: number;
125
+ };
126
+ res: Record<string, never>;
127
+ };
128
+ track: {
129
+ req: {
130
+ readonly name: string;
131
+ readonly params?: Readonly<Record<string, unknown>>;
132
+ };
133
+ res: Record<string, never>;
134
+ };
135
+ storage: {
136
+ req: {
137
+ readonly op: StorageOp;
138
+ readonly key: string;
139
+ readonly value?: string;
140
+ };
141
+ res: {
142
+ readonly value: string | null;
143
+ };
144
+ };
145
+ log: {
146
+ req: {
147
+ readonly level: LogLevel;
148
+ readonly message: string;
149
+ };
150
+ res: Record<string, never>;
151
+ };
152
+ }
153
+ /** 이벤트 type별 payload. */
154
+ interface BridgeEventMap {
155
+ 'slot.context': SlotState;
156
+ locale: {
157
+ readonly locale: string;
158
+ readonly translations?: BridgeTranslations;
159
+ };
160
+ member: MemberState;
161
+ theme: ThemeState;
162
+ visibility: {
163
+ readonly visible: boolean;
164
+ };
165
+ }
166
+ /** `res` payload — 성공이면 `data`, 실패면 코드만 담긴 `error`. */
167
+ type BridgeResult<T> = {
168
+ readonly ok: true;
169
+ readonly data: T;
170
+ } | {
171
+ readonly ok: false;
172
+ readonly error: {
173
+ readonly code: BridgeErrorCode;
174
+ readonly message: string;
175
+ };
176
+ };
177
+ /** 격리 iframe 속성. 호스트(플랫폼·미리보기)가 iframe을 만들 때 그대로 쓴다. */
178
+ declare const IFRAME_ATTRIBUTES: {
179
+ readonly sandbox: "allow-scripts";
180
+ readonly allow: "autoplay; fullscreen; picture-in-picture; encrypted-media; clipboard-write";
181
+ readonly referrerpolicy: "no-referrer";
182
+ };
183
+ declare function isRequestType(value: unknown): value is BridgeRequestType;
184
+ declare function isHostEventType(value: unknown): value is BridgeHostEventType;
185
+
186
+ export { BRIDGE_ERROR_CODES as B, type FetchRequest as F, HOST_EVENT_TYPES as H, IFRAME_ATTRIBUTES as I, type LogLevel as L, type MemberState as M, READY_EVENT as R, type SlotState as S, type ThemeState as T, type WithSession as W, BRIDGE_SURFACES as a, BridgeError as b, type BridgeErrorCode as c, type BridgeErrorLike as d, type BridgeEventMap as e, type BridgeHostEventType as f, type BridgeInit as g, type BridgeLimits as h, type BridgeRequestMap as i, type BridgeRequestType as j, type BridgeResult as k, type BridgeSurface as l, type BridgeTranslations as m, type FetchResult as n, INIT_RESPONSE as o, REQUEST_TIMEOUT_MS as p, REQUEST_TYPES as q, type StorageOp as r, type ToastKind as s, isBridgeErrorCode as t, isBridgeErrorLike as u, isBridgeSurface as v, isHostEventType as w, isRequestType as x };
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@bstage-sdk/bridge",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.9.0",
4
+ "description": "bstage SDK bridge — isolated template iframe protocol, host policy and frame client",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/bstage-sdk/web-sdk.git",
12
+ "directory": "packages/bridge"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "import": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "require": {
21
+ "types": "./dist/index.d.cts",
22
+ "default": "./dist/index.cjs"
23
+ }
24
+ },
25
+ "./host": {
26
+ "import": {
27
+ "types": "./dist/host.d.ts",
28
+ "default": "./dist/host.js"
29
+ },
30
+ "require": {
31
+ "types": "./dist/host.d.cts",
32
+ "default": "./dist/host.cjs"
33
+ }
34
+ },
35
+ "./frame": {
36
+ "import": {
37
+ "types": "./dist/frame.d.ts",
38
+ "default": "./dist/frame.js"
39
+ },
40
+ "require": {
41
+ "types": "./dist/frame.d.cts",
42
+ "default": "./dist/frame.cjs"
43
+ }
44
+ }
45
+ },
46
+ "main": "./dist/index.cjs",
47
+ "module": "./dist/index.js",
48
+ "types": "./dist/index.d.ts",
49
+ "typesVersions": {
50
+ "*": {
51
+ "host": [
52
+ "./dist/host.d.ts"
53
+ ],
54
+ "frame": [
55
+ "./dist/frame.d.ts"
56
+ ]
57
+ }
58
+ },
59
+ "files": [
60
+ "dist"
61
+ ],
62
+ "devDependencies": {
63
+ "tsup": "^8.0.0",
64
+ "typescript": "^5.5.0"
65
+ },
66
+ "license": "MIT",
67
+ "scripts": {
68
+ "build": "tsup",
69
+ "typecheck": "tsc --noEmit"
70
+ }
6
71
  }