halfcode-compiler.xnl 0.2.3 → 0.2.5
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/dist/application-assembly.js +1 -1
- package/dist/{index-96qHPZj2.d.ts → index-D7UtYNm7.d.ts} +1 -1
- package/dist/{index-DdRHFKSQ.d.ts → index-DihSfO7X.d.ts} +33 -2
- package/dist/{index-D2mpux6L.d.ts → index-DjvNDidT.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/kind-definition.d.ts +1 -1
- package/dist/{resource-core-Byhqyadq.d.ts → resource-core-UAvFx3m-.d.ts} +1 -1
- package/dist/resource-core.d.ts +3 -3
- package/dist/resource-core.js +4 -4
- package/dist/resource-projection.d.ts +1 -1
- package/dist/skill-capsule.d.ts +1 -1
- package/dist/skill-capsule.js +1 -1
- package/dist/{src-DCRih45n.js → src-BGFskWEk.js} +272 -37
- package/dist/{src-D1Bmq7Lo.js → src-BJ5cQQ7P.js} +1 -1
- package/dist/{src-DRIws6tY.js → src-BxwHmx6r.js} +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as assertObjectOperationCatalog, c as resolveApplicationAssembly, i as assertObjectOperationCall, l as resourceRefToFqn, n as applicationAssemblyPackage, o as assertObjectOperationDefinition, r as assertExecuteObjectOperationRequest, s as loadApplicationAssembly, t as ObjectOperationContractError } from "./src-
|
|
1
|
+
import { a as assertObjectOperationCatalog, c as resolveApplicationAssembly, i as assertObjectOperationCall, l as resourceRefToFqn, n as applicationAssemblyPackage, o as assertObjectOperationDefinition, r as assertExecuteObjectOperationRequest, s as loadApplicationAssembly, t as ObjectOperationContractError } from "./src-BxwHmx6r.js";
|
|
2
2
|
export { ObjectOperationContractError, applicationAssemblyPackage, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, loadApplicationAssembly, resolveApplicationAssembly, resourceRefToFqn };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ApplicationAssembly } from "./index-Cqh9pEBa.js";
|
|
2
|
-
import { t as ResourceRegistry } from "./index-
|
|
2
|
+
import { t as ResourceRegistry } from "./index-DjvNDidT.js";
|
|
3
3
|
//#region ../compiler-skill/src/index.d.ts
|
|
4
4
|
interface SkillDescriptor {
|
|
5
5
|
name: string;
|
|
@@ -103,8 +103,38 @@ declare function sha256Digest(value: string | Uint8Array): Sha256Digest;
|
|
|
103
103
|
declare function createResourceContentIdentity(input: CreateResourceContentIdentityInput): ResourceContentIdentity;
|
|
104
104
|
declare function buildResourceDependencySnapshot(input: BuildResourceDependencySnapshotInput): ResourceDependencySnapshot;
|
|
105
105
|
//#endregion
|
|
106
|
+
//#region ../resource-core/src/code-package.d.ts
|
|
107
|
+
declare const CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY = "code-binding:module";
|
|
108
|
+
interface CodePackageBinding {
|
|
109
|
+
readonly resourceId: string;
|
|
110
|
+
readonly moduleUri: string;
|
|
111
|
+
readonly exportName?: string;
|
|
112
|
+
}
|
|
113
|
+
interface LoadedCodePackageModule {
|
|
114
|
+
readonly resourceId: string;
|
|
115
|
+
readonly binding: CodePackageBinding;
|
|
116
|
+
readonly revision: string;
|
|
117
|
+
readonly moduleNamespace: Readonly<Record<string, unknown>>;
|
|
118
|
+
}
|
|
119
|
+
interface LoadCodePackageModuleInput {
|
|
120
|
+
readonly tree: LoadedResourceTree;
|
|
121
|
+
readonly resourceId: string;
|
|
122
|
+
readonly rootDir: string;
|
|
123
|
+
}
|
|
124
|
+
interface CodePackageExportContract<T> {
|
|
125
|
+
isDefinition(value: unknown): value is T;
|
|
126
|
+
identityOf(value: T): string;
|
|
127
|
+
}
|
|
128
|
+
declare class CodePackageLoadError extends Error {
|
|
129
|
+
readonly diagnostics: readonly ResourceDiagnostic[];
|
|
130
|
+
constructor(diagnostics: readonly ResourceDiagnostic[]);
|
|
131
|
+
}
|
|
132
|
+
declare function loadCodePackageModule(input: LoadCodePackageModuleInput): Promise<LoadedCodePackageModule>;
|
|
133
|
+
declare function admitCodePackageExports<T>(loaded: LoadedCodePackageModule, contract: CodePackageExportContract<T>): readonly T[];
|
|
134
|
+
declare function admitCodePackages<T>(loaded: readonly LoadedCodePackageModule[], contract: CodePackageExportContract<T>): readonly T[];
|
|
135
|
+
//#endregion
|
|
106
136
|
//#region ../resource-core/src/index.d.ts
|
|
107
|
-
type SourceShape = "single-file" | "directory" | "manifest";
|
|
137
|
+
type SourceShape = "single-file" | "directory" | "manifest" | "code-package";
|
|
108
138
|
interface ResourceIdentity {
|
|
109
139
|
kind: string;
|
|
110
140
|
fqn?: string;
|
|
@@ -164,6 +194,7 @@ interface ResourceTree {
|
|
|
164
194
|
}
|
|
165
195
|
interface LoadedResourceTree extends ResourceTree {
|
|
166
196
|
readonly contentIdentities: ReadonlyMap<string, ResourceContentIdentity>;
|
|
197
|
+
readonly codePackageBindings: ReadonlyMap<string, CodePackageBinding>;
|
|
167
198
|
}
|
|
168
199
|
interface ResourceDiagnostic {
|
|
169
200
|
code: string;
|
|
@@ -189,4 +220,4 @@ declare class ResourceValidationError extends Error {
|
|
|
189
220
|
declare function loadResourceTree(options: LoadResourceTreeOptions): Promise<LoadedResourceTree>;
|
|
190
221
|
declare function validateResourceTree(options: LoadResourceTreeOptions): Promise<ResourceDiagnostic[]>;
|
|
191
222
|
//#endregion
|
|
192
|
-
export {
|
|
223
|
+
export { admitCodePackages as A, createResourceContentIdentity as B, CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY as C, LoadCodePackageModuleInput as D, CodePackageLoadError as E, ResourceDependencyEdge as F, EffectiveResourceRegistry as G, ComposeLayeredResourceRegistryInput as H, ResourceDependencySnapshot as I, ResourceOrigin as J, ResourceLayerDescriptor as K, ResourceDigestContribution as L, BuildResourceDependencySnapshotInput as M, CreateResourceContentIdentityInput as N, LoadedCodePackageModule as O, ResourceContentIdentity as P, Sha256Digest as Q, SnapshotResource as R, validateResourceTree as S, CodePackageExportContract as T, EffectiveKindDefinition as U, sha256Digest as V, EffectiveResourceEntry as W, ResourceTombstoneOrigin as X, ResourceTombstone as Y, composeLayeredResourceRegistry as Z, ResourceValue as _, ResourceDescriptor as a, SourceShape as b, ResourceKindContract as c, ResourceRecord as d, ResourceRegistry as f, ResourceValidationError as g, ResourceTreeBuildResult as h, RegisteredKindDefinition as i, loadCodePackageModule as j, admitCodePackageExports as k, ResourceMetadata as l, ResourceTree as m, LoadedResourceTree as n, ResourceDiagnostic as o, ResourceScalar as p, ResourceLayerInput as q, LoadedResourceTreeBuildResult as r, ResourceIdentity as s, LoadResourceTreeOptions as t, ResourceNode as u, ResourceValueList as v, CodePackageBinding as w, loadResourceTree as x, ResourceValueMap as y, buildResourceDependencySnapshot as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ResourceDescriptor } from "./index-
|
|
1
|
+
import { a as ResourceDescriptor } from "./index-DihSfO7X.js";
|
|
2
2
|
//#region ../resource-projection/src/index.d.ts
|
|
3
3
|
interface ResourceRegistry {
|
|
4
4
|
readonly byKind: ReadonlyMap<string, readonly ResourceDescriptor[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { A as ObjectTargets, B as applicationAssemblyPackage, C as ObjectOperationDefinition, D as ObjectOperationTargetDeclaration, E as ObjectOperationOwnerKind, F as ResourceSource, G as loadApplicationAssembly, H as assertObjectOperationCall, I as SkillCapsuleDependency, K as resolveApplicationAssembly, L as SkillCapsuleResource, M as ResolveApplicationAssemblyOptions, N as ResolvedAssemblyPortBinding, O as ObjectTargetKindDefinition, P as ResourceInclude, R as TextMaterial, S as ObjectOperationContractError, T as ObjectOperationHandler, U as assertObjectOperationCatalog, V as assertExecuteObjectOperationRequest, W as assertObjectOperationDefinition, _ as ObjectInvocationMode, a as AssemblyResource, b as ObjectOperationCatalog, c as BusinessObjectSopResource, d as ExecuteObjectOperationRequest, f as JsonObject, g as ObjectInvocation, h as LoadApplicationAssemblyOptions, i as AssemblyPortBinding, j as PageObjectResource, k as ObjectTargetRef, l as CodeBinding, m as JsonValue, n as ApplicationScope, o as AuthoringModuleDescriptor, p as JsonPrimitive, q as resourceRefToFqn, r as AssemblyPort, s as BusinessObjectResource, t as ApplicationAssembly, u as ContractedCallableResource, v as ObjectOperationBehavior, w as ObjectOperationEffect, x as ObjectOperationConfig, y as ObjectOperationCall, z as TextResource } from "./index-Cqh9pEBa.js";
|
|
2
|
-
import { A as
|
|
3
|
-
import { i as ResourceCompositionError, n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./resource-core-
|
|
4
|
-
import { S as skillCapsuleDistributionProjection, _ as applySkillCapsuleDistributionPlan, a as PlannedSkillCapsule, b as compilerSkillPackage, c as SkillCapsuleContentDigest, d as SkillCapsuleDistributionReceipt, f as SkillCapsuleIdentity, g as SkillReference, h as SkillDescriptor, i as PlanSkillCapsuleDistributionInput, l as SkillCapsuleDistributionError, m as SkillCapsuleProvenanceManifest, n as CompileResourceSkillCapsuleInput, o as PlannedSkillFile, p as SkillCapsulePlan, r as CompileSkillCapsuleInput, s as SkillCapsuleApplyStep, t as ApplySkillCapsuleDistributionOptions, u as SkillCapsuleDistributionPlan, v as compileResourceSkillCapsule, x as planSkillCapsuleDistribution, y as compileSkillCapsule } from "./index-
|
|
2
|
+
import { A as admitCodePackages, B as createResourceContentIdentity, C as CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, D as LoadCodePackageModuleInput, E as CodePackageLoadError, F as ResourceDependencyEdge, G as EffectiveResourceRegistry, H as ComposeLayeredResourceRegistryInput, I as ResourceDependencySnapshot, J as ResourceOrigin, K as ResourceLayerDescriptor, L as ResourceDigestContribution, M as BuildResourceDependencySnapshotInput, N as CreateResourceContentIdentityInput, O as LoadedCodePackageModule, P as ResourceContentIdentity, Q as Sha256Digest, R as SnapshotResource, S as validateResourceTree, T as CodePackageExportContract, U as EffectiveKindDefinition, V as sha256Digest, W as EffectiveResourceEntry, X as ResourceTombstoneOrigin, Y as ResourceTombstone, Z as composeLayeredResourceRegistry, _ as ResourceValue, a as ResourceDescriptor, b as SourceShape, c as ResourceKindContract, d as ResourceRecord, f as ResourceRegistry, g as ResourceValidationError, h as ResourceTreeBuildResult, i as RegisteredKindDefinition, j as loadCodePackageModule, k as admitCodePackageExports, l as ResourceMetadata, m as ResourceTree, n as LoadedResourceTree, o as ResourceDiagnostic, p as ResourceScalar, q as ResourceLayerInput, r as LoadedResourceTreeBuildResult, s as ResourceIdentity, t as LoadResourceTreeOptions, u as ResourceNode, v as ResourceValueList, w as CodePackageBinding, x as loadResourceTree, y as ResourceValueMap, z as buildResourceDependencySnapshot } from "./index-DihSfO7X.js";
|
|
3
|
+
import { i as ResourceCompositionError, n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./resource-core-UAvFx3m-.js";
|
|
4
|
+
import { S as skillCapsuleDistributionProjection, _ as applySkillCapsuleDistributionPlan, a as PlannedSkillCapsule, b as compilerSkillPackage, c as SkillCapsuleContentDigest, d as SkillCapsuleDistributionReceipt, f as SkillCapsuleIdentity, g as SkillReference, h as SkillDescriptor, i as PlanSkillCapsuleDistributionInput, l as SkillCapsuleDistributionError, m as SkillCapsuleProvenanceManifest, n as CompileResourceSkillCapsuleInput, o as PlannedSkillFile, p as SkillCapsulePlan, r as CompileSkillCapsuleInput, s as SkillCapsuleApplyStep, t as ApplySkillCapsuleDistributionOptions, u as SkillCapsuleDistributionPlan, v as compileResourceSkillCapsule, x as planSkillCapsuleDistribution, y as compileSkillCapsule } from "./index-D7UtYNm7.js";
|
|
5
5
|
//#region src/bundled-system-skills.d.ts
|
|
6
6
|
declare function loadHalfcodeResourceDslSystemSkillModule(): AuthoringModuleDescriptor;
|
|
7
7
|
declare function loadHalfcodeResourceDslSystemSkillPlan(): Promise<SkillCapsuleDistributionPlan>;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { type ApplicationAssembly, type ApplicationScope, ApplySkillCapsuleDistributionOptions, type AssemblyPort, type AssemblyPortBinding, type AssemblyResource, type AuthoringModuleDescriptor, BuildResourceDependencySnapshotInput, type BusinessObjectResource, type BusinessObjectSopResource, type CodeBinding, CompileResourceSkillCapsuleInput, CompileSkillCapsuleInput, ComposeLayeredResourceRegistryInput, type ContractedCallableResource, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, type ExecuteObjectOperationRequest, type JsonObject, type JsonPrimitive, type JsonValue, type LoadApplicationAssemblyOptions, LoadResourceTreeOptions, LoadedResourceTree, LoadedResourceTreeBuildResult, type ObjectInvocation, type ObjectInvocationMode, type ObjectOperationBehavior, type ObjectOperationCall, type ObjectOperationCatalog, type ObjectOperationConfig, ObjectOperationContractError, type ObjectOperationDefinition, type ObjectOperationEffect, type ObjectOperationHandler, type ObjectOperationOwnerKind, type ObjectOperationTargetDeclaration, type ObjectTargetKindDefinition, type ObjectTargetRef, type ObjectTargets, type PageObjectResource, PlanSkillCapsuleDistributionInput, PlannedSkillCapsule, PlannedSkillFile, RegisteredKindDefinition, type ResolveApplicationAssemblyOptions, ResolveEffectiveResourceContentIdentitiesInput, type ResolvedAssemblyPortBinding, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, type ResourceInclude, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMetadata, ResourceNode, ResourceOrigin, ResourceRecord, ResourceRegistry, ResourceScalar, type ResourceSource, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SkillCapsuleApplyStep, SkillCapsuleContentDigest, type SkillCapsuleDependency, SkillCapsuleDistributionError, SkillCapsuleDistributionPlan, SkillCapsuleDistributionReceipt, SkillCapsuleIdentity, SkillCapsulePlan, SkillCapsuleProvenanceManifest, type SkillCapsuleResource, SkillDescriptor, SkillReference, SnapshotResource, SourceShape, type TextMaterial, type TextResource, applicationAssemblyPackage, applySkillCapsuleDistributionPlan, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, buildResourceDependencySnapshot, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, composeLayeredResourceRegistry, createResourceContentIdentity, loadApplicationAssembly, loadHalfcodeResourceDslSystemSkillModule, loadHalfcodeResourceDslSystemSkillPlan, loadResourceTree, planSkillCapsuleDistribution, resolveApplicationAssembly, resolveEffectiveResourceContentIdentities, resourceRefToFqn, sha256Digest, skillCapsuleDistributionProjection, validateResourceTree };
|
|
9
|
+
export { type ApplicationAssembly, type ApplicationScope, ApplySkillCapsuleDistributionOptions, type AssemblyPort, type AssemblyPortBinding, type AssemblyResource, type AuthoringModuleDescriptor, BuildResourceDependencySnapshotInput, type BusinessObjectResource, type BusinessObjectSopResource, CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, type CodeBinding, type CodePackageBinding, type CodePackageExportContract, CodePackageLoadError, CompileResourceSkillCapsuleInput, CompileSkillCapsuleInput, ComposeLayeredResourceRegistryInput, type ContractedCallableResource, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, type ExecuteObjectOperationRequest, type JsonObject, type JsonPrimitive, type JsonValue, type LoadApplicationAssemblyOptions, type LoadCodePackageModuleInput, LoadResourceTreeOptions, type LoadedCodePackageModule, LoadedResourceTree, LoadedResourceTreeBuildResult, type ObjectInvocation, type ObjectInvocationMode, type ObjectOperationBehavior, type ObjectOperationCall, type ObjectOperationCatalog, type ObjectOperationConfig, ObjectOperationContractError, type ObjectOperationDefinition, type ObjectOperationEffect, type ObjectOperationHandler, type ObjectOperationOwnerKind, type ObjectOperationTargetDeclaration, type ObjectTargetKindDefinition, type ObjectTargetRef, type ObjectTargets, type PageObjectResource, PlanSkillCapsuleDistributionInput, PlannedSkillCapsule, PlannedSkillFile, RegisteredKindDefinition, type ResolveApplicationAssemblyOptions, ResolveEffectiveResourceContentIdentitiesInput, type ResolvedAssemblyPortBinding, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, type ResourceInclude, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMetadata, ResourceNode, ResourceOrigin, ResourceRecord, ResourceRegistry, ResourceScalar, type ResourceSource, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SkillCapsuleApplyStep, SkillCapsuleContentDigest, type SkillCapsuleDependency, SkillCapsuleDistributionError, SkillCapsuleDistributionPlan, SkillCapsuleDistributionReceipt, SkillCapsuleIdentity, SkillCapsulePlan, SkillCapsuleProvenanceManifest, type SkillCapsuleResource, SkillDescriptor, SkillReference, SnapshotResource, SourceShape, type TextMaterial, type TextResource, admitCodePackageExports, admitCodePackages, applicationAssemblyPackage, applySkillCapsuleDistributionPlan, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, buildResourceDependencySnapshot, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, composeLayeredResourceRegistry, createResourceContentIdentity, loadApplicationAssembly, loadCodePackageModule, loadHalfcodeResourceDslSystemSkillModule, loadHalfcodeResourceDslSystemSkillPlan, loadResourceTree, planSkillCapsuleDistribution, resolveApplicationAssembly, resolveEffectiveResourceContentIdentities, resourceRefToFqn, sha256Digest, skillCapsuleDistributionProjection, validateResourceTree };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { a as assertObjectOperationCatalog, c as resolveApplicationAssembly, i as assertObjectOperationCall, l as resourceRefToFqn, n as applicationAssemblyPackage, o as assertObjectOperationDefinition, r as assertExecuteObjectOperationRequest, s as loadApplicationAssembly, t as ObjectOperationContractError } from "./src-
|
|
1
|
+
import { _ as ResourceCompositionError, a as CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, c as admitCodePackages, d as buildResourceDependencySnapshot, f as createResourceContentIdentity, l as loadCodePackageModule, n as loadResourceTree, o as CodePackageLoadError, p as sha256Digest, r as validateResourceTree, s as admitCodePackageExports, t as ResourceValidationError } from "./src-BGFskWEk.js";
|
|
2
|
+
import { a as assertObjectOperationCatalog, c as resolveApplicationAssembly, i as assertObjectOperationCall, l as resourceRefToFqn, n as applicationAssemblyPackage, o as assertObjectOperationDefinition, r as assertExecuteObjectOperationRequest, s as loadApplicationAssembly, t as ObjectOperationContractError } from "./src-BxwHmx6r.js";
|
|
3
3
|
import "./application-assembly.js";
|
|
4
4
|
import { composeLayeredResourceRegistry, resolveEffectiveResourceContentIdentities } from "./resource-core.js";
|
|
5
|
-
import { a as compilerSkillPackage, i as compileSkillCapsule, n as applySkillCapsuleDistributionPlan, o as planSkillCapsuleDistribution, r as compileResourceSkillCapsule, s as skillCapsuleDistributionProjection, t as SkillCapsuleDistributionError } from "./src-
|
|
5
|
+
import { a as compilerSkillPackage, i as compileSkillCapsule, n as applySkillCapsuleDistributionPlan, o as planSkillCapsuleDistribution, r as compileResourceSkillCapsule, s as skillCapsuleDistributionProjection, t as SkillCapsuleDistributionError } from "./src-BJ5cQQ7P.js";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
//#region src/bundled-system-skills.ts
|
|
8
8
|
function loadHalfcodeResourceDslSystemSkillModule() {
|
|
@@ -20,4 +20,4 @@ async function loadHalfcodeResourceDslSystemSkillPlan() {
|
|
|
20
20
|
return bundled.default;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
|
-
export { ObjectOperationContractError, ResourceCompositionError, ResourceValidationError, SkillCapsuleDistributionError, applicationAssemblyPackage, applySkillCapsuleDistributionPlan, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, buildResourceDependencySnapshot, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, composeLayeredResourceRegistry, createResourceContentIdentity, loadApplicationAssembly, loadHalfcodeResourceDslSystemSkillModule, loadHalfcodeResourceDslSystemSkillPlan, loadResourceTree, planSkillCapsuleDistribution, resolveApplicationAssembly, resolveEffectiveResourceContentIdentities, resourceRefToFqn, sha256Digest, skillCapsuleDistributionProjection, validateResourceTree };
|
|
23
|
+
export { CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, CodePackageLoadError, ObjectOperationContractError, ResourceCompositionError, ResourceValidationError, SkillCapsuleDistributionError, admitCodePackageExports, admitCodePackages, applicationAssemblyPackage, applySkillCapsuleDistributionPlan, assertExecuteObjectOperationRequest, assertObjectOperationCall, assertObjectOperationCatalog, assertObjectOperationDefinition, buildResourceDependencySnapshot, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, composeLayeredResourceRegistry, createResourceContentIdentity, loadApplicationAssembly, loadCodePackageModule, loadHalfcodeResourceDslSystemSkillModule, loadHalfcodeResourceDslSystemSkillPlan, loadResourceTree, planSkillCapsuleDistribution, resolveApplicationAssembly, resolveEffectiveResourceContentIdentities, resourceRefToFqn, sha256Digest, skillCapsuleDistributionProjection, validateResourceTree };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ResourceDescriptor, c as ResourceKindContract } from "./index-
|
|
1
|
+
import { a as ResourceDescriptor, c as ResourceKindContract } from "./index-DihSfO7X.js";
|
|
2
2
|
//#region ../kind-definition/src/index.d.ts
|
|
3
3
|
interface KindDefinition extends ResourceDescriptor, ResourceKindContract {
|
|
4
4
|
kind: "KindDefinition";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as EffectiveResourceRegistry, L as ResourceDigestContribution, P as ResourceContentIdentity, n as LoadedResourceTree, o as ResourceDiagnostic } from "./index-DihSfO7X.js";
|
|
2
2
|
//#region ../resource-core/src/composition-error.d.ts
|
|
3
3
|
declare class ResourceCompositionError extends Error {
|
|
4
4
|
readonly diagnostics: readonly ResourceDiagnostic[];
|
package/dist/resource-core.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { i as ResourceCompositionError, n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./resource-core-
|
|
3
|
-
export { BuildResourceDependencySnapshotInput, ComposeLayeredResourceRegistryInput, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, LoadResourceTreeOptions, LoadedResourceTree, LoadedResourceTreeBuildResult, RegisteredKindDefinition, ResolveEffectiveResourceContentIdentitiesInput, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMetadata, ResourceNode, ResourceOrigin, ResourceRecord, ResourceRegistry, ResourceScalar, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SnapshotResource, SourceShape, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
|
|
1
|
+
import { A as admitCodePackages, B as createResourceContentIdentity, C as CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, D as LoadCodePackageModuleInput, E as CodePackageLoadError, F as ResourceDependencyEdge, G as EffectiveResourceRegistry, H as ComposeLayeredResourceRegistryInput, I as ResourceDependencySnapshot, J as ResourceOrigin, K as ResourceLayerDescriptor, L as ResourceDigestContribution, M as BuildResourceDependencySnapshotInput, N as CreateResourceContentIdentityInput, O as LoadedCodePackageModule, P as ResourceContentIdentity, Q as Sha256Digest, R as SnapshotResource, S as validateResourceTree, T as CodePackageExportContract, U as EffectiveKindDefinition, V as sha256Digest, W as EffectiveResourceEntry, X as ResourceTombstoneOrigin, Y as ResourceTombstone, Z as composeLayeredResourceRegistry, _ as ResourceValue, a as ResourceDescriptor, b as SourceShape, c as ResourceKindContract, d as ResourceRecord, f as ResourceRegistry, g as ResourceValidationError, h as ResourceTreeBuildResult, i as RegisteredKindDefinition, j as loadCodePackageModule, k as admitCodePackageExports, l as ResourceMetadata, m as ResourceTree, n as LoadedResourceTree, o as ResourceDiagnostic, p as ResourceScalar, q as ResourceLayerInput, r as LoadedResourceTreeBuildResult, s as ResourceIdentity, t as LoadResourceTreeOptions, u as ResourceNode, v as ResourceValueList, w as CodePackageBinding, x as loadResourceTree, y as ResourceValueMap, z as buildResourceDependencySnapshot } from "./index-DihSfO7X.js";
|
|
2
|
+
import { i as ResourceCompositionError, n as ResourceLayerContentIdentityInput, r as resolveEffectiveResourceContentIdentities, t as ResolveEffectiveResourceContentIdentitiesInput } from "./resource-core-UAvFx3m-.js";
|
|
3
|
+
export { BuildResourceDependencySnapshotInput, CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, type CodePackageBinding, type CodePackageExportContract, CodePackageLoadError, ComposeLayeredResourceRegistryInput, CreateResourceContentIdentityInput, EffectiveKindDefinition, EffectiveResourceEntry, EffectiveResourceRegistry, type LoadCodePackageModuleInput, LoadResourceTreeOptions, type LoadedCodePackageModule, LoadedResourceTree, LoadedResourceTreeBuildResult, RegisteredKindDefinition, ResolveEffectiveResourceContentIdentitiesInput, ResourceCompositionError, ResourceContentIdentity, ResourceDependencyEdge, ResourceDependencySnapshot, ResourceDescriptor, ResourceDiagnostic, ResourceDigestContribution, ResourceIdentity, ResourceKindContract, ResourceLayerContentIdentityInput, ResourceLayerDescriptor, ResourceLayerInput, ResourceMetadata, ResourceNode, ResourceOrigin, ResourceRecord, ResourceRegistry, ResourceScalar, ResourceTombstone, ResourceTombstoneOrigin, ResourceTree, ResourceTreeBuildResult, ResourceValidationError, ResourceValue, ResourceValueList, ResourceValueMap, type Sha256Digest, SnapshotResource, SourceShape, admitCodePackageExports, admitCodePackages, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadCodePackageModule, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
|
package/dist/resource-core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { _ as ResourceCompositionError, a as CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, c as admitCodePackages, d as buildResourceDependencySnapshot, f as createResourceContentIdentity, g as markEffectiveRegistryAuthentic, h as isEffectiveRegistryAuthentic, i as readonlyMap, l as loadCodePackageModule, m as effectiveRegistryLayerBindings, n as loadResourceTree, o as CodePackageLoadError, p as sha256Digest, r as validateResourceTree, s as admitCodePackageExports, t as ResourceValidationError, u as isLoadedResourceTreeAuthentic, v as compareCodeUnits, y as digestCanonical } from "./src-BGFskWEk.js";
|
|
2
2
|
//#region ../resource-core/src/layered-registry.ts
|
|
3
3
|
function composeLayeredResourceRegistry(input) {
|
|
4
4
|
const diagnostics = [];
|
|
@@ -368,7 +368,7 @@ function resolveEffectiveResourceContentIdentities(input) {
|
|
|
368
368
|
const identity = createResourceContentIdentity({
|
|
369
369
|
resourceId: entry.resourceId,
|
|
370
370
|
authorityDigest: authorityIdentity.authorityDigest,
|
|
371
|
-
contributions: input.contributions?.get(entry.resourceId) ?? []
|
|
371
|
+
contributions: [...authorityIdentity.contributions, ...input.contributions?.get(entry.resourceId) ?? []]
|
|
372
372
|
});
|
|
373
373
|
output.push([entry.resourceId, identity]);
|
|
374
374
|
} catch (error) {
|
|
@@ -391,7 +391,7 @@ function validateLoadedIdentityCoverage(tree, layerId, diagnostics) {
|
|
|
391
391
|
const normalized = createResourceContentIdentity({
|
|
392
392
|
resourceId: identity.resourceId,
|
|
393
393
|
authorityDigest: identity.authorityDigest,
|
|
394
|
-
contributions:
|
|
394
|
+
contributions: identity.contributions
|
|
395
395
|
});
|
|
396
396
|
if (identity.resourceId !== resource.resourceId || identity.contentDigest !== normalized.contentDigest) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_INVALID", layerLocation(void 0, layerId, resource.resourceId), `Loaded resource '${resource.resourceId}' has an inconsistent authority identity.`));
|
|
397
397
|
}
|
|
@@ -429,4 +429,4 @@ function contentLocation(resourceId) {
|
|
|
429
429
|
return `content:${resourceId || "unnamed"}`;
|
|
430
430
|
}
|
|
431
431
|
//#endregion
|
|
432
|
-
export { ResourceCompositionError, ResourceValidationError, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
|
|
432
|
+
export { CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, CodePackageLoadError, ResourceCompositionError, ResourceValidationError, admitCodePackageExports, admitCodePackages, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadCodePackageModule, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as resourceProjectionPackage, t as ResourceRegistry } from "./index-
|
|
1
|
+
import { n as resourceProjectionPackage, t as ResourceRegistry } from "./index-DjvNDidT.js";
|
|
2
2
|
export { ResourceRegistry, resourceProjectionPackage };
|
package/dist/skill-capsule.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { I as SkillCapsuleDependency } from "./index-Cqh9pEBa.js";
|
|
2
|
-
import { S as skillCapsuleDistributionProjection, _ as applySkillCapsuleDistributionPlan, a as PlannedSkillCapsule, b as compilerSkillPackage, c as SkillCapsuleContentDigest, d as SkillCapsuleDistributionReceipt, f as SkillCapsuleIdentity, g as SkillReference, h as SkillDescriptor, i as PlanSkillCapsuleDistributionInput, l as SkillCapsuleDistributionError, m as SkillCapsuleProvenanceManifest, n as CompileResourceSkillCapsuleInput, o as PlannedSkillFile, p as SkillCapsulePlan, r as CompileSkillCapsuleInput, s as SkillCapsuleApplyStep, t as ApplySkillCapsuleDistributionOptions, u as SkillCapsuleDistributionPlan, v as compileResourceSkillCapsule, x as planSkillCapsuleDistribution, y as compileSkillCapsule } from "./index-
|
|
2
|
+
import { S as skillCapsuleDistributionProjection, _ as applySkillCapsuleDistributionPlan, a as PlannedSkillCapsule, b as compilerSkillPackage, c as SkillCapsuleContentDigest, d as SkillCapsuleDistributionReceipt, f as SkillCapsuleIdentity, g as SkillReference, h as SkillDescriptor, i as PlanSkillCapsuleDistributionInput, l as SkillCapsuleDistributionError, m as SkillCapsuleProvenanceManifest, n as CompileResourceSkillCapsuleInput, o as PlannedSkillFile, p as SkillCapsulePlan, r as CompileSkillCapsuleInput, s as SkillCapsuleApplyStep, t as ApplySkillCapsuleDistributionOptions, u as SkillCapsuleDistributionPlan, v as compileResourceSkillCapsule, x as planSkillCapsuleDistribution, y as compileSkillCapsule } from "./index-D7UtYNm7.js";
|
|
3
3
|
export { ApplySkillCapsuleDistributionOptions, CompileResourceSkillCapsuleInput, CompileSkillCapsuleInput, PlanSkillCapsuleDistributionInput, PlannedSkillCapsule, PlannedSkillFile, SkillCapsuleApplyStep, SkillCapsuleContentDigest, type SkillCapsuleDependency, SkillCapsuleDistributionError, SkillCapsuleDistributionPlan, SkillCapsuleDistributionReceipt, SkillCapsuleIdentity, SkillCapsulePlan, SkillCapsuleProvenanceManifest, SkillDescriptor, SkillReference, applySkillCapsuleDistributionPlan, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, planSkillCapsuleDistribution, skillCapsuleDistributionProjection };
|
package/dist/skill-capsule.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as compilerSkillPackage, i as compileSkillCapsule, n as applySkillCapsuleDistributionPlan, o as planSkillCapsuleDistribution, r as compileResourceSkillCapsule, s as skillCapsuleDistributionProjection, t as SkillCapsuleDistributionError } from "./src-
|
|
1
|
+
import { a as compilerSkillPackage, i as compileSkillCapsule, n as applySkillCapsuleDistributionPlan, o as planSkillCapsuleDistribution, r as compileResourceSkillCapsule, s as skillCapsuleDistributionProjection, t as SkillCapsuleDistributionError } from "./src-BJ5cQQ7P.js";
|
|
2
2
|
export { SkillCapsuleDistributionError, applySkillCapsuleDistributionPlan, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, planSkillCapsuleDistribution, skillCapsuleDistributionProjection };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { n as wordToString, t as parseXnl } from "./dist-Bkv7YeVi.js";
|
|
2
|
-
import { readFile, readdir, realpath, stat } from "node:fs/promises";
|
|
3
|
-
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
2
|
+
import { mkdtemp, readFile, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
5
7
|
//#region ../resource-core/src/canonical.ts
|
|
6
8
|
function compareCodeUnits(left, right) {
|
|
7
9
|
if (left < right) return -1;
|
|
@@ -72,17 +74,17 @@ function createResourceContentIdentity(input) {
|
|
|
72
74
|
strictCanonicalInput: false,
|
|
73
75
|
validateClaimedDigest: false
|
|
74
76
|
});
|
|
75
|
-
if (diagnostics.length > 0 || !identity) throw new ResourceCompositionError(stableDiagnostics(diagnostics));
|
|
77
|
+
if (diagnostics.length > 0 || !identity) throw new ResourceCompositionError(stableDiagnostics$1(diagnostics));
|
|
76
78
|
return identity;
|
|
77
79
|
}
|
|
78
80
|
function buildResourceDependencySnapshot(input) {
|
|
79
81
|
const diagnostics = [];
|
|
80
|
-
if (!isEffectiveRegistryAuthentic(input.registry) || input.registry.revision !== input.registry.compositionRevision) throw new ResourceCompositionError(Object.freeze([diagnostic("RESOURCE_EFFECTIVE_REGISTRY_UNTRUSTED", "effective-registry:revision", "Dependency snapshots require an authentic immutable registry returned by composeLayeredResourceRegistry().")]));
|
|
82
|
+
if (!isEffectiveRegistryAuthentic(input.registry) || input.registry.revision !== input.registry.compositionRevision) throw new ResourceCompositionError(Object.freeze([diagnostic$1("RESOURCE_EFFECTIVE_REGISTRY_UNTRUSTED", "effective-registry:revision", "Dependency snapshots require an authentic immutable registry returned by composeLayeredResourceRegistry().")]));
|
|
81
83
|
const roots = validateRoots(input.roots, input.registry, diagnostics);
|
|
82
84
|
const edges = validateEdges(input.edges, input.registry, diagnostics);
|
|
83
85
|
validateContentIdentityIndex(input.contentIdentities, diagnostics);
|
|
84
86
|
const validatedIdentities = validateEffectiveContentIdentities(input.registry, input.contentIdentities, diagnostics);
|
|
85
|
-
if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics(diagnostics));
|
|
87
|
+
if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics$1(diagnostics));
|
|
86
88
|
const registryRevision = digestCanonical({
|
|
87
89
|
compositionRevision: input.registry.compositionRevision,
|
|
88
90
|
resources: [...validatedIdentities.values()].sort((left, right) => compareCodeUnits(left.resourceId, right.resourceId)).map((identity) => ({
|
|
@@ -106,7 +108,7 @@ function buildResourceDependencySnapshot(input) {
|
|
|
106
108
|
if (visiting.has(resourceId)) {
|
|
107
109
|
const cycleStart = path.indexOf(resourceId);
|
|
108
110
|
const cycle = [...path.slice(cycleStart), resourceId];
|
|
109
|
-
diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_CYCLE", dependencyLocation(resourceId), `Resource dependency cycle detected: ${cycle.join(" -> ")}.`));
|
|
111
|
+
diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_CYCLE", dependencyLocation(resourceId), `Resource dependency cycle detected: ${cycle.join(" -> ")}.`));
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
114
|
if (visited.has(resourceId)) return;
|
|
@@ -122,7 +124,7 @@ function buildResourceDependencySnapshot(input) {
|
|
|
122
124
|
visited.add(resourceId);
|
|
123
125
|
};
|
|
124
126
|
for (const root of roots) visit(root);
|
|
125
|
-
if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics(diagnostics));
|
|
127
|
+
if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics$1(diagnostics));
|
|
126
128
|
const closure = Object.freeze([...reachable].sort(compareCodeUnits).map((resourceId) => {
|
|
127
129
|
const entry = input.registry.byId.get(resourceId);
|
|
128
130
|
const identity = validatedIdentities.get(resourceId);
|
|
@@ -160,19 +162,19 @@ function validateRoots(inputRoots, registry, diagnostics) {
|
|
|
160
162
|
for (const value of inputRoots) {
|
|
161
163
|
const resourceId = value.trim();
|
|
162
164
|
if (resourceId.length === 0) {
|
|
163
|
-
diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_ROOT_EMPTY", "dependency-root:unnamed", "Dependency snapshot roots must be non-empty resource ids."));
|
|
165
|
+
diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_ROOT_EMPTY", "dependency-root:unnamed", "Dependency snapshot roots must be non-empty resource ids."));
|
|
164
166
|
continue;
|
|
165
167
|
}
|
|
166
168
|
if (seen.has(resourceId)) {
|
|
167
|
-
diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_ROOT_DUPLICATE", dependencyLocation(resourceId), `Dependency snapshot root '${resourceId}' is declared more than once.`));
|
|
169
|
+
diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_ROOT_DUPLICATE", dependencyLocation(resourceId), `Dependency snapshot root '${resourceId}' is declared more than once.`));
|
|
168
170
|
continue;
|
|
169
171
|
}
|
|
170
172
|
seen.add(resourceId);
|
|
171
173
|
roots.push(resourceId);
|
|
172
174
|
const entry = registry.byId.get(resourceId);
|
|
173
|
-
if (!entry || !entry.resource) diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_ROOT_MISSING", dependencyLocation(resourceId), `Dependency snapshot root '${resourceId}' is not an effective resource.`));
|
|
175
|
+
if (!entry || !entry.resource) diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_ROOT_MISSING", dependencyLocation(resourceId), `Dependency snapshot root '${resourceId}' is not an effective resource.`));
|
|
174
176
|
}
|
|
175
|
-
if (roots.length === 0 && diagnostics.length === 0) diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_ROOTS_EMPTY", "dependency-root:none", "Dependency snapshot requires at least one explicit root."));
|
|
177
|
+
if (roots.length === 0 && diagnostics.length === 0) diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_ROOTS_EMPTY", "dependency-root:none", "Dependency snapshot requires at least one explicit root."));
|
|
176
178
|
return roots;
|
|
177
179
|
}
|
|
178
180
|
function validateEdges(inputEdges, registry, diagnostics) {
|
|
@@ -185,13 +187,13 @@ function validateEdges(inputEdges, registry, diagnostics) {
|
|
|
185
187
|
declaredBy: inputEdge.declaredBy.trim()
|
|
186
188
|
});
|
|
187
189
|
if (!edge.fromResourceId || !edge.toResourceId || !edge.relation || !edge.declaredBy) {
|
|
188
|
-
diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_EDGE_INVALID", `dependency-edge:${index}`, "Dependency edges require non-empty fromResourceId, toResourceId, relation, and declaredBy fields."));
|
|
190
|
+
diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_EDGE_INVALID", `dependency-edge:${index}`, "Dependency edges require non-empty fromResourceId, toResourceId, relation, and declaredBy fields."));
|
|
189
191
|
return;
|
|
190
192
|
}
|
|
191
193
|
const source = registry.byId.get(edge.fromResourceId);
|
|
192
194
|
const target = registry.byId.get(edge.toResourceId);
|
|
193
|
-
if (!source?.resource) diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_SOURCE_MISSING", dependencyLocation(edge.fromResourceId), `Dependency edge source '${edge.fromResourceId}' is not an effective resource.`));
|
|
194
|
-
if (!target?.resource) diagnostics.push(diagnostic("RESOURCE_DEPENDENCY_TARGET_MISSING", dependencyLocation(edge.toResourceId), `Dependency edge target '${edge.toResourceId}' is not an effective resource.`));
|
|
195
|
+
if (!source?.resource) diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_SOURCE_MISSING", dependencyLocation(edge.fromResourceId), `Dependency edge source '${edge.fromResourceId}' is not an effective resource.`));
|
|
196
|
+
if (!target?.resource) diagnostics.push(diagnostic$1("RESOURCE_DEPENDENCY_TARGET_MISSING", dependencyLocation(edge.toResourceId), `Dependency edge target '${edge.toResourceId}' is not an effective resource.`));
|
|
195
197
|
values.set(edgeKey(edge), edge);
|
|
196
198
|
});
|
|
197
199
|
return [...values.values()].sort(compareEdges);
|
|
@@ -199,41 +201,41 @@ function validateEdges(inputEdges, registry, diagnostics) {
|
|
|
199
201
|
function normalizeContentIdentity(input, diagnostics, options) {
|
|
200
202
|
const initialDiagnosticCount = diagnostics.length;
|
|
201
203
|
if (!isRecord(input)) {
|
|
202
|
-
diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_INVALID", contentLocation(""), "Resource content identity must be an object fact."));
|
|
204
|
+
diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_INVALID", contentLocation(""), "Resource content identity must be an object fact."));
|
|
203
205
|
return;
|
|
204
206
|
}
|
|
205
207
|
const rawResourceId = input.resourceId;
|
|
206
208
|
const resourceId = typeof rawResourceId === "string" ? rawResourceId.trim() : "";
|
|
207
|
-
if (resourceId.length === 0) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_ID_EMPTY", contentLocation(""), "Resource content identity requires a non-empty resource id."));
|
|
208
|
-
else if (options.strictCanonicalInput && rawResourceId !== resourceId) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_NON_CANONICAL", contentLocation(resourceId), `Resource content identity '${resourceId}' must use its canonical id without surrounding whitespace.`));
|
|
209
|
+
if (resourceId.length === 0) diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_ID_EMPTY", contentLocation(""), "Resource content identity requires a non-empty resource id."));
|
|
210
|
+
else if (options.strictCanonicalInput && rawResourceId !== resourceId) diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_NON_CANONICAL", contentLocation(resourceId), `Resource content identity '${resourceId}' must use its canonical id without surrounding whitespace.`));
|
|
209
211
|
const authorityDigest = typeof input.authorityDigest === "string" ? input.authorityDigest : "";
|
|
210
|
-
if (!isSha256Digest(authorityDigest)) diagnostics.push(diagnostic("RESOURCE_CONTENT_AUTHORITY_DIGEST_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has an invalid authority digest.`));
|
|
212
|
+
if (!isSha256Digest(authorityDigest)) diagnostics.push(diagnostic$1("RESOURCE_CONTENT_AUTHORITY_DIGEST_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has an invalid authority digest.`));
|
|
211
213
|
const rawContributions = input.contributions;
|
|
212
214
|
let contributionFacts = [];
|
|
213
215
|
if (rawContributions === void 0 && !options.requireContributions) contributionFacts = [];
|
|
214
|
-
else if (!Array.isArray(rawContributions)) diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTIONS_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' must provide an explicit digest contribution array.`));
|
|
216
|
+
else if (!Array.isArray(rawContributions)) diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTIONS_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' must provide an explicit digest contribution array.`));
|
|
215
217
|
else contributionFacts = rawContributions;
|
|
216
218
|
const contributions = /* @__PURE__ */ new Map();
|
|
217
219
|
for (const fact of contributionFacts) {
|
|
218
220
|
if (!isRecord(fact)) {
|
|
219
|
-
diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has a non-object digest contribution.`));
|
|
221
|
+
diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_INVALID", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has a non-object digest contribution.`));
|
|
220
222
|
continue;
|
|
221
223
|
}
|
|
222
224
|
const rawKey = fact.key;
|
|
223
225
|
const key = typeof rawKey === "string" ? rawKey.trim() : "";
|
|
224
226
|
if (key.length === 0) {
|
|
225
|
-
diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_KEY_EMPTY", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has a digest contribution with an empty key.`));
|
|
227
|
+
diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_KEY_EMPTY", contentLocation(resourceId), `Resource '${resourceId || "unnamed"}' has a digest contribution with an empty key.`));
|
|
226
228
|
continue;
|
|
227
229
|
}
|
|
228
|
-
if (options.strictCanonicalInput && rawKey !== key) diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_NON_CANONICAL", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId}' must use its canonical key.`));
|
|
230
|
+
if (options.strictCanonicalInput && rawKey !== key) diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_NON_CANONICAL", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId}' must use its canonical key.`));
|
|
229
231
|
const digest = typeof fact.digest === "string" ? fact.digest : "";
|
|
230
232
|
if (!isSha256Digest(digest)) {
|
|
231
|
-
diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_INVALID", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' is invalid.`));
|
|
233
|
+
diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_INVALID", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' is invalid.`));
|
|
232
234
|
continue;
|
|
233
235
|
}
|
|
234
236
|
const sourceUri = fact.sourceUri;
|
|
235
237
|
if (sourceUri !== void 0 && typeof sourceUri !== "string") {
|
|
236
|
-
diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_SOURCE_INVALID", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId}' has an invalid source URI.`));
|
|
238
|
+
diagnostics.push(diagnostic$1("RESOURCE_DIGEST_CONTRIBUTION_SOURCE_INVALID", contentLocation(resourceId, key), `Digest contribution '${key}' for resource '${resourceId}' has an invalid source URI.`));
|
|
237
239
|
continue;
|
|
238
240
|
}
|
|
239
241
|
const contribution = Object.freeze({
|
|
@@ -244,7 +246,7 @@ function normalizeContentIdentity(input, diagnostics, options) {
|
|
|
244
246
|
const current = contributions.get(key);
|
|
245
247
|
if (current) {
|
|
246
248
|
const conflicting = current.digest !== digest;
|
|
247
|
-
diagnostics.push(diagnostic(conflicting ? "RESOURCE_DIGEST_CONTRIBUTION_CONFLICT" : "RESOURCE_DIGEST_CONTRIBUTION_DUPLICATE", contentLocation(resourceId, key), conflicting ? `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' has conflicting digests.` : `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' is declared more than once.`));
|
|
249
|
+
diagnostics.push(diagnostic$1(conflicting ? "RESOURCE_DIGEST_CONTRIBUTION_CONFLICT" : "RESOURCE_DIGEST_CONTRIBUTION_DUPLICATE", contentLocation(resourceId, key), conflicting ? `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' has conflicting digests.` : `Digest contribution '${key}' for resource '${resourceId || "unnamed"}' is declared more than once.`));
|
|
248
250
|
continue;
|
|
249
251
|
}
|
|
250
252
|
contributions.set(key, contribution);
|
|
@@ -262,11 +264,11 @@ function normalizeContentIdentity(input, diagnostics, options) {
|
|
|
262
264
|
if (options.validateClaimedDigest) {
|
|
263
265
|
const claimedDigest = input.contentDigest;
|
|
264
266
|
if (typeof claimedDigest !== "string" || !isSha256Digest(claimedDigest)) {
|
|
265
|
-
diagnostics.push(diagnostic("RESOURCE_CONTENT_DIGEST_INVALID", contentLocation(resourceId), `Resource '${resourceId}' has an invalid claimed content digest.`));
|
|
267
|
+
diagnostics.push(diagnostic$1("RESOURCE_CONTENT_DIGEST_INVALID", contentLocation(resourceId), `Resource '${resourceId}' has an invalid claimed content digest.`));
|
|
266
268
|
return;
|
|
267
269
|
}
|
|
268
270
|
if (claimedDigest !== contentDigest) {
|
|
269
|
-
diagnostics.push(diagnostic("RESOURCE_CONTENT_DIGEST_MISMATCH", contentLocation(resourceId), `Resource '${resourceId}' claimed a content digest that does not match its explicit authority and contributions.`));
|
|
271
|
+
diagnostics.push(diagnostic$1("RESOURCE_CONTENT_DIGEST_MISMATCH", contentLocation(resourceId), `Resource '${resourceId}' claimed a content digest that does not match its explicit authority and contributions.`));
|
|
270
272
|
return;
|
|
271
273
|
}
|
|
272
274
|
}
|
|
@@ -283,7 +285,7 @@ function validateEffectiveContentIdentities(registry, identities, diagnostics) {
|
|
|
283
285
|
for (const entry of effectiveEntries) {
|
|
284
286
|
const input = identities.get(entry.resourceId);
|
|
285
287
|
if (input === void 0) {
|
|
286
|
-
diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_MISSING", dependencyLocation(entry.resourceId), `Effective resource '${entry.resourceId}' has no explicit content identity.`));
|
|
288
|
+
diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_MISSING", dependencyLocation(entry.resourceId), `Effective resource '${entry.resourceId}' has no explicit content identity.`));
|
|
287
289
|
continue;
|
|
288
290
|
}
|
|
289
291
|
const identity = normalizeContentIdentity(input, diagnostics, {
|
|
@@ -298,7 +300,7 @@ function validateEffectiveContentIdentities(registry, identities, diagnostics) {
|
|
|
298
300
|
function validateContentIdentityIndex(identities, diagnostics) {
|
|
299
301
|
for (const [key, identity] of [...identities.entries()].sort(([left], [right]) => compareCodeUnits(left, right))) {
|
|
300
302
|
const identityResourceId = isRecord(identity) && typeof identity.resourceId === "string" ? identity.resourceId : void 0;
|
|
301
|
-
if (key !== identityResourceId) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_KEY_MISMATCH", dependencyLocation(key), `Content identity index key '${key}' does not match identity '${identityResourceId ?? "invalid"}'.`));
|
|
303
|
+
if (key !== identityResourceId) diagnostics.push(diagnostic$1("RESOURCE_CONTENT_IDENTITY_KEY_MISMATCH", dependencyLocation(key), `Content identity index key '${key}' does not match identity '${identityResourceId ?? "invalid"}'.`));
|
|
302
304
|
}
|
|
303
305
|
}
|
|
304
306
|
function isSha256Digest(value) {
|
|
@@ -344,10 +346,10 @@ function cloneOrigin(origin) {
|
|
|
344
346
|
...origin.logicalPath === void 0 ? {} : { logicalPath: origin.logicalPath }
|
|
345
347
|
});
|
|
346
348
|
}
|
|
347
|
-
function stableDiagnostics(diagnostics) {
|
|
349
|
+
function stableDiagnostics$1(diagnostics) {
|
|
348
350
|
return Object.freeze([...diagnostics].sort((left, right) => compareCodeUnits(left.location, right.location) || compareCodeUnits(left.code, right.code)));
|
|
349
351
|
}
|
|
350
|
-
function diagnostic(code, location, message) {
|
|
352
|
+
function diagnostic$1(code, location, message) {
|
|
351
353
|
return Object.freeze({
|
|
352
354
|
code,
|
|
353
355
|
location,
|
|
@@ -371,6 +373,217 @@ function isLoadedResourceTreeAuthentic(tree) {
|
|
|
371
373
|
return authenticLoadedResourceTrees.has(tree);
|
|
372
374
|
}
|
|
373
375
|
//#endregion
|
|
376
|
+
//#region ../resource-core/src/code-package.ts
|
|
377
|
+
const CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY = "code-binding:module";
|
|
378
|
+
/** @internal Node effect implementation bound by the public facade. */
|
|
379
|
+
const nodeCodePackageRuntime = Object.freeze({
|
|
380
|
+
realpath,
|
|
381
|
+
readFile,
|
|
382
|
+
stat,
|
|
383
|
+
prepareModuleSource: async ({ bytes }) => {
|
|
384
|
+
const directory = await mkdtemp(join(tmpdir(), "halfcode-code-package-module-"));
|
|
385
|
+
const sourcePath = join(directory, "entry.mjs");
|
|
386
|
+
try {
|
|
387
|
+
await writeFile(sourcePath, bytes, { flag: "wx" });
|
|
388
|
+
} catch (error) {
|
|
389
|
+
await rm(directory, {
|
|
390
|
+
recursive: true,
|
|
391
|
+
force: true
|
|
392
|
+
}).catch(() => void 0);
|
|
393
|
+
throw error;
|
|
394
|
+
}
|
|
395
|
+
return Object.freeze({
|
|
396
|
+
url: pathToFileURL(sourcePath).href,
|
|
397
|
+
dispose: async () => rm(directory, {
|
|
398
|
+
recursive: true,
|
|
399
|
+
force: true
|
|
400
|
+
})
|
|
401
|
+
});
|
|
402
|
+
},
|
|
403
|
+
importModule: async (url) => import(url)
|
|
404
|
+
});
|
|
405
|
+
var CodePackageLoadError = class extends Error {
|
|
406
|
+
diagnostics;
|
|
407
|
+
constructor(diagnostics) {
|
|
408
|
+
super(`CodePackage loading failed with ${diagnostics.length} diagnostic(s)`);
|
|
409
|
+
this.name = "CodePackageLoadError";
|
|
410
|
+
this.diagnostics = Object.freeze([...diagnostics]);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
/** @internal Used by the canonical XNL loader before it brands the completed tree. */
|
|
414
|
+
function normalizeCodePackageBinding(record) {
|
|
415
|
+
const diagnostics = [];
|
|
416
|
+
if (record.sourceShape !== "code-package") {
|
|
417
|
+
diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_SHAPE_INVALID", record.documentUri, `Resource '${record.resourceId}' does not use the code-package source shape.`));
|
|
418
|
+
return { diagnostics };
|
|
419
|
+
}
|
|
420
|
+
const node = record.node.subdomains.CodeBinding;
|
|
421
|
+
if (!node || node.tag !== "CodeBinding") {
|
|
422
|
+
diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_BINDING_MISSING", record.documentUri, `CodePackage resource '${record.resourceId}' requires one CodeBinding.`));
|
|
423
|
+
return { diagnostics };
|
|
424
|
+
}
|
|
425
|
+
if (node.properties.package !== void 0) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_BINDING_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' must bind a package-local module, not an external package.`));
|
|
426
|
+
const rawModule = stringValue(node.properties.module);
|
|
427
|
+
const moduleUri = rawModule === void 0 ? void 0 : normalizeModuleUri(rawModule);
|
|
428
|
+
if (!moduleUri) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_MODULE_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' requires a canonical package-local .js or .mjs module URI.`));
|
|
429
|
+
const rawExport = node.properties.export;
|
|
430
|
+
const exportName = stringValue(rawExport);
|
|
431
|
+
if (rawExport !== void 0 && (!exportName || !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(exportName))) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_EXPORT_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' has an invalid named export binding.`));
|
|
432
|
+
if (diagnostics.length > 0 || !moduleUri) return { diagnostics: stableDiagnostics(diagnostics) };
|
|
433
|
+
return {
|
|
434
|
+
binding: Object.freeze({
|
|
435
|
+
resourceId: record.resourceId,
|
|
436
|
+
moduleUri,
|
|
437
|
+
...exportName ? { exportName } : {}
|
|
438
|
+
}),
|
|
439
|
+
diagnostics: Object.freeze([])
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
/** @internal Resolves and reads the exact entry bytes under the descriptor directory. */
|
|
443
|
+
async function readCodePackageEntry(runtime, rootDir, record, binding) {
|
|
444
|
+
const diagnostics = [];
|
|
445
|
+
const realRoot = await runtime.realpath(resolve(rootDir)).catch(() => void 0);
|
|
446
|
+
if (!realRoot) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_ROOT_MISSING", record.documentUri, `The resource root for '${record.resourceId}' is missing or unreadable.`)] };
|
|
447
|
+
if (!isSafeLogicalPath(record.logicalPath)) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_PROVENANCE_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' has unsafe logical provenance.`)] };
|
|
448
|
+
const descriptorPath = resolve(realRoot, record.logicalPath);
|
|
449
|
+
const descriptorDirectory = await runtime.realpath(dirname(descriptorPath)).catch(() => void 0);
|
|
450
|
+
if (!descriptorDirectory || !isWithin(realRoot, descriptorDirectory)) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_CONTAINMENT", record.documentUri, `CodePackage resource '${record.resourceId}' resolves outside the resource root.`)] };
|
|
451
|
+
const localPath = moduleLocalPath(binding.moduleUri);
|
|
452
|
+
if (!localPath) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_MODULE_INVALID", record.documentUri, `CodePackage resource '${record.resourceId}' has an invalid module URI.`)] };
|
|
453
|
+
const entryPath = await runtime.realpath(resolve(descriptorDirectory, ...localPath.split("/"))).catch(() => void 0);
|
|
454
|
+
if (!entryPath) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_MISSING", `${record.documentUri}#CodeBinding`, `CodePackage entry is missing for '${record.resourceId}'.`)] };
|
|
455
|
+
if (!isWithin(descriptorDirectory, entryPath) || entryPath === descriptorDirectory) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_CONTAINMENT", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' resolves outside its package directory.`));
|
|
456
|
+
if (!(await runtime.stat(entryPath).catch(() => void 0))?.isFile()) diagnostics.push(diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_INVALID", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' must be a regular file.`));
|
|
457
|
+
if (diagnostics.length > 0) return { diagnostics: stableDiagnostics(diagnostics) };
|
|
458
|
+
const bytes = await runtime.readFile(entryPath).catch(() => void 0);
|
|
459
|
+
if (!bytes) return { diagnostics: [diagnostic("RESOURCE_CODE_PACKAGE_ENTRY_MISSING", `${record.documentUri}#CodeBinding`, `CodePackage entry is unreadable for '${record.resourceId}'.`)] };
|
|
460
|
+
const resourceDirectory = posix.dirname(record.logicalPath);
|
|
461
|
+
return {
|
|
462
|
+
entryPath,
|
|
463
|
+
bytes,
|
|
464
|
+
sourceUri: `vfs://@/${resourceDirectory === "." ? localPath : `${resourceDirectory}/${localPath}`}`,
|
|
465
|
+
diagnostics: Object.freeze([])
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
async function loadCodePackageModule(input) {
|
|
469
|
+
return loadCodePackageModuleWithRuntime(nodeCodePackageRuntime, input);
|
|
470
|
+
}
|
|
471
|
+
/** @internal Pure orchestration over an injected effect runtime; hidden by the package facade. */
|
|
472
|
+
async function loadCodePackageModuleWithRuntime(runtime, input) {
|
|
473
|
+
if (!isLoadedResourceTreeAuthentic(input.tree)) throw loadError("RESOURCE_CODE_PACKAGE_TREE_UNTRUSTED", `code-package:${input.resourceId}`, "CodePackage modules require an authentic LoadedResourceTree.");
|
|
474
|
+
const record = findResource(input.tree, input.resourceId);
|
|
475
|
+
const binding = input.tree.codePackageBindings.get(input.resourceId);
|
|
476
|
+
const identity = input.tree.contentIdentities.get(input.resourceId);
|
|
477
|
+
if (!record || record.sourceShape !== "code-package" || !binding || !identity) throw loadError("RESOURCE_CODE_PACKAGE_RESOURCE_INVALID", `code-package:${input.resourceId}`, `Resource '${input.resourceId}' is not a loaded CodePackage.`);
|
|
478
|
+
const entry = await readCodePackageEntry(runtime, input.rootDir, record, binding);
|
|
479
|
+
if (entry.diagnostics.length > 0 || !entry.entryPath || !entry.bytes) throw new CodePackageLoadError(entry.diagnostics);
|
|
480
|
+
const contribution = identity.contributions.find((item) => item.key === CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY);
|
|
481
|
+
if (!contribution || contribution.digest !== sha256Digest(entry.bytes) || contribution.sourceUri !== entry.sourceUri) throw loadError("RESOURCE_CODE_PACKAGE_REVISION_STALE", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' changed after its ResourceTree was loaded.`);
|
|
482
|
+
let preparedSource;
|
|
483
|
+
try {
|
|
484
|
+
preparedSource = await runtime.prepareModuleSource({
|
|
485
|
+
bytes: entry.bytes,
|
|
486
|
+
revision: identity.contentDigest
|
|
487
|
+
});
|
|
488
|
+
} catch {
|
|
489
|
+
throw loadError("RESOURCE_CODE_PACKAGE_IMPORT_PREPARE_FAILED", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' could not be prepared for import.`);
|
|
490
|
+
}
|
|
491
|
+
let moduleNamespace;
|
|
492
|
+
let importFailed = false;
|
|
493
|
+
try {
|
|
494
|
+
moduleNamespace = await runtime.importModule(preparedSource.url);
|
|
495
|
+
} catch {
|
|
496
|
+
importFailed = true;
|
|
497
|
+
moduleNamespace = Object.freeze({});
|
|
498
|
+
}
|
|
499
|
+
const cleanupFailed = await preparedSource.dispose().then(() => false, () => true);
|
|
500
|
+
if (importFailed) throw loadError("RESOURCE_CODE_PACKAGE_IMPORT_FAILED", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' could not be imported.`);
|
|
501
|
+
if (cleanupFailed) throw loadError("RESOURCE_CODE_PACKAGE_IMPORT_CLEANUP_FAILED", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' could not be cleaned up after import.`);
|
|
502
|
+
if (binding.exportName && !(binding.exportName in moduleNamespace)) throw loadError("RESOURCE_CODE_PACKAGE_EXPORT_MISSING", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' does not export '${binding.exportName}'.`);
|
|
503
|
+
const currentBytes = await runtime.readFile(entry.entryPath).catch(() => void 0);
|
|
504
|
+
if (!currentBytes || sha256Digest(currentBytes) !== contribution.digest) throw loadError("RESOURCE_CODE_PACKAGE_REVISION_STALE", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' changed while it was being imported.`);
|
|
505
|
+
const frozenNamespace = Object.freeze(Object.fromEntries(Object.keys(moduleNamespace).sort(compareCodeUnits).map((name) => [name, moduleNamespace[name]])));
|
|
506
|
+
return Object.freeze({
|
|
507
|
+
resourceId: record.resourceId,
|
|
508
|
+
binding,
|
|
509
|
+
revision: identity.contentDigest,
|
|
510
|
+
moduleNamespace: frozenNamespace
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
function admitCodePackageExports(loaded, contract) {
|
|
514
|
+
return admitCandidates([{
|
|
515
|
+
loaded,
|
|
516
|
+
contract
|
|
517
|
+
}]);
|
|
518
|
+
}
|
|
519
|
+
function admitCodePackages(loaded, contract) {
|
|
520
|
+
return admitCandidates(loaded.map((item) => ({
|
|
521
|
+
loaded: item,
|
|
522
|
+
contract
|
|
523
|
+
})));
|
|
524
|
+
}
|
|
525
|
+
function admitCandidates(packages) {
|
|
526
|
+
const definitions = /* @__PURE__ */ new Map();
|
|
527
|
+
for (const { loaded, contract } of packages) {
|
|
528
|
+
const names = loaded.binding.exportName ? [loaded.binding.exportName] : Object.keys(loaded.moduleNamespace).sort(compareCodeUnits);
|
|
529
|
+
for (const name of names) {
|
|
530
|
+
const exported = loaded.moduleNamespace[name];
|
|
531
|
+
const candidates = Array.isArray(exported) ? exported : [exported];
|
|
532
|
+
for (const candidate of candidates) {
|
|
533
|
+
if (!contract.isDefinition(candidate)) continue;
|
|
534
|
+
const identity = contract.identityOf(candidate).trim();
|
|
535
|
+
if (!identity) throw new TypeError(`CodePackage definition from '${loaded.resourceId}' has an empty identity`);
|
|
536
|
+
if (definitions.has(identity)) throw new TypeError(`Duplicate CodePackage definition identity '${identity}'`);
|
|
537
|
+
definitions.set(identity, candidate);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return Object.freeze([...definitions.entries()].sort(([left], [right]) => compareCodeUnits(left, right)).map(([, definition]) => definition));
|
|
542
|
+
}
|
|
543
|
+
function normalizeModuleUri(value) {
|
|
544
|
+
const prefix = "vfs://./";
|
|
545
|
+
if (!value.startsWith(prefix) || value !== value.trim() || value.includes("%") || value.includes("\\") || value.includes("?") || value.includes("#")) return void 0;
|
|
546
|
+
const localPath = value.slice(8);
|
|
547
|
+
if (!localPath || isAbsolute(localPath) || posix.isAbsolute(localPath)) return void 0;
|
|
548
|
+
const parts = localPath.split("/");
|
|
549
|
+
if (parts.some((part) => !part || part === "." || part === "..")) return void 0;
|
|
550
|
+
const extension = extname(localPath).toLowerCase();
|
|
551
|
+
if (extension !== ".js" && extension !== ".mjs") return void 0;
|
|
552
|
+
return `${prefix}${parts.join("/")}`;
|
|
553
|
+
}
|
|
554
|
+
function moduleLocalPath(moduleUri) {
|
|
555
|
+
return normalizeModuleUri(moduleUri)?.slice(8);
|
|
556
|
+
}
|
|
557
|
+
function findResource(tree, resourceId) {
|
|
558
|
+
for (const records of tree.registry.byKind.values()) {
|
|
559
|
+
const record = records.find((item) => item.resourceId === resourceId);
|
|
560
|
+
if (record) return record;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function isSafeLogicalPath(value) {
|
|
564
|
+
return Boolean(value) && !isAbsolute(value) && !value.includes("\\") && !value.split("/").some((part) => !part || part === "." || part === "..");
|
|
565
|
+
}
|
|
566
|
+
function isWithin(boundary, candidate) {
|
|
567
|
+
const path = relative(boundary, candidate);
|
|
568
|
+
return path === "" || !path.startsWith(`..${sep}`) && path !== ".." && !isAbsolute(path);
|
|
569
|
+
}
|
|
570
|
+
function stringValue(value) {
|
|
571
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
572
|
+
}
|
|
573
|
+
function loadError(code, location, message) {
|
|
574
|
+
return new CodePackageLoadError([diagnostic(code, location, message)]);
|
|
575
|
+
}
|
|
576
|
+
function stableDiagnostics(diagnostics) {
|
|
577
|
+
return Object.freeze([...diagnostics].sort((left, right) => compareCodeUnits(left.location, right.location) || compareCodeUnits(left.code, right.code)));
|
|
578
|
+
}
|
|
579
|
+
function diagnostic(code, location, message) {
|
|
580
|
+
return Object.freeze({
|
|
581
|
+
code,
|
|
582
|
+
location,
|
|
583
|
+
message
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
//#endregion
|
|
374
587
|
//#region ../resource-core/src/readonly-map.ts
|
|
375
588
|
function readonlyMap(entries) {
|
|
376
589
|
const values = new Map(entries);
|
|
@@ -413,7 +626,9 @@ async function buildXnlResourceTree(options) {
|
|
|
413
626
|
resources: [],
|
|
414
627
|
seenIdentities: /* @__PURE__ */ new Map(),
|
|
415
628
|
authorityFiles: /* @__PURE__ */ new Map(),
|
|
416
|
-
recordAuthorityDigests: /* @__PURE__ */ new WeakMap()
|
|
629
|
+
recordAuthorityDigests: /* @__PURE__ */ new WeakMap(),
|
|
630
|
+
recordContributions: /* @__PURE__ */ new WeakMap(),
|
|
631
|
+
codePackageBindings: /* @__PURE__ */ new Map()
|
|
417
632
|
};
|
|
418
633
|
const manifest = await loadManifest(resolve(context.rootDir, options.manifestPath), "manifest", context, true);
|
|
419
634
|
if (!manifest || context.diagnostics.length > 0) return { diagnostics: context.diagnostics };
|
|
@@ -426,6 +641,7 @@ async function buildXnlResourceTree(options) {
|
|
|
426
641
|
const frozenByKind = readonlyMap([...byKind.entries()].sort(([left], [right]) => compareCodeUnits(left, right)).map(([kind, records]) => [kind, Object.freeze([...records].sort((left, right) => compareCodeUnits(left.resourceId, right.resourceId)))]));
|
|
427
642
|
const frozenKindDefinitions = readonlyMap([...context.kindDefinitions.entries()].sort(([left], [right]) => compareCodeUnits(left, right)));
|
|
428
643
|
const contentIdentities = readonlyMap(context.resources.map((resource) => [resource.resourceId, loadedContentIdentity(resource, context)]).sort(([left], [right]) => compareCodeUnits(left, right)));
|
|
644
|
+
const codePackageBindings = readonlyMap([...context.codePackageBindings.entries()].sort(([left], [right]) => compareCodeUnits(left, right)));
|
|
429
645
|
return {
|
|
430
646
|
diagnostics: [],
|
|
431
647
|
tree: markLoadedResourceTreeAuthentic(Object.freeze({
|
|
@@ -435,7 +651,8 @@ async function buildXnlResourceTree(options) {
|
|
|
435
651
|
kindDefinitions: frozenKindDefinitions
|
|
436
652
|
}),
|
|
437
653
|
diagnostics: Object.freeze([]),
|
|
438
|
-
contentIdentities
|
|
654
|
+
contentIdentities,
|
|
655
|
+
codePackageBindings
|
|
439
656
|
}))
|
|
440
657
|
};
|
|
441
658
|
}
|
|
@@ -524,6 +741,7 @@ async function loadCatalog(catalog, manifestDir, context) {
|
|
|
524
741
|
}
|
|
525
742
|
validateResourceApiVersion(record, definition, context.diagnostics);
|
|
526
743
|
await validateRequiredFiles(dirname(file), record, definition, context.diagnostics);
|
|
744
|
+
if (catalog.shape === "code-package" && !await prepareCodePackageRecord(record, context)) continue;
|
|
527
745
|
validateIdentity(record, context);
|
|
528
746
|
context.resources.push(record);
|
|
529
747
|
}
|
|
@@ -559,7 +777,7 @@ async function catalogFiles(catalog, manifestDir, context) {
|
|
|
559
777
|
context.diagnostics.push({
|
|
560
778
|
code: "RESOURCE_CATALOG_ENTRY_INVALID",
|
|
561
779
|
location: catalog.location,
|
|
562
|
-
message: "Directory and
|
|
780
|
+
message: "Directory, manifest and code-package catalogs require a plain XNL entry filename."
|
|
563
781
|
});
|
|
564
782
|
return [];
|
|
565
783
|
}
|
|
@@ -640,8 +858,25 @@ function loadedContentIdentity(resource, context) {
|
|
|
640
858
|
if (!authorityDigest) throw new Error(`Loader authority digest is missing for ${resource.resourceId}`);
|
|
641
859
|
return createResourceContentIdentity({
|
|
642
860
|
resourceId: resource.resourceId,
|
|
643
|
-
authorityDigest
|
|
861
|
+
authorityDigest,
|
|
862
|
+
contributions: context.recordContributions.get(resource) ?? []
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
async function prepareCodePackageRecord(record, context) {
|
|
866
|
+
const normalized = normalizeCodePackageBinding(record);
|
|
867
|
+
context.diagnostics.push(...normalized.diagnostics);
|
|
868
|
+
if (!normalized.binding) return false;
|
|
869
|
+
const entry = await readCodePackageEntry(nodeCodePackageRuntime, context.rootDir, record, normalized.binding);
|
|
870
|
+
context.diagnostics.push(...entry.diagnostics);
|
|
871
|
+
if (!entry.bytes || !entry.sourceUri) return false;
|
|
872
|
+
const contribution = Object.freeze({
|
|
873
|
+
key: CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY,
|
|
874
|
+
digest: sha256Digest(entry.bytes),
|
|
875
|
+
sourceUri: entry.sourceUri
|
|
644
876
|
});
|
|
877
|
+
context.recordContributions.set(record, Object.freeze([contribution]));
|
|
878
|
+
context.codePackageBindings.set(record.resourceId, normalized.binding);
|
|
879
|
+
return true;
|
|
645
880
|
}
|
|
646
881
|
function resourceRecordFromRoot(root, filePath, sourceShape, context) {
|
|
647
882
|
const documentUri = documentUriFor(context.rootDir, filePath);
|
|
@@ -877,7 +1112,7 @@ function kindMismatch(actual, expected, location) {
|
|
|
877
1112
|
};
|
|
878
1113
|
}
|
|
879
1114
|
function isXnlShape(value) {
|
|
880
|
-
return value === "single-file" || value === "directory" || value === "manifest";
|
|
1115
|
+
return value === "single-file" || value === "directory" || value === "manifest" || value === "code-package";
|
|
881
1116
|
}
|
|
882
1117
|
function isDocumentCardinality(value) {
|
|
883
1118
|
return value === "one" || value === "many";
|
|
@@ -944,4 +1179,4 @@ function unsupportedAuthorityDiagnostic(options) {
|
|
|
944
1179
|
};
|
|
945
1180
|
}
|
|
946
1181
|
//#endregion
|
|
947
|
-
export {
|
|
1182
|
+
export { ResourceCompositionError as _, CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY as a, admitCodePackages as c, buildResourceDependencySnapshot as d, createResourceContentIdentity as f, markEffectiveRegistryAuthentic as g, isEffectiveRegistryAuthentic as h, readonlyMap as i, loadCodePackageModule as l, effectiveRegistryLayerBindings as m, loadResourceTree as n, CodePackageLoadError as o, sha256Digest as p, validateResourceTree as r, admitCodePackageExports as s, ResourceValidationError as t, isLoadedResourceTreeAuthentic as u, compareCodeUnits as v, digestCanonical as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as resourceRefToFqn, u as resolveObjectOperationCompilation } from "./src-
|
|
1
|
+
import { l as resourceRefToFqn, u as resolveObjectOperationCompilation } from "./src-BxwHmx6r.js";
|
|
2
2
|
import { c as unsafeUnicodeCodeUnitIssue, i as planResourceMappings, o as safePathLexicalIssue, r as parseResourceMappings, t as ResourceMappingPathError } from "./src-25wZPUyX.js";
|
|
3
3
|
import { lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { basename, dirname, join, posix, resolve } from "node:path";
|