bkper 3.8.1 → 4.0.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.
- package/CHANGELOG.md +20 -1
- package/README.md +217 -183
- package/lib/auth/auth-page.d.ts +14 -0
- package/lib/auth/auth-page.d.ts.map +1 -0
- package/lib/auth/auth-page.js +110 -0
- package/lib/auth/auth-page.js.map +1 -0
- package/lib/auth/local-auth-service.d.ts.map +1 -1
- package/lib/auth/local-auth-service.js +135 -17
- package/lib/auth/local-auth-service.js.map +1 -1
- package/lib/bkper-factory.d.ts.map +1 -0
- package/lib/{mcp/bkper-factory.js → bkper-factory.js} +5 -2
- package/lib/bkper-factory.js.map +1 -0
- package/lib/cli.d.ts +1 -1
- package/lib/cli.d.ts.map +1 -1
- package/lib/cli.js +851 -47
- package/lib/cli.js.map +1 -1
- package/lib/commands/accounts/create.d.ts +10 -0
- package/lib/commands/accounts/create.d.ts.map +1 -0
- package/lib/commands/accounts/create.js +42 -0
- package/lib/commands/accounts/create.js.map +1 -0
- package/lib/commands/accounts/delete.d.ts +3 -0
- package/lib/commands/accounts/delete.d.ts.map +1 -0
- package/lib/commands/accounts/delete.js +22 -0
- package/lib/commands/accounts/delete.js.map +1 -0
- package/lib/commands/accounts/get.d.ts +3 -0
- package/lib/commands/accounts/get.d.ts.map +1 -0
- package/lib/commands/accounts/get.js +22 -0
- package/lib/commands/accounts/get.js.map +1 -0
- package/lib/commands/accounts/index.d.ts +6 -0
- package/lib/commands/accounts/index.d.ts.map +1 -0
- package/lib/commands/accounts/index.js +6 -0
- package/lib/commands/accounts/index.js.map +1 -0
- package/lib/commands/accounts/list.d.ts +3 -0
- package/lib/commands/accounts/list.d.ts.map +1 -0
- package/lib/commands/accounts/list.js +19 -0
- package/lib/commands/accounts/list.js.map +1 -0
- package/lib/commands/accounts/update.d.ts +9 -0
- package/lib/commands/accounts/update.d.ts.map +1 -0
- package/lib/commands/accounts/update.js +40 -0
- package/lib/commands/accounts/update.js.map +1 -0
- package/lib/commands/apps/build.d.ts +11 -0
- package/lib/commands/apps/build.d.ts.map +1 -0
- package/lib/commands/apps/build.js +144 -0
- package/lib/commands/apps/build.js.map +1 -0
- package/lib/commands/apps/bundler.d.ts +34 -0
- package/lib/commands/apps/bundler.d.ts.map +1 -0
- package/lib/commands/apps/bundler.js +112 -0
- package/lib/commands/apps/bundler.js.map +1 -0
- package/lib/commands/apps/config.d.ts +51 -0
- package/lib/commands/apps/config.d.ts.map +1 -0
- package/lib/commands/apps/config.js +146 -0
- package/lib/commands/apps/config.js.map +1 -0
- package/lib/commands/apps/deploy.d.ts +23 -0
- package/lib/commands/apps/deploy.d.ts.map +1 -0
- package/lib/commands/apps/deploy.js +344 -0
- package/lib/commands/apps/deploy.js.map +1 -0
- package/lib/commands/apps/dev.d.ts +28 -0
- package/lib/commands/apps/dev.d.ts.map +1 -0
- package/lib/commands/apps/dev.js +393 -0
- package/lib/commands/apps/dev.js.map +1 -0
- package/lib/commands/apps/index.d.ts +12 -0
- package/lib/commands/apps/index.d.ts.map +1 -0
- package/lib/commands/apps/index.js +24 -0
- package/lib/commands/apps/index.js.map +1 -0
- package/lib/commands/apps/init.d.ts +7 -0
- package/lib/commands/apps/init.d.ts.map +1 -0
- package/lib/commands/apps/init.js +249 -0
- package/lib/commands/apps/init.js.map +1 -0
- package/lib/commands/apps/install.d.ts +3 -0
- package/lib/commands/apps/install.d.ts.map +1 -0
- package/lib/commands/apps/install.js +18 -0
- package/lib/commands/apps/install.js.map +1 -0
- package/lib/commands/apps/list.d.ts +7 -0
- package/lib/commands/apps/list.d.ts.map +1 -0
- package/lib/commands/apps/list.js +23 -0
- package/lib/commands/apps/list.js.map +1 -0
- package/lib/commands/apps/secrets.d.ts +22 -0
- package/lib/commands/apps/secrets.d.ts.map +1 -0
- package/lib/commands/apps/secrets.js +209 -0
- package/lib/commands/apps/secrets.js.map +1 -0
- package/lib/commands/{apps.d.ts → apps/sync.d.ts} +8 -7
- package/lib/commands/apps/sync.d.ts.map +1 -0
- package/lib/commands/apps/sync.js +76 -0
- package/lib/commands/apps/sync.js.map +1 -0
- package/lib/commands/apps/types.d.ts +54 -0
- package/lib/commands/apps/types.d.ts.map +1 -0
- package/lib/commands/apps/types.js +2 -0
- package/lib/commands/apps/types.js.map +1 -0
- package/lib/commands/apps/uninstall.d.ts +3 -0
- package/lib/commands/apps/uninstall.d.ts.map +1 -0
- package/lib/commands/apps/uninstall.js +23 -0
- package/lib/commands/apps/uninstall.js.map +1 -0
- package/lib/commands/balances/get.d.ts +12 -0
- package/lib/commands/balances/get.d.ts.map +1 -0
- package/lib/commands/balances/get.js +32 -0
- package/lib/commands/balances/get.js.map +1 -0
- package/lib/commands/balances/index.d.ts +2 -0
- package/lib/commands/balances/index.d.ts.map +1 -0
- package/lib/commands/balances/index.js +2 -0
- package/lib/commands/balances/index.js.map +1 -0
- package/lib/commands/books/create.d.ts +12 -0
- package/lib/commands/books/create.d.ts.map +1 -0
- package/lib/commands/books/create.js +37 -0
- package/lib/commands/books/create.js.map +1 -0
- package/lib/commands/books/get.d.ts +3 -0
- package/lib/commands/books/get.d.ts.map +1 -0
- package/lib/commands/books/get.js +17 -0
- package/lib/commands/books/get.js.map +1 -0
- package/lib/commands/books/index.d.ts +5 -0
- package/lib/commands/books/index.d.ts.map +1 -0
- package/lib/commands/books/index.js +5 -0
- package/lib/commands/books/index.js.map +1 -0
- package/lib/commands/books/list.d.ts +3 -0
- package/lib/commands/books/list.d.ts.map +1 -0
- package/lib/commands/books/list.js +17 -0
- package/lib/commands/books/list.js.map +1 -0
- package/lib/commands/books/update.d.ts +14 -0
- package/lib/commands/books/update.d.ts.map +1 -0
- package/lib/commands/books/update.js +46 -0
- package/lib/commands/books/update.js.map +1 -0
- package/lib/commands/collections/add-book.d.ts +3 -0
- package/lib/commands/collections/add-book.d.ts.map +1 -0
- package/lib/commands/collections/add-book.js +27 -0
- package/lib/commands/collections/add-book.js.map +1 -0
- package/lib/commands/collections/create.d.ts +6 -0
- package/lib/commands/collections/create.d.ts.map +1 -0
- package/lib/commands/collections/create.js +19 -0
- package/lib/commands/collections/create.js.map +1 -0
- package/lib/commands/collections/delete.d.ts +3 -0
- package/lib/commands/collections/delete.d.ts.map +1 -0
- package/lib/commands/collections/delete.js +22 -0
- package/lib/commands/collections/delete.js.map +1 -0
- package/lib/commands/collections/get.d.ts +3 -0
- package/lib/commands/collections/get.d.ts.map +1 -0
- package/lib/commands/collections/get.js +22 -0
- package/lib/commands/collections/get.js.map +1 -0
- package/lib/commands/collections/index.d.ts +8 -0
- package/lib/commands/collections/index.d.ts.map +1 -0
- package/lib/commands/collections/index.js +8 -0
- package/lib/commands/collections/index.js.map +1 -0
- package/lib/commands/collections/list.d.ts +3 -0
- package/lib/commands/collections/list.d.ts.map +1 -0
- package/lib/commands/collections/list.js +18 -0
- package/lib/commands/collections/list.js.map +1 -0
- package/lib/commands/collections/remove-book.d.ts +3 -0
- package/lib/commands/collections/remove-book.d.ts.map +1 -0
- package/lib/commands/collections/remove-book.js +27 -0
- package/lib/commands/collections/remove-book.js.map +1 -0
- package/lib/commands/collections/update.d.ts +6 -0
- package/lib/commands/collections/update.d.ts.map +1 -0
- package/lib/commands/collections/update.js +24 -0
- package/lib/commands/collections/update.js.map +1 -0
- package/lib/commands/groups/create.d.ts +9 -0
- package/lib/commands/groups/create.d.ts.map +1 -0
- package/lib/commands/groups/create.js +40 -0
- package/lib/commands/groups/create.js.map +1 -0
- package/lib/commands/groups/delete.d.ts +3 -0
- package/lib/commands/groups/delete.d.ts.map +1 -0
- package/lib/commands/groups/delete.js +22 -0
- package/lib/commands/groups/delete.js.map +1 -0
- package/lib/commands/groups/get.d.ts +3 -0
- package/lib/commands/groups/get.d.ts.map +1 -0
- package/lib/commands/groups/get.js +22 -0
- package/lib/commands/groups/get.js.map +1 -0
- package/lib/commands/groups/index.d.ts +6 -0
- package/lib/commands/groups/index.d.ts.map +1 -0
- package/lib/commands/groups/index.js +6 -0
- package/lib/commands/groups/index.js.map +1 -0
- package/lib/commands/groups/list.d.ts +3 -0
- package/lib/commands/groups/list.d.ts.map +1 -0
- package/lib/commands/groups/list.js +19 -0
- package/lib/commands/groups/list.js.map +1 -0
- package/lib/commands/groups/update.d.ts +8 -0
- package/lib/commands/groups/update.d.ts.map +1 -0
- package/lib/commands/groups/update.js +38 -0
- package/lib/commands/groups/update.js.map +1 -0
- package/lib/commands/skills.d.ts +17 -0
- package/lib/commands/skills.d.ts.map +1 -0
- package/lib/commands/skills.js +248 -0
- package/lib/commands/skills.js.map +1 -0
- package/lib/commands/transactions/check.d.ts +3 -0
- package/lib/commands/transactions/check.d.ts.map +1 -0
- package/lib/commands/transactions/check.js +22 -0
- package/lib/commands/transactions/check.js.map +1 -0
- package/lib/commands/transactions/create.d.ts +13 -0
- package/lib/commands/transactions/create.d.ts.map +1 -0
- package/lib/commands/transactions/create.js +55 -0
- package/lib/commands/transactions/create.js.map +1 -0
- package/lib/commands/transactions/index.d.ts +8 -0
- package/lib/commands/transactions/index.d.ts.map +1 -0
- package/lib/commands/transactions/index.js +8 -0
- package/lib/commands/transactions/index.js.map +1 -0
- package/lib/commands/transactions/list.d.ts +14 -0
- package/lib/commands/transactions/list.d.ts.map +1 -0
- package/lib/commands/transactions/list.js +26 -0
- package/lib/commands/transactions/list.js.map +1 -0
- package/lib/commands/transactions/merge.d.ts +8 -0
- package/lib/commands/transactions/merge.d.ts.map +1 -0
- package/lib/commands/transactions/merge.js +44 -0
- package/lib/commands/transactions/merge.js.map +1 -0
- package/lib/commands/transactions/post.d.ts +3 -0
- package/lib/commands/transactions/post.d.ts.map +1 -0
- package/lib/commands/transactions/post.js +22 -0
- package/lib/commands/transactions/post.js.map +1 -0
- package/lib/commands/transactions/trash.d.ts +3 -0
- package/lib/commands/transactions/trash.d.ts.map +1 -0
- package/lib/commands/transactions/trash.js +22 -0
- package/lib/commands/transactions/trash.js.map +1 -0
- package/lib/commands/transactions/update.d.ts +12 -0
- package/lib/commands/transactions/update.d.ts.map +1 -0
- package/lib/commands/transactions/update.js +53 -0
- package/lib/commands/transactions/update.js.map +1 -0
- package/lib/dev/auth-middleware.d.ts +18 -0
- package/lib/dev/auth-middleware.d.ts.map +1 -0
- package/lib/dev/auth-middleware.js +113 -0
- package/lib/dev/auth-middleware.js.map +1 -0
- package/lib/dev/cleanup.d.ts +10 -0
- package/lib/dev/cleanup.d.ts.map +1 -0
- package/lib/dev/cleanup.js +36 -0
- package/lib/dev/cleanup.js.map +1 -0
- package/lib/dev/cloudflared/constants.d.ts +35 -0
- package/lib/dev/cloudflared/constants.d.ts.map +1 -0
- package/lib/dev/cloudflared/constants.js +48 -0
- package/lib/dev/cloudflared/constants.js.map +1 -0
- package/lib/dev/cloudflared/index.d.ts +11 -0
- package/lib/dev/cloudflared/index.d.ts.map +1 -0
- package/lib/dev/cloudflared/index.js +10 -0
- package/lib/dev/cloudflared/index.js.map +1 -0
- package/lib/dev/cloudflared/install.d.ts +15 -0
- package/lib/dev/cloudflared/install.d.ts.map +1 -0
- package/lib/dev/cloudflared/install.js +140 -0
- package/lib/dev/cloudflared/install.js.map +1 -0
- package/lib/dev/cloudflared/tunnel.d.ts +64 -0
- package/lib/dev/cloudflared/tunnel.d.ts.map +1 -0
- package/lib/dev/cloudflared/tunnel.js +109 -0
- package/lib/dev/cloudflared/tunnel.js.map +1 -0
- package/lib/dev/esbuild.d.ts +28 -0
- package/lib/dev/esbuild.d.ts.map +1 -0
- package/lib/dev/esbuild.js +83 -0
- package/lib/dev/esbuild.js.map +1 -0
- package/lib/dev/logger.d.ts +51 -0
- package/lib/dev/logger.d.ts.map +1 -0
- package/lib/dev/logger.js +102 -0
- package/lib/dev/logger.js.map +1 -0
- package/lib/dev/miniflare.d.ts +32 -0
- package/lib/dev/miniflare.d.ts.map +1 -0
- package/lib/dev/miniflare.js +111 -0
- package/lib/dev/miniflare.js.map +1 -0
- package/lib/dev/preflight.d.ts +7 -0
- package/lib/dev/preflight.d.ts.map +1 -0
- package/lib/dev/preflight.js +61 -0
- package/lib/dev/preflight.js.map +1 -0
- package/lib/dev/shared.d.ts +7 -0
- package/lib/dev/shared.d.ts.map +1 -0
- package/lib/dev/shared.js +99 -0
- package/lib/dev/shared.js.map +1 -0
- package/lib/dev/tunnel.d.ts +31 -0
- package/lib/dev/tunnel.d.ts.map +1 -0
- package/lib/dev/tunnel.js +110 -0
- package/lib/dev/tunnel.js.map +1 -0
- package/lib/dev/types.d.ts +53 -0
- package/lib/dev/types.d.ts.map +1 -0
- package/lib/dev/types.js +223 -0
- package/lib/dev/types.js.map +1 -0
- package/lib/dev/vite.d.ts +50 -0
- package/lib/dev/vite.d.ts.map +1 -0
- package/lib/dev/vite.js +114 -0
- package/lib/dev/vite.js.map +1 -0
- package/lib/dev/webhook-dev.d.ts +9 -0
- package/lib/dev/webhook-dev.d.ts.map +1 -0
- package/lib/dev/webhook-dev.js +28 -0
- package/lib/dev/webhook-dev.js.map +1 -0
- package/lib/domain/transaction/merge-operation.d.ts.map +1 -0
- package/lib/{mcp/domain → domain}/transaction/merge-operation.js +10 -11
- package/lib/domain/transaction/merge-operation.js.map +1 -0
- package/lib/domain/transaction/merge-types.d.ts.map +1 -0
- package/lib/domain/transaction/merge-types.js.map +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/platform/client.d.ts +37 -0
- package/lib/platform/client.d.ts.map +1 -0
- package/lib/platform/client.js +37 -0
- package/lib/platform/client.js.map +1 -0
- package/lib/render/index.d.ts +3 -0
- package/lib/render/index.d.ts.map +1 -0
- package/lib/render/index.js +3 -0
- package/lib/render/index.js.map +1 -0
- package/lib/render/output.d.ts +15 -0
- package/lib/render/output.d.ts.map +1 -0
- package/lib/render/output.js +30 -0
- package/lib/render/output.js.map +1 -0
- package/lib/render/table-formatter.d.ts +34 -0
- package/lib/render/table-formatter.d.ts.map +1 -0
- package/lib/render/table-formatter.js +221 -0
- package/lib/render/table-formatter.js.map +1 -0
- package/lib/utils/properties.d.ts +12 -0
- package/lib/utils/properties.d.ts.map +1 -0
- package/lib/utils/properties.js +23 -0
- package/lib/utils/properties.js.map +1 -0
- package/package.json +23 -23
- package/lib/auth/keys.json +0 -12
- package/lib/commands/apps.d.ts.map +0 -1
- package/lib/commands/apps.js +0 -93
- package/lib/commands/apps.js.map +0 -1
- package/lib/mcp/bkper-factory.d.ts.map +0 -1
- package/lib/mcp/bkper-factory.js.map +0 -1
- package/lib/mcp/domain/transaction/merge-operation.d.ts.map +0 -1
- package/lib/mcp/domain/transaction/merge-operation.js.map +0 -1
- package/lib/mcp/domain/transaction/merge-types.d.ts.map +0 -1
- package/lib/mcp/domain/transaction/merge-types.js.map +0 -1
- package/lib/mcp/server.d.ts +0 -13
- package/lib/mcp/server.d.ts.map +0 -1
- package/lib/mcp/server.js +0 -161
- package/lib/mcp/server.js.map +0 -1
- package/lib/mcp/system-prompt.md +0 -192
- package/lib/mcp/tools/create_transactions.d.ts +0 -59
- package/lib/mcp/tools/create_transactions.d.ts.map +0 -1
- package/lib/mcp/tools/create_transactions.js +0 -163
- package/lib/mcp/tools/create_transactions.js.map +0 -1
- package/lib/mcp/tools/get_balances.d.ts +0 -26
- package/lib/mcp/tools/get_balances.d.ts.map +0 -1
- package/lib/mcp/tools/get_balances.js +0 -106
- package/lib/mcp/tools/get_balances.js.map +0 -1
- package/lib/mcp/tools/get_book.d.ts +0 -21
- package/lib/mcp/tools/get_book.d.ts.map +0 -1
- package/lib/mcp/tools/get_book.js +0 -126
- package/lib/mcp/tools/get_book.js.map +0 -1
- package/lib/mcp/tools/list_books.d.ts +0 -21
- package/lib/mcp/tools/list_books.d.ts.map +0 -1
- package/lib/mcp/tools/list_books.js +0 -67
- package/lib/mcp/tools/list_books.js.map +0 -1
- package/lib/mcp/tools/list_transactions.d.ts +0 -38
- package/lib/mcp/tools/list_transactions.d.ts.map +0 -1
- package/lib/mcp/tools/list_transactions.js +0 -109
- package/lib/mcp/tools/list_transactions.js.map +0 -1
- package/lib/mcp/tools/merge_transactions.d.ts +0 -40
- package/lib/mcp/tools/merge_transactions.d.ts.map +0 -1
- package/lib/mcp/tools/merge_transactions.js +0 -120
- package/lib/mcp/tools/merge_transactions.js.map +0 -1
- /package/lib/{mcp/bkper-factory.d.ts → bkper-factory.d.ts} +0 -0
- /package/lib/{mcp/domain → domain}/transaction/merge-operation.d.ts +0 -0
- /package/lib/{mcp/domain → domain}/transaction/merge-types.d.ts +0 -0
- /package/lib/{mcp/domain → domain}/transaction/merge-types.js +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { bin } from './constants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Regex patterns for parsing cloudflared output.
|
|
6
|
+
*/
|
|
7
|
+
const TRYCLOUDFLARE_URL_REGEX = /https:\/\/[^\s]+\.trycloudflare\.com/;
|
|
8
|
+
const CONNECTION_REGEX = /Connection ([a-f0-9-]+) registered with protocol: .* connIndex=\d+ ip=([\d.]+) location=(\w+)/;
|
|
9
|
+
const DISCONNECTION_REGEX = /Unregistered tunnel connection connIndex=\d+ ip=([\d.]+)/;
|
|
10
|
+
/**
|
|
11
|
+
* Manages a cloudflared tunnel process.
|
|
12
|
+
*/
|
|
13
|
+
export class Tunnel extends EventEmitter {
|
|
14
|
+
constructor(args) {
|
|
15
|
+
super();
|
|
16
|
+
this._url = null;
|
|
17
|
+
this._process = this.createProcess(args);
|
|
18
|
+
this.setupEventHandlers();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The underlying child process.
|
|
22
|
+
*/
|
|
23
|
+
get process() {
|
|
24
|
+
return this._process;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The assigned tunnel URL, if available.
|
|
28
|
+
*/
|
|
29
|
+
get url() {
|
|
30
|
+
return this._url;
|
|
31
|
+
}
|
|
32
|
+
createProcess(args) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const child = spawn(bin, args, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
35
|
+
child.on('error', error => this.emit('error', error));
|
|
36
|
+
child.on('exit', (code, signal) => this.emit('exit', code, signal));
|
|
37
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', data => this.emit('stdout', data.toString()));
|
|
38
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on('data', data => this.emit('stderr', data.toString()));
|
|
39
|
+
return child;
|
|
40
|
+
}
|
|
41
|
+
setupEventHandlers() {
|
|
42
|
+
// cloudflared outputs to stderr primarily
|
|
43
|
+
const handleOutput = (output) => {
|
|
44
|
+
// Check for URL assignment
|
|
45
|
+
const urlMatch = output.match(TRYCLOUDFLARE_URL_REGEX);
|
|
46
|
+
if (urlMatch && !this._url) {
|
|
47
|
+
this._url = urlMatch[0];
|
|
48
|
+
this.emit('url', this._url);
|
|
49
|
+
}
|
|
50
|
+
// Check for connection
|
|
51
|
+
const connMatch = output.match(CONNECTION_REGEX);
|
|
52
|
+
if (connMatch) {
|
|
53
|
+
this.emit('connected', {
|
|
54
|
+
id: connMatch[1],
|
|
55
|
+
ip: connMatch[2],
|
|
56
|
+
location: connMatch[3],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// Check for disconnection
|
|
60
|
+
const disconnMatch = output.match(DISCONNECTION_REGEX);
|
|
61
|
+
if (disconnMatch) {
|
|
62
|
+
this.emit('disconnected', {
|
|
63
|
+
id: '',
|
|
64
|
+
ip: disconnMatch[1],
|
|
65
|
+
location: '',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
this.on('stdout', handleOutput);
|
|
70
|
+
this.on('stderr', handleOutput);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Stops the tunnel process.
|
|
74
|
+
*/
|
|
75
|
+
stop() {
|
|
76
|
+
return this._process.kill('SIGINT');
|
|
77
|
+
}
|
|
78
|
+
// Type-safe event emitter methods
|
|
79
|
+
on(event, listener) {
|
|
80
|
+
return super.on(event, listener);
|
|
81
|
+
}
|
|
82
|
+
once(event, listener) {
|
|
83
|
+
return super.once(event, listener);
|
|
84
|
+
}
|
|
85
|
+
off(event, listener) {
|
|
86
|
+
return super.off(event, listener);
|
|
87
|
+
}
|
|
88
|
+
emit(event, ...args) {
|
|
89
|
+
return super.emit(event, ...args);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates a Quick Tunnel (no Cloudflare account required).
|
|
93
|
+
*
|
|
94
|
+
* @param url - The local URL to tunnel (e.g., 'http://localhost:8080').
|
|
95
|
+
* If not provided, uses cloudflared's hello-world mode.
|
|
96
|
+
* @returns A new Tunnel instance.
|
|
97
|
+
*/
|
|
98
|
+
static quick(url) {
|
|
99
|
+
const args = ['tunnel'];
|
|
100
|
+
if (url) {
|
|
101
|
+
args.push('--url', url);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
args.push('--hello-world');
|
|
105
|
+
}
|
|
106
|
+
return new Tunnel(args);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=tunnel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../../../src/dev/cloudflared/tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AA+BrC;;GAEG;AACH,MAAM,uBAAuB,GAAG,sCAAsC,CAAC;AACvE,MAAM,gBAAgB,GAClB,+FAA+F,CAAC;AACpG,MAAM,mBAAmB,GAAG,0DAA0D,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,YAAY;IAIpC,YAAY,IAAc;QACtB,KAAK,EAAE,CAAC;QAHJ,SAAI,GAAkB,IAAI,CAAC;QAI/B,IAAI,CAAC,QAAQ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QAAyB;QACzE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAEM,GAAG,CAA+B,KAAQ,EAAE,QAAyB;QACxE,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;IAEM,IAAI,CACP,KAAQ,EACR,GAAG,IAAiC;QAEpC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,GAAY;QAC5B,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxB,IAAI,GAAG,EAAE,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
/**
|
|
3
|
+
* Plugin to externalize cloudflare:* and node:* imports.
|
|
4
|
+
* These are provided by the Workers runtime and should not be bundled.
|
|
5
|
+
*/
|
|
6
|
+
export declare const workersExternalsPlugin: esbuild.Plugin;
|
|
7
|
+
/**
|
|
8
|
+
* Builds a Worker and returns the bundled code as a string.
|
|
9
|
+
* Used for Miniflare integration (in-memory).
|
|
10
|
+
*
|
|
11
|
+
* Configuration rationale:
|
|
12
|
+
* - target: es2024 - Workers runtime uses V8 with ES2024 support (not esnext)
|
|
13
|
+
* - format: esm - Modern Workers require ES Modules
|
|
14
|
+
* - conditions: ['workerd', 'worker', 'browser'] - Critical for package resolution
|
|
15
|
+
*
|
|
16
|
+
* @param entryPoint - Path to TypeScript entry file
|
|
17
|
+
* @returns The bundled JavaScript code as a string
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildWorker(entryPoint: string): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Builds a Worker and writes to a file.
|
|
22
|
+
* Used for deployment builds.
|
|
23
|
+
*
|
|
24
|
+
* @param entryPoint - Path to TypeScript entry file
|
|
25
|
+
* @param outfile - Path to output JavaScript file
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildWorkerToFile(entryPoint: string, outfile: string): Promise<void>;
|
|
28
|
+
//# sourceMappingURL=esbuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.d.ts","sourceRoot":"","sources":["../../src/dev/esbuild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAInC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,OAAO,CAAC,MAS5C,CAAC;AAsBF;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYrE;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAa1F"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as esbuild from 'esbuild';
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
/**
|
|
14
|
+
* Plugin to externalize cloudflare:* and node:* imports.
|
|
15
|
+
* These are provided by the Workers runtime and should not be bundled.
|
|
16
|
+
*/
|
|
17
|
+
export const workersExternalsPlugin = {
|
|
18
|
+
name: 'workers-externals',
|
|
19
|
+
setup(build) {
|
|
20
|
+
// Cloudflare-specific imports (Durable Objects, Sockets, etc.)
|
|
21
|
+
build.onResolve({ filter: /^cloudflare:.*/ }, () => ({ external: true }));
|
|
22
|
+
// Node.js built-in modules (when using nodejs_compat)
|
|
23
|
+
build.onResolve({ filter: /^node:.*/ }, () => ({ external: true }));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Shared esbuild configuration for Cloudflare Workers.
|
|
28
|
+
*
|
|
29
|
+
* Configuration rationale:
|
|
30
|
+
* - target: es2024 - Workers runtime uses V8 with ES2024 support (not esnext)
|
|
31
|
+
* - format: esm - Modern Workers require ES Modules
|
|
32
|
+
* - conditions: ['workerd', 'worker', 'browser'] - Critical for package resolution
|
|
33
|
+
*/
|
|
34
|
+
function getBaseConfig(entryPoint) {
|
|
35
|
+
return {
|
|
36
|
+
entryPoints: [entryPoint],
|
|
37
|
+
bundle: true,
|
|
38
|
+
format: 'esm',
|
|
39
|
+
target: 'es2024',
|
|
40
|
+
conditions: ['workerd', 'worker', 'browser'],
|
|
41
|
+
plugins: [workersExternalsPlugin],
|
|
42
|
+
minify: process.env.NODE_ENV === 'production',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Builds a Worker and returns the bundled code as a string.
|
|
47
|
+
* Used for Miniflare integration (in-memory).
|
|
48
|
+
*
|
|
49
|
+
* Configuration rationale:
|
|
50
|
+
* - target: es2024 - Workers runtime uses V8 with ES2024 support (not esnext)
|
|
51
|
+
* - format: esm - Modern Workers require ES Modules
|
|
52
|
+
* - conditions: ['workerd', 'worker', 'browser'] - Critical for package resolution
|
|
53
|
+
*
|
|
54
|
+
* @param entryPoint - Path to TypeScript entry file
|
|
55
|
+
* @returns The bundled JavaScript code as a string
|
|
56
|
+
*/
|
|
57
|
+
export function buildWorker(entryPoint) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const result = yield esbuild.build(Object.assign(Object.assign({}, getBaseConfig(entryPoint)), { write: false, sourcemap: 'inline' }));
|
|
60
|
+
if (!result.outputFiles || result.outputFiles.length === 0) {
|
|
61
|
+
throw new Error('Build produced no output files');
|
|
62
|
+
}
|
|
63
|
+
return result.outputFiles[0].text;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Builds a Worker and writes to a file.
|
|
68
|
+
* Used for deployment builds.
|
|
69
|
+
*
|
|
70
|
+
* @param entryPoint - Path to TypeScript entry file
|
|
71
|
+
* @param outfile - Path to output JavaScript file
|
|
72
|
+
*/
|
|
73
|
+
export function buildWorkerToFile(entryPoint, outfile) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
// Ensure parent directory exists
|
|
76
|
+
const outDir = path.dirname(outfile);
|
|
77
|
+
if (!fs.existsSync(outDir)) {
|
|
78
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
79
|
+
}
|
|
80
|
+
yield esbuild.build(Object.assign(Object.assign({}, getBaseConfig(entryPoint)), { outfile, write: true, sourcemap: true }));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=esbuild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.js","sourceRoot":"","sources":["../../src/dev/esbuild.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,M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MG;AACH,MAAM,UAAgB,iBAAiB,CAAC,UAAkB,EAAE,OAAe;;QACvE,iCAAiC;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,OAAO,CAAC,KAAK,iCACZ,aAAa,CAAC,UAAU,CAAC,KAC5B,OAAO,EACP,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,IAAI,IACjB,CAAC;IACP,CAAC;CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utilities for dev server output
|
|
3
|
+
* Provides prefixed, colored output for different subsystems
|
|
4
|
+
*/
|
|
5
|
+
export type LogPrefix = 'server' | 'events' | 'client' | 'build' | 'types' | 'shared';
|
|
6
|
+
export interface Logger {
|
|
7
|
+
info(message: string): void;
|
|
8
|
+
success(message: string): void;
|
|
9
|
+
warn(message: string): void;
|
|
10
|
+
error(message: string): void;
|
|
11
|
+
debug(message: string): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a logger with a specific prefix
|
|
15
|
+
* @param prefix - The prefix to show in brackets (e.g., "server", "events")
|
|
16
|
+
* @returns Logger instance with info, success, warn, error, and debug methods
|
|
17
|
+
*/
|
|
18
|
+
export declare function createLogger(prefix: LogPrefix): Logger;
|
|
19
|
+
/**
|
|
20
|
+
* Formats file size in human-readable format (B, KB, MB)
|
|
21
|
+
* @param bytes - Size in bytes
|
|
22
|
+
* @returns Formatted string with appropriate unit
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatSize(bytes: number): string;
|
|
25
|
+
/**
|
|
26
|
+
* Logs startup banner for the dev server
|
|
27
|
+
* @param options - URLs for client, server, and events endpoints
|
|
28
|
+
*/
|
|
29
|
+
export declare function logDevServerBanner(options: {
|
|
30
|
+
clientUrl?: string;
|
|
31
|
+
tunnelUrl?: string;
|
|
32
|
+
}): void;
|
|
33
|
+
/**
|
|
34
|
+
* Logs build results with file sizes
|
|
35
|
+
* @param results - Build output paths and sizes
|
|
36
|
+
*/
|
|
37
|
+
export declare function logBuildResults(results: {
|
|
38
|
+
webClient?: {
|
|
39
|
+
path: string;
|
|
40
|
+
size: number;
|
|
41
|
+
};
|
|
42
|
+
webServer?: {
|
|
43
|
+
path: string;
|
|
44
|
+
size: number;
|
|
45
|
+
};
|
|
46
|
+
events?: {
|
|
47
|
+
path: string;
|
|
48
|
+
size: number;
|
|
49
|
+
};
|
|
50
|
+
}): void;
|
|
51
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/dev/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtF,MAAM,WAAW,MAAM;IACnB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAiBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAuBtD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYhD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAgB5F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACrC,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,GAAG,IAAI,CAgCP"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utilities for dev server output
|
|
3
|
+
* Provides prefixed, colored output for different subsystems
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Icon mapping for different log types
|
|
7
|
+
*/
|
|
8
|
+
const icons = {
|
|
9
|
+
success: '\u2705',
|
|
10
|
+
warn: '\u26A0\uFE0F ',
|
|
11
|
+
error: '\u274C',
|
|
12
|
+
reload: '\uD83D\uDD04',
|
|
13
|
+
build: '\uD83D\uDD28',
|
|
14
|
+
deploy: '\uD83D\uDE80',
|
|
15
|
+
change: '\uD83D\uDCDD',
|
|
16
|
+
package: '\uD83D\uDCE6',
|
|
17
|
+
rocket: '\uD83D\uDE80',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Creates a logger with a specific prefix
|
|
21
|
+
* @param prefix - The prefix to show in brackets (e.g., "server", "events")
|
|
22
|
+
* @returns Logger instance with info, success, warn, error, and debug methods
|
|
23
|
+
*/
|
|
24
|
+
export function createLogger(prefix) {
|
|
25
|
+
const formatMessage = (message, icon) => {
|
|
26
|
+
const iconPart = icon ? `${icon} ` : '';
|
|
27
|
+
return `[${prefix}] ${iconPart}${message}`;
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
info(message) {
|
|
31
|
+
console.log(formatMessage(message));
|
|
32
|
+
},
|
|
33
|
+
success(message) {
|
|
34
|
+
console.log(formatMessage(message, icons.success));
|
|
35
|
+
},
|
|
36
|
+
warn(message) {
|
|
37
|
+
console.warn(formatMessage(message, icons.warn));
|
|
38
|
+
},
|
|
39
|
+
error(message) {
|
|
40
|
+
console.error(formatMessage(message, icons.error));
|
|
41
|
+
},
|
|
42
|
+
debug(message) {
|
|
43
|
+
console.log(formatMessage(message));
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Formats file size in human-readable format (B, KB, MB)
|
|
49
|
+
* @param bytes - Size in bytes
|
|
50
|
+
* @returns Formatted string with appropriate unit
|
|
51
|
+
*/
|
|
52
|
+
export function formatSize(bytes) {
|
|
53
|
+
if (bytes < 1024) {
|
|
54
|
+
return `${bytes} B`;
|
|
55
|
+
}
|
|
56
|
+
const kb = bytes / 1024;
|
|
57
|
+
if (kb < 1024) {
|
|
58
|
+
return `${kb.toFixed(1)} KB`;
|
|
59
|
+
}
|
|
60
|
+
const mb = kb / 1024;
|
|
61
|
+
return `${mb.toFixed(1)} MB`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Logs startup banner for the dev server
|
|
65
|
+
* @param options - URLs for client, server, and events endpoints
|
|
66
|
+
*/
|
|
67
|
+
export function logDevServerBanner(options) {
|
|
68
|
+
console.log('');
|
|
69
|
+
console.log(`${icons.rocket} Bkper App Development Server`);
|
|
70
|
+
console.log('');
|
|
71
|
+
if (options.clientUrl) {
|
|
72
|
+
console.log(` ${options.clientUrl}`);
|
|
73
|
+
}
|
|
74
|
+
if (options.tunnelUrl) {
|
|
75
|
+
console.log(` Events: ${options.tunnelUrl} (tunneled)`);
|
|
76
|
+
}
|
|
77
|
+
console.log('');
|
|
78
|
+
console.log(' Press Ctrl+C to stop');
|
|
79
|
+
console.log('');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Logs build results with file sizes
|
|
83
|
+
* @param results - Build output paths and sizes
|
|
84
|
+
*/
|
|
85
|
+
export function logBuildResults(results) {
|
|
86
|
+
console.log('');
|
|
87
|
+
console.log(`${icons.package} Building Bkper App...`);
|
|
88
|
+
console.log('');
|
|
89
|
+
if (results.webClient) {
|
|
90
|
+
console.log(` \u2713 Web client \u2192 ${results.webClient.path.padEnd(20)} (${formatSize(results.webClient.size)})`);
|
|
91
|
+
}
|
|
92
|
+
if (results.webServer) {
|
|
93
|
+
console.log(` \u2713 Web server \u2192 ${results.webServer.path.padEnd(20)} (${formatSize(results.webServer.size)})`);
|
|
94
|
+
}
|
|
95
|
+
if (results.events) {
|
|
96
|
+
console.log(` \u2713 Events \u2192 ${results.events.path.padEnd(20)} (${formatSize(results.events.size)})`);
|
|
97
|
+
}
|
|
98
|
+
console.log('');
|
|
99
|
+
console.log(`${icons.success} Build complete`);
|
|
100
|
+
console.log('');
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/dev/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;GAEG;AACH,MAAM,KAAK,GAAG;IACV,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,cAAc;IACtB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,cAAc;IACtB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,cAAc;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC1C,MAAM,aAAa,GAAG,CAAC,OAAe,EAAE,IAAa,EAAU,EAAE;QAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,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,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CACP,kCAAkC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,UAAU,CAC3E,OAAO,CAAC,MAAM,CAAC,IAAI,CACtB,GAAG,CACP,CAAC;IACN,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Miniflare } from 'miniflare';
|
|
2
|
+
export interface WorkerServerOptions {
|
|
3
|
+
port: number;
|
|
4
|
+
kvNamespaces?: string[];
|
|
5
|
+
vars?: Record<string, string>;
|
|
6
|
+
compatibilityDate?: string;
|
|
7
|
+
persist?: boolean;
|
|
8
|
+
persistPath?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates and starts a Miniflare instance for local Worker development
|
|
12
|
+
*
|
|
13
|
+
* @param entryPoint - Path to TypeScript Worker entry file
|
|
14
|
+
* @param options - Server configuration options
|
|
15
|
+
* @returns Configured and ready Miniflare instance
|
|
16
|
+
*/
|
|
17
|
+
export declare function createWorkerServer(entryPoint: string, options: WorkerServerOptions): Promise<Miniflare>;
|
|
18
|
+
/**
|
|
19
|
+
* Reloads a Worker with new code (hot reload)
|
|
20
|
+
* Rebuilds the entry point and updates Miniflare
|
|
21
|
+
*
|
|
22
|
+
* @param mf - Existing Miniflare instance
|
|
23
|
+
* @param entryPoint - Path to TypeScript Worker entry file
|
|
24
|
+
*/
|
|
25
|
+
export declare function reloadWorker(mf: Miniflare, entryPoint: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Gracefully stops a Miniflare instance
|
|
28
|
+
*
|
|
29
|
+
* @param mf - Miniflare instance to stop
|
|
30
|
+
*/
|
|
31
|
+
export declare function stopWorkerServer(mf: Miniflare): Promise<void>;
|
|
32
|
+
//# sourceMappingURL=miniflare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"miniflare.d.ts","sourceRoot":"","sources":["../../src/dev/miniflare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,WAAW,CAAC;AAGrD,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAuBD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACpC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,mBAAmB,GAC7B,OAAO,CAAC,SAAS,CAAC,CAqDpB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BnF;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Miniflare, Log, LogLevel } from 'miniflare';
|
|
11
|
+
import { buildWorker } from './esbuild.js';
|
|
12
|
+
/**
|
|
13
|
+
* Store the base configuration for each Miniflare instance to support hot reload.
|
|
14
|
+
* Maps Miniflare instance to its base configuration (without modules).
|
|
15
|
+
*/
|
|
16
|
+
const instanceConfigs = new WeakMap();
|
|
17
|
+
/**
|
|
18
|
+
* Creates and starts a Miniflare instance for local Worker development
|
|
19
|
+
*
|
|
20
|
+
* @param entryPoint - Path to TypeScript Worker entry file
|
|
21
|
+
* @param options - Server configuration options
|
|
22
|
+
* @returns Configured and ready Miniflare instance
|
|
23
|
+
*/
|
|
24
|
+
export function createWorkerServer(entryPoint, options) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
// Build the Worker code from TypeScript
|
|
28
|
+
const script = yield buildWorker(entryPoint);
|
|
29
|
+
// Build the base configuration (without modules) for hot reload support
|
|
30
|
+
const baseConfig = {
|
|
31
|
+
// Server port
|
|
32
|
+
port: options.port,
|
|
33
|
+
// Compatibility settings (match production)
|
|
34
|
+
compatibilityDate: options.compatibilityDate || '2026-01-29',
|
|
35
|
+
compatibilityFlags: ['nodejs_compat'],
|
|
36
|
+
// Logging
|
|
37
|
+
log: new Log(LogLevel.INFO),
|
|
38
|
+
// Live reload (inject script into HTML responses)
|
|
39
|
+
liveReload: true,
|
|
40
|
+
// KV namespaces - convert array to object format
|
|
41
|
+
// ["KV"] -> { KV: "kv-local" }
|
|
42
|
+
kvNamespaces: (_a = options.kvNamespaces) === null || _a === void 0 ? void 0 : _a.reduce((acc, ns) => (Object.assign(Object.assign({}, acc), { [ns]: `${ns.toLowerCase()}-local` })), {}),
|
|
43
|
+
// Persist KV data across restarts
|
|
44
|
+
kvPersist: options.persist !== false ? (_b = options.persistPath) !== null && _b !== void 0 ? _b : './.mf/kv' : undefined,
|
|
45
|
+
// Environment variables and secrets
|
|
46
|
+
bindings: options.vars,
|
|
47
|
+
};
|
|
48
|
+
const mf = new Miniflare(Object.assign(Object.assign({}, baseConfig), {
|
|
49
|
+
// Use modules array format instead of script string
|
|
50
|
+
// This allows Miniflare to properly handle dynamic imports of external modules
|
|
51
|
+
// like cloudflare:workers that are used by libraries (e.g., Hono)
|
|
52
|
+
modules: [
|
|
53
|
+
{
|
|
54
|
+
type: 'ESModule',
|
|
55
|
+
path: 'index.js', // Virtual path for the bundled module
|
|
56
|
+
contents: script,
|
|
57
|
+
},
|
|
58
|
+
] }));
|
|
59
|
+
// Store the base config for hot reload
|
|
60
|
+
instanceConfigs.set(mf, baseConfig);
|
|
61
|
+
// Wait for Miniflare to be ready
|
|
62
|
+
yield mf.ready;
|
|
63
|
+
return mf;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Reloads a Worker with new code (hot reload)
|
|
68
|
+
* Rebuilds the entry point and updates Miniflare
|
|
69
|
+
*
|
|
70
|
+
* @param mf - Existing Miniflare instance
|
|
71
|
+
* @param entryPoint - Path to TypeScript Worker entry file
|
|
72
|
+
*/
|
|
73
|
+
export function reloadWorker(mf, entryPoint) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const script = yield buildWorker(entryPoint);
|
|
76
|
+
// Retrieve the stored base config
|
|
77
|
+
const baseConfig = instanceConfigs.get(mf);
|
|
78
|
+
if (!baseConfig) {
|
|
79
|
+
// Fallback: use minimal config if no stored config (shouldn't happen normally)
|
|
80
|
+
yield mf.setOptions({
|
|
81
|
+
modules: [
|
|
82
|
+
{
|
|
83
|
+
type: 'ESModule',
|
|
84
|
+
path: 'index.js',
|
|
85
|
+
contents: script,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Apply the full config with new modules
|
|
92
|
+
yield mf.setOptions(Object.assign(Object.assign({}, baseConfig), { modules: [
|
|
93
|
+
{
|
|
94
|
+
type: 'ESModule',
|
|
95
|
+
path: 'index.js',
|
|
96
|
+
contents: script,
|
|
97
|
+
},
|
|
98
|
+
] }));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Gracefully stops a Miniflare instance
|
|
103
|
+
*
|
|
104
|
+
* @param mf - Miniflare instance to stop
|
|
105
|
+
*/
|
|
106
|
+
export function stopWorkerServer(mf) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
yield mf.dispose();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=miniflare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"miniflare.js","sourceRoot":"","sources":["../../src/dev/miniflare.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA0B3C;;;GAGG;AACH,MAAM,eAAe,GAAG,IAAI,OAAO,EAAyB,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,UAAgB,kBAAkB,CACpC,UAAkB,EAClB,OAA4B;;;QAE5B,wCAAwC;QACxC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,CAAC;QAE7C,wEAAwE;QACxE,MAAM,UAAU,GAAe;YAC3B,cAAc;YACd,IAAI,EAAE,OAAO,CAAC,IAAI;YAElB,4CAA4C;YAC5C,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,YAAY;YAC5D,kBAAkB,EAAE,CAAC,eAAe,CAAC;YAErC,UAAU;YACV,GAAG,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;YAE3B,kDAAkD;YAClD,U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U;wBAChB,QAAQ,EAAE,MAAM;qBACnB;iBACJ;aACJ,CAAC,CAAC;YACH,OAAO;QACX,CAAC;QAED,yCAAyC;QACzC,MAAM,EAAE,CAAC,UAAU,iCACZ,UAAU,KACb,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,UAAU;oBAChB,QAAQ,EAAE,MAAM;iBACnB;aACJ,IACH,CAAC;IACP,CAAC;CAAA;AAED;;;;GAIG;AACH,MAAM,UAAgB,gBAAgB,CAAC,EAAa;;QAChD,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/dev/preflight.ts"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACrB,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAiCD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,eAAe,CAuC/F"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
function getClientDependencyName(clientRoot) {
|
|
4
|
+
const pkgPath = path.join(clientRoot, 'package.json');
|
|
5
|
+
if (!fs.existsSync(pkgPath))
|
|
6
|
+
return undefined;
|
|
7
|
+
try {
|
|
8
|
+
const content = fs.readFileSync(pkgPath, 'utf8');
|
|
9
|
+
const pkg = JSON.parse(content);
|
|
10
|
+
const deps = pkg.dependencies || {};
|
|
11
|
+
const devDeps = pkg.devDependencies || {};
|
|
12
|
+
const depNames = Object.keys(deps).concat(Object.keys(devDeps));
|
|
13
|
+
if (depNames.includes('lit'))
|
|
14
|
+
return 'lit';
|
|
15
|
+
return depNames[0];
|
|
16
|
+
}
|
|
17
|
+
catch (_a) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function isDependencyInstalled(projectRoot, depName) {
|
|
22
|
+
const depPath = path.join(projectRoot, 'node_modules', depName, 'package.json');
|
|
23
|
+
return fs.existsSync(depPath);
|
|
24
|
+
}
|
|
25
|
+
function hasSharedPackage(projectRoot) {
|
|
26
|
+
return fs.existsSync(path.join(projectRoot, 'packages/shared'));
|
|
27
|
+
}
|
|
28
|
+
export function preflightDependencies(projectRoot, clientRoot) {
|
|
29
|
+
const rootPkgPath = path.join(projectRoot, 'package.json');
|
|
30
|
+
if (!fs.existsSync(rootPkgPath)) {
|
|
31
|
+
return {
|
|
32
|
+
ok: false,
|
|
33
|
+
message: 'Missing dependencies. Run bun install at the app root (no package.json found).',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const nodeModulesPath = path.join(projectRoot, 'node_modules');
|
|
37
|
+
if (!fs.existsSync(nodeModulesPath)) {
|
|
38
|
+
return {
|
|
39
|
+
ok: false,
|
|
40
|
+
message: 'Missing dependencies. Run bun install at the app root (node_modules not found).',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Check for TypeScript if shared package exists
|
|
44
|
+
if (hasSharedPackage(projectRoot) && !isDependencyInstalled(projectRoot, 'typescript')) {
|
|
45
|
+
return {
|
|
46
|
+
ok: false,
|
|
47
|
+
message: 'Missing TypeScript. Run bun install at the app root (required for shared package build).',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (clientRoot) {
|
|
51
|
+
const depName = getClientDependencyName(clientRoot);
|
|
52
|
+
if (depName && !isDependencyInstalled(projectRoot, depName)) {
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
message: `Missing client dependencies. Run bun install at the app root (cannot resolve ${depName}).`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { ok: true };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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