@fluojs/runtime 2.0.1 → 3.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/README.ko.md +278 -20
- package/README.md +278 -20
- package/dist/adapters/internal-request-response-factory.d.ts +1 -1
- package/dist/adapters/internal-request-response-factory.d.ts.map +1 -1
- package/dist/adapters/internal-request-response-factory.js +1 -1
- package/dist/adapters/request-response-factory.d.ts +20 -1
- package/dist/adapters/request-response-factory.d.ts.map +1 -1
- package/dist/adapters/request-response-factory.js +75 -22
- package/dist/bootstrap.d.ts +3 -9
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +179 -75
- package/dist/devtools/contracts.d.ts +3 -135
- package/dist/devtools/contracts.d.ts.map +1 -1
- package/dist/devtools/index.d.ts +2 -3
- package/dist/devtools/index.d.ts.map +1 -1
- package/dist/devtools/index.js +1 -2
- package/dist/devtools/snapshot.d.ts +1 -1
- package/dist/devtools/snapshot.d.ts.map +1 -1
- package/dist/devtools/snapshot.js +18 -17
- package/dist/devtools/studio-request-observer.d.ts +14 -0
- package/dist/devtools/studio-request-observer.d.ts.map +1 -0
- package/dist/devtools/studio-request-observer.js +112 -0
- package/dist/devtools/studio-runtime-config.d.ts +25 -0
- package/dist/devtools/studio-runtime-config.d.ts.map +1 -0
- package/dist/devtools/studio-runtime-config.js +59 -0
- package/dist/devtools/studio-runtime.d.ts +12 -18
- package/dist/devtools/studio-runtime.d.ts.map +1 -1
- package/dist/devtools/studio-runtime.js +25 -169
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +38 -0
- package/dist/health/health.d.ts +6 -2
- package/dist/health/health.d.ts.map +1 -1
- package/dist/health/health.js +3 -2
- package/dist/http-adapter-shared.d.ts +1 -1
- package/dist/http-adapter-shared.d.ts.map +1 -1
- package/dist/http-adapter-shared.js +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/internal/route-inspection-metadata.d.ts +30 -0
- package/dist/internal/route-inspection-metadata.d.ts.map +1 -0
- package/dist/internal/route-inspection-metadata.js +68 -0
- package/dist/internal.d.ts +6 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +4 -1
- package/dist/module-definition.d.ts +10 -0
- package/dist/module-definition.d.ts.map +1 -0
- package/dist/module-definition.js +12 -0
- package/dist/module-graph.d.ts +41 -0
- package/dist/module-graph.d.ts.map +1 -1
- package/dist/module-graph.js +108 -13
- package/dist/multipart.d.ts +67 -3
- package/dist/multipart.d.ts.map +1 -1
- package/dist/multipart.js +665 -103
- package/dist/platform-component-registry.d.ts +9 -0
- package/dist/platform-component-registry.d.ts.map +1 -0
- package/dist/platform-component-registry.js +70 -0
- package/dist/platform-diagnostic-retention.d.ts +13 -0
- package/dist/platform-diagnostic-retention.d.ts.map +1 -0
- package/dist/platform-diagnostic-retention.js +43 -0
- package/dist/platform-shell-probe-reports.d.ts +8 -0
- package/dist/platform-shell-probe-reports.d.ts.map +1 -0
- package/dist/platform-shell-probe-reports.js +95 -0
- package/dist/platform-shell-probes.d.ts +16 -0
- package/dist/platform-shell-probes.d.ts.map +1 -0
- package/dist/platform-shell-probes.js +141 -0
- package/dist/platform-shell.d.ts +7 -13
- package/dist/platform-shell.d.ts.map +1 -1
- package/dist/platform-shell.js +58 -310
- package/dist/retryable-shutdown.d.ts +7 -0
- package/dist/retryable-shutdown.d.ts.map +1 -0
- package/dist/retryable-shutdown.js +20 -0
- package/dist/route-inspection.d.ts +56 -0
- package/dist/route-inspection.d.ts.map +1 -0
- package/dist/route-inspection.js +80 -0
- package/dist/tokens.d.ts +6 -4
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +5 -0
- package/dist/types.d.ts +53 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/web.d.ts +22 -3
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +80 -34
- package/package.json +13 -26
- package/dist/internal-node.d.ts +0 -2
- package/dist/internal-node.d.ts.map +0 -1
- package/dist/internal-node.js +0 -1
- package/dist/logging/json-logger.d.ts +0 -8
- package/dist/logging/json-logger.d.ts.map +0 -1
- package/dist/logging/json-logger.js +0 -45
- package/dist/logging/logger.d.ts +0 -37
- package/dist/logging/logger.d.ts.map +0 -1
- package/dist/logging/logger.js +0 -103
- package/dist/node/internal-node-compression.d.ts +0 -22
- package/dist/node/internal-node-compression.d.ts.map +0 -1
- package/dist/node/internal-node-compression.js +0 -84
- package/dist/node/internal-node-request.d.ts +0 -162
- package/dist/node/internal-node-request.d.ts.map +0 -1
- package/dist/node/internal-node-request.js +0 -478
- package/dist/node/internal-node-response.d.ts +0 -28
- package/dist/node/internal-node-response.d.ts.map +0 -1
- package/dist/node/internal-node-response.js +0 -205
- package/dist/node/internal-node-shutdown.d.ts +0 -34
- package/dist/node/internal-node-shutdown.d.ts.map +0 -1
- package/dist/node/internal-node-shutdown.js +0 -83
- package/dist/node/internal-node.d.ts +0 -111
- package/dist/node/internal-node.d.ts.map +0 -1
- package/dist/node/internal-node.js +0 -283
- package/dist/node/node-compression.d.ts +0 -2
- package/dist/node/node-compression.d.ts.map +0 -1
- package/dist/node/node-compression.js +0 -1
- package/dist/node/node-request.d.ts +0 -2
- package/dist/node/node-request.d.ts.map +0 -1
- package/dist/node/node-request.js +0 -1
- package/dist/node/node-response.d.ts +0 -2
- package/dist/node/node-response.d.ts.map +0 -1
- package/dist/node/node-response.js +0 -1
- package/dist/node/node-shutdown.d.ts +0 -2
- package/dist/node/node-shutdown.d.ts.map +0 -1
- package/dist/node/node-shutdown.js +0 -1
- package/dist/node/node.d.ts +0 -2
- package/dist/node/node.d.ts.map +0 -1
- package/dist/node/node.js +0 -1
- package/dist/node.d.ts +0 -5
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -3
package/dist/module-graph.d.ts
CHANGED
|
@@ -8,6 +8,47 @@ import type { BootstrapModuleOptions, CompiledModule, ModuleType } from './types
|
|
|
8
8
|
* @returns The token that should be registered and resolved for the provider.
|
|
9
9
|
*/
|
|
10
10
|
export declare function providerToken(provider: Provider): Token;
|
|
11
|
+
/**
|
|
12
|
+
* Bounds retained module graph compile snapshots for an owning application or host.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Cache reads update recency. Call {@link dispose} when the owner no longer needs
|
|
16
|
+
* cache hits so retained module constructors and compiled graph snapshots are released.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ModuleGraphCompileCache {
|
|
19
|
+
private readonly maxEntries;
|
|
20
|
+
private disposed;
|
|
21
|
+
private readonly entries;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a bounded module graph compile cache.
|
|
24
|
+
*
|
|
25
|
+
* @param maxEntries Maximum successful compile snapshots retained by this cache.
|
|
26
|
+
* @throws {RangeError} When `maxEntries` is not a positive safe integer.
|
|
27
|
+
*/
|
|
28
|
+
constructor(maxEntries?: number);
|
|
29
|
+
/**
|
|
30
|
+
* Reads a snapshot and updates its recency.
|
|
31
|
+
*
|
|
32
|
+
* @param key Cache key for the requested compile input.
|
|
33
|
+
* @returns The retained snapshot when available and not disposed.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
get(key: string): readonly CompiledModule[] | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Retains a successful snapshot and evicts the least-recently-used entry when full.
|
|
40
|
+
*
|
|
41
|
+
* @param key Cache key for the compile input.
|
|
42
|
+
* @param snapshot Isolated successful compile snapshot to retain.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
set(key: string, snapshot: readonly CompiledModule[]): void;
|
|
47
|
+
/** Releases every retained snapshot and permanently disables future cache retention. */
|
|
48
|
+
dispose(): void;
|
|
49
|
+
/** Returns the number of compile snapshots currently retained. */
|
|
50
|
+
get size(): number;
|
|
51
|
+
}
|
|
11
52
|
/** Clears the process-local module graph compile cache for isolated regression tests. */
|
|
12
53
|
export declare function clearModuleGraphCompileCacheForTesting(): void;
|
|
13
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-graph.d.ts","sourceRoot":"","sources":["../src/module-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"module-graph.d.ts","sourceRoot":"","sources":["../src/module-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AAe5E,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EAGd,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAMvD;AAkBD;;;;;;GAMG;AACH,qBAAa,uBAAuB;IAUtB,OAAO,CAAC,QAAQ,CAAC,UAAU;IATvC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;IAExE;;;;;OAKG;gBAC0B,UAAU,SAAqC;IAM5E;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,GAAG,SAAS;IAgBvD;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,IAAI;IAkB3D,wFAAwF;IACxF,OAAO,IAAI,IAAI;IAKf,kEAAkE;IAClE,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAID,yFAAyF;AACzF,wBAAgB,sCAAsC,IAAI,IAAI,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,IAAI,MAAM,CAEjE;AA2FD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,MAAM,CAc9G;AAqRD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,GAAE,QAAQ,EAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAE5E;AAgYD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,cAAc,EAAE,CAkCjH"}
|
package/dist/module-graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { validateProviderInputs } from '@fluojs/di/internal';
|
|
2
|
-
import { getRuntimeClassDiMetadata, getRuntimeClassDiMetadataVersion, getOwnRuntimeClassDiMetadata, getRuntimeModuleMetadata, getRuntimeModuleMetadataVersion } from './internal/core-metadata.js';
|
|
3
2
|
import { ModuleGraphError, ModuleInjectionMetadataError, ModuleVisibilityError } from './errors.js';
|
|
3
|
+
import { getOwnRuntimeClassDiMetadata, getRuntimeClassDiMetadata, getRuntimeClassDiMetadataVersion, getRuntimeModuleMetadata, getRuntimeModuleMetadataVersion } from './internal/core-metadata.js';
|
|
4
4
|
/**
|
|
5
5
|
* Returns the public token represented by a provider declaration.
|
|
6
6
|
*
|
|
@@ -16,13 +16,94 @@ export function providerToken(provider) {
|
|
|
16
16
|
const objectTokenIds = new WeakMap();
|
|
17
17
|
const symbolTokenIds = new Map();
|
|
18
18
|
let nextTokenId = 0;
|
|
19
|
-
const MODULE_GRAPH_COMPILE_ALGORITHM_VERSION =
|
|
20
|
-
const
|
|
19
|
+
const MODULE_GRAPH_COMPILE_ALGORITHM_VERSION = 2;
|
|
20
|
+
const DEFAULT_MODULE_GRAPH_CACHE_ENTRIES = 100;
|
|
21
21
|
const EMPTY_MODULE_REPLACEMENTS = new Map();
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Bounds retained module graph compile snapshots for an owning application or host.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* Cache reads update recency. Call {@link dispose} when the owner no longer needs
|
|
28
|
+
* cache hits so retained module constructors and compiled graph snapshots are released.
|
|
29
|
+
*/
|
|
30
|
+
export class ModuleGraphCompileCache {
|
|
31
|
+
disposed = false;
|
|
32
|
+
entries = new Map();
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Creates a bounded module graph compile cache.
|
|
36
|
+
*
|
|
37
|
+
* @param maxEntries Maximum successful compile snapshots retained by this cache.
|
|
38
|
+
* @throws {RangeError} When `maxEntries` is not a positive safe integer.
|
|
39
|
+
*/
|
|
40
|
+
constructor(maxEntries = DEFAULT_MODULE_GRAPH_CACHE_ENTRIES) {
|
|
41
|
+
this.maxEntries = maxEntries;
|
|
42
|
+
if (!Number.isSafeInteger(maxEntries) || maxEntries <= 0) {
|
|
43
|
+
throw new RangeError('Module graph cache maxEntries must be a positive safe integer.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Reads a snapshot and updates its recency.
|
|
49
|
+
*
|
|
50
|
+
* @param key Cache key for the requested compile input.
|
|
51
|
+
* @returns The retained snapshot when available and not disposed.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
get(key) {
|
|
56
|
+
if (this.disposed) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const snapshot = this.entries.get(key);
|
|
60
|
+
if (snapshot === undefined) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
this.entries.delete(key);
|
|
64
|
+
this.entries.set(key, snapshot);
|
|
65
|
+
return snapshot;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Retains a successful snapshot and evicts the least-recently-used entry when full.
|
|
70
|
+
*
|
|
71
|
+
* @param key Cache key for the compile input.
|
|
72
|
+
* @param snapshot Isolated successful compile snapshot to retain.
|
|
73
|
+
*
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
set(key, snapshot) {
|
|
77
|
+
if (this.disposed) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.entries.delete(key);
|
|
81
|
+
this.entries.set(key, snapshot);
|
|
82
|
+
if (this.entries.size <= this.maxEntries) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const oldest = this.entries.keys().next();
|
|
86
|
+
if (!oldest.done) {
|
|
87
|
+
this.entries.delete(oldest.value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Releases every retained snapshot and permanently disables future cache retention. */
|
|
92
|
+
dispose() {
|
|
93
|
+
this.entries.clear();
|
|
94
|
+
this.disposed = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Returns the number of compile snapshots currently retained. */
|
|
98
|
+
get size() {
|
|
99
|
+
return this.entries.size;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
let moduleGraphCompileCache = new ModuleGraphCompileCache();
|
|
103
|
+
|
|
23
104
|
/** Clears the process-local module graph compile cache for isolated regression tests. */
|
|
24
105
|
export function clearModuleGraphCompileCacheForTesting() {
|
|
25
|
-
moduleGraphCompileCache
|
|
106
|
+
moduleGraphCompileCache = new ModuleGraphCompileCache();
|
|
26
107
|
}
|
|
27
108
|
|
|
28
109
|
/**
|
|
@@ -325,6 +406,9 @@ function providerDependencies(provider) {
|
|
|
325
406
|
if ('useClass' in provider) {
|
|
326
407
|
return provider.inject ?? [...(getEffectiveClassDiMetadata(provider.useClass)?.inject ?? [])];
|
|
327
408
|
}
|
|
409
|
+
if ('useExisting' in provider) {
|
|
410
|
+
return [provider.useExisting];
|
|
411
|
+
}
|
|
328
412
|
return [];
|
|
329
413
|
}
|
|
330
414
|
function controllerDependencies(controller) {
|
|
@@ -474,11 +558,14 @@ function memoizeAccessibleTokenSet(compiledModule, importedModules, runtimeProvi
|
|
|
474
558
|
compiledModule.importedExportedTokens = createImportedExportedTokenSet(importedModules);
|
|
475
559
|
compiledModule.accessibleTokens = createAccessibleTokenSet(runtimeProviderTokens, compiledModule.providerTokens, compiledModule.importedExportedTokens, globalExportedTokens);
|
|
476
560
|
}
|
|
477
|
-
function validateProviderVisibility(compiledModule, scope, accessibleTokens) {
|
|
561
|
+
function validateProviderVisibility(compiledModule, scope, accessibleTokens, registeredTokens) {
|
|
478
562
|
for (const provider of compiledModule.definition.providers ?? []) {
|
|
479
563
|
validateProviderInjectionMetadata(provider, scope);
|
|
480
564
|
for (const rawToken of providerDependencies(provider)) {
|
|
481
565
|
const token = resolveInjectionToken(rawToken);
|
|
566
|
+
if (isOptionalToken(rawToken) && !accessibleTokens.has(token) && !registeredTokens.has(token)) {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
482
569
|
if (!accessibleTokens.has(token)) {
|
|
483
570
|
throw new ModuleVisibilityError(`Provider ${String(providerToken(provider))} in module ${compiledModule.type.name} cannot access token ${String(token)} because it is not local, not exported by an imported module, and not visible through a global module.`, {
|
|
484
571
|
module: compiledModule.type.name,
|
|
@@ -490,11 +577,14 @@ function validateProviderVisibility(compiledModule, scope, accessibleTokens) {
|
|
|
490
577
|
}
|
|
491
578
|
}
|
|
492
579
|
}
|
|
493
|
-
function validateControllerVisibility(compiledModule, scope, accessibleTokens) {
|
|
580
|
+
function validateControllerVisibility(compiledModule, scope, accessibleTokens, registeredTokens) {
|
|
494
581
|
for (const controller of compiledModule.definition.controllers ?? []) {
|
|
495
582
|
validateControllerInjectionMetadata(controller, scope);
|
|
496
583
|
for (const rawToken of controllerDependencies(controller)) {
|
|
497
584
|
const token = resolveInjectionToken(rawToken);
|
|
585
|
+
if (isOptionalToken(rawToken) && !accessibleTokens.has(token) && !registeredTokens.has(token)) {
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
498
588
|
if (!accessibleTokens.has(token)) {
|
|
499
589
|
throw new ModuleVisibilityError(`Controller ${controller.name} in module ${compiledModule.type.name} cannot access token ${String(token)} because it is not local, not exported by an imported module, and not visible through a global module.`, {
|
|
500
590
|
module: compiledModule.type.name,
|
|
@@ -524,10 +614,14 @@ function createExportedTokenSet(compiledModule, importedExportedTokens) {
|
|
|
524
614
|
function validateCompiledModules(modules, runtimeProviders, runtimeProviderTokens) {
|
|
525
615
|
const compiledByType = new Map(modules.map(compiledModule => [compiledModule.type, compiledModule]));
|
|
526
616
|
const globalExportedTokens = new Set();
|
|
617
|
+
const registeredTokens = new Set(runtimeProviderTokens);
|
|
527
618
|
for (const provider of runtimeProviders) {
|
|
528
619
|
validateProviderInjectionMetadata(provider, 'bootstrap runtime');
|
|
529
620
|
}
|
|
530
621
|
for (const compiledModule of modules) {
|
|
622
|
+
for (const token of compiledModule.providerTokens) {
|
|
623
|
+
registeredTokens.add(token);
|
|
624
|
+
}
|
|
531
625
|
if (!compiledModule.definition.global) {
|
|
532
626
|
continue;
|
|
533
627
|
}
|
|
@@ -538,8 +632,8 @@ function validateCompiledModules(modules, runtimeProviders, runtimeProviderToken
|
|
|
538
632
|
for (const compiledModule of modules) {
|
|
539
633
|
const scope = `module ${compiledModule.type.name}`;
|
|
540
634
|
memoizeAccessibleTokenSet(compiledModule, resolveImportedModules(compiledModule, compiledByType), runtimeProviderTokens, globalExportedTokens);
|
|
541
|
-
validateProviderVisibility(compiledModule, scope, compiledModule.accessibleTokens);
|
|
542
|
-
validateControllerVisibility(compiledModule, scope, compiledModule.accessibleTokens);
|
|
635
|
+
validateProviderVisibility(compiledModule, scope, compiledModule.accessibleTokens, registeredTokens);
|
|
636
|
+
validateControllerVisibility(compiledModule, scope, compiledModule.accessibleTokens, registeredTokens);
|
|
543
637
|
compiledModule.exportedTokens = createExportedTokenSet(compiledModule, compiledModule.importedExportedTokens);
|
|
544
638
|
}
|
|
545
639
|
}
|
|
@@ -552,9 +646,10 @@ function validateCompiledModules(modules, runtimeProviders, runtimeProviderToken
|
|
|
552
646
|
* @returns Compiled modules in dependency order after visibility and injection validation succeed.
|
|
553
647
|
*/
|
|
554
648
|
export function compileModuleGraph(rootModule, options = {}) {
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
649
|
+
const cache = options.moduleGraphCache === true ? moduleGraphCompileCache : options.moduleGraphCache instanceof ModuleGraphCompileCache ? options.moduleGraphCache : undefined;
|
|
650
|
+
const cacheKey = cache !== undefined ? createModuleGraphCacheKey(rootModule, options) : undefined;
|
|
651
|
+
if (cache !== undefined && cacheKey !== undefined) {
|
|
652
|
+
const cachedModules = cache.get(cacheKey);
|
|
558
653
|
if (cachedModules !== undefined) {
|
|
559
654
|
return cloneCompiledModules(cachedModules);
|
|
560
655
|
}
|
|
@@ -565,9 +660,9 @@ export function compileModuleGraph(rootModule, options = {}) {
|
|
|
565
660
|
const moduleReplacements = options.moduleReplacements ?? EMPTY_MODULE_REPLACEMENTS;
|
|
566
661
|
compileModule(rootModule, runtimeProviderTokens, moduleReplacements, new Map(), new Set(), ordered);
|
|
567
662
|
validateCompiledModules(ordered, runtimeProviders, runtimeProviderTokens);
|
|
568
|
-
if (cacheKey !== undefined) {
|
|
663
|
+
if (cache !== undefined && cacheKey !== undefined) {
|
|
569
664
|
const cacheSnapshot = createModuleGraphCacheSnapshot(ordered);
|
|
570
|
-
|
|
665
|
+
cache.set(cacheKey, cacheSnapshot);
|
|
571
666
|
return cloneCompiledModules(cacheSnapshot);
|
|
572
667
|
}
|
|
573
668
|
return ordered;
|
package/dist/multipart.d.ts
CHANGED
|
@@ -9,11 +9,23 @@ export interface UploadedFile {
|
|
|
9
9
|
size: number;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Configures multipart parsing limits for
|
|
12
|
+
* Configures multipart parsing limits for fields, files, headers, and total payload size.
|
|
13
13
|
*/
|
|
14
14
|
export interface MultipartOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Selects bounded streaming defaults when an application adapter exposes multipart parts through `request.body`.
|
|
17
|
+
*
|
|
18
|
+
* `parseMultipart(...)` remains buffered regardless of this option so its established acceptance defaults stay intact.
|
|
19
|
+
*/
|
|
20
|
+
strategy?: 'buffered' | 'stream';
|
|
21
|
+
/** Maximum size in bytes for one non-file field. */
|
|
22
|
+
maxFieldSize?: number;
|
|
23
|
+
/** Maximum number of non-file fields. */
|
|
24
|
+
maxFields?: number;
|
|
15
25
|
maxFileSize?: number;
|
|
16
26
|
maxFiles?: number;
|
|
27
|
+
/** Maximum size in bytes for one part header block. */
|
|
28
|
+
maxHeaderSize?: number;
|
|
17
29
|
maxTotalSize?: number;
|
|
18
30
|
}
|
|
19
31
|
/**
|
|
@@ -30,16 +42,68 @@ export interface MultipartRequestLike {
|
|
|
30
42
|
body?: AsyncIterable<Uint8Array> | BodyInit | null;
|
|
31
43
|
headers: Headers | Readonly<Record<string, string | string[] | undefined>>;
|
|
32
44
|
method?: string;
|
|
45
|
+
signal?: AbortSignal;
|
|
33
46
|
url?: string;
|
|
34
47
|
[Symbol.asyncIterator]?(): AsyncIterator<Uint8Array>;
|
|
35
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* A decoded non-file multipart field.
|
|
51
|
+
*/
|
|
52
|
+
export interface MultipartFieldPart {
|
|
53
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
54
|
+
readonly kind: 'field';
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly value: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A multipart file whose bytes are read exactly once from a portable Web stream.
|
|
60
|
+
*/
|
|
61
|
+
export interface MultipartFilePart {
|
|
62
|
+
readonly contentType: string;
|
|
63
|
+
readonly filename: string;
|
|
64
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
65
|
+
readonly kind: 'file';
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly stream: ReadableStream<Uint8Array>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A typed item yielded by {@link parseMultipartStream}.
|
|
71
|
+
*/
|
|
72
|
+
export type MultipartPart = MultipartFieldPart | MultipartFilePart;
|
|
73
|
+
/**
|
|
74
|
+
* Signals that a multipart body has already been selected for buffered or streaming consumption.
|
|
75
|
+
*/
|
|
76
|
+
export declare class MultipartBodyConsumedError extends Error {
|
|
77
|
+
constructor();
|
|
78
|
+
}
|
|
36
79
|
/**
|
|
37
80
|
* Parses a multipart request into string fields and in-memory uploaded files.
|
|
38
81
|
*
|
|
39
82
|
* @param request - Web `Request` or request-like input carrying a multipart body.
|
|
40
|
-
* @param options - Multipart limits for file size, file count,
|
|
83
|
+
* @param options - Multipart limits for file size, file count, total size, field count, field size, and header size.
|
|
41
84
|
* @returns Parsed string fields plus uploaded files buffered in memory.
|
|
42
|
-
* @throws {PayloadTooLargeException} When
|
|
85
|
+
* @throws {PayloadTooLargeException} When any configured file-size, file-count, total-size, field-count, field-size,
|
|
86
|
+
* or header-size limit is exceeded.
|
|
43
87
|
*/
|
|
44
88
|
export declare function parseMultipart(request: Request | MultipartRequestLike, options?: MultipartOptions): Promise<MultipartResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Streams multipart fields and file parts from a request body.
|
|
91
|
+
*
|
|
92
|
+
* A yielded file stream must finish or be cancelled before requesting the next part. Calling
|
|
93
|
+
* this function selects the request body for streaming consumption; callers cannot also use
|
|
94
|
+
* {@link parseMultipart} for the same request body.
|
|
95
|
+
*
|
|
96
|
+
* @param request - Web `Request` or request-like input carrying a multipart body.
|
|
97
|
+
* @param options - Limits enforced while parsing headers, fields, files, and total input bytes.
|
|
98
|
+
* @returns An async iterator of typed field and file parts.
|
|
99
|
+
* @throws {MultipartBodyConsumedError} When buffered or streaming parsing already selected the body.
|
|
100
|
+
*/
|
|
101
|
+
export declare function parseMultipartStream(request: Request | MultipartRequestLike, options?: MultipartOptions): AsyncIterableIterator<MultipartPart>;
|
|
102
|
+
/**
|
|
103
|
+
* Marks an input as selected for buffered or streaming multipart consumption.
|
|
104
|
+
*
|
|
105
|
+
* @param request - Request input whose body cannot be selected again.
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
export declare function markMultipartBodyConsumed(request: Request | MultipartRequestLike): void;
|
|
45
109
|
//# sourceMappingURL=multipart.d.ts.map
|
package/dist/multipart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../src/multipart.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;IACnD,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;CACtD;
|
|
1
|
+
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../src/multipart.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,YAAY;IA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