fenrir-runtime 0.0.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +5 -11
- package/README.md +114 -48
- package/READMEs/turkish.md +156 -0
- package/example/.fenrir/archives/2026-03-14_21-07-26/.metadata.json +7 -0
- package/example/.fenrir/archives/2026-03-14_21-07-26/fenrir.json +9 -0
- package/example/.fenrir/archives/2026-03-14_21-07-26/main.fnr +67 -0
- package/example/{fenrir+aperium → .fenrir/archives/2026-03-14_21-07-26}/package-lock.json +93 -157
- package/example/.fenrir/archives/2026-03-14_21-07-26/package.json +8 -0
- package/example/.fenrir/archives/2026-03-14_21-07-32/.metadata.json +7 -0
- package/example/.fenrir/archives/2026-03-14_21-07-32/fenrir.json +9 -0
- package/example/.fenrir/archives/2026-03-14_21-07-32/main.fnr +67 -0
- package/example/.fenrir/archives/2026-03-14_21-07-32/package-lock.json +826 -0
- package/example/.fenrir/archives/2026-03-14_21-07-32/package.json +8 -0
- package/example/fenrir.json +4 -5
- package/example/main.fnr +96 -11
- package/example/node_modules/.package-lock.json +819 -0
- package/example/node_modules/accepts/HISTORY.md +250 -0
- package/example/node_modules/accepts/LICENSE +23 -0
- package/example/node_modules/accepts/README.md +140 -0
- package/example/node_modules/accepts/index.js +238 -0
- package/example/node_modules/accepts/package.json +47 -0
- package/example/node_modules/body-parser/LICENSE +23 -0
- package/example/node_modules/body-parser/README.md +494 -0
- package/example/node_modules/body-parser/index.js +71 -0
- package/example/node_modules/body-parser/lib/read.js +247 -0
- package/example/node_modules/body-parser/lib/types/json.js +158 -0
- package/example/node_modules/body-parser/lib/types/raw.js +42 -0
- package/example/node_modules/body-parser/lib/types/text.js +36 -0
- package/example/node_modules/body-parser/lib/types/urlencoded.js +142 -0
- package/example/node_modules/body-parser/lib/utils.js +98 -0
- package/example/node_modules/body-parser/package.json +52 -0
- package/example/node_modules/bytes/History.md +97 -0
- package/example/node_modules/bytes/LICENSE +23 -0
- package/example/node_modules/bytes/Readme.md +152 -0
- package/example/node_modules/bytes/index.js +170 -0
- package/example/node_modules/bytes/package.json +42 -0
- package/example/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
- package/example/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
- package/example/node_modules/call-bind-apply-helpers/.nycrc +9 -0
- package/example/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
- package/example/node_modules/call-bind-apply-helpers/LICENSE +21 -0
- package/example/node_modules/call-bind-apply-helpers/README.md +62 -0
- package/example/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
- package/example/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/example/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
- package/example/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/example/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
- package/example/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/example/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
- package/example/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/example/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
- package/example/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/example/node_modules/call-bind-apply-helpers/package.json +85 -0
- package/example/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
- package/example/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/example/node_modules/call-bind-apply-helpers/test/index.js +63 -0
- package/example/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
- package/example/node_modules/call-bound/.eslintrc +13 -0
- package/example/node_modules/call-bound/.github/FUNDING.yml +12 -0
- package/example/node_modules/call-bound/.nycrc +9 -0
- package/example/node_modules/call-bound/CHANGELOG.md +42 -0
- package/example/node_modules/call-bound/LICENSE +21 -0
- package/example/node_modules/call-bound/README.md +53 -0
- package/example/node_modules/call-bound/index.d.ts +94 -0
- package/example/node_modules/call-bound/index.js +19 -0
- package/example/node_modules/call-bound/package.json +99 -0
- package/example/node_modules/call-bound/test/index.js +61 -0
- package/example/node_modules/call-bound/tsconfig.json +10 -0
- package/example/node_modules/content-disposition/HISTORY.md +72 -0
- package/example/node_modules/content-disposition/LICENSE +22 -0
- package/example/node_modules/content-disposition/README.md +142 -0
- package/example/node_modules/content-disposition/index.js +458 -0
- package/example/node_modules/content-disposition/package.json +43 -0
- package/example/node_modules/content-type/HISTORY.md +29 -0
- package/example/node_modules/content-type/LICENSE +22 -0
- package/example/node_modules/content-type/README.md +94 -0
- package/example/node_modules/content-type/index.js +225 -0
- package/example/node_modules/content-type/package.json +42 -0
- package/example/node_modules/cookie/LICENSE +24 -0
- package/example/node_modules/cookie/README.md +317 -0
- package/example/node_modules/cookie/SECURITY.md +25 -0
- package/example/node_modules/cookie/index.js +335 -0
- package/example/node_modules/cookie/package.json +44 -0
- package/example/node_modules/cookie-signature/History.md +70 -0
- package/example/node_modules/cookie-signature/LICENSE +22 -0
- package/example/node_modules/cookie-signature/Readme.md +23 -0
- package/example/node_modules/cookie-signature/index.js +47 -0
- package/example/node_modules/cookie-signature/package.json +24 -0
- package/example/node_modules/debug/LICENSE +20 -0
- package/example/node_modules/debug/README.md +481 -0
- package/example/node_modules/debug/package.json +64 -0
- package/example/node_modules/debug/src/browser.js +272 -0
- package/example/node_modules/debug/src/common.js +292 -0
- package/example/node_modules/debug/src/index.js +10 -0
- package/example/node_modules/debug/src/node.js +263 -0
- package/example/node_modules/depd/History.md +103 -0
- package/example/node_modules/depd/LICENSE +22 -0
- package/example/node_modules/depd/Readme.md +280 -0
- package/example/node_modules/depd/index.js +538 -0
- package/example/node_modules/depd/lib/browser/index.js +77 -0
- package/example/node_modules/depd/package.json +45 -0
- package/example/node_modules/dunder-proto/.eslintrc +5 -0
- package/example/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
- package/example/node_modules/dunder-proto/.nycrc +13 -0
- package/example/node_modules/dunder-proto/CHANGELOG.md +24 -0
- package/example/node_modules/dunder-proto/LICENSE +21 -0
- package/example/node_modules/dunder-proto/README.md +54 -0
- package/example/node_modules/dunder-proto/get.d.ts +5 -0
- package/example/node_modules/dunder-proto/get.js +30 -0
- package/example/node_modules/dunder-proto/package.json +76 -0
- package/example/node_modules/dunder-proto/set.d.ts +5 -0
- package/example/node_modules/dunder-proto/set.js +35 -0
- package/example/node_modules/dunder-proto/test/get.js +34 -0
- package/example/node_modules/dunder-proto/test/index.js +4 -0
- package/example/node_modules/dunder-proto/test/set.js +50 -0
- package/example/node_modules/dunder-proto/tsconfig.json +9 -0
- package/example/node_modules/ee-first/LICENSE +22 -0
- package/example/node_modules/ee-first/README.md +80 -0
- package/example/node_modules/ee-first/index.js +95 -0
- package/example/node_modules/ee-first/package.json +29 -0
- package/example/node_modules/encodeurl/LICENSE +22 -0
- package/example/node_modules/encodeurl/README.md +109 -0
- package/example/node_modules/encodeurl/index.js +60 -0
- package/example/node_modules/encodeurl/package.json +40 -0
- package/example/node_modules/es-define-property/.eslintrc +13 -0
- package/example/node_modules/es-define-property/.github/FUNDING.yml +12 -0
- package/example/node_modules/es-define-property/.nycrc +9 -0
- package/example/node_modules/es-define-property/CHANGELOG.md +29 -0
- package/example/node_modules/es-define-property/LICENSE +21 -0
- package/example/node_modules/es-define-property/README.md +49 -0
- package/example/node_modules/es-define-property/index.d.ts +3 -0
- package/example/node_modules/es-define-property/index.js +14 -0
- package/example/node_modules/es-define-property/package.json +81 -0
- package/example/node_modules/es-define-property/test/index.js +56 -0
- package/example/node_modules/es-define-property/tsconfig.json +10 -0
- package/example/node_modules/es-errors/.eslintrc +5 -0
- package/example/node_modules/es-errors/.github/FUNDING.yml +12 -0
- package/example/node_modules/es-errors/CHANGELOG.md +40 -0
- package/example/node_modules/es-errors/LICENSE +21 -0
- package/example/node_modules/es-errors/README.md +55 -0
- package/example/node_modules/es-errors/eval.d.ts +3 -0
- package/example/node_modules/es-errors/eval.js +4 -0
- package/example/node_modules/es-errors/index.d.ts +3 -0
- package/example/node_modules/es-errors/index.js +4 -0
- package/example/node_modules/es-errors/package.json +80 -0
- package/example/node_modules/es-errors/range.d.ts +3 -0
- package/example/node_modules/es-errors/range.js +4 -0
- package/example/node_modules/es-errors/ref.d.ts +3 -0
- package/example/node_modules/es-errors/ref.js +4 -0
- package/example/node_modules/es-errors/syntax.d.ts +3 -0
- package/example/node_modules/es-errors/syntax.js +4 -0
- package/example/node_modules/es-errors/test/index.js +19 -0
- package/example/node_modules/es-errors/tsconfig.json +49 -0
- package/example/node_modules/es-errors/type.d.ts +3 -0
- package/example/node_modules/es-errors/type.js +4 -0
- package/example/node_modules/es-errors/uri.d.ts +3 -0
- package/example/node_modules/es-errors/uri.js +4 -0
- package/example/node_modules/es-object-atoms/.eslintrc +16 -0
- package/example/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- package/example/node_modules/es-object-atoms/CHANGELOG.md +37 -0
- package/example/node_modules/es-object-atoms/LICENSE +21 -0
- package/example/node_modules/es-object-atoms/README.md +63 -0
- package/example/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- package/example/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- package/example/node_modules/es-object-atoms/ToObject.d.ts +7 -0
- package/example/node_modules/es-object-atoms/ToObject.js +10 -0
- package/example/node_modules/es-object-atoms/index.d.ts +3 -0
- package/example/node_modules/es-object-atoms/index.js +4 -0
- package/example/node_modules/es-object-atoms/isObject.d.ts +3 -0
- package/example/node_modules/es-object-atoms/isObject.js +6 -0
- package/example/node_modules/es-object-atoms/package.json +80 -0
- package/example/node_modules/es-object-atoms/test/index.js +38 -0
- package/example/node_modules/es-object-atoms/tsconfig.json +6 -0
- package/example/node_modules/escape-html/LICENSE +24 -0
- package/example/node_modules/escape-html/Readme.md +43 -0
- package/example/node_modules/escape-html/index.js +78 -0
- package/example/node_modules/escape-html/package.json +24 -0
- package/example/node_modules/etag/HISTORY.md +83 -0
- package/example/node_modules/etag/LICENSE +22 -0
- package/example/node_modules/etag/README.md +159 -0
- package/example/node_modules/etag/index.js +131 -0
- package/example/node_modules/etag/package.json +47 -0
- package/example/node_modules/express/LICENSE +24 -0
- package/example/node_modules/express/Readme.md +276 -0
- package/example/node_modules/express/index.js +11 -0
- package/example/node_modules/express/lib/application.js +631 -0
- package/example/node_modules/express/lib/express.js +81 -0
- package/example/node_modules/express/lib/request.js +514 -0
- package/example/node_modules/express/lib/response.js +1053 -0
- package/example/node_modules/express/lib/utils.js +271 -0
- package/example/node_modules/express/lib/view.js +205 -0
- package/example/node_modules/express/package.json +99 -0
- package/example/node_modules/finalhandler/HISTORY.md +239 -0
- package/example/node_modules/finalhandler/LICENSE +22 -0
- package/example/node_modules/finalhandler/README.md +150 -0
- package/example/node_modules/finalhandler/index.js +293 -0
- package/example/node_modules/finalhandler/package.json +47 -0
- package/example/node_modules/forwarded/HISTORY.md +21 -0
- package/example/node_modules/forwarded/LICENSE +22 -0
- package/example/node_modules/forwarded/README.md +57 -0
- package/example/node_modules/forwarded/index.js +90 -0
- package/example/node_modules/forwarded/package.json +45 -0
- package/example/node_modules/fresh/HISTORY.md +80 -0
- package/example/node_modules/fresh/LICENSE +23 -0
- package/example/node_modules/fresh/README.md +117 -0
- package/example/node_modules/fresh/index.js +136 -0
- package/example/node_modules/fresh/package.json +46 -0
- package/example/node_modules/function-bind/.eslintrc +21 -0
- package/example/node_modules/function-bind/.github/FUNDING.yml +12 -0
- package/example/node_modules/function-bind/.github/SECURITY.md +3 -0
- package/example/node_modules/function-bind/.nycrc +13 -0
- package/example/node_modules/function-bind/CHANGELOG.md +136 -0
- package/example/node_modules/function-bind/LICENSE +20 -0
- package/example/node_modules/function-bind/README.md +46 -0
- package/example/node_modules/function-bind/implementation.js +84 -0
- package/example/node_modules/function-bind/index.js +5 -0
- package/example/node_modules/function-bind/package.json +87 -0
- package/example/node_modules/function-bind/test/.eslintrc +9 -0
- package/example/node_modules/function-bind/test/index.js +252 -0
- package/example/node_modules/get-intrinsic/.eslintrc +42 -0
- package/example/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
- package/example/node_modules/get-intrinsic/.nycrc +9 -0
- package/example/node_modules/get-intrinsic/CHANGELOG.md +186 -0
- package/example/node_modules/get-intrinsic/LICENSE +21 -0
- package/example/node_modules/get-intrinsic/README.md +71 -0
- package/example/node_modules/get-intrinsic/index.js +378 -0
- package/example/node_modules/get-intrinsic/package.json +97 -0
- package/example/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
- package/example/node_modules/get-proto/.eslintrc +10 -0
- package/example/node_modules/get-proto/.github/FUNDING.yml +12 -0
- package/example/node_modules/get-proto/.nycrc +9 -0
- package/example/node_modules/get-proto/CHANGELOG.md +21 -0
- package/example/node_modules/get-proto/LICENSE +21 -0
- package/example/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
- package/example/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/example/node_modules/get-proto/README.md +50 -0
- package/example/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
- package/example/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/example/node_modules/get-proto/index.d.ts +5 -0
- package/example/node_modules/get-proto/index.js +27 -0
- package/example/node_modules/get-proto/package.json +81 -0
- package/example/node_modules/get-proto/test/index.js +68 -0
- package/example/node_modules/get-proto/tsconfig.json +9 -0
- package/example/node_modules/gopd/.eslintrc +16 -0
- package/example/node_modules/gopd/.github/FUNDING.yml +12 -0
- package/example/node_modules/gopd/CHANGELOG.md +45 -0
- package/example/node_modules/gopd/LICENSE +21 -0
- package/example/node_modules/gopd/README.md +40 -0
- package/example/node_modules/gopd/gOPD.d.ts +1 -0
- package/example/node_modules/gopd/gOPD.js +4 -0
- package/example/node_modules/gopd/index.d.ts +5 -0
- package/example/node_modules/gopd/index.js +15 -0
- package/example/node_modules/gopd/package.json +77 -0
- package/example/node_modules/gopd/test/index.js +36 -0
- package/example/node_modules/gopd/tsconfig.json +9 -0
- package/example/node_modules/has-symbols/.eslintrc +11 -0
- package/example/node_modules/has-symbols/.github/FUNDING.yml +12 -0
- package/example/node_modules/has-symbols/.nycrc +9 -0
- package/example/node_modules/has-symbols/CHANGELOG.md +91 -0
- package/example/node_modules/has-symbols/LICENSE +21 -0
- package/example/node_modules/has-symbols/README.md +46 -0
- package/example/node_modules/has-symbols/index.d.ts +3 -0
- package/example/node_modules/has-symbols/index.js +14 -0
- package/example/node_modules/has-symbols/package.json +111 -0
- package/example/node_modules/has-symbols/shams.d.ts +3 -0
- package/example/node_modules/has-symbols/shams.js +45 -0
- package/example/node_modules/has-symbols/test/index.js +22 -0
- package/example/node_modules/has-symbols/test/shams/core-js.js +29 -0
- package/example/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
- package/example/node_modules/has-symbols/test/tests.js +58 -0
- package/example/node_modules/has-symbols/tsconfig.json +10 -0
- package/example/node_modules/hasown/.eslintrc +5 -0
- package/example/node_modules/hasown/.github/FUNDING.yml +12 -0
- package/example/node_modules/hasown/.nycrc +13 -0
- package/example/node_modules/hasown/CHANGELOG.md +40 -0
- package/example/node_modules/hasown/LICENSE +21 -0
- package/example/node_modules/hasown/README.md +40 -0
- package/example/node_modules/hasown/index.d.ts +3 -0
- package/example/node_modules/hasown/index.js +8 -0
- package/example/node_modules/hasown/package.json +92 -0
- package/example/node_modules/hasown/tsconfig.json +6 -0
- package/example/node_modules/http-errors/HISTORY.md +186 -0
- package/example/node_modules/http-errors/LICENSE +23 -0
- package/example/node_modules/http-errors/README.md +169 -0
- package/example/node_modules/http-errors/index.js +290 -0
- package/example/node_modules/http-errors/package.json +54 -0
- package/example/node_modules/iconv-lite/LICENSE +21 -0
- package/example/node_modules/iconv-lite/README.md +138 -0
- package/example/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
- package/example/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
- package/example/node_modules/iconv-lite/encodings/index.js +23 -0
- package/example/node_modules/iconv-lite/encodings/internal.js +218 -0
- package/example/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
- package/example/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/example/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
- package/example/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/example/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/example/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/example/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/example/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/example/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/example/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/example/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/example/node_modules/iconv-lite/encodings/utf16.js +187 -0
- package/example/node_modules/iconv-lite/encodings/utf32.js +307 -0
- package/example/node_modules/iconv-lite/encodings/utf7.js +283 -0
- package/example/node_modules/iconv-lite/lib/bom-handling.js +48 -0
- package/example/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/example/node_modules/iconv-lite/lib/index.d.ts +129 -0
- package/example/node_modules/iconv-lite/lib/index.js +182 -0
- package/example/node_modules/iconv-lite/lib/streams.js +105 -0
- package/example/node_modules/iconv-lite/package.json +70 -0
- package/example/node_modules/iconv-lite/types/encodings.d.ts +423 -0
- package/example/node_modules/inherits/LICENSE +16 -0
- package/example/node_modules/inherits/README.md +42 -0
- package/example/node_modules/inherits/inherits.js +9 -0
- package/example/node_modules/inherits/inherits_browser.js +27 -0
- package/example/node_modules/inherits/package.json +29 -0
- package/example/node_modules/ipaddr.js/LICENSE +19 -0
- package/example/node_modules/ipaddr.js/README.md +233 -0
- package/example/node_modules/ipaddr.js/ipaddr.min.js +1 -0
- package/example/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
- package/example/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
- package/example/node_modules/ipaddr.js/package.json +35 -0
- package/example/node_modules/is-promise/LICENSE +19 -0
- package/example/node_modules/is-promise/index.d.ts +2 -0
- package/example/node_modules/is-promise/index.js +6 -0
- package/example/node_modules/is-promise/index.mjs +3 -0
- package/example/node_modules/is-promise/package.json +30 -0
- package/example/node_modules/is-promise/readme.md +33 -0
- package/example/node_modules/math-intrinsics/.eslintrc +16 -0
- package/example/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
- package/example/node_modules/math-intrinsics/CHANGELOG.md +24 -0
- package/example/node_modules/math-intrinsics/LICENSE +21 -0
- package/example/node_modules/math-intrinsics/README.md +50 -0
- package/example/node_modules/math-intrinsics/abs.d.ts +1 -0
- package/example/node_modules/math-intrinsics/abs.js +4 -0
- package/example/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
- package/example/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
- package/example/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
- package/example/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
- package/example/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
- package/example/node_modules/math-intrinsics/constants/maxValue.js +5 -0
- package/example/node_modules/math-intrinsics/floor.d.ts +1 -0
- package/example/node_modules/math-intrinsics/floor.js +4 -0
- package/example/node_modules/math-intrinsics/isFinite.d.ts +3 -0
- package/example/node_modules/math-intrinsics/isFinite.js +12 -0
- package/example/node_modules/math-intrinsics/isInteger.d.ts +3 -0
- package/example/node_modules/math-intrinsics/isInteger.js +16 -0
- package/example/node_modules/math-intrinsics/isNaN.d.ts +1 -0
- package/example/node_modules/math-intrinsics/isNaN.js +6 -0
- package/example/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
- package/example/node_modules/math-intrinsics/isNegativeZero.js +6 -0
- package/example/node_modules/math-intrinsics/max.d.ts +1 -0
- package/example/node_modules/math-intrinsics/max.js +4 -0
- package/example/node_modules/math-intrinsics/min.d.ts +1 -0
- package/example/node_modules/math-intrinsics/min.js +4 -0
- package/example/node_modules/math-intrinsics/mod.d.ts +3 -0
- package/example/node_modules/math-intrinsics/mod.js +9 -0
- package/example/node_modules/math-intrinsics/package.json +86 -0
- package/example/node_modules/math-intrinsics/pow.d.ts +1 -0
- package/example/node_modules/math-intrinsics/pow.js +4 -0
- package/example/node_modules/math-intrinsics/round.d.ts +1 -0
- package/example/node_modules/math-intrinsics/round.js +4 -0
- package/example/node_modules/math-intrinsics/sign.d.ts +3 -0
- package/example/node_modules/math-intrinsics/sign.js +11 -0
- package/example/node_modules/math-intrinsics/test/index.js +192 -0
- package/example/node_modules/math-intrinsics/tsconfig.json +3 -0
- package/example/node_modules/media-typer/HISTORY.md +50 -0
- package/example/node_modules/media-typer/LICENSE +22 -0
- package/example/node_modules/media-typer/README.md +93 -0
- package/example/node_modules/media-typer/index.js +143 -0
- package/example/node_modules/media-typer/package.json +33 -0
- package/example/node_modules/merge-descriptors/index.d.ts +11 -0
- package/example/node_modules/merge-descriptors/index.js +26 -0
- package/example/node_modules/merge-descriptors/license +11 -0
- package/example/node_modules/merge-descriptors/package.json +50 -0
- package/example/node_modules/merge-descriptors/readme.md +55 -0
- package/example/node_modules/mime-db/HISTORY.md +541 -0
- package/example/node_modules/mime-db/LICENSE +23 -0
- package/example/node_modules/mime-db/README.md +109 -0
- package/example/node_modules/mime-db/db.json +9342 -0
- package/example/node_modules/mime-db/index.js +12 -0
- package/example/node_modules/mime-db/package.json +56 -0
- package/example/node_modules/mime-types/HISTORY.md +428 -0
- package/example/node_modules/mime-types/LICENSE +23 -0
- package/example/node_modules/mime-types/README.md +126 -0
- package/example/node_modules/mime-types/index.js +211 -0
- package/example/node_modules/mime-types/mimeScore.js +57 -0
- package/example/node_modules/mime-types/package.json +49 -0
- package/example/node_modules/ms/index.js +162 -0
- package/example/node_modules/ms/license.md +21 -0
- package/example/node_modules/ms/package.json +38 -0
- package/example/node_modules/ms/readme.md +59 -0
- package/example/node_modules/negotiator/HISTORY.md +114 -0
- package/example/node_modules/negotiator/LICENSE +24 -0
- package/example/node_modules/negotiator/README.md +212 -0
- package/example/node_modules/negotiator/index.js +83 -0
- package/example/node_modules/negotiator/lib/charset.js +169 -0
- package/example/node_modules/negotiator/lib/encoding.js +205 -0
- package/example/node_modules/negotiator/lib/language.js +179 -0
- package/example/node_modules/negotiator/lib/mediaType.js +294 -0
- package/example/node_modules/negotiator/package.json +43 -0
- package/example/node_modules/object-inspect/.eslintrc +53 -0
- package/example/node_modules/object-inspect/.github/FUNDING.yml +12 -0
- package/example/node_modules/object-inspect/.nycrc +13 -0
- package/example/node_modules/object-inspect/CHANGELOG.md +424 -0
- package/example/node_modules/object-inspect/LICENSE +21 -0
- package/example/node_modules/object-inspect/example/all.js +23 -0
- package/example/node_modules/object-inspect/example/circular.js +6 -0
- package/example/node_modules/object-inspect/example/fn.js +5 -0
- package/example/node_modules/object-inspect/example/inspect.js +10 -0
- package/example/node_modules/object-inspect/index.js +544 -0
- package/example/node_modules/object-inspect/package-support.json +20 -0
- package/example/node_modules/object-inspect/package.json +105 -0
- package/example/node_modules/object-inspect/readme.markdown +84 -0
- package/example/node_modules/object-inspect/test/bigint.js +58 -0
- package/example/node_modules/object-inspect/test/browser/dom.js +15 -0
- package/example/node_modules/object-inspect/test/circular.js +16 -0
- package/example/node_modules/object-inspect/test/deep.js +12 -0
- package/example/node_modules/object-inspect/test/element.js +53 -0
- package/example/node_modules/object-inspect/test/err.js +48 -0
- package/example/node_modules/object-inspect/test/fakes.js +29 -0
- package/example/node_modules/object-inspect/test/fn.js +76 -0
- package/example/node_modules/object-inspect/test/global.js +17 -0
- package/example/node_modules/object-inspect/test/has.js +15 -0
- package/example/node_modules/object-inspect/test/holes.js +15 -0
- package/example/node_modules/object-inspect/test/indent-option.js +271 -0
- package/example/node_modules/object-inspect/test/inspect.js +139 -0
- package/example/node_modules/object-inspect/test/lowbyte.js +12 -0
- package/example/node_modules/object-inspect/test/number.js +58 -0
- package/example/node_modules/object-inspect/test/quoteStyle.js +26 -0
- package/example/node_modules/object-inspect/test/toStringTag.js +40 -0
- package/example/node_modules/object-inspect/test/undef.js +12 -0
- package/example/node_modules/object-inspect/test/values.js +261 -0
- package/example/node_modules/object-inspect/test-core-js.js +26 -0
- package/example/node_modules/object-inspect/util.inspect.js +1 -0
- package/example/node_modules/on-finished/HISTORY.md +98 -0
- package/example/node_modules/on-finished/LICENSE +23 -0
- package/example/node_modules/on-finished/README.md +162 -0
- package/example/node_modules/on-finished/index.js +234 -0
- package/example/node_modules/on-finished/package.json +39 -0
- package/example/node_modules/once/LICENSE +15 -0
- package/example/node_modules/once/README.md +79 -0
- package/example/node_modules/once/once.js +42 -0
- package/example/node_modules/once/package.json +33 -0
- package/example/node_modules/parseurl/HISTORY.md +58 -0
- package/example/node_modules/parseurl/LICENSE +24 -0
- package/example/node_modules/parseurl/README.md +133 -0
- package/example/node_modules/parseurl/index.js +158 -0
- package/example/node_modules/parseurl/package.json +40 -0
- package/example/node_modules/path-to-regexp/LICENSE +21 -0
- package/example/node_modules/path-to-regexp/Readme.md +224 -0
- package/example/node_modules/path-to-regexp/dist/index.d.ts +144 -0
- package/example/node_modules/path-to-regexp/dist/index.js +409 -0
- package/example/node_modules/path-to-regexp/dist/index.js.map +1 -0
- package/example/node_modules/path-to-regexp/package.json +64 -0
- package/example/node_modules/proxy-addr/HISTORY.md +161 -0
- package/example/node_modules/proxy-addr/LICENSE +22 -0
- package/example/node_modules/proxy-addr/README.md +139 -0
- package/example/node_modules/proxy-addr/index.js +327 -0
- package/example/node_modules/proxy-addr/package.json +47 -0
- package/example/node_modules/qs/.editorconfig +46 -0
- package/example/node_modules/qs/.github/FUNDING.yml +12 -0
- package/example/node_modules/qs/.github/SECURITY.md +11 -0
- package/example/node_modules/qs/.github/THREAT_MODEL.md +78 -0
- package/example/node_modules/qs/.nycrc +13 -0
- package/example/node_modules/qs/CHANGELOG.md +806 -0
- package/example/node_modules/qs/LICENSE.md +29 -0
- package/example/node_modules/qs/README.md +758 -0
- package/example/node_modules/qs/dist/qs.js +141 -0
- package/example/node_modules/qs/eslint.config.mjs +56 -0
- package/example/node_modules/qs/lib/formats.js +23 -0
- package/example/node_modules/qs/lib/index.js +11 -0
- package/example/node_modules/qs/lib/parse.js +373 -0
- package/example/node_modules/qs/lib/stringify.js +356 -0
- package/example/node_modules/qs/lib/utils.js +342 -0
- package/example/node_modules/qs/package.json +94 -0
- package/example/node_modules/qs/test/empty-keys-cases.js +267 -0
- package/example/node_modules/qs/test/parse.js +1568 -0
- package/example/node_modules/qs/test/stringify.js +1310 -0
- package/example/node_modules/qs/test/utils.js +404 -0
- package/example/node_modules/range-parser/HISTORY.md +56 -0
- package/example/node_modules/range-parser/LICENSE +23 -0
- package/example/node_modules/range-parser/README.md +84 -0
- package/example/node_modules/range-parser/index.js +162 -0
- package/example/node_modules/range-parser/package.json +44 -0
- package/example/node_modules/raw-body/LICENSE +22 -0
- package/example/node_modules/raw-body/README.md +223 -0
- package/example/node_modules/raw-body/index.d.ts +85 -0
- package/example/node_modules/raw-body/index.js +336 -0
- package/example/node_modules/raw-body/package.json +46 -0
- package/example/node_modules/router/HISTORY.md +228 -0
- package/example/node_modules/router/LICENSE +23 -0
- package/example/node_modules/router/README.md +416 -0
- package/example/node_modules/router/index.js +748 -0
- package/example/node_modules/router/lib/layer.js +247 -0
- package/example/node_modules/router/lib/route.js +242 -0
- package/example/node_modules/router/package.json +44 -0
- package/example/node_modules/safer-buffer/LICENSE +21 -0
- package/example/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/example/node_modules/safer-buffer/Readme.md +156 -0
- package/example/node_modules/safer-buffer/dangerous.js +58 -0
- package/example/node_modules/safer-buffer/package.json +34 -0
- package/example/node_modules/safer-buffer/safer.js +77 -0
- package/example/node_modules/safer-buffer/tests.js +406 -0
- package/example/node_modules/send/LICENSE +23 -0
- package/example/node_modules/send/README.md +317 -0
- package/example/node_modules/send/index.js +997 -0
- package/example/node_modules/send/package.json +63 -0
- package/example/node_modules/serve-static/LICENSE +25 -0
- package/example/node_modules/serve-static/README.md +253 -0
- package/example/node_modules/serve-static/index.js +208 -0
- package/example/node_modules/serve-static/package.json +44 -0
- package/example/node_modules/setprototypeof/LICENSE +13 -0
- package/example/node_modules/setprototypeof/README.md +31 -0
- package/example/node_modules/setprototypeof/index.d.ts +2 -0
- package/example/node_modules/setprototypeof/index.js +17 -0
- package/example/node_modules/setprototypeof/package.json +38 -0
- package/example/node_modules/setprototypeof/test/index.js +24 -0
- package/example/node_modules/side-channel/.editorconfig +9 -0
- package/example/node_modules/side-channel/.eslintrc +12 -0
- package/example/node_modules/side-channel/.github/FUNDING.yml +12 -0
- package/example/node_modules/side-channel/.nycrc +13 -0
- package/example/node_modules/side-channel/CHANGELOG.md +110 -0
- package/example/node_modules/side-channel/LICENSE +21 -0
- package/example/node_modules/side-channel/README.md +61 -0
- package/example/node_modules/side-channel/index.d.ts +14 -0
- package/example/node_modules/side-channel/index.js +43 -0
- package/example/node_modules/side-channel/package.json +85 -0
- package/example/node_modules/side-channel/test/index.js +104 -0
- package/example/node_modules/side-channel/tsconfig.json +9 -0
- package/example/node_modules/side-channel-list/.editorconfig +9 -0
- package/example/node_modules/side-channel-list/.eslintrc +11 -0
- package/example/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
- package/example/node_modules/side-channel-list/.nycrc +13 -0
- package/example/node_modules/side-channel-list/CHANGELOG.md +15 -0
- package/example/node_modules/side-channel-list/LICENSE +21 -0
- package/example/node_modules/side-channel-list/README.md +62 -0
- package/example/node_modules/side-channel-list/index.d.ts +13 -0
- package/example/node_modules/side-channel-list/index.js +113 -0
- package/example/node_modules/side-channel-list/list.d.ts +14 -0
- package/example/node_modules/side-channel-list/package.json +77 -0
- package/example/node_modules/side-channel-list/test/index.js +104 -0
- package/example/node_modules/side-channel-list/tsconfig.json +9 -0
- package/example/node_modules/side-channel-map/.editorconfig +9 -0
- package/example/node_modules/side-channel-map/.eslintrc +11 -0
- package/example/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
- package/example/node_modules/side-channel-map/.nycrc +13 -0
- package/example/node_modules/side-channel-map/CHANGELOG.md +22 -0
- package/example/node_modules/side-channel-map/LICENSE +21 -0
- package/example/node_modules/side-channel-map/README.md +62 -0
- package/example/node_modules/side-channel-map/index.d.ts +15 -0
- package/example/node_modules/side-channel-map/index.js +68 -0
- package/example/node_modules/side-channel-map/package.json +80 -0
- package/example/node_modules/side-channel-map/test/index.js +114 -0
- package/example/node_modules/side-channel-map/tsconfig.json +9 -0
- package/example/node_modules/side-channel-weakmap/.editorconfig +9 -0
- package/example/node_modules/side-channel-weakmap/.eslintrc +12 -0
- package/example/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
- package/example/node_modules/side-channel-weakmap/.nycrc +13 -0
- package/example/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
- package/example/node_modules/side-channel-weakmap/LICENSE +21 -0
- package/example/node_modules/side-channel-weakmap/README.md +62 -0
- package/example/node_modules/side-channel-weakmap/index.d.ts +15 -0
- package/example/node_modules/side-channel-weakmap/index.js +84 -0
- package/example/node_modules/side-channel-weakmap/package.json +87 -0
- package/example/node_modules/side-channel-weakmap/test/index.js +114 -0
- package/example/node_modules/side-channel-weakmap/tsconfig.json +9 -0
- package/example/node_modules/statuses/HISTORY.md +87 -0
- package/example/node_modules/statuses/LICENSE +23 -0
- package/example/node_modules/statuses/README.md +139 -0
- package/example/node_modules/statuses/codes.json +65 -0
- package/example/node_modules/statuses/index.js +146 -0
- package/example/node_modules/statuses/package.json +49 -0
- package/example/node_modules/toidentifier/HISTORY.md +9 -0
- package/example/node_modules/toidentifier/LICENSE +21 -0
- package/example/node_modules/toidentifier/README.md +61 -0
- package/example/node_modules/toidentifier/index.js +32 -0
- package/example/node_modules/toidentifier/package.json +38 -0
- package/example/node_modules/type-is/HISTORY.md +292 -0
- package/example/node_modules/type-is/LICENSE +23 -0
- package/example/node_modules/type-is/README.md +198 -0
- package/example/node_modules/type-is/index.js +250 -0
- package/example/node_modules/type-is/package.json +47 -0
- package/example/node_modules/unpipe/HISTORY.md +4 -0
- package/example/node_modules/unpipe/LICENSE +22 -0
- package/example/node_modules/unpipe/README.md +43 -0
- package/example/node_modules/unpipe/index.js +69 -0
- package/example/node_modules/unpipe/package.json +27 -0
- package/example/node_modules/vary/HISTORY.md +39 -0
- package/example/node_modules/vary/LICENSE +22 -0
- package/example/node_modules/vary/README.md +101 -0
- package/example/node_modules/vary/index.js +149 -0
- package/example/node_modules/vary/package.json +43 -0
- package/example/node_modules/wrappy/LICENSE +15 -0
- package/example/node_modules/wrappy/README.md +36 -0
- package/example/node_modules/wrappy/package.json +29 -0
- package/example/node_modules/wrappy/wrappy.js +33 -0
- package/example/package-lock.json +101 -142
- package/example/package.json +2 -11
- package/package.json +11 -23
- package/src/cli/archiveSystem.js +119 -0
- package/src/cli/doctor.js +87 -0
- package/src/cli/index.js +99 -0
- package/src/cli/packageManager.js +52 -0
- package/src/cli/repl.js +108 -0
- package/src/cli/scaffolder.js +68 -0
- package/src/cli/testRunner.js +99 -0
- package/src/runtime/runner.js +383 -0
- package/src/stdlib/index.js +297 -0
- package/src/stdlib/sandbox.js +32 -0
- package/test_fenrir.sh +435 -0
- package/App/App.axaml +0 -8
- package/App/App.axaml.cs +0 -23
- package/App/FenrirLinux.csproj +0 -27
- package/App/LICENSE +0 -674
- package/App/MainWindow.axaml +0 -10
- package/App/MainWindow.axaml.cs +0 -16
- package/App/Program.cs +0 -19
- package/App/README.md +0 -24
- package/App/Views/InstallationView.axaml +0 -48
- package/App/Views/InstallationView.axaml.cs +0 -204
- package/App/Views/PasswordView.axaml +0 -34
- package/App/Views/PasswordView.axaml.cs +0 -62
- package/App/Views/WelcomeView.axaml +0 -63
- package/App/Views/WelcomeView.axaml.cs +0 -22
- package/App/app.manifest +0 -18
- package/App/images/screenshot1.png +0 -0
- package/App/images/screenshot2.png +0 -0
- package/App/obj/Debug/net9.0/Avalonia/Resources.Inputs.cache +0 -1
- package/App/obj/Debug/net9.0/Avalonia/original.dll +0 -0
- package/App/obj/Debug/net9.0/Avalonia/original.pdb +0 -0
- package/App/obj/Debug/net9.0/Avalonia/original.ref.dll +0 -0
- package/App/obj/Debug/net9.0/Avalonia/references +0 -202
- package/App/obj/Debug/net9.0/Avalonia/resources +0 -0
- package/App/obj/Debug/net9.0/FenrirLi.7B98506C.Up2Date +0 -0
- package/App/obj/Debug/net9.0/FenrirLinux.AssemblyInfo.cs +0 -22
- package/App/obj/Debug/net9.0/FenrirLinux.AssemblyInfoInputs.cache +0 -1
- package/App/obj/Debug/net9.0/FenrirLinux.GeneratedMSBuildEditorConfig.editorconfig +0 -35
- package/App/obj/Debug/net9.0/FenrirLinux.assets.cache +0 -0
- package/App/obj/Debug/net9.0/FenrirLinux.csproj.AssemblyReference.cache +0 -0
- package/App/obj/Debug/net9.0/FenrirLinux.csproj.CoreCompileInputs.cache +0 -1
- package/App/obj/Debug/net9.0/FenrirLinux.csproj.FileListAbsolute.txt +0 -135
- package/App/obj/Debug/net9.0/FenrirLinux.dll +0 -0
- package/App/obj/Debug/net9.0/FenrirLinux.genruntimeconfig.cache +0 -1
- package/App/obj/Debug/net9.0/FenrirLinux.pdb +0 -0
- package/App/obj/Debug/net9.0/apphost +0 -0
- package/App/obj/Debug/net9.0/ref/FenrirLinux.dll +0 -0
- package/App/obj/Debug/net9.0/refint/FenrirLinux.dll +0 -0
- package/App/obj/FenrirLinux.csproj.nuget.dgspec.json +0 -115
- package/App/obj/FenrirLinux.csproj.nuget.g.props +0 -26
- package/App/obj/FenrirLinux.csproj.nuget.g.targets +0 -9
- package/App/obj/Release/net9.0/linux-x64/Avalonia/Resources.Inputs.cache +0 -1
- package/App/obj/Release/net9.0/linux-x64/Avalonia/original.dll +0 -0
- package/App/obj/Release/net9.0/linux-x64/Avalonia/original.pdb +0 -0
- package/App/obj/Release/net9.0/linux-x64/Avalonia/original.ref.dll +0 -0
- package/App/obj/Release/net9.0/linux-x64/Avalonia/references +0 -194
- package/App/obj/Release/net9.0/linux-x64/Avalonia/resources +0 -0
- package/App/obj/Release/net9.0/linux-x64/FenrirLi.7B98506C.Up2Date +0 -0
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.AssemblyInfo.cs +0 -22
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.AssemblyInfoInputs.cache +0 -1
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.GeneratedMSBuildEditorConfig.editorconfig +0 -39
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.assets.cache +0 -0
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.csproj.AssemblyReference.cache +0 -0
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.csproj.CoreCompileInputs.cache +0 -1
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.csproj.FileListAbsolute.txt +0 -238
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.deps.json +0 -1317
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.dll +0 -0
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.genbundle.cache +0 -1
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.genpublishdeps.cache +0 -1
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.genruntimeconfig.cache +0 -1
- package/App/obj/Release/net9.0/linux-x64/FenrirLinux.pdb +0 -0
- package/App/obj/Release/net9.0/linux-x64/PublishOutputs.fac9e24064.txt +0 -4
- package/App/obj/Release/net9.0/linux-x64/apphost +0 -0
- package/App/obj/Release/net9.0/linux-x64/ref/FenrirLinux.dll +0 -0
- package/App/obj/Release/net9.0/linux-x64/refint/FenrirLinux.dll +0 -0
- package/App/obj/Release/net9.0/linux-x64/singlefilehost +0 -0
- package/App/obj/project.assets.json +0 -2463
- package/App/obj/project.nuget.cache +0 -47
- package/LICENSE +0 -674
- package/dist/archiveSystem.js +0 -219
- package/dist/cli.js +0 -188
- package/dist/packageManager.js +0 -98
- package/dist/parser.js +0 -24
- package/dist/runtime.js +0 -99
- package/dist/transformer.js +0 -120
- package/example/fenrir+aperium/aperium.json +0 -17
- package/example/fenrir+aperium/aperium_modules/hello-world/index.js +0 -4
- package/example/fenrir+aperium/aperium_modules/hello-world/module.json +0 -6
- package/example/fenrir+aperium/app.fnr +0 -19
- package/example/fenrir+aperium/package.json +0 -17
- package/src/archiveSystem.ts +0 -264
- package/src/cli.ts +0 -216
- package/src/packageManager.ts +0 -119
- package/src/parser.ts +0 -36
- package/src/runtime.ts +0 -111
- package/src/transformer.ts +0 -147
- package/tsconfig.json +0 -15
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
import crypto from 'crypto';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const transformCache = new Map();
|
|
12
|
+
|
|
13
|
+
function getCacheKey(source) {
|
|
14
|
+
return crypto.createHash('md5').update(source).digest('hex');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function transformFString(line) {
|
|
18
|
+
return line.replace(/f"((?:[^"\\]|\\.)*)"/g, (_, content) => {
|
|
19
|
+
const converted = content.replace(/\{([^}]+)\}/g, '${$1}');
|
|
20
|
+
return '`' + converted + '`';
|
|
21
|
+
}).replace(/f'((?:[^'\\]|\\.)*)'/g, (_, content) => {
|
|
22
|
+
const converted = content.replace(/\{([^}]+)\}/g, '${$1}');
|
|
23
|
+
return '`' + converted + '`';
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function transformPipe(line) {
|
|
28
|
+
if (!line.includes('|>')) return line;
|
|
29
|
+
|
|
30
|
+
// Handle assignment: "const x = a |> b |> c"
|
|
31
|
+
const assignMatch = line.match(/^((?:const|let|var)\s+\w+\s*=\s*)(.+)$/);
|
|
32
|
+
const prefix = assignMatch ? assignMatch[1] : '';
|
|
33
|
+
const expr = assignMatch ? assignMatch[2] : line;
|
|
34
|
+
|
|
35
|
+
if (!expr.includes('|>')) return line;
|
|
36
|
+
|
|
37
|
+
const parts = expr.split('|>').map(s => s.trim());
|
|
38
|
+
let result = parts[0];
|
|
39
|
+
for (let i = 1; i < parts.length; i++) {
|
|
40
|
+
const fn = parts[i];
|
|
41
|
+
if (fn.includes('(')) {
|
|
42
|
+
result = fn.replace(/\(/, `(${result}, `);
|
|
43
|
+
} else {
|
|
44
|
+
result = `${fn}(${result})`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return prefix + result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function transformMatch(lines, startIdx) {
|
|
51
|
+
const matchLine = lines[startIdx].trim();
|
|
52
|
+
const m = matchLine.match(/^match\s+(.+?)\s*\{?\s*$/);
|
|
53
|
+
if (!m) return null;
|
|
54
|
+
const subject = m[1];
|
|
55
|
+
const arms = [];
|
|
56
|
+
let i = startIdx + 1;
|
|
57
|
+
let braceDepth = matchLine.endsWith('{') ? 1 : 0;
|
|
58
|
+
if (!matchLine.endsWith('{') && i < lines.length && lines[i].trim() === '{') {
|
|
59
|
+
i++;
|
|
60
|
+
braceDepth = 1;
|
|
61
|
+
}
|
|
62
|
+
while (i < lines.length && braceDepth > 0) {
|
|
63
|
+
const l = lines[i].trim();
|
|
64
|
+
if (l === '}') { braceDepth--; i++; continue; }
|
|
65
|
+
const arm = l.match(/^(.+?)\s*=>\s*(.+)$/);
|
|
66
|
+
if (arm) {
|
|
67
|
+
arms.push({ pattern: arm[1].trim(), body: arm[2].trim() });
|
|
68
|
+
}
|
|
69
|
+
i++;
|
|
70
|
+
}
|
|
71
|
+
const cases = arms.map(({ pattern, body }) => {
|
|
72
|
+
if (pattern === '_') return ` default: { ${body}; break; }`;
|
|
73
|
+
if (/^-?\d+$/.test(pattern) || pattern.startsWith('"') || pattern.startsWith("'")) {
|
|
74
|
+
return ` case ${pattern}: { ${body}; break; }`;
|
|
75
|
+
}
|
|
76
|
+
return ` case ${pattern}: { ${body}; break; }`;
|
|
77
|
+
});
|
|
78
|
+
const switchCode = `switch (${subject}) {\n${cases.join('\n')}\n}`;
|
|
79
|
+
return { code: switchCode, nextIdx: i };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function precompileLocal(fnrPath, dir) {
|
|
83
|
+
const hash = crypto.createHash('md5').update(fnrPath).digest('hex').slice(0, 8);
|
|
84
|
+
const outFile = path.join(dir, `dep_${hash}.mjs`);
|
|
85
|
+
if (fs.existsSync(outFile)) return outFile;
|
|
86
|
+
const src = fs.readFileSync(fnrPath, 'utf8');
|
|
87
|
+
const compiled = transform(src, fnrPath, dir);
|
|
88
|
+
const stdlibPath = path.join(__dirname, '..', 'stdlib', 'index.js');
|
|
89
|
+
const inject = fs.existsSync(stdlibPath)
|
|
90
|
+
? `import { injectGlobals } from "file://${stdlibPath}";\ninjectGlobals();\n`
|
|
91
|
+
: '';
|
|
92
|
+
fs.writeFileSync(outFile, inject + '\n' + compiled, 'utf8');
|
|
93
|
+
return outFile;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function transform(source, filePath, precompileDir = null) {
|
|
97
|
+
const cacheKey = getCacheKey(source) + (precompileDir || '');
|
|
98
|
+
if (transformCache.has(cacheKey)) return transformCache.get(cacheKey);
|
|
99
|
+
|
|
100
|
+
const lines = source.split('\n');
|
|
101
|
+
const out = [];
|
|
102
|
+
let i = 0;
|
|
103
|
+
|
|
104
|
+
while (i < lines.length) {
|
|
105
|
+
let raw = lines[i];
|
|
106
|
+
const line = raw.trim();
|
|
107
|
+
i++;
|
|
108
|
+
|
|
109
|
+
if (!line) { out.push(''); continue; }
|
|
110
|
+
if (line.startsWith('//') || line.startsWith('/*') || line.startsWith('*')) { out.push(raw); continue; }
|
|
111
|
+
|
|
112
|
+
if (line.startsWith('use ') && line.includes(' from ')) {
|
|
113
|
+
const m = line.match(/^use\s+(.*?)\s+from\s+(['"])(.*?)\2\s*;?$/);
|
|
114
|
+
if (m) {
|
|
115
|
+
const [, spec,, mod] = m;
|
|
116
|
+
const isLocal = /^\.\.\//.test(mod) || /^\.\//.test(mod) || mod.startsWith('/');
|
|
117
|
+
if (isLocal) {
|
|
118
|
+
const absPath = path.resolve(path.dirname(filePath), mod);
|
|
119
|
+
if (absPath.endsWith('.fnr') && precompileDir) {
|
|
120
|
+
const compiled = precompileLocal(absPath, precompileDir);
|
|
121
|
+
out.push(`import ${spec} from "file://${compiled}";`);
|
|
122
|
+
} else {
|
|
123
|
+
out.push(`import ${spec} from "file://${absPath}";`);
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
out.push(`import ${spec} from "${mod}";`);
|
|
127
|
+
}
|
|
128
|
+
} else { out.push(raw); }
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (line.startsWith('match ')) {
|
|
133
|
+
const result = transformMatch(lines, i - 1);
|
|
134
|
+
if (result) {
|
|
135
|
+
out.push(result.code);
|
|
136
|
+
i = result.nextIdx;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (line.startsWith('async fn ') || line.startsWith('fn ')) {
|
|
142
|
+
out.push(sh(raw).replace(/\basync fn\s+/, 'async function ').replace(/\bfn\s+/, 'function '));
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (line.startsWith('type ') && line.includes('=')) continue;
|
|
147
|
+
if (isJs(line)) { out.push(sh(transformFString(transformPipe(raw)))); continue; }
|
|
148
|
+
|
|
149
|
+
if (!bal(line)) {
|
|
150
|
+
let full = raw;
|
|
151
|
+
while (i < lines.length && !bal(full)) { full += '\n' + lines[i]; i++; }
|
|
152
|
+
const s = sh(transformFString(transformPipe(full)));
|
|
153
|
+
out.push(s + (semi(s.trim()) ? ';' : ''));
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const s = sh(transformFString(transformPipe(raw)));
|
|
158
|
+
out.push(s.trim() + (semi(s.trim()) ? ';' : ''));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const result = out.join('\n');
|
|
162
|
+
transformCache.set(cacheKey, result);
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const sh = c => c
|
|
167
|
+
.replace(/\blog\(/g, 'console.log(')
|
|
168
|
+
.replace(/\berr\(/g, 'console.error(')
|
|
169
|
+
.replace(/\bwarn\(/g, 'console.warn(')
|
|
170
|
+
.replace(/\binfo\(/g, 'console.info(')
|
|
171
|
+
.replace(/\basync fn\b/g, 'async function')
|
|
172
|
+
.replace(/\bfn\b/g, 'function');
|
|
173
|
+
|
|
174
|
+
function ch(s, c) { let n=0,inS=false,sC=''; for(let j=0;j<s.length;j++){const x=s[j];if(inS){if(x==='\\'){j++;continue}if(x===sC)inS=false;continue}if(x==='"'||x==="'"){inS=true;sC=x;continue}if(x===c)n++}return n; }
|
|
175
|
+
const bal = s => ch(s,'(')=== ch(s,')')&& ch(s,'[')=== ch(s,']')&& ch(s,'{')=== ch(s,'}');
|
|
176
|
+
|
|
177
|
+
function isJs(l) {
|
|
178
|
+
return l.startsWith('import ')||l.startsWith('export ')||l.startsWith('class ')||
|
|
179
|
+
l.startsWith('function ')||l.startsWith('async function ')||
|
|
180
|
+
l.startsWith('if ')||l.startsWith('if(')||l.startsWith('else')||l.startsWith('} else')||
|
|
181
|
+
l.startsWith('for ')||l.startsWith('for(')||l.startsWith('while ')||l.startsWith('while(')||
|
|
182
|
+
l.startsWith('switch ')||l.startsWith('switch(')||l.startsWith('try')||
|
|
183
|
+
l.startsWith('catch')||l.startsWith('finally')||l.startsWith('return')||
|
|
184
|
+
l.startsWith('throw ')||l.startsWith('case ')||l.startsWith('default:')||
|
|
185
|
+
/^}\s*(else|catch|finally)/.test(l)||l==='break'||l==='continue';
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function semi(l) {
|
|
189
|
+
if(!l) return false;
|
|
190
|
+
if(l.endsWith(';')||l.endsWith('{')||l.endsWith('}')||l.endsWith(',')||l.endsWith('[')||l.endsWith('(')) return false;
|
|
191
|
+
if(isJs(l)) return false;
|
|
192
|
+
if(l.endsWith(')')&&!(l.includes('=')||l.includes('console.')||/^[a-zA-Z_$][\w$.]*\s*\(/.test(l)||/^(await|return)\s/.test(l))) return false;
|
|
193
|
+
return l.includes('=')||l.includes('console.')||
|
|
194
|
+
l.startsWith('const ')||l.startsWith('let ')||l.startsWith('var ')||
|
|
195
|
+
l.startsWith('throw ')||l.startsWith('return')||l.startsWith('import ')||
|
|
196
|
+
/^[a-zA-Z_$][\w$.]*\s*[\(`[]/.test(l)||/^(await|yield)\s/.test(l)||
|
|
197
|
+
/^\w+\s*(\+\+|--)/.test(l)||/^\w+\s*[+\-*/&|^]=/.test(l);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export async function runFile(filePath, debug=false, sandbox=false) {
|
|
201
|
+
if (!fs.existsSync(filePath)) { console.error(`\x1b[31m✘ File not found: ${filePath}\x1b[0m`); process.exit(1); }
|
|
202
|
+
|
|
203
|
+
const source = fs.readFileSync(filePath, 'utf8');
|
|
204
|
+
if (!source.trim()) { console.error('\x1b[31m✘ File is empty.\x1b[0m'); process.exit(1); }
|
|
205
|
+
|
|
206
|
+
const tempDir = path.join(os.tmpdir(), `fenrir_${Date.now()}`);
|
|
207
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
208
|
+
|
|
209
|
+
const userCode = transform(source, filePath, tempDir);
|
|
210
|
+
const stdlibPath = path.join(__dirname, '..', 'stdlib', 'index.js');
|
|
211
|
+
const sandboxPath = path.join(__dirname, '..', 'stdlib', 'sandbox.js');
|
|
212
|
+
|
|
213
|
+
let inject = '';
|
|
214
|
+
if (sandbox && fs.existsSync(sandboxPath)) {
|
|
215
|
+
inject = `import { injectGlobals } from "file://${sandboxPath}";\ninjectGlobals();\n`;
|
|
216
|
+
} else if (fs.existsSync(stdlibPath)) {
|
|
217
|
+
inject = `import { injectGlobals } from "file://${stdlibPath}";\ninjectGlobals();\n`;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const final = `${inject}\n${userCode}`;
|
|
221
|
+
if (debug) console.log('\x1b[90m[debug]\x1b[0m\n' + final);
|
|
222
|
+
|
|
223
|
+
const tempFile = path.join(tempDir, 'run.mjs');
|
|
224
|
+
fs.writeFileSync(tempFile, final);
|
|
225
|
+
|
|
226
|
+
const root = process.cwd();
|
|
227
|
+
const cwdMods = path.join(root, 'node_modules');
|
|
228
|
+
const tempMods = path.join(tempDir, 'node_modules');
|
|
229
|
+
if (fs.existsSync(cwdMods)) try { cpDir(cwdMods, tempMods); } catch {}
|
|
230
|
+
const pkg = path.join(root, 'package.json');
|
|
231
|
+
if (fs.existsSync(pkg)) try { fs.copyFileSync(pkg, path.join(tempDir,'package.json')); } catch {}
|
|
232
|
+
|
|
233
|
+
const env = { ...process.env,
|
|
234
|
+
NODE_PATH: [tempMods, cwdMods, process.env.NODE_PATH].filter(Boolean).join(path.delimiter),
|
|
235
|
+
...(sandbox ? { FENRIR_SANDBOX: '1' } : {})
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const child = spawn('node', [tempFile], { stdio:'inherit', env, cwd:root });
|
|
239
|
+
child.on('close', code => { del(tempDir); process.exit(code??0); });
|
|
240
|
+
child.on('error', e => { console.error(`\x1b[31m✘ ${e.message}\x1b[0m`); del(tempDir); process.exit(1); });
|
|
241
|
+
process.on('SIGINT', () => { del(tempDir); process.exit(130); });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export async function watchFile(filePath, debug=false) {
|
|
245
|
+
const { default: chokidar } = await import('chokidar');
|
|
246
|
+
console.log(`\x1b[36m👁 Watching: ${filePath}\x1b[0m`);
|
|
247
|
+
let child = null;
|
|
248
|
+
|
|
249
|
+
const run = () => {
|
|
250
|
+
if (child) { try { child.kill(); } catch {} }
|
|
251
|
+
console.log('\x1b[90m─────────────────────────────\x1b[0m');
|
|
252
|
+
console.log(`\x1b[36m▶ Running ${path.basename(filePath)}\x1b[0m`);
|
|
253
|
+
const source = fs.readFileSync(filePath, 'utf8');
|
|
254
|
+
const tempDir = path.join(os.tmpdir(), `fenrir_watch_${Date.now()}`);
|
|
255
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
256
|
+
const userCode = transform(source, filePath, tempDir);
|
|
257
|
+
const stdlibPath = path.join(__dirname, '..', 'stdlib', 'index.js');
|
|
258
|
+
const inject = fs.existsSync(stdlibPath)
|
|
259
|
+
? `import { injectGlobals } from "file://${stdlibPath}";\ninjectGlobals();\n`
|
|
260
|
+
: '';
|
|
261
|
+
const final = `${inject}\n${userCode}`;
|
|
262
|
+
const tempFile = path.join(tempDir, 'run.mjs');
|
|
263
|
+
fs.writeFileSync(tempFile, final);
|
|
264
|
+
const root = process.cwd();
|
|
265
|
+
const cwdMods = path.join(root, 'node_modules');
|
|
266
|
+
const tempMods = path.join(tempDir, 'node_modules');
|
|
267
|
+
if (fs.existsSync(cwdMods)) try { cpDir(cwdMods, tempMods); } catch {}
|
|
268
|
+
const pkg = path.join(root, 'package.json');
|
|
269
|
+
if (fs.existsSync(pkg)) try { fs.copyFileSync(pkg, path.join(tempDir, 'package.json')); } catch {}
|
|
270
|
+
const env = { ...process.env, NODE_PATH: [tempMods, cwdMods, process.env.NODE_PATH].filter(Boolean).join(path.delimiter) };
|
|
271
|
+
child = spawn('node', [tempFile], { stdio: 'inherit', env, cwd: root });
|
|
272
|
+
child.on('close', code => {
|
|
273
|
+
del(tempDir);
|
|
274
|
+
console.log(`\x1b[90m[exited: ${code}]\x1b[0m`);
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
run();
|
|
279
|
+
chokidar.watch(filePath, { ignoreInitial: true }).on('change', () => {
|
|
280
|
+
console.log(`\x1b[33m⟳ Changed, restarting...\x1b[0m`);
|
|
281
|
+
run();
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function formatFile(filePath) {
|
|
286
|
+
const source = fs.readFileSync(filePath, 'utf8');
|
|
287
|
+
const lines = source.split('\n');
|
|
288
|
+
const out = [];
|
|
289
|
+
let indent = 0;
|
|
290
|
+
const TAB = ' ';
|
|
291
|
+
|
|
292
|
+
for (const raw of lines) {
|
|
293
|
+
const line = raw.trim();
|
|
294
|
+
if (!line) { out.push(''); continue; }
|
|
295
|
+
|
|
296
|
+
const closes = (line.match(/^[}\])]/) || []).length;
|
|
297
|
+
if (closes) indent = Math.max(0, indent - closes);
|
|
298
|
+
|
|
299
|
+
out.push(TAB.repeat(indent) + line);
|
|
300
|
+
|
|
301
|
+
const opens = (line.match(/[{[(]$/) || []).length;
|
|
302
|
+
const closeInline = (line.match(/[}\])]$/) && !line.match(/^[}\]]/) || []).length;
|
|
303
|
+
if (opens && !closeInline) indent++;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const formatted = out.join('\n');
|
|
307
|
+
fs.writeFileSync(filePath, formatted, 'utf8');
|
|
308
|
+
console.log(`\x1b[32m✓ Formatted: ${filePath}\x1b[0m`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function lintFile(filePath) {
|
|
312
|
+
const source = fs.readFileSync(filePath, 'utf8');
|
|
313
|
+
const lines = source.split('\n');
|
|
314
|
+
const issues = [];
|
|
315
|
+
|
|
316
|
+
lines.forEach((raw, idx) => {
|
|
317
|
+
const line = raw.trim();
|
|
318
|
+
const ln = idx + 1;
|
|
319
|
+
if (line.length > 120) issues.push({ ln, msg: `Line too long (${line.length} chars)` });
|
|
320
|
+
if (/\bconsole\.log\b/.test(line)) issues.push({ ln, msg: 'Use print() instead of console.log()' });
|
|
321
|
+
if (/var\s+/.test(line) && !line.startsWith('//')) issues.push({ ln, msg: 'Prefer const/let over var' });
|
|
322
|
+
if (/==(?!=)/.test(line) && !line.startsWith('//')) issues.push({ ln, msg: 'Use === instead of ==' });
|
|
323
|
+
if (/!=(?!=)/.test(line) && !line.startsWith('//')) issues.push({ ln, msg: 'Use !== instead of !=' });
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
if (!issues.length) {
|
|
327
|
+
console.log(`\x1b[32m✓ No issues found in ${filePath}\x1b[0m`);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
console.log(`\x1b[33m⚠ ${issues.length} issue(s) in ${filePath}:\x1b[0m`);
|
|
331
|
+
for (const { ln, msg } of issues) {
|
|
332
|
+
console.log(` \x1b[90mline ${ln}:\x1b[0m ${msg}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function bundleFile(entryPath, outPath) {
|
|
337
|
+
const visited = new Set();
|
|
338
|
+
const chunks = [];
|
|
339
|
+
|
|
340
|
+
function collect(fp) {
|
|
341
|
+
const abs = path.resolve(fp);
|
|
342
|
+
if (visited.has(abs)) return;
|
|
343
|
+
visited.add(abs);
|
|
344
|
+
const src = fs.readFileSync(abs, 'utf8');
|
|
345
|
+
const lines = src.split('\n');
|
|
346
|
+
const out = [];
|
|
347
|
+
for (const line of lines) {
|
|
348
|
+
const m = line.trim().match(/^(?:use|import)\s+.*?\s+from\s+['"](\..+?)['"]/);
|
|
349
|
+
if (m) {
|
|
350
|
+
const dep = path.resolve(path.dirname(abs), m[1]);
|
|
351
|
+
const candidates = [dep, dep + '.js', dep + '.fnr', dep + '/index.js'];
|
|
352
|
+
for (const c of candidates) {
|
|
353
|
+
if (fs.existsSync(c)) { collect(c); break; }
|
|
354
|
+
}
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
out.push(line);
|
|
358
|
+
}
|
|
359
|
+
chunks.push(`\n// === ${path.relative(process.cwd(), abs)} ===\n` + out.join('\n'));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
collect(entryPath);
|
|
363
|
+
const stdlibPath = path.join(__dirname, '..', 'stdlib', 'index.js');
|
|
364
|
+
const inject = fs.existsSync(stdlibPath)
|
|
365
|
+
? `import { injectGlobals } from "file://${stdlibPath}";\ninjectGlobals();\n`
|
|
366
|
+
: '';
|
|
367
|
+
const bundle = inject + chunks.join('\n');
|
|
368
|
+
const dest = outPath || entryPath.replace(/\.(fnr|js)$/, '.bundle.mjs');
|
|
369
|
+
fs.writeFileSync(dest, bundle, 'utf8');
|
|
370
|
+
console.log(`\x1b[32m✓ Bundled → ${dest}\x1b[0m`);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const del = dir => { try { fs.rmSync(dir,{recursive:true,force:true}); } catch {} };
|
|
374
|
+
|
|
375
|
+
function cpDir(src, dest) {
|
|
376
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
377
|
+
for (const e of fs.readdirSync(src, { withFileTypes: true })) {
|
|
378
|
+
const s = path.join(src, e.name), d = path.join(dest, e.name);
|
|
379
|
+
if (e.isSymbolicLink()) try { cpDir(fs.realpathSync(s),d); } catch {}
|
|
380
|
+
else if (e.isDirectory()) cpDir(s,d);
|
|
381
|
+
else try { fs.copyFileSync(s,d); } catch {}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import http from 'http';
|
|
4
|
+
import { execSync, spawn as nodeSpawn } from 'child_process';
|
|
5
|
+
import { createInterface } from 'readline';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const fmt = v => v===null?'null':v===undefined?'undefined':typeof v==='object'?JSON.stringify(v,null,2):String(v);
|
|
12
|
+
|
|
13
|
+
export const print = (...a) => { process.stdout.write(a.map(fmt).join(' ')+'\n'); };
|
|
14
|
+
export const log = print;
|
|
15
|
+
export const err = (...a) => { process.stderr.write(a.map(fmt).join(' ')+'\n'); };
|
|
16
|
+
export const warn = (...a) => { process.stderr.write('\x1b[33m'+a.map(fmt).join(' ')+'\x1b[0m\n'); };
|
|
17
|
+
export const info = (...a) => { process.stdout.write('\x1b[36m'+a.map(fmt).join(' ')+'\x1b[0m\n'); };
|
|
18
|
+
|
|
19
|
+
export const prompt = q => new Promise(r => {
|
|
20
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
21
|
+
rl.question(q, a => { rl.close(); r(a); });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const readFile = p => fs.readFileSync(path.resolve(p), 'utf8');
|
|
25
|
+
export const writeFile = (p,c) => { fs.writeFileSync(path.resolve(p), c, 'utf8'); };
|
|
26
|
+
export const appendFile = (p,c) => { fs.appendFileSync(path.resolve(p), c, 'utf8'); };
|
|
27
|
+
export const fileExists = p => fs.existsSync(path.resolve(p));
|
|
28
|
+
export const readDir = p => fs.readdirSync(path.resolve(p));
|
|
29
|
+
export const readJSON = p => JSON.parse(readFile(p));
|
|
30
|
+
export const writeJSON = (p,d) => writeFile(p, JSON.stringify(d,null,2));
|
|
31
|
+
export const mkdir = p => { fs.mkdirSync(path.resolve(p), { recursive: true }); };
|
|
32
|
+
export const rm = p => { fs.rmSync(path.resolve(p), { recursive: true, force: true }); };
|
|
33
|
+
|
|
34
|
+
export const get = async (url, headers) => { const r=await fetch(url,{headers}); const t=await r.text(); try{return JSON.parse(t)}catch{return t}};
|
|
35
|
+
export const post = async (url, body, headers) => { const r=await fetch(url,{method:'POST',headers:{'Content-Type':'application/json',...headers},body:JSON.stringify(body)}); const t=await r.text(); try{return JSON.parse(t)}catch{return t}};
|
|
36
|
+
|
|
37
|
+
export const exec = cmd => execSync(cmd, { encoding:'utf8', stdio:['pipe','pipe','pipe'] }).trim();
|
|
38
|
+
export const run = cmd => { execSync(cmd, { stdio:'inherit' }); };
|
|
39
|
+
export const spawn = (cmd, args=[]) => new Promise((res,rej) => {
|
|
40
|
+
const c = nodeSpawn(cmd, args, { stdio:'inherit' });
|
|
41
|
+
c.on('close', res); c.on('error', rej);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const env = (k, fb='') => process.env[k] ?? fb;
|
|
45
|
+
export const args = () => process.argv.slice(2);
|
|
46
|
+
export const exit = (c=0) => process.exit(c);
|
|
47
|
+
export const cwd = () => process.cwd();
|
|
48
|
+
|
|
49
|
+
export const now = () => Date.now();
|
|
50
|
+
export const time = () => new Date().toISOString();
|
|
51
|
+
export const sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
52
|
+
export const bench = async (label, fn) => { const s=performance.now(); await fn(); info(`[bench] ${label}: ${(performance.now()-s).toFixed(2)}ms`); };
|
|
53
|
+
|
|
54
|
+
export const range = (start, end, step=1) => { if(end===undefined){end=start;start=0;} const r=[];for(let i=start;i<end;i+=step)r.push(i);return r; };
|
|
55
|
+
export const rand = (min=0,max=1) => Math.random()*(max-min)+min;
|
|
56
|
+
export const randInt = (min,max) => Math.floor(rand(min,max+1));
|
|
57
|
+
export const pick = arr => arr[randInt(0,arr.length-1)];
|
|
58
|
+
export const shuffle = arr => { const a=[...arr]; for(let i=a.length-1;i>0;i--){const j=randInt(0,i);[a[i],a[j]]=[a[j],a[i]];} return a; };
|
|
59
|
+
export const chunk = (arr,n) => { const r=[];for(let i=0;i<arr.length;i+=n)r.push(arr.slice(i,i+n));return r; };
|
|
60
|
+
export const unique = arr => [...new Set(arr)];
|
|
61
|
+
export const flatten = arr => arr.flat(Infinity);
|
|
62
|
+
export const sum = arr => arr.reduce((a,b)=>a+b,0);
|
|
63
|
+
export const avg = arr => sum(arr)/arr.length;
|
|
64
|
+
export const min = (...a) => Math.min(...(Array.isArray(a[0])?a[0]:a));
|
|
65
|
+
export const max = (...a) => Math.max(...(Array.isArray(a[0])?a[0]:a));
|
|
66
|
+
export const clamp = (n,lo,hi) => Math.max(lo,Math.min(hi,n));
|
|
67
|
+
|
|
68
|
+
export const capitalize = s => s.charAt(0).toUpperCase()+s.slice(1);
|
|
69
|
+
export const truncate = (s,n,suf='...') => s.length>n?s.slice(0,n)+suf:s;
|
|
70
|
+
export const pad = (s,n,c=' ') => String(s).padStart(n,c);
|
|
71
|
+
export const repeat = (s,n) => s.repeat(n);
|
|
72
|
+
|
|
73
|
+
export const keys = o => Object.keys(o);
|
|
74
|
+
export const values = o => Object.values(o);
|
|
75
|
+
export const entries = o => Object.entries(o);
|
|
76
|
+
export const merge = (...os) => Object.assign({},...os);
|
|
77
|
+
export const clone = v => JSON.parse(JSON.stringify(v));
|
|
78
|
+
|
|
79
|
+
export const all = ps => Promise.all(ps);
|
|
80
|
+
export const race = ps => Promise.race(ps);
|
|
81
|
+
export const retry = async (fn,times=3,delay=500) => { for(let i=0;i<times;i++){try{return await fn()}catch(e){if(i===times-1)throw e;await sleep(delay);}} };
|
|
82
|
+
|
|
83
|
+
export const isString = v => typeof v==='string';
|
|
84
|
+
export const isNumber = v => typeof v==='number';
|
|
85
|
+
export const isBool = v => typeof v==='boolean';
|
|
86
|
+
export const isArray = v => Array.isArray(v);
|
|
87
|
+
export const isObject = v => v!==null&&typeof v==='object'&&!Array.isArray(v);
|
|
88
|
+
export const isNull = v => v===null;
|
|
89
|
+
export const isDefined= v => v!==undefined&&v!==null;
|
|
90
|
+
|
|
91
|
+
export const { abs,ceil,floor,round,sqrt,pow,PI,E,log2,log10,sin,cos,tan } = Math;
|
|
92
|
+
|
|
93
|
+
export function serve(port, handler) {
|
|
94
|
+
const server = http.createServer(async (req, res) => {
|
|
95
|
+
let body = '';
|
|
96
|
+
req.on('data', d => body += d);
|
|
97
|
+
req.on('end', async () => {
|
|
98
|
+
const request = {
|
|
99
|
+
method: req.method,
|
|
100
|
+
url: req.url,
|
|
101
|
+
headers: req.headers,
|
|
102
|
+
body: body ? ((() => { try { return JSON.parse(body); } catch { return body; } })()) : null,
|
|
103
|
+
params: Object.fromEntries(new URL(req.url, `http://localhost`).searchParams),
|
|
104
|
+
};
|
|
105
|
+
try {
|
|
106
|
+
const result = await handler(request);
|
|
107
|
+
if (typeof result === 'string') {
|
|
108
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
109
|
+
res.end(result);
|
|
110
|
+
} else if (result && typeof result === 'object') {
|
|
111
|
+
if (result.__raw) {
|
|
112
|
+
res.writeHead(result.status || 200, result.headers || {});
|
|
113
|
+
res.end(result.body ?? '');
|
|
114
|
+
} else {
|
|
115
|
+
res.writeHead(result.status || 200, { 'Content-Type': 'application/json', ...(result.headers||{}) });
|
|
116
|
+
res.end(JSON.stringify(result.body ?? result));
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
res.writeHead(200); res.end(String(result ?? ''));
|
|
120
|
+
}
|
|
121
|
+
} catch(e) {
|
|
122
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
123
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
server.listen(port, () => info(`[serve] Listening on http://localhost:${port}`));
|
|
128
|
+
return server;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function response(body, status=200, headers={}) {
|
|
132
|
+
return { __raw: true, body: typeof body === 'object' ? JSON.stringify(body) : body, status, headers: { 'Content-Type': typeof body === 'object' ? 'application/json' : 'text/plain', ...headers } };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function openDb(dbPath) {
|
|
136
|
+
let initSqlJs;
|
|
137
|
+
try {
|
|
138
|
+
const m = await import('sql.js');
|
|
139
|
+
initSqlJs = m.default;
|
|
140
|
+
} catch {
|
|
141
|
+
throw new Error('sql.js not found. Run: fenrir install sql.js');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const SQL = await initSqlJs();
|
|
145
|
+
const absPath = dbPath && dbPath !== ':memory:' ? path.resolve(dbPath) : null;
|
|
146
|
+
const db = absPath && fs.existsSync(absPath)
|
|
147
|
+
? new SQL.Database(fs.readFileSync(absPath))
|
|
148
|
+
: new SQL.Database();
|
|
149
|
+
|
|
150
|
+
const save = () => {
|
|
151
|
+
if (absPath) fs.writeFileSync(absPath, Buffer.from(db.export()));
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
query(sql, ...params) {
|
|
156
|
+
if (/^\s*(select|pragma)/i.test(sql)) {
|
|
157
|
+
const stmt = db.prepare(sql);
|
|
158
|
+
stmt.bind(params);
|
|
159
|
+
const rows = [];
|
|
160
|
+
while (stmt.step()) rows.push(stmt.getAsObject());
|
|
161
|
+
stmt.free();
|
|
162
|
+
return rows;
|
|
163
|
+
}
|
|
164
|
+
db.run(sql, params);
|
|
165
|
+
save();
|
|
166
|
+
return { changes: db.getRowsModified() };
|
|
167
|
+
},
|
|
168
|
+
run(sql, ...params) { db.run(sql, params); save(); return { changes: db.getRowsModified() }; },
|
|
169
|
+
get(sql, ...params) {
|
|
170
|
+
const stmt = db.prepare(sql);
|
|
171
|
+
stmt.bind(params);
|
|
172
|
+
const row = stmt.step() ? stmt.getAsObject() : null;
|
|
173
|
+
stmt.free();
|
|
174
|
+
return row;
|
|
175
|
+
},
|
|
176
|
+
all(sql, ...params) {
|
|
177
|
+
const stmt = db.prepare(sql);
|
|
178
|
+
stmt.bind(params);
|
|
179
|
+
const rows = [];
|
|
180
|
+
while (stmt.step()) rows.push(stmt.getAsObject());
|
|
181
|
+
stmt.free();
|
|
182
|
+
return rows;
|
|
183
|
+
},
|
|
184
|
+
exec(sql) { db.run(sql); save(); },
|
|
185
|
+
close() { save(); db.close(); },
|
|
186
|
+
transaction(fn) {
|
|
187
|
+
db.run('BEGIN');
|
|
188
|
+
try { fn(); db.run('COMMIT'); save(); }
|
|
189
|
+
catch(e) { db.run('ROLLBACK'); throw e; }
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export async function parse(input, typeHint) {
|
|
195
|
+
const str = typeof input === 'string' && fs.existsSync(input)
|
|
196
|
+
? fs.readFileSync(input, 'utf8')
|
|
197
|
+
: String(input);
|
|
198
|
+
|
|
199
|
+
const ext = typeof input === 'string' ? path.extname(input).toLowerCase() : '';
|
|
200
|
+
const hint = typeHint || ext;
|
|
201
|
+
|
|
202
|
+
if (hint === '.csv' || hint === 'csv') return parseCsv(str);
|
|
203
|
+
if (hint === '.toml' || hint === 'toml') {
|
|
204
|
+
try { const { default: toml } = await import('toml'); return toml.parse(str); } catch { throw new Error('toml not found. Run: fenrir install toml'); }
|
|
205
|
+
}
|
|
206
|
+
if (hint === '.yaml' || hint === '.yml' || hint === 'yaml') {
|
|
207
|
+
try { const { default: yaml } = await import('js-yaml'); return yaml.load(str); } catch { throw new Error('js-yaml not found. Run: fenrir install js-yaml'); }
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
try { return JSON.parse(str); } catch {}
|
|
211
|
+
try {
|
|
212
|
+
const { default: yaml } = await import('js-yaml');
|
|
213
|
+
return yaml.load(str);
|
|
214
|
+
} catch {}
|
|
215
|
+
if (str.includes(',')) return parseCsv(str);
|
|
216
|
+
return str;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function parseCsv(str) {
|
|
220
|
+
const lines = str.trim().split('\n');
|
|
221
|
+
if (!lines.length) return [];
|
|
222
|
+
const headers = lines[0].split(',').map(h => h.trim().replace(/^"|"$/g, ''));
|
|
223
|
+
return lines.slice(1).map(line => {
|
|
224
|
+
const vals = line.split(',').map(v => v.trim().replace(/^"|"$/g, ''));
|
|
225
|
+
return Object.fromEntries(headers.map((h, i) => [h, vals[i] ?? '']));
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function cache(ttlMs = 60000) {
|
|
230
|
+
const store = new Map();
|
|
231
|
+
return {
|
|
232
|
+
get: key => {
|
|
233
|
+
const entry = store.get(key);
|
|
234
|
+
if (!entry) return undefined;
|
|
235
|
+
if (Date.now() > entry.expires) { store.delete(key); return undefined; }
|
|
236
|
+
return entry.value;
|
|
237
|
+
},
|
|
238
|
+
set: (key, value, customTtl) => {
|
|
239
|
+
store.set(key, { value, expires: Date.now() + (customTtl ?? ttlMs) });
|
|
240
|
+
},
|
|
241
|
+
has: key => {
|
|
242
|
+
const entry = store.get(key);
|
|
243
|
+
if (!entry) return false;
|
|
244
|
+
if (Date.now() > entry.expires) { store.delete(key); return false; }
|
|
245
|
+
return true;
|
|
246
|
+
},
|
|
247
|
+
del: key => store.delete(key),
|
|
248
|
+
clear: () => store.clear(),
|
|
249
|
+
size: () => store.size,
|
|
250
|
+
wrap: async (key, fn, customTtl) => {
|
|
251
|
+
const cached = store.get(key);
|
|
252
|
+
if (cached && Date.now() <= cached.expires) return cached.value;
|
|
253
|
+
const value = await fn();
|
|
254
|
+
store.set(key, { value, expires: Date.now() + (customTtl ?? ttlMs) });
|
|
255
|
+
return value;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function pipe(...fns) {
|
|
261
|
+
return async (input) => {
|
|
262
|
+
let result = input;
|
|
263
|
+
for (const fn of fns) result = await fn(result);
|
|
264
|
+
return result;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function assert(condition, message = 'Assertion failed') {
|
|
269
|
+
if (!condition) throw new Error(`\x1b[31m✘ Assert: ${message}\x1b[0m`);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function assertEqual(a, b, message) {
|
|
273
|
+
const pass = JSON.stringify(a) === JSON.stringify(b);
|
|
274
|
+
if (!pass) throw new Error(`\x1b[31m✘ Assert equal failed${message ? ': ' + message : ''}\n expected: ${JSON.stringify(b)}\n got: ${JSON.stringify(a)}\x1b[0m`);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function assertThrows(fn, message) {
|
|
278
|
+
try { fn(); throw new Error(`\x1b[31m✘ Expected throw${message ? ': ' + message : ''}\x1b[0m`); }
|
|
279
|
+
catch(e) { if (e.message.startsWith('\x1b[31m✘ Expected')) throw e; }
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function injectGlobals() {
|
|
283
|
+
Object.assign(globalThis, {
|
|
284
|
+
print,log,err,warn,info,prompt,
|
|
285
|
+
readFile,writeFile,appendFile,fileExists,readDir,readJSON,writeJSON,mkdir,rm,
|
|
286
|
+
get,post,exec,run,spawn,env,args,exit,cwd,
|
|
287
|
+
now,time,sleep,bench,
|
|
288
|
+
range,rand,randInt,pick,shuffle,chunk,unique,flatten,sum,avg,min,max,clamp,
|
|
289
|
+
capitalize,truncate,pad,repeat,
|
|
290
|
+
keys,values,entries,merge,clone,
|
|
291
|
+
all,race,retry,
|
|
292
|
+
isString,isNumber,isBool,isArray,isObject,isNull,isDefined,
|
|
293
|
+
abs,ceil,floor,round,sqrt,pow,PI,E,log2,log10,sin,cos,tan,
|
|
294
|
+
serve,response,openDb,parse,cache,pipe,
|
|
295
|
+
assert,assertEqual,assertThrows,
|
|
296
|
+
});
|
|
297
|
+
}
|