diff --git a/CHANGELOG.md b/CHANGELOG.md index c43930c..7695156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.7.0](https://github.com/dropecho/lib_example/compare/0.6.8...0.7.0) (2022-12-03) + + +### Features + +* setup esm and cjs builds. ([fc3f381](https://github.com/dropecho/lib_example/commit/fc3f381a3e7f59f4f8fab9f4efb6a22585856a7f)) + ## [0.6.8](https://github.com/dropecho/lib_example/compare/0.6.7...0.6.8) (2022-12-03) diff --git a/dist/js/cjs/index.js b/dist/js/cjs/index.js new file mode 100644 index 0000000..254c04b --- /dev/null +++ b/dist/js/cjs/index.js @@ -0,0 +1,34 @@ +(function ($hx_exports, $global) { "use strict"; +$hx_exports["dropecho"] = $hx_exports["dropecho"] || {}; +$hx_exports["dropecho"]["lib_example"] = $hx_exports["dropecho"]["lib_example"] || {}; +class dropecho_lib_$example_LibExample { + static test() { + console.log("src/dropecho/lib_example/LibExample.hx:6:","hello world."); + return 2; + } +} +$hx_exports["dropecho"]["lib_example"]["LibExample"] = dropecho_lib_$example_LibExample; +class dropecho_lib_$example_OtherExample { + constructor() { + this.x = 0; + } + banana(b) { + return b + 5 + this.x; + } +} +$hx_exports["dropecho"]["lib_example"]["OtherExample"] = dropecho_lib_$example_OtherExample; +class haxe_iterators_ArrayIterator { + constructor(array) { + this.current = 0; + this.array = array; + } + hasNext() { + return this.current < this.array.length; + } + next() { + return this.array[this.current++]; + } +} +{ +} +})(typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this, {}); diff --git a/dist/js/esm/Std.js b/dist/js/esm/Std.js new file mode 100644 index 0000000..e93cc86 --- /dev/null +++ b/dist/js/esm/Std.js @@ -0,0 +1,18 @@ +import {Register} from "./genes/Register.js" + +/** +The Std class provides standard methods for manipulating basic types. +*/ +export const Std = Register.global("$hxClasses")["Std"] = +class Std { + static get __name__() { + return "Std" + } + get __class__() { + return Std + } +} + + +;{ +} diff --git a/dist/js/esm/dropecho/lib_example/LibExample.js b/dist/js/esm/dropecho/lib_example/LibExample.js new file mode 100644 index 0000000..e85f904 --- /dev/null +++ b/dist/js/esm/dropecho/lib_example/LibExample.js @@ -0,0 +1,16 @@ +import {Register} from "../../genes/Register.js" + +export const LibExample = Register.global("$hxClasses")["dropecho.lib_example.LibExample"] = +class LibExample { + static test() { + console.log("src/dropecho/lib_example/LibExample.hx:6:","hello world."); + return 2; + } + static get __name__() { + return "dropecho.lib_example.LibExample" + } + get __class__() { + return LibExample + } +} + diff --git a/dist/js/esm/dropecho/lib_example/OtherExample.js b/dist/js/esm/dropecho/lib_example/OtherExample.js new file mode 100644 index 0000000..37ac665 --- /dev/null +++ b/dist/js/esm/dropecho/lib_example/OtherExample.js @@ -0,0 +1,18 @@ +import {Register} from "../../genes/Register.js" + +export const OtherExample = Register.global("$hxClasses")["dropecho.lib_example.OtherExample"] = +class OtherExample extends Register.inherits() { + new() { + this.x = 0; + } + banana(b) { + return b + 5 + this.x; + } + static get __name__() { + return "dropecho.lib_example.OtherExample" + } + get __class__() { + return OtherExample + } +} + diff --git a/dist/js/esm/genes/Register.js b/dist/js/esm/genes/Register.js new file mode 100644 index 0000000..e315926 --- /dev/null +++ b/dist/js/esm/genes/Register.js @@ -0,0 +1,107 @@ + +export class Register { + static global(name) { + if (Register.globals[name]) { + return Register.globals[name]; + } else { + return Register.globals[name] = {}; + }; + } + static createStatic(obj, name, get) { + var value = null; + Object.defineProperty(obj, name, {"enumerable": true, "get": function () { + if (get != null) { + value = get(); + get = null; + }; + return value; + }, "set": function (v) { + if (get != null) { + value = get(); + get = null; + }; + value = v; + }}); + } + static iter(a) { + if (!Array.isArray(a)) { + return a.iterator(); + } else { + return {"cur": 0, "arr": a, "hasNext": function () { + return this.cur < this.arr.length; + }, "next": function () { + return this.arr[this.cur++]; + }}; + }; + } + static extend(superClass) { + + function res() { + this.new.apply(this, arguments) + } + Object.setPrototypeOf(res.prototype, superClass.prototype) + return res + ; + } + static inherits(resolve, defer) { + if (defer == null) { + defer = false; + }; + + function res() { + if (defer && resolve && res.__init__) res.__init__() + this.new.apply(this, arguments) + } + if (!defer) { + if (resolve && resolve.__init__) { + defer = true + res.__init__ = () => { + resolve.__init__() + Object.setPrototypeOf(res.prototype, resolve.prototype) + res.__init__ = undefined + } + } else if (resolve) { + Object.setPrototypeOf(res.prototype, resolve.prototype) + } + } else { + res.__init__ = () => { + const superClass = resolve() + if (superClass.__init__) superClass.__init__() + Object.setPrototypeOf(res.prototype, superClass.prototype) + res.__init__ = undefined + } + } + return res + ; + } + static bind(o, m) { + if (m == null) { + return null; + }; + if (m.__id__ == null) { + m.__id__ = Register.fid++; + }; + var f = null; + if (o.hx__closures__ == null) { + o.hx__closures__ = {}; + } else { + f = o.hx__closures__[m.__id__]; + }; + if (f == null) { + f = m.bind(o); + o.hx__closures__[m.__id__] = f; + }; + return f; + } + static get __name__() { + return "genes.Register" + } + get __class__() { + return Register + } +} + + +Register.$global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : undefined +Register.globals = {} +Register.fid = 0 \ No newline at end of file diff --git a/dist/js/esm/haxe/iterators/ArrayIterator.js b/dist/js/esm/haxe/iterators/ArrayIterator.js new file mode 100644 index 0000000..34850ba --- /dev/null +++ b/dist/js/esm/haxe/iterators/ArrayIterator.js @@ -0,0 +1,33 @@ +import {Register} from "../../genes/Register.js" + +/** +This iterator is used only when `Array` is passed to `Iterable` +*/ +export const ArrayIterator = Register.global("$hxClasses")["haxe.iterators.ArrayIterator"] = +class ArrayIterator extends Register.inherits() { + new(array) { + this.current = 0; + this.array = array; + } + + /** + See `Iterator.hasNext` + */ + hasNext() { + return this.current < this.array.length; + } + + /** + See `Iterator.next` + */ + next() { + return this.array[this.current++]; + } + static get __name__() { + return "haxe.iterators.ArrayIterator" + } + get __class__() { + return ArrayIterator + } +} + diff --git a/dist/js/esm/index.js b/dist/js/esm/index.js new file mode 100644 index 0000000..8161101 --- /dev/null +++ b/dist/js/esm/index.js @@ -0,0 +1,4 @@ +import {Register} from "./genes/Register.js" + +export {OtherExample} from "./dropecho/lib_example/OtherExample.js" +export {LibExample} from "./dropecho/lib_example/LibExample.js" \ No newline at end of file diff --git a/haxelib.json b/haxelib.json index 6bb1779..17a4aa0 100644 --- a/haxelib.json +++ b/haxelib.json @@ -10,8 +10,8 @@ "contributors": [ "vantreeseba" ], - "version": "0.6.8", - "releasenote": "Release version 0.6.8. See CHANGELOG.md for details.", + "version": "0.7.0", + "releasenote": "Release version 0.7.0. See CHANGELOG.md for details.", "tags": [ "example" ], diff --git a/package.json b/package.json index dfb540b..4935edd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dropecho/lib_example", - "version": "0.6.8", + "version": "0.7.0", "description": "An example haxelib that outputs to multiple targets.", "author": "vantreeseba ", "repository": "github:dropecho/lib_example",