diff --git a/.haxerc b/.haxerc index 2922fec..a052cec 100644 --- a/.haxerc +++ b/.haxerc @@ -1,4 +1,4 @@ { - "version": "4.0.0-preview.2", + "version": "c0b6767", "resolveLibs": "scoped" } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c6a6a5c..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "haxe.displayConfigurations": [ - ["regle.hxml"] - ], - "editor.minimap.enabled": true -} diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 872385f..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "2.0.0", - "command": "haxe", - "args": ["regle.hxml"], - "problemMatcher": "$haxe" -} diff --git a/README.md b/README.md index 964a995..ced98d3 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Regle is a collection of utilities that generate ids. Regle currently contains: - An [Hashids] port that generates short, unique, non-sequential ids from numbers. + + To access the original `uhx.uid` Hashids implementation add `-D uhx_hashids`. The lib `hashids` by @kevinresol has better expanded tests. - An [Optimus] port that obfuscates ids based on Knuth's multiplicative hashing method. ## Installation @@ -16,7 +17,8 @@ Regle currently contains: You need to install the following libraries from HaxeLib and GitHub. 1. yaml - `haxelib install yaml` -2. regle - `haxelib git regle https://github.com/skial/regle master src` +2. hashids - `haxelib git hashids https://github.com/kevinresol/hashids master src` +3. regle - `haxelib git regle https://github.com/skial/regle master src` Then in your `.hxml` file, add `-lib regle` and you're set. diff --git a/haxe_libraries/hashids.hxml b/haxe_libraries/hashids.hxml new file mode 100644 index 0000000..339da68 --- /dev/null +++ b/haxe_libraries/hashids.hxml @@ -0,0 +1,3 @@ +-D hashids=1.0.0 +# @install: lix --silent download "gh://github.com/kevinresol/hashids#f9dfd8146301503220fc2cf56b4e13c160fd4a18" into hashids/1.0.0/github/f9dfd8146301503220fc2cf56b4e13c160fd4a18 +-cp ${HAXE_LIBCACHE}/hashids/1.0.0/github/f9dfd8146301503220fc2cf56b4e13c160fd4a18/src diff --git a/haxe_libraries/hxcs.hxml b/haxe_libraries/hxcs.hxml deleted file mode 100644 index 574c9b1..0000000 --- a/haxe_libraries/hxcs.hxml +++ /dev/null @@ -1,3 +0,0 @@ -# @install: lix --silent download "haxelib:hxcs#3.4.0" into hxcs/3.4.0/haxelib --D hxcs=3.4.0 --cp ${HAXESHIM_LIBCACHE}/hxcs/3.4.0/haxelib/ diff --git a/haxe_libraries/hxnodejs.hxml b/haxe_libraries/hxnodejs.hxml new file mode 100644 index 0000000..4b84567 --- /dev/null +++ b/haxe_libraries/hxnodejs.hxml @@ -0,0 +1,6 @@ +-D hxnodejs=6.9.0 +# @install: lix --silent download "gh://github.com/haxefoundation/hxnodejs#877a80e7f1f96218f7f3fbf8f37ffc2a7f42e1bd" into hxnodejs/6.9.0/github/877a80e7f1f96218f7f3fbf8f37ffc2a7f42e1bd +-cp ${HAXE_LIBCACHE}/hxnodejs/6.9.0/github/877a80e7f1f96218f7f3fbf8f37ffc2a7f42e1bd/src +--macro allowPackage('sys') +# should behave like other target defines and not be defined in macro context +--macro define('nodejs') diff --git a/haxe_libraries/random.hxml b/haxe_libraries/random.hxml index d3ea192..d02a39c 100644 --- a/haxe_libraries/random.hxml +++ b/haxe_libraries/random.hxml @@ -1,3 +1,3 @@ -# @install: lix --silent download "haxelib:random#1.4.1" into random/1.4.1/haxelib -D random=1.4.1 --cp ${HAXESHIM_LIBCACHE}/random/1.4.1/haxelib/src/ +# @install: lix --silent download "haxelib:/random#1.4.1" into random/1.4.1/haxelib +-cp ${HAXE_LIBCACHE}/random/1.4.1/haxelib/src/ diff --git a/haxe_libraries/tink_core.hxml b/haxe_libraries/tink_core.hxml index 02b42b8..d0da3fc 100644 --- a/haxe_libraries/tink_core.hxml +++ b/haxe_libraries/tink_core.hxml @@ -1,3 +1,3 @@ -# @install: lix --silent download "https://github.com/haxetink/tink_core/archive/41187d54224fe8adab5d93018831700fd9bd41d8.tar.gz" into tink_core/1.15.2/github/41187d54224fe8adab5d93018831700fd9bd41d8 --D tink_core=1.15.2 --cp ${HAXESHIM_LIBCACHE}/tink_core/1.15.2/github/41187d54224fe8adab5d93018831700fd9bd41d8/src +-D tink_core=1.18.0 +# @install: lix --silent download "gh://github.com/haxetink/tink_core#7b5acdbc54ddcd27bbdd5fcebd666c4ad150426e" into tink_core/1.18.0/github/7b5acdbc54ddcd27bbdd5fcebd666c4ad150426e +-cp ${HAXE_LIBCACHE}/tink_core/1.18.0/github/7b5acdbc54ddcd27bbdd5fcebd666c4ad150426e/src diff --git a/haxe_libraries/utest.hxml b/haxe_libraries/utest.hxml index c28295f..e31ec1a 100644 --- a/haxe_libraries/utest.hxml +++ b/haxe_libraries/utest.hxml @@ -1,3 +1,3 @@ -# @install: lix --silent download "haxelib:utest#1.7.2" into utest/1.7.2/haxelib --D utest=1.7.2 --cp ${HAXESHIM_LIBCACHE}/utest/1.7.2/haxelib/src +-D utest=1.9.0 +# @install: lix --silent download "haxelib:/utest#1.9.0" into utest/1.9.0/haxelib +-cp ${HAXE_LIBCACHE}/utest/1.9.0/haxelib/src diff --git a/haxe_libraries/yaml.hxml b/haxe_libraries/yaml.hxml index d0af0d5..944503b 100644 --- a/haxe_libraries/yaml.hxml +++ b/haxe_libraries/yaml.hxml @@ -1,3 +1,3 @@ -# @install: lix --silent download "haxelib:yaml#1.3.0" into yaml/1.3.0/haxelib -D yaml=1.3.0 --cp ${HAXESHIM_LIBCACHE}/yaml/1.3.0/haxelib/ +# @install: lix --silent download "haxelib:/yaml#1.3.0" into yaml/1.3.0/haxelib +-cp ${HAXE_LIBCACHE}/yaml/1.3.0/haxelib/ diff --git a/regle.hxml b/regle.hxml index 7a68fe5..5131588 100644 --- a/regle.hxml +++ b/regle.hxml @@ -2,13 +2,14 @@ -lib utest -lib random -lib tink_core +-lib hashids -cp src -cp tests -dce full --debug +#-debug -D analyzer-optimize -main Main @@ -19,6 +20,7 @@ --next +-lib hxnodejs -js bin/regle.js --next @@ -39,6 +41,10 @@ -D php7 -php bin/php +#--next + +#--macro Main.main() + --next ---macro Main.main() \ No newline at end of file +-hl bin/regle.hl \ No newline at end of file diff --git a/src/uhx/uid/Hashids.hx b/src/uhx/uid/Hashids.hx index 553e54c..df311ca 100644 --- a/src/uhx/uid/Hashids.hx +++ b/src/uhx/uid/Hashids.hx @@ -2,6 +2,9 @@ package uhx.uid; import yaml.util.Ints; +#if !uhx_hashids +typedef Hashids = hashids.Hashids; +#else /** * @author Skial Bainn * Port of the JavaScript version of Hashids @@ -239,4 +242,5 @@ class Hashids { return Std.int( number ); } -} \ No newline at end of file +} +#end \ No newline at end of file diff --git a/src/uhx/uid/Optimus.hx b/src/uhx/uid/Optimus.hx index e946a37..90e53f2 100644 --- a/src/uhx/uid/Optimus.hx +++ b/src/uhx/uid/Optimus.hx @@ -10,6 +10,7 @@ class Optimus { public static var MAX_INT:Int64 = 2147483647.ofInt(); + public static macro function make() { var path = '${Sys.getCwd()}/.optimus'.normalize(); if (!sys.FileSystem.exists(path)) {