@kubohiroya/turbowarp-http-server 0.1.0 → 0.2.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 +29 -13
- package/README.md +101 -42
- package/dist/cli.js +131 -17
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapters/cloudflare.d.ts +2 -0
- package/dist/compiler/adapters/cloudflare.js +477 -0
- package/dist/compiler/adapters/cloudflare.js.map +1 -0
- package/dist/compiler/adapters/firebase.d.ts +2 -0
- package/dist/compiler/adapters/firebase.js +489 -0
- package/dist/compiler/adapters/firebase.js.map +1 -0
- package/dist/compiler/adapters/index.d.ts +2 -0
- package/dist/compiler/adapters/index.js +3 -0
- package/dist/compiler/adapters/index.js.map +1 -0
- package/dist/compiler/binary/codec.d.ts +4 -0
- package/dist/compiler/binary/codec.js +45 -0
- package/dist/compiler/binary/codec.js.map +1 -0
- package/dist/compiler/binary/error.d.ts +3 -0
- package/dist/compiler/binary/error.js +21 -0
- package/dist/compiler/binary/error.js.map +1 -0
- package/dist/compiler/binary/index.d.ts +4 -0
- package/dist/compiler/binary/index.js +5 -0
- package/dist/compiler/binary/index.js.map +1 -0
- package/dist/compiler/binary/runtime.d.ts +18 -0
- package/dist/compiler/binary/runtime.js +123 -0
- package/dist/compiler/binary/runtime.js.map +1 -0
- package/dist/compiler/binary/types.d.ts +17 -0
- package/dist/compiler/binary/types.js +2 -0
- package/dist/compiler/binary/types.js.map +1 -0
- package/dist/compiler/feature-flags.d.ts +4 -0
- package/dist/compiler/feature-flags.js +4 -0
- package/dist/compiler/feature-flags.js.map +1 -0
- package/dist/compiler/index.d.ts +35 -0
- package/dist/compiler/index.js +84 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/ir-v2/canonical.d.ts +3 -0
- package/dist/compiler/ir-v2/canonical.js +50 -0
- package/dist/compiler/ir-v2/canonical.js.map +1 -0
- package/dist/compiler/ir-v2/index.d.ts +4 -0
- package/dist/compiler/ir-v2/index.js +5 -0
- package/dist/compiler/ir-v2/index.js.map +1 -0
- package/dist/compiler/ir-v2/parse.d.ts +10 -0
- package/dist/compiler/ir-v2/parse.js +753 -0
- package/dist/compiler/ir-v2/parse.js.map +1 -0
- package/dist/compiler/ir-v2/strict-json.d.ts +4 -0
- package/dist/compiler/ir-v2/strict-json.js +133 -0
- package/dist/compiler/ir-v2/strict-json.js.map +1 -0
- package/dist/compiler/ir-v2/types.d.ts +412 -0
- package/dist/compiler/ir-v2/types.js +84 -0
- package/dist/compiler/ir-v2/types.js.map +1 -0
- package/dist/compiler/kvs/lowering.d.ts +13 -0
- package/dist/compiler/kvs/lowering.js +77 -0
- package/dist/compiler/kvs/lowering.js.map +1 -0
- package/dist/compiler/manifest/error.d.ts +7 -0
- package/dist/compiler/manifest/error.js +9 -0
- package/dist/compiler/manifest/error.js.map +1 -0
- package/dist/compiler/manifest/index.d.ts +6 -0
- package/dist/compiler/manifest/index.js +7 -0
- package/dist/compiler/manifest/index.js.map +1 -0
- package/dist/compiler/manifest/operations.d.ts +12 -0
- package/dist/compiler/manifest/operations.js +60 -0
- package/dist/compiler/manifest/operations.js.map +1 -0
- package/dist/compiler/manifest/parse.d.ts +9 -0
- package/dist/compiler/manifest/parse.js +280 -0
- package/dist/compiler/manifest/parse.js.map +1 -0
- package/dist/compiler/manifest/registry.d.ts +3 -0
- package/dist/compiler/manifest/registry.js +48 -0
- package/dist/compiler/manifest/registry.js.map +1 -0
- package/dist/compiler/manifest/resolve.d.ts +14 -0
- package/dist/compiler/manifest/resolve.js +116 -0
- package/dist/compiler/manifest/resolve.js.map +1 -0
- package/dist/compiler/manifest/types.d.ts +95 -0
- package/dist/compiler/manifest/types.js +3 -0
- package/dist/compiler/manifest/types.js.map +1 -0
- package/dist/compiler/named-body/index.d.ts +1 -0
- package/dist/compiler/named-body/index.js +2 -0
- package/dist/compiler/named-body/index.js.map +1 -0
- package/dist/compiler/named-body/lowering.d.ts +18 -0
- package/dist/compiler/named-body/lowering.js +83 -0
- package/dist/compiler/named-body/lowering.js.map +1 -0
- package/dist/compiler/pipeline/compiler.d.ts +18 -0
- package/dist/compiler/pipeline/compiler.js +105 -0
- package/dist/compiler/pipeline/compiler.js.map +1 -0
- package/dist/compiler/pipeline/core-generator.d.ts +3 -0
- package/dist/compiler/pipeline/core-generator.js +483 -0
- package/dist/compiler/pipeline/core-generator.js.map +1 -0
- package/dist/compiler/pipeline/index.d.ts +5 -0
- package/dist/compiler/pipeline/index.js +6 -0
- package/dist/compiler/pipeline/index.js.map +1 -0
- package/dist/compiler/pipeline/registry.d.ts +7 -0
- package/dist/compiler/pipeline/registry.js +17 -0
- package/dist/compiler/pipeline/registry.js.map +1 -0
- package/dist/compiler/pipeline/requirements.d.ts +9 -0
- package/dist/compiler/pipeline/requirements.js +135 -0
- package/dist/compiler/pipeline/requirements.js.map +1 -0
- package/dist/compiler/pipeline/types.d.ts +65 -0
- package/dist/compiler/pipeline/types.js +2 -0
- package/dist/compiler/pipeline/types.js.map +1 -0
- package/dist/compiler/runtime/error.d.ts +6 -0
- package/dist/compiler/runtime/error.js +9 -0
- package/dist/compiler/runtime/error.js.map +1 -0
- package/dist/compiler/runtime/index.d.ts +1 -0
- package/dist/compiler/runtime/index.js +2 -0
- package/dist/compiler/runtime/index.js.map +1 -0
- package/dist/compiler/structured-data/index.d.ts +3 -0
- package/dist/compiler/structured-data/index.js +4 -0
- package/dist/compiler/structured-data/index.js.map +1 -0
- package/dist/compiler/structured-data/lowering.d.ts +30 -0
- package/dist/compiler/structured-data/lowering.js +202 -0
- package/dist/compiler/structured-data/lowering.js.map +1 -0
- package/dist/compiler/structured-data/path.d.ts +2 -0
- package/dist/compiler/structured-data/path.js +60 -0
- package/dist/compiler/structured-data/path.js.map +1 -0
- package/dist/compiler/structured-data/runtime.d.ts +20 -0
- package/dist/compiler/structured-data/runtime.js +210 -0
- package/dist/compiler/structured-data/runtime.js.map +1 -0
- package/dist/compiler/turbowarp-v2.d.ts +8 -0
- package/dist/compiler/turbowarp-v2.js +479 -0
- package/dist/compiler/turbowarp-v2.js.map +1 -0
- package/dist/compiler/validator/index.d.ts +4 -0
- package/dist/compiler/validator/index.js +5 -0
- package/dist/compiler/validator/index.js.map +1 -0
- package/dist/compiler/validator/ir-validator.d.ts +10 -0
- package/dist/compiler/validator/ir-validator.js +463 -0
- package/dist/compiler/validator/ir-validator.js.map +1 -0
- package/dist/compiler/validator/resource-lifetime.d.ts +18 -0
- package/dist/compiler/validator/resource-lifetime.js +106 -0
- package/dist/compiler/validator/resource-lifetime.js.map +1 -0
- package/dist/compiler/validator/turbowarp-subset.d.ts +3 -0
- package/dist/compiler/validator/turbowarp-subset.js +241 -0
- package/dist/compiler/validator/turbowarp-subset.js.map +1 -0
- package/dist/compiler/validator/types.d.ts +30 -0
- package/dist/compiler/validator/types.js +7 -0
- package/dist/compiler/validator/types.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -0
- package/dist/digest-cli.js +0 -0
- package/dist/extension-manifest.json +102 -0
- package/dist/named-body.d.ts +57 -0
- package/dist/named-body.js +396 -0
- package/dist/named-body.js.map +1 -0
- package/dist/named-data-namespace.d.ts +3 -0
- package/dist/named-data-namespace.js +6 -0
- package/dist/named-data-namespace.js.map +1 -0
- package/dist/protocol.d.ts +13 -1
- package/dist/protocol.js +34 -0
- package/dist/protocol.js.map +1 -1
- package/dist/resource-named-body-provider.d.ts +8 -0
- package/dist/resource-named-body-provider.js +88 -0
- package/dist/resource-named-body-provider.js.map +1 -0
- package/dist/server.d.ts +10 -1
- package/dist/server.js +37 -7
- package/dist/server.js.map +1 -1
- package/dist/turbowarp-http-server.js +516 -1
- package/docs/binary-resource-semantics.ja.md +84 -0
- package/docs/cloudflare-worker-compiler.ja.md +90 -0
- package/docs/compiler-manifest-registry.ja.md +79 -0
- package/docs/compiler-platform-pipeline.ja.md +94 -0
- package/docs/deploy-ir-v2.ja.md +123 -0
- package/docs/fixed-input-editors.ja.md +23 -0
- package/docs/index.html +80 -0
- package/docs/ir-v2-conformance.ja.md +65 -0
- package/docs/named-response-body.ja.md +120 -0
- package/docs/platform-storage-adapters.ja.md +99 -0
- package/docs/server-executable-subset.ja.md +88 -0
- package/docs/structured-data-lowering.ja.md +63 -0
- package/examples/compiler/message-app.v2.ir.json +41 -0
- package/package.json +44 -20
- package/schemas/block-editor-fixed-inputs.schema.json +85 -0
- package/schemas/compiler-extension-manifest.schema.json +126 -0
- package/schemas/compiler-manifest-lock-v1.schema.json +48 -0
- package/schemas/deploy-ir-v2.schema.json +835 -0
- package/schemas/ir-v2-conformance-fixture.schema.json +44 -0
- package/src/block-definitions.json +76 -0
- package/src/cli.ts +136 -23
- package/src/compiler/adapters/cloudflare.ts +510 -0
- package/src/compiler/adapters/firebase.ts +538 -0
- package/src/compiler/adapters/index.ts +2 -0
- package/src/compiler/binary/codec.ts +61 -0
- package/src/compiler/binary/error.ts +25 -0
- package/src/compiler/binary/index.ts +4 -0
- package/src/compiler/binary/runtime.ts +133 -0
- package/src/compiler/binary/types.ts +26 -0
- package/src/compiler/feature-flags.ts +7 -0
- package/src/compiler/index.ts +114 -0
- package/src/compiler/ir-v2/canonical.ts +46 -0
- package/src/compiler/ir-v2/index.ts +9 -0
- package/src/compiler/ir-v2/parse.ts +921 -0
- package/src/compiler/ir-v2/strict-json.ts +129 -0
- package/src/compiler/ir-v2/types.ts +462 -0
- package/src/compiler/kvs/lowering.ts +88 -0
- package/src/compiler/manifest/error.ts +29 -0
- package/src/compiler/manifest/index.ts +17 -0
- package/src/compiler/manifest/operations.ts +175 -0
- package/src/compiler/manifest/parse.ts +390 -0
- package/src/compiler/manifest/registry.ts +74 -0
- package/src/compiler/manifest/resolve.ts +159 -0
- package/src/compiler/manifest/types.ts +112 -0
- package/src/compiler/named-body/index.ts +1 -0
- package/src/compiler/named-body/lowering.ts +186 -0
- package/src/compiler/pipeline/compiler.ts +138 -0
- package/src/compiler/pipeline/core-generator.ts +486 -0
- package/src/compiler/pipeline/index.ts +5 -0
- package/src/compiler/pipeline/registry.ts +18 -0
- package/src/compiler/pipeline/requirements.ts +139 -0
- package/src/compiler/pipeline/types.ts +59 -0
- package/src/compiler/runtime/error.ts +11 -0
- package/src/compiler/runtime/index.ts +1 -0
- package/src/compiler/structured-data/index.ts +3 -0
- package/src/compiler/structured-data/lowering.ts +314 -0
- package/src/compiler/structured-data/path.ts +53 -0
- package/src/compiler/structured-data/runtime.ts +221 -0
- package/src/compiler/turbowarp-v2.ts +610 -0
- package/src/compiler/validator/index.ts +4 -0
- package/src/compiler/validator/ir-validator.ts +812 -0
- package/src/compiler/validator/resource-lifetime.ts +153 -0
- package/src/compiler/validator/turbowarp-subset.ts +387 -0
- package/src/compiler/validator/types.ts +68 -0
- package/src/extension.ts +87 -1
- package/src/fixed-input-editors.ts +181 -0
- package/src/fixed-input-schema.ts +15 -0
- package/src/named-body.ts +495 -0
- package/src/named-data-namespace.ts +6 -0
- package/src/protocol.ts +50 -1
- package/src/resource-named-body-provider.ts +106 -0
- package/src/server.ts +88 -8
- package/docs/turbowarp-http-server.architecture.visual-check.1440x900.dark.png +0 -0
- package/docs/turbowarp-http-server.architecture.visual-check.1440x900.light.png +0 -0
- package/docs/turbowarp-http-server.architecture.visual-check.2048x1320.dark.png +0 -0
- package/docs/turbowarp-http-server.architecture.visual-check.2048x1320.light.png +0 -0
- package/docs/turbowarp-http-server.architecture.visual-check.html +0 -32
- package/docs/turbowarp-http-server.architecture.visual-check.json +0 -547
- package/schemas/extension-manifest.schema.json +0 -49
- package/src/extension-manifest.ts +0 -149
package/README.ja.md
CHANGED
|
@@ -71,14 +71,14 @@ turbowarp-http-server \
|
|
|
71
71
|
|---|---|
|
|
72
72
|
| `GET /health` | ヘルスチェック |
|
|
73
73
|
| `GET /ws` | TurboWarp extension が接続する WebSocket endpoint |
|
|
74
|
-
| `GET /@assets/<name>` | resource capability が接続されている場合、Asset
|
|
74
|
+
| `GET /@assets/<name>` | resource capability が接続されている場合、Asset Cache の named resource を配信 |
|
|
75
75
|
| `HEAD /@assets/<name>` | body なしで同じ resource metadata を返却 |
|
|
76
76
|
| `PUT /@assets/<name>` | 対応 capability で named resource を作成または atomic replace |
|
|
77
77
|
| `DELETE /@assets/<name>` | 対応 capability で named resource を削除 |
|
|
78
78
|
| `GET /@assets/` | binary payload を含めず metadata/listing を返却 |
|
|
79
79
|
| その他の HTTP route | HTTP forwarding 実装前の一時的な `503 not_connected` 応答 |
|
|
80
80
|
|
|
81
|
-
Sprite route はこれとは別の TurboWarp-facing layer です。`camera` という名前の Sprite は `/camera` を公開でき、Sprite を「隠す」とその route を無効化できます。Sprite handler は HTML、JSON、redirect、`/camera/image.jpg` のような friendly alias を返せますが、`@assets` を Sprite の子 namespace にするのではなく Asset
|
|
81
|
+
Sprite route はこれとは別の TurboWarp-facing layer です。`camera` という名前の Sprite は `/camera` を公開でき、Sprite を「隠す」とその route を無効化できます。Sprite handler は HTML、JSON、redirect、`/camera/image.jpg` のような friendly alias を返せますが、`@assets` を Sprite の子 namespace にするのではなく Asset Cache capability を参照します。
|
|
82
82
|
|
|
83
83
|
### 学習用コミュニティサーバ
|
|
84
84
|
|
|
@@ -121,11 +121,11 @@ COMMUNITY_OAUTH_DEMO_SCOPE=profile
|
|
|
121
121
|
|
|
122
122
|
この community server は local educational implementation であり、公開運用向けではありません。internet に公開する前に、in-memory storage を durable storage に置き換え、rate limit と abuse moderation、HTTPS と secure cookie、完全な OAuth token/userinfo exchange、必要な email または external identity verification、upload scan、audit log、backup、retention、takedown、incident-response 手順を追加してください。
|
|
123
123
|
|
|
124
|
-
## Asset
|
|
124
|
+
## Asset Cache Resource Serving
|
|
125
125
|
|
|
126
|
-
HTTP server は camera-agnostic です。`turbowarp-asset-
|
|
126
|
+
HTTP server は camera-agnostic です。`turbowarp-asset-cache` のような外部 capability が提供する generic named resource を配信し、private field を読んだり Asset Cache の storage を複製したりしません。
|
|
127
127
|
|
|
128
|
-
generic Asset
|
|
128
|
+
generic Asset Cache namespace は `/@assets/` を root にします。これは Sprite route の管理下ではなく、background/server-side resource capability が管理します。Sprite route は friendly alias を提供できますが、generic resource route は global に保ちます。
|
|
129
129
|
|
|
130
130
|
| Resource | HTTP route |
|
|
131
131
|
|---|---|
|
|
@@ -138,7 +138,7 @@ resource response は `Content-Type`、`Content-Length`、可能な場合は `ET
|
|
|
138
138
|
|
|
139
139
|
`PUT` は request body bytes と `Content-Type` を使い、capability 経由で resource を作成または置換します。server は configurable body-size limit を適用し、capability が拒否する MIME type を `415` にし、置換は後続 request へ atomic に見えるようにします。進行中の `GET` は開始時点の snapshot を受け取ります。
|
|
140
140
|
|
|
141
|
-
`/_tw-http/` は management namespace として予約し、asset route として扱いません。`/camera/@assets/live-camera` のような path は generic Asset
|
|
141
|
+
`/_tw-http/` は management namespace として予約し、asset route として扱いません。`/camera/@assets/live-camera` のような path は generic Asset Cache route ではありません。必要なら Scratch/TurboWarp handler で friendly Sprite URL を `/@assets/<name>` へ alias します。authorization hook が設定されている場合は `GET`、`HEAD`、`PUT`、`DELETE`、listing に一貫して適用します。structured log には route、resource name、MIME type、byte count、status などの metadata だけを含め、binary request/response body は含めません。
|
|
142
142
|
|
|
143
143
|
## Sprite Route Model
|
|
144
144
|
|
|
@@ -150,7 +150,7 @@ TurboWarp-facing route は project object と自然に対応させます。
|
|
|
150
150
|
| Sprite `camera` が表示中 | `/camera` |
|
|
151
151
|
| Sprite `camera` が非表示 | route disabled |
|
|
152
152
|
|
|
153
|
-
これにより Scratch 上の操作が HTTP 公開状態と直感的につながります。Sprite を「表示する」と route が公開され、「隠す」と route が取り下げられます。Asset
|
|
153
|
+
これにより Scratch 上の操作が HTTP 公開状態と直感的につながります。Sprite を「表示する」と route が公開され、「隠す」と route が取り下げられます。Asset Cache resource は `/@assets/<name>` に global に置くため、同じ resource を複数の Sprite route から storage duplication なしに再利用できます。
|
|
154
154
|
|
|
155
155
|
live camera page は次のように扱えます。
|
|
156
156
|
|
|
@@ -166,7 +166,7 @@ GET /camera/image.jpg
|
|
|
166
166
|
-> /@assets/live-camera を返す friendly handler/alias
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
つまり `/camera/image.jpg` は Sprite route の判断で、`/@assets/live-camera` は generic Asset
|
|
169
|
+
つまり `/camera/image.jpg` は Sprite route の判断で、`/@assets/live-camera` は generic Asset Cache resource endpoint です。
|
|
170
170
|
|
|
171
171
|
## デプロイターゲット検討
|
|
172
172
|
|
|
@@ -236,6 +236,20 @@ current request ID
|
|
|
236
236
|
|
|
237
237
|
simple query/header reporter は最初の値を返します。wire protocol は全値を保持するため、将来 list-oriented block を追加しても protocol を壊さずに済みます。
|
|
238
238
|
|
|
239
|
+
server へ compile 可能な一時値には、通常の Scratch 変数ではなく handler variable を使います。値は request ID ごとに分離され、response 完了時に破棄されます。
|
|
240
|
+
|
|
241
|
+
```text
|
|
242
|
+
set handler variable [name] to [value]
|
|
243
|
+
change handler variable [name] by [amount]
|
|
244
|
+
handler variable [name]
|
|
245
|
+
handler variable [name] exists?
|
|
246
|
+
delete handler variable [name]
|
|
247
|
+
delete all handler variables
|
|
248
|
+
active handler variables
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
これは TurboWarp Temporary Variables の thread variable に対応する request-local な機能です。request をまたいで残す値には D1 等の永続 storage を使います。通常の variable/list、broadcast、`forever` は Cloudflare Worker 用 compiler の MVP では受理しません。詳しい置換規則と compile command は [TurboWarp → Cloudflare Workers/Hono コンパイラ設計](docs/cloudflare-worker-compiler.ja.md) を参照してください。
|
|
252
|
+
|
|
239
253
|
response blocks は current request の response builder を変更し、最後に response message として完了します。
|
|
240
254
|
|
|
241
255
|
```text
|
|
@@ -260,12 +274,12 @@ bridge が未接続の場合、通常 route は `503` を返します。connecte
|
|
|
260
274
|
```text
|
|
261
275
|
TurboWarp Camera Source
|
|
262
276
|
-> 10 秒ごとに current frame を capture
|
|
263
|
-
-> Asset
|
|
277
|
+
-> Asset Cache resource "live-camera" を replace
|
|
264
278
|
-> HTTP Server が /@assets/live-camera を配信
|
|
265
279
|
-> browser が stable URL を読み込む
|
|
266
280
|
```
|
|
267
281
|
|
|
268
|
-
HTTP server は `turbowarp-camera-source` や `turbowarp-html` に依存しません。Camera Source は snapshot を作り、Asset
|
|
282
|
+
HTTP server は `turbowarp-camera-source` や `turbowarp-html` に依存しません。Camera Source は snapshot を作り、Asset Cache が named resource を所有し、HTTP Server は generic resource URL を配信します。
|
|
269
283
|
|
|
270
284
|
ブロックレベルの例:
|
|
271
285
|
|
|
@@ -289,7 +303,7 @@ end
|
|
|
289
303
|
/camera/image.jpg -> /@assets/live-camera
|
|
290
304
|
```
|
|
291
305
|
|
|
292
|
-
`turbowarp-html` で生成した HTML page が `<img>` を 10 秒ごとに refresh する構成でも、cache correctness は timestamp query string ではなく HTTP validation headers で担保します。Asset
|
|
306
|
+
`turbowarp-html` で生成した HTML page が `<img>` を 10 秒ごとに refresh する構成でも、cache correctness は timestamp query string ではなく HTTP validation headers で担保します。Asset Cache から replacement identity が得られる場合、client は stable URL を ETag で revalidate し、古い browser cache に固定されず最新 snapshot を受け取れます。
|
|
293
307
|
|
|
294
308
|
### TurboWarp extension bundle
|
|
295
309
|
|
|
@@ -304,7 +318,7 @@ end
|
|
|
304
318
|
レビューした exact version をインストールします。
|
|
305
319
|
|
|
306
320
|
```bash
|
|
307
|
-
pnpm add --save-exact @kubohiroya/turbowarp-http-server@0.1
|
|
321
|
+
pnpm add --save-exact @kubohiroya/turbowarp-http-server@0.2.1
|
|
308
322
|
```
|
|
309
323
|
|
|
310
324
|
standalone bundle は次の場所から読み込めます。
|
|
@@ -316,7 +330,7 @@ node_modules/@kubohiroya/turbowarp-http-server/dist/turbowarp-http-server.js
|
|
|
316
330
|
version 固定の CDN URL は次の形式です。
|
|
317
331
|
|
|
318
332
|
```text
|
|
319
|
-
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-http-server@0.1
|
|
333
|
+
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-http-server@0.2.1/dist/turbowarp-http-server.js
|
|
320
334
|
```
|
|
321
335
|
|
|
322
336
|
## 開発
|
|
@@ -344,3 +358,5 @@ pnpm check
|
|
|
344
358
|
## ライセンス
|
|
345
359
|
|
|
346
360
|
[Mozilla Public License 2.0](LICENSE) (SPDX: `MPL-2.0`)。
|
|
361
|
+
|
|
362
|
+
固定入力の編集範囲・互換性・切戻しについては [固定入力の編集](docs/fixed-input-editors.ja.md) を参照してください。
|
package/README.md
CHANGED
|
@@ -36,49 +36,20 @@ From an installed package:
|
|
|
36
36
|
turbowarp-http-server --host 127.0.0.1 --port 8787
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
For an offline venue LAN, enable HTTP Digest authentication with an htdigest file:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
turbowarp-http-digest init ./users.htdigest --realm turbowarp-lan
|
|
43
|
-
turbowarp-http-digest add ./users.htdigest alice --realm turbowarp-lan
|
|
44
|
-
|
|
45
|
-
turbowarp-http-server \
|
|
46
|
-
--host 0.0.0.0 \
|
|
47
|
-
--port 8787 \
|
|
48
|
-
--auth-digest ./users.htdigest \
|
|
49
|
-
--auth-realm turbowarp-lan
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Digest authentication is intended for simple user identification on a trusted LAN where certificates and external identity providers are not available. It is disabled by default. The authenticated username is forwarded to TurboWarp handlers as the runtime-owned `x-turbowarp-http-auth-user` request header; an incoming client-supplied header with the same name is overwritten. The `/ws` endpoint is only accepted from localhost peers.
|
|
53
|
-
|
|
54
|
-
TurboWarp handlers can read authentication context with reporter blocks: `current auth type`, `current authenticated user`, `current auth provider`, `current auth profile JSON`, and `auth profile field [NAME]`. Digest authentication provides the username. OAuth-capable deployments can forward provider profile data as request auth context, and handlers can read fields such as `email`, `name`, or dotted paths like `organization.name`.
|
|
55
|
-
|
|
56
|
-
If a certificate and private key are already available, the server can run HTTPS directly:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
turbowarp-http-server \
|
|
60
|
-
--host 0.0.0.0 \
|
|
61
|
-
--port 8787 \
|
|
62
|
-
--tls-cert ./certs/server.crt \
|
|
63
|
-
--tls-key ./certs/server.key
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Certificate issuance, renewal, distribution, and OS/browser trust configuration are outside this package. For Internet-facing deployments, terminate TLS at a reverse proxy and use the Cloudflare/OAuth deployment path for authentication.
|
|
67
|
-
|
|
68
39
|
The server exposes:
|
|
69
40
|
|
|
70
41
|
| Route | Purpose |
|
|
71
42
|
|---|---|
|
|
72
43
|
| `GET /health` | Health check |
|
|
73
44
|
| `GET /ws` | WebSocket endpoint used by the TurboWarp extension |
|
|
74
|
-
| `GET /@assets/<name>` | Serve a named Asset
|
|
45
|
+
| `GET /@assets/<name>` | Serve a named Asset Cache resource when a resource capability is attached |
|
|
75
46
|
| `HEAD /@assets/<name>` | Return the same resource metadata without a body |
|
|
76
47
|
| `PUT /@assets/<name>` | Create or atomically replace a named resource when supported |
|
|
77
48
|
| `DELETE /@assets/<name>` | Remove a named resource when supported |
|
|
78
49
|
| `GET /@assets/` | Return resource metadata without embedding binary payloads when supported |
|
|
79
50
|
| Any other HTTP route | Temporary `503 not_connected` placeholder until HTTP forwarding is implemented |
|
|
80
51
|
|
|
81
|
-
Sprite routes are a separate TurboWarp-facing layer. A Sprite named `camera` can publish `/camera`, and hiding that Sprite can disable the route. Those Sprite handlers may serve HTML, JSON, redirects, or friendly aliases such as `/camera/image.jpg`; they should call into the Asset
|
|
52
|
+
Sprite routes are a separate TurboWarp-facing layer. A Sprite named `camera` can publish `/camera`, and hiding that Sprite can disable the route. Those Sprite handlers may serve HTML, JSON, redirects, or friendly aliases such as `/camera/image.jpg`; they should call into the Asset Cache capability instead of making `@assets` a child namespace of the Sprite.
|
|
82
53
|
|
|
83
54
|
### Learning-only community server
|
|
84
55
|
|
|
@@ -134,7 +105,7 @@ The reviewed JavaScript build is committed to this repository, so users do not n
|
|
|
134
105
|
Install an exact version that you have reviewed:
|
|
135
106
|
|
|
136
107
|
```bash
|
|
137
|
-
pnpm add --save-exact @kubohiroya/turbowarp-http-server@0.1
|
|
108
|
+
pnpm add --save-exact @kubohiroya/turbowarp-http-server@0.2.1
|
|
138
109
|
```
|
|
139
110
|
|
|
140
111
|
Load the standalone bundle from:
|
|
@@ -146,7 +117,7 @@ node_modules/@kubohiroya/turbowarp-http-server/dist/turbowarp-http-server.js
|
|
|
146
117
|
A version-pinned CDN URL is:
|
|
147
118
|
|
|
148
119
|
```text
|
|
149
|
-
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-http-server@0.1
|
|
120
|
+
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-http-server@0.2.1/dist/turbowarp-http-server.js
|
|
150
121
|
```
|
|
151
122
|
|
|
152
123
|
## Quick start
|
|
@@ -162,11 +133,11 @@ send [{"type":"ping"}] to HTTP bridge
|
|
|
162
133
|
last HTTP bridge message
|
|
163
134
|
```
|
|
164
135
|
|
|
165
|
-
## Asset
|
|
136
|
+
## Asset Cache Resource Serving
|
|
166
137
|
|
|
167
|
-
The HTTP server is camera-agnostic. It serves generic named resources supplied by an external capability, such as `turbowarp-asset-
|
|
138
|
+
The HTTP server is camera-agnostic. It serves generic named resources supplied by an external capability, such as `turbowarp-asset-cache`, without reading private extension fields or duplicating Asset Cache storage.
|
|
168
139
|
|
|
169
|
-
The generic Asset
|
|
140
|
+
The generic Asset Cache namespace is rooted at `/@assets/`. It is not owned by a Sprite route; it is managed by the background/server-side resource capability. Sprite routes can still expose friendly aliases, but the generic resource route stays global.
|
|
170
141
|
|
|
171
142
|
| Resource | HTTP route |
|
|
172
143
|
|---|---|
|
|
@@ -187,7 +158,7 @@ Resource responses include `Content-Type`, `Content-Length`, `ETag` when identit
|
|
|
187
158
|
|
|
188
159
|
`PUT` uses the request body bytes and `Content-Type` to create or replace a resource through the capability. The server enforces a configurable body-size limit before handing bytes to the capability, rejects unsupported MIME types when the capability reports them, and makes replacements visible atomically to subsequent requests. A `GET` already in progress receives the snapshot it started with.
|
|
189
160
|
|
|
190
|
-
The management namespace `/_tw-http/` is reserved and is not treated as an asset route. Paths such as `/camera/@assets/live-camera` are not generic Asset
|
|
161
|
+
The management namespace `/_tw-http/` is reserved and is not treated as an asset route. Paths such as `/camera/@assets/live-camera` are not generic Asset Cache routes; use a Scratch/TurboWarp handler to alias friendly Sprite URLs to `/@assets/<name>` when needed. Resource authorization hooks, when configured, are applied to `GET`, `HEAD`, `PUT`, `DELETE`, and listing requests. Structured resource logs include metadata such as route, resource name, MIME type, byte count, and status; they do not include binary request or response bodies.
|
|
191
162
|
|
|
192
163
|
## Sprite Route Model
|
|
193
164
|
|
|
@@ -199,7 +170,7 @@ TurboWarp-facing routes should map naturally to visible project objects:
|
|
|
199
170
|
| Sprite `camera` while visible | `/camera` |
|
|
200
171
|
| Sprite `camera` while hidden | route disabled |
|
|
201
172
|
|
|
202
|
-
This keeps Scratch interaction tangible: showing a Sprite publishes its route, and hiding it withdraws that route. Asset
|
|
173
|
+
This keeps Scratch interaction tangible: showing a Sprite publishes its route, and hiding it withdraws that route. Asset Cache resources remain global at `/@assets/<name>` so the same resource can be reused by multiple Sprite routes without duplicating storage.
|
|
203
174
|
|
|
204
175
|
A live camera page can therefore be modeled as:
|
|
205
176
|
|
|
@@ -215,7 +186,7 @@ GET /camera/image.jpg
|
|
|
215
186
|
-> friendly handler/alias that serves /@assets/live-camera
|
|
216
187
|
```
|
|
217
188
|
|
|
218
|
-
In other words, `/camera/image.jpg` is a Sprite route decision, while `/@assets/live-camera` is the generic Asset
|
|
189
|
+
In other words, `/camera/image.jpg` is a Sprite route decision, while `/@assets/live-camera` is the generic Asset Cache resource endpoint.
|
|
219
190
|
|
|
220
191
|
## Response Content Builders
|
|
221
192
|
|
|
@@ -305,12 +276,12 @@ For low-frequency camera publishing, compose three independent pieces:
|
|
|
305
276
|
```text
|
|
306
277
|
TurboWarp Camera Source
|
|
307
278
|
-> capture current frame every 10 seconds
|
|
308
|
-
-> replace Asset
|
|
279
|
+
-> replace Asset Cache resource "live-camera"
|
|
309
280
|
-> HTTP Server serves /@assets/live-camera
|
|
310
281
|
-> browser loads the stable URL
|
|
311
282
|
```
|
|
312
283
|
|
|
313
|
-
The HTTP server does not depend on `turbowarp-camera-source` or `turbowarp-html`. Camera Source only produces snapshots; Asset
|
|
284
|
+
The HTTP server does not depend on `turbowarp-camera-source` or `turbowarp-html`. Camera Source only produces snapshots; Asset Cache owns the named resource; HTTP Server serves the generic resource URL.
|
|
314
285
|
|
|
315
286
|
Example block-level flow:
|
|
316
287
|
|
|
@@ -334,7 +305,7 @@ If a friendlier URL is desired, a Scratch/TurboWarp route handler can alias:
|
|
|
334
305
|
/camera/image.jpg -> /@assets/live-camera
|
|
335
306
|
```
|
|
336
307
|
|
|
337
|
-
An HTML page generated by `turbowarp-html` can refresh an `<img>` every 10 seconds, but cache correctness should come from HTTP validation headers, not timestamp query strings. With replacement identities from Asset
|
|
308
|
+
An HTML page generated by `turbowarp-html` can refresh an `<img>` every 10 seconds, but cache correctness should come from HTTP validation headers, not timestamp query strings. With replacement identities from Asset Cache, clients can revalidate the stable URL using ETag and receive the newest snapshot without stale browser cache behavior.
|
|
338
309
|
|
|
339
310
|
## Block reference
|
|
340
311
|
|
|
@@ -510,6 +481,76 @@ Returns the current request client address when available.
|
|
|
510
481
|
| Type | Reporter |
|
|
511
482
|
| Opcode | `currentRequestClientAddress` |
|
|
512
483
|
|
|
484
|
+
### `set handler variable [NAME] to [VALUE]`
|
|
485
|
+
|
|
486
|
+
Sets a request-local variable that is discarded when the current HTTP response completes.
|
|
487
|
+
|
|
488
|
+
| Property | Value |
|
|
489
|
+
|---|---|
|
|
490
|
+
| Type | Command |
|
|
491
|
+
| Opcode | `setHandlerVariable` |
|
|
492
|
+
| `NAME` | String, default: `value` |
|
|
493
|
+
| `VALUE` | String, default: `0` |
|
|
494
|
+
|
|
495
|
+
### `change handler variable [NAME] by [AMOUNT]`
|
|
496
|
+
|
|
497
|
+
Changes a request-local numeric variable using Scratch number conversion rules.
|
|
498
|
+
|
|
499
|
+
| Property | Value |
|
|
500
|
+
|---|---|
|
|
501
|
+
| Type | Command |
|
|
502
|
+
| Opcode | `changeHandlerVariable` |
|
|
503
|
+
| `NAME` | String, default: `value` |
|
|
504
|
+
| `AMOUNT` | Number, default: `1` |
|
|
505
|
+
|
|
506
|
+
### `handler variable [NAME]`
|
|
507
|
+
|
|
508
|
+
Returns a request-local handler variable, or an empty string when it does not exist.
|
|
509
|
+
|
|
510
|
+
| Property | Value |
|
|
511
|
+
|---|---|
|
|
512
|
+
| Type | Reporter |
|
|
513
|
+
| Opcode | `handlerVariable` |
|
|
514
|
+
| `NAME` | String, default: `value` |
|
|
515
|
+
|
|
516
|
+
### `handler variable [NAME] exists?`
|
|
517
|
+
|
|
518
|
+
Reports whether a request-local handler variable exists.
|
|
519
|
+
|
|
520
|
+
| Property | Value |
|
|
521
|
+
|---|---|
|
|
522
|
+
| Type | Boolean |
|
|
523
|
+
| Opcode | `handlerVariableExists` |
|
|
524
|
+
| `NAME` | String, default: `value` |
|
|
525
|
+
|
|
526
|
+
### `delete handler variable [NAME]`
|
|
527
|
+
|
|
528
|
+
Deletes a request-local handler variable.
|
|
529
|
+
|
|
530
|
+
| Property | Value |
|
|
531
|
+
|---|---|
|
|
532
|
+
| Type | Command |
|
|
533
|
+
| Opcode | `deleteHandlerVariable` |
|
|
534
|
+
| `NAME` | String, default: `value` |
|
|
535
|
+
|
|
536
|
+
### `delete all handler variables`
|
|
537
|
+
|
|
538
|
+
Deletes all request-local handler variables for the current HTTP handler.
|
|
539
|
+
|
|
540
|
+
| Property | Value |
|
|
541
|
+
|---|---|
|
|
542
|
+
| Type | Command |
|
|
543
|
+
| Opcode | `clearHandlerVariables` |
|
|
544
|
+
|
|
545
|
+
### `active handler variables`
|
|
546
|
+
|
|
547
|
+
Returns comma-separated names of request-local handler variables.
|
|
548
|
+
|
|
549
|
+
| Property | Value |
|
|
550
|
+
|---|---|
|
|
551
|
+
| Type | Reporter |
|
|
552
|
+
| Opcode | `listHandlerVariables` |
|
|
553
|
+
|
|
513
554
|
### `current auth type`
|
|
514
555
|
|
|
515
556
|
Returns the current authentication type, such as digest or oauth.
|
|
@@ -656,6 +697,22 @@ Responds with JSON.
|
|
|
656
697
|
| Opcode | `respondWithJson` |
|
|
657
698
|
| `BODY` | String, default: `{"ok":true}` |
|
|
658
699
|
|
|
700
|
+
### `respond with named [NAMESPACE] [NAME] kind [KIND] scope [SCOPE] target [TARGET_ID] as [REPRESENTATION] max bytes [MAX_BYTES]`
|
|
701
|
+
|
|
702
|
+
Completes the response with a named structured, document, binary, or asset snapshot resolved by the server.
|
|
703
|
+
|
|
704
|
+
| Property | Value |
|
|
705
|
+
|---|---|
|
|
706
|
+
| Type | Command |
|
|
707
|
+
| Opcode | `respondWithNamedBody` |
|
|
708
|
+
| `NAMESPACE` | String, default: `asset` |
|
|
709
|
+
| `NAME` | String, default: `avatar` |
|
|
710
|
+
| `KIND` | String, default: `asset` |
|
|
711
|
+
| `SCOPE` | String, default: `project` |
|
|
712
|
+
| `TARGET_ID` | String, default: `Stage:1` |
|
|
713
|
+
| `REPRESENTATION` | String, default: `raw` |
|
|
714
|
+
| `MAX_BYTES` | Number, default: `10485760` |
|
|
715
|
+
|
|
659
716
|
### `record HTTP log [ENTRY]`
|
|
660
717
|
|
|
661
718
|
Adds a structured HTTP log entry JSON string to the extension log buffer.
|
|
@@ -872,3 +929,5 @@ Useful commands:
|
|
|
872
929
|
## License
|
|
873
930
|
|
|
874
931
|
[Mozilla Public License 2.0](LICENSE) (SPDX: `MPL-2.0`).
|
|
932
|
+
|
|
933
|
+
固定入力の編集範囲・互換性・切戻しについては [固定入力の編集](docs/fixed-input-editors.ja.md) を参照してください。
|
package/dist/cli.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { HtdigestFile } from './auth/digest-file.js';
|
|
3
3
|
import { startServer } from './server.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
console.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
import { compileToDirectory } from './compiler/index.js';
|
|
5
|
+
void main(process.argv.slice(2)).catch((error) => {
|
|
6
|
+
console.error(error instanceof Error ? error.message : error);
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
});
|
|
9
|
+
async function main(args) {
|
|
10
|
+
if (args[0] === 'compile') {
|
|
11
|
+
const options = parseCompileArgs(args.slice(1));
|
|
12
|
+
const result = await compileToDirectory(options);
|
|
13
|
+
for (const diagnostic of result.diagnostics) {
|
|
14
|
+
console.warn(`[${diagnostic.code}] ${diagnostic.message}`);
|
|
15
|
+
}
|
|
16
|
+
console.log(`Generated ${result.files.length} files in ${options.output}.`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const options = parseArgs(args);
|
|
20
|
+
const server = startServer(toServerOptions(options));
|
|
21
|
+
console.log(`turbowarp-http-server listening on ${options.tlsCert ? 'https' : 'http'}://${server.hostname}:${server.port}`);
|
|
22
|
+
function shutdown(signal) {
|
|
23
|
+
console.log(`Received ${signal}; shutting down.`);
|
|
24
|
+
server
|
|
25
|
+
.close()
|
|
26
|
+
.catch((error) => {
|
|
27
|
+
console.error(error);
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
})
|
|
30
|
+
.finally(() => {
|
|
31
|
+
process.exit();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
35
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
18
36
|
}
|
|
19
|
-
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
20
|
-
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
21
37
|
function parseArgs(args) {
|
|
22
38
|
const options = {
|
|
23
39
|
hostname: process.env.HOST ?? '127.0.0.1',
|
|
@@ -49,6 +65,9 @@ function parseArgs(args) {
|
|
|
49
65
|
else if (arg === '--community') {
|
|
50
66
|
options.community = {};
|
|
51
67
|
}
|
|
68
|
+
else if (arg === '--enable-named-response-body') {
|
|
69
|
+
options.namedResponseBody = true;
|
|
70
|
+
}
|
|
52
71
|
else if (arg === '--auth-digest') {
|
|
53
72
|
options.authDigestFile = requireValue(args, index, '--auth-digest');
|
|
54
73
|
index += 1;
|
|
@@ -84,6 +103,78 @@ function parseArgs(args) {
|
|
|
84
103
|
}
|
|
85
104
|
return options;
|
|
86
105
|
}
|
|
106
|
+
function parseCompileArgs(args) {
|
|
107
|
+
let input = '';
|
|
108
|
+
let output = '';
|
|
109
|
+
let format = 'turbowarp-json';
|
|
110
|
+
let force = false;
|
|
111
|
+
let target;
|
|
112
|
+
let targetConfig;
|
|
113
|
+
let manifestLock;
|
|
114
|
+
let namedResponseBody = false;
|
|
115
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
116
|
+
const arg = args[index];
|
|
117
|
+
if (arg === '--input') {
|
|
118
|
+
input = requireValue(args, index, '--input');
|
|
119
|
+
index += 1;
|
|
120
|
+
}
|
|
121
|
+
else if (arg === '--output') {
|
|
122
|
+
output = requireValue(args, index, '--output');
|
|
123
|
+
index += 1;
|
|
124
|
+
}
|
|
125
|
+
else if (arg === '--format') {
|
|
126
|
+
const value = requireValue(args, index, '--format');
|
|
127
|
+
if (value !== 'turbowarp-json' && value !== 'ir')
|
|
128
|
+
throw new Error(`Invalid format: ${value}`);
|
|
129
|
+
format = value;
|
|
130
|
+
index += 1;
|
|
131
|
+
}
|
|
132
|
+
else if (arg === '--force') {
|
|
133
|
+
force = true;
|
|
134
|
+
}
|
|
135
|
+
else if (arg === '--target') {
|
|
136
|
+
target = requireValue(args, index, '--target');
|
|
137
|
+
index += 1;
|
|
138
|
+
}
|
|
139
|
+
else if (arg === '--target-config') {
|
|
140
|
+
targetConfig = requireValue(args, index, '--target-config');
|
|
141
|
+
index += 1;
|
|
142
|
+
}
|
|
143
|
+
else if (arg === '--manifest-lock') {
|
|
144
|
+
manifestLock = requireValue(args, index, '--manifest-lock');
|
|
145
|
+
index += 1;
|
|
146
|
+
}
|
|
147
|
+
else if (arg === '--enable-named-response-body') {
|
|
148
|
+
namedResponseBody = true;
|
|
149
|
+
}
|
|
150
|
+
else if (arg === '--help' || arg === '-h') {
|
|
151
|
+
printCompileHelp();
|
|
152
|
+
process.exit(0);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
throw new Error(`Unknown compile argument: ${arg}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (!input)
|
|
159
|
+
throw new Error('compile requires --input <file>.');
|
|
160
|
+
if (!output)
|
|
161
|
+
throw new Error('compile requires --output <directory>.');
|
|
162
|
+
if (target === undefined)
|
|
163
|
+
throw new Error('compile requires --target <id>.');
|
|
164
|
+
if (manifestLock !== undefined && format !== 'turbowarp-json') {
|
|
165
|
+
throw new Error('--manifest-lock requires --format turbowarp-json.');
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
input,
|
|
169
|
+
output,
|
|
170
|
+
format,
|
|
171
|
+
force,
|
|
172
|
+
target,
|
|
173
|
+
namedResponseBody,
|
|
174
|
+
...(targetConfig === undefined ? {} : { targetConfig }),
|
|
175
|
+
...(manifestLock === undefined ? {} : { manifestLock })
|
|
176
|
+
};
|
|
177
|
+
}
|
|
87
178
|
function toServerOptions(options) {
|
|
88
179
|
const serverOptions = {
|
|
89
180
|
hostname: options.hostname,
|
|
@@ -91,6 +182,9 @@ function toServerOptions(options) {
|
|
|
91
182
|
};
|
|
92
183
|
if (options.community !== undefined)
|
|
93
184
|
serverOptions.community = options.community;
|
|
185
|
+
if (options.namedResponseBody !== undefined) {
|
|
186
|
+
serverOptions.namedResponseBody = options.namedResponseBody;
|
|
187
|
+
}
|
|
94
188
|
const digestAuth = toDigestAuthOptions(options);
|
|
95
189
|
if (digestAuth)
|
|
96
190
|
serverOptions.digestAuth = digestAuth;
|
|
@@ -128,7 +222,9 @@ function isTruthy(value) {
|
|
|
128
222
|
return value === '1' || value === 'true' || value === 'yes';
|
|
129
223
|
}
|
|
130
224
|
function printHelp() {
|
|
131
|
-
console.log(`Usage:
|
|
225
|
+
console.log(`Usage:
|
|
226
|
+
turbowarp-http-server [--host <host>] [--port <port>]
|
|
227
|
+
turbowarp-http-server compile --input <file> --output <directory> [options]
|
|
132
228
|
|
|
133
229
|
Starts the companion HTTP/WebSocket bridge for the TurboWarp extension.
|
|
134
230
|
|
|
@@ -136,6 +232,7 @@ Options:
|
|
|
136
232
|
--host <host> Hostname or address to bind. Defaults to HOST or 127.0.0.1.
|
|
137
233
|
--port <port> TCP port to bind. Defaults to PORT or 8787.
|
|
138
234
|
--community Enable the learning-only Scratch-like community routes.
|
|
235
|
+
--enable-named-response-body Enable experimental named response blocks (default OFF).
|
|
139
236
|
--auth-digest <file>
|
|
140
237
|
Enable HTTP Digest authentication using an htdigest file.
|
|
141
238
|
--auth-realm <realm>
|
|
@@ -153,4 +250,21 @@ Environment:
|
|
|
153
250
|
TURBOWARP_HTTP_TLS_KEY
|
|
154
251
|
`);
|
|
155
252
|
}
|
|
253
|
+
function printCompileHelp() {
|
|
254
|
+
console.log(`Usage: turbowarp-http-server compile --input <file> --output <directory> [options]
|
|
255
|
+
|
|
256
|
+
Compiles an accepted TurboWarp project.json subset or deploy IR to Hono deployment artifacts.
|
|
257
|
+
|
|
258
|
+
Options:
|
|
259
|
+
--input <file> TurboWarp project.json or deploy IR JSON.
|
|
260
|
+
--output <directory> Generated project directory.
|
|
261
|
+
--format <format> turbowarp-json (default) or ir.
|
|
262
|
+
--target <id> Required deployment target; for example cloudflare-workers.
|
|
263
|
+
--target-config <file> Adapter config containing binding names, never secrets.
|
|
264
|
+
--manifest-lock <file> Locked extension manifests for TurboWarp project input.
|
|
265
|
+
--enable-named-response-body Enable the experimental named body IR operation (default OFF).
|
|
266
|
+
--force Replace generated files in a non-empty output directory.
|
|
267
|
+
-h, --help Show this help.
|
|
268
|
+
`);
|
|
269
|
+
}
|
|
156
270
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAExC,OAAO,EAAC,kBAAkB,EAA2B,MAAM,qBAAqB,CAAC;AAajF,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACxD,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,IAAI,CAAC,IAAuB;IACzC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACjD,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;Y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