-
Notifications
You must be signed in to change notification settings - Fork 0
Separate host and client exports #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(npm run build:*)" | ||
| ], | ||
| "deny": [], | ||
| "ask": [] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| export { type WebviewContextValue } from './client/WebviewContext'; | ||
| // export { type WebviewContextValue } from './client/WebviewContext'; | ||
| export { WebviewProvider } from './client/WebviewProvider'; | ||
| export { createCtxKey, useWebviewApi } from './client/useWebviewApi'; | ||
| export { useVscodeState } from './client/useVscodeState'; | ||
| export { useLogger } from './client/useLogger'; | ||
| export { isViewApiRequest, isViewApiResponse, isViewApiEvent, type CtxKey } from './types'; | ||
| export type { ClientCalls, ViewApiResponse, ViewApiError } from './types'; | ||
| export type { StateReducer, WebviewKey } from './types/ipcReducer'; | ||
| export type { WebviewLayout } from './types'; | ||
| export { isViewApiRequest, type CtxKey } from './types'; | ||
| export type { ClientCalls, HostCalls, ViewApiResponse, ViewApiError } from './types'; | ||
| export type { WebviewKey } from './types/reducer'; | ||
| export type { StateReducer, WebviewLayout } from './client/types'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type { FnKeys } from '../types/reducer'; | ||
|
|
||
| export function isFnKey<T extends object>( | ||
| prop: string | symbol | number, | ||
| obj: T | ||
| ): prop is FnKeys<T> { | ||
| return ( | ||
| Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop as keyof T] === 'function' | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| export type { ILogger } from './host/ILogger'; | ||
| export { Logger, getLogger, disallowedLogKeys } from './host/logger'; | ||
| export { WebviewApiProvider } from './host/WebviewApiProvider'; | ||
| export { BaseWebviewViewProvider } from './host/BaseWebviewViewProvider'; | ||
| export { isViewApiRequest, isViewApiResponse, isViewApiEvent, type CtxKey } from './types'; | ||
| export type { HostCalls, ViewApiResponse, ViewApiError } from './types'; | ||
| export type { ActionDelegate, StateReducer, WebviewKey } from './types/ipcReducer'; | ||
| export type { WebviewLayout } from './types'; | ||
| export { isViewApiRequest } from './types'; | ||
| export type { ViewApiResponse, ViewApiError, ILogger } from './types'; | ||
| export type { ActionDelegate } from './types/reducer'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,15 @@ | ||
| import * as vscode from 'vscode'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainCI failing: add ‘vscode’ as a dependency and externalize for bundling The build reports “Missing dependencies: 'vscode'…”. Add vscode as a devDependency (and optionally peerDependency) and ensure bundlers mark it external. Minimal package.json patch: {
"name": "react-vscode-webview-ipc",
"version": "…",
+ "peerDependencies": {
+ "vscode": "*"
+ },
"devDependencies": {
+ "vscode": "*"
}
}Also configure your bundler (tsup/rollup/esbuild) to externalize "vscode" (e.g., tsup: { external: ['vscode'] }). 🏁 Script executed: #!/bin/bash
# Verify presence and usage
rg -n "from 'vscode'" -g 'src/**'
jq '.peerDependencies, .devDependencies' package.jsonLength of output: 1415 CI failing — add 'vscode' dev/peer dependency and externalize in bundler Build reports "Missing dependencies: 'vscode'". Add "vscode" to package.json (devDependency and peerDependency) and mark it external in your bundler. Affected files importing vscode: src/lib/host/logger.ts, src/lib/host/WebviewApiProvider.ts, src/lib/host/BaseWebviewViewProvider.ts. Minimal package.json patch: {
"name": "react-vscode-webview-ipc",
"version": "…",
+ "peerDependencies": {
+ "vscode": "*"
+ },
"devDependencies": {
+ "vscode": "*"
}
}Also configure your bundler (tsup/rollup/esbuild) to externalize "vscode" (e.g., tsup: { external: ['vscode'] }).
🧰 Tools🪛 GitHub Actions: CI[error] 1-1: Missing dependencies: 'vscode' required by ./src/lib/host/BaseWebviewViewProvider.ts. |
||
| import type { HostCalls } from '../types'; | ||
| import { type HostCalls, type ILogger, isLogMessage, LogLevel, type LogMessage } from '../types'; | ||
| import { | ||
| isMyActionMessage, | ||
| PATCH, | ||
| type ActionDelegate, | ||
| type FnKeys, | ||
| type Patch, | ||
| type Patches, | ||
| type WebviewKey, | ||
| } from '../types/ipcReducer'; | ||
| import { LogLevel, type ILogger } from './ILogger'; | ||
| } from '../types/reducer'; | ||
| import { getLogger } from './logger'; | ||
| import { isLogMessage, type LogMessage } from './WebviewLogger'; | ||
| import { isMyActionMessage } from './utils'; | ||
| import type { WebviewApiProvider } from './WebviewApiProvider'; | ||
|
|
||
| export abstract class BaseWebviewViewProvider<A extends object> | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { ACT, type Action, type WebviewKey } from '../types/reducer'; | ||
|
|
||
| export function isMyActionMessage<T extends object>( | ||
| message: unknown, | ||
| providerId: WebviewKey | ||
| ): message is Action<T> { | ||
| return ( | ||
| message !== null && | ||
| message !== undefined && | ||
| typeof message === 'object' && | ||
| 'providerId' in message && | ||
| 'type' in message && | ||
| 'key' in message && | ||
| 'params' in message && | ||
| message.type === ACT && | ||
| typeof message.providerId === 'string' && | ||
| message.providerId === providerId && | ||
| (typeof message.key === 'string' || typeof message.key === 'symbol') && | ||
| Array.isArray(message.params) | ||
| ); | ||
| } | ||
|
hbmartin marked this conversation as resolved.
hbmartin marked this conversation as resolved.
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export * from './log'; | ||
| export * from './rpc'; | ||
|
|
||
| export type Brand<T, B> = T & { readonly __brand: B }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * Interface for logging services that can be implemented | ||
| * by both the extension host (Logger) and webview (WebviewLogger) | ||
| */ | ||
|
|
||
| export interface ILogger { | ||
| debug(message: string, data?: Record<string, unknown>): void; | ||
| info(message: string, data?: Record<string, unknown>): void; | ||
| warn(message: string, data?: Record<string, unknown>): void; | ||
| error(message: string, data?: Record<string, unknown>): void; | ||
| dispose(): void; | ||
| } | ||
|
|
||
| export enum LogLevel { | ||
| DEBUG, | ||
| INFO, | ||
| WARN, | ||
| ERROR, | ||
| } | ||
|
|
||
| export interface LogMessage { | ||
| type: 'log'; | ||
| level: LogLevel; | ||
| message: string; | ||
| data?: Record<string, unknown>; | ||
| } | ||
|
|
||
| export function isLogMessage(value: unknown): value is LogMessage { | ||
| if (value === null || typeof value !== 'object' || Array.isArray(value)) { | ||
| return false; | ||
| } | ||
| if (!('type' in value) || value.type !== 'log') { | ||
| return false; | ||
| } | ||
| if (!('level' in value) || typeof value.level !== 'number') { | ||
| return false; | ||
| } | ||
| if (!('message' in value) || typeof value.message !== 'string') { | ||
| return false; | ||
| } | ||
| return true; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.