localflare-core 0.2.0-beta.2 → 0.2.0-beta.4

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.
Files changed (2) hide show
  1. package/README.md +73 -37
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # localflare-core
2
2
 
3
- Core Miniflare wrapper and configuration parser for [Localflare](https://www.npmjs.com/package/localflare).
3
+ Core configuration parser and utilities for [Localflare](https://www.npmjs.com/package/localflare).
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/localflare-core.svg)](https://www.npmjs.com/package/localflare-core)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
8
  ## Overview
9
9
 
10
- This package provides the core functionality for Localflare:
10
+ This package provides core utilities for Localflare:
11
11
 
12
- - **Miniflare Integration** - Wraps Miniflare to provide a consistent API for running Cloudflare Workers locally
13
- - **Config Parser** - Reads and parses `wrangler.toml` configuration files
14
- - **Bindings Support** - Full support for D1, KV, R2, Durable Objects, Queues, and more
12
+ - **Config Parser** - Reads and parses `wrangler.toml` / `wrangler.json` / `wrangler.jsonc` configuration files
13
+ - **Binding Discovery** - Extracts D1, KV, R2, Durable Objects, and Queue binding configurations
14
+ - **Type Definitions** - TypeScript types for wrangler configuration and Localflare manifests
15
15
 
16
16
  ## Installation
17
17
 
@@ -24,52 +24,88 @@ pnpm add localflare-core
24
24
  ## Usage
25
25
 
26
26
  ```typescript
27
- import { LocalFlareCore } from 'localflare-core';
27
+ import {
28
+ parseWranglerConfig,
29
+ findWranglerConfig,
30
+ WRANGLER_CONFIG_FILES
31
+ } from 'localflare-core';
32
+
33
+ // Find wrangler config in current directory
34
+ const configPath = findWranglerConfig(process.cwd());
35
+ // Returns: ./wrangler.toml, ./wrangler.json, or ./wrangler.jsonc
36
+
37
+ // Parse the configuration
38
+ const config = parseWranglerConfig(configPath);
39
+
40
+ // Access binding configurations
41
+ console.log(config.d1_databases); // D1 database bindings
42
+ console.log(config.kv_namespaces); // KV namespace bindings
43
+ console.log(config.r2_buckets); // R2 bucket bindings
44
+ console.log(config.durable_objects); // Durable Object bindings
45
+ console.log(config.queues); // Queue producer/consumer config
46
+ ```
28
47
 
29
- const core = new LocalFlareCore({
30
- configPath: './wrangler.toml',
31
- port: 8787,
32
- persist: '.localflare'
33
- });
48
+ ## API Reference
34
49
 
35
- // Start the worker
36
- await core.start();
50
+ ### `findWranglerConfig(directory: string): string | null`
37
51
 
38
- // Access bindings programmatically
39
- const bindings = core.getBindings();
52
+ Searches for a wrangler configuration file in the specified directory.
40
53
 
41
- // Get D1 databases
42
- const d1Databases = bindings.d1;
54
+ ```typescript
55
+ const configPath = findWranglerConfig('/path/to/project');
56
+ // Returns: '/path/to/project/wrangler.toml' or null
57
+ ```
43
58
 
44
- // Get KV namespaces
45
- const kvNamespaces = bindings.kv;
59
+ ### `parseWranglerConfig(configPath: string): WranglerConfig`
46
60
 
47
- // Stop when done
48
- await core.stop();
61
+ Parses a wrangler configuration file (TOML, JSON, or JSONC format).
62
+
63
+ ```typescript
64
+ const config = parseWranglerConfig('./wrangler.toml');
49
65
  ```
50
66
 
51
- ## Supported Bindings
52
-
53
- | Binding | Support |
54
- |---------|---------|
55
- | D1 | ✅ Full |
56
- | KV | ✅ Full |
57
- | R2 | ✅ Full |
58
- | Durable Objects | ✅ Full |
59
- | Queues | ✅ Full |
60
- | Service Bindings | ✅ Full |
61
- | Cache API | ✅ Full |
62
- | Hyperdrive | ✅ Full |
63
- | Vectorize | ⚠️ Limited |
64
- | Workers AI | ⚠️ Mock |
67
+ ### `WRANGLER_CONFIG_FILES`
68
+
69
+ Array of supported config file names: `['wrangler.toml', 'wrangler.json', 'wrangler.jsonc']`
70
+
71
+ ## Types
72
+
73
+ ```typescript
74
+ interface WranglerConfig {
75
+ name?: string;
76
+ main?: string;
77
+ compatibility_date?: string;
78
+ d1_databases?: D1DatabaseConfig[];
79
+ kv_namespaces?: KVNamespaceConfig[];
80
+ r2_buckets?: R2BucketConfig[];
81
+ durable_objects?: { bindings: DurableObjectConfig[] };
82
+ queues?: {
83
+ producers?: QueueProducerConfig[];
84
+ consumers?: QueueConsumerConfig[];
85
+ };
86
+ vars?: Record<string, string>;
87
+ // ... and more
88
+ }
89
+
90
+ interface LocalflareManifest {
91
+ name: string;
92
+ d1: { binding: string; database_name: string }[];
93
+ kv: { binding: string }[];
94
+ r2: { binding: string; bucket_name: string }[];
95
+ queues: {
96
+ producers: { binding: string; queue: string }[];
97
+ consumers: { queue: string; max_batch_size?: number; /* ... */ }[];
98
+ };
99
+ do: { binding: string; className: string }[];
100
+ }
101
+ ```
65
102
 
66
103
  ## Related Packages
67
104
 
68
105
  | Package | Description |
69
106
  |---------|-------------|
70
107
  | [`localflare`](https://www.npmjs.com/package/localflare) | CLI tool (main package) |
71
- | [`localflare-server`](https://www.npmjs.com/package/localflare-server) | Dashboard API server |
72
- | [`localflare-dashboard`](https://www.npmjs.com/package/localflare-dashboard) | React dashboard UI |
108
+ | [`localflare-api`](https://www.npmjs.com/package/localflare-api) | Dashboard API worker |
73
109
 
74
110
  ## License
75
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "localflare-core",
3
- "version": "0.2.0-beta.2",
3
+ "version": "0.2.0-beta.4",
4
4
  "description": "Core utilities for Localflare - config parsing and binding discovery",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",