halfcode-compiler.xnl 0.2.7 → 0.2.9

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.
@@ -1,4 +1,7 @@
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-88_zDKZE.js";
1
+ import { a as isLoadedResourceTreeAuthentic, c as sha256Digest, d as markEffectiveRegistryAuthentic, f as ResourceCompositionError, i as readonlyMap, m as digestCanonical, n as loadResourceTree, o as buildResourceDependencySnapshot, p as compareCodeUnits, r as validateResourceTree, s as createResourceContentIdentity, t as ResourceValidationError } from "./src-D3qSzGFn.js";
2
+ import { t as resolveEffectiveResourceContentIdentities } from "./effective-content-identities-DV5fTr5Q.js";
3
+ import { lstat, readFile, realpath } from "node:fs/promises";
4
+ import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
2
5
  //#region ../resource-core/src/layered-registry.ts
3
6
  function composeLayeredResourceRegistry(input) {
4
7
  const diagnostics = [];
@@ -10,11 +13,11 @@ function composeLayeredResourceRegistry(input) {
10
13
  const layerId = layer.id.trim();
11
14
  const packageId = layer.tree.manifest.resourceId;
12
15
  if (layerId.length === 0) {
13
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_ID_EMPTY", layerLocation$1(layerIndex), "Resource layer id must be a non-empty explicit value."));
16
+ diagnostics.push(diagnostic("RESOURCE_LAYER_ID_EMPTY", layerLocation(layerIndex), "Resource layer id must be a non-empty explicit value."));
14
17
  return;
15
18
  }
16
19
  if (layerIds.has(layerId)) {
17
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_ID_DUPLICATE", layerLocation$1(layerIndex, layerId), `Resource layer id '${layerId}' is declared more than once.`));
20
+ diagnostics.push(diagnostic("RESOURCE_LAYER_ID_DUPLICATE", layerLocation(layerIndex, layerId), `Resource layer id '${layerId}' is declared more than once.`));
18
21
  return;
19
22
  }
20
23
  layerIds.add(layerId);
@@ -27,7 +30,7 @@ function composeLayeredResourceRegistry(input) {
27
30
  mergeResources(layer.tree, layerId, layerIndex, packageId, entries, diagnostics);
28
31
  applyTombstones(layer, layerId, layerIndex, packageId, entries, diagnostics);
29
32
  });
30
- if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics$1(diagnostics));
33
+ if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics(diagnostics));
31
34
  const frozenEntries = [...entries.values()].sort((left, right) => compareCodeUnits(left.resourceId, right.resourceId)).map((entry) => freezeEntry(entry));
32
35
  const byId = readonlyMap(frozenEntries.map((entry) => [entry.resourceId, entry]));
33
36
  const byKindValues = /* @__PURE__ */ new Map();
@@ -73,7 +76,7 @@ function composeLayeredResourceRegistry(input) {
73
76
  function mergeKindDefinitions(tree, layerId, layerIndex, packageId, definitions, diagnostics) {
74
77
  for (const [kind, inputDefinition] of [...tree.registry.kindDefinitions.entries()].sort(([left], [right]) => compareCodeUnits(left, right))) {
75
78
  if (!isCanonicalVfsDocumentUri(inputDefinition.documentUri)) {
76
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_PROVENANCE_INVALID", layerLocation$1(layerIndex, layerId, kind), `Resource kind '${kind}' must use canonical VFS document provenance.`));
79
+ diagnostics.push(diagnostic("RESOURCE_LAYER_PROVENANCE_INVALID", layerLocation(layerIndex, layerId, kind), `Resource kind '${kind}' must use canonical VFS document provenance.`));
77
80
  continue;
78
81
  }
79
82
  const definition = cloneRegisteredKindDefinition(inputDefinition);
@@ -87,7 +90,7 @@ function mergeKindDefinitions(tree, layerId, layerIndex, packageId, definitions,
87
90
  continue;
88
91
  }
89
92
  if (JSON.stringify(normalizedKindContract(current.definition)) !== JSON.stringify(normalizedKindContract(definition))) {
90
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_KIND_DEFINITION_CONFLICT", layerLocation$1(layerIndex, layerId, kind), `Resource kind '${kind}' has incompatible KindDefinition contracts across layers.`));
93
+ diagnostics.push(diagnostic("RESOURCE_LAYER_KIND_DEFINITION_CONFLICT", layerLocation(layerIndex, layerId, kind), `Resource kind '${kind}' has incompatible KindDefinition contracts across layers.`));
91
94
  continue;
92
95
  }
93
96
  current.origins.push(origin);
@@ -98,12 +101,12 @@ function mergeResources(tree, layerId, layerIndex, packageId, entries, diagnosti
98
101
  const seenInLayer = /* @__PURE__ */ new Set();
99
102
  for (const resource of records) {
100
103
  if (seenInLayer.has(resource.resourceId)) {
101
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_RESOURCE_DUPLICATE", layerLocation$1(layerIndex, layerId, resource.resourceId), `Resource '${resource.resourceId}' occurs more than once in layer '${layerId}'.`));
104
+ diagnostics.push(diagnostic("RESOURCE_LAYER_RESOURCE_DUPLICATE", layerLocation(layerIndex, layerId, resource.resourceId), `Resource '${resource.resourceId}' occurs more than once in layer '${layerId}'.`));
102
105
  continue;
103
106
  }
104
107
  seenInLayer.add(resource.resourceId);
105
108
  if (!isSafeLogicalPath(resource.logicalPath) || resource.documentUri !== `vfs://@/${resource.logicalPath}`) {
106
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_PROVENANCE_INVALID", layerLocation$1(layerIndex, layerId, resource.resourceId), `Resource '${resource.resourceId}' must use matching canonical VFS documentUri and safe logicalPath provenance.`));
109
+ diagnostics.push(diagnostic("RESOURCE_LAYER_PROVENANCE_INVALID", layerLocation(layerIndex, layerId, resource.resourceId), `Resource '${resource.resourceId}' must use matching canonical VFS documentUri and safe logicalPath provenance.`));
107
110
  continue;
108
111
  }
109
112
  const immutableResource = cloneResourceRecord(resource);
@@ -122,7 +125,7 @@ function mergeResources(tree, layerId, layerIndex, packageId, entries, diagnosti
122
125
  continue;
123
126
  }
124
127
  if (current.kind !== resource.kind) {
125
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_IDENTITY_KIND_CONFLICT", layerLocation$1(layerIndex, layerId, resource.resourceId), `Resource '${resource.resourceId}' changes kind from '${current.kind}' to '${resource.kind}' across layers.`));
128
+ diagnostics.push(diagnostic("RESOURCE_LAYER_IDENTITY_KIND_CONFLICT", layerLocation(layerIndex, layerId, resource.resourceId), `Resource '${resource.resourceId}' changes kind from '${current.kind}' to '${resource.kind}' across layers.`));
126
129
  continue;
127
130
  }
128
131
  if (current.effectiveOrigin) current.shadowed.push(current.effectiveOrigin);
@@ -138,25 +141,25 @@ function applyTombstones(layer, layerId, layerIndex, packageId, entries, diagnos
138
141
  for (const tombstone of tombstones) {
139
142
  const resourceId = tombstone.resourceId.trim();
140
143
  if (resourceId.length === 0) {
141
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_TOMBSTONE_ID_EMPTY", layerLocation$1(layerIndex, layerId), "Resource tombstone target must be a non-empty resource id."));
144
+ diagnostics.push(diagnostic("RESOURCE_LAYER_TOMBSTONE_ID_EMPTY", layerLocation(layerIndex, layerId), "Resource tombstone target must be a non-empty resource id."));
142
145
  continue;
143
146
  }
144
147
  if (seen.has(resourceId)) {
145
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_TOMBSTONE_DUPLICATE", layerLocation$1(layerIndex, layerId, resourceId), `Resource '${resourceId}' has more than one tombstone in layer '${layerId}'.`));
148
+ diagnostics.push(diagnostic("RESOURCE_LAYER_TOMBSTONE_DUPLICATE", layerLocation(layerIndex, layerId, resourceId), `Resource '${resourceId}' has more than one tombstone in layer '${layerId}'.`));
146
149
  continue;
147
150
  }
148
151
  seen.add(resourceId);
149
152
  const current = entries.get(resourceId);
150
153
  if (!current) {
151
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_TOMBSTONE_TARGET_MISSING", layerLocation$1(layerIndex, layerId, resourceId), `Tombstone target '${resourceId}' does not exist in a lower or current layer.`));
154
+ diagnostics.push(diagnostic("RESOURCE_LAYER_TOMBSTONE_TARGET_MISSING", layerLocation(layerIndex, layerId, resourceId), `Tombstone target '${resourceId}' does not exist in a lower or current layer.`));
152
155
  continue;
153
156
  }
154
157
  if (current.effectiveLayerId === layerId) {
155
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_TOMBSTONE_RESOURCE_CONFLICT", layerLocation$1(layerIndex, layerId, resourceId), `Resource '${resourceId}' cannot be both effective and tombstoned in layer '${layerId}'.`));
158
+ diagnostics.push(diagnostic("RESOURCE_LAYER_TOMBSTONE_RESOURCE_CONFLICT", layerLocation(layerIndex, layerId, resourceId), `Resource '${resourceId}' cannot be both effective and tombstoned in layer '${layerId}'.`));
156
159
  continue;
157
160
  }
158
161
  if (tombstone.expectedKind !== void 0 && tombstone.expectedKind !== current.kind) {
159
- diagnostics.push(diagnostic$1("RESOURCE_LAYER_TOMBSTONE_KIND_MISMATCH", layerLocation$1(layerIndex, layerId, resourceId), `Tombstone for '${resourceId}' expects kind '${tombstone.expectedKind}', but the target kind is '${current.kind}'.`));
162
+ diagnostics.push(diagnostic("RESOURCE_LAYER_TOMBSTONE_KIND_MISMATCH", layerLocation(layerIndex, layerId, resourceId), `Tombstone for '${resourceId}' expects kind '${tombstone.expectedKind}', but the target kind is '${current.kind}'.`));
160
163
  continue;
161
164
  }
162
165
  const origin = Object.freeze({
@@ -299,134 +302,102 @@ function compareOrigins(left, right) {
299
302
  function compareTombstones(left, right) {
300
303
  return left.layerIndex - right.layerIndex || compareCodeUnits(left.resourceId, right.resourceId);
301
304
  }
302
- function stableDiagnostics$1(diagnostics) {
305
+ function stableDiagnostics(diagnostics) {
303
306
  return Object.freeze([...diagnostics].sort((left, right) => compareCodeUnits(left.location, right.location) || compareCodeUnits(left.code, right.code)));
304
307
  }
305
- function diagnostic$1(code, location, message) {
308
+ function diagnostic(code, location, message) {
306
309
  return Object.freeze({
307
310
  code,
308
311
  location,
309
312
  message
310
313
  });
311
314
  }
312
- function layerLocation$1(index, layerId, subject) {
315
+ function layerLocation(index, layerId, subject) {
313
316
  return `layer:${index}:${layerId ?? "unnamed"}${subject === void 0 ? "" : `:${subject}`}`;
314
317
  }
315
318
  //#endregion
316
- //#region ../resource-core/src/effective-content-identities.ts
317
- function resolveEffectiveResourceContentIdentities(input) {
318
- const diagnostics = [];
319
- if (!isEffectiveRegistryAuthentic(input.registry)) throw compositionError(diagnostic("RESOURCE_CONTENT_IDENTITY_REGISTRY_UNTRUSTED", "content-projector:registry", "Effective content identities require an authentic registry returned by composeLayeredResourceRegistry()."));
320
- const bindings = effectiveRegistryLayerBindings(input.registry) ?? [];
321
- if (input.layers.length !== input.registry.layers.length || bindings.length !== input.registry.layers.length) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_LAYER_COUNT_MISMATCH", "content-projector:layers", "Effective content identity layers must exactly match the composed registry layers."));
322
- const loadedById = /* @__PURE__ */ new Map();
323
- for (let index = 0; index < input.registry.layers.length; index += 1) {
324
- const descriptor = input.registry.layers[index];
325
- const layer = input.layers[index];
326
- const binding = bindings[index];
327
- if (!layer) continue;
328
- if (!isLoadedResourceTreeAuthentic(layer.tree)) {
329
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_LAYER_UNTRUSTED", layerLocation(index, layer.id), `Layer '${layer.id}' must use an authentic LoadedResourceTree returned by loadResourceTree().`));
330
- continue;
331
- }
332
- if (layer.id !== descriptor.id || binding?.id !== descriptor.id) {
333
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_LAYER_ID_MISMATCH", layerLocation(index, layer.id), `Layer at index ${index} must retain exact id '${descriptor.id}'.`));
334
- continue;
335
- }
336
- if (descriptor.index !== index) {
337
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_LAYER_INDEX_MISMATCH", layerLocation(index, layer.id), `Layer '${layer.id}' has inconsistent registry index ${descriptor.index}.`));
338
- continue;
339
- }
340
- if (layer.tree.manifest.resourceId !== descriptor.packageId) {
341
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_LAYER_PACKAGE_MISMATCH", layerLocation(index, layer.id), `Layer '${layer.id}' must retain package '${descriptor.packageId}'.`));
342
- continue;
343
- }
344
- if (binding?.tree !== layer.tree) {
345
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_LAYER_BINDING_MISMATCH", layerLocation(index, layer.id), `Layer '${layer.id}' must use the exact loaded tree composed into the registry.`));
346
- continue;
347
- }
348
- validateLoadedIdentityCoverage(layer.tree, layer.id, diagnostics);
349
- loadedById.set(layer.id, layer.tree);
350
- }
351
- const effectiveEntries = [...input.registry.byId.values()].filter((entry) => entry.resource !== void 0).sort((left, right) => compareCodeUnits(left.resourceId, right.resourceId));
352
- const effectiveIds = new Set(effectiveEntries.map((entry) => entry.resourceId));
353
- for (const resourceId of input.contributions?.keys() ?? []) if (!effectiveIds.has(resourceId)) diagnostics.push(diagnostic("RESOURCE_DIGEST_CONTRIBUTION_OWNER_UNKNOWN", contentLocation(resourceId), `Digest contributions target unknown effective resource '${resourceId}'.`));
354
- const output = [];
355
- for (const entry of effectiveEntries) {
356
- const tree = entry.effectiveLayerId === void 0 ? void 0 : loadedById.get(entry.effectiveLayerId);
357
- if (!tree || !entry.effectiveOrigin) {
358
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_EFFECTIVE_ORIGIN_MISSING", contentLocation(entry.resourceId), `Effective resource '${entry.resourceId}' has no exact loaded layer origin.`));
359
- continue;
360
- }
361
- validateEffectiveOrigin(entry, input.registry, tree, diagnostics);
362
- const authorityIdentity = tree.contentIdentities.get(entry.resourceId);
363
- if (!authorityIdentity) {
364
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_MISSING", contentLocation(entry.resourceId), `Effective resource '${entry.resourceId}' is missing its loader authority identity.`));
365
- continue;
366
- }
367
- try {
368
- const identity = createResourceContentIdentity({
369
- resourceId: entry.resourceId,
370
- authorityDigest: authorityIdentity.authorityDigest,
371
- contributions: [...authorityIdentity.contributions, ...input.contributions?.get(entry.resourceId) ?? []]
372
- });
373
- output.push([entry.resourceId, identity]);
374
- } catch (error) {
375
- if (error instanceof ResourceCompositionError) diagnostics.push(...error.diagnostics);
376
- else throw error;
377
- }
319
+ //#region ../resource-core/src/resource-material.ts
320
+ var ResourceMaterialError = class extends Error {
321
+ diagnostics;
322
+ constructor(diagnostics) {
323
+ super(`Resource material read failed with ${diagnostics.length} diagnostic(s)`);
324
+ this.name = "ResourceMaterialError";
325
+ this.diagnostics = Object.freeze([...diagnostics].sort((left, right) => compareCodeUnits(left.location, right.location) || compareCodeUnits(left.code, right.code)));
378
326
  }
379
- if (diagnostics.length > 0) throw new ResourceCompositionError(stableDiagnostics(diagnostics));
380
- return readonlyMap(output.sort(([left], [right]) => compareCodeUnits(left, right)));
327
+ };
328
+ async function readResourceMaterial(input) {
329
+ if (!isLoadedResourceTreeAuthentic(input.tree)) throw materialError("RESOURCE_MATERIAL_TREE_UNTRUSTED", input.resourceId, "Resource materials require an authentic LoadedResourceTree.");
330
+ const record = findResource(input.tree, input.resourceId);
331
+ const identity = input.tree.contentIdentities.get(input.resourceId);
332
+ if (!record || record.sourceShape !== "directory" || !identity) throw materialError("RESOURCE_MATERIAL_RESOURCE_INVALID", input.resourceId, `Resource '${input.resourceId}' is not an authentic directory resource.`);
333
+ const materialPath = materialRelativePath(input.uri);
334
+ if (!materialPath) throw materialError("RESOURCE_MATERIAL_URI_INVALID", input.resourceId, "Resource material URI must be a non-empty lexical-safe vfs://./ reference.");
335
+ const requestedRoot = resolve(input.rootDir);
336
+ const root = await realpath(requestedRoot).catch(() => requestedRoot);
337
+ const authorityCandidate = resolve(root, record.logicalPath);
338
+ const authorityPath = await realpath(authorityCandidate).catch(() => authorityCandidate);
339
+ if (!contains(root, authorityPath) || record.documentUri !== documentUri(root, authorityPath) || sha256Digest(await readFile(authorityPath).catch(() => /* @__PURE__ */ new Uint8Array())) !== identity.authorityDigest) throw materialError("RESOURCE_MATERIAL_AUTHORITY_MISMATCH", input.resourceId, "Directory resource authority does not match the loaded tree provenance.");
340
+ const ownerDirectory = dirname(authorityPath);
341
+ const candidate = resolve(ownerDirectory, materialPath);
342
+ if (!contains(ownerDirectory, candidate)) throw materialError("RESOURCE_MATERIAL_URI_INVALID", input.resourceId, "Resource material URI escapes its owning directory resource.");
343
+ const before = await lstat(candidate).catch(() => void 0);
344
+ if (!before) throw materialError("RESOURCE_MATERIAL_MISSING", input.resourceId, `Resource material '${input.uri}' does not exist.`);
345
+ if (before.isSymbolicLink()) throw materialError("RESOURCE_MATERIAL_SYMLINK_UNSUPPORTED", input.resourceId, `Resource material '${input.uri}' must not be a symbolic link.`);
346
+ if (!before.isFile()) throw materialError("RESOURCE_MATERIAL_NOT_FILE", input.resourceId, `Resource material '${input.uri}' must be a regular file.`);
347
+ const canonicalPath = await realpath(candidate).catch(() => candidate);
348
+ if (!contains(ownerDirectory, canonicalPath)) throw materialError("RESOURCE_MATERIAL_CONTAINMENT", input.resourceId, `Resource material '${input.uri}' resolves outside its owning directory resource.`);
349
+ const source = await readFile(canonicalPath).catch(() => void 0);
350
+ const after = await lstat(candidate).catch(() => void 0);
351
+ const afterCanonical = await realpath(candidate).catch(() => void 0);
352
+ if (!source || !after || after.isSymbolicLink() || !after.isFile() || afterCanonical !== canonicalPath) throw materialError("RESOURCE_MATERIAL_CHANGED", input.resourceId, `Resource material '${input.uri}' changed while it was being read.`);
353
+ const bytes = new Uint8Array(source);
354
+ const digest = sha256Digest(bytes);
355
+ const sourceUri = documentUri(root, canonicalPath);
356
+ const contribution = Object.freeze({
357
+ key: `material:${input.uri}`,
358
+ digest,
359
+ sourceUri
360
+ });
361
+ return Object.freeze({
362
+ resourceId: input.resourceId,
363
+ uri: input.uri,
364
+ sourceUri,
365
+ digest,
366
+ contribution,
367
+ bytes: () => new Uint8Array(bytes)
368
+ });
381
369
  }
382
- function validateLoadedIdentityCoverage(tree, layerId, diagnostics) {
383
- const resources = [...tree.registry.byKind.values()].flatMap((records) => [...records]).sort((left, right) => compareCodeUnits(left.resourceId, right.resourceId));
384
- const resourcesById = new Map(resources.map((resource) => [resource.resourceId, resource]));
385
- for (const resource of resources) {
386
- const identity = tree.contentIdentities.get(resource.resourceId);
387
- if (!identity) {
388
- diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_MISSING", layerLocation(void 0, layerId, resource.resourceId), `Loaded resource '${resource.resourceId}' has no authority identity.`));
389
- continue;
390
- }
391
- const normalized = createResourceContentIdentity({
392
- resourceId: identity.resourceId,
393
- authorityDigest: identity.authorityDigest,
394
- contributions: identity.contributions
395
- });
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.`));
370
+ function materialRelativePath(uri) {
371
+ const match = /^vfs:\/\/\.\/(.+)$/u.exec(uri);
372
+ if (!match || /%2f|%5c/i.test(uri)) return void 0;
373
+ let decoded;
374
+ try {
375
+ decoded = decodeURIComponent(match[1]);
376
+ } catch {
377
+ return;
397
378
  }
398
- for (const resourceId of tree.contentIdentities.keys()) if (!resourcesById.has(resourceId)) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_EXTRA", layerLocation(void 0, layerId, resourceId), `Loaded tree contains an extra authority identity '${resourceId}'.`));
399
- }
400
- function validateEffectiveOrigin(entry, registry, tree, diagnostics) {
401
- const origin = entry.effectiveOrigin;
402
- const descriptor = registry.layers[origin.layerIndex];
403
- const loadedRecord = findResource(tree, entry.resourceId);
404
- if (!descriptor || descriptor.id !== origin.layerId || descriptor.packageId !== origin.packageId || tree.manifest.resourceId !== origin.packageId || !loadedRecord || loadedRecord.documentUri !== origin.documentUri || loadedRecord.logicalPath !== origin.logicalPath) diagnostics.push(diagnostic("RESOURCE_CONTENT_IDENTITY_EFFECTIVE_ORIGIN_MISMATCH", contentLocation(entry.resourceId), `Effective resource '${entry.resourceId}' does not match its exact layer/package/origin facts.`));
379
+ const segments = decoded.split(/[\\/]+/u);
380
+ if (isAbsolute(decoded) || decoded.includes("\\") || segments.some((segment) => !segment || segment === "." || segment === "..")) return void 0;
381
+ return segments.join(sep);
405
382
  }
406
383
  function findResource(tree, resourceId) {
407
384
  for (const records of tree.registry.byKind.values()) {
408
- const resource = records.find((record) => record.resourceId === resourceId);
409
- if (resource) return resource;
385
+ const record = records.find((item) => item.resourceId === resourceId);
386
+ if (record) return record;
410
387
  }
411
388
  }
412
- function stableDiagnostics(diagnostics) {
413
- return Object.freeze([...diagnostics].sort((left, right) => compareCodeUnits(left.location, right.location) || compareCodeUnits(left.code, right.code)));
389
+ function contains(boundary, candidate) {
390
+ return candidate === boundary || candidate.startsWith(`${boundary}${sep}`);
414
391
  }
415
- function compositionError(diagnosticValue) {
416
- return new ResourceCompositionError(Object.freeze([diagnosticValue]));
392
+ function documentUri(root, filePath) {
393
+ return `vfs://@/${relative(root, filePath).split(sep).join("/")}`;
417
394
  }
418
- function diagnostic(code, location, message) {
419
- return Object.freeze({
395
+ function materialError(code, resourceId, message) {
396
+ return new ResourceMaterialError([Object.freeze({
420
397
  code,
421
- location,
398
+ location: `resource-material:${resourceId || "unknown"}`,
422
399
  message
423
- });
424
- }
425
- function layerLocation(index, layerId, resourceId) {
426
- return `content-layer:${index ?? "unknown"}:${layerId}${resourceId === void 0 ? "" : `:${resourceId}`}`;
427
- }
428
- function contentLocation(resourceId) {
429
- return `content:${resourceId || "unnamed"}`;
400
+ })]);
430
401
  }
431
402
  //#endregion
432
- export { CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY, CodePackageLoadError, ResourceCompositionError, ResourceValidationError, admitCodePackageExports, admitCodePackages, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadCodePackageModule, loadResourceTree, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
403
+ export { ResourceCompositionError, ResourceMaterialError, ResourceValidationError, buildResourceDependencySnapshot, composeLayeredResourceRegistry, createResourceContentIdentity, loadResourceTree, readResourceMaterial, resolveEffectiveResourceContentIdentities, sha256Digest, validateResourceTree };
@@ -1,2 +1,2 @@
1
- import { n as resourceProjectionPackage, t as ResourceRegistry } from "./index-DkqggaxV.js";
1
+ import { n as resourceProjectionPackage, t as ResourceRegistry } from "./index-CF4nEkOi.js";
2
2
  export { ResourceRegistry, resourceProjectionPackage };
@@ -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-X6R_4lMW.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-B515mMkO.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 };
@@ -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-BxyKIkBg.js";
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-CaQ25rMj.js";
2
2
  export { SkillCapsuleDistributionError, applySkillCapsuleDistributionPlan, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, planSkillCapsuleDistribution, skillCapsuleDistributionProjection };