Skip to content

Commit

Permalink
Try add dist folder
Browse files Browse the repository at this point in the history
  • Loading branch information
vilaug committed Sep 27, 2024
1 parent f4f77aa commit c648ea9
Show file tree
Hide file tree
Showing 107 changed files with 5,186 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
node_modules/
typings/
cache/
*.js
*.d.ts
# *.js
# *.d.ts
*.log.*
*.log
*.tgz
1 change: 1 addition & 0 deletions dist/cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
67 changes: 67 additions & 0 deletions dist/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"use strict";
// This file is part of cxsd, copyright (c) 2015-2016 BusFaster Ltd.
// Released under the MIT license, see LICENSE.
Object.defineProperty(exports, "__esModule", { value: true });
var cmd = require("commander");
var cget_1 = require("cget");
var schema = require("./schema");
var AddImports_1 = require("./schema/transform/AddImports");
var Sanitize_1 = require("./schema/transform/Sanitize");
var Context_1 = require("./xsd/Context");
var Exporter_1 = require("./xsd/Exporter");
var Loader_1 = require("./xsd/Loader");
var command = cmd.createCommand("cxsd")
.arguments('<url>')
.description('XSD download and conversion tool')
.option('-H, --force-host <host>', 'Fetch all xsd files from <host>\n (original host is passed in GET parameter "host")')
.option('-P, --force-port <port>', 'Connect to <port> when using --force-host')
// .option('-c, --cache-xsd <path>', 'Cache downloaded XSD filed under <path>')
.option('-t, --out-ts <path>', 'Output TypeScript definitions under <path>')
.option('-j, --out-js <path>', 'Output JavaScript modules under <path>')
.action(handleConvert)
.parse(process.argv);
if (process.argv.length < 3)
command.help();
function handleConvert(urlRemote, opts) {
var schemaContext = new schema.Context();
var xsdContext = new Context_1.Context(schemaContext);
var fetchOptions = {};
if (opts['forceHost']) {
fetchOptions.forceHost = opts['forceHost'];
if (opts['forcePort'])
fetchOptions.forcePort = opts['forcePort'];
cget_1.Cache.patchRequest();
}
var jsCache = new cget_1.Cache(opts['outJs'] || 'xmlns', '_index.js');
var tsCache = new cget_1.Cache(opts['outTs'] || 'xmlns', '_index.d.ts');
var loader = new Loader_1.Loader(xsdContext, fetchOptions);
loader.import(urlRemote).then(function (namespace) {
try {
(0, Exporter_1.exportNamespace)(xsdContext.primitiveSpace, schemaContext);
(0, Exporter_1.exportNamespace)(xsdContext.xmlSpace, schemaContext);
var spec = (0, Exporter_1.exportNamespace)(namespace, schemaContext);
var addImports = new AddImports_1.AddImports(spec);
var sanitize = new Sanitize_1.Sanitize(spec);
var importsAdded = addImports.exec();
// Find ID numbers of all types imported from other namespaces.
importsAdded.then(function () {
// Rename types to valid JavaScript class names,
// adding a prefix or suffix to duplicates.
return sanitize.exec();
}).then(function () {
return sanitize.finish();
}).then(function () {
return addImports.finish(importsAdded.value());
}).then(function () {
return new schema.exporter.JS(spec, jsCache).exec();
}).then(function () {
return new schema.exporter.TS(spec, tsCache).exec();
});
}
catch (err) {
console.error(err);
console.log('Stack:');
console.error(err.stack);
}
});
}
7 changes: 7 additions & 0 deletions dist/schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { Context } from './schema/Context';
export { Namespace } from './schema/Namespace';
export { Type } from './schema/Type';
export { Member } from './schema/Member';
export { MemberRef } from './schema/MemberRef';
import * as exporter from './schema/exporter';
export { exporter };
17 changes: 17 additions & 0 deletions dist/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";
// This file is part of cxsd, copyright (c) 2015-2016 BusFaster Ltd.
// Released under the MIT license, see LICENSE.
Object.defineProperty(exports, "__esModule", { value: true });
exports.exporter = exports.MemberRef = exports.Member = exports.Type = exports.Namespace = exports.Context = void 0;
var Context_1 = require("./schema/Context");
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return Context_1.Context; } });
var Namespace_1 = require("./schema/Namespace");
Object.defineProperty(exports, "Namespace", { enumerable: true, get: function () { return Namespace_1.Namespace; } });
var Type_1 = require("./schema/Type");
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return Type_1.Type; } });
var Member_1 = require("./schema/Member");
Object.defineProperty(exports, "Member", { enumerable: true, get: function () { return Member_1.Member; } });
var MemberRef_1 = require("./schema/MemberRef");
Object.defineProperty(exports, "MemberRef", { enumerable: true, get: function () { return MemberRef_1.MemberRef; } });
var exporter = require("./schema/exporter");
exports.exporter = exporter;
5 changes: 5 additions & 0 deletions dist/schema/Context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as cxml from 'cxml';
import { Namespace } from './Namespace';
export declare class Context extends cxml.ContextBase<Context, Namespace> {
constructor();
}
30 changes: 30 additions & 0 deletions dist/schema/Context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";
// This file is part of cxsd, copyright (c) 2016 BusFaster Ltd.
// Released under the MIT license, see LICENSE.
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = void 0;
var cxml = require("cxml");
var Namespace_1 = require("./Namespace");
var Context = /** @class */ (function (_super) {
__extends(Context, _super);
function Context() {
return _super.call(this, Namespace_1.Namespace) || this;
}
return Context;
}(cxml.ContextBase));
exports.Context = Context;
17 changes: 17 additions & 0 deletions dist/schema/Member.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as cxml from 'cxml';
import { Namespace } from './Namespace';
import { Type } from './Type';
import { MemberRef } from './MemberRef';
export declare class Member extends cxml.MemberBase<Member, Namespace, cxml.ItemBase<Member>> {
constructor(name: string);
getRef(): MemberRef;
getProxy(): Type;
typeList: Type[];
substitutes: Member;
/** Proxy type containing other substitution group members. */
proxy: Type;
comment: string;
isExported: boolean;
surrogateKey: number;
private static nextKey;
}
52 changes: 52 additions & 0 deletions dist/schema/Member.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict";
// This file is part of cxsd, copyright (c) 2016 BusFaster Ltd.
// Released under the MIT license, see LICENSE.
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Member = void 0;
var cxml = require("cxml");
var Type_1 = require("./Type");
var MemberRef_1 = require("./MemberRef");
var Member = /** @class */ (function (_super) {
__extends(Member, _super);
function Member(name) {
var _this = _super.call(this, null, name) || this;
_this.surrogateKey = Member.nextKey++;
return _this;
}
Member.prototype.getRef = function () {
return (new MemberRef_1.MemberRef(this, 0, 1));
};
Member.prototype.getProxy = function () {
var proxy = this.proxy;
if (!proxy) {
var proxy = new Type_1.Type(null);
proxy.namespace = this.namespace;
proxy.isProxy = true;
proxy.containingRef = this.getRef();
this.proxy = proxy;
this.namespace.addType(proxy);
if (!this.isAbstract) {
proxy.addChildSpec(this);
}
}
return (proxy);
};
Member.nextKey = 0;
return Member;
}(cxml.MemberBase));
exports.Member = Member;
5 changes: 5 additions & 0 deletions dist/schema/MemberRef.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as cxml from 'cxml';
import { Member } from './Member';
export declare class MemberRef extends cxml.MemberRefBase<Member> {
prefix: string;
}
29 changes: 29 additions & 0 deletions dist/schema/MemberRef.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";
// This file is part of cxsd, copyright (c) 2016 BusFaster Ltd.
// Released under the MIT license, see LICENSE.
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MemberRef = void 0;
var cxml = require("cxml");
var MemberRef = /** @class */ (function (_super) {
__extends(MemberRef, _super);
function MemberRef() {
return _super !== null && _super.apply(this, arguments) || this;
}
return MemberRef;
}(cxml.MemberRefBase));
exports.MemberRef = MemberRef;
55 changes: 55 additions & 0 deletions dist/schema/Namespace.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as cxml from 'cxml';
import { Context } from './Context';
import { Type } from './Type';
import { Member } from './Member';
import { MemberRef } from './MemberRef';
export interface ImportContent {
typeTbl: {
[key: string]: Type;
};
memberTbl: {
[key: string]: Member;
};
}
export declare class Namespace extends cxml.NamespaceBase<Context, Namespace> {
addRef(shortName: string, namespace: Namespace): void;
getShortRef(id: number): string;
getUsedImportTbl(): {
[short: string]: Namespace;
};
getUsedImportList(): Namespace[];
addType(type: Type): void;
addMember(member: Member): void;
/** Augment type in another namespace with member from this namespace. */
addAugmentation(type: Type, member: Member): void;
/** Invisible document element defining the types of XML file root elements. */
doc: Type;
/** All types used in the document. */
typeList: Type[];
/** All members used in the document. */
memberList: Member[];
/** Types from other namespaces augmented with members from this namespace. */
augmentTbl: {
[namespaceId: string]: {
[typeId: string]: {
type: Type;
refList: MemberRef[];
};
};
};
pendingSubstituteList: Member[];
/** List of URL addresses of files with definitions for this namespace. */
sourceList: string[];
/** Short names used to reference other namespaces in schemas defining this namespace. */
shortNameTbl: {
[namespaceId: string]: string[];
};
/** Table of namespaces actually imported, by short name. */
private importTbl;
/** List of referenced type names from each imported namespace. */
importContentTbl: {
[namespaceId: string]: ImportContent;
};
/** True only for the special namespace containing primitives. */
isPrimitiveSpace: boolean;
}
Loading

0 comments on commit c648ea9

Please sign in to comment.