diff --git a/demo/CHANGELOG.md b/demo/CHANGELOG.md deleted file mode 100644 index fe261b11..00000000 --- a/demo/CHANGELOG.md +++ /dev/null @@ -1,353 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [0.32.0](https://github.com/AliMD/alwatr-signal/compare/v0.31.0...v0.32.0) (2023-05-27) - -### Bug Fixes - -- import util/node ([ca9e995](https://github.com/AliMD/alwatr-signal/commit/ca9e995567ad267c1730e1c98f9dbbd03ab90331)) - -### Features - -- **es-bench:** enhance with optional count and warning ([0d21ee7](https://github.com/AliMD/alwatr-signal/commit/0d21ee79210cf86b6b94904afdac09d5698c3cec)) -- **es-bench:** test flatStr ([961fe4e](https://github.com/AliMD/alwatr-signal/commit/961fe4edb9bb686cc5da8325726eb19099149173)) - -# [0.31.0](https://github.com/AliMD/alwatr-signal/compare/v0.30.0...v0.31.0) (2023-05-08) - -### Bug Fixes - -- build issues ([e1060bc](https://github.com/AliMD/alwatr-signal/commit/e1060bccbfe3c775c32b85e9b8eb601e48b2998c)) -- **demo/crypto:** `logger`s & `token` ([3a777fb](https://github.com/AliMD/alwatr-signal/commit/3a777fb8c7d4deba682c1a84c472c502604f1d2b)) -- **demo/crypto:** log ([0e12cfd](https://github.com/AliMD/alwatr-signal/commit/0e12cfd5fc97a4099353bc12a32d1db179be4720)) -- **demo/crypto:** revert last demo ([8a350a5](https://github.com/AliMD/alwatr-signal/commit/8a350a5554907329cf2c6efc61ea8fef23a0a548)) -- **demo/crypto:** use all token status ([66ae2b7](https://github.com/AliMD/alwatr-signal/commit/66ae2b7286bd8b422e31296f2c17fc477656ab29)) -- **demo/fsm:** new demo for new fsm ([32fa215](https://github.com/AliMD/alwatr-signal/commit/32fa2155d73be3c1328b4926273176ee47505c39)) -- **demo/icon:** remove preloadIcon in demo ([72fe224](https://github.com/AliMD/alwatr-signal/commit/72fe224aeebe4abd6508d0132e4f1943efbd9123)) -- **demo/storage-engine:** use save ([b21408f](https://github.com/AliMD/alwatr-signal/commit/b21408f430608249bb82c418fcaf08b35f4d166e)) -- **demo/token:** import type ([046403a](https://github.com/AliMD/alwatr-signal/commit/046403ab5e3a01642e9a171e2953f087d35c15c5)) -- **demo:** fix demo based on latest `fsm`s changes ([551e5fe](https://github.com/AliMD/alwatr-signal/commit/551e5fe75fa106bc3252bbbbf108a68bf0dc19e7)) -- **demo:** token ([ad03a19](https://github.com/AliMD/alwatr-signal/commit/ad03a19fc4970c01c39ac1b40e8d933a8d0539a0)) -- **es-bench:** logger dev mode ([c2d6cf3](https://github.com/AliMD/alwatr-signal/commit/c2d6cf3753d28cd3c760ab9cd34efa3d3cc50232)) -- **es-bench:** remove `stat` ([9dc52c7](https://github.com/AliMD/alwatr-signal/commit/9dc52c7801cde62d90e962c69635162c416e55ee)) -- **fsm/demo:** signalList ([d53202c](https://github.com/AliMD/alwatr-signal/commit/d53202c7daf3f55682e47e78f9a8a1b8bc70441d)) -- **lint:** ignore es-bench ([a6f59e4](https://github.com/AliMD/alwatr-signal/commit/a6f59e433f6104b934b24ae90676fd0273eea3e8)) -- new logger api ([9d83a7d](https://github.com/AliMD/alwatr-signal/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) -- **storage-engine:** dev mode ([65491ce](https://github.com/AliMD/alwatr-signal/commit/65491ce7b7ff0756d8e475442d175b880b9894db)) - -### Features - -- **bench:** improve bench mark logs ([8d3121b](https://github.com/AliMD/alwatr-signal/commit/8d3121be52493440906c9788a90c69e4c8d05789)) -- **bench:** test logger benchmark impact ([8ed98d8](https://github.com/AliMD/alwatr-signal/commit/8ed98d8764834431c6806545660ba3a77eadc9c6)) -- **bench:** test object vs map ([f60a9fc](https://github.com/AliMD/alwatr-signal/commit/f60a9fce1ca9491e3916fd40fb7a1443927f9d65)) -- **com-pwa/sign-in:** use simple hash for phoneNumber ([4b88494](https://github.com/AliMD/alwatr-signal/commit/4b884940a536f02928692fbf8686c5ca04dea23a)) -- **crypto/hash:** new crc length strategy ([7a6c27e](https://github.com/AliMD/alwatr-signal/commit/7a6c27e2f1b78df4aaa03a764f1b57477f1220fc)) -- **crypto:** add `user factory` demo ([94236c8](https://github.com/AliMD/alwatr-signal/commit/94236c8ece66a1ced6cbf3f35603d2716ab1d5c1)) -- **demo/crypto:** random ([d820445](https://github.com/AliMD/alwatr-signal/commit/d8204451e356c60572df3862edbdb02c06bf6b9f)) -- **demo/fsm:** new demo for state machine ([136b563](https://github.com/AliMD/alwatr-signal/commit/136b563220310d8ec637b4e776c48c1d3bb62ecc)) -- **demo/fsm:** update ([6080469](https://github.com/AliMD/alwatr-signal/commit/60804694ccab53b5c22ea636992f54ef1dde6a4b)) -- **demo/fsm:** update with new api ([9170694](https://github.com/AliMD/alwatr-signal/commit/917069457630eecfa24c6fe83b7d34fb281a9d2d)) -- **demo:** crypto hash ([445b865](https://github.com/AliMD/alwatr-signal/commit/445b8650a1abd98696b7fe954bcfca23f76afba8)) -- **es-bench:** compare `bind` vs `class` ([b949f87](https://github.com/AliMD/alwatr-signal/commit/b949f87234353cd7238730aa26c353422fb06951)) -- **es-bench:** date locale ([7591331](https://github.com/AliMD/alwatr-signal/commit/7591331f08adf1cad855cfcaeca98122d3045009)) -- **es-bench:** new bench model ([3ef68b0](https://github.com/AliMD/alwatr-signal/commit/3ef68b034562a96a927d969d35a54966997aff6e)) -- **es-bench:** test node exist methods ([73bb495](https://github.com/AliMD/alwatr-signal/commit/73bb495deea5df537e42f7c604ab262dba17026a)) -- **fsm:** custom signal callback ([47c22e9](https://github.com/AliMD/alwatr-signal/commit/47c22e92a8a8085148b44b316d649b695ff8071a)) -- **validator:** add `phone` validation ([e5c19ca](https://github.com/AliMD/alwatr-signal/commit/e5c19ca67e7c804cf3e63841890e68c11620d796)) - -# [0.30.0](https://github.com/AliMD/alwatr-signal/compare/v0.29.0...v0.30.0) (2023-03-06) - -### Bug Fixes - -- **demo/fsm:** context object ([1fa8aac](https://github.com/AliMD/alwatr-signal/commit/1fa8aac30ca6b1e15fd29309384466962b4b9f64)) -- **demo/math:** remove getClientId ([8be5a4a](https://github.com/AliMD/alwatr-signal/commit/8be5a4a5c85c1129387667f4f6ceab56ebfb97e6)) -- **fsm:** demo ([079abf9](https://github.com/AliMD/alwatr-signal/commit/079abf9b46bd0a271a30b942dcb0405993010be6)) -- **fsm:** every signal mather ([0dc504d](https://github.com/AliMD/alwatr-signal/commit/0dc504dacbb1ec68f154244619d644ff8e43cc04)) - -### Features - -- Alwatr Finite State Machines ([d5900b4](https://github.com/AliMD/alwatr-signal/commit/d5900b4ee8685b120188888871405853f5a69417)) -- **demo:** fsm light machine ([fe168e3](https://github.com/AliMD/alwatr-signal/commit/fe168e373fa0463124acb5f9b3bf971d1d64a596)) -- es bench ([a6ec86b](https://github.com/AliMD/alwatr-signal/commit/a6ec86bc71dba2aec4dc6c4b42a64af75bb2b012)) -- **fsm:** $all and $self state ([69adf41](https://github.com/AliMD/alwatr-signal/commit/69adf41064ca0f55497484c50e298ebc26c42dcc)) -- **fsm:** enhance types ([3b13046](https://github.com/AliMD/alwatr-signal/commit/3b130463a102f59c38603b0de470be5c87ee88c9)) -- **fsm:** share state events ([de42522](https://github.com/AliMD/alwatr-signal/commit/de42522a97fdf6be8bee73d91a35820e2a5e6efb)) - -# [0.29.0](https://github.com/AliMD/alwatr-signal/compare/v0.28.0...v0.29.0) (2023-02-10) - -### Features - -- **demo/router:** enhance demo ([3595b83](https://github.com/AliMD/alwatr-signal/commit/3595b83b49e34b9d3d7b172bd12509b258839d0b)) -- **i18n:** add replaceNumber and auto detect setLocale from html ([3413471](https://github.com/AliMD/alwatr-signal/commit/341347149f8685bc259034f5593048aa7db0b927)) -- **math:** getDeviceUuid ([946dad3](https://github.com/AliMD/alwatr-signal/commit/946dad3544f2741462ff239edab8b4a9ea323bd6)) -- **math:** rename deviceId to clientId ([b211fd4](https://github.com/AliMD/alwatr-signal/commit/b211fd42245d51d7109186ddb2f41574d0f0b786)) -- review ([53726b7](https://github.com/AliMD/alwatr-signal/commit/53726b77274be429c87b2fd322fe2d939b048c77)) -- **signal:** new demo ([10ffc20](https://github.com/AliMD/alwatr-signal/commit/10ffc2061a463b980da0dcd65d4afb2f850e2553)) - -# [0.28.0](https://github.com/AliMD/alwatr-signal/compare/v0.27.0...v0.28.0) (2023-01-20) - -### Bug Fixes - -- review issue ([e5d192c](https://github.com/AliMD/alwatr-signal/commit/e5d192cbee6917c2de01146cf8bd026895724ab8)) -- **validator:** remove extra trim ([ee9b601](https://github.com/AliMD/alwatr-signal/commit/ee9b601198ea8dded43497df6824e09f65be86b3)) -- **validator:** validate boolean ([c0cfdc2](https://github.com/AliMD/alwatr-signal/commit/c0cfdc21a99cf02bb4d56c00ba186429e72d3aa2)) - -### Features - -- **validator:** demo ([9e577ca](https://github.com/AliMD/alwatr-signal/commit/9e577cad18be45942d36d633932ef0aa2c2ec512)) -- **validator:** demo ([b48a30b](https://github.com/AliMD/alwatr-signal/commit/b48a30bac9f02f0b7edb3b4069c324f835f6d49b)) -- **validator:** update demo ([d49929f](https://github.com/AliMD/alwatr-signal/commit/d49929fca0007aa94482010b7a6245f0bb360bc0)) -- **validator:** update demo ([cc21a90](https://github.com/AliMD/alwatr-signal/commit/cc21a906b371f51696c3619fc0df0f392be99dee)) -- **validator:** update demo ([4f11b61](https://github.com/AliMD/alwatr-signal/commit/4f11b61af433f348cc4a4bd5f837848c6c1298a4)) - -# [0.27.0](https://github.com/AliMD/alwatr-signal/compare/v0.26.0...v0.27.0) (2022-12-29) - -**Note:** Version bump only for package @alwatr/demo - -# [0.26.0](https://github.com/AliMD/alwatr-signal/compare/v0.25.0...v0.26.0) (2022-12-22) - -### Bug Fixes - -- **demo/storage-client:** getStorage ([21b2361](https://github.com/AliMD/alwatr-signal/commit/21b2361a2de49097a5e70ff5282a3df0d393e3d2)) -- set correct path ([d01ce6f](https://github.com/AliMD/alwatr-signal/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) -- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr-signal/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) -- tsconfig path ([02a1fdf](https://github.com/AliMD/alwatr-signal/commit/02a1fdfc8491e0fade218f00c6790e1409fafcaa)) -- **ui/\*:** package path in refrences ([841d86d](https://github.com/AliMD/alwatr-signal/commit/841d86dc2555fdc86a950b490ea2eb9fffe4df2d)) - -### Features - -- improve error debugging ([1fba504](https://github.com/AliMD/alwatr-signal/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) - -# [0.25.0](https://github.com/AliMD/alwatr-signal/compare/v0.24.1...v0.25.0) (2022-12-07) - -**Note:** Version bump only for package @alwatr/demo - -## [0.24.1](https://github.com/AliMD/alwatr-signal/compare/v0.24.0...v0.24.1) (2022-12-01) - -**Note:** Version bump only for package @alwatr/demo - -# [0.24.0](https://github.com/AliMD/alwatr-signal/compare/v0.23.0...v0.24.0) (2022-11-28) - -### Bug Fixes - -- **demo/storage-client:** set default token ([f7a8962](https://github.com/AliMD/alwatr-signal/commit/f7a896202e4a6acd2c248904cdc32dae2773550b)) -- **demo/storage-client:** update config ([2c71396](https://github.com/AliMD/alwatr-signal/commit/2c71396f628942e776814a8bc08705bac679e5ab)) -- **demo:** update types ([010b123](https://github.com/AliMD/alwatr-signal/commit/010b123075d073c8583f557608a9781064d7cc5c)) -- remove \_updatedBy ([d8d5c83](https://github.com/AliMD/alwatr-signal/commit/d8d5c83884bbd30566001ff84faf9e840503471c)) -- update types ([44cc57f](https://github.com/AliMD/alwatr-signal/commit/44cc57f97a99ed810dae3fde39c9525bd0e8ff3c)) -- use ~ for package version ([4e027ff](https://github.com/AliMD/alwatr-signal/commit/4e027ff63875e03b088ebcdc1bdf2495f4494eec)) - -# [0.23.0](https://github.com/AliMD/alwatr-signal/compare/v0.22.1...v0.23.0) (2022-11-23) - -**Note:** Version bump only for package @alwatr/demo - -## [0.22.1](https://github.com/AliMD/alwatr-signal/compare/v0.22.0...v0.22.1) (2022-11-21) - -**Note:** Version bump only for package @alwatr/demo - -# [0.22.0](https://github.com/AliMD/alwatr-signal/compare/v0.21.0...v0.22.0) (2022-11-20) - -### Bug Fixes - -- **demo/storage-client:** handle document not found ([fb73532](https://github.com/AliMD/alwatr-signal/commit/fb73532fd1a1b52552d0b79f97847db059444785)) -- **demo/storage-client:** use host in config ([f3bd04d](https://github.com/AliMD/alwatr-signal/commit/f3bd04dd047afebd99650f57fe6a2715b014dfb2)) -- **storage-client:** demo ([83fa9d0](https://github.com/AliMD/alwatr-signal/commit/83fa9d0bde2a65a02c225bcb9829a87667606fb6)) -- **storage-client:** demo get not found ([5070912](https://github.com/AliMD/alwatr-signal/commit/507091267f06a8f854833ccac5b9a3f77c46ae70)) -- **storage-client:** demo security issue ([85a71d4](https://github.com/AliMD/alwatr-signal/commit/85a71d496bd9e62863ce85c5abb994648f69a36c)) -- **storage-client:** handle 404 in benchmark ([b149c85](https://github.com/AliMD/alwatr-signal/commit/b149c857ae8ec46ae854eb5fd3893395945d5da2)) -- **storage:** performance demo test ([17b2c1a](https://github.com/AliMD/alwatr-signal/commit/17b2c1a54132b524b2389976fb2e21f84e20e9c1)) -- **tsconfig:** rename storage to storage-engine ([229dd77](https://github.com/AliMD/alwatr-signal/commit/229dd77a0aa928013f93ac43514309e163631a29)) - -### Features - -- **demo:** forAll storage-client ([a856099](https://github.com/AliMD/alwatr-signal/commit/a856099f5644a0b059fd0ff25521376d5f9b97eb)) -- **demo:** storage-client ([e19abc4](https://github.com/AliMD/alwatr-signal/commit/e19abc4ecd59200204be7f26ce0021157a26e262)) -- **fetch:** support nodejs ([2ed2ef4](https://github.com/AliMD/alwatr-signal/commit/2ed2ef42e9f204d4896ada4e20b839cfabdc7284)) -- **storage-client:** benchmark test ([7c0fc92](https://github.com/AliMD/alwatr-signal/commit/7c0fc92fa910168775459dc2be484844a6a178cb)) -- **storage-client:** performance demo ([186832c](https://github.com/AliMD/alwatr-signal/commit/186832cfea21b02aa6f7c9ec3eba768fa0ea64ed)) - -### Performance Improvements - -- **storage-client:** refactor for perf improve and keep alive ([ed0b743](https://github.com/AliMD/alwatr-signal/commit/ed0b743a8936602b63d92c216d2d65f6a31d74cf)) - -# [0.21.0](https://github.com/AliMD/alwatr-signal/compare/v0.20.0...v0.21.0) (2022-11-13) - -**Note:** Version bump only for package @alwatr/demo - -# [0.20.0](https://github.com/AliMD/alwatr-signal/compare/v0.19.0...v0.20.0) (2022-11-05) - -### Features - -- **`alwatr-icon`:** icon component ([4a24cdc](https://github.com/AliMD/alwatr-signal/commit/4a24cdcfbb55bdc3928dd39ca9e6372caec386b2)) -- **demo:** dynamic icon demo ([f9c57f5](https://github.com/AliMD/alwatr-signal/commit/f9c57f52bb8ebcbe5f2d26d2aa3287cda48df5c5)) -- **demo:** fetch revalidateCallback ([55a58b7](https://github.com/AliMD/alwatr-signal/commit/55a58b7174065bc01b52de32816505e189cbdf34)) -- **fetch:** update demo ([441c084](https://github.com/AliMD/alwatr-signal/commit/441c08418c67283cf192ca192bfd5f0e238ecdc5)) - -# [0.19.0](https://github.com/AliMD/alwatr-signal/compare/v0.18.0...v0.19.0) (2022-11-01) - -### Bug Fixes - -- **font:** review ([a371bf2](https://github.com/AliMD/alwatr-signal/commit/a371bf2bcf6477487ceeadeaa596919066f5c468)) - -### Features - -- **`demo`:** improve icon demo ([6519f6f](https://github.com/AliMD/alwatr-signal/commit/6519f6f05567b8a4ce3db0bd3a442139902a01d4)) -- **demo:** improve demo dark mode ([b89217e](https://github.com/AliMD/alwatr-signal/commit/b89217eb2bd271e1d62ebe29b41ac2599852d7da)) -- **demo:** seprate fonts ([222e014](https://github.com/AliMD/alwatr-signal/commit/222e014d488416042bf1d8575bfc0eb84d6009e8)) - -# [0.18.0](https://github.com/AliMD/alwatr-signal/compare/v0.17.0...v0.18.0) (2022-10-22) - -### Features - -- **fetch:** cache strategy ([106eabd](https://github.com/AliMD/alwatr-signal/commit/106eabdd10574b24f9919049d0b509ae40168a9a)) -- **fetch:** cache strategy demo ([47dd239](https://github.com/AliMD/alwatr-signal/commit/47dd2391cd1d760cfec8b0f54a249d05b83b4c33)) -- **fetch:** improve demo ([638830f](https://github.com/AliMD/alwatr-signal/commit/638830f817923a71ce0900776622a858e4905cad)) - -# [0.17.0](https://github.com/AliMD/alwatr-signal/compare/v0.16.1...v0.17.0) (2022-10-21) - -### Bug Fixes - -- **storage:** \_last ket ([a1c452a](https://github.com/AliMD/alwatr-signal/commit/a1c452a50c7b53b03765bf37556264a64ac3ed55)) - -### Features - -- add math demo ([7a92dc2](https://github.com/AliMD/alwatr-signal/commit/7a92dc22ab323ddea9ed166e597ea1924cf368e9)) -- **demo:** fetch ([2bf7a69](https://github.com/AliMD/alwatr-signal/commit/2bf7a694f53921b3096b4092f85bd212ec32881b)) -- **fetch:** docs & pattern ([459ad1c](https://github.com/AliMD/alwatr-signal/commit/459ad1c5996f851769306639136d79c0f7270770)) -- **Math:** translateUnicodeDigits ([996c507](https://github.com/AliMD/alwatr-signal/commit/996c507abb4708b9ef32377eb4045efb8a3f0939)) - -# [0.16.0](https://github.com/AliMD/alwatr-signal/compare/v0.15.0...v0.16.0) (2022-09-08) - -**Note:** Version bump only for package @alwatr/demo - -# [0.15.0](https://github.com/AliMD/alwatr-signal/compare/v0.14.0...v0.15.0) (2022-09-01) - -**Note:** Version bump only for package @alwatr/demo - -# [0.14.0](https://github.com/AliMD/alwatr-signal/compare/v0.13.0...v0.14.0) (2022-08-19) - -**Note:** Version bump only for package @alwatr/demo - -# [0.13.0](https://github.com/AliMD/alwatr-signal/compare/v0.12.0...v0.13.0) (2022-08-06) - -### Bug Fixes - -- **token:** calc benchs ([f1240cc](https://github.com/AliMD/alwatr-signal/commit/f1240cce9247c6fb53dd63a940bd95123ba628d1)) - -### Features - -- **storage:** add \_createdBy and \_updatedBy ([1a70945](https://github.com/AliMD/alwatr-signal/commit/1a70945bc61921f13d839adde25fdfe9fb37eaad)) -- **storage:** improve process and add has, storagePath, keys and length ([4e323ad](https://github.com/AliMD/alwatr-signal/commit/4e323ad10ee0630cfa02edd191167b69e14743ff)) -- **token:** generate and verify HOTP tpkens ([d0372f8](https://github.com/AliMD/alwatr-signal/commit/d0372f805a45d6fd6571b50821529068cec7d424)) -- **token:** new package files ([fe620e0](https://github.com/AliMD/alwatr-signal/commit/fe620e0d9f84c4e6d8e0eed47d6b398e218429ad)) - -# [0.12.0](https://github.com/AliMD/alwatr-signal/compare/v0.11.0...v0.12.0) (2022-07-22) - -### Bug Fixes - -- all package refrences ([11b027d](https://github.com/AliMD/alwatr-signal/commit/11b027d4cdbe142e1f5ef6c6f87c1812fbb2d94b)) - -### Features - -- **font:** demo for sahel ([bb087ef](https://github.com/AliMD/alwatr-signal/commit/bb087eff880aceaedfb253494581d1f363632573)) -- **jatabase:** demo ([17beb7e](https://github.com/AliMD/alwatr-signal/commit/17beb7ecdf3e89b0ffee43f4365f3b2dc4950f99)) -- **logger:** node coloring support ([2b4aab6](https://github.com/AliMD/alwatr-signal/commit/2b4aab655bc0707761587a7439de98bbd4ad0e08)) - -# [0.11.0](https://github.com/AliMD/alwatr-signal/compare/v0.10.1...v0.11.0) (2022-04-16) - -**Note:** Version bump only for package @alwatr/demo - -# [0.10.0](https://github.com/AliMD/alwatr-signal/compare/v0.9.0...v0.10.0) (2022-04-02) - -### Bug Fixes - -- **font:** cleanup ([cdd4ee1](https://github.com/AliMD/alwatr-signal/commit/cdd4ee15332cb9f1ec19bf34ec02cb1f5999cad5)) -- try to fix typescript importer in eslint ([ceb508c](https://github.com/AliMD/alwatr-signal/commit/ceb508c9d8152aba4f3833b1c1f4930828e2014d)) - -### Features - -- **demo:** add font demo ([33f3825](https://github.com/AliMD/alwatr-signal/commit/33f3825a7e23b86281d047dd3be3b2f8eb862b8d)) -- **demo:** font ([8035d73](https://github.com/AliMD/alwatr-signal/commit/8035d73dc99d4ff9c8eec0f70bec43b97b80320c)) - -# [0.9.0](https://github.com/AliMD/alwatr-signal/compare/v0.8.0...v0.9.0) (2022-03-22) - -**Note:** Version bump only for package @alwatr/demo - -# [0.8.0](https://github.com/AliMD/alwatr-signal/compare/v0.7.2...v0.8.0) (2022-03-14) - -### Features - -- **demo:** router outlet demo ([54576f0](https://github.com/AliMD/alwatr-signal/commit/54576f0397df1d1471467564529a01b4e75335bf)) -- **router:** improve demo for test signal! ([59a1017](https://github.com/AliMD/alwatr-signal/commit/59a1017f3ed323fea8e9e798f612f0f54b74b399)) -- **router:** simple demo ([884359a](https://github.com/AliMD/alwatr-signal/commit/884359ac2c77a306c2410d6fd351382b416c36fe)) - -## [0.7.2](https://github.com/AliMD/alwatr-signal/compare/v0.7.1...v0.7.2) (2022-03-12) - -### Features - -- **signal:** demo as test ([fc3f9fd](https://github.com/AliMD/alwatr-signal/commit/fc3f9fdd8c76c6bc5117f3ee894480500f81cc80)) - -# [0.7.0](https://github.com/AliMD/alwatr-signal/compare/v0.6.1...v0.7.0) (2022-03-12) - -**Note:** Version bump only for package @alwatr/demo - -# [0.6.0](https://github.com/AliMD/vatr/compare/v0.5.0...v0.6.0) (2022-03-11) - -### Bug Fixes - -- **demo:** package ([c2b2339](https://github.com/AliMD/vatr/commit/c2b2339f1ca08207ae0d0f8f0d7fff9c98a822ce)) -- old One repo links ([1156b07](https://github.com/AliMD/vatr/commit/1156b077e0abc4712207183e01896fe86f7a05f6)) - -# [0.5.0](https://github.com/AliMD/alwatr-signal/compare/v0.4.0...v0.5.0) (2022-03-11) - -**Note:** Version bump only for package @alwatr/demo - -# [0.4.0](https://github.com/AliMD/alwatr-signal/compare/v0.3.0...v0.4.0) (2022-03-11) - -### Features - -- **logger:** add logProperty, logMethodFull ([8b0317d](https://github.com/AliMD/alwatr-signal/commit/8b0317db88ed73604a27935a3a30cd5c31cb0804)) -- **logger:** complete refactor the logger with new API and fix show correct line number ([7efe8cf](https://github.com/AliMD/alwatr-signal/commit/7efe8cf0f566e148406f38fdd60fa3d747c9bc51)) - -# [0.3.0](https://github.com/AliMD/alwatr-signal/compare/v0.2.1...v0.3.0) (2022-03-06) - -**Note:** Version bump only for package @alwatr/demo - -## [0.2.1](https://github.com/AliMD/alwatr-signal/compare/v0.2.0...v0.2.1) (2022-03-05) - -**Note:** Version bump only for package @alwatr/demo - -# [0.2.0](https://github.com/AliMD/alwatr-signal/compare/v0.1.2...v0.2.0) (2022-03-05) - -### Bug Fixes - -- **util:** remove package ([b337d9a](https://github.com/AliMD/alwatr-signal/commit/b337d9a97c8f73c2a87e722b23a50718321d1648)) - -## [0.1.2](https://github.com/AliMD/alwatr-signal/compare/v0.1.1...v0.1.2) (2022-03-03) - -**Note:** Version bump only for package @alwatr/demo - -## [0.1.1](https://github.com/AliMD/alwatr-signal/compare/v0.1.0...v0.1.1) (2022-03-03) - -**Note:** Version bump only for package @alwatr/demo - -# 0.1.0 (2022-03-02) - -### Bug Fixes - -- add type module ([2649798](https://github.com/AliMD/alwatr-signal/commit/2649798c752138742cbdd14ee78768daa26f5b5a)) -- **bug:** rootDir `src` to `.` ([4ad87ee](https://github.com/AliMD/alwatr-signal/commit/4ad87ee4a84b80afe563db5d42671ec9624ffce3)) -- change all [@one](https://github.com/one) to [@alwatr](https://github.com/alwatr) ([e0573bf](https://github.com/AliMD/alwatr-signal/commit/e0573bf8b55c9e25bad3f7b407cc2c3d509f36d3)) -- fix import module ([38dff29](https://github.com/AliMD/alwatr-signal/commit/38dff29a99e21f75f35be31bc11fb84e1f9d4a55)) -- remove `src` and move all content to `root` ([3323322](https://github.com/AliMD/alwatr-signal/commit/33233220ed576f30249aa1197105219b62c65945)) - -### Features - -- build demo ([e50b310](https://github.com/AliMD/alwatr-signal/commit/e50b3106f428a2a11cc0d960970017d564caa017)) -- build index ([93b604f](https://github.com/AliMD/alwatr-signal/commit/93b604f44d43eedec5df1dd47ad84b96a99ed9b7)) -- demo html ([de43204](https://github.com/AliMD/alwatr-signal/commit/de432043c1b46f2c8f0d9c4f46580b31f3eee066)) -- **demo:** add error and force sample ([0aa2edd](https://github.com/AliMD/alwatr-signal/commit/0aa2edd896b417ea79a249f3332ad629e80a17fa)) -- **demo:** add alwatr logger demo ([f759a06](https://github.com/AliMD/alwatr-signal/commit/f759a06f65545d3589a136f2b9a553dfdb1f2af2)) -- **demo:** alwatr logger demo ([302c6f4](https://github.com/AliMD/alwatr-signal/commit/302c6f46fcc00796e6c030c6fe98a6c2b9f21d04)) -- **svg-icon:** init svg-icon package (ionicons) ([#14](https://github.com/AliMD/alwatr-signal/issues/14)) ([5b3a8f6](https://github.com/AliMD/alwatr-signal/commit/5b3a8f67f5676e0a2139cfa30b60666190c991cf)) diff --git a/demo/crypto/benchmark.ts b/demo/crypto/benchmark.ts deleted file mode 100644 index 32224a75..00000000 --- a/demo/crypto/benchmark.ts +++ /dev/null @@ -1,40 +0,0 @@ -import {AlwatrTokenGenerator, type CryptoAlgorithm} from '@alwatr/crypto'; -import {delay} from '@alwatr/util'; - -if (process.env.NODE_ENV !== 'production') { - console.log('Please run node in production for benchmark. NODE_ENV=production node demo/crypto/benchmark.js'); - process.exit(); -} - -const tokenGenerator = new AlwatrTokenGenerator({ - secret: 'my-very-secret-key', - duration: null, - algorithm: 'md5', - encoding: 'base64url', -}); - -const sampleData = 'Lorem ipsum dolor sit amet consectetur adipisicing elit.'; - -function benchmark(algorithm: CryptoAlgorithm): void { - tokenGenerator.config.algorithm = algorithm; - const now = Date.now(); - const testRun = 1_000_000; - let i = testRun; - for (; i > 0; i--) { - tokenGenerator.generate(sampleData); - } - const runPerSec = Math.round((testRun / (Date.now() - now)) * 1000); - console.log(`Benchmark for ${algorithm} runs %s per sec`, runPerSec); -} - -benchmark('md5'); -await delay(500); -benchmark('sha1'); -await delay(500); -benchmark('sha224'); -await delay(500); -benchmark('sha256'); -await delay(500); -benchmark('sha384'); -await delay(500); -benchmark('sha512'); diff --git a/demo/crypto/hash.ts b/demo/crypto/hash.ts deleted file mode 100644 index 117294d6..00000000 --- a/demo/crypto/hash.ts +++ /dev/null @@ -1,16 +0,0 @@ -import {AlwatrHashGenerator} from '@alwatr/crypto'; - -const hashGenerator = new AlwatrHashGenerator({ - algorithm: 'sha1', - encoding: 'base64url', - crcLength: 8, -}); - -const test = (): void => { - const hash = hashGenerator.randomSelfValidate(); - console.log('hash: %s validation: %s', hash, hashGenerator.verifySelfValidate(hash)); -}; - -for (let index = 0; index < 10; index++) { - test(); -} diff --git a/demo/crypto/rand.ts b/demo/crypto/rand.ts deleted file mode 100644 index cc484aae..00000000 --- a/demo/crypto/rand.ts +++ /dev/null @@ -1,8 +0,0 @@ -import {AlwatrHashGenerator, secretGeneratorPreConfig} from '@alwatr/crypto'; - -const hashGenerator = new AlwatrHashGenerator(secretGeneratorPreConfig); - -for (let i = 0; i <= 10; i++) { - console.log('hash: %s', hashGenerator.randomSelfValidate()); -} - diff --git a/demo/crypto/token.ts b/demo/crypto/token.ts deleted file mode 100644 index 7f24f30f..00000000 --- a/demo/crypto/token.ts +++ /dev/null @@ -1,55 +0,0 @@ -import {type TokenStatus, AlwatrTokenGenerator} from '@alwatr/crypto'; -import {createLogger} from '@alwatr/logger'; - -const logger = createLogger('token/demo', true); - -const tokenGenerator = new AlwatrTokenGenerator({ - secret: 'my-very-secret-key', - duration: '2s', - algorithm: 'sha512', - encoding: 'base64url', -}); - -interface User { - id: string; - name: string; - role: 'admin' | 'user'; - auth: string; -} - -const user: User = { - id: 'alimd', - name: 'Ali Mihandoost', - role: 'admin', - auth: '', // Generated in first login -}; - -// ------ - -// For example when user authenticated we send user data contain valid auth token. -function login(): User { - user.auth = tokenGenerator.generate(`${user.id}-${user.role}`); - logger.logMethodFull?.('login', {}, {user}); - return user; -} - -// Now request received and we want to validate the token to ensure that the user is authenticated. -function userValidate(user: User): TokenStatus { - const validateStatus = tokenGenerator.verify(`${user.id}-${user.role}`, user.auth); - logger.logMethodFull?.('userValidate', {user}, {validateStatus}); - return validateStatus; -} - -// demo -const userData = login(); -userValidate(userData); // { validateStatus: 'valid' } - -setTimeout(() => { - // 2s later - userValidate(user); // { validateStatus: 'expired' } -}, 2001); - -setTimeout(() => { - // 4s later - userValidate(user); -}, 4001); // { validateStatus: 'invalid' } diff --git a/demo/crypto/user.ts b/demo/crypto/user.ts deleted file mode 100644 index d55e643f..00000000 --- a/demo/crypto/user.ts +++ /dev/null @@ -1,47 +0,0 @@ -import {AlwatrUserFactory} from '@alwatr/crypto'; -import {createLogger} from '@alwatr/logger'; -import {delay} from '@alwatr/util'; - -import type {User} from '@alwatr/type'; - -const logger = createLogger('crypto/user', true); - -const userFactory = new AlwatrUserFactory( - { - algorithm: 'sha1', - encoding: 'base64url', - crcLength: 4, - }, - { - secret: 'my-very-secret-key', - duration: '2s', - algorithm: 'sha512', - encoding: 'base64url', - }, -); - -const user: User = { - id: userFactory.generateId(), - country: 'iran', - fullName: 'امیرمحمد نجفی', - gender: 'male', - lpe: 1, - phoneNumber: 989151234567, -}; - -const userIdValidation = userFactory.verifyId(user.id); -logger.logOther?.('user id validation:', userIdValidation); - -const userToken = userFactory.generateToken([user.id, user.lpe]); -logger.logOther?.('user token:', userToken); - -const userTokenValidation = (): void => { - const tokenValidationStatus = userFactory.verifyToken([user.id, user.lpe], userToken); - logger.logOther?.('user token validation status:', tokenValidationStatus); -}; - -userTokenValidation(); -await delay(2000); -userTokenValidation(); -await delay(1000); -userTokenValidation(); diff --git a/demo/es-bench/bench.ts b/demo/es-bench/bench.ts deleted file mode 100644 index 184e74cb..00000000 --- a/demo/es-bench/bench.ts +++ /dev/null @@ -1,25 +0,0 @@ -if (globalThis.process && (globalThis.process?.env.NODE_ENV !== 'production' || typeof globalThis.gc !== 'function')) { - console.warn('Please run node in production with `--expose-gc` for benchmark\nNODE_ENV=production node --expose-gc demo/...'); -} - -export const bench = (name: string, func: () => void, count = 1_000_000): void => { - globalThis.gc?.(); - let i = count; - const startMemory = globalThis.process?.memoryUsage.rss() ?? 0; - const startTime = performance.now(); - - while (i--) { - func(); - } - - const duration = performance.now() - startTime; - const runPerSec = Math.ceil((count / duration) * 1000); - const memoryUsage = Math.round(((globalThis.process?.memoryUsage.rss() ?? 0) - startMemory) / 10) / 100; - - console.log( - `run ${name} ${runPerSec.toLocaleString()}/s with ${ - globalThis.process?.memoryUsage.rss !== undefined ? memoryUsage.toLocaleString() : '?' - }kb` - ); - globalThis.gc?.(); -}; diff --git a/demo/es-bench/compare.ts b/demo/es-bench/compare.ts deleted file mode 100644 index 97ba890f..00000000 --- a/demo/es-bench/compare.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {bench} from './bench.js'; - -const value = undefined; - -function test_1(): boolean { - if (value === true) { - return true; - } - else { - return false; - } -} - -function test_2(): boolean { - if (value) { - return true; - } - else { - return false; - } -} - - -bench('test_1', test_1); -bench('test_2', test_2); - -bench('test_1', test_1); -bench('test_2', test_2); diff --git a/demo/es-bench/date-locale.ts b/demo/es-bench/date-locale.ts deleted file mode 100644 index 63c222e9..00000000 --- a/demo/es-bench/date-locale.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {bench} from './bench.js'; - -// 18,303,355/s with 44,597.25kb -bench('date_now', () => { - Date.now(); -}); - -// 12,177,203/s with 51,511.3kb -bench('new_date', () => { - new Date(); -}); - -// 677,056/s with 52,559.87kb -const dateTimeFormat = Intl.DateTimeFormat('fa'); -bench('date_time_format_new', () => { - dateTimeFormat.format(new Date()); -}); - -// 9,770/s with 2,381,545.47kb -bench('new_date_time_format_new', () => { - const dateTimeFormat = Intl.DateTimeFormat('fa'); - dateTimeFormat.format(new Date()); -}); - -// 766,025/s with 2,227,060.74kb -bench('date_time_format_now', () => { - dateTimeFormat.format(Date.now()); -}); - -// 9,616/s with 1,784,446.98kb -bench('new_date_time_format_now', () => { - const dateTimeFormat = Intl.DateTimeFormat('fa'); - dateTimeFormat.format(Date.now()); -}); - -// 757,297/s with 1,626,062.85kb -bench('to_locale_date_string', () => { - const time = Date.now(); - new Date(time).toLocaleDateString('fa'); -}); - -globalThis.document?.body.append(' Done. Check the console.'); diff --git a/demo/es-bench/flat-str.ts b/demo/es-bench/flat-str.ts deleted file mode 100644 index 1d1c6e03..00000000 --- a/demo/es-bench/flat-str.ts +++ /dev/null @@ -1,40 +0,0 @@ -import {bench} from './bench.js'; - -function flatstr (s: string) { - // @ts-ignore - s | 0 - return s -} - -let temp = ''; - -function test_1(): void { - let s = ''; - let n = 1_000_000; - while(n--) { - s += 'ali'; - } - temp = s; -} - -function test_2(): void { - let s = ''; - let n = 1_000_000; - while(n--) { - s += 'ali'; - } - temp = flatstr(s); -} - - -bench('test_1', test_1, 10); -bench('test_2', test_2, 10); - -bench('test_1', test_1, 10); -bench('test_2', test_2, 10); - -bench('test_1', test_1, 10); -bench('test_2', test_2, 10); - - -console.log(temp.length) diff --git a/demo/es-bench/for-in-vs-of.ts b/demo/es-bench/for-in-vs-of.ts deleted file mode 100644 index 2a596125..00000000 --- a/demo/es-bench/for-in-vs-of.ts +++ /dev/null @@ -1,80 +0,0 @@ -import {random} from '@alwatr/math'; - -import {bench} from './bench.js'; - -const obj: Record> = {}; -let userName = ''; -console.log(userName); - -function prepare(): void { - for (let i = 100; i; i--) { - obj[i] = { - id: 'user_' + i, - fname: random.string(4, 16), - lname: random.string(4, 32), - email: random.string(8, 32), - token: random.string(16), - }; - } -} - -function test_for_in(): void { - for (const key in obj) { - if (!Object.prototype.hasOwnProperty.call(obj, key)) continue; - userName = obj[key].id; - } -} - -function test_for_of_values(): void { - for (const item of Object.values(obj)) { - userName = item.id; - } -} - -function test_for_of_keys(): void { - for (const key of Object.keys(obj)) { - userName = obj[key].id; - } -} - -prepare(); - -bench('for-of-values', test_for_of_values); -bench('for-of-keys', test_for_of_keys); -bench('for-in', test_for_in); - -globalThis.document?.body.append(' Done. Check the console.'); - -/* -1000 items, key is numberString (obj[i]) - for-of-values: 1s - for-of-keys: 3s - for-in: 6s - -1000 items, if key is string (obj['user_'+i]) - for-of-keys: 11s - for-in: 15s - for-of-values: 26s - - -100 items, key is numberString (obj[i]) - for-of-values: 139ms - for-of-keys: 342ms - for-in: 599ms - -100 items, if key is string (obj['user_'+i]) - for-of-keys: 651ms - for-in: 960ms - for-of-values: 2159ms - - -10 items, key is numberString (obj[i]) - for-of-values: 54ms - for-of-keys: 70ms - for-in: 107ms - -10 items, if key is string (obj['user_'+i]) - for-in: 28ms - for-of-values: 35ms - for-of-keys: 53ms -*/ diff --git a/demo/es-bench/import-tmp.ts b/demo/es-bench/import-tmp.ts deleted file mode 100644 index a8ada091..00000000 --- a/demo/es-bench/import-tmp.ts +++ /dev/null @@ -1,3 +0,0 @@ -export {} - -console.log('test'); diff --git a/demo/es-bench/import.ts b/demo/es-bench/import.ts deleted file mode 100644 index b4d1a438..00000000 --- a/demo/es-bench/import.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {bench} from './bench.js'; - -const a = await import('./import-tmp.js'); - -function test_1(): unknown { - return a; -} - -function test_2(): unknown { - return import('./import-tmp.js'); -} - -bench('test_1', test_1); -bench('test_2', test_2); -bench('test_1', test_1); - -globalThis.document?.body.append(' Done. Check the console.'); diff --git a/demo/es-bench/index.html b/demo/es-bench/index.html deleted file mode 100644 index b0c1e779..00000000 --- a/demo/es-bench/index.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - ES Bench - - - - - Waiting... -
- - diff --git a/demo/es-bench/logger.ts b/demo/es-bench/logger.ts deleted file mode 100644 index 150e7da3..00000000 --- a/demo/es-bench/logger.ts +++ /dev/null @@ -1,39 +0,0 @@ -import {createLogger} from '@alwatr/logger'; -// import {delay} from '@alwatr/util'; - -import {bench} from './bench.js'; - -const logger = createLogger('logger-bench', false); - -const getUserList = (): Record> => { - const userList: Record> = {}; - for (let i = 10; i; i--) { - const userId = 'user_' + i; - userList[userId] = { - user: userId, - fname: 'ali', - lname: 'md', - email: 'i@ali.md', - token: '1234abcd', - }; - } - return userList; -}; - -function test_without_logger(obj: Record): number { - return Object.values(obj).length; -} - -function test_with_logger(obj: Record): number { - logger.logMethodArgs?.('test_with_logger', obj); - return Object.values(obj).length; -} - -bench('test_with_logger 1st', () => test_with_logger(getUserList())); -bench('test_without_logger 1st', () => test_without_logger(getUserList())); - -bench('test_with_logger 2nd', () => test_with_logger(getUserList())); -bench('test_without_logger 2nd', () => test_without_logger(getUserList())); - - -globalThis.document?.body.append(' Done. Check the console.'); diff --git a/demo/es-bench/many-bind.ts b/demo/es-bench/many-bind.ts deleted file mode 100644 index f5c070d9..00000000 --- a/demo/es-bench/many-bind.ts +++ /dev/null @@ -1,53 +0,0 @@ -import {bench} from './bench.js'; - -function test1(id: string): void { - console.log(id); -} -function test2(id: string): void { - console.log(id); -} -function test3(id: string): void { - console.log(id); -} - -const bind = (id: string) => ({ - id, - test1: test1.bind(null, id), - test2: test2.bind(null, id), - test3: test3.bind(null, id), -} as const); - -class MyClass { - constructor(public id: string) { - } - - test1(): void { - console.log(this.id); - } - test2(): void { - console.log(this.id); - } - test3(): void { - console.log(this.id); - } -} - -function test_bind(): string { - const a = bind('123'); - return a.id; -} - -function test_class(): string { - const a = new MyClass('123'); - return a.id; -} - -test_class(); -test_bind(); - -bench('test_bind', test_bind); -bench('test_class', test_class); -bench('test_bind', test_bind); -bench('test_class', test_class); - -globalThis.document?.body.append(' Done. Check the console.'); diff --git a/demo/es-bench/memory-arrow-func.ts b/demo/es-bench/memory-arrow-func.ts deleted file mode 100644 index 95681019..00000000 --- a/demo/es-bench/memory-arrow-func.ts +++ /dev/null @@ -1,31 +0,0 @@ -import {random} from '@alwatr/math'; - -export function heavyObject() { - const obj: Record> = {}; - for (let i = 100_000; i; i--) { - const id = 'user_' + i; - obj[id] = { - id, - fname: random.string(4, 16), - lname: random.string(4, 32), - email: random.string(8, 32), - token: random.string(16), - }; - } - return obj; -} - -(() => { - // @ts-ignore - const temp = heavyObject(); - window.addEventListener('click', () => { - console.log(1); - }); -})(); - -/** - * Empty html: 3.1MB - * Simple event: 3.3MB - * Use heavyObject: 64MB - * Make heavyObject but don`t use it: 3.3MB (برگام!) - */ diff --git a/demo/es-bench/memory-many-func.js b/demo/es-bench/memory-many-func.js deleted file mode 100644 index 0eab094d..00000000 --- a/demo/es-bench/memory-many-func.js +++ /dev/null @@ -1,39 +0,0 @@ -class test1 { -} - -for(let i=0; i<1000; i++) { - test1.prototype['method' + i] = function (a) { - a++; - return a; - } -} - -console.time('bench'); -const a1 = new test1(); -let n1=0; -for(let i=0; i<1000; i++) { - n1 += a1.method500(i); -} -console.timeEnd('bench'); - - -/// -- - - -class test2 { -} - -test2.prototype.methodN = function() { - return function (a) { - a++; - return a; - } -} - -console.time('bench'); -const a2 = new test2(); -let n2=0; -for(let i=0; i<1000; i++) { - n2 += a2.methodN()(i); -} -console.timeEnd('bench'); diff --git a/demo/es-bench/node-exist.ts b/demo/es-bench/node-exist.ts deleted file mode 100644 index 539d0adc..00000000 --- a/demo/es-bench/node-exist.ts +++ /dev/null @@ -1,23 +0,0 @@ -import {accessSync, existsSync, constants} from 'node:fs'; -import { bench } from './bench.js'; - -const filePath = './temp-file.txt'; -function exist(): boolean { - return existsSync(filePath); -} - -function access(): boolean { - try { - accessSync(filePath, constants.F_OK); - return true; - } - catch { - return false - } -} - -console.log('exist(%s) => %s', filePath, exist()) -console.log('access(%s) => %s', filePath, access()) - -bench('exist', exist); -bench('access', access); diff --git a/demo/es-bench/object-vs-map.ts b/demo/es-bench/object-vs-map.ts deleted file mode 100644 index b4ea2416..00000000 --- a/demo/es-bench/object-vs-map.ts +++ /dev/null @@ -1,56 +0,0 @@ -import {bench} from './bench.js'; - -const size = 1_000; - -let userListRecord: Record> = {}; -let userListMap = new Map>(); - -function test_make_map() { - userListMap = new Map>(); - for (let i = size; i; i--) { - const userId = 'user_' + i; - - const user = new Map(); - user.set('user', userId); - user.set('fname', 'ali'); - user.set('lname', 'md'); - user.set('email', 'i@ali.md'); - user.set('token', '1234abcd'); - - userListMap.set(userId, user); - } -} - -function test_make_obj() { - userListRecord = {}; - for (let i = size; i; i--) { - const userId = 'user_' + i; - userListRecord[userId] = { - user: userId, - fname: 'ali', - lname: 'md', - email: 'i@ali.md', - token: '1234abcd', - }; - } -} - -function test_access_map() { - if (userListMap.get('user_' + size / 2)!.get('user') !== 'user_' + size / 2) throw new Error('not_match'); -} - -function test_access_obj() { - if (userListRecord['user_' + size / 2]['user'] !== 'user_' + size / 2) throw new Error('not_match'); -} - -bench('test_make_map_1st', test_make_map, 10_000); -bench('test_make_obj_1st', test_make_obj, 10_000); -bench('test_access_map_1st', test_access_map, 10_000); -bench('test_access_obj_1st', test_access_obj, 10_000); - -bench('test_make_map_2nd', test_make_map, 10_000); -bench('test_make_obj_2nd', test_make_obj, 10_000); -bench('test_access_map_2nd', test_access_map, 10_000); -bench('test_access_obj_2nd', test_access_obj, 10_000); - -globalThis.document?.body.append(' Done. Check the console.'); diff --git a/demo/es-bench/reg-cost.ts b/demo/es-bench/reg-cost.ts deleted file mode 100644 index 0233f5cc..00000000 --- a/demo/es-bench/reg-cost.ts +++ /dev/null @@ -1,26 +0,0 @@ -import {bench} from './bench.js'; - -function test_1(input = 'ali'): string { - return input.replace(/[l i]/g, ''); -} - -const regex = /[l i]/g; -function test_2(input = 'ali'): string { - return input.replace(regex, ''); -} - -function test_3(input = 'ali'): string { - return input.replace(new RegExp('[l i]', 'g'), ''); -} - -const regex2 = new RegExp('[l i]', 'g'); -function test_4(input = 'ali'): string { - return input.replace(regex2, ''); -} - -bench('test_1', test_1); -bench('test_2', test_2); -bench('test_3', test_3); -bench('test_4', test_4); - -globalThis.document?.body.append(' Done. Check the console.'); diff --git a/demo/fetch/index.html b/demo/fetch/index.html deleted file mode 100644 index 13e88e74..00000000 --- a/demo/fetch/index.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - @alwatr/fetch - - - - - -

@alwatr/fetch

- -
- - - - - - - - -
- -
- - - - -
- -

Check the console for result

- - diff --git a/demo/fetch/index.ts b/demo/fetch/index.ts deleted file mode 100644 index ccbfefa4..00000000 --- a/demo/fetch/index.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {type CacheStrategy, type CacheDuplicate, fetch} from '@alwatr/fetch'; - -const buttons = document.querySelectorAll('button') as NodeListOf; - -for (const button of buttons) { - const url = button.dataset.url; - - if (button && url) { - button.addEventListener('click', async () => { - try { - const response = await fetch({ - url, - mode: 'cors', - timeout: +document.querySelector('#timeout')!.value, - cacheStrategy: document.querySelector('#cacheStrategy')!.value as CacheStrategy, - removeDuplicate: document.querySelector('#removeDuplicate')!.value as CacheDuplicate, - async revalidateCallback(response) { - console.log('Demo revalidateCallback: %o', {url, response, text: await response.text()}); - }, - }); - console.log('Demo response: %o', {url, response, text: await response.text()}); - } - catch (error) { - console.warn('Demo catch error: %o', {url, error}); - } - }); - } -} diff --git a/demo/fetch/node.ts b/demo/fetch/node.ts deleted file mode 100644 index 3607a95b..00000000 --- a/demo/fetch/node.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {fetch} from '@alwatr/fetch'; - -try { - const response = await fetch({ - url: 'http://httpbin.org/uuid', - timeout: 3_000, - removeDuplicate: 'auto', - }); - console.log('ok: %s', response.ok); - console.log('text: %s', await response.text()); -} -catch (err) { - console.error(err); -} diff --git a/demo/fetch/style.css b/demo/fetch/style.css deleted file mode 100644 index 879203c1..00000000 --- a/demo/fetch/style.css +++ /dev/null @@ -1,64 +0,0 @@ -html { - color-scheme: light dark; -} - -body { - font-family: system-ui; - width: 20em; - margin: 5em auto 0; -} - -h1, -h3 { - text-align: center; -} - -button { - --border-size: 3px; - --corner-size: 0.45em; /* size of the corner */ - --color: #373b44; - - margin: var(--corner-size); - padding: calc(0.5em + var(--corner-size)) calc(0.9em + var(--corner-size)); - color: var(--color); - --_p: var(--corner-size); - background: - conic-gradient(from 90deg at var(--border-size) var(--border-size),#0000 90deg,var(--color) 0) - var(--_p) var(--_p)/calc(100% - var(--border-size) - 2*var(--_p)) calc(100% - var(--border-size) - 2*var(--_p)); - transition: .3s linear, color 0s, background-color 0s; - outline: var(--border-size) solid #0000; - outline-offset: 0.6em; - font-size: 16px; - border: 0; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; -} - -button:hover, -button:focus-visible { - --_p: 0px; - outline-color: var(--color); - outline-offset: 0.05em; -} - -button:active { - background: var(--color); - color: #fff; -} - -.option-container, -.button-container { - display: flex; - flex-direction: column; - margin: 1em; -} - -@media (prefers-color-scheme: dark) { - button { - --color: #d8dbdf; - } - button:active { - background: #373b44; - } -} diff --git a/demo/finite-state-machine/index.html b/demo/finite-state-machine/index.html deleted file mode 100644 index 497593db..00000000 --- a/demo/finite-state-machine/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - FSM - - - - - - diff --git a/demo/finite-state-machine/light-machine.ts b/demo/finite-state-machine/light-machine.ts index 02ddf22e..dc69f44a 100644 --- a/demo/finite-state-machine/light-machine.ts +++ b/demo/finite-state-machine/light-machine.ts @@ -1,143 +1,60 @@ -import {finiteStateMachineConsumer, finiteStateMachineProvider, type FsmTypeHelper} from '@alwatr/fsm'; +import {FiniteStateMachine} from '@alwatr/fsm2'; import {delay} from '@alwatr/util'; -// Provider -const lightMachineConstructor = finiteStateMachineProvider.defineConstructor('light_machine', { - initial: 'green', - context: { - a: 0 as number, - b: 0 as number, - }, - stateRecord: { - $all: { - entry: 'action_all_entry', - exit: 'action_all_exit', - on: { - POWER_LOST: { - target: 'flashingRed', - actions: 'action_all_POWER_LOST', - }, +type State = 'green' | 'yellow' | 'red' | 'flashingRed'; +type Event = 'timer' | 'powerBack' | 'powerLost'; + +class LightMachine extends FiniteStateMachine { + constructor(name: string) { + super({name, initialState: 'green'}); + + this._stateRecord = { + _all: { + powerLost: 'flashingRed', }, - }, - green: { - entry: 'action_green_entry', - exit: 'action_green_exit', - on: { - TIMER: { - target: 'yellow', - actions: 'action_green_TIMER', - }, + green: { + timer: 'yellow', }, - }, - yellow: { - entry: 'action_yellow_entry', - exit: 'action_yellow_exit', - on: { - TIMER: { - target: 'red', - actions: 'action_yellow_TIMER', - }, + yellow: { + timer: 'red', }, - }, - red: { - entry: 'action_red_entry', - exit: 'action_red_exit', - on: { - TIMER: { - target: 'green', - actions: 'action_red_TIMER', - }, + red: { + timer: 'green', }, - }, - flashingRed: { - entry: 'action_flashingRed_entry', - exit: 'action_flashingRed_exit', - on: { - POWER_BACK: { - target: 'green', - actions: 'action_flashingRed_POWER_BACK', - }, + flashingRed: { + powerBack: 'green', }, - }, - }, -}); - -type LightMachine = FsmTypeHelper; - -// entries actions -finiteStateMachineProvider.defineActions('light_machine', { - 'action_all_entry': (m): void => console.log('$all entry called', m.getState()), - 'action_green_entry': (): void => console.log('green entry called'), - 'action_yellow_entry': (): void => console.log('yellow entry called'), - 'action_red_entry': (): void => console.log('red entry called'), - 'action_flashingRed_entry': (): void => console.log('flashingRed entry called'), -}); + }; -// exits actions -finiteStateMachineProvider.defineActions('light_machine', { - 'action_all_exit': (): void => console.log('$all exit called'), - 'action_green_exit': (): void => console.log('green exit called'), - 'action_yellow_exit': (): void => console.log('yellow exit called'), - 'action_red_exit': (): void => console.log('red exit called'), - 'action_flashingRed_exit': (): void => console.log('flashingRed exit called'), -}); + this._actionRecord = { + _on_powerLost: this._onPowerLost, + }; + } -// transition events actions -finiteStateMachineProvider.defineActions('light_machine', { - 'action_all_POWER_LOST': (): void => console.log('$all.POWER_LOST actions called'), - 'action_green_TIMER': (): void => console.log('green.TIMER actions called'), - 'action_yellow_TIMER': (): void => console.log('yellow.TIMER actions called'), - 'action_red_TIMER': (): void => console.log('red.TIMER actions called'), - 'action_flashingRed_POWER_BACK': (): void => console.log('flashingRed.POWER_BACK actions called'), -}); + protected _onPowerLost(): void { + console.warn('_onPowerLost'); + } +} -finiteStateMachineProvider.defineSignals('light_machine', [ - { - signalId: 'new_content_received', - transition: 'POWER_BACK', - contextName: 'a', - receivePrevious: 'NextCycle', - }, -]); +// ---- -// signals -// 'action_ali_signal': (a): void => console.log('ali signal ', a), +const lightMachine = new LightMachine('demo.light-machine.1'); -// Consumer -const lightMachineConsumer = finiteStateMachineConsumer('light_machine-50', 'light_machine'); - -lightMachineConsumer.defineSignals([ - { - signalId: 'power_button_click_event', - transition: 'POWER_BACK', - receivePrevious: 'No', - }, - { - signalId: 'jafang', - callback: (signalDetail: Record): void => { - console.log(signalDetail); - }, - receivePrevious: 'NextCycle', - }, - { - callback: (): void => { - console.log('subscribe_callback', lightMachineConsumer.getState()); - }, - receivePrevious: 'NextCycle', - }, -]); +lightMachine.subscribe(function StateChanged() { + console.log('state changed: %s', this.state); +}); -console.log('start', lightMachineConsumer.getState()); +console.log('start', lightMachine.state); await delay(1000); -lightMachineConsumer.transition('TIMER', {a: 1}); +lightMachine.transition('timer'); await delay(1000); -lightMachineConsumer.transition('TIMER', {b: 2}); +lightMachine.transition('timer'); await delay(1000); -lightMachineConsumer.transition('TIMER'); +lightMachine.transition('timer'); await delay(1000); -lightMachineConsumer.transition('POWER_LOST', {a: 4}); +lightMachine.transition('powerLost'); await delay(1000); -lightMachineConsumer.transition('TIMER', {a: 5, b: 5}); +lightMachine.transition('timer'); await delay(1000); -lightMachineConsumer.transition('POWER_BACK', {a: 6}); +lightMachine.transition('powerBack'); diff --git a/demo/finite-state-machine2/light-machine.ts b/demo/finite-state-machine2/light-machine.ts deleted file mode 100644 index dc69f44a..00000000 --- a/demo/finite-state-machine2/light-machine.ts +++ /dev/null @@ -1,60 +0,0 @@ -import {FiniteStateMachine} from '@alwatr/fsm2'; -import {delay} from '@alwatr/util'; - -type State = 'green' | 'yellow' | 'red' | 'flashingRed'; -type Event = 'timer' | 'powerBack' | 'powerLost'; - -class LightMachine extends FiniteStateMachine { - constructor(name: string) { - super({name, initialState: 'green'}); - - this._stateRecord = { - _all: { - powerLost: 'flashingRed', - }, - green: { - timer: 'yellow', - }, - yellow: { - timer: 'red', - }, - red: { - timer: 'green', - }, - flashingRed: { - powerBack: 'green', - }, - }; - - this._actionRecord = { - _on_powerLost: this._onPowerLost, - }; - } - - protected _onPowerLost(): void { - console.warn('_onPowerLost'); - } -} - -// ---- - -const lightMachine = new LightMachine('demo.light-machine.1'); - -lightMachine.subscribe(function StateChanged() { - console.log('state changed: %s', this.state); -}); - -console.log('start', lightMachine.state); - -await delay(1000); -lightMachine.transition('timer'); -await delay(1000); -lightMachine.transition('timer'); -await delay(1000); -lightMachine.transition('timer'); -await delay(1000); -lightMachine.transition('powerLost'); -await delay(1000); -lightMachine.transition('timer'); -await delay(1000); -lightMachine.transition('powerBack'); diff --git a/demo/font/index.html b/demo/font/index.html deleted file mode 100644 index 8dd192e8..00000000 --- a/demo/font/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - @alwatr/font - - - - - - - - - - -

@alwatr/font

-
-

فونت وزیر‌متن

-

- بِسْمِ اللهِ الرَّحْمنِ الرَّحِیمِ -
- به نام خداوند بخشنده مهربان -

- اللَّهُمَ کُنْ لِوَلِیکَ الحُجَةِ بنِ الحَسَن صَلَواتُکَ علَیهِ و عَلی آبائِهِ فِی هَذِهِ السَّاعَةِ وَ فِی - کُلِّ سَاعَةٍ وَلِیاً وَ حَافِظاً وَ قَائِداً وَ نَاصِراً وَ دَلِیلًا وَ عَیناً حَتَّی تُسْکِنَهُ أَرْضَکَ - طَوْعاً وَ تُمَتِّعَهُ فِیهَا طَوِیلًا. -
- خدایا برای ولی‌ات حجّة بن الحسن كه درود‌هاى تو بر او و بر پدرانش باد، در این ساعت و در هر ساعت، سرپرست و نگهبان - و پیشوا و یاور و راهنما و دیده‌بان باش، تا او را با رغبت مردم در زمینت سکونت دهی و زمانی طولانی بهره‌مندش سازی. -
- 0123456789 ۰۱۲۳۴۵۶۷۸۹ ٠١٢٣٤٥٦٧٨٩ -

-
- -
-

فونت وزیر‌متن نقطه‌گرد

-

-
- -
-

فونت ساحل

-

-
- - - - diff --git a/demo/font/simple.html b/demo/font/simple.html deleted file mode 100644 index 7e37cf28..00000000 --- a/demo/font/simple.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - @alwatr/font - - - - - - - - - - - -

- بِسْمِ اللهِ الرَّحْمنِ الرَّحِیمِ -
- به نام خداوند بخشنده مهربان -

-
-

- اللَّهُمَ کُنْ لِوَلِیکَ الحُجَةِ بنِ الحَسَن صَلَواتُکَ علَیهِ و عَلی آبائِهِ فِی هَذِهِ السَّاعَةِ وَ فِی - کُلِّ سَاعَةٍ وَلِیاً وَ حَافِظاً وَ قَائِداً وَ نَاصِراً وَ دَلِیلًا وَ عَیناً حَتَّی تُسْکِنَهُ أَرْضَکَ - طَوْعاً وَ تُمَتِّعَهُ فِیهَا طَوِیلًا. -

- -

- خدایا برای ولی‌ات حجّة بن الحسن كه درود‌هاى تو بر او و بر پدرانش باد، در این ساعت و در هر ساعت، سرپرست و نگهبان - و پیشوا و یاور و راهنما و دیده‌بان باش، تا او را با رغبت مردم در زمینت سکونت دهی و زمانی طولانی بهره‌مندش سازی. -

- -

- 0 1 2 3 4 5 6 7 8 9 (english) -
- ۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ (فارسی) -
- ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩ (عربی) -

-
- - diff --git a/demo/i18n/i18n.ts b/demo/i18n/i18n.ts deleted file mode 100644 index 85b22f4a..00000000 --- a/demo/i18n/i18n.ts +++ /dev/null @@ -1,44 +0,0 @@ -import {l10n} from '@alwatr/i18n2'; -import {createLogger} from '@alwatr/logger'; -import {delay} from '@alwatr/util'; -const logger = createLogger('demo/l18n', true); - -l10n.subscribe(() => { - logger.logProperty?.('locale', l10n.locale); - logger.logProperty?.('hi', l10n.message('hi')); -}); - -logger.logProperty?.('hi', l10n.message('hi')); - -l10n.setResourceLoader((locale) => { - return { - ok: true, - meta: { - code: locale.language === 'fa' ? 'fa-IR' : 'en-US', - rev: 2, - }, - data: locale.language === 'fa' ? { - 'hi': 'سلام', - } : { - 'hi': 'hello', - }, - }; -}); - -l10n.setLocale('fa'); - -const now = Date.now(); -// @ts-expect-error constructor type -for (const unit of l10n.constructor._timeUnits) { - const sec = unit.seconds * 1000; - logger.logProperty?.('time ' + unit.label, l10n.relativeTime(now, now - sec)); - logger.logProperty?.('time ' + unit.label, l10n.relativeTime(now, now - 2 * sec)); - logger.logProperty?.('time ' + unit.label, l10n.relativeTime(now, now - 3 * sec)); - logger.logProperty?.('time ' + unit.label, l10n.relativeTime(now, now + sec)); - logger.logProperty?.('time ' + unit.label, l10n.relativeTime(now, now + 2 * sec)); - logger.logProperty?.('time ' + unit.label, l10n.relativeTime(now, now + 3 * sec)); -} - -await delay(500); - -l10n.setLocale('en'); diff --git a/demo/icon/index.html b/demo/icon/index.html deleted file mode 100644 index 36ece63b..00000000 --- a/demo/icon/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - @alwatr/icon - - - - - -

@alwatr/icon

- -
- - diff --git a/demo/icon/index.ts b/demo/icon/index.ts deleted file mode 100644 index d89d2f05..00000000 --- a/demo/icon/index.ts +++ /dev/null @@ -1,435 +0,0 @@ -import '@alwatr/icon'; -// import {preloadIcon} from '@alwatr/icon'; -import {random} from '@alwatr/math'; - -const iconList = [ - 'accessibility', - 'add-circle', - 'add', - 'airplane', - 'alarm', - 'albums', - 'alert-circle', - 'alert', - 'american-football', - 'analytics', - 'aperture', - 'apps', - 'archive', - 'arrow-back-circle', - 'arrow-back', - 'arrow-down-circle', - 'arrow-down', - 'arrow-forward-circle', - 'arrow-forward', - 'arrow-redo-circle', - 'arrow-redo', - 'arrow-undo-circle', - 'arrow-undo', - 'arrow-up-circle', - 'arrow-up', - 'at-circle', - 'at', - 'attach', - 'backspace', - 'bag-add', - 'bag-check', - 'bag-handle', - 'bag', - 'bag-remove', - 'balloon', - 'ban', - 'bandage', - 'bar-chart', - 'barbell', - 'barcode', - 'baseball', - 'basket', - 'basketball', - 'battery-charging', - 'battery-dead', - 'battery-full', - 'battery-half', - 'beaker', - 'bed', - 'beer', - 'bicycle', - 'bluetooth', - 'boat', - 'body', - 'bonfire', - 'book', - 'bookmark', - 'bookmarks', - 'bowling-ball', - 'briefcase', - 'browsers', - 'brush', - 'bug', - 'build', - 'bulb', - 'bus', - 'business', - 'cafe', - 'calculator', - 'calendar-clear', - 'calendar-number', - 'calendar', - 'call', - 'camera', - 'camera-reverse', - 'car', - 'car-sport', - 'card', - 'caret-back-circle', - 'caret-back', - 'caret-down-circle', - 'caret-down', - 'caret-forward-circle', - 'caret-forward', - 'caret-up-circle', - 'caret-up', - 'cart', - 'cash', - 'cellular', - 'chatbox-ellipses', - 'chatbox', - 'chatbubble-ellipses', - 'chatbubble', - 'chatbubbles', - 'checkbox', - 'checkmark-circle', - 'checkmark-done-circle', - 'checkmark-done', - 'checkmark', - 'chevron-back-circle', - 'chevron-back', - 'chevron-down-circle', - 'chevron-down', - 'chevron-forward-circle', - 'chevron-forward', - 'chevron-up-circle', - 'chevron-up', - 'clipboard', - 'close-circle', - 'close', - 'cloud-circle', - 'cloud-done', - 'cloud-download', - 'cloud-offline', - 'cloud', - 'cloud-upload', - 'cloudy-night', - 'cloudy', - 'code-download', - 'code', - 'code-slash', - 'code-working', - 'cog', - 'color-fill', - 'color-filter', - 'color-palette', - 'color-wand', - 'compass', - 'construct', - 'contract', - 'contrast', - 'copy', - 'create', - 'crop', - 'cube', - 'cut', - 'desktop', - 'diamond', - 'dice', - 'disc', - 'document-attach', - 'document-lock', - 'document', - 'document-text', - 'documents', - 'download', - 'duplicate', - 'ear', - 'earth', - 'easel', - 'egg', - 'ellipse', - 'ellipsis-horizontal-circle', - 'ellipsis-horizontal', - 'ellipsis-vertical-circle', - 'ellipsis-vertical', - 'enter', - 'exit', - 'expand', - 'extension-puzzle', - 'eye-off', - 'eye', - 'eyedrop', - 'fast-food', - 'female', - 'file-tray-full', - 'file-tray', - 'file-tray-stacked', - 'film', - 'filter-circle', - 'filter', - 'finger-print', - 'fish', - 'fitness', - 'flag', - 'flame', - 'flash-off', - 'flash', - 'flashlight', - 'flask', - 'flower', - 'folder-open', - 'folder', - 'football', - 'footsteps', - 'funnel', - 'game-controller', - 'gift', - 'git-branch', - 'git-commit', - 'git-compare', - 'git-merge', - 'git-network', - 'git-pull-request', - 'glasses', - 'globe', - 'golf', - 'grid', - 'hammer', - 'hand-left', - 'hand-right', - 'happy', - 'hardware-chip', - 'headset', - 'heart-circle', - 'heart-dislike-circle', - 'heart-dislike', - 'heart-half', - 'heart', - 'help-buoy', - 'help-circle', - 'help', - 'home', - 'hourglass', - 'ice-cream', - 'id-card', - 'image', - 'images', - 'infinite', - 'information-circle', - 'information', - 'invert-mode', - 'journal', - 'key', - 'keypad', - 'language', - 'laptop', - 'layers', - 'leaf', - 'library', - 'link', - 'list-circle', - 'list', - 'locate', - 'location', - 'lock-closed', - 'lock-open', - 'log-in', - 'log-out', - 'magnet', - 'mail-open', - 'mail', - 'mail-unread', - 'male-female', - 'male', - 'man', - 'map', - 'medal', - 'medical', - 'medkit', - 'megaphone', - 'menu', - 'mic-circle', - 'mic-off-circle', - 'mic-off', - 'mic', - 'moon', - 'move', - 'musical-note', - 'musical-notes', - 'navigate-circle', - 'navigate', - 'newspaper', - 'notifications-circle', - 'notifications-off-circle', - 'notifications-off', - 'notifications', - 'nuclear', - 'nutrition', - 'open', - 'options', - 'paper-plane', - 'partly-sunny', - 'pause-circle', - 'pause', - 'paw', - 'pencil', - 'people-circle', - 'people', - 'person-add', - 'person-circle', - 'person', - 'person-remove', - 'phone-landscape', - 'phone-portrait', - 'pie-chart', - 'pin', - 'pint', - 'pizza', - 'planet', - 'play-back-circle', - 'play-back', - 'play-circle', - 'play-forward-circle', - 'play-forward', - 'play', - 'play-skip-back-circle', - 'play-skip-back', - 'play-skip-forward-circle', - 'play-skip-forward', - 'podium', - 'power', - 'pricetag', - 'pricetags', - 'print', - 'prism', - 'pulse', - 'push', - 'qr-code', - 'radio-button-off', - 'radio-button-on', - 'radio', - 'rainy', - 'reader', - 'receipt', - 'recording', - 'refresh-circle', - 'refresh', - 'reload-circle', - 'reload', - 'remove-circle', - 'remove', - 'reorder-four', - 'reorder-three', - 'reorder-two', - 'repeat', - 'resize', - 'restaurant', - 'return-down-back', - 'return-down-forward', - 'return-up-back', - 'return-up-forward', - 'ribbon', - 'rocket', - 'rose', - 'sad', - 'save', - 'scale', - 'scan-circle', - 'scan', - 'school', - 'search-circle', - 'search', - 'send', - 'server', - 'settings', - 'shapes', - 'share', - 'share-social', - 'shield-checkmark', - 'shield-half', - 'shield', - 'shirt', - 'shuffle', - 'skull', - 'snow', - 'sparkles', - 'speedometer', - 'square', - 'star-half', - 'star', - 'stats-chart', - 'stop-circle', - 'stop', - 'stopwatch', - 'storefront', - 'subway', - 'sunny', - 'swap-horizontal', - 'swap-vertical', - 'sync-circle', - 'sync', - 'tablet-landscape', - 'tablet-portrait', - 'telescope', - 'tennisball', - 'terminal', - 'text', - 'thermometer', - 'thumbs-down', - 'thumbs-up', - 'thunderstorm', - 'ticket', - 'time', - 'timer', - 'today', - 'toggle', - 'trail-sign', - 'train', - 'transgender', - 'trash-bin', - 'trash', - 'trending-down', - 'trending-up', - 'triangle', - 'trophy', - 'tv', - 'umbrella', - 'unlink', - 'videocam-off', - 'videocam', - 'volume-high', - 'volume-low', - 'volume-medium', - 'volume-mute', - 'volume-off', - 'walk', - 'wallet', - 'warning', - 'watch', - 'water', - 'wifi', - 'wine', - 'woman', -]; - -const container = document.querySelector('.icons')!; - -function addIcon(): void { - const iconElement = document.createElement('alwatr-icon'); - iconElement.name = iconList[random.integer(0, iconList.length - 1)] + '-outline'; - container.appendChild(iconElement); -} - -document.addEventListener('click', addIcon); -addIcon(); - -// for (const iconName of iconList) { -// preloadIcon(iconName + '-outline'); -// } diff --git a/demo/index.html b/demo/index.html index 0ef10770..42c09d81 100644 --- a/demo/index.html +++ b/demo/index.html @@ -13,20 +13,8 @@
    -
  1. Logger
  2. -
  3. Fetch
  4. Signal
  5. -
  6. Signal Simple
  7. -
  8. Context Signal
  9. -
  10. Signal multithread
  11. -
  12. Router
  13. -
  14. Router2
  15. -
  16. Font
  17. -
  18. Math
  19. -
  20. Icon
  21. -
  22. ES Bench
  23. FSM
  24. -
  25. Validator
  26. Server Context
diff --git a/demo/logger/index.html b/demo/logger/index.html deleted file mode 100644 index 46b7c8ca..00000000 --- a/demo/logger/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - @alwatr/logger - - - - - -

Check the console

- - diff --git a/demo/logger/index.ts b/demo/logger/index.ts deleted file mode 100644 index 21338042..00000000 --- a/demo/logger/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {createLogger} from '@alwatr/logger'; - -const logger1 = createLogger('logger/demo1'); -const logger2 = createLogger('logger/demo2'); - -console.debug('--- logger.logProperty ---'); -logger1.logProperty?.('name', 'ali'); -logger2.logProperty?.('options', {a: 1, b: 2}); - -console.debug('--- logger.logMethod ---'); -logger1.logMethod?.('myMethod1'); -logger2.logMethod?.('myMethod2'); - -console.debug('--- logger.logMethodArgs ---'); -logger1.logMethodArgs?.('myMethod1', {a: 1, b: 2}); -logger2.logMethodArgs?.('myMethod2', {a: 1, b: 2}); - -console.debug('--- logger.logMethodFull ---'); -logger1.logMethodFull?.('add', {a: 1, b: 2}, 3); - -console.debug('--- logger.incident ---'); -logger1.incident?.('myMethod', 'abort_signal', 'Aborted signal received', {url: '/test.json'}); - -console.debug('--- logger.accident ---'); -logger2.accident('myMethod', 'file_not_found', 'Url requested return 404 not found', { - url: '/test.json', -}); - -console.debug('--- logger.logOther ---'); -logger1.logOther?.('foo:', 'bar', {a: 1}); - -console.debug('--- logger.error ---'); -try { - throw new Error('my_error_message'); -} -catch (err) { - logger1.error('myMethod', 'error_code', err, {a: 1, b: 2}); -} diff --git a/demo/math/index.html b/demo/math/index.html deleted file mode 100644 index cb631516..00000000 --- a/demo/math/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - @alwatr/math - - - - - -

Check the console

- - diff --git a/demo/math/translate-unicode-digits.ts b/demo/math/translate-unicode-digits.ts deleted file mode 100644 index 59f3547b..00000000 --- a/demo/math/translate-unicode-digits.ts +++ /dev/null @@ -1,29 +0,0 @@ -import {UnicodeDigits} from '@alwatr/math'; - -const unicodeDigits = new UnicodeDigits('fa', 'all'); - -const list = [ - '0123456789', - '٠١٢٣٤٥٦٧٨٩', - '߀߁߂߃߄߅߆߇߈߉', - '०१२३४५६७८९', - '০১২৩৪৫৬৭৮৯', - '੦੧੨੩੪੫੬੭੮੯', - '૦૧૨૩૪૫૬૭૮૯', - '୦୧୨୩୪୫୬୭୮୯', - '௦௧௨௩௪௫௬௭௮௯', -].join('\n'); - -console.log(list); -console.log('-----'); - -console.log(unicodeDigits.translate(list)); - -const start = Date.now(); -const count = 20_000; - -for (let i = count; i > 0; i--) { - unicodeDigits.translate(list); -} - -console.log((count / (Date.now() - start)) * 1000); diff --git a/demo/package.json b/demo/package.json index 0335882a..edb1a4df 100644 --- a/demo/package.json +++ b/demo/package.json @@ -4,20 +4,5 @@ "main": "index.js", "author": "S. Ali Mihandoost (https://ali.mihandoost.com)", "type": "module", - "private": "true", - "dependencies": { - "@alwatr/crypto": "^1.0.0", - "@alwatr/fetch": "^1.0.0", - "@alwatr/icon": "^1.0.0", - "@alwatr/logger": "^1.0.0", - "@alwatr/math": "^1.0.0", - "@alwatr/router": "^1.0.0", - "@alwatr/signal": "^1.0.0", - "@alwatr/storage-client": "^1.0.0", - "@alwatr/storage-engine": "^1.0.0", - "@alwatr/type": "^1.0.0", - "@alwatr/util": "^1.0.0", - "@alwatr/validator": "^1.0.0", - "tslib": "^2.6.2" - } + "private": "true" } diff --git a/demo/router/index.html b/demo/router/index.html deleted file mode 100644 index 91101344..00000000 --- a/demo/router/index.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - @alwatr/router - - - - - -

Check the console

-
    - - - - - - - - -
- -
- - - - diff --git a/demo/router/index.ts b/demo/router/index.ts deleted file mode 100644 index bc1a3c72..00000000 --- a/demo/router/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import {routerOutlet, routeContextConsumer, redirect, type RouteContext, type RoutesConfig} from '@alwatr/router'; - -const routes: RoutesConfig = { - routeId: (routeContext: RouteContext): string | undefined => routeContext.sectionList[0]?.toString(), - templates: { - 'home': () => '

Home Page

', - '_404': () => '

404 Not Found!

', - 'about': () => '

About Page

', - 'product-list': () => '

Product List

', - 'product': (routeContext) => `

Product ${routeContext.sectionList[1]}

`, - 'contact': () => '

Product Page

', - }, -}; - -/** - * Your render process, can be lit-element requestUpdate or any other framework request render method. - */ -function render(): void { - console.info('render'); - document.querySelector('textarea')!.value = JSON.stringify(routeContextConsumer.getValue(), null, 2); - document.querySelector('.render')!.innerHTML = routerOutlet(routes) as string; -} - -/** - * Request update in route change. - */ -routeContextConsumer.subscribe(render); - -redirect('/'); diff --git a/demo/router2/index.html b/demo/router2/index.html deleted file mode 100644 index 79cd83f4..00000000 --- a/demo/router2/index.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - @alwatr/router - - - - - -

Check the console

-
    - - - - - - - - -
- -
- - - - diff --git a/demo/router2/index.ts b/demo/router2/index.ts deleted file mode 100644 index 888a0104..00000000 --- a/demo/router2/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import {router} from '@alwatr/router2'; -import {renderState} from '@alwatr/util'; - -type PageName = 'home' | 'about' | 'products' | 'product' | 'contact'; - -/** - * Your render process, can be lit-element requestUpdate or any other framework request render method. - */ -function render(): void { - console.info('render'); - document.querySelector('textarea')!.value = JSON.stringify(router.route, null, 2); - document.querySelector('.render')!.innerHTML = renderState( - router.route.sectionList[0] as PageName ?? 'home', - { - home: 'about', - about: () => '

About Page

', - products: () => '

Product List

', - product: () => `

Product ${router.route.sectionList[1]}

`, - contact: () => '

Product Page

', - _default: () => '

404 Not Found!

', - }, - ) ?? 'error!'; -} - -/** - * Request update in route change. - */ -router.subscribe(render); - -router.redirect('/'); diff --git a/demo/signal2/context/index.html b/demo/signal/context/index.html similarity index 100% rename from demo/signal2/context/index.html rename to demo/signal/context/index.html diff --git a/demo/signal2/context/index.ts b/demo/signal/context/index.ts similarity index 100% rename from demo/signal2/context/index.ts rename to demo/signal/context/index.ts diff --git a/demo/signal/index.html b/demo/signal/index.html deleted file mode 100644 index 4dd4687a..00000000 --- a/demo/signal/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - @alwatr/signal - - - - - -

Check the console

- - - - diff --git a/demo/signal/index.ts b/demo/signal/index.ts deleted file mode 100644 index 0801a351..00000000 --- a/demo/signal/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -import {commandHandler, commandTrigger} from '@alwatr/signal'; - -commandHandler.define<{a: number; b: number}, number>( - 'command-add', - (argumentObject) => argumentObject.a + argumentObject.b, -); - -// ---- - -const commandAddTrigger = commandTrigger.bind<{a: number; b: number}, number>('command-add'); - -document.getElementById('requestButton')?.addEventListener('click', async () => { - console.info('1. request command'); - const value = await commandAddTrigger.request({a: 10, b: 20}); - console.info('2. returned: ', value); -}); - -document.getElementById('requestButton2')?.addEventListener('click', async () => { - console.info('1. request command (10+20)'); - const value = await commandAddTrigger.request({a: 10, b: 20}); - console.info('2. returned (10+20): ', value); - - console.info('3. request command (10+30, 10+40)'); - const value1p = commandAddTrigger.request({a: 10, b: 30}); - const value2p = commandAddTrigger.request({a: 10, b: 40}); - console.info('4. returned (%s)', (await Promise.all([value1p, value2p])).join(', ')); -}); diff --git a/demo/signal2/multithread-context/index.html b/demo/signal/multithread-context/index.html similarity index 100% rename from demo/signal2/multithread-context/index.html rename to demo/signal/multithread-context/index.html diff --git a/demo/signal2/multithread-context/index.ts b/demo/signal/multithread-context/index.ts similarity index 100% rename from demo/signal2/multithread-context/index.ts rename to demo/signal/multithread-context/index.ts diff --git a/demo/signal2/multithread-context/main.ts b/demo/signal/multithread-context/main.ts similarity index 100% rename from demo/signal2/multithread-context/main.ts rename to demo/signal/multithread-context/main.ts diff --git a/demo/signal2/multithread-context/share-context.ts b/demo/signal/multithread-context/share-context.ts similarity index 100% rename from demo/signal2/multithread-context/share-context.ts rename to demo/signal/multithread-context/share-context.ts diff --git a/demo/signal2/multithread-context/worker.ts b/demo/signal/multithread-context/worker.ts similarity index 100% rename from demo/signal2/multithread-context/worker.ts rename to demo/signal/multithread-context/worker.ts diff --git a/demo/signal2/simple/index.html b/demo/signal/simple/index.html similarity index 100% rename from demo/signal2/simple/index.html rename to demo/signal/simple/index.html diff --git a/demo/signal2/simple/index.ts b/demo/signal/simple/index.ts similarity index 100% rename from demo/signal2/simple/index.ts rename to demo/signal/simple/index.ts diff --git a/demo/storage-client/benchmark.ts b/demo/storage-client/benchmark.ts deleted file mode 100644 index 8e0583a8..00000000 --- a/demo/storage-client/benchmark.ts +++ /dev/null @@ -1,88 +0,0 @@ -import {random} from '@alwatr/math'; -import {AlwatrStorageClient} from '@alwatr/storage-client'; - -import type {AlwatrDocumentObject} from '@alwatr/type'; - -type User = AlwatrDocumentObject & { - fname: string; - lname: string; - email: string; - token: string; -}; - -const token = process.env.TOKEN ?? 'YOUR_SECRET_TOKEN'; - -const db = new AlwatrStorageClient({ - name: 'junk-data', - host: '127.0.0.1', - port: 9000, - token, -}); - -const max = 100_000; -let i = 0; -let last = 0; - -setInterval(() => { - const speed = (i - last) / 2; - console.log('Index: %s, Speed: %s r/s, Memory: %s MB', last, speed, Math.round(process.memoryUsage.rss() / 1000_000)); - last = i; -}, 2_000); - -console.time('set all items'); - -async function request(): Promise { - const parallelRequest: Promise[] = []; - - for (let j = 0; j < 100; j++) { - i++; - const newUser: User = { - id: 'user_' + i, - fname: random.string(4, 16), - lname: random.string(4, 32), - email: random.string(8, 32), - token: random.string(16), - }; - - parallelRequest.push(db.set(newUser)); - } - - await Promise.all(parallelRequest); - - if (i < max) { - setImmediate(request); - } - else { - console.timeEnd('set all items'); - } -} - -async function getBench(): Promise { - console.time('get item'); - try { - const item = await db.get('user_5000'); - console.dir(item); - } - catch (err) { - if ((err as Error)?.message === 'document_not_found') { - console.log('user_5000 id not found!'); - } - else { - throw err; - } - } - console.timeEnd('get item'); - - console.time('get keys'); - const keys = await db.keys(); - console.timeEnd('get keys'); - console.log('keys.length: %s', keys.length); - - console.time('get all'); - await db.getStorage(); - console.timeEnd('get all'); -} - -await getBench(); - -request(); diff --git a/demo/storage-client/index.ts b/demo/storage-client/index.ts deleted file mode 100644 index 0cec5b24..00000000 --- a/demo/storage-client/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -import {AlwatrStorageClient} from '@alwatr/storage-client'; - -import type {AlwatrDocumentObject} from '@alwatr/type'; - -type User = AlwatrDocumentObject & { - fname: string; - lname: string; - email: string; - token?: string; -}; - -const token = process.env.TOKEN ?? 'YOUR_SECRET_TOKEN'; - -const db = new AlwatrStorageClient({ - name: 'user-list', - host: '127.0.0.1', - port: 9000, - token, -}); - -let ali: User | null; - -try { - ali = await db.get('alimd'); - - if (ali == null ) { - console.log('ali not found'); - const ali = { - id: 'alimd', - fname: 'Ali', - lname: 'Mihandoost', - email: 'ali@mihandoost.com', - }; - await db.set(ali); - } - else { - console.log('ali found: %o', ali); - ali.token = Math.random().toString(36).substring(2, 15); - } -} -catch (err) { - console.error(err); -} - -await db.set({ - id: 'fmd', - fname: 'Fatemeh', - lname: 'Mihandoost', - email: 'Fatemeh@mihandoost.com', - token: Math.random().toString(36).substring(2, 15), -}); - -console.log('has \'alimd\': %o', await db.has('alimd')); -console.log('keys: %o', await db.keys()); -console.log('getAll: %o', await db.getStorage()); -await db.delete('alimd'); -await db.delete('fmd'); - -try { - await db.delete('abcd'); -} -catch (err) { - console.log('delete 404: %o', (err as Error).message); -} diff --git a/demo/storage-engine/benchmark.ts b/demo/storage-engine/benchmark.ts deleted file mode 100644 index 12a9ebf0..00000000 --- a/demo/storage-engine/benchmark.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {random} from '@alwatr/math'; -import {AlwatrStorageEngine} from '@alwatr/storage-engine'; - -import type {AlwatrDocumentObject} from '@alwatr/type'; - -type User = AlwatrDocumentObject & { - fname: string; - lname: string; - email: string; - token: string; -}; - -const db = new AlwatrStorageEngine({ - name: 'junk-data', - path: 'db', - saveBeautiful: false, - devMode: false, -}); - -console.time('set all items'); - -const max = 100_000; -for (let i = 0; i < max; i++) { - db.set({ - id: 'user_' + i, - fname: random.string(4, 16), - lname: random.string(4, 32), - email: random.string(8, 32), - token: random.string(16), - }); -} - -console.timeEnd('set all items'); - -console.time('get item'); -const item = db.get('user_' + max / 2); -console.timeEnd('get item'); -console.dir(item); diff --git a/demo/storage-engine/index.ts b/demo/storage-engine/index.ts deleted file mode 100644 index 0864f6f0..00000000 --- a/demo/storage-engine/index.ts +++ /dev/null @@ -1,54 +0,0 @@ -import {AlwatrStorageEngine} from '@alwatr/storage-engine'; - -import type {AlwatrDocumentObject} from '@alwatr/type'; - -type User = AlwatrDocumentObject & { - fname: string; - lname: string; - email: string; - token?: string; -}; - -const db = new AlwatrStorageEngine({ - name: 'user-list', - path: 'db', - saveBeautiful: true, - devMode: true, -}); - -console.log('db loaded and ready to access.'); - -let ali = db.get('alimd'); - -if (ali == null) { - console.log('ali not found'); - ali = { - id: 'alimd', - fname: 'Ali', - lname: 'Mihandoost', - email: 'ali@mihandoost.com', - }; -} -else { - console.log('ali found: %o', ali); - /** - * { - * id: 'alimd', - * fname: 'Ali', - * lname: 'MM', - * email: 'i@ali.md', - * } - */ - - ali.token = Math.random().toString(36).substring(2, 15); -} - -db.set(ali); - -db.set({ - id: 'fmd', - fname: 'Fatemeh', - lname: 'Mihandoost', - email: 'Fatemeh@mihandoost.com', - token: Math.random().toString(36).substring(2, 15), -}); diff --git a/demo/validator/index.html b/demo/validator/index.html deleted file mode 100644 index f2078038..00000000 --- a/demo/validator/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - @alwatr/signal - - - - - - -

Check the console

- - diff --git a/demo/validator/phone.ts b/demo/validator/phone.ts deleted file mode 100644 index 1ae8637a..00000000 --- a/demo/validator/phone.ts +++ /dev/null @@ -1,46 +0,0 @@ -import {sanitizePhoneNumber} from '@alwatr/validator'; - -let phoneNumber: string | number | null | undefined; -console.log('sanitizedPhoneNumber(%s): %s', (phoneNumber = null), sanitizePhoneNumber(phoneNumber)); - -console.log( - 'sanitizedPhoneNumber(%s): %s', - (phoneNumber = '91 is not a valid phone 55'), - sanitizePhoneNumber(phoneNumber), -); - -console.log( - 'sanitizedPhoneNumber(%s): %s', - (phoneNumber = 1234), - sanitizePhoneNumber(phoneNumber), -); - -console.log( - 'sanitizedPhoneNumber(%s): %s', - (phoneNumber = '+ 98 915 11 22 123'), - sanitizePhoneNumber(phoneNumber), -); - -console.log( - 'sanitizedPhoneNumber(%s): %s', - (phoneNumber = '98 (915) 11 22 123'), - sanitizePhoneNumber(phoneNumber), -); - -console.log( - 'sanitizedPhoneNumber(%s): %s', - (phoneNumber = '0 (915) 11-22-123'), - sanitizePhoneNumber(phoneNumber), -); - -console.log( - 'sanitizedPhoneNumber(%s): %s', - (phoneNumber = '91511-22123'), - sanitizePhoneNumber(phoneNumber), -); - -console.log( - 'sanitizedPhoneNumber(%s): %s', - (phoneNumber = '۹۸ ۹15۱۱-۲۲-۱۲۳'), - sanitizePhoneNumber(phoneNumber), -); diff --git a/demo/validator/validator.ts b/demo/validator/validator.ts deleted file mode 100644 index f151fe63..00000000 --- a/demo/validator/validator.ts +++ /dev/null @@ -1,132 +0,0 @@ -import {validator} from '@alwatr/validator'; - -console.log('basic test'); -console.log( - validator< - {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true} - >( - {num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true}, - {num: 123, str: 'test', bool: false, _null: null, ali: 'ali', five: 5, true: true}, - ), -); - -console.log('sanitize value test'); -console.log( - validator< - {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true} - >( - {num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true}, - {num: '123', str: 'test', bool: 'false', _null: null, ali: 'ali', five: 5, true: true}, - ), -); - -console.log('nested value test'); -console.log( - validator< - {a: {num: number; str: string; bool: boolean; _null: null; ali: 'ali'; five: 5; true: true}} - >( - {a: {num: Number, str: String, bool: Boolean, _null: null, ali: 'ali', five: 5, true: true}}, - {a: {num: '123', str: 'test', bool: 'false', _null: null, ali: 'ali', five: 5, true: true}}, - ), -); - -console.log('not valid test'); -try { - console.log( - validator< - {num: number} - >( - {num: Number}, - {num: 'test'}, - ), - ); - throw new Error('validator_not_work'); -} -catch (err) { - if ((err as Error).message !== 'validator_not_work') { - console.log('test ok, error message `%s`, error cause: %s', (err as Error).message, (err as Error).cause); - } - else { - throw err; - } -} - -try { - console.log( - validator< - {num: boolean} - >( - {num: Boolean}, - {num: 'true'}, - ), - ); - throw new Error('validator_not_work'); -} -catch (err) { - if ((err as Error).message !== 'validator_not_work') { - console.log('test ok, error message `%s`, error cause: %s', (err as Error).message, (err as Error).cause); - } - else { - throw err; - } -} - -try { - console.log( - validator< - {num: null} - >( - {num: null}, - {num: 'test'}, - ), - ); - throw new Error('validator_not_work'); -} -catch (err) { - if ((err as Error).message !== 'validator_not_work') { - console.log('test ok, error message `%s`, error cause: %s', (err as Error).message, (err as Error).cause); - } - else { - throw err; - } -} - -try { - console.log( - validator< - {num: number} - >( - {num: Number}, - {num: 'test'}, - ), - ); - throw new Error('validator_not_work'); -} -catch (err) { - if ((err as Error).message !== 'validator_not_work') { - console.log('test ok, error message `%s`, error cause: %s', (err as Error).message, (err as Error).cause); - } - else { - throw err; - } -} - -try { - console.log( - validator< - {num: string} - >( - {num: 'test'}, - {num: 'tes'}, - ), - ); - throw new Error('validator_not_work'); -} -catch (err) { - if ((err as Error).message !== 'validator_not_work') { - console.log('test ok, error message `%s`, error cause: %s', (err as Error).message, (err as Error).cause); - } - else { - throw err; - } -}