@resourcexjs/cli 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +1399 -1139
  2. package/dist/index.js.map +17 -16
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -770,249 +770,614 @@ var init_prompt = __esm(() => {
770
770
  });
771
771
 
772
772
  // ../../packages/core/dist/index.js
773
- import { gzip } from "zlib";
774
773
  import { promisify } from "util";
775
- import { gunzip } from "zlib";
774
+ import { gzip } from "zlib";
776
775
  import { promisify as promisify2 } from "util";
776
+ import { gunzip } from "zlib";
777
+ import { readdir, readFile, stat } from "fs/promises";
777
778
  import { join, relative } from "path";
778
- import { stat, readFile as readFile2, readdir } from "fs/promises";
779
+ import { readdir as readdir2, readFile as readFile2, stat as stat2 } from "fs/promises";
780
+ import { join as join2, relative as relative2 } from "path";
779
781
  import { createHash } from "crypto";
780
- function $constructor(name, initializer, params) {
781
- function init2(inst, def) {
782
- if (!inst._zod) {
783
- Object.defineProperty(inst, "_zod", {
784
- value: {
785
- def,
786
- constr: _3,
787
- traits: new Set
788
- },
789
- enumerable: false
790
- });
791
- }
792
- if (inst._zod.traits.has(name)) {
793
- return;
794
- }
795
- inst._zod.traits.add(name);
796
- initializer(inst, def);
797
- const proto = _3.prototype;
798
- const keys = Object.keys(proto);
799
- for (let i2 = 0;i2 < keys.length; i2++) {
800
- const k2 = keys[i2];
801
- if (!(k2 in inst)) {
802
- inst[k2] = proto[k2].bind(inst);
803
- }
804
- }
805
- }
806
- const Parent = params?.Parent ?? Object;
807
-
808
- class Definition extends Parent {
809
- }
810
- Object.defineProperty(Definition, "name", { value: name });
811
- function _3(def) {
812
- var _a;
813
- const inst = params?.Parent ? new Definition : this;
814
- init2(inst, def);
815
- (_a = inst._zod).deferred ?? (_a.deferred = []);
816
- for (const fn of inst._zod.deferred) {
817
- fn();
818
- }
819
- return inst;
820
- }
821
- Object.defineProperty(_3, "init", { value: init2 });
822
- Object.defineProperty(_3, Symbol.hasInstance, {
823
- value: (inst) => {
824
- if (params?.Parent && inst instanceof params.Parent)
825
- return true;
826
- return inst?._zod?.traits?.has(name);
827
- }
828
- });
829
- Object.defineProperty(_3, "name", { value: name });
830
- return _3;
831
- }
832
- function config(newConfig) {
833
- if (newConfig)
834
- Object.assign(globalConfig, newConfig);
835
- return globalConfig;
836
- }
837
- function assertEqual(val) {
838
- return val;
839
- }
840
- function assertNotEqual(val) {
841
- return val;
842
- }
843
- function assertIs(_arg) {}
844
- function assertNever(_x) {
845
- throw new Error("Unexpected value in exhaustive check");
782
+ function writeString(view, offset, size, value) {
783
+ if (value)
784
+ encoder.encodeInto(value, view.subarray(offset, offset + size));
846
785
  }
847
- function assert(_3) {}
848
- function getEnumValues(entries) {
849
- const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
850
- const values = Object.entries(entries).filter(([k2, _3]) => numericValues.indexOf(+k2) === -1).map(([_3, v2]) => v2);
851
- return values;
786
+ function writeOctal(view, offset, size, value) {
787
+ if (value === undefined)
788
+ return;
789
+ const octalString = value.toString(8).padStart(size - 1, "0");
790
+ encoder.encodeInto(octalString, view.subarray(offset, offset + size - 1));
852
791
  }
853
- function joinValues(array, separator = "|") {
854
- return array.map((val) => stringifyPrimitive(val)).join(separator);
792
+ async function normalizeBody(body) {
793
+ if (body === null || body === undefined)
794
+ return EMPTY;
795
+ if (body instanceof Uint8Array)
796
+ return body;
797
+ if (typeof body === "string")
798
+ return encoder.encode(body);
799
+ if (body instanceof ArrayBuffer)
800
+ return new Uint8Array(body);
801
+ if (body instanceof Blob)
802
+ return new Uint8Array(await body.arrayBuffer());
803
+ throw new TypeError("Unsupported content type for entry body.");
855
804
  }
856
- function jsonStringifyReplacer(_3, value) {
857
- if (typeof value === "bigint")
858
- return value.toString();
859
- return value;
805
+ function writeChecksum(block) {
806
+ block.fill(CHECKSUM_SPACE, USTAR_CHECKSUM_OFFSET, USTAR_CHECKSUM_OFFSET + USTAR_CHECKSUM_SIZE);
807
+ let checksum = 0;
808
+ for (const byte of block)
809
+ checksum += byte;
810
+ for (let i2 = USTAR_CHECKSUM_OFFSET + 6 - 1;i2 >= USTAR_CHECKSUM_OFFSET; i2--) {
811
+ block[i2] = (checksum & 7) + ASCII_ZERO;
812
+ checksum >>= 3;
813
+ }
814
+ block[USTAR_CHECKSUM_OFFSET + 6] = 0;
815
+ block[USTAR_CHECKSUM_OFFSET + 7] = CHECKSUM_SPACE;
860
816
  }
861
- function cached(getter) {
862
- const set = false;
817
+ function generatePax(header) {
818
+ const paxRecords = {};
819
+ if (header.name.length > USTAR_NAME_SIZE) {
820
+ if (findUstarSplit(header.name) === null)
821
+ paxRecords.path = header.name;
822
+ }
823
+ if (header.linkname && header.linkname.length > USTAR_NAME_SIZE)
824
+ paxRecords.linkpath = header.linkname;
825
+ if (header.uname && header.uname.length > USTAR_UNAME_SIZE)
826
+ paxRecords.uname = header.uname;
827
+ if (header.gname && header.gname.length > USTAR_GNAME_SIZE)
828
+ paxRecords.gname = header.gname;
829
+ if (header.uid != null && header.uid > USTAR_MAX_UID_GID)
830
+ paxRecords.uid = String(header.uid);
831
+ if (header.gid != null && header.gid > USTAR_MAX_UID_GID)
832
+ paxRecords.gid = String(header.gid);
833
+ if (header.size != null && header.size > USTAR_MAX_SIZE)
834
+ paxRecords.size = String(header.size);
835
+ if (header.pax)
836
+ Object.assign(paxRecords, header.pax);
837
+ const paxEntries = Object.entries(paxRecords);
838
+ if (paxEntries.length === 0)
839
+ return null;
840
+ const paxBody = encoder.encode(paxEntries.map(([key, value]) => {
841
+ const record = `${key}=${value}
842
+ `;
843
+ const partLength = encoder.encode(record).length + 1;
844
+ let totalLength = partLength + String(partLength).length;
845
+ totalLength = partLength + String(totalLength).length;
846
+ return `${totalLength} ${record}`;
847
+ }).join(""));
863
848
  return {
864
- get value() {
865
- if (!set) {
866
- const value = getter();
867
- Object.defineProperty(this, "value", { value });
868
- return value;
869
- }
870
- throw new Error("cached value already set");
871
- }
849
+ paxHeader: createTarHeader({
850
+ name: decoder.decode(encoder.encode(`PaxHeader/${header.name}`).slice(0, 100)),
851
+ size: paxBody.length,
852
+ type: "pax-header",
853
+ mode: 420,
854
+ mtime: header.mtime,
855
+ uname: header.uname,
856
+ gname: header.gname,
857
+ uid: header.uid,
858
+ gid: header.gid
859
+ }),
860
+ paxBody
872
861
  };
873
862
  }
874
- function nullish(input) {
875
- return input === null || input === undefined;
876
- }
877
- function cleanRegex(source) {
878
- const start = source.startsWith("^") ? 1 : 0;
879
- const end = source.endsWith("$") ? source.length - 1 : source.length;
880
- return source.slice(start, end);
863
+ function findUstarSplit(path) {
864
+ if (path.length <= USTAR_NAME_SIZE)
865
+ return null;
866
+ const minSlashIndex = path.length - USTAR_NAME_SIZE - 1;
867
+ const slashIndex = path.lastIndexOf("/", USTAR_PREFIX_SIZE);
868
+ if (slashIndex > 0 && slashIndex >= minSlashIndex)
869
+ return {
870
+ prefix: path.slice(0, slashIndex),
871
+ name: path.slice(slashIndex + 1)
872
+ };
873
+ return null;
881
874
  }
882
- function floatSafeRemainder(val, step) {
883
- const valDecCount = (val.toString().split(".")[1] || "").length;
884
- const stepString = step.toString();
885
- let stepDecCount = (stepString.split(".")[1] || "").length;
886
- if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
887
- const match = stepString.match(/\d?e-(\d?)/);
888
- if (match?.[1]) {
889
- stepDecCount = Number.parseInt(match[1]);
875
+ function createTarHeader(header) {
876
+ const view = new Uint8Array(BLOCK_SIZE);
877
+ const size = isBodyless(header) ? 0 : header.size ?? 0;
878
+ let name = header.name;
879
+ let prefix = "";
880
+ if (!header.pax?.path) {
881
+ const split = findUstarSplit(name);
882
+ if (split) {
883
+ name = split.name;
884
+ prefix = split.prefix;
890
885
  }
891
886
  }
892
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
893
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
894
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
895
- return valInt % stepInt / 10 ** decCount;
887
+ writeString(view, USTAR_NAME_OFFSET, USTAR_NAME_SIZE, name);
888
+ writeOctal(view, USTAR_MODE_OFFSET, USTAR_MODE_SIZE, header.mode ?? (header.type === DIRECTORY ? DEFAULT_DIR_MODE : DEFAULT_FILE_MODE));
889
+ writeOctal(view, USTAR_UID_OFFSET, USTAR_UID_SIZE, header.uid ?? 0);
890
+ writeOctal(view, USTAR_GID_OFFSET, USTAR_GID_SIZE, header.gid ?? 0);
891
+ writeOctal(view, USTAR_SIZE_OFFSET, USTAR_SIZE_SIZE, size);
892
+ writeOctal(view, USTAR_MTIME_OFFSET, USTAR_MTIME_SIZE, Math.floor((header.mtime?.getTime() ?? Date.now()) / 1000));
893
+ writeString(view, USTAR_TYPEFLAG_OFFSET, USTAR_TYPEFLAG_SIZE, TYPEFLAG[header.type ?? FILE]);
894
+ writeString(view, USTAR_LINKNAME_OFFSET, USTAR_LINKNAME_SIZE, header.linkname);
895
+ writeString(view, USTAR_MAGIC_OFFSET, USTAR_MAGIC_SIZE, "ustar\x00");
896
+ writeString(view, USTAR_VERSION_OFFSET, USTAR_VERSION_SIZE, USTAR_VERSION);
897
+ writeString(view, USTAR_UNAME_OFFSET, USTAR_UNAME_SIZE, header.uname);
898
+ writeString(view, USTAR_GNAME_OFFSET, USTAR_GNAME_SIZE, header.gname);
899
+ writeString(view, USTAR_PREFIX_OFFSET, USTAR_PREFIX_SIZE, prefix);
900
+ writeChecksum(view);
901
+ return view;
896
902
  }
897
- function defineLazy(object, key, getter) {
898
- let value = undefined;
899
- Object.defineProperty(object, key, {
900
- get() {
901
- if (value === EVALUATING) {
902
- return;
903
+ function getHeaderBlocks(header) {
904
+ const base = createTarHeader(header);
905
+ const pax = generatePax(header);
906
+ if (!pax)
907
+ return [base];
908
+ const paxPadding = -pax.paxBody.length & BLOCK_SIZE_MASK;
909
+ const paddingBlocks = paxPadding > 0 ? [ZERO_BLOCK.subarray(0, paxPadding)] : [];
910
+ return [
911
+ pax.paxHeader,
912
+ pax.paxBody,
913
+ ...paddingBlocks,
914
+ base
915
+ ];
916
+ }
917
+ function createTarPacker(onData, onError, onFinalize) {
918
+ let currentHeader = null;
919
+ let bytesWritten = 0;
920
+ let finalized = false;
921
+ return {
922
+ add(header) {
923
+ if (finalized) {
924
+ const error = /* @__PURE__ */ new Error("No new tar entries after finalize.");
925
+ onError(error);
926
+ throw error;
903
927
  }
904
- if (value === undefined) {
905
- value = EVALUATING;
906
- value = getter();
928
+ if (currentHeader !== null) {
929
+ const error = /* @__PURE__ */ new Error("Previous entry must be completed before adding a new one");
930
+ onError(error);
931
+ throw error;
932
+ }
933
+ try {
934
+ const size = isBodyless(header) ? 0 : header.size ?? 0;
935
+ const headerBlocks = getHeaderBlocks({
936
+ ...header,
937
+ size
938
+ });
939
+ for (const block of headerBlocks)
940
+ onData(block);
941
+ currentHeader = {
942
+ ...header,
943
+ size
944
+ };
945
+ bytesWritten = 0;
946
+ } catch (error) {
947
+ onError(error);
907
948
  }
908
- return value;
909
- },
910
- set(v2) {
911
- Object.defineProperty(object, key, {
912
- value: v2
913
- });
914
949
  },
915
- configurable: true
916
- });
917
- }
918
- function objectClone(obj) {
919
- return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
950
+ write(chunk) {
951
+ if (!currentHeader) {
952
+ const error = /* @__PURE__ */ new Error("No active tar entry.");
953
+ onError(error);
954
+ throw error;
955
+ }
956
+ if (finalized) {
957
+ const error = /* @__PURE__ */ new Error("Cannot write data after finalize.");
958
+ onError(error);
959
+ throw error;
960
+ }
961
+ const newTotal = bytesWritten + chunk.length;
962
+ if (newTotal > currentHeader.size) {
963
+ const error = /* @__PURE__ */ new Error(`"${currentHeader.name}" exceeds given size of ${currentHeader.size} bytes.`);
964
+ onError(error);
965
+ throw error;
966
+ }
967
+ try {
968
+ bytesWritten = newTotal;
969
+ onData(chunk);
970
+ } catch (error) {
971
+ onError(error);
972
+ }
973
+ },
974
+ endEntry() {
975
+ if (!currentHeader) {
976
+ const error = /* @__PURE__ */ new Error("No active entry to end.");
977
+ onError(error);
978
+ throw error;
979
+ }
980
+ if (finalized) {
981
+ const error = /* @__PURE__ */ new Error("Cannot end entry after finalize.");
982
+ onError(error);
983
+ throw error;
984
+ }
985
+ try {
986
+ if (bytesWritten !== currentHeader.size) {
987
+ const error = /* @__PURE__ */ new Error(`Size mismatch for "${currentHeader.name}".`);
988
+ onError(error);
989
+ throw error;
990
+ }
991
+ const paddingSize = -currentHeader.size & BLOCK_SIZE_MASK;
992
+ if (paddingSize > 0)
993
+ onData(new Uint8Array(paddingSize));
994
+ currentHeader = null;
995
+ bytesWritten = 0;
996
+ } catch (error) {
997
+ onError(error);
998
+ throw error;
999
+ }
1000
+ },
1001
+ finalize() {
1002
+ if (finalized) {
1003
+ const error = /* @__PURE__ */ new Error("Archive has already been finalized");
1004
+ onError(error);
1005
+ throw error;
1006
+ }
1007
+ if (currentHeader !== null) {
1008
+ const error = /* @__PURE__ */ new Error("Cannot finalize while an entry is still active");
1009
+ onError(error);
1010
+ throw error;
1011
+ }
1012
+ try {
1013
+ onData(EOF_BUFFER);
1014
+ finalized = true;
1015
+ if (onFinalize)
1016
+ onFinalize();
1017
+ } catch (error) {
1018
+ onError(error);
1019
+ }
1020
+ }
1021
+ };
920
1022
  }
921
- function assignProp(target, prop, value) {
922
- Object.defineProperty(target, prop, {
923
- value,
924
- writable: true,
925
- enumerable: true,
926
- configurable: true
927
- });
1023
+ function createTarPacker2() {
1024
+ let streamController;
1025
+ let packer;
1026
+ return {
1027
+ readable: new ReadableStream({ start(controller) {
1028
+ streamController = controller;
1029
+ packer = createTarPacker(controller.enqueue.bind(controller), controller.error.bind(controller), controller.close.bind(controller));
1030
+ } }),
1031
+ controller: {
1032
+ add(header) {
1033
+ const bodyless = isBodyless(header);
1034
+ const h2 = { ...header };
1035
+ if (bodyless)
1036
+ h2.size = 0;
1037
+ packer.add(h2);
1038
+ if (bodyless)
1039
+ packer.endEntry();
1040
+ return new WritableStream({
1041
+ write(chunk) {
1042
+ packer.write(chunk);
1043
+ },
1044
+ close() {
1045
+ if (!bodyless)
1046
+ packer.endEntry();
1047
+ },
1048
+ abort(reason) {
1049
+ streamController.error(reason);
1050
+ }
1051
+ });
1052
+ },
1053
+ finalize() {
1054
+ packer.finalize();
1055
+ },
1056
+ error(err) {
1057
+ streamController.error(err);
1058
+ }
1059
+ }
1060
+ };
928
1061
  }
929
- function mergeDefs(...defs) {
930
- const mergedDescriptors = {};
931
- for (const def of defs) {
932
- const descriptors = Object.getOwnPropertyDescriptors(def);
933
- Object.assign(mergedDescriptors, descriptors);
1062
+ async function streamToBuffer(stream) {
1063
+ const chunks = [];
1064
+ const reader = stream.getReader();
1065
+ let totalLength = 0;
1066
+ try {
1067
+ while (true) {
1068
+ const { done, value } = await reader.read();
1069
+ if (done)
1070
+ break;
1071
+ chunks.push(value);
1072
+ totalLength += value.length;
1073
+ }
1074
+ const result = new Uint8Array(totalLength);
1075
+ let offset = 0;
1076
+ for (const chunk of chunks) {
1077
+ result.set(chunk, offset);
1078
+ offset += chunk.length;
1079
+ }
1080
+ return result;
1081
+ } finally {
1082
+ reader.releaseLock();
934
1083
  }
935
- return Object.defineProperties({}, mergedDescriptors);
936
- }
937
- function cloneDef(schema) {
938
- return mergeDefs(schema._zod.def);
939
- }
940
- function getElementAtPath(obj, path) {
941
- if (!path)
942
- return obj;
943
- return path.reduce((acc, key) => acc?.[key], obj);
944
1084
  }
945
- function promiseAllObject(promisesObj) {
946
- const keys = Object.keys(promisesObj);
947
- const promises = keys.map((key) => promisesObj[key]);
948
- return Promise.all(promises).then((results) => {
949
- const resolvedObj = {};
950
- for (let i2 = 0;i2 < keys.length; i2++) {
951
- resolvedObj[keys[i2]] = results[i2];
1085
+ async function packTar(entries) {
1086
+ const { readable, controller } = createTarPacker2();
1087
+ await (async () => {
1088
+ for (const entry of entries) {
1089
+ const entryStream = controller.add(entry.header);
1090
+ const body = "body" in entry ? entry.body : entry.data;
1091
+ if (!body) {
1092
+ await entryStream.close();
1093
+ continue;
1094
+ }
1095
+ if (body instanceof ReadableStream)
1096
+ await body.pipeTo(entryStream);
1097
+ else if (body instanceof Blob)
1098
+ await body.stream().pipeTo(entryStream);
1099
+ else
1100
+ try {
1101
+ const chunk = await normalizeBody(body);
1102
+ if (chunk.length > 0) {
1103
+ const writer = entryStream.getWriter();
1104
+ await writer.write(chunk);
1105
+ await writer.close();
1106
+ } else
1107
+ await entryStream.close();
1108
+ } catch {
1109
+ throw new TypeError(`Unsupported content type for entry "${entry.header.name}".`);
1110
+ }
952
1111
  }
953
- return resolvedObj;
954
- });
1112
+ })().then(() => controller.finalize()).catch((err) => controller.error(err));
1113
+ return new Uint8Array(await streamToBuffer(readable));
955
1114
  }
956
- function randomString(length = 10) {
957
- const chars = "abcdefghijklmnopqrstuvwxyz";
958
- let str = "";
959
- for (let i2 = 0;i2 < length; i2++) {
960
- str += chars[Math.floor(Math.random() * chars.length)];
1115
+
1116
+ class RXAImpl {
1117
+ _buffer;
1118
+ constructor(buffer) {
1119
+ this._buffer = buffer;
961
1120
  }
962
- return str;
963
- }
964
- function esc(str) {
965
- return JSON.stringify(str);
966
- }
967
- function slugify(input) {
968
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
969
- }
970
- function isObject(data) {
971
- return typeof data === "object" && data !== null && !Array.isArray(data);
972
- }
973
- function isPlainObject2(o3) {
974
- if (isObject(o3) === false)
975
- return false;
976
- const ctor = o3.constructor;
977
- if (ctor === undefined)
978
- return true;
979
- if (typeof ctor !== "function")
980
- return true;
981
- const prot = ctor.prototype;
982
- if (isObject(prot) === false)
983
- return false;
984
- if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
985
- return false;
1121
+ get stream() {
1122
+ const buffer = this._buffer;
1123
+ return new ReadableStream({
1124
+ start(controller) {
1125
+ controller.enqueue(new Uint8Array(buffer));
1126
+ controller.close();
1127
+ }
1128
+ });
986
1129
  }
987
- return true;
988
- }
989
- function shallowClone(o3) {
990
- if (isPlainObject2(o3))
991
- return { ...o3 };
992
- if (Array.isArray(o3))
993
- return [...o3];
994
- return o3;
995
- }
996
- function numKeys(data) {
997
- let keyCount = 0;
998
- for (const key in data) {
999
- if (Object.prototype.hasOwnProperty.call(data, key)) {
1000
- keyCount++;
1001
- }
1130
+ async buffer() {
1131
+ return this._buffer;
1002
1132
  }
1003
- return keyCount;
1004
- }
1005
- function escapeRegex(str) {
1006
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1007
1133
  }
1008
- function clone(inst, def, params) {
1009
- const cl = new inst._zod.constr(def ?? inst._zod.def);
1010
- if (!def || params?.parent)
1011
- cl._zod.parent = inst;
1012
- return cl;
1013
- }
1014
- function normalizeParams(_params) {
1015
- const params = _params;
1134
+ async function archive(files) {
1135
+ const entries = Object.entries(files).map(([name, content]) => {
1136
+ return {
1137
+ header: { name, size: content.length, type: "file" },
1138
+ body: new Uint8Array(content)
1139
+ };
1140
+ });
1141
+ const tarBuffer = await packTar(entries);
1142
+ const gzipBuffer = await gzipAsync(Buffer.from(tarBuffer));
1143
+ return new RXAImpl(gzipBuffer);
1144
+ }
1145
+ function $constructor(name, initializer, params) {
1146
+ function init2(inst, def) {
1147
+ if (!inst._zod) {
1148
+ Object.defineProperty(inst, "_zod", {
1149
+ value: {
1150
+ def,
1151
+ constr: _3,
1152
+ traits: new Set
1153
+ },
1154
+ enumerable: false
1155
+ });
1156
+ }
1157
+ if (inst._zod.traits.has(name)) {
1158
+ return;
1159
+ }
1160
+ inst._zod.traits.add(name);
1161
+ initializer(inst, def);
1162
+ const proto = _3.prototype;
1163
+ const keys = Object.keys(proto);
1164
+ for (let i2 = 0;i2 < keys.length; i2++) {
1165
+ const k2 = keys[i2];
1166
+ if (!(k2 in inst)) {
1167
+ inst[k2] = proto[k2].bind(inst);
1168
+ }
1169
+ }
1170
+ }
1171
+ const Parent = params?.Parent ?? Object;
1172
+
1173
+ class Definition extends Parent {
1174
+ }
1175
+ Object.defineProperty(Definition, "name", { value: name });
1176
+ function _3(def) {
1177
+ var _a;
1178
+ const inst = params?.Parent ? new Definition : this;
1179
+ init2(inst, def);
1180
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
1181
+ for (const fn of inst._zod.deferred) {
1182
+ fn();
1183
+ }
1184
+ return inst;
1185
+ }
1186
+ Object.defineProperty(_3, "init", { value: init2 });
1187
+ Object.defineProperty(_3, Symbol.hasInstance, {
1188
+ value: (inst) => {
1189
+ if (params?.Parent && inst instanceof params.Parent)
1190
+ return true;
1191
+ return inst?._zod?.traits?.has(name);
1192
+ }
1193
+ });
1194
+ Object.defineProperty(_3, "name", { value: name });
1195
+ return _3;
1196
+ }
1197
+ function config(newConfig) {
1198
+ if (newConfig)
1199
+ Object.assign(globalConfig, newConfig);
1200
+ return globalConfig;
1201
+ }
1202
+ function assertEqual(val) {
1203
+ return val;
1204
+ }
1205
+ function assertNotEqual(val) {
1206
+ return val;
1207
+ }
1208
+ function assertIs(_arg) {}
1209
+ function assertNever(_x) {
1210
+ throw new Error("Unexpected value in exhaustive check");
1211
+ }
1212
+ function assert(_3) {}
1213
+ function getEnumValues(entries) {
1214
+ const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
1215
+ const values = Object.entries(entries).filter(([k2, _3]) => numericValues.indexOf(+k2) === -1).map(([_3, v2]) => v2);
1216
+ return values;
1217
+ }
1218
+ function joinValues(array, separator = "|") {
1219
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
1220
+ }
1221
+ function jsonStringifyReplacer(_3, value) {
1222
+ if (typeof value === "bigint")
1223
+ return value.toString();
1224
+ return value;
1225
+ }
1226
+ function cached(getter) {
1227
+ const set = false;
1228
+ return {
1229
+ get value() {
1230
+ if (!set) {
1231
+ const value = getter();
1232
+ Object.defineProperty(this, "value", { value });
1233
+ return value;
1234
+ }
1235
+ throw new Error("cached value already set");
1236
+ }
1237
+ };
1238
+ }
1239
+ function nullish(input) {
1240
+ return input === null || input === undefined;
1241
+ }
1242
+ function cleanRegex(source) {
1243
+ const start = source.startsWith("^") ? 1 : 0;
1244
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
1245
+ return source.slice(start, end);
1246
+ }
1247
+ function floatSafeRemainder(val, step) {
1248
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1249
+ const stepString = step.toString();
1250
+ let stepDecCount = (stepString.split(".")[1] || "").length;
1251
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
1252
+ const match = stepString.match(/\d?e-(\d?)/);
1253
+ if (match?.[1]) {
1254
+ stepDecCount = Number.parseInt(match[1]);
1255
+ }
1256
+ }
1257
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1258
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1259
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1260
+ return valInt % stepInt / 10 ** decCount;
1261
+ }
1262
+ function defineLazy(object, key, getter) {
1263
+ let value = undefined;
1264
+ Object.defineProperty(object, key, {
1265
+ get() {
1266
+ if (value === EVALUATING) {
1267
+ return;
1268
+ }
1269
+ if (value === undefined) {
1270
+ value = EVALUATING;
1271
+ value = getter();
1272
+ }
1273
+ return value;
1274
+ },
1275
+ set(v2) {
1276
+ Object.defineProperty(object, key, {
1277
+ value: v2
1278
+ });
1279
+ },
1280
+ configurable: true
1281
+ });
1282
+ }
1283
+ function objectClone(obj) {
1284
+ return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
1285
+ }
1286
+ function assignProp(target, prop, value) {
1287
+ Object.defineProperty(target, prop, {
1288
+ value,
1289
+ writable: true,
1290
+ enumerable: true,
1291
+ configurable: true
1292
+ });
1293
+ }
1294
+ function mergeDefs(...defs) {
1295
+ const mergedDescriptors = {};
1296
+ for (const def of defs) {
1297
+ const descriptors = Object.getOwnPropertyDescriptors(def);
1298
+ Object.assign(mergedDescriptors, descriptors);
1299
+ }
1300
+ return Object.defineProperties({}, mergedDescriptors);
1301
+ }
1302
+ function cloneDef(schema) {
1303
+ return mergeDefs(schema._zod.def);
1304
+ }
1305
+ function getElementAtPath(obj, path) {
1306
+ if (!path)
1307
+ return obj;
1308
+ return path.reduce((acc, key) => acc?.[key], obj);
1309
+ }
1310
+ function promiseAllObject(promisesObj) {
1311
+ const keys = Object.keys(promisesObj);
1312
+ const promises = keys.map((key) => promisesObj[key]);
1313
+ return Promise.all(promises).then((results) => {
1314
+ const resolvedObj = {};
1315
+ for (let i2 = 0;i2 < keys.length; i2++) {
1316
+ resolvedObj[keys[i2]] = results[i2];
1317
+ }
1318
+ return resolvedObj;
1319
+ });
1320
+ }
1321
+ function randomString(length = 10) {
1322
+ const chars = "abcdefghijklmnopqrstuvwxyz";
1323
+ let str = "";
1324
+ for (let i2 = 0;i2 < length; i2++) {
1325
+ str += chars[Math.floor(Math.random() * chars.length)];
1326
+ }
1327
+ return str;
1328
+ }
1329
+ function esc(str) {
1330
+ return JSON.stringify(str);
1331
+ }
1332
+ function slugify(input) {
1333
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
1334
+ }
1335
+ function isObject(data) {
1336
+ return typeof data === "object" && data !== null && !Array.isArray(data);
1337
+ }
1338
+ function isPlainObject2(o3) {
1339
+ if (isObject(o3) === false)
1340
+ return false;
1341
+ const ctor = o3.constructor;
1342
+ if (ctor === undefined)
1343
+ return true;
1344
+ if (typeof ctor !== "function")
1345
+ return true;
1346
+ const prot = ctor.prototype;
1347
+ if (isObject(prot) === false)
1348
+ return false;
1349
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
1350
+ return false;
1351
+ }
1352
+ return true;
1353
+ }
1354
+ function shallowClone(o3) {
1355
+ if (isPlainObject2(o3))
1356
+ return { ...o3 };
1357
+ if (Array.isArray(o3))
1358
+ return [...o3];
1359
+ return o3;
1360
+ }
1361
+ function numKeys(data) {
1362
+ let keyCount = 0;
1363
+ for (const key in data) {
1364
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
1365
+ keyCount++;
1366
+ }
1367
+ }
1368
+ return keyCount;
1369
+ }
1370
+ function escapeRegex(str) {
1371
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1372
+ }
1373
+ function clone(inst, def, params) {
1374
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
1375
+ if (!def || params?.parent)
1376
+ cl._zod.parent = inst;
1377
+ return cl;
1378
+ }
1379
+ function normalizeParams(_params) {
1380
+ const params = _params;
1016
1381
  if (!params)
1017
1382
  return {};
1018
1383
  if (typeof params === "string")
@@ -4224,641 +4589,269 @@ function convertBaseSchema(schema, ctx) {
4224
4589
  stringSchema = stringSchema.max(schema.maxLength);
4225
4590
  }
4226
4591
  if (schema.pattern) {
4227
- stringSchema = stringSchema.regex(new RegExp(schema.pattern));
4228
- }
4229
- zodSchema = stringSchema;
4230
- break;
4231
- }
4232
- case "number":
4233
- case "integer": {
4234
- let numberSchema = type === "integer" ? z2.number().int() : z2.number();
4235
- if (typeof schema.minimum === "number") {
4236
- numberSchema = numberSchema.min(schema.minimum);
4237
- }
4238
- if (typeof schema.maximum === "number") {
4239
- numberSchema = numberSchema.max(schema.maximum);
4240
- }
4241
- if (typeof schema.exclusiveMinimum === "number") {
4242
- numberSchema = numberSchema.gt(schema.exclusiveMinimum);
4243
- } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
4244
- numberSchema = numberSchema.gt(schema.minimum);
4245
- }
4246
- if (typeof schema.exclusiveMaximum === "number") {
4247
- numberSchema = numberSchema.lt(schema.exclusiveMaximum);
4248
- } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
4249
- numberSchema = numberSchema.lt(schema.maximum);
4250
- }
4251
- if (typeof schema.multipleOf === "number") {
4252
- numberSchema = numberSchema.multipleOf(schema.multipleOf);
4253
- }
4254
- zodSchema = numberSchema;
4255
- break;
4256
- }
4257
- case "boolean": {
4258
- zodSchema = z2.boolean();
4259
- break;
4260
- }
4261
- case "null": {
4262
- zodSchema = z2.null();
4263
- break;
4264
- }
4265
- case "object": {
4266
- const shape = {};
4267
- const properties = schema.properties || {};
4268
- const requiredSet = new Set(schema.required || []);
4269
- for (const [key, propSchema] of Object.entries(properties)) {
4270
- const propZodSchema = convertSchema(propSchema, ctx);
4271
- shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
4272
- }
4273
- if (schema.propertyNames) {
4274
- const keySchema = convertSchema(schema.propertyNames, ctx);
4275
- const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z2.any();
4276
- if (Object.keys(shape).length === 0) {
4277
- zodSchema = z2.record(keySchema, valueSchema);
4278
- break;
4279
- }
4280
- const objectSchema2 = z2.object(shape).passthrough();
4281
- const recordSchema = z2.looseRecord(keySchema, valueSchema);
4282
- zodSchema = z2.intersection(objectSchema2, recordSchema);
4283
- break;
4284
- }
4285
- if (schema.patternProperties) {
4286
- const patternProps = schema.patternProperties;
4287
- const patternKeys = Object.keys(patternProps);
4288
- const looseRecords = [];
4289
- for (const pattern of patternKeys) {
4290
- const patternValue = convertSchema(patternProps[pattern], ctx);
4291
- const keySchema = z2.string().regex(new RegExp(pattern));
4292
- looseRecords.push(z2.looseRecord(keySchema, patternValue));
4293
- }
4294
- const schemasToIntersect = [];
4295
- if (Object.keys(shape).length > 0) {
4296
- schemasToIntersect.push(z2.object(shape).passthrough());
4297
- }
4298
- schemasToIntersect.push(...looseRecords);
4299
- if (schemasToIntersect.length === 0) {
4300
- zodSchema = z2.object({}).passthrough();
4301
- } else if (schemasToIntersect.length === 1) {
4302
- zodSchema = schemasToIntersect[0];
4303
- } else {
4304
- let result = z2.intersection(schemasToIntersect[0], schemasToIntersect[1]);
4305
- for (let i2 = 2;i2 < schemasToIntersect.length; i2++) {
4306
- result = z2.intersection(result, schemasToIntersect[i2]);
4307
- }
4308
- zodSchema = result;
4309
- }
4310
- break;
4311
- }
4312
- const objectSchema = z2.object(shape);
4313
- if (schema.additionalProperties === false) {
4314
- zodSchema = objectSchema.strict();
4315
- } else if (typeof schema.additionalProperties === "object") {
4316
- zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
4317
- } else {
4318
- zodSchema = objectSchema.passthrough();
4319
- }
4320
- break;
4321
- }
4322
- case "array": {
4323
- const prefixItems = schema.prefixItems;
4324
- const items = schema.items;
4325
- if (prefixItems && Array.isArray(prefixItems)) {
4326
- const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
4327
- const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : undefined;
4328
- if (rest) {
4329
- zodSchema = z2.tuple(tupleItems).rest(rest);
4330
- } else {
4331
- zodSchema = z2.tuple(tupleItems);
4332
- }
4333
- if (typeof schema.minItems === "number") {
4334
- zodSchema = zodSchema.check(z2.minLength(schema.minItems));
4335
- }
4336
- if (typeof schema.maxItems === "number") {
4337
- zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
4338
- }
4339
- } else if (Array.isArray(items)) {
4340
- const tupleItems = items.map((item) => convertSchema(item, ctx));
4341
- const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : undefined;
4342
- if (rest) {
4343
- zodSchema = z2.tuple(tupleItems).rest(rest);
4344
- } else {
4345
- zodSchema = z2.tuple(tupleItems);
4346
- }
4347
- if (typeof schema.minItems === "number") {
4348
- zodSchema = zodSchema.check(z2.minLength(schema.minItems));
4349
- }
4350
- if (typeof schema.maxItems === "number") {
4351
- zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
4352
- }
4353
- } else if (items !== undefined) {
4354
- const element = convertSchema(items, ctx);
4355
- let arraySchema = z2.array(element);
4356
- if (typeof schema.minItems === "number") {
4357
- arraySchema = arraySchema.min(schema.minItems);
4358
- }
4359
- if (typeof schema.maxItems === "number") {
4360
- arraySchema = arraySchema.max(schema.maxItems);
4361
- }
4362
- zodSchema = arraySchema;
4363
- } else {
4364
- zodSchema = z2.array(z2.any());
4365
- }
4366
- break;
4367
- }
4368
- default:
4369
- throw new Error(`Unsupported type: ${type}`);
4370
- }
4371
- if (schema.description) {
4372
- zodSchema = zodSchema.describe(schema.description);
4373
- }
4374
- if (schema.default !== undefined) {
4375
- zodSchema = zodSchema.default(schema.default);
4376
- }
4377
- return zodSchema;
4378
- }
4379
- function convertSchema(schema, ctx) {
4380
- if (typeof schema === "boolean") {
4381
- return schema ? z2.any() : z2.never();
4382
- }
4383
- let baseSchema = convertBaseSchema(schema, ctx);
4384
- const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
4385
- if (schema.anyOf && Array.isArray(schema.anyOf)) {
4386
- const options = schema.anyOf.map((s2) => convertSchema(s2, ctx));
4387
- const anyOfUnion = z2.union(options);
4388
- baseSchema = hasExplicitType ? z2.intersection(baseSchema, anyOfUnion) : anyOfUnion;
4389
- }
4390
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
4391
- const options = schema.oneOf.map((s2) => convertSchema(s2, ctx));
4392
- const oneOfUnion = z2.xor(options);
4393
- baseSchema = hasExplicitType ? z2.intersection(baseSchema, oneOfUnion) : oneOfUnion;
4394
- }
4395
- if (schema.allOf && Array.isArray(schema.allOf)) {
4396
- if (schema.allOf.length === 0) {
4397
- baseSchema = hasExplicitType ? baseSchema : z2.any();
4398
- } else {
4399
- let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
4400
- const startIdx = hasExplicitType ? 0 : 1;
4401
- for (let i2 = startIdx;i2 < schema.allOf.length; i2++) {
4402
- result = z2.intersection(result, convertSchema(schema.allOf[i2], ctx));
4403
- }
4404
- baseSchema = result;
4405
- }
4406
- }
4407
- if (schema.nullable === true && ctx.version === "openapi-3.0") {
4408
- baseSchema = z2.nullable(baseSchema);
4409
- }
4410
- if (schema.readOnly === true) {
4411
- baseSchema = z2.readonly(baseSchema);
4412
- }
4413
- const extraMeta = {};
4414
- const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
4415
- for (const key of coreMetadataKeys) {
4416
- if (key in schema) {
4417
- extraMeta[key] = schema[key];
4418
- }
4419
- }
4420
- const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
4421
- for (const key of contentMetadataKeys) {
4422
- if (key in schema) {
4423
- extraMeta[key] = schema[key];
4424
- }
4425
- }
4426
- for (const key of Object.keys(schema)) {
4427
- if (!RECOGNIZED_KEYS.has(key)) {
4428
- extraMeta[key] = schema[key];
4429
- }
4430
- }
4431
- if (Object.keys(extraMeta).length > 0) {
4432
- ctx.registry.add(baseSchema, extraMeta);
4433
- }
4434
- return baseSchema;
4435
- }
4436
- function fromJSONSchema(schema, params) {
4437
- if (typeof schema === "boolean") {
4438
- return schema ? z2.any() : z2.never();
4439
- }
4440
- const version2 = detectVersion(schema, params?.defaultTarget);
4441
- const defs = schema.$defs || schema.definitions || {};
4442
- const ctx = {
4443
- version: version2,
4444
- defs,
4445
- refs: new Map,
4446
- processing: new Set,
4447
- rootSchema: schema,
4448
- registry: params?.registry ?? globalRegistry
4449
- };
4450
- return convertSchema(schema, ctx);
4451
- }
4452
- function string3(params) {
4453
- return _coercedString(ZodString, params);
4454
- }
4455
- function number3(params) {
4456
- return _coercedNumber(ZodNumber, params);
4457
- }
4458
- function boolean3(params) {
4459
- return _coercedBoolean(ZodBoolean, params);
4460
- }
4461
- function bigint3(params) {
4462
- return _coercedBigint(ZodBigInt, params);
4463
- }
4464
- function date4(params) {
4465
- return _coercedDate(ZodDate, params);
4466
- }
4467
- function define(input) {
4468
- if (input === null || typeof input !== "object") {
4469
- throw new DefinitionError("definition must be an object");
4470
- }
4471
- let validated;
4472
- try {
4473
- validated = RXDSchema.parse(input);
4474
- } catch (e2) {
4475
- throw new DefinitionError(`Invalid definition: ${e2 instanceof Error ? e2.message : String(e2)}`);
4476
- }
4477
- const rxd = Object.assign(Object.create(null), {
4478
- name: validated.name,
4479
- type: validated.type,
4480
- tag: validated.tag ?? validated.version ?? undefined,
4481
- registry: validated.registry,
4482
- path: validated.path,
4483
- description: validated.description,
4484
- author: validated.author,
4485
- license: validated.license,
4486
- keywords: validated.keywords,
4487
- repository: validated.repository
4488
- });
4489
- return rxd;
4490
- }
4491
- function manifest(rxd) {
4492
- return {
4493
- registry: rxd.registry,
4494
- path: rxd.path,
4495
- name: rxd.name,
4496
- type: rxd.type,
4497
- tag: rxd.tag ?? "latest"
4498
- };
4499
- }
4500
- function writeString(view, offset, size, value) {
4501
- if (value)
4502
- encoder.encodeInto(value, view.subarray(offset, offset + size));
4503
- }
4504
- function writeOctal(view, offset, size, value) {
4505
- if (value === undefined)
4506
- return;
4507
- const octalString = value.toString(8).padStart(size - 1, "0");
4508
- encoder.encodeInto(octalString, view.subarray(offset, offset + size - 1));
4509
- }
4510
- async function normalizeBody(body) {
4511
- if (body === null || body === undefined)
4512
- return EMPTY;
4513
- if (body instanceof Uint8Array)
4514
- return body;
4515
- if (typeof body === "string")
4516
- return encoder.encode(body);
4517
- if (body instanceof ArrayBuffer)
4518
- return new Uint8Array(body);
4519
- if (body instanceof Blob)
4520
- return new Uint8Array(await body.arrayBuffer());
4521
- throw new TypeError("Unsupported content type for entry body.");
4522
- }
4523
- function writeChecksum(block) {
4524
- block.fill(CHECKSUM_SPACE, USTAR_CHECKSUM_OFFSET, USTAR_CHECKSUM_OFFSET + USTAR_CHECKSUM_SIZE);
4525
- let checksum = 0;
4526
- for (const byte of block)
4527
- checksum += byte;
4528
- for (let i2 = USTAR_CHECKSUM_OFFSET + 6 - 1;i2 >= USTAR_CHECKSUM_OFFSET; i2--) {
4529
- block[i2] = (checksum & 7) + ASCII_ZERO;
4530
- checksum >>= 3;
4531
- }
4532
- block[USTAR_CHECKSUM_OFFSET + 6] = 0;
4533
- block[USTAR_CHECKSUM_OFFSET + 7] = CHECKSUM_SPACE;
4534
- }
4535
- function generatePax(header) {
4536
- const paxRecords = {};
4537
- if (header.name.length > USTAR_NAME_SIZE) {
4538
- if (findUstarSplit(header.name) === null)
4539
- paxRecords.path = header.name;
4540
- }
4541
- if (header.linkname && header.linkname.length > USTAR_NAME_SIZE)
4542
- paxRecords.linkpath = header.linkname;
4543
- if (header.uname && header.uname.length > USTAR_UNAME_SIZE)
4544
- paxRecords.uname = header.uname;
4545
- if (header.gname && header.gname.length > USTAR_GNAME_SIZE)
4546
- paxRecords.gname = header.gname;
4547
- if (header.uid != null && header.uid > USTAR_MAX_UID_GID)
4548
- paxRecords.uid = String(header.uid);
4549
- if (header.gid != null && header.gid > USTAR_MAX_UID_GID)
4550
- paxRecords.gid = String(header.gid);
4551
- if (header.size != null && header.size > USTAR_MAX_SIZE)
4552
- paxRecords.size = String(header.size);
4553
- if (header.pax)
4554
- Object.assign(paxRecords, header.pax);
4555
- const paxEntries = Object.entries(paxRecords);
4556
- if (paxEntries.length === 0)
4557
- return null;
4558
- const paxBody = encoder.encode(paxEntries.map(([key, value]) => {
4559
- const record2 = `${key}=${value}
4560
- `;
4561
- const partLength = encoder.encode(record2).length + 1;
4562
- let totalLength = partLength + String(partLength).length;
4563
- totalLength = partLength + String(totalLength).length;
4564
- return `${totalLength} ${record2}`;
4565
- }).join(""));
4566
- return {
4567
- paxHeader: createTarHeader({
4568
- name: decoder.decode(encoder.encode(`PaxHeader/${header.name}`).slice(0, 100)),
4569
- size: paxBody.length,
4570
- type: "pax-header",
4571
- mode: 420,
4572
- mtime: header.mtime,
4573
- uname: header.uname,
4574
- gname: header.gname,
4575
- uid: header.uid,
4576
- gid: header.gid
4577
- }),
4578
- paxBody
4579
- };
4580
- }
4581
- function findUstarSplit(path) {
4582
- if (path.length <= USTAR_NAME_SIZE)
4583
- return null;
4584
- const minSlashIndex = path.length - USTAR_NAME_SIZE - 1;
4585
- const slashIndex = path.lastIndexOf("/", USTAR_PREFIX_SIZE);
4586
- if (slashIndex > 0 && slashIndex >= minSlashIndex)
4587
- return {
4588
- prefix: path.slice(0, slashIndex),
4589
- name: path.slice(slashIndex + 1)
4590
- };
4591
- return null;
4592
- }
4593
- function createTarHeader(header) {
4594
- const view = new Uint8Array(BLOCK_SIZE);
4595
- const size = isBodyless(header) ? 0 : header.size ?? 0;
4596
- let name = header.name;
4597
- let prefix = "";
4598
- if (!header.pax?.path) {
4599
- const split = findUstarSplit(name);
4600
- if (split) {
4601
- name = split.name;
4602
- prefix = split.prefix;
4603
- }
4604
- }
4605
- writeString(view, USTAR_NAME_OFFSET, USTAR_NAME_SIZE, name);
4606
- writeOctal(view, USTAR_MODE_OFFSET, USTAR_MODE_SIZE, header.mode ?? (header.type === DIRECTORY ? DEFAULT_DIR_MODE : DEFAULT_FILE_MODE));
4607
- writeOctal(view, USTAR_UID_OFFSET, USTAR_UID_SIZE, header.uid ?? 0);
4608
- writeOctal(view, USTAR_GID_OFFSET, USTAR_GID_SIZE, header.gid ?? 0);
4609
- writeOctal(view, USTAR_SIZE_OFFSET, USTAR_SIZE_SIZE, size);
4610
- writeOctal(view, USTAR_MTIME_OFFSET, USTAR_MTIME_SIZE, Math.floor((header.mtime?.getTime() ?? Date.now()) / 1000));
4611
- writeString(view, USTAR_TYPEFLAG_OFFSET, USTAR_TYPEFLAG_SIZE, TYPEFLAG[header.type ?? FILE]);
4612
- writeString(view, USTAR_LINKNAME_OFFSET, USTAR_LINKNAME_SIZE, header.linkname);
4613
- writeString(view, USTAR_MAGIC_OFFSET, USTAR_MAGIC_SIZE, "ustar\x00");
4614
- writeString(view, USTAR_VERSION_OFFSET, USTAR_VERSION_SIZE, USTAR_VERSION);
4615
- writeString(view, USTAR_UNAME_OFFSET, USTAR_UNAME_SIZE, header.uname);
4616
- writeString(view, USTAR_GNAME_OFFSET, USTAR_GNAME_SIZE, header.gname);
4617
- writeString(view, USTAR_PREFIX_OFFSET, USTAR_PREFIX_SIZE, prefix);
4618
- writeChecksum(view);
4619
- return view;
4620
- }
4621
- function getHeaderBlocks(header) {
4622
- const base = createTarHeader(header);
4623
- const pax = generatePax(header);
4624
- if (!pax)
4625
- return [base];
4626
- const paxPadding = -pax.paxBody.length & BLOCK_SIZE_MASK;
4627
- const paddingBlocks = paxPadding > 0 ? [ZERO_BLOCK.subarray(0, paxPadding)] : [];
4628
- return [
4629
- pax.paxHeader,
4630
- pax.paxBody,
4631
- ...paddingBlocks,
4632
- base
4633
- ];
4634
- }
4635
- function createTarPacker(onData, onError, onFinalize) {
4636
- let currentHeader = null;
4637
- let bytesWritten = 0;
4638
- let finalized = false;
4639
- return {
4640
- add(header) {
4641
- if (finalized) {
4642
- const error48 = /* @__PURE__ */ new Error("No new tar entries after finalize.");
4643
- onError(error48);
4644
- throw error48;
4645
- }
4646
- if (currentHeader !== null) {
4647
- const error48 = /* @__PURE__ */ new Error("Previous entry must be completed before adding a new one");
4648
- onError(error48);
4649
- throw error48;
4650
- }
4651
- try {
4652
- const size = isBodyless(header) ? 0 : header.size ?? 0;
4653
- const headerBlocks = getHeaderBlocks({
4654
- ...header,
4655
- size
4656
- });
4657
- for (const block of headerBlocks)
4658
- onData(block);
4659
- currentHeader = {
4660
- ...header,
4661
- size
4662
- };
4663
- bytesWritten = 0;
4664
- } catch (error48) {
4665
- onError(error48);
4666
- }
4667
- },
4668
- write(chunk) {
4669
- if (!currentHeader) {
4670
- const error48 = /* @__PURE__ */ new Error("No active tar entry.");
4671
- onError(error48);
4672
- throw error48;
4592
+ stringSchema = stringSchema.regex(new RegExp(schema.pattern));
4673
4593
  }
4674
- if (finalized) {
4675
- const error48 = /* @__PURE__ */ new Error("Cannot write data after finalize.");
4676
- onError(error48);
4677
- throw error48;
4594
+ zodSchema = stringSchema;
4595
+ break;
4596
+ }
4597
+ case "number":
4598
+ case "integer": {
4599
+ let numberSchema = type === "integer" ? z2.number().int() : z2.number();
4600
+ if (typeof schema.minimum === "number") {
4601
+ numberSchema = numberSchema.min(schema.minimum);
4678
4602
  }
4679
- const newTotal = bytesWritten + chunk.length;
4680
- if (newTotal > currentHeader.size) {
4681
- const error48 = /* @__PURE__ */ new Error(`"${currentHeader.name}" exceeds given size of ${currentHeader.size} bytes.`);
4682
- onError(error48);
4683
- throw error48;
4603
+ if (typeof schema.maximum === "number") {
4604
+ numberSchema = numberSchema.max(schema.maximum);
4684
4605
  }
4685
- try {
4686
- bytesWritten = newTotal;
4687
- onData(chunk);
4688
- } catch (error48) {
4689
- onError(error48);
4606
+ if (typeof schema.exclusiveMinimum === "number") {
4607
+ numberSchema = numberSchema.gt(schema.exclusiveMinimum);
4608
+ } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
4609
+ numberSchema = numberSchema.gt(schema.minimum);
4690
4610
  }
4691
- },
4692
- endEntry() {
4693
- if (!currentHeader) {
4694
- const error48 = /* @__PURE__ */ new Error("No active entry to end.");
4695
- onError(error48);
4696
- throw error48;
4611
+ if (typeof schema.exclusiveMaximum === "number") {
4612
+ numberSchema = numberSchema.lt(schema.exclusiveMaximum);
4613
+ } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
4614
+ numberSchema = numberSchema.lt(schema.maximum);
4697
4615
  }
4698
- if (finalized) {
4699
- const error48 = /* @__PURE__ */ new Error("Cannot end entry after finalize.");
4700
- onError(error48);
4701
- throw error48;
4616
+ if (typeof schema.multipleOf === "number") {
4617
+ numberSchema = numberSchema.multipleOf(schema.multipleOf);
4702
4618
  }
4703
- try {
4704
- if (bytesWritten !== currentHeader.size) {
4705
- const error48 = /* @__PURE__ */ new Error(`Size mismatch for "${currentHeader.name}".`);
4706
- onError(error48);
4707
- throw error48;
4619
+ zodSchema = numberSchema;
4620
+ break;
4621
+ }
4622
+ case "boolean": {
4623
+ zodSchema = z2.boolean();
4624
+ break;
4625
+ }
4626
+ case "null": {
4627
+ zodSchema = z2.null();
4628
+ break;
4629
+ }
4630
+ case "object": {
4631
+ const shape = {};
4632
+ const properties = schema.properties || {};
4633
+ const requiredSet = new Set(schema.required || []);
4634
+ for (const [key, propSchema] of Object.entries(properties)) {
4635
+ const propZodSchema = convertSchema(propSchema, ctx);
4636
+ shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
4637
+ }
4638
+ if (schema.propertyNames) {
4639
+ const keySchema = convertSchema(schema.propertyNames, ctx);
4640
+ const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z2.any();
4641
+ if (Object.keys(shape).length === 0) {
4642
+ zodSchema = z2.record(keySchema, valueSchema);
4643
+ break;
4708
4644
  }
4709
- const paddingSize = -currentHeader.size & BLOCK_SIZE_MASK;
4710
- if (paddingSize > 0)
4711
- onData(new Uint8Array(paddingSize));
4712
- currentHeader = null;
4713
- bytesWritten = 0;
4714
- } catch (error48) {
4715
- onError(error48);
4716
- throw error48;
4645
+ const objectSchema2 = z2.object(shape).passthrough();
4646
+ const recordSchema = z2.looseRecord(keySchema, valueSchema);
4647
+ zodSchema = z2.intersection(objectSchema2, recordSchema);
4648
+ break;
4717
4649
  }
4718
- },
4719
- finalize() {
4720
- if (finalized) {
4721
- const error48 = /* @__PURE__ */ new Error("Archive has already been finalized");
4722
- onError(error48);
4723
- throw error48;
4650
+ if (schema.patternProperties) {
4651
+ const patternProps = schema.patternProperties;
4652
+ const patternKeys = Object.keys(patternProps);
4653
+ const looseRecords = [];
4654
+ for (const pattern of patternKeys) {
4655
+ const patternValue = convertSchema(patternProps[pattern], ctx);
4656
+ const keySchema = z2.string().regex(new RegExp(pattern));
4657
+ looseRecords.push(z2.looseRecord(keySchema, patternValue));
4658
+ }
4659
+ const schemasToIntersect = [];
4660
+ if (Object.keys(shape).length > 0) {
4661
+ schemasToIntersect.push(z2.object(shape).passthrough());
4662
+ }
4663
+ schemasToIntersect.push(...looseRecords);
4664
+ if (schemasToIntersect.length === 0) {
4665
+ zodSchema = z2.object({}).passthrough();
4666
+ } else if (schemasToIntersect.length === 1) {
4667
+ zodSchema = schemasToIntersect[0];
4668
+ } else {
4669
+ let result = z2.intersection(schemasToIntersect[0], schemasToIntersect[1]);
4670
+ for (let i2 = 2;i2 < schemasToIntersect.length; i2++) {
4671
+ result = z2.intersection(result, schemasToIntersect[i2]);
4672
+ }
4673
+ zodSchema = result;
4674
+ }
4675
+ break;
4724
4676
  }
4725
- if (currentHeader !== null) {
4726
- const error48 = /* @__PURE__ */ new Error("Cannot finalize while an entry is still active");
4727
- onError(error48);
4728
- throw error48;
4677
+ const objectSchema = z2.object(shape);
4678
+ if (schema.additionalProperties === false) {
4679
+ zodSchema = objectSchema.strict();
4680
+ } else if (typeof schema.additionalProperties === "object") {
4681
+ zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
4682
+ } else {
4683
+ zodSchema = objectSchema.passthrough();
4729
4684
  }
4730
- try {
4731
- onData(EOF_BUFFER);
4732
- finalized = true;
4733
- if (onFinalize)
4734
- onFinalize();
4735
- } catch (error48) {
4736
- onError(error48);
4685
+ break;
4686
+ }
4687
+ case "array": {
4688
+ const prefixItems = schema.prefixItems;
4689
+ const items = schema.items;
4690
+ if (prefixItems && Array.isArray(prefixItems)) {
4691
+ const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
4692
+ const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : undefined;
4693
+ if (rest) {
4694
+ zodSchema = z2.tuple(tupleItems).rest(rest);
4695
+ } else {
4696
+ zodSchema = z2.tuple(tupleItems);
4697
+ }
4698
+ if (typeof schema.minItems === "number") {
4699
+ zodSchema = zodSchema.check(z2.minLength(schema.minItems));
4700
+ }
4701
+ if (typeof schema.maxItems === "number") {
4702
+ zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
4703
+ }
4704
+ } else if (Array.isArray(items)) {
4705
+ const tupleItems = items.map((item) => convertSchema(item, ctx));
4706
+ const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : undefined;
4707
+ if (rest) {
4708
+ zodSchema = z2.tuple(tupleItems).rest(rest);
4709
+ } else {
4710
+ zodSchema = z2.tuple(tupleItems);
4711
+ }
4712
+ if (typeof schema.minItems === "number") {
4713
+ zodSchema = zodSchema.check(z2.minLength(schema.minItems));
4714
+ }
4715
+ if (typeof schema.maxItems === "number") {
4716
+ zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
4717
+ }
4718
+ } else if (items !== undefined) {
4719
+ const element = convertSchema(items, ctx);
4720
+ let arraySchema = z2.array(element);
4721
+ if (typeof schema.minItems === "number") {
4722
+ arraySchema = arraySchema.min(schema.minItems);
4723
+ }
4724
+ if (typeof schema.maxItems === "number") {
4725
+ arraySchema = arraySchema.max(schema.maxItems);
4726
+ }
4727
+ zodSchema = arraySchema;
4728
+ } else {
4729
+ zodSchema = z2.array(z2.any());
4737
4730
  }
4731
+ break;
4738
4732
  }
4739
- };
4733
+ default:
4734
+ throw new Error(`Unsupported type: ${type}`);
4735
+ }
4736
+ if (schema.description) {
4737
+ zodSchema = zodSchema.describe(schema.description);
4738
+ }
4739
+ if (schema.default !== undefined) {
4740
+ zodSchema = zodSchema.default(schema.default);
4741
+ }
4742
+ return zodSchema;
4740
4743
  }
4741
- function createTarPacker2() {
4742
- let streamController;
4743
- let packer;
4744
- return {
4745
- readable: new ReadableStream({ start(controller) {
4746
- streamController = controller;
4747
- packer = createTarPacker(controller.enqueue.bind(controller), controller.error.bind(controller), controller.close.bind(controller));
4748
- } }),
4749
- controller: {
4750
- add(header) {
4751
- const bodyless = isBodyless(header);
4752
- const h2 = { ...header };
4753
- if (bodyless)
4754
- h2.size = 0;
4755
- packer.add(h2);
4756
- if (bodyless)
4757
- packer.endEntry();
4758
- return new WritableStream({
4759
- write(chunk) {
4760
- packer.write(chunk);
4761
- },
4762
- close() {
4763
- if (!bodyless)
4764
- packer.endEntry();
4765
- },
4766
- abort(reason) {
4767
- streamController.error(reason);
4768
- }
4769
- });
4770
- },
4771
- finalize() {
4772
- packer.finalize();
4773
- },
4774
- error(err) {
4775
- streamController.error(err);
4744
+ function convertSchema(schema, ctx) {
4745
+ if (typeof schema === "boolean") {
4746
+ return schema ? z2.any() : z2.never();
4747
+ }
4748
+ let baseSchema = convertBaseSchema(schema, ctx);
4749
+ const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
4750
+ if (schema.anyOf && Array.isArray(schema.anyOf)) {
4751
+ const options = schema.anyOf.map((s2) => convertSchema(s2, ctx));
4752
+ const anyOfUnion = z2.union(options);
4753
+ baseSchema = hasExplicitType ? z2.intersection(baseSchema, anyOfUnion) : anyOfUnion;
4754
+ }
4755
+ if (schema.oneOf && Array.isArray(schema.oneOf)) {
4756
+ const options = schema.oneOf.map((s2) => convertSchema(s2, ctx));
4757
+ const oneOfUnion = z2.xor(options);
4758
+ baseSchema = hasExplicitType ? z2.intersection(baseSchema, oneOfUnion) : oneOfUnion;
4759
+ }
4760
+ if (schema.allOf && Array.isArray(schema.allOf)) {
4761
+ if (schema.allOf.length === 0) {
4762
+ baseSchema = hasExplicitType ? baseSchema : z2.any();
4763
+ } else {
4764
+ let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
4765
+ const startIdx = hasExplicitType ? 0 : 1;
4766
+ for (let i2 = startIdx;i2 < schema.allOf.length; i2++) {
4767
+ result = z2.intersection(result, convertSchema(schema.allOf[i2], ctx));
4776
4768
  }
4769
+ baseSchema = result;
4777
4770
  }
4778
- };
4779
- }
4780
- async function streamToBuffer(stream) {
4781
- const chunks = [];
4782
- const reader = stream.getReader();
4783
- let totalLength = 0;
4784
- try {
4785
- while (true) {
4786
- const { done, value } = await reader.read();
4787
- if (done)
4788
- break;
4789
- chunks.push(value);
4790
- totalLength += value.length;
4771
+ }
4772
+ if (schema.nullable === true && ctx.version === "openapi-3.0") {
4773
+ baseSchema = z2.nullable(baseSchema);
4774
+ }
4775
+ if (schema.readOnly === true) {
4776
+ baseSchema = z2.readonly(baseSchema);
4777
+ }
4778
+ const extraMeta = {};
4779
+ const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
4780
+ for (const key of coreMetadataKeys) {
4781
+ if (key in schema) {
4782
+ extraMeta[key] = schema[key];
4791
4783
  }
4792
- const result = new Uint8Array(totalLength);
4793
- let offset = 0;
4794
- for (const chunk of chunks) {
4795
- result.set(chunk, offset);
4796
- offset += chunk.length;
4784
+ }
4785
+ const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
4786
+ for (const key of contentMetadataKeys) {
4787
+ if (key in schema) {
4788
+ extraMeta[key] = schema[key];
4797
4789
  }
4798
- return result;
4799
- } finally {
4800
- reader.releaseLock();
4801
4790
  }
4802
- }
4803
- async function packTar(entries) {
4804
- const { readable, controller } = createTarPacker2();
4805
- await (async () => {
4806
- for (const entry of entries) {
4807
- const entryStream = controller.add(entry.header);
4808
- const body = "body" in entry ? entry.body : entry.data;
4809
- if (!body) {
4810
- await entryStream.close();
4811
- continue;
4812
- }
4813
- if (body instanceof ReadableStream)
4814
- await body.pipeTo(entryStream);
4815
- else if (body instanceof Blob)
4816
- await body.stream().pipeTo(entryStream);
4817
- else
4818
- try {
4819
- const chunk = await normalizeBody(body);
4820
- if (chunk.length > 0) {
4821
- const writer = entryStream.getWriter();
4822
- await writer.write(chunk);
4823
- await writer.close();
4824
- } else
4825
- await entryStream.close();
4826
- } catch {
4827
- throw new TypeError(`Unsupported content type for entry "${entry.header.name}".`);
4828
- }
4791
+ for (const key of Object.keys(schema)) {
4792
+ if (!RECOGNIZED_KEYS.has(key)) {
4793
+ extraMeta[key] = schema[key];
4829
4794
  }
4830
- })().then(() => controller.finalize()).catch((err) => controller.error(err));
4831
- return new Uint8Array(await streamToBuffer(readable));
4832
- }
4833
-
4834
- class RXAImpl {
4835
- _buffer;
4836
- constructor(buffer) {
4837
- this._buffer = buffer;
4838
4795
  }
4839
- get stream() {
4840
- const buffer = this._buffer;
4841
- return new ReadableStream({
4842
- start(controller) {
4843
- controller.enqueue(new Uint8Array(buffer));
4844
- controller.close();
4845
- }
4846
- });
4796
+ if (Object.keys(extraMeta).length > 0) {
4797
+ ctx.registry.add(baseSchema, extraMeta);
4847
4798
  }
4848
- async buffer() {
4849
- return this._buffer;
4799
+ return baseSchema;
4800
+ }
4801
+ function fromJSONSchema(schema, params) {
4802
+ if (typeof schema === "boolean") {
4803
+ return schema ? z2.any() : z2.never();
4850
4804
  }
4805
+ const version2 = detectVersion(schema, params?.defaultTarget);
4806
+ const defs = schema.$defs || schema.definitions || {};
4807
+ const ctx = {
4808
+ version: version2,
4809
+ defs,
4810
+ refs: new Map,
4811
+ processing: new Set,
4812
+ rootSchema: schema,
4813
+ registry: params?.registry ?? globalRegistry
4814
+ };
4815
+ return convertSchema(schema, ctx);
4851
4816
  }
4852
- async function archive(files) {
4853
- const entries = Object.entries(files).map(([name, content]) => {
4854
- return {
4855
- header: { name, size: content.length, type: "file" },
4856
- body: new Uint8Array(content)
4857
- };
4817
+ function string3(params) {
4818
+ return _coercedString(ZodString, params);
4819
+ }
4820
+ function number3(params) {
4821
+ return _coercedNumber(ZodNumber, params);
4822
+ }
4823
+ function boolean3(params) {
4824
+ return _coercedBoolean(ZodBoolean, params);
4825
+ }
4826
+ function bigint3(params) {
4827
+ return _coercedBigint(ZodBigInt, params);
4828
+ }
4829
+ function date4(params) {
4830
+ return _coercedDate(ZodDate, params);
4831
+ }
4832
+ function define(input) {
4833
+ if (input === null || typeof input !== "object") {
4834
+ throw new DefinitionError("definition must be an object");
4835
+ }
4836
+ let validated;
4837
+ try {
4838
+ validated = RXDSchema.parse(input);
4839
+ } catch (e2) {
4840
+ throw new DefinitionError(`Invalid definition: ${e2 instanceof Error ? e2.message : String(e2)}`);
4841
+ }
4842
+ const rxd = Object.assign(Object.create(null), {
4843
+ name: validated.name,
4844
+ type: validated.type,
4845
+ tag: validated.tag ?? validated.version ?? undefined,
4846
+ registry: validated.registry,
4847
+ path: validated.path,
4848
+ description: validated.description,
4849
+ author: validated.author,
4850
+ license: validated.license,
4851
+ keywords: validated.keywords,
4852
+ repository: validated.repository
4858
4853
  });
4859
- const tarBuffer = await packTar(entries);
4860
- const gzipBuffer = await gzipAsync(Buffer.from(tarBuffer));
4861
- return new RXAImpl(gzipBuffer);
4854
+ return rxd;
4862
4855
  }
4863
4856
  function locate(rxm) {
4864
4857
  return {
@@ -4868,6 +4861,15 @@ function locate(rxm) {
4868
4861
  tag: rxm.tag
4869
4862
  };
4870
4863
  }
4864
+ function manifest(rxd) {
4865
+ return {
4866
+ registry: rxd.registry,
4867
+ path: rxd.path,
4868
+ name: rxd.name,
4869
+ type: rxd.type,
4870
+ tag: rxd.tag ?? "latest"
4871
+ };
4872
+ }
4871
4873
  function resource(rxm, rxa) {
4872
4874
  const rxl = locate(rxm);
4873
4875
  return {
@@ -4877,59 +4879,6 @@ function resource(rxm, rxa) {
4877
4879
  };
4878
4880
  }
4879
4881
 
4880
- class TypeHandlerChain {
4881
- handlers = new Map;
4882
- constructor() {
4883
- for (const type of builtinTypes) {
4884
- this.registerInternal(type);
4885
- }
4886
- }
4887
- static create() {
4888
- return new TypeHandlerChain;
4889
- }
4890
- registerInternal(type) {
4891
- this.handlers.set(type.name, type);
4892
- if (type.aliases) {
4893
- for (const alias of type.aliases) {
4894
- this.handlers.set(alias, type);
4895
- }
4896
- }
4897
- }
4898
- register(type) {
4899
- if (this.handlers.has(type.name)) {
4900
- throw new ResourceTypeError(`Type '${type.name}' is already registered`);
4901
- }
4902
- this.handlers.set(type.name, type);
4903
- if (type.aliases) {
4904
- for (const alias of type.aliases) {
4905
- if (this.handlers.has(alias)) {
4906
- throw new ResourceTypeError(`Alias '${alias}' conflicts with existing type or alias`);
4907
- }
4908
- this.handlers.set(alias, type);
4909
- }
4910
- }
4911
- }
4912
- canHandle(typeName) {
4913
- return this.handlers.has(typeName);
4914
- }
4915
- getHandler(typeName) {
4916
- const handler = this.handlers.get(typeName);
4917
- if (!handler) {
4918
- throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);
4919
- }
4920
- return handler;
4921
- }
4922
- getHandlerOrUndefined(typeName) {
4923
- return this.handlers.get(typeName);
4924
- }
4925
- getSupportedTypes() {
4926
- return Array.from(this.handlers.keys());
4927
- }
4928
- clear() {
4929
- this.handlers.clear();
4930
- }
4931
- }
4932
-
4933
4882
  class FolderLoader {
4934
4883
  async canLoad(source) {
4935
4884
  try {
@@ -4948,7 +4897,7 @@ class FolderLoader {
4948
4897
  const resourceJsonPath = join(folderPath, "resource.json");
4949
4898
  let resourceJson;
4950
4899
  try {
4951
- resourceJson = await readFile2(resourceJsonPath, "utf-8");
4900
+ resourceJson = await readFile(resourceJsonPath, "utf-8");
4952
4901
  } catch (error48) {
4953
4902
  throw new ResourceXError(`Failed to read resource.json: ${error48 instanceof Error ? error48.message : String(error48)}`);
4954
4903
  }
@@ -4976,6 +4925,40 @@ class FolderLoader {
4976
4925
  if (relativePath === "resource.json") {
4977
4926
  continue;
4978
4927
  }
4928
+ if (entry.isFile()) {
4929
+ files[relativePath] = await readFile(fullPath);
4930
+ } else if (entry.isDirectory()) {
4931
+ const subFiles = await this.readFolderFiles(fullPath, basePath);
4932
+ Object.assign(files, subFiles);
4933
+ }
4934
+ }
4935
+ return files;
4936
+ }
4937
+ }
4938
+
4939
+ class FolderSourceLoader {
4940
+ async canLoad(source) {
4941
+ try {
4942
+ const stats = await stat2(source);
4943
+ return stats.isDirectory();
4944
+ } catch {
4945
+ return false;
4946
+ }
4947
+ }
4948
+ async load(source) {
4949
+ const canLoad = await this.canLoad(source);
4950
+ if (!canLoad) {
4951
+ throw new ResourceXError(`Source is not a directory: ${source}`);
4952
+ }
4953
+ const files = await this.readFolderFiles(source);
4954
+ return { source, files };
4955
+ }
4956
+ async readFolderFiles(folderPath, basePath = folderPath) {
4957
+ const files = {};
4958
+ const entries = await readdir2(folderPath, { withFileTypes: true });
4959
+ for (const entry of entries) {
4960
+ const fullPath = join2(folderPath, entry.name);
4961
+ const relativePath = relative2(basePath, fullPath);
4979
4962
  if (entry.isFile()) {
4980
4963
  files[relativePath] = await readFile2(fullPath);
4981
4964
  } else if (entry.isDirectory()) {
@@ -5026,6 +5009,7 @@ class MemoryRXAStore {
5026
5009
 
5027
5010
  class MemoryRXMStore {
5028
5011
  manifests = new Map;
5012
+ latestPointers = new Map;
5029
5013
  buildKey(name, tag, registry2) {
5030
5014
  return registry2 ? `${registry2}/${name}:${tag}` : `${name}:${tag}`;
5031
5015
  }
@@ -5078,25 +5062,87 @@ class MemoryRXMStore {
5078
5062
  results = results.filter((m2) => m2.registry === registry2);
5079
5063
  }
5080
5064
  }
5081
- if (query) {
5082
- const lowerQuery = query.toLowerCase();
5083
- results = results.filter((m2) => m2.name.toLowerCase().includes(lowerQuery));
5084
- }
5085
- results = results.slice(offset);
5086
- if (limit !== undefined) {
5087
- results = results.slice(0, limit);
5088
- }
5089
- return results;
5065
+ if (query) {
5066
+ const lowerQuery = query.toLowerCase();
5067
+ results = results.filter((m2) => m2.name.toLowerCase().includes(lowerQuery));
5068
+ }
5069
+ results = results.slice(offset);
5070
+ if (limit !== undefined) {
5071
+ results = results.slice(0, limit);
5072
+ }
5073
+ return results;
5074
+ }
5075
+ async deleteByRegistry(registry2) {
5076
+ for (const [key, m2] of this.manifests.entries()) {
5077
+ if (m2.registry === registry2) {
5078
+ this.manifests.delete(key);
5079
+ }
5080
+ }
5081
+ }
5082
+ async setLatest(name, tag, registry2) {
5083
+ const key = registry2 ? `${registry2}/${name}` : name;
5084
+ this.latestPointers.set(key, tag);
5085
+ }
5086
+ async getLatest(name, registry2) {
5087
+ const key = registry2 ? `${registry2}/${name}` : name;
5088
+ return this.latestPointers.get(key) ?? null;
5089
+ }
5090
+ clear() {
5091
+ this.manifests.clear();
5092
+ this.latestPointers.clear();
5093
+ }
5094
+ }
5095
+
5096
+ class TypeHandlerChain {
5097
+ handlers = new Map;
5098
+ constructor() {
5099
+ for (const type of builtinTypes) {
5100
+ this.registerInternal(type);
5101
+ }
5102
+ }
5103
+ static create() {
5104
+ return new TypeHandlerChain;
5105
+ }
5106
+ registerInternal(type) {
5107
+ this.handlers.set(type.name, type);
5108
+ if (type.aliases) {
5109
+ for (const alias of type.aliases) {
5110
+ this.handlers.set(alias, type);
5111
+ }
5112
+ }
5113
+ }
5114
+ register(type) {
5115
+ if (this.handlers.has(type.name)) {
5116
+ throw new ResourceTypeError(`Type '${type.name}' is already registered`);
5117
+ }
5118
+ this.handlers.set(type.name, type);
5119
+ if (type.aliases) {
5120
+ for (const alias of type.aliases) {
5121
+ if (this.handlers.has(alias)) {
5122
+ throw new ResourceTypeError(`Alias '${alias}' conflicts with existing type or alias`);
5123
+ }
5124
+ this.handlers.set(alias, type);
5125
+ }
5126
+ }
5090
5127
  }
5091
- async deleteByRegistry(registry2) {
5092
- for (const [key, m2] of this.manifests.entries()) {
5093
- if (m2.registry === registry2) {
5094
- this.manifests.delete(key);
5095
- }
5128
+ canHandle(typeName) {
5129
+ return this.handlers.has(typeName);
5130
+ }
5131
+ getHandler(typeName) {
5132
+ const handler = this.handlers.get(typeName);
5133
+ if (!handler) {
5134
+ throw new ResourceTypeError(`Unsupported resource type: ${typeName}`);
5096
5135
  }
5136
+ return handler;
5137
+ }
5138
+ getHandlerOrUndefined(typeName) {
5139
+ return this.handlers.get(typeName);
5140
+ }
5141
+ getSupportedTypes() {
5142
+ return Array.from(this.handlers.keys());
5097
5143
  }
5098
5144
  clear() {
5099
- this.manifests.clear();
5145
+ this.handlers.clear();
5100
5146
  }
5101
5147
  }
5102
5148
  var __defProp2, __export2 = (target, all) => {
@@ -5107,7 +5153,7 @@ var __defProp2, __export2 = (target, all) => {
5107
5153
  configurable: true,
5108
5154
  set: (newValue) => all[name] = () => newValue
5109
5155
  });
5110
- }, ResourceXError, DefinitionError, exports_external, exports_core2, NEVER, $brand, $ZodAsyncError, $ZodEncodeError, globalConfig, exports_util, EVALUATING, captureStackTrace, allowsEval, getParsedType = (data) => {
5156
+ }, BLOCK_SIZE = 512, BLOCK_SIZE_MASK = 511, DEFAULT_FILE_MODE = 420, DEFAULT_DIR_MODE = 493, USTAR_NAME_OFFSET = 0, USTAR_NAME_SIZE = 100, USTAR_MODE_OFFSET = 100, USTAR_MODE_SIZE = 8, USTAR_UID_OFFSET = 108, USTAR_UID_SIZE = 8, USTAR_GID_OFFSET = 116, USTAR_GID_SIZE = 8, USTAR_SIZE_OFFSET = 124, USTAR_SIZE_SIZE = 12, USTAR_MTIME_OFFSET = 136, USTAR_MTIME_SIZE = 12, USTAR_CHECKSUM_OFFSET = 148, USTAR_CHECKSUM_SIZE = 8, USTAR_TYPEFLAG_OFFSET = 156, USTAR_TYPEFLAG_SIZE = 1, USTAR_LINKNAME_OFFSET = 157, USTAR_LINKNAME_SIZE = 100, USTAR_MAGIC_OFFSET = 257, USTAR_MAGIC_SIZE = 6, USTAR_VERSION_OFFSET = 263, USTAR_VERSION_SIZE = 2, USTAR_UNAME_OFFSET = 265, USTAR_UNAME_SIZE = 32, USTAR_GNAME_OFFSET = 297, USTAR_GNAME_SIZE = 32, USTAR_PREFIX_OFFSET = 345, USTAR_PREFIX_SIZE = 155, USTAR_VERSION = "00", USTAR_MAX_UID_GID = 2097151, USTAR_MAX_SIZE = 8589934591, FILE = "file", LINK = "link", SYMLINK = "symlink", DIRECTORY = "directory", TYPEFLAG, ZERO_BLOCK, EMPTY, encoder, decoder, isBodyless = (header) => header.type === DIRECTORY || header.type === SYMLINK || header.type === LINK, CHECKSUM_SPACE = 32, ASCII_ZERO = 48, EOF_BUFFER, gzipAsync, exports_external, exports_core2, NEVER, $brand, $ZodAsyncError, $ZodEncodeError, globalConfig, exports_util, EVALUATING, captureStackTrace, allowsEval, getParsedType = (data) => {
5111
5157
  const t2 = typeof data;
5112
5158
  switch (t2) {
5113
5159
  case "undefined":
@@ -10785,21 +10831,28 @@ var __defProp2, __export2 = (target, all) => {
10785
10831
  Codec: ZodCodec,
10786
10832
  Boolean: ZodBoolean,
10787
10833
  String: ZodString
10788
- }, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, RXDSchema, BLOCK_SIZE = 512, BLOCK_SIZE_MASK = 511, DEFAULT_FILE_MODE = 420, DEFAULT_DIR_MODE = 493, USTAR_NAME_OFFSET = 0, USTAR_NAME_SIZE = 100, USTAR_MODE_OFFSET = 100, USTAR_MODE_SIZE = 8, USTAR_UID_OFFSET = 108, USTAR_UID_SIZE = 8, USTAR_GID_OFFSET = 116, USTAR_GID_SIZE = 8, USTAR_SIZE_OFFSET = 124, USTAR_SIZE_SIZE = 12, USTAR_MTIME_OFFSET = 136, USTAR_MTIME_SIZE = 12, USTAR_CHECKSUM_OFFSET = 148, USTAR_CHECKSUM_SIZE = 8, USTAR_TYPEFLAG_OFFSET = 156, USTAR_TYPEFLAG_SIZE = 1, USTAR_LINKNAME_OFFSET = 157, USTAR_LINKNAME_SIZE = 100, USTAR_MAGIC_OFFSET = 257, USTAR_MAGIC_SIZE = 6, USTAR_VERSION_OFFSET = 263, USTAR_VERSION_SIZE = 2, USTAR_UNAME_OFFSET = 265, USTAR_UNAME_SIZE = 32, USTAR_GNAME_OFFSET = 297, USTAR_GNAME_SIZE = 32, USTAR_PREFIX_OFFSET = 345, USTAR_PREFIX_SIZE = 155, USTAR_VERSION = "00", USTAR_MAX_UID_GID = 2097151, USTAR_MAX_SIZE = 8589934591, FILE = "file", LINK = "link", SYMLINK = "symlink", DIRECTORY = "directory", TYPEFLAG, ZERO_BLOCK, EMPTY, encoder, decoder, isBodyless = (header) => header.type === DIRECTORY || header.type === SYMLINK || header.type === LINK, CHECKSUM_SPACE = 32, ASCII_ZERO = 48, EOF_BUFFER, gzipAsync, gunzipAsync, ResourceTypeError, textType, jsonType, binaryType, skillType, builtinTypes, RegistryError;
10834
+ }, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, ResourceXError, DefinitionError, RXDSchema, gunzipAsync, RegistryError, textType, jsonType, binaryType, skillType, builtinTypes, ResourceTypeError;
10789
10835
  var init_dist = __esm(() => {
10790
10836
  __defProp2 = Object.defineProperty;
10791
- ResourceXError = class ResourceXError extends Error {
10792
- constructor(message, options) {
10793
- super(message, options);
10794
- this.name = "ResourceXError";
10795
- }
10796
- };
10797
- DefinitionError = class DefinitionError extends ResourceXError {
10798
- constructor(message) {
10799
- super(message);
10800
- this.name = "DefinitionError";
10801
- }
10837
+ TYPEFLAG = {
10838
+ file: "0",
10839
+ link: "1",
10840
+ symlink: "2",
10841
+ "character-device": "3",
10842
+ "block-device": "4",
10843
+ directory: "5",
10844
+ fifo: "6",
10845
+ "pax-header": "x",
10846
+ "pax-global-header": "g",
10847
+ "gnu-long-name": "L",
10848
+ "gnu-long-link-name": "K"
10802
10849
  };
10850
+ ZERO_BLOCK = new Uint8Array(BLOCK_SIZE);
10851
+ EMPTY = new Uint8Array(0);
10852
+ encoder = new TextEncoder;
10853
+ decoder = new TextDecoder;
10854
+ EOF_BUFFER = new Uint8Array(BLOCK_SIZE * 2);
10855
+ gzipAsync = promisify(gzip);
10803
10856
  exports_external = {};
10804
10857
  __export2(exports_external, {
10805
10858
  xor: () => xor,
@@ -14761,6 +14814,18 @@ var init_dist = __esm(() => {
14761
14814
  bigint: () => bigint3
14762
14815
  });
14763
14816
  config(en_default());
14817
+ ResourceXError = class ResourceXError extends Error {
14818
+ constructor(message, options) {
14819
+ super(message, options);
14820
+ this.name = "ResourceXError";
14821
+ }
14822
+ };
14823
+ DefinitionError = class DefinitionError extends ResourceXError {
14824
+ constructor(message) {
14825
+ super(message);
14826
+ this.name = "DefinitionError";
14827
+ }
14828
+ };
14764
14829
  RXDSchema = exports_external.object({
14765
14830
  name: exports_external.string().min(1).max(128),
14766
14831
  type: exports_external.string().min(1).max(64),
@@ -14774,30 +14839,11 @@ var init_dist = __esm(() => {
14774
14839
  keywords: exports_external.array(exports_external.string().max(64)).max(20).optional(),
14775
14840
  repository: exports_external.string().max(256).optional()
14776
14841
  }).strict();
14777
- TYPEFLAG = {
14778
- file: "0",
14779
- link: "1",
14780
- symlink: "2",
14781
- "character-device": "3",
14782
- "block-device": "4",
14783
- directory: "5",
14784
- fifo: "6",
14785
- "pax-header": "x",
14786
- "pax-global-header": "g",
14787
- "gnu-long-name": "L",
14788
- "gnu-long-link-name": "K"
14789
- };
14790
- ZERO_BLOCK = new Uint8Array(BLOCK_SIZE);
14791
- EMPTY = new Uint8Array(0);
14792
- encoder = new TextEncoder;
14793
- decoder = new TextDecoder;
14794
- EOF_BUFFER = new Uint8Array(BLOCK_SIZE * 2);
14795
- gzipAsync = promisify(gzip);
14796
14842
  gunzipAsync = promisify2(gunzip);
14797
- ResourceTypeError = class ResourceTypeError extends ResourceXError {
14798
- constructor(message) {
14799
- super(message);
14800
- this.name = "ResourceTypeError";
14843
+ RegistryError = class RegistryError extends ResourceXError {
14844
+ constructor(message, options) {
14845
+ super(message, options);
14846
+ this.name = "RegistryError";
14801
14847
  }
14802
14848
  };
14803
14849
  textType = {
@@ -14887,10 +14933,10 @@ var skill_type_default = {
14887
14933
  }
14888
14934
  };
14889
14935
  builtinTypes = [textType, jsonType, binaryType, skillType];
14890
- RegistryError = class RegistryError extends ResourceXError {
14891
- constructor(message, options) {
14892
- super(message, options);
14893
- this.name = "RegistryError";
14936
+ ResourceTypeError = class ResourceTypeError extends ResourceXError {
14937
+ constructor(message) {
14938
+ super(message);
14939
+ this.name = "ResourceTypeError";
14894
14940
  }
14895
14941
  };
14896
14942
  });
@@ -14902,14 +14948,14 @@ __export(exports_dist, {
14902
14948
  FileSystemRXMStore: () => FileSystemRXMStore,
14903
14949
  FileSystemRXAStore: () => FileSystemRXAStore
14904
14950
  });
14905
- import { homedir } from "os";
14906
- import { join as join3 } from "path";
14907
- import { mkdir, writeFile, unlink, readdir as readdir2, stat as stat2 } from "fs/promises";
14908
- import { createReadStream } from "fs";
14909
14951
  import { createHash as createHash2 } from "crypto";
14910
- import { join as join2 } from "path";
14911
- import { mkdir as mkdir2, readFile, writeFile as writeFile2, unlink as unlink2, readdir as readdir22, stat as stat22, rm } from "fs/promises";
14952
+ import { createReadStream } from "fs";
14953
+ import { mkdir, readdir as readdir3, stat as stat3, unlink, writeFile } from "fs/promises";
14954
+ import { join as join3 } from "path";
14955
+ import { mkdir as mkdir2, readdir as readdir22, readFile as readFile3, rm, stat as stat22, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
14912
14956
  import { join as join22 } from "path";
14957
+ import { homedir } from "os";
14958
+ import { join as join32 } from "path";
14913
14959
 
14914
14960
  class FileSystemRXAStore {
14915
14961
  basePath;
@@ -14918,7 +14964,7 @@ class FileSystemRXAStore {
14918
14964
  }
14919
14965
  getPath(digest) {
14920
14966
  const prefix = digest.substring(7, 9);
14921
- return join2(this.basePath, prefix, digest);
14967
+ return join3(this.basePath, prefix, digest);
14922
14968
  }
14923
14969
  async get(digest) {
14924
14970
  if (!isValidDigest(digest)) {
@@ -14930,6 +14976,8 @@ class FileSystemRXAStore {
14930
14976
  const readStream = createReadStream(path);
14931
14977
  await new Promise((resolve, reject) => {
14932
14978
  readStream.on("data", (chunk) => {
14979
+ if (typeof chunk === "string")
14980
+ chunk = Buffer.from(chunk);
14933
14981
  chunks.push(chunk);
14934
14982
  hash2.update(chunk);
14935
14983
  });
@@ -14948,7 +14996,7 @@ class FileSystemRXAStore {
14948
14996
  if (await this.has(digest)) {
14949
14997
  return digest;
14950
14998
  }
14951
- const dir = join2(path, "..");
14999
+ const dir = join3(path, "..");
14952
15000
  await mkdir(dir, { recursive: true });
14953
15001
  await writeFile(path, data);
14954
15002
  return digest;
@@ -14956,7 +15004,7 @@ class FileSystemRXAStore {
14956
15004
  async has(digest) {
14957
15005
  const path = this.getPath(digest);
14958
15006
  try {
14959
- await stat2(path);
15007
+ await stat3(path);
14960
15008
  return true;
14961
15009
  } catch {
14962
15010
  return false;
@@ -14971,11 +15019,11 @@ class FileSystemRXAStore {
14971
15019
  async list() {
14972
15020
  const digests = [];
14973
15021
  try {
14974
- const prefixes = await readdir2(this.basePath);
15022
+ const prefixes = await readdir3(this.basePath);
14975
15023
  for (const prefix of prefixes) {
14976
- const prefixPath = join2(this.basePath, prefix);
15024
+ const prefixPath = join3(this.basePath, prefix);
14977
15025
  try {
14978
- const files = await readdir2(prefixPath);
15026
+ const files = await readdir3(prefixPath);
14979
15027
  for (const file2 of files) {
14980
15028
  if (file2.startsWith("sha256:")) {
14981
15029
  digests.push(file2);
@@ -15003,7 +15051,7 @@ class FileSystemRXMStore {
15003
15051
  async get(name, tag, registry2) {
15004
15052
  const path = this.getPath(name, tag, registry2);
15005
15053
  try {
15006
- const data = await readFile(path, "utf-8");
15054
+ const data = await readFile3(path, "utf-8");
15007
15055
  return JSON.parse(data);
15008
15056
  } catch {
15009
15057
  return null;
@@ -15043,6 +15091,19 @@ class FileSystemRXMStore {
15043
15091
  } catch {}
15044
15092
  return tags;
15045
15093
  }
15094
+ async setLatest(name, tag, registry2) {
15095
+ const dir = this.getDir(name, registry2);
15096
+ await mkdir2(dir, { recursive: true });
15097
+ await writeFile2(join22(dir, LATEST_FILE), tag, "utf-8");
15098
+ }
15099
+ async getLatest(name, registry2) {
15100
+ const dir = this.getDir(name, registry2);
15101
+ try {
15102
+ return (await readFile3(join22(dir, LATEST_FILE), "utf-8")).trim();
15103
+ } catch {
15104
+ return null;
15105
+ }
15106
+ }
15046
15107
  async listNames(registry2, query) {
15047
15108
  const registryDir = registry2 ?? LOCAL_DIR;
15048
15109
  const basePath = join22(this.basePath, registryDir);
@@ -15092,7 +15153,7 @@ class FileSystemRXMStore {
15092
15153
  for (const file2 of files) {
15093
15154
  if (file2.endsWith(".json")) {
15094
15155
  const filePath = join22(namePath, file2);
15095
- const data = await readFile(filePath, "utf-8");
15156
+ const data = await readFile3(filePath, "utf-8");
15096
15157
  const manifest2 = JSON.parse(data);
15097
15158
  results.push(manifest2);
15098
15159
  }
@@ -15120,15 +15181,18 @@ class NodeProvider {
15120
15181
  createStores(config2) {
15121
15182
  const basePath = config2.path ?? DEFAULT_BASE_PATH;
15122
15183
  return {
15123
- rxaStore: new FileSystemRXAStore(join3(basePath, "blobs")),
15124
- rxmStore: new FileSystemRXMStore(join3(basePath, "manifests"))
15184
+ rxaStore: new FileSystemRXAStore(join32(basePath, "blobs")),
15185
+ rxmStore: new FileSystemRXMStore(join32(basePath, "manifests"))
15125
15186
  };
15126
15187
  }
15127
15188
  createLoader(_config) {
15128
15189
  return new FolderLoader;
15129
15190
  }
15191
+ createSourceLoader(_config) {
15192
+ return new FolderSourceLoader;
15193
+ }
15130
15194
  }
15131
- var LOCAL_DIR = "_local", DEFAULT_BASE_PATH;
15195
+ var LOCAL_DIR = "_local", LATEST_FILE = ".latest", DEFAULT_BASE_PATH;
15132
15196
  var init_dist2 = __esm(() => {
15133
15197
  init_dist();
15134
15198
  init_dist();
@@ -15624,12 +15688,12 @@ var init_dist3 = __esm(() => {
15624
15688
  }
15625
15689
  }
15626
15690
  get headers() {
15627
- const cache = this[cacheKey];
15628
- if (cache) {
15629
- if (!(cache[2] instanceof Headers)) {
15630
- cache[2] = new Headers(cache[2]);
15691
+ const cache2 = this[cacheKey];
15692
+ if (cache2) {
15693
+ if (!(cache2[2] instanceof Headers)) {
15694
+ cache2[2] = new Headers(cache2[2]);
15631
15695
  }
15632
- return cache[2];
15696
+ return cache2[2];
15633
15697
  }
15634
15698
  return this[getResponseCache]().headers;
15635
15699
  }
@@ -17068,14 +17132,14 @@ import { createResourceX, setProvider } from "resourcexjs";
17068
17132
 
17069
17133
  // src/lib/paths.ts
17070
17134
  import { homedir as homedir2 } from "os";
17071
- import { join as join4 } from "path";
17072
- var RX_HOME = process.env.RX_HOME || join4(homedir2(), ".resourcex");
17135
+ import { join as join5 } from "path";
17136
+ var RX_HOME = process.env.RX_HOME || join5(homedir2(), ".resourcex");
17073
17137
  var PATHS = {
17074
17138
  root: RX_HOME,
17075
- config: join4(RX_HOME, "config.json"),
17076
- local: join4(RX_HOME, "local"),
17077
- cache: join4(RX_HOME, "cache"),
17078
- linked: join4(RX_HOME, "linked")
17139
+ config: join5(RX_HOME, "config.json"),
17140
+ local: join5(RX_HOME, "local"),
17141
+ cache: join5(RX_HOME, "cache"),
17142
+ linked: join5(RX_HOME, "linked")
17079
17143
  };
17080
17144
 
17081
17145
  // src/lib/config.ts
@@ -17087,11 +17151,22 @@ async function getConfig() {
17087
17151
  fileConfig = await file2.json();
17088
17152
  }
17089
17153
  } catch {}
17154
+ if (fileConfig.registry && !fileConfig.registries) {
17155
+ fileConfig.registries = [{ name: "default", url: fileConfig.registry, default: true }];
17156
+ delete fileConfig.registry;
17157
+ }
17090
17158
  const envRegistry = process.env.RX_REGISTRY;
17091
- const registry2 = envRegistry !== undefined ? envRegistry || undefined : fileConfig.registry;
17159
+ let registry2;
17160
+ if (envRegistry !== undefined) {
17161
+ registry2 = envRegistry || undefined;
17162
+ } else {
17163
+ const defaultEntry = fileConfig.registries?.find((r3) => r3.default);
17164
+ registry2 = defaultEntry?.url;
17165
+ }
17092
17166
  return {
17093
17167
  path: process.env.RX_HOME || fileConfig.path || RX_HOME,
17094
- registry: registry2
17168
+ registry: registry2,
17169
+ registries: fileConfig.registries ?? []
17095
17170
  };
17096
17171
  }
17097
17172
  async function setConfig(key, value) {
@@ -17100,6 +17175,73 @@ async function setConfig(key, value) {
17100
17175
  await Bun.$`mkdir -p ${RX_HOME}`.quiet();
17101
17176
  await Bun.write(PATHS.config, JSON.stringify(config2, null, 2));
17102
17177
  }
17178
+ async function readRawConfig() {
17179
+ try {
17180
+ const file2 = Bun.file(PATHS.config);
17181
+ if (await file2.exists()) {
17182
+ return await file2.json();
17183
+ }
17184
+ } catch {}
17185
+ return {};
17186
+ }
17187
+ async function writeConfig(config2) {
17188
+ await Bun.$`mkdir -p ${RX_HOME}`.quiet();
17189
+ const { registry: _3, ...toWrite } = config2;
17190
+ await Bun.write(PATHS.config, JSON.stringify(toWrite, null, 2));
17191
+ }
17192
+ function migrateConfig(config2) {
17193
+ if (config2.registry && !config2.registries) {
17194
+ config2.registries = [{ name: "default", url: config2.registry, default: true }];
17195
+ delete config2.registry;
17196
+ }
17197
+ return config2;
17198
+ }
17199
+ async function addRegistry(name, url2, setDefault) {
17200
+ const raw = migrateConfig(await readRawConfig());
17201
+ const registries = raw.registries ?? [];
17202
+ if (registries.some((r3) => r3.name === name)) {
17203
+ throw new Error(`Registry "${name}" already exists`);
17204
+ }
17205
+ const isDefault = setDefault || registries.length === 0;
17206
+ if (isDefault) {
17207
+ for (const r3 of registries)
17208
+ r3.default = false;
17209
+ }
17210
+ registries.push({ name, url: url2, default: isDefault });
17211
+ raw.registries = registries;
17212
+ await writeConfig(raw);
17213
+ }
17214
+ async function removeRegistry(name) {
17215
+ const raw = migrateConfig(await readRawConfig());
17216
+ const registries = raw.registries ?? [];
17217
+ const idx = registries.findIndex((r3) => r3.name === name);
17218
+ if (idx === -1) {
17219
+ throw new Error(`Registry "${name}" not found`);
17220
+ }
17221
+ registries.splice(idx, 1);
17222
+ raw.registries = registries;
17223
+ await writeConfig(raw);
17224
+ }
17225
+ async function setDefaultRegistry(name) {
17226
+ const raw = migrateConfig(await readRawConfig());
17227
+ const registries = raw.registries ?? [];
17228
+ const entry = registries.find((r3) => r3.name === name);
17229
+ if (!entry) {
17230
+ throw new Error(`Registry "${name}" not found`);
17231
+ }
17232
+ for (const r3 of registries)
17233
+ r3.default = r3.name === name;
17234
+ raw.registries = registries;
17235
+ await writeConfig(raw);
17236
+ }
17237
+ async function getRegistries() {
17238
+ const raw = migrateConfig(await readRawConfig());
17239
+ return raw.registries ?? [];
17240
+ }
17241
+ async function getRegistryByName(name) {
17242
+ const registries = await getRegistries();
17243
+ return registries.find((r3) => r3.name === name);
17244
+ }
17103
17245
 
17104
17246
  // src/lib/client.ts
17105
17247
  setProvider(new NodeProvider);
@@ -17144,36 +17286,93 @@ var add = defineCommand({
17144
17286
  }
17145
17287
  });
17146
17288
 
17147
- // src/commands/list.ts
17148
- var list = defineCommand({
17289
+ // src/commands/cache.ts
17290
+ var clear = defineCommand({
17149
17291
  meta: {
17150
- name: "list",
17151
- description: "List local resources"
17292
+ name: "clear",
17293
+ description: "Clear all cached resources"
17152
17294
  },
17153
17295
  args: {
17154
- query: {
17155
- type: "positional",
17156
- description: "Optional search query",
17157
- required: false
17296
+ registry: {
17297
+ type: "string",
17298
+ alias: "r",
17299
+ description: "Only clear resources from this registry"
17158
17300
  }
17159
17301
  },
17160
17302
  async run({ args }) {
17161
17303
  try {
17162
17304
  const rx = await getClient();
17163
- const results = await rx.search(args.query);
17164
- if (results.length === 0) {
17165
- consola.info("No resources found");
17166
- return;
17167
- }
17168
- consola.info(`Found ${results.length} resource(s):
17169
- `);
17170
- for (const locator of results) {
17171
- console.log(` ${locator}`);
17305
+ await rx.clearCache(args.registry);
17306
+ if (args.registry) {
17307
+ consola.success(`Cleared cache for registry: ${args.registry}`);
17308
+ } else {
17309
+ consola.success("Cleared all cached resources");
17172
17310
  }
17173
17311
  } catch (error48) {
17174
- consola.error(error48 instanceof Error ? error48.message : "Failed to list resources");
17312
+ consola.error(error48 instanceof Error ? error48.message : "Failed to clear cache");
17313
+ process.exit(1);
17314
+ }
17315
+ }
17316
+ });
17317
+ var cache = defineCommand({
17318
+ meta: {
17319
+ name: "cache",
17320
+ description: "Manage cached resources"
17321
+ },
17322
+ subCommands: {
17323
+ clear
17324
+ }
17325
+ });
17326
+
17327
+ // src/commands/config.ts
17328
+ var set2 = defineCommand({
17329
+ meta: {
17330
+ name: "set",
17331
+ description: "Set configuration value"
17332
+ },
17333
+ args: {
17334
+ key: {
17335
+ type: "positional",
17336
+ description: "Configuration key (path, registry)",
17337
+ required: true
17338
+ },
17339
+ value: {
17340
+ type: "positional",
17341
+ description: "Configuration value",
17342
+ required: true
17343
+ }
17344
+ },
17345
+ async run({ args }) {
17346
+ const validKeys = ["path", "registry"];
17347
+ if (!validKeys.includes(args.key)) {
17348
+ consola.error(`Invalid key: ${args.key}. Valid keys: ${validKeys.join(", ")}`);
17175
17349
  process.exit(1);
17176
17350
  }
17351
+ await setConfig(args.key, args.value);
17352
+ consola.success(`Set ${args.key} = ${args.value}`);
17353
+ }
17354
+ });
17355
+ var list = defineCommand({
17356
+ meta: {
17357
+ name: "list",
17358
+ description: "List configuration"
17359
+ },
17360
+ async run() {
17361
+ const config2 = await getConfig();
17362
+ consola.info(`Configuration:
17363
+ `);
17364
+ console.log(` path: ${config2.path}`);
17365
+ console.log(` registry: ${config2.registry || "(not set)"}`);
17366
+ }
17367
+ });
17368
+ var config2 = defineCommand({
17369
+ meta: {
17370
+ name: "config",
17371
+ description: "Manage CLI configuration"
17372
+ },
17373
+ subCommands: {
17374
+ set: set2,
17375
+ list
17177
17376
  }
17178
17377
  });
17179
17378
 
@@ -17250,41 +17449,80 @@ function printFileTree(files) {
17250
17449
  console.log(` ${prefix}${item}`);
17251
17450
  }
17252
17451
  }
17253
- }
17254
- function printSubTree(files, indent) {
17255
- for (let i2 = 0;i2 < files.length; i2++) {
17256
- const file2 = files[i2];
17257
- const isLast = i2 === files.length - 1;
17258
- const prefix = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
17259
- console.log(` ${indent}${prefix}${file2}`);
17260
- }
17261
- }
17452
+ }
17453
+ function printSubTree(files, indent) {
17454
+ for (let i2 = 0;i2 < files.length; i2++) {
17455
+ const file2 = files[i2];
17456
+ const isLast = i2 === files.length - 1;
17457
+ const prefix = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
17458
+ console.log(` ${indent}${prefix}${file2}`);
17459
+ }
17460
+ }
17461
+
17462
+ // src/commands/list.ts
17463
+ var list2 = defineCommand({
17464
+ meta: {
17465
+ name: "list",
17466
+ description: "List local resources"
17467
+ },
17468
+ args: {
17469
+ query: {
17470
+ type: "positional",
17471
+ description: "Optional search query",
17472
+ required: false
17473
+ }
17474
+ },
17475
+ async run({ args }) {
17476
+ try {
17477
+ const rx = await getClient();
17478
+ const results = await rx.search(args.query);
17479
+ if (results.length === 0) {
17480
+ consola.info("No resources found");
17481
+ return;
17482
+ }
17483
+ consola.info(`Found ${results.length} resource(s):
17484
+ `);
17485
+ for (const locator of results) {
17486
+ console.log(` ${locator}`);
17487
+ }
17488
+ } catch (error48) {
17489
+ consola.error(error48 instanceof Error ? error48.message : "Failed to list resources");
17490
+ process.exit(1);
17491
+ }
17492
+ }
17493
+ });
17262
17494
 
17263
- // src/commands/remove.ts
17264
- var remove = defineCommand({
17495
+ // src/commands/pull.ts
17496
+ var pull = defineCommand({
17265
17497
  meta: {
17266
- name: "remove",
17267
- description: "Remove resource from local storage"
17498
+ name: "pull",
17499
+ description: "Pull resource from remote registry to local cache"
17268
17500
  },
17269
17501
  args: {
17270
17502
  locator: {
17271
17503
  type: "positional",
17272
17504
  description: "Resource locator (e.g., hello.text@1.0.0)",
17273
17505
  required: true
17506
+ },
17507
+ registry: {
17508
+ type: "string",
17509
+ alias: "r",
17510
+ description: "Registry URL (overrides config)"
17274
17511
  }
17275
17512
  },
17276
17513
  async run({ args }) {
17277
17514
  try {
17278
- const rx = await getClient();
17279
- const exists = await rx.has(args.locator);
17280
- if (!exists) {
17281
- consola.warn(`Resource not found: ${args.locator}`);
17282
- return;
17515
+ const config3 = await getConfig();
17516
+ const registryUrl = args.registry ?? config3.registry;
17517
+ if (!registryUrl) {
17518
+ consola.error("No registry configured. Use: rx config set registry <url> or --registry <url>");
17519
+ process.exit(1);
17283
17520
  }
17284
- await rx.remove(args.locator);
17285
- consola.success(`Removed: ${args.locator}`);
17521
+ const rx = await getClient({ registry: registryUrl });
17522
+ await rx.pull(args.locator);
17523
+ consola.success(`Pulled: ${args.locator}`);
17286
17524
  } catch (error48) {
17287
- consola.error(error48 instanceof Error ? error48.message : "Failed to remove resource");
17525
+ consola.error(error48 instanceof Error ? error48.message : "Failed to pull resource");
17288
17526
  process.exit(1);
17289
17527
  }
17290
17528
  }
@@ -17305,15 +17543,21 @@ var push = defineCommand({
17305
17543
  registry: {
17306
17544
  type: "string",
17307
17545
  alias: "r",
17308
- description: "Registry URL (overrides config)"
17546
+ description: "Registry name or URL (overrides default)"
17309
17547
  }
17310
17548
  },
17311
17549
  async run({ args }) {
17312
17550
  try {
17313
- const config2 = await getConfig();
17314
- const registryUrl = args.registry ?? config2.registry;
17551
+ let registryUrl;
17552
+ if (args.registry) {
17553
+ const entry = await getRegistryByName(args.registry);
17554
+ registryUrl = entry ? entry.url : args.registry;
17555
+ } else {
17556
+ const config3 = await getConfig();
17557
+ registryUrl = config3.registry;
17558
+ }
17315
17559
  if (!registryUrl) {
17316
- consola.error("No registry configured. Use: rx config set registry <url> or --registry <url>");
17560
+ consola.error("No registry configured. Use: rx registry add <name> <url> or --registry <name|url>");
17317
17561
  process.exit(1);
17318
17562
  }
17319
17563
  const rx = await getClient({ registry: registryUrl });
@@ -17326,37 +17570,143 @@ var push = defineCommand({
17326
17570
  }
17327
17571
  });
17328
17572
 
17329
- // src/commands/pull.ts
17330
- var pull = defineCommand({
17573
+ // src/commands/registry.ts
17574
+ var add2 = defineCommand({
17331
17575
  meta: {
17332
- name: "pull",
17333
- description: "Pull resource from remote registry to local cache"
17576
+ name: "add",
17577
+ description: "Add a registry"
17578
+ },
17579
+ args: {
17580
+ name: {
17581
+ type: "positional",
17582
+ description: "Registry name",
17583
+ required: true
17584
+ },
17585
+ url: {
17586
+ type: "positional",
17587
+ description: "Registry URL",
17588
+ required: true
17589
+ },
17590
+ default: {
17591
+ type: "boolean",
17592
+ description: "Set as default registry",
17593
+ default: false
17594
+ }
17595
+ },
17596
+ async run({ args }) {
17597
+ try {
17598
+ await addRegistry(args.name, args.url, args.default);
17599
+ const registries = await getRegistries();
17600
+ const entry = registries.find((r3) => r3.name === args.name);
17601
+ const marker = entry?.default ? " (default)" : "";
17602
+ consola.success(`Added registry: ${args.name} \u2192 ${args.url}${marker}`);
17603
+ } catch (error48) {
17604
+ consola.error(error48 instanceof Error ? error48.message : "Failed to add registry");
17605
+ process.exit(1);
17606
+ }
17607
+ }
17608
+ });
17609
+ var remove = defineCommand({
17610
+ meta: {
17611
+ name: "remove",
17612
+ description: "Remove a registry"
17613
+ },
17614
+ args: {
17615
+ name: {
17616
+ type: "positional",
17617
+ description: "Registry name",
17618
+ required: true
17619
+ }
17620
+ },
17621
+ async run({ args }) {
17622
+ try {
17623
+ await removeRegistry(args.name);
17624
+ consola.success(`Removed registry: ${args.name}`);
17625
+ } catch (error48) {
17626
+ consola.error(error48 instanceof Error ? error48.message : "Failed to remove registry");
17627
+ process.exit(1);
17628
+ }
17629
+ }
17630
+ });
17631
+ var listCmd = defineCommand({
17632
+ meta: {
17633
+ name: "list",
17634
+ description: "List all configured registries"
17635
+ },
17636
+ async run() {
17637
+ const registries = await getRegistries();
17638
+ if (registries.length === 0) {
17639
+ consola.info("No registries configured. Use: rx registry add <name> <url>");
17640
+ return;
17641
+ }
17642
+ consola.info(`Registries:
17643
+ `);
17644
+ for (const r3 of registries) {
17645
+ const marker = r3.default ? " (default)" : "";
17646
+ console.log(` ${r3.name} ${r3.url}${marker}`);
17647
+ }
17648
+ }
17649
+ });
17650
+ var defaultCmd = defineCommand({
17651
+ meta: {
17652
+ name: "default",
17653
+ description: "Set default registry"
17654
+ },
17655
+ args: {
17656
+ name: {
17657
+ type: "positional",
17658
+ description: "Registry name",
17659
+ required: true
17660
+ }
17661
+ },
17662
+ async run({ args }) {
17663
+ try {
17664
+ await setDefaultRegistry(args.name);
17665
+ consola.success(`Default registry set to: ${args.name}`);
17666
+ } catch (error48) {
17667
+ consola.error(error48 instanceof Error ? error48.message : "Failed to set default");
17668
+ process.exit(1);
17669
+ }
17670
+ }
17671
+ });
17672
+ var registry2 = defineCommand({
17673
+ meta: {
17674
+ name: "registry",
17675
+ description: "Manage registry configurations"
17676
+ },
17677
+ subCommands: {
17678
+ add: add2,
17679
+ remove,
17680
+ list: listCmd,
17681
+ default: defaultCmd
17682
+ }
17683
+ });
17684
+
17685
+ // src/commands/remove.ts
17686
+ var remove2 = defineCommand({
17687
+ meta: {
17688
+ name: "remove",
17689
+ description: "Remove resource from local storage"
17334
17690
  },
17335
17691
  args: {
17336
17692
  locator: {
17337
17693
  type: "positional",
17338
17694
  description: "Resource locator (e.g., hello.text@1.0.0)",
17339
17695
  required: true
17340
- },
17341
- registry: {
17342
- type: "string",
17343
- alias: "r",
17344
- description: "Registry URL (overrides config)"
17345
17696
  }
17346
17697
  },
17347
17698
  async run({ args }) {
17348
17699
  try {
17349
- const config2 = await getConfig();
17350
- const registryUrl = args.registry ?? config2.registry;
17351
- if (!registryUrl) {
17352
- consola.error("No registry configured. Use: rx config set registry <url> or --registry <url>");
17353
- process.exit(1);
17700
+ const rx = await getClient();
17701
+ const exists = await rx.has(args.locator);
17702
+ if (!exists) {
17703
+ consola.warn(`Resource not found: ${args.locator}`);
17704
+ return;
17354
17705
  }
17355
- const rx = await getClient({ registry: registryUrl });
17356
- await rx.pull(args.locator);
17357
- consola.success(`Pulled: ${args.locator}`);
17706
+ await rx.remove(args.locator);
17707
+ consola.success(`Removed: ${args.locator}`);
17358
17708
  } catch (error48) {
17359
- consola.error(error48 instanceof Error ? error48.message : "Failed to pull resource");
17709
+ consola.error(error48 instanceof Error ? error48.message : "Failed to remove resource");
17360
17710
  process.exit(1);
17361
17711
  }
17362
17712
  }
@@ -17383,12 +17733,12 @@ var search = defineCommand({
17383
17733
  },
17384
17734
  async run({ args }) {
17385
17735
  try {
17386
- const config2 = await getConfig();
17387
- if (!config2.registry) {
17736
+ const config3 = await getConfig();
17737
+ if (!config3.registry) {
17388
17738
  consola.error("No registry configured. Use: rx config set registry <url>");
17389
17739
  process.exit(1);
17390
17740
  }
17391
- const url2 = buildSearchUrl(config2.registry, {
17741
+ const url2 = buildSearchUrl(config3.registry, {
17392
17742
  q: args.query,
17393
17743
  limit: Number(args.limit)
17394
17744
  });
@@ -17416,90 +17766,6 @@ var search = defineCommand({
17416
17766
  }
17417
17767
  });
17418
17768
 
17419
- // src/commands/use.ts
17420
- var use = defineCommand({
17421
- meta: {
17422
- name: "use",
17423
- description: "Use and execute resource"
17424
- },
17425
- args: {
17426
- locator: {
17427
- type: "positional",
17428
- description: "Resource locator (e.g., hello.text@1.0.0)",
17429
- required: true
17430
- }
17431
- },
17432
- async run({ args }) {
17433
- try {
17434
- const rx = await getClient();
17435
- const executable = await rx.use(args.locator);
17436
- const result = await executable.execute();
17437
- if (typeof result === "string") {
17438
- console.log(result);
17439
- } else if (result instanceof Uint8Array) {
17440
- process.stdout.write(result);
17441
- } else {
17442
- console.log(JSON.stringify(result, null, 2));
17443
- }
17444
- } catch (error48) {
17445
- consola.error(error48 instanceof Error ? error48.message : "Failed to use resource");
17446
- process.exit(1);
17447
- }
17448
- }
17449
- });
17450
-
17451
- // src/commands/config.ts
17452
- var set2 = defineCommand({
17453
- meta: {
17454
- name: "set",
17455
- description: "Set configuration value"
17456
- },
17457
- args: {
17458
- key: {
17459
- type: "positional",
17460
- description: "Configuration key (path, registry)",
17461
- required: true
17462
- },
17463
- value: {
17464
- type: "positional",
17465
- description: "Configuration value",
17466
- required: true
17467
- }
17468
- },
17469
- async run({ args }) {
17470
- const validKeys = ["path", "registry"];
17471
- if (!validKeys.includes(args.key)) {
17472
- consola.error(`Invalid key: ${args.key}. Valid keys: ${validKeys.join(", ")}`);
17473
- process.exit(1);
17474
- }
17475
- await setConfig(args.key, args.value);
17476
- consola.success(`Set ${args.key} = ${args.value}`);
17477
- }
17478
- });
17479
- var list2 = defineCommand({
17480
- meta: {
17481
- name: "list",
17482
- description: "List configuration"
17483
- },
17484
- async run() {
17485
- const config2 = await getConfig();
17486
- consola.info(`Configuration:
17487
- `);
17488
- console.log(` path: ${config2.path}`);
17489
- console.log(` registry: ${config2.registry || "(not set)"}`);
17490
- }
17491
- });
17492
- var config2 = defineCommand({
17493
- meta: {
17494
- name: "config",
17495
- description: "Manage CLI configuration"
17496
- },
17497
- subCommands: {
17498
- set: set2,
17499
- list: list2
17500
- }
17501
- });
17502
-
17503
17769
  // src/commands/server.ts
17504
17770
  import { join as join6 } from "path";
17505
17771
  var server = defineCommand({
@@ -17548,43 +17814,36 @@ var server = defineCommand({
17548
17814
  }
17549
17815
  });
17550
17816
 
17551
- // src/commands/cache.ts
17552
- var clear = defineCommand({
17817
+ // src/commands/use.ts
17818
+ var ingest = defineCommand({
17553
17819
  meta: {
17554
- name: "clear",
17555
- description: "Clear all cached resources"
17820
+ name: "ingest",
17821
+ description: "Ingest and execute resource from any source (directory path or locator)"
17556
17822
  },
17557
17823
  args: {
17558
- registry: {
17559
- type: "string",
17560
- alias: "r",
17561
- description: "Only clear resources from this registry"
17824
+ source: {
17825
+ type: "positional",
17826
+ description: "Resource source (directory path or locator, e.g., ./my-skill or hello:1.0.0)",
17827
+ required: true
17562
17828
  }
17563
17829
  },
17564
17830
  async run({ args }) {
17565
17831
  try {
17566
17832
  const rx = await getClient();
17567
- await rx.clearCache(args.registry);
17568
- if (args.registry) {
17569
- consola.success(`Cleared cache for registry: ${args.registry}`);
17833
+ const result = await rx.ingest(args.source);
17834
+ if (typeof result === "string") {
17835
+ console.log(result);
17836
+ } else if (result instanceof Uint8Array) {
17837
+ process.stdout.write(result);
17570
17838
  } else {
17571
- consola.success("Cleared all cached resources");
17839
+ console.log(JSON.stringify(result, null, 2));
17572
17840
  }
17573
17841
  } catch (error48) {
17574
- consola.error(error48 instanceof Error ? error48.message : "Failed to clear cache");
17842
+ consola.error(error48 instanceof Error ? error48.message : "Failed to ingest resource");
17575
17843
  process.exit(1);
17576
17844
  }
17577
17845
  }
17578
17846
  });
17579
- var cache = defineCommand({
17580
- meta: {
17581
- name: "cache",
17582
- description: "Manage cached resources"
17583
- },
17584
- subCommands: {
17585
- clear
17586
- }
17587
- });
17588
17847
 
17589
17848
  // src/index.ts
17590
17849
  var main = defineCommand({
@@ -17595,18 +17854,19 @@ var main = defineCommand({
17595
17854
  },
17596
17855
  subCommands: {
17597
17856
  add,
17598
- list,
17857
+ list: list2,
17599
17858
  info,
17600
- remove,
17859
+ remove: remove2,
17601
17860
  push,
17602
17861
  pull,
17603
17862
  search,
17604
- use,
17863
+ ingest,
17605
17864
  config: config2,
17865
+ registry: registry2,
17606
17866
  cache,
17607
17867
  server
17608
17868
  }
17609
17869
  });
17610
17870
  runMain(main);
17611
17871
 
17612
- //# debugId=BC9BE61BDA75B33264756E2164756E21
17872
+ //# debugId=0E33A1E8B726679564756E2164756E21