@kubohiroya/turbowarp-plus-editor-git 0.13.0 → 0.13.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.ja.md CHANGED
@@ -18,7 +18,7 @@ Node.js 26 で `npm ci` と `npm test` を実行します。Vite でライブラ
18
18
 
19
19
  `test/smart-http-fixture.js` は、`git-http-backend` を IPv4 のループバックで動かす検証用のフィクスチャです。Node.js の標準モジュールだけを使い、利用側のブラウザーテストが同じ版を使えるよう配布物に含めます。
20
20
 
21
- `@kubohiroya/turbowarp-plus-editor-git/smart-http` の `createGitSmartHttp` に、Git 設定から選んだ GitHub の HTTPS リモート、信頼済みの接続先(`mode` と `proxyOrigin`)、現在のプロキシセッションか `null` を返す関数を渡します。auth パッケージの `GitAuthProvider` を使えます。Git パッケージは必要なセッションの型だけを構造的に参照するため、読み取り専用パネルとアダプターは auth パッケージと独立してインストールできます。
21
+ `@kubohiroya/turbowarp-plus-editor-git/smart-http` の `createGitSmartHttp` に、Git 設定から選んだ GitHub の HTTPS リモート、信頼済みの接続先(`mode` と `proxyOrigin`)、現在のプロキシセッションか `null` を返す関数を渡します。auth パッケージの `GitAuthProvider` を使えます。Git パッケージはこれらの型を auth パッケージから取り込みます。auth は省略可能な peer で、型を使う TypeScript の利用者だけがインストールすれば足ります。読み取り専用パネルとアダプターは auth パッケージが無くても動きます。
22
22
 
23
23
  ```ts
24
24
  const transport = createGitSmartHttp({
package/README.md CHANGED
@@ -18,7 +18,7 @@ The panel structure and local Git approach were informed by [duff](https://githu
18
18
 
19
19
  `test/smart-http-fixture.js` runs `git-http-backend` on the IPv4 loopback for tests. It uses only Node.js built-in modules and ships in the package so browser tests of a host use the fixture of the same version.
20
20
 
21
- Import `createGitSmartHttp` from `@kubohiroya/turbowarp-plus-editor-git/smart-http`. Pass the selected GitHub HTTPS remote from Git config, a trusted connection (`mode` and `proxyOrigin`), and a function that returns the current proxy session or `null`. A `GitAuthProvider` from the auth package satisfies this contract. The Git package uses the session fields structurally, so the read-only panel and the adapter can be installed independently of the auth package.
21
+ Import `createGitSmartHttp` from `@kubohiroya/turbowarp-plus-editor-git/smart-http`. Pass the selected GitHub HTTPS remote from Git config, a trusted connection (`mode` and `proxyOrigin`), and a function that returns the current proxy session or `null`. A `GitAuthProvider` from the auth package satisfies this contract. The Git package takes these types from the auth package, which is an optional peer: only TypeScript users need it installed, and the read-only panel and the adapter run without it.
22
22
 
23
23
  ```ts
24
24
  const transport = createGitSmartHttp({
@@ -1,18 +1,11 @@
1
1
  import React from 'react';
2
+ import type { GitAuthState, GitConnectionMode as Mode } from '@kubohiroya/turbowarp-plus-editor-auth';
2
3
  import type { GetRemoteSession, RemoteOperation } from './remote-operations.js';
3
- type Mode = 'desktop' | 'cloudflare';
4
- type Status = 'disconnected' | 'connecting' | 'connected' | 'reauth-required';
5
4
  export interface GitConnectionSettings {
6
5
  modes: readonly Mode[];
7
6
  getView(): {
8
7
  mode: Mode | null;
9
- state: {
10
- status: Status;
11
- account?: {
12
- login: string;
13
- };
14
- expiresAt?: number;
15
- };
8
+ state: GitAuthState;
16
9
  proxyOrigin?: string;
17
10
  write?: boolean;
18
11
  authorization?: {
@@ -32,4 +25,3 @@ export declare function ConnectionSettings({ settings, locale, readOrigin, runOp
32
25
  readOrigin?: () => Promise<string | undefined>;
33
26
  runOperation?: (operation: RemoteOperation) => Promise<void>;
34
27
  }): React.JSX.Element;
35
- export {};
package/dist/index.js CHANGED
@@ -3277,7 +3277,7 @@ function ConnectionSettings({ settings, locale, readOrigin, runOperation }) {
3277
3277
  }, labels[choice])))), /* @__PURE__ */ React.createElement("p", null, labels.changed), /* @__PURE__ */ React.createElement("p", {
3278
3278
  "data-git-connection-state": "",
3279
3279
  role: "status"
3280
- }, labels[state.status]), proxyOrigin && /* @__PURE__ */ React.createElement("p", null, labels.proxy, " · ", /* @__PURE__ */ React.createElement("code", null, proxyOrigin)), state.account && /* @__PURE__ */ React.createElement("p", null, labels.account, " · ", state.account.login), !readOrigin && /* @__PURE__ */ React.createElement("p", null, labels.noRemote), mode && /* @__PURE__ */ React.createElement(React.Fragment, null, runOperation && /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("input", {
3280
+ }, labels[state.status]), proxyOrigin && /* @__PURE__ */ React.createElement("p", null, labels.proxy, " · ", /* @__PURE__ */ React.createElement("code", null, proxyOrigin)), state.status === "connected" && /* @__PURE__ */ React.createElement("p", null, labels.account, " · ", state.account.login), !readOrigin && /* @__PURE__ */ React.createElement("p", null, labels.noRemote), mode && /* @__PURE__ */ React.createElement(React.Fragment, null, runOperation && /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("input", {
3281
3281
  type: "checkbox",
3282
3282
  checked: allowPush,
3283
3283
  disabled: busy || state.status === "connecting" || state.status === "connected",
@@ -1,17 +1,9 @@
1
+ import type { GitProxyConnection, GitProxySession } from '@kubohiroya/turbowarp-plus-editor-auth';
1
2
  export declare const MAX_GIT_REQUEST_BYTES: number;
2
- type Connection = Readonly<{
3
- mode: 'desktop' | 'cloudflare';
4
- proxyOrigin: string;
5
- }>;
6
- type Session = Readonly<{
7
- connection: Connection;
8
- bearer: string;
9
- expiresAt: number;
10
- }>;
11
3
  export interface GitSmartHttpOptions {
12
4
  readonly remote: string;
13
- readonly connection: Connection;
14
- readonly getSession: () => Promise<Session | null>;
5
+ readonly connection: GitProxyConnection;
6
+ readonly getSession: () => Promise<GitProxySession | null>;
15
7
  readonly maxRequestBytes?: number;
16
8
  readonly signal?: AbortSignal;
17
9
  readonly fetch?: typeof fetch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-plus-editor-git",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Read-only local Git panel for TurboWarp Plus Editor",
5
5
  "type": "module",
6
6
  "license": "MPL-2.0",
@@ -49,10 +49,17 @@
49
49
  "prepack": "npm run build"
50
50
  },
51
51
  "peerDependencies": {
52
+ "@kubohiroya/turbowarp-plus-editor-auth": ">=0.3.0 <0.4.0",
52
53
  "react": ">=16.14 <19",
53
54
  "react-dom": ">=16.14 <19"
54
55
  },
56
+ "peerDependenciesMeta": {
57
+ "@kubohiroya/turbowarp-plus-editor-auth": {
58
+ "optional": true
59
+ }
60
+ },
55
61
  "devDependencies": {
62
+ "@kubohiroya/turbowarp-plus-editor-auth": "0.3.0",
56
63
  "@types/node": "24.19.2",
57
64
  "@types/react": "16.14.70",
58
65
  "@types/react-dom": "16.9.25",
@@ -1,13 +1,12 @@
1
1
  import React, {useEffect, useRef, useState} from 'react';
2
+ import type {GitAuthState, GitConnectionMode as Mode} from '@kubohiroya/turbowarp-plus-editor-auth';
2
3
  import type {GetRemoteSession, RemoteOperation} from './remote-operations.js';
3
4
 
4
- type Mode = 'desktop' | 'cloudflare';
5
- type Status = 'disconnected' | 'connecting' | 'connected' | 'reauth-required';
6
5
  export interface GitConnectionSettings {
7
6
  modes: readonly Mode[];
8
7
  getView(): {
9
8
  mode: Mode | null;
10
- state: {status: Status; account?: {login: string}; expiresAt?: number};
9
+ state: GitAuthState;
11
10
  proxyOrigin?: string;
12
11
  write?: boolean;
13
12
  authorization?: {url: string; userCode?: string};
@@ -87,7 +86,7 @@ export function ConnectionSettings({settings, locale, readOrigin, runOperation}:
87
86
  <p>{labels.changed}</p>
88
87
  <p data-git-connection-state="" role="status">{labels[state.status]}</p>
89
88
  {proxyOrigin && <p>{labels.proxy} · <code>{proxyOrigin}</code></p>}
90
- {state.account && <p>{labels.account} · {state.account.login}</p>}
89
+ {state.status === 'connected' && <p>{labels.account} · {state.account.login}</p>}
91
90
  {!readOrigin && <p>{labels.noRemote}</p>}
92
91
  {mode && <>
93
92
  {runOperation && <label><input type="checkbox" checked={allowPush}
package/src/smart-http.ts CHANGED
@@ -1,14 +1,12 @@
1
+ import type {GitProxyConnection, GitProxySession} from '@kubohiroya/turbowarp-plus-editor-auth';
1
2
  import type {HttpClient} from 'isomorphic-git';
2
3
 
3
4
  export const MAX_GIT_REQUEST_BYTES = 32 * 1024 * 1024;
4
5
 
5
- type Connection = Readonly<{mode: 'desktop' | 'cloudflare'; proxyOrigin: string}>;
6
- type Session = Readonly<{connection: Connection; bearer: string; expiresAt: number}>;
7
-
8
6
  export interface GitSmartHttpOptions {
9
7
  readonly remote: string;
10
- readonly connection: Connection;
11
- readonly getSession: () => Promise<Session | null>;
8
+ readonly connection: GitProxyConnection;
9
+ readonly getSession: () => Promise<GitProxySession | null>;
12
10
  readonly maxRequestBytes?: number;
13
11
  readonly signal?: AbortSignal;
14
12
  readonly fetch?: typeof fetch;
@@ -54,7 +52,7 @@ function remoteUrl(remote: string) {
54
52
  return `https://github.com/${match[1]}/${match[2]}.git`;
55
53
  }
56
54
 
57
- function checkConnection({mode, proxyOrigin}: Connection) {
55
+ function checkConnection({mode, proxyOrigin}: GitProxyConnection) {
58
56
  const url = URL.parse(proxyOrigin);
59
57
  if (!url || url.origin !== proxyOrigin ||
60
58
  (mode === 'desktop' ? !/^http:\/\/127\.0\.0\.1:[1-9][0-9]{0,4}$/u.test(proxyOrigin) :
@@ -142,7 +140,7 @@ export function createGitSmartHttp(options: GitSmartHttpOptions) {
142
140
  checkAbort(abort);
143
141
  const payload = body ? await boundedBody(body, maxRequestBytes, abort) : undefined;
144
142
  checkAbort(abort);
145
- let session: Session | null;
143
+ let session: GitProxySession | null;
146
144
  try {
147
145
  session = await getSession();
148
146
  } catch {