halfcode-compiler.xnl 0.2.4 → 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.
@@ -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-6nezdi57.js";
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 };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
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-Bj7BZokJ.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-6nezdi57.js";
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-ClihwpeP.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-BJ5cQQ7P.js";
6
6
  import { fileURLToPath } from "node:url";
7
7
  //#region src/bundled-system-skills.ts
8
8
  function loadHalfcodeResourceDslSystemSkillModule() {
@@ -1,4 +1,4 @@
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-Bj7BZokJ.js";
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 = [];
@@ -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-ClihwpeP.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-BJ5cQQ7P.js";
2
2
  export { SkillCapsuleDistributionError, applySkillCapsuleDistributionPlan, compileResourceSkillCapsule, compileSkillCapsule, compilerSkillPackage, planSkillCapsuleDistribution, skillCapsuleDistributionProjection };
@@ -1,8 +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";
2
+ import { mkdtemp, readFile, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
3
3
  import { dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
4
4
  import { createHash } from "node:crypto";
5
- import { Buffer } from "node:buffer";
5
+ import { tmpdir } from "node:os";
6
+ import { pathToFileURL } from "node:url";
6
7
  //#region ../resource-core/src/canonical.ts
7
8
  function compareCodeUnits(left, right) {
8
9
  if (left < right) return -1;
@@ -379,6 +380,26 @@ const nodeCodePackageRuntime = Object.freeze({
379
380
  realpath,
380
381
  readFile,
381
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
+ },
382
403
  importModule: async (url) => import(url)
383
404
  });
384
405
  var CodePackageLoadError = class extends Error {
@@ -458,13 +479,26 @@ async function loadCodePackageModuleWithRuntime(runtime, input) {
458
479
  if (entry.diagnostics.length > 0 || !entry.entryPath || !entry.bytes) throw new CodePackageLoadError(entry.diagnostics);
459
480
  const contribution = identity.contributions.find((item) => item.key === CODE_PACKAGE_ENTRY_CONTRIBUTION_KEY);
460
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.`);
461
- const url = `data:text/javascript;base64,${Buffer.concat([Buffer.from(entry.bytes), Buffer.from(`\n/* halfcode_revision=${identity.contentDigest} */\n`)]).toString("base64")}`;
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
+ }
462
491
  let moduleNamespace;
492
+ let importFailed = false;
463
493
  try {
464
- moduleNamespace = await runtime.importModule(url);
494
+ moduleNamespace = await runtime.importModule(preparedSource.url);
465
495
  } catch {
466
- throw loadError("RESOURCE_CODE_PACKAGE_IMPORT_FAILED", `${record.documentUri}#CodeBinding`, `CodePackage entry for '${record.resourceId}' could not be imported.`);
496
+ importFailed = true;
497
+ moduleNamespace = Object.freeze({});
467
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.`);
468
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}'.`);
469
503
  const currentBytes = await runtime.readFile(entry.entryPath).catch(() => void 0);
470
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.`);
@@ -1,4 +1,4 @@
1
- import { l as resourceRefToFqn, u as resolveObjectOperationCompilation } from "./src-6nezdi57.js";
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";
@@ -1,4 +1,4 @@
1
- import { n as loadResourceTree } from "./src-Bj7BZokJ.js";
1
+ import { n as loadResourceTree } from "./src-BGFskWEk.js";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { dirname, join } from "node:path";
4
4
  import { parse } from "yaml";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "halfcode-compiler.xnl",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Compile XNL-described applications into runtime-ready skill capsules.",
5
5
  "type": "module",
6
6
  "private": false,