diff --git a/README.md b/README.md index 777504c..cb7b27f 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ compiles to: ### API Usage [![Clojars Project](https://img.shields.io/clojars/v/cirru/sepal.svg)](https://clojars.org/cirru/sepal) ```edn -[cirru/sepal "0.2.8"] +[cirru/sepal "0.2.9-a1"] ``` ```clojure diff --git a/data/compiled/def.cljs b/data/compiled/def.cljs index 5c89637..76a0eb6 100644 --- a/data/compiled/def.cljs +++ b/data/compiled/def.cljs @@ -11,6 +11,8 @@ (defn f2 ([a b] (+ a b)) ([a b c] (+ a b c))) +(defn ^:dev/after-load f3 []) + (defn- f1 [x] (+ x 1)) (println :key "string" "c" "\n") diff --git a/data/examples/def.edn b/data/examples/def.edn index 80a1e0e..b9ab0ee 100644 --- a/data/examples/def.edn +++ b/data/examples/def.edn @@ -7,5 +7,6 @@ "f2" [["a" "b"] ["+" "a" "b"]] [["a" "b" "c"] ["+" "a" "b" "c"]]] + ["defn" "^:dev/after-load" "f3" []] ["defn-" "f1" ["x"] ["+" "x" "1"]] ["println" ":key" "|string" "\\c" "\\newline"]] diff --git a/package.json b/package.json index cb806d0..d6aa103 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sepal.clj", - "version": "0.2.8", + "version": "0.2.9-a1", "main": "index.js", "repository": "git@github.com:Cirru/sepal.clj.git", "author": "jiyinyiyong ", @@ -11,6 +11,6 @@ "test": "yarn compile && node target/test.js" }, "devDependencies": { - "shadow-cljs": "^2.10.17" + "shadow-cljs": "^2.10.19" } } diff --git a/polyfill/cirru_sepal/core.cljs b/polyfill/cirru_sepal/core.cljs index 7c3a0d2..d723b95 100644 --- a/polyfill/cirru_sepal/core.cljs +++ b/polyfill/cirru_sepal/core.cljs @@ -12,10 +12,18 @@ (defn transform-apply [xs] (map transform-x xs)) +(defn transform-defn-meta [tag func params & body] + (assert (string? func) "[Sepal] function name should be a symbol!") + (assert (coll? params) "[Sepal] params should be a sequence!") + `(~'defn ~(symbol tag) ~(symbol func) [~@(map transform-x params)] ~@(map transform-x body))) + (defn transform-defn [func params & body] - (assert (string? func) "[Sepal] function name should be a symbol!") - (assert (coll? params) "[Sepal] params should be a sequence!") - `(~'defn ~(symbol func) [~@(map transform-x params)] ~@(map transform-x body))) + (if (string/starts-with? func "^") + (apply transform-defn-meta func params body) + (do + (assert (string? func) "[Sepal] function name should be a symbol!") + (assert (coll? params) "[Sepal] params should be a sequence!") + `(~'defn ~(symbol func) [~@(map transform-x params)] ~@(map transform-x body))))) (defn transform-defn$ [func & body] (assert (string? func) "[Sepal] function name should be a symbol!") diff --git a/release.edn b/release.edn index b1bcd3a..89a9649 100644 --- a/release.edn +++ b/release.edn @@ -1,4 +1,4 @@ -{:version "0.2.8", +{:version "0.2.9-a1", :group-id "cirru", :artifact-id "sepal", :skip-tag true, diff --git a/yarn.lock b/yarn.lock index 29aa195..ca5c95d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -84,15 +84,15 @@ browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: randombytes "^2.0.1" browserify-sign@^4.0.0: - version "4.2.0" - resolved "https://registry.npm.taobao.org/browserify-sign/download/browserify-sign-4.2.0.tgz#545d0b1b07e6b2c99211082bf1b12cce7a0b0e11" - integrity sha1-VF0LGwfmssmSEQgr8bEsznoLDhE= + version "4.2.1" + resolved "https://registry.npm.taobao.org/browserify-sign/download/browserify-sign-4.2.1.tgz?cache=0&sync_timestamp=1596557797092&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbrowserify-sign%2Fdownload%2Fbrowserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" + integrity sha1-6vSt1G3VS+O7OzbAzxWrvrp5VsM= dependencies: bn.js "^5.1.1" browserify-rsa "^4.0.1" create-hash "^1.2.0" create-hmac "^1.1.7" - elliptic "^6.5.2" + elliptic "^6.5.3" inherits "^2.0.4" parse-asn1 "^5.1.5" readable-stream "^3.6.0" @@ -148,12 +148,12 @@ core-util-is@~1.0.0: integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= create-ecdh@^4.0.0: - version "4.0.3" - resolved "https://registry.npm.taobao.org/create-ecdh/download/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff" - integrity sha1-yREbbzMEXEaX8UR4f5JUzcd8Rf8= + version "4.0.4" + resolved "https://registry.npm.taobao.org/create-ecdh/download/create-ecdh-4.0.4.tgz?cache=0&sync_timestamp=1596557796546&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcreate-ecdh%2Fdownload%2Fcreate-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" + integrity sha1-1uf0v/pmc2CFoHYv06YyaE2rzE4= dependencies: bn.js "^4.1.0" - elliptic "^6.0.0" + elliptic "^6.5.3" create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: version "1.2.0" @@ -217,9 +217,9 @@ domain-browser@^1.1.1: resolved "https://registry.npm.taobao.org/domain-browser/download/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda" integrity sha1-PTH1AZGmdJ3RN1p/Ui6CPULlTto= -elliptic@^6.0.0, elliptic@^6.5.2: +elliptic@^6.5.3: version "6.5.3" - resolved "https://registry.npm.taobao.org/elliptic/download/elliptic-6.5.3.tgz?cache=0&sync_timestamp=1592492742430&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felliptic%2Fdownload%2Felliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" + resolved "https://registry.npm.taobao.org/elliptic/download/elliptic-6.5.3.tgz?cache=0&sync_timestamp=1592492734974&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felliptic%2Fdownload%2Felliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" integrity sha1-y1nrLv2vc6C9eMzXAVpirW4Pk9Y= dependencies: bn.js "^4.4.0" @@ -232,7 +232,7 @@ elliptic@^6.0.0, elliptic@^6.5.2: events@^3.0.0: version "3.2.0" - resolved "https://registry.npm.taobao.org/events/download/events-3.2.0.tgz?cache=0&sync_timestamp=1595422555438&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fevents%2Fdownload%2Fevents-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" + resolved "https://registry.npm.taobao.org/events/download/events-3.2.0.tgz?cache=0&sync_timestamp=1595422651095&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fevents%2Fdownload%2Fevents-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" integrity sha1-k7h8GPjvzUICpGGuxN/AVWtjk3k= evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: @@ -245,7 +245,7 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: hash-base@^3.0.0: version "3.1.0" - resolved "https://registry.npm.taobao.org/hash-base/download/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" + resolved "https://registry.npm.taobao.org/hash-base/download/hash-base-3.1.0.tgz?cache=0&sync_timestamp=1588318012719&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhash-base%2Fdownload%2Fhash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" integrity sha1-VcOB2eBuHSmXqIO0o/3f5/DTrzM= dependencies: inherits "^2.0.4" @@ -362,7 +362,7 @@ node-libs-browser@^2.0.0: object-assign@^4.1.1: version "4.1.1" - resolved "https://registry.npm.taobao.org/object-assign/download/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + resolved "https://registry.npm.taobao.org/object-assign/download/object-assign-4.1.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fobject-assign%2Fdownload%2Fobject-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= os-browserify@^0.3.0: @@ -372,12 +372,12 @@ os-browserify@^0.3.0: pako@~1.0.5: version "1.0.11" - resolved "https://registry.npm.taobao.org/pako/download/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" + resolved "https://registry.npm.taobao.org/pako/download/pako-1.0.11.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fpako%2Fdownload%2Fpako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" integrity sha1-bJWZ00DVTf05RjgCUqNXBaa5kr8= parse-asn1@^5.0.0, parse-asn1@^5.1.5: version "5.1.5" - resolved "https://registry.npm.taobao.org/parse-asn1/download/parse-asn1-5.1.5.tgz?cache=0&sync_timestamp=1568806175683&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fparse-asn1%2Fdownload%2Fparse-asn1-5.1.5.tgz#003271343da58dc94cace494faef3d2147ecea0e" + resolved "https://registry.npm.taobao.org/parse-asn1/download/parse-asn1-5.1.5.tgz#003271343da58dc94cace494faef3d2147ecea0e" integrity sha1-ADJxND2ljclMrOSU+u89IUfs6g4= dependencies: asn1.js "^4.0.0" @@ -389,12 +389,12 @@ parse-asn1@^5.0.0, parse-asn1@^5.1.5: path-browserify@0.0.1: version "0.0.1" - resolved "https://registry.npm.taobao.org/path-browserify/download/path-browserify-0.0.1.tgz?cache=0&sync_timestamp=1583254548523&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fpath-browserify%2Fdownload%2Fpath-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" + resolved "https://registry.npm.taobao.org/path-browserify/download/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" integrity sha1-5sTd1+06onxoogzE5Q4aTug7vEo= pbkdf2@^3.0.3: version "3.1.1" - resolved "https://registry.npm.taobao.org/pbkdf2/download/pbkdf2-3.1.1.tgz?cache=0&sync_timestamp=1591276015876&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fpbkdf2%2Fdownload%2Fpbkdf2-3.1.1.tgz#cb8724b0fada984596856d1a6ebafd3584654b94" + resolved "https://registry.npm.taobao.org/pbkdf2/download/pbkdf2-3.1.1.tgz#cb8724b0fada984596856d1a6ebafd3584654b94" integrity sha1-y4cksPramEWWhW0abrr9NYRlS5Q= dependencies: create-hash "^1.1.2" @@ -497,12 +497,12 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: version "5.2.1" - resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.1.tgz?cache=0&sync_timestamp=1589129978562&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsafe-buffer%2Fdownload%2Fsafe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.1.tgz?cache=0&sync_timestamp=1589129611964&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsafe-buffer%2Fdownload%2Fsafe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY= safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" - resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz?cache=0&sync_timestamp=1589129978562&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsafe-buffer%2Fdownload%2Fsafe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz?cache=0&sync_timestamp=1589129611964&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsafe-buffer%2Fdownload%2Fsafe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha1-mR7GnSluAxN0fVm9/St0XDX4go0= setimmediate@^1.0.4: @@ -512,7 +512,7 @@ setimmediate@^1.0.4: sha.js@^2.4.0, sha.js@^2.4.8: version "2.4.11" - resolved "https://registry.npm.taobao.org/sha.js/download/sha.js-2.4.11.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsha.js%2Fdownload%2Fsha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" + resolved "https://registry.npm.taobao.org/sha.js/download/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" integrity sha1-N6XPC4HsvGlD3hCbopYNGyZYSuc= dependencies: inherits "^2.0.1" @@ -523,10 +523,10 @@ shadow-cljs-jar@1.3.2: resolved "https://registry.npm.taobao.org/shadow-cljs-jar/download/shadow-cljs-jar-1.3.2.tgz#97273afe1747b6a2311917c1c88d9e243c81957b" integrity sha1-lyc6/hdHtqIxGRfByI2eJDyBlXs= -shadow-cljs@^2.10.17: - version "2.10.17" - resolved "https://registry.npm.taobao.org/shadow-cljs/download/shadow-cljs-2.10.17.tgz#490aea50f95481bb40936d79bade3aa62033dca3" - integrity sha1-SQrqUPlUgbtAk215ut46piAz3KM= +shadow-cljs@^2.10.19: + version "2.10.19" + resolved "https://registry.npm.taobao.org/shadow-cljs/download/shadow-cljs-2.10.19.tgz#907bbad10bb3af38f6a728452e3cd9c34f1166d1" + integrity sha1-kHu60Quzrzj2pyhFLjzZw08RZtE= dependencies: node-libs-browser "^2.0.0" readline-sync "^1.4.7" @@ -537,7 +537,7 @@ shadow-cljs@^2.10.17: source-map-support@^0.4.15: version "0.4.18" - resolved "https://registry.npm.taobao.org/source-map-support/download/source-map-support-0.4.18.tgz?cache=0&sync_timestamp=1587719493563&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsource-map-support%2Fdownload%2Fsource-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" + resolved "https://registry.npm.taobao.org/source-map-support/download/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" integrity sha1-Aoam3ovkJkEzhZTpfM6nXwosWF8= dependencies: source-map "^0.5.6" @@ -549,7 +549,7 @@ source-map@^0.5.6: stream-browserify@^2.0.1: version "2.0.2" - resolved "https://registry.npm.taobao.org/stream-browserify/download/stream-browserify-2.0.2.tgz?cache=0&sync_timestamp=1587041581155&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstream-browserify%2Fdownload%2Fstream-browserify-2.0.2.tgz#87521d38a44aa7ee91ce1cd2a47df0cb49dd660b" + resolved "https://registry.npm.taobao.org/stream-browserify/download/stream-browserify-2.0.2.tgz#87521d38a44aa7ee91ce1cd2a47df0cb49dd660b" integrity sha1-h1IdOKRKp+6RzhzSpH3wy0ndZgs= dependencies: inherits "~2.0.1" @@ -557,7 +557,7 @@ stream-browserify@^2.0.1: stream-http@^2.7.2: version "2.8.3" - resolved "https://registry.npm.taobao.org/stream-http/download/stream-http-2.8.3.tgz#b2d242469288a5a27ec4fe8933acf623de6514fc" + resolved "https://registry.npm.taobao.org/stream-http/download/stream-http-2.8.3.tgz?cache=0&sync_timestamp=1588701397289&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstream-http%2Fdownload%2Fstream-http-2.8.3.tgz#b2d242469288a5a27ec4fe8933acf623de6514fc" integrity sha1-stJCRpKIpaJ+xP6JM6z2I95lFPw= dependencies: builtin-status-codes "^3.0.0" @@ -604,7 +604,7 @@ ultron@~1.1.0: url@^0.11.0: version "0.11.0" - resolved "https://registry.npm.taobao.org/url/download/url-0.11.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Furl%2Fdownload%2Furl-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + resolved "https://registry.npm.taobao.org/url/download/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" integrity sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE= dependencies: punycode "1.3.2" @@ -617,14 +617,14 @@ util-deprecate@^1.0.1, util-deprecate@~1.0.1: util@0.10.3: version "0.10.3" - resolved "https://registry.npm.taobao.org/util/download/util-0.10.3.tgz?cache=0&sync_timestamp=1588238580972&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Futil%2Fdownload%2Futil-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + resolved "https://registry.npm.taobao.org/util/download/util-0.10.3.tgz?cache=0&sync_timestamp=1588238397004&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Futil%2Fdownload%2Futil-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" integrity sha1-evsa/lCAUkZInj23/g7TeTNqwPk= dependencies: inherits "2.0.1" util@^0.11.0: version "0.11.1" - resolved "https://registry.npm.taobao.org/util/download/util-0.11.1.tgz?cache=0&sync_timestamp=1588238580972&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Futil%2Fdownload%2Futil-0.11.1.tgz#3236733720ec64bb27f6e26f421aaa2e1b588d61" + resolved "https://registry.npm.taobao.org/util/download/util-0.11.1.tgz?cache=0&sync_timestamp=1588238397004&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Futil%2Fdownload%2Futil-0.11.1.tgz#3236733720ec64bb27f6e26f421aaa2e1b588d61" integrity sha1-MjZzNyDsZLsn9uJvQhqqLhtYjWE= dependencies: inherits "2.0.3" @@ -636,14 +636,14 @@ vm-browserify@^1.0.1: which@^1.3.1: version "1.3.1" - resolved "https://registry.npm.taobao.org/which/download/which-1.3.1.tgz?cache=0&sync_timestamp=1574116092455&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwhich%2Fdownload%2Fwhich-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + resolved "https://registry.npm.taobao.org/which/download/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" integrity sha1-pFBD1U9YBTFtqNYvn1CRjT2nCwo= dependencies: isexe "^2.0.0" ws@^3.0.0: version "3.3.3" - resolved "https://registry.npm.taobao.org/ws/download/ws-3.3.3.tgz?cache=0&sync_timestamp=1593925670988&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fws%2Fdownload%2Fws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" + resolved "https://registry.npm.taobao.org/ws/download/ws-3.3.3.tgz?cache=0&sync_timestamp=1593925746458&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fws%2Fdownload%2Fws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" integrity sha1-8c+E/i1ekB686U767OeF8YeiKPI= dependencies: async-limiter "~1.0.0"