@kuratchi/js 0.0.19 → 0.0.21
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.md +193 -7
- package/dist/cli.js +8 -0
- package/dist/compiler/client-module-pipeline.d.ts +8 -0
- package/dist/compiler/client-module-pipeline.js +181 -30
- package/dist/compiler/compiler-shared.d.ts +23 -0
- package/dist/compiler/component-pipeline.js +9 -1
- package/dist/compiler/config-reading.js +27 -1
- package/dist/compiler/convention-discovery.d.ts +2 -0
- package/dist/compiler/convention-discovery.js +16 -0
- package/dist/compiler/durable-object-pipeline.d.ts +1 -0
- package/dist/compiler/durable-object-pipeline.js +459 -119
- package/dist/compiler/index.js +40 -1
- package/dist/compiler/page-route-pipeline.js +31 -2
- package/dist/compiler/parser.d.ts +1 -0
- package/dist/compiler/parser.js +47 -4
- package/dist/compiler/root-layout-pipeline.js +18 -3
- package/dist/compiler/route-pipeline.d.ts +2 -0
- package/dist/compiler/route-pipeline.js +19 -3
- package/dist/compiler/routes-module-feature-blocks.js +143 -17
- package/dist/compiler/routes-module-types.d.ts +1 -0
- package/dist/compiler/server-module-pipeline.js +24 -0
- package/dist/compiler/template.d.ts +4 -0
- package/dist/compiler/template.js +50 -18
- package/dist/compiler/type-generator.d.ts +8 -0
- package/dist/compiler/type-generator.js +124 -0
- package/dist/compiler/worker-output-pipeline.js +2 -0
- package/dist/compiler/wrangler-sync.d.ts +3 -0
- package/dist/compiler/wrangler-sync.js +25 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/runtime/context.d.ts +9 -1
- package/dist/runtime/context.js +25 -2
- package/dist/runtime/generated-worker.d.ts +1 -0
- package/dist/runtime/generated-worker.js +11 -7
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/navigation.d.ts +8 -0
- package/dist/runtime/navigation.js +8 -0
- package/dist/runtime/request.d.ts +28 -0
- package/dist/runtime/request.js +44 -0
- package/dist/runtime/schema.d.ts +49 -0
- package/dist/runtime/schema.js +148 -0
- package/dist/runtime/types.d.ts +2 -0
- package/dist/runtime/validation.d.ts +26 -0
- package/dist/runtime/validation.js +147 -0
- package/package.json +76 -68
|
@@ -170,7 +170,7 @@ export function readAuthConfig(projectDir) {
|
|
|
170
170
|
export function readDoConfig(projectDir) {
|
|
171
171
|
const configPath = path.join(projectDir, 'kuratchi.config.ts');
|
|
172
172
|
if (!fs.existsSync(configPath))
|
|
173
|
-
return
|
|
173
|
+
return readWranglerDoConfig(projectDir);
|
|
174
174
|
const source = fs.readFileSync(configPath, 'utf-8');
|
|
175
175
|
const doIdx = source.search(/durableObjects\s*:\s*\{/);
|
|
176
176
|
if (doIdx === -1)
|
|
@@ -229,6 +229,32 @@ export function readDoConfig(projectDir) {
|
|
|
229
229
|
}
|
|
230
230
|
return entries;
|
|
231
231
|
}
|
|
232
|
+
/** Read durable_objects.bindings from wrangler.jsonc / wrangler.json as fallback. */
|
|
233
|
+
function readWranglerDoConfig(projectDir) {
|
|
234
|
+
const candidates = ['wrangler.jsonc', 'wrangler.json'];
|
|
235
|
+
const wranglerPath = candidates
|
|
236
|
+
.map((file) => path.join(projectDir, file))
|
|
237
|
+
.find((filePath) => fs.existsSync(filePath));
|
|
238
|
+
if (!wranglerPath)
|
|
239
|
+
return [];
|
|
240
|
+
const source = fs.readFileSync(wranglerPath, 'utf-8');
|
|
241
|
+
const bindingsMatch = source.match(/"durable_objects"\s*:\s*\{[\s\S]*?"bindings"\s*:\s*\[([\s\S]*?)\][\s\S]*?\}/);
|
|
242
|
+
if (!bindingsMatch)
|
|
243
|
+
return [];
|
|
244
|
+
const bindingsBody = bindingsMatch[1];
|
|
245
|
+
const entries = [];
|
|
246
|
+
const objectRegex = /\{([\s\S]*?)\}/g;
|
|
247
|
+
let m;
|
|
248
|
+
while ((m = objectRegex.exec(bindingsBody)) !== null) {
|
|
249
|
+
const body = m[1];
|
|
250
|
+
const bindingMatch = body.match(/"name"\s*:\s*"([^"]+)"/);
|
|
251
|
+
const classMatch = body.match(/"class_name"\s*:\s*"([^"]+)"/);
|
|
252
|
+
if (!bindingMatch || !classMatch)
|
|
253
|
+
continue;
|
|
254
|
+
entries.push({ binding: bindingMatch[1], className: classMatch[1] });
|
|
255
|
+
}
|
|
256
|
+
return entries;
|
|
257
|
+
}
|
|
232
258
|
export function readWorkerClassConfig(projectDir, key) {
|
|
233
259
|
const configPath = path.join(projectDir, 'kuratchi.config.ts');
|
|
234
260
|
if (!fs.existsSync(configPath))
|
|
@@ -5,5 +5,7 @@ export declare function resolveClassExportFromFile(absPath: string, errorLabel:
|
|
|
5
5
|
};
|
|
6
6
|
export declare function discoverConventionClassFiles(projectDir: string, dir: string, suffix: string, errorLabel: string): ConventionClassEntry[];
|
|
7
7
|
export declare function discoverFilesWithSuffix(dir: string, suffix: string): string[];
|
|
8
|
+
/** Returns all files in a directory (non-recursive) whose extension is one of the given extensions. */
|
|
9
|
+
export declare function discoverFilesWithExtensions(dir: string, extensions: string[]): string[];
|
|
8
10
|
export declare function discoverWorkflowFiles(projectDir: string): WorkerClassConfigEntry[];
|
|
9
11
|
export declare function discoverContainerFiles(projectDir: string): WorkerClassConfigEntry[];
|
|
@@ -47,6 +47,22 @@ export function discoverFilesWithSuffix(dir, suffix) {
|
|
|
47
47
|
walk(dir);
|
|
48
48
|
return out;
|
|
49
49
|
}
|
|
50
|
+
/** Returns all files in a directory (non-recursive) whose extension is one of the given extensions. */
|
|
51
|
+
export function discoverFilesWithExtensions(dir, extensions) {
|
|
52
|
+
if (!fs.existsSync(dir))
|
|
53
|
+
return [];
|
|
54
|
+
const extSet = new Set(extensions.map((e) => e.toLowerCase()));
|
|
55
|
+
const out = [];
|
|
56
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
57
|
+
if (!entry.isFile())
|
|
58
|
+
continue;
|
|
59
|
+
const ext = path.extname(entry.name).toLowerCase();
|
|
60
|
+
if (extSet.has(ext)) {
|
|
61
|
+
out.push(path.join(dir, entry.name));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
50
66
|
export function discoverWorkflowFiles(projectDir) {
|
|
51
67
|
const serverDir = path.join(projectDir, 'src', 'server');
|
|
52
68
|
const files = discoverFilesWithSuffix(serverDir, '.workflow.ts');
|