diff --git a/docs/changelog.md b/docs/changelog.md index c87f44c5c7..9ea3c989b3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -8,6 +8,7 @@ Change Log * Fix: Preserve nullability in `KSType.toClassName()`. (#1956) * New: Add `KSTypeAlias.toClassName()`. (#1956) * New: Add `KSType.toClassNameOrNull()`. (#1956) +* New: Make the kotlinpoet module multi-platform and add source set configuration for the JS and wasmJs platforms. (#1959) ## Version 1.18.1 diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock new file mode 100644 index 0000000000..0c5f9df6f4 --- /dev/null +++ b/kotlin-js-store/yarn.lock @@ -0,0 +1,2010 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@colors/colors@1.5.0": + version "1.5.0" + resolved "https://registry.npmmirror.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" + integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== + +"@discoveryjs/json-ext@^0.5.0": + version "0.5.7" + resolved "https://registry.npmmirror.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" + integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== + +"@jridgewell/gen-mapping@^0.3.5": + version "0.3.5" + resolved "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz#dcce6aff74bdf6dad1a95802b69b04a2fcb1fb36" + integrity sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg== + dependencies: + "@jridgewell/set-array" "^1.2.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.24" + +"@jridgewell/resolve-uri@^3.1.0": + version "3.1.2" + resolved "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" + integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== + +"@jridgewell/set-array@^1.2.1": + version "1.2.1" + resolved "https://registry.npmmirror.com/@jridgewell/set-array/-/set-array-1.2.1.tgz#558fb6472ed16a4c850b889530e6b36438c49280" + integrity sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A== + +"@jridgewell/source-map@^0.3.3": + version "0.3.6" + resolved "https://registry.npmmirror.com/@jridgewell/source-map/-/source-map-0.3.6.tgz#9d71ca886e32502eb9362c9a74a46787c36df81a" + integrity sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ== + dependencies: + "@jridgewell/gen-mapping" "^0.3.5" + "@jridgewell/trace-mapping" "^0.3.25" + +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": + version "1.5.0" + resolved "https://registry.npmmirror.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== + +"@jridgewell/trace-mapping@^0.3.20", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25": + version "0.3.25" + resolved "https://registry.npmmirror.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0" + integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ== + dependencies: + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" + +"@socket.io/component-emitter@~3.1.0": + version "3.1.2" + resolved "https://registry.npmmirror.com/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz#821f8442f4175d8f0467b9daf26e3a18e2d02af2" + integrity sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA== + +"@types/cookie@^0.4.1": + version "0.4.1" + resolved "https://registry.npmmirror.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" + integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== + +"@types/cors@^2.8.12": + version "2.8.17" + resolved "https://registry.npmmirror.com/@types/cors/-/cors-2.8.17.tgz#5d718a5e494a8166f569d986794e49c48b216b2b" + integrity sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA== + dependencies: + "@types/node" "*" + +"@types/eslint-scope@^3.7.3": + version "3.7.7" + resolved "https://registry.npmmirror.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" + integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== + dependencies: + "@types/eslint" "*" + "@types/estree" "*" + +"@types/eslint@*": + version "9.6.0" + resolved "https://registry.npmmirror.com/@types/eslint/-/eslint-9.6.0.tgz#51d4fe4d0316da9e9f2c80884f2c20ed5fb022ff" + integrity sha512-gi6WQJ7cHRgZxtkQEoyHMppPjq9Kxo5Tjn2prSKDSmZrCz8TZ3jSRCeTJm+WoM+oB0WG37bRqLzaaU3q7JypGg== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*", "@types/estree@^1.0.5": + version "1.0.5" + resolved "https://registry.npmmirror.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" + integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== + +"@types/json-schema@*", "@types/json-schema@^7.0.8": + version "7.0.15" + resolved "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== + +"@types/node@*", "@types/node@>=10.0.0": + version "22.2.0" + resolved "https://registry.npmmirror.com/@types/node/-/node-22.2.0.tgz#7cf046a99f0ba4d628ad3088cb21f790df9b0c5b" + integrity sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ== + dependencies: + undici-types "~6.13.0" + +"@webassemblyjs/ast@1.12.1", "@webassemblyjs/ast@^1.12.1": + version "1.12.1" + resolved "https://registry.npmmirror.com/@webassemblyjs/ast/-/ast-1.12.1.tgz#bb16a0e8b1914f979f45864c23819cc3e3f0d4bb" + integrity sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg== + dependencies: + "@webassemblyjs/helper-numbers" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + +"@webassemblyjs/floating-point-hex-parser@1.11.6": + version "1.11.6" + resolved "https://registry.npmmirror.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz#dacbcb95aff135c8260f77fa3b4c5fea600a6431" + integrity sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw== + +"@webassemblyjs/helper-api-error@1.11.6": + version "1.11.6" + resolved "https://registry.npmmirror.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz#6132f68c4acd59dcd141c44b18cbebbd9f2fa768" + integrity sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q== + +"@webassemblyjs/helper-buffer@1.12.1": + version "1.12.1" + resolved "https://registry.npmmirror.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.12.1.tgz#6df20d272ea5439bf20ab3492b7fb70e9bfcb3f6" + integrity sha512-nzJwQw99DNDKr9BVCOZcLuJJUlqkJh+kVzVl6Fmq/tI5ZtEyWT1KZMyOXltXLZJmDtvLCDgwsyrkohEtopTXCw== + +"@webassemblyjs/helper-numbers@1.11.6": + version "1.11.6" + resolved "https://registry.npmmirror.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz#cbce5e7e0c1bd32cf4905ae444ef64cea919f1b5" + integrity sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g== + dependencies: + "@webassemblyjs/floating-point-hex-parser" "1.11.6" + "@webassemblyjs/helper-api-error" "1.11.6" + "@xtuc/long" "4.2.2" + +"@webassemblyjs/helper-wasm-bytecode@1.11.6": + version "1.11.6" + resolved "https://registry.npmmirror.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz#bb2ebdb3b83aa26d9baad4c46d4315283acd51e9" + integrity sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA== + +"@webassemblyjs/helper-wasm-section@1.12.1": + version "1.12.1" + resolved "https://registry.npmmirror.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.12.1.tgz#3da623233ae1a60409b509a52ade9bc22a37f7bf" + integrity sha512-Jif4vfB6FJlUlSbgEMHUyk1j234GTNG9dBJ4XJdOySoj518Xj0oGsNi59cUQF4RRMS9ouBUxDDdyBVfPTypa5g== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/wasm-gen" "1.12.1" + +"@webassemblyjs/ieee754@1.11.6": + version "1.11.6" + resolved "https://registry.npmmirror.com/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz#bb665c91d0b14fffceb0e38298c329af043c6e3a" + integrity sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg== + dependencies: + "@xtuc/ieee754" "^1.2.0" + +"@webassemblyjs/leb128@1.11.6": + version "1.11.6" + resolved "https://registry.npmmirror.com/@webassemblyjs/leb128/-/leb128-1.11.6.tgz#70e60e5e82f9ac81118bc25381a0b283893240d7" + integrity sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ== + dependencies: + "@xtuc/long" "4.2.2" + +"@webassemblyjs/utf8@1.11.6": + version "1.11.6" + resolved "https://registry.npmmirror.com/@webassemblyjs/utf8/-/utf8-1.11.6.tgz#90f8bc34c561595fe156603be7253cdbcd0fab5a" + integrity sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA== + +"@webassemblyjs/wasm-edit@^1.12.1": + version "1.12.1" + resolved "https://registry.npmmirror.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.12.1.tgz#9f9f3ff52a14c980939be0ef9d5df9ebc678ae3b" + integrity sha512-1DuwbVvADvS5mGnXbE+c9NfA8QRcZ6iKquqjjmR10k6o+zzsRVesil54DKexiowcFCPdr/Q0qaMgB01+SQ1u6g== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/helper-wasm-section" "1.12.1" + "@webassemblyjs/wasm-gen" "1.12.1" + "@webassemblyjs/wasm-opt" "1.12.1" + "@webassemblyjs/wasm-parser" "1.12.1" + "@webassemblyjs/wast-printer" "1.12.1" + +"@webassemblyjs/wasm-gen@1.12.1": + version "1.12.1" + resolved "https://registry.npmmirror.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.12.1.tgz#a6520601da1b5700448273666a71ad0a45d78547" + integrity sha512-TDq4Ojh9fcohAw6OIMXqiIcTq5KUXTGRkVxbSo1hQnSy6lAM5GSdfwWeSxpAo0YzgsgF182E/U0mDNhuA0tW7w== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/ieee754" "1.11.6" + "@webassemblyjs/leb128" "1.11.6" + "@webassemblyjs/utf8" "1.11.6" + +"@webassemblyjs/wasm-opt@1.12.1": + version "1.12.1" + resolved "https://registry.npmmirror.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.12.1.tgz#9e6e81475dfcfb62dab574ac2dda38226c232bc5" + integrity sha512-Jg99j/2gG2iaz3hijw857AVYekZe2SAskcqlWIZXjji5WStnOpVoat3gQfT/Q5tb2djnCjBtMocY/Su1GfxPBg== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/wasm-gen" "1.12.1" + "@webassemblyjs/wasm-parser" "1.12.1" + +"@webassemblyjs/wasm-parser@1.12.1", "@webassemblyjs/wasm-parser@^1.12.1": + version "1.12.1" + resolved "https://registry.npmmirror.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.12.1.tgz#c47acb90e6f083391e3fa61d113650eea1e95937" + integrity sha512-xikIi7c2FHXysxXe3COrVUPSheuBtpcfhbpFj4gmu7KRLYOzANztwUU0IbsqvMqzuNK2+glRGWCEqZo1WCLyAQ== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-api-error" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/ieee754" "1.11.6" + "@webassemblyjs/leb128" "1.11.6" + "@webassemblyjs/utf8" "1.11.6" + +"@webassemblyjs/wast-printer@1.12.1": + version "1.12.1" + resolved "https://registry.npmmirror.com/@webassemblyjs/wast-printer/-/wast-printer-1.12.1.tgz#bcecf661d7d1abdaf989d8341a4833e33e2b31ac" + integrity sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@xtuc/long" "4.2.2" + +"@webpack-cli/configtest@^2.1.1": + version "2.1.1" + resolved "https://registry.npmmirror.com/@webpack-cli/configtest/-/configtest-2.1.1.tgz#3b2f852e91dac6e3b85fb2a314fb8bef46d94646" + integrity sha512-wy0mglZpDSiSS0XHrVR+BAdId2+yxPSoJW8fsna3ZpYSlufjvxnP4YbKTCBZnNIcGN4r6ZPXV55X4mYExOfLmw== + +"@webpack-cli/info@^2.0.2": + version "2.0.2" + resolved "https://registry.npmmirror.com/@webpack-cli/info/-/info-2.0.2.tgz#cc3fbf22efeb88ff62310cf885c5b09f44ae0fdd" + integrity sha512-zLHQdI/Qs1UyT5UBdWNqsARasIA+AaF8t+4u2aS2nEpBQh2mWIVb8qAklq0eUENnC5mOItrIB4LiS9xMtph18A== + +"@webpack-cli/serve@^2.0.5": + version "2.0.5" + resolved "https://registry.npmmirror.com/@webpack-cli/serve/-/serve-2.0.5.tgz#325db42395cd49fe6c14057f9a900e427df8810e" + integrity sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ== + +"@xtuc/ieee754@^1.2.0": + version "1.2.0" + resolved "https://registry.npmmirror.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" + integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== + +"@xtuc/long@4.2.2": + version "4.2.2" + resolved "https://registry.npmmirror.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" + integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== + +accepts@~1.3.4: + version "1.3.8" + resolved "https://registry.npmmirror.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" + integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== + dependencies: + mime-types "~2.1.34" + negotiator "0.6.3" + +acorn-import-assertions@^1.9.0: + version "1.9.0" + resolved "https://registry.npmmirror.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac" + integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA== + +acorn@^8.7.1, acorn@^8.8.2: + version "8.12.1" + resolved "https://registry.npmmirror.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248" + integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg== + +ajv-keywords@^3.5.2: + version "3.5.2" + resolved "https://registry.npmmirror.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" + integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== + +ajv@^6.12.5: + version "6.12.6" + resolved "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.npmmirror.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.npmmirror.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +base64id@2.0.0, base64id@~2.0.0: + version "2.0.0" + resolved "https://registry.npmmirror.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" + integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== + +binary-extensions@^2.0.0: + version "2.3.0" + resolved "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" + integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== + +body-parser@^1.19.0: + version "1.20.2" + resolved "https://registry.npmmirror.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd" + integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA== + dependencies: + bytes "3.1.2" + content-type "~1.0.5" + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" + iconv-lite "0.4.24" + on-finished "2.4.1" + qs "6.11.0" + raw-body "2.5.2" + type-is "~1.6.18" + unpipe "1.0.0" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@^3.0.2, braces@~3.0.2: + version "3.0.3" + resolved "https://registry.npmmirror.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== + dependencies: + fill-range "^7.1.1" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.npmmirror.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +browserslist@^4.21.10: + version "4.23.3" + resolved "https://registry.npmmirror.com/browserslist/-/browserslist-4.23.3.tgz#debb029d3c93ebc97ffbc8d9cbb03403e227c800" + integrity sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA== + dependencies: + caniuse-lite "^1.0.30001646" + electron-to-chromium "^1.5.4" + node-releases "^2.0.18" + update-browserslist-db "^1.1.0" + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.npmmirror.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +bytes@3.1.2: + version "3.1.2" + resolved "https://registry.npmmirror.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" + integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== + +call-bind@^1.0.7: + version "1.0.7" + resolved "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" + integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + set-function-length "^1.2.1" + +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.npmmirror.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +caniuse-lite@^1.0.30001646: + version "1.0.30001651" + resolved "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz#52de59529e8b02b1aedcaaf5c05d9e23c0c28138" + integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg== + +chalk@^4.1.0: + version "4.1.2" + resolved "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chokidar@3.5.3: + version "3.5.3" + resolved "https://registry.npmmirror.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +chokidar@^3.5.1: + version "3.6.0" + resolved "https://registry.npmmirror.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" + integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +chrome-trace-event@^1.0.2: + version "1.0.4" + resolved "https://registry.npmmirror.com/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz#05bffd7ff928465093314708c93bdfa9bd1f0f5b" + integrity sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ== + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.npmmirror.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +clone-deep@^4.0.1: + version "4.0.1" + resolved "https://registry.npmmirror.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" + integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== + dependencies: + is-plain-object "^2.0.4" + kind-of "^6.0.2" + shallow-clone "^3.0.0" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +colorette@^2.0.14: + version "2.0.20" + resolved "https://registry.npmmirror.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" + integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== + +commander@^10.0.1: + version "10.0.1" + resolved "https://registry.npmmirror.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" + integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== + +commander@^2.20.0: + version "2.20.3" + resolved "https://registry.npmmirror.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +connect@^3.7.0: + version "3.7.0" + resolved "https://registry.npmmirror.com/connect/-/connect-3.7.0.tgz#5d49348910caa5e07a01800b030d0c35f20484f8" + integrity sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ== + dependencies: + debug "2.6.9" + finalhandler "1.1.2" + parseurl "~1.3.3" + utils-merge "1.0.1" + +content-type@~1.0.5: + version "1.0.5" + resolved "https://registry.npmmirror.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" + integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== + +cookie@~0.4.1: + version "0.4.2" + resolved "https://registry.npmmirror.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" + integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== + +cors@~2.8.5: + version "2.8.5" + resolved "https://registry.npmmirror.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + +cross-spawn@^7.0.3: + version "7.0.3" + resolved "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +custom-event@~1.0.0: + version "1.0.1" + resolved "https://registry.npmmirror.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" + integrity sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg== + +date-format@^4.0.14: + version "4.0.14" + resolved "https://registry.npmmirror.com/date-format/-/date-format-4.0.14.tgz#7a8e584434fb169a521c8b7aa481f355810d9400" + integrity sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg== + +debug@2.6.9: + version "2.6.9" + resolved "https://registry.npmmirror.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@4.3.4: + version "4.3.4" + resolved "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: + version "4.3.6" + resolved "https://registry.npmmirror.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" + integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== + dependencies: + ms "2.1.2" + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.npmmirror.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.npmmirror.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + +depd@2.0.0: + version "2.0.0" + resolved "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== + +destroy@1.2.0: + version "1.2.0" + resolved "https://registry.npmmirror.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + +di@^0.0.1: + version "0.0.1" + resolved "https://registry.npmmirror.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" + integrity sha512-uJaamHkagcZtHPqCIHZxnFrXlunQXgBOsZSUOWwFw31QJCAbyTBoHMW75YOTur5ZNx8pIeAKgf6GWIgaqqiLhA== + +diff@5.0.0: + version "5.0.0" + resolved "https://registry.npmmirror.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +dom-serialize@^2.2.1: + version "2.2.1" + resolved "https://registry.npmmirror.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" + integrity sha512-Yra4DbvoW7/Z6LBN560ZwXMjoNOSAN2wRsKFGc4iBeso+mpIA6qj1vfdf9HpMaKAqG6wXTy+1SYEzmNpKXOSsQ== + dependencies: + custom-event "~1.0.0" + ent "~2.2.0" + extend "^3.0.0" + void-elements "^2.0.0" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.npmmirror.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== + +electron-to-chromium@^1.5.4: + version "1.5.6" + resolved "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.5.6.tgz#c81d9938b5a877314ad370feb73b4e5409b36abd" + integrity sha512-jwXWsM5RPf6j9dPYzaorcBSUg6AiqocPEyMpkchkvntaH9HGfOOMZwxMJjDY/XEs3T5dM7uyH1VhRMkqUU9qVw== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.npmmirror.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== + +engine.io-parser@~5.2.1: + version "5.2.3" + resolved "https://registry.npmmirror.com/engine.io-parser/-/engine.io-parser-5.2.3.tgz#00dc5b97b1f233a23c9398d0209504cf5f94d92f" + integrity sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q== + +engine.io@~6.5.2: + version "6.5.5" + resolved "https://registry.npmmirror.com/engine.io/-/engine.io-6.5.5.tgz#430b80d8840caab91a50e9e23cb551455195fc93" + integrity sha512-C5Pn8Wk+1vKBoHghJODM63yk8MvrO9EWZUfkAt5HAqIgPE4/8FF0PEGHXtEd40l223+cE5ABWuPzm38PHFXfMA== + dependencies: + "@types/cookie" "^0.4.1" + "@types/cors" "^2.8.12" + "@types/node" ">=10.0.0" + accepts "~1.3.4" + base64id "2.0.0" + cookie "~0.4.1" + cors "~2.8.5" + debug "~4.3.1" + engine.io-parser "~5.2.1" + ws "~8.17.1" + +enhanced-resolve@^5.16.0: + version "5.17.1" + resolved "https://registry.npmmirror.com/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz#67bfbbcc2f81d511be77d686a90267ef7f898a15" + integrity sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + +ent@~2.2.0: + version "2.2.1" + resolved "https://registry.npmmirror.com/ent/-/ent-2.2.1.tgz#68dc99a002f115792c26239baedaaea9e70c0ca2" + integrity sha512-QHuXVeZx9d+tIQAz/XztU0ZwZf2Agg9CcXcgE1rurqvdBeDBrpSwjl8/6XUqMg7tw2Y7uAdKb2sRv+bSEFqQ5A== + dependencies: + punycode "^1.4.1" + +envinfo@^7.7.3: + version "7.13.0" + resolved "https://registry.npmmirror.com/envinfo/-/envinfo-7.13.0.tgz#81fbb81e5da35d74e814941aeab7c325a606fb31" + integrity sha512-cvcaMr7KqXVh4nyzGTVqTum+gAiL265x5jUWQIDLq//zOGbW+gSW/C+OWLleY/rs9Qole6AZLMXPbtIFQbqu+Q== + +es-define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" + integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== + dependencies: + get-intrinsic "^1.2.4" + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.npmmirror.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + +es-module-lexer@^1.2.1: + version "1.5.4" + resolved "https://registry.npmmirror.com/es-module-lexer/-/es-module-lexer-1.5.4.tgz#a8efec3a3da991e60efa6b633a7cad6ab8d26b78" + integrity sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw== + +escalade@^3.1.1, escalade@^3.1.2: + version "3.1.2" + resolved "https://registry.npmmirror.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" + integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA== + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== + +escape-string-regexp@4.0.0: + version "4.0.0" + resolved "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-scope@5.1.1: + version "5.1.1" + resolved "https://registry.npmmirror.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== + dependencies: + esrecurse "^4.3.0" + estraverse "^4.1.1" + +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.npmmirror.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^4.1.1: + version "4.3.0" + resolved "https://registry.npmmirror.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + +estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.npmmirror.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + +eventemitter3@^4.0.0: + version "4.0.7" + resolved "https://registry.npmmirror.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +events@^3.2.0: + version "3.3.0" + resolved "https://registry.npmmirror.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + +extend@^3.0.0: + version "3.0.2" + resolved "https://registry.npmmirror.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + +fast-deep-equal@^3.1.1: + version "3.1.3" + resolved "https://registry.npmmirror.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.npmmirror.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fastest-levenshtein@^1.0.12: + version "1.0.16" + resolved "https://registry.npmmirror.com/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5" + integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg== + +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.npmmirror.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== + dependencies: + to-regex-range "^5.0.1" + +finalhandler@1.1.2: + version "1.1.2" + resolved "https://registry.npmmirror.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" + integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.3" + statuses "~1.5.0" + unpipe "~1.0.0" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.npmmirror.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +find-up@^4.0.0: + version "4.1.0" + resolved "https://registry.npmmirror.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + dependencies: + locate-path "^5.0.0" + path-exists "^4.0.0" + +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.npmmirror.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +flatted@^3.2.7: + version "3.3.1" + resolved "https://registry.npmmirror.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" + integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== + +follow-redirects@^1.0.0: + version "1.15.6" + resolved "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" + integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== + +format-util@^1.0.5: + version "1.0.5" + resolved "https://registry.npmmirror.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271" + integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg== + +fs-extra@^8.1.0: + version "8.1.0" + resolved "https://registry.npmmirror.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" + integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.npmmirror.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-intrinsic@^1.1.3, get-intrinsic@^1.2.4: + version "1.2.4" + resolved "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" + integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob-to-regexp@^0.4.1: + version "0.4.1" + resolved "https://registry.npmmirror.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" + integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== + +glob@8.1.0: + version "8.1.0" + resolved "https://registry.npmmirror.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" + integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^5.0.1" + once "^1.3.0" + +glob@^7.1.3, glob@^7.1.7: + version "7.2.3" + resolved "https://registry.npmmirror.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.npmmirror.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.10, graceful-fs@^4.2.11, graceful-fs@^4.2.4, graceful-fs@^4.2.6: + version "4.2.11" + resolved "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.npmmirror.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-proto@^1.0.1: + version "1.0.3" + resolved "https://registry.npmmirror.com/has-proto/-/has-proto-1.0.3.tgz#b31ddfe9b0e6e9914536a6ab286426d0214f77fd" + integrity sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q== + +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +hasown@^2.0.0, hasown@^2.0.2: + version "2.0.2" + resolved "https://registry.npmmirror.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" + integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== + dependencies: + function-bind "^1.1.2" + +he@1.2.0: + version "1.2.0" + resolved "https://registry.npmmirror.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +http-errors@2.0.0: + version "2.0.0" + resolved "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== + dependencies: + depd "2.0.0" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" + +http-proxy@^1.18.1: + version "1.18.1" + resolved "https://registry.npmmirror.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" + integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== + dependencies: + eventemitter3 "^4.0.0" + follow-redirects "^1.0.0" + requires-port "^1.0.0" + +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +iconv-lite@^0.6.3: + version "0.6.3" + resolved "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + +import-local@^3.0.2: + version "3.2.0" + resolved "https://registry.npmmirror.com/import-local/-/import-local-3.2.0.tgz#c3d5c745798c02a6f8b897726aba5100186ee260" + integrity sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA== + dependencies: + pkg-dir "^4.2.0" + resolve-cwd "^3.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.npmmirror.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@2.0.4: + version "2.0.4" + resolved "https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +interpret@^3.1.1: + version "3.1.1" + resolved "https://registry.npmmirror.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" + integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-core-module@^2.13.0: + version "2.15.0" + resolved "https://registry.npmmirror.com/is-core-module/-/is-core-module-2.15.0.tgz#71c72ec5442ace7e76b306e9d48db361f22699ea" + integrity sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA== + dependencies: + hasown "^2.0.2" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.npmmirror.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.npmmirror.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + +is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.npmmirror.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.npmmirror.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +isbinaryfile@^4.0.8: + version "4.0.10" + resolved "https://registry.npmmirror.com/isbinaryfile/-/isbinaryfile-4.0.10.tgz#0c5b5e30c2557a2f06febd37b7322946aaee42b3" + integrity sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.npmmirror.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.npmmirror.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== + +jest-worker@^27.4.5: + version "27.5.1" + resolved "https://registry.npmmirror.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" + integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== + dependencies: + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^8.0.0" + +js-yaml@4.1.0: + version "4.1.0" + resolved "https://registry.npmmirror.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +json-parse-even-better-errors@^2.3.1: + version "2.3.1" + resolved "https://registry.npmmirror.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" + integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.npmmirror.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== + optionalDependencies: + graceful-fs "^4.1.6" + +karma-chrome-launcher@3.2.0: + version "3.2.0" + resolved "https://registry.npmmirror.com/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz#eb9c95024f2d6dfbb3748d3415ac9b381906b9a9" + integrity sha512-rE9RkUPI7I9mAxByQWkGJFXfFD6lE4gC5nPuZdobf/QdTEJI6EU4yIay/cfU/xV4ZxlM5JiTv7zWYgA64NpS5Q== + dependencies: + which "^1.2.1" + +karma-mocha@2.0.1: + version "2.0.1" + resolved "https://registry.npmmirror.com/karma-mocha/-/karma-mocha-2.0.1.tgz#4b0254a18dfee71bdbe6188d9a6861bf86b0cd7d" + integrity sha512-Tzd5HBjm8his2OA4bouAsATYEpZrp9vC7z5E5j4C5Of5Rrs1jY67RAwXNcVmd/Bnk1wgvQRou0zGVLey44G4tQ== + dependencies: + minimist "^1.2.3" + +karma-sourcemap-loader@0.4.0: + version "0.4.0" + resolved "https://registry.npmmirror.com/karma-sourcemap-loader/-/karma-sourcemap-loader-0.4.0.tgz#b01d73f8f688f533bcc8f5d273d43458e13b5488" + integrity sha512-xCRL3/pmhAYF3I6qOrcn0uhbQevitc2DERMPH82FMnG+4WReoGcGFZb1pURf2a5apyrOHRdvD+O6K7NljqKHyA== + dependencies: + graceful-fs "^4.2.10" + +karma-webpack@5.0.1: + version "5.0.1" + resolved "https://registry.npmmirror.com/karma-webpack/-/karma-webpack-5.0.1.tgz#4eafd31bbe684a747a6e8f3e4ad373e53979ced4" + integrity sha512-oo38O+P3W2mSPCSUrQdySSPv1LvPpXP+f+bBimNomS5sW+1V4SuhCuW8TfJzV+rDv921w2fDSDw0xJbPe6U+kQ== + dependencies: + glob "^7.1.3" + minimatch "^9.0.3" + webpack-merge "^4.1.5" + +karma@6.4.3: + version "6.4.3" + resolved "https://registry.npmmirror.com/karma/-/karma-6.4.3.tgz#763e500f99597218bbb536de1a14acc4ceea7ce8" + integrity sha512-LuucC/RE92tJ8mlCwqEoRWXP38UMAqpnq98vktmS9SznSoUPPUJQbc91dHcxcunROvfQjdORVA/YFviH+Xci9Q== + dependencies: + "@colors/colors" "1.5.0" + body-parser "^1.19.0" + braces "^3.0.2" + chokidar "^3.5.1" + connect "^3.7.0" + di "^0.0.1" + dom-serialize "^2.2.1" + glob "^7.1.7" + graceful-fs "^4.2.6" + http-proxy "^1.18.1" + isbinaryfile "^4.0.8" + lodash "^4.17.21" + log4js "^6.4.1" + mime "^2.5.2" + minimatch "^3.0.4" + mkdirp "^0.5.5" + qjobs "^1.2.0" + range-parser "^1.2.1" + rimraf "^3.0.2" + socket.io "^4.7.2" + source-map "^0.6.1" + tmp "^0.2.1" + ua-parser-js "^0.7.30" + yargs "^16.1.1" + +kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.npmmirror.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +loader-runner@^4.2.0: + version "4.3.0" + resolved "https://registry.npmmirror.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" + integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg== + +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.npmmirror.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.npmmirror.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash@^4.17.15, lodash@^4.17.21: + version "4.17.21" + resolved "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + +log-symbols@4.1.0: + version "4.1.0" + resolved "https://registry.npmmirror.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +log4js@^6.4.1: + version "6.9.1" + resolved "https://registry.npmmirror.com/log4js/-/log4js-6.9.1.tgz#aba5a3ff4e7872ae34f8b4c533706753709e38b6" + integrity sha512-1somDdy9sChrr9/f4UlzhdaGfDR2c/SaD2a4T7qEkG4jTS57/B3qmnjLYePwQ8cqWnUHZI0iAKxMBpCZICiZ2g== + dependencies: + date-format "^4.0.14" + debug "^4.3.4" + flatted "^3.2.7" + rfdc "^1.3.0" + streamroller "^3.1.5" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.npmmirror.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== + +merge-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.npmmirror.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" + integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.27, mime-types@~2.1.24, mime-types@~2.1.34: + version "2.1.35" + resolved "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +mime@^2.5.2: + version "2.6.0" + resolved "https://registry.npmmirror.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" + integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== + +minimatch@5.0.1: + version "5.0.1" + resolved "https://registry.npmmirror.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^3.0.4, minimatch@^3.1.1: + version "3.1.2" + resolved "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimatch@^5.0.1: + version "5.1.6" + resolved "https://registry.npmmirror.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96" + integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^9.0.3: + version "9.0.5" + resolved "https://registry.npmmirror.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5" + integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow== + dependencies: + brace-expansion "^2.0.1" + +minimist@^1.2.3, minimist@^1.2.6: + version "1.2.8" + resolved "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +mkdirp@^0.5.5: + version "0.5.6" + resolved "https://registry.npmmirror.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +mocha@10.3.0: + version "10.3.0" + resolved "https://registry.npmmirror.com/mocha/-/mocha-10.3.0.tgz#0e185c49e6dccf582035c05fa91084a4ff6e3fe9" + integrity sha512-uF2XJs+7xSLsrmIvn37i/wnc91nw7XjOQB8ccyx5aEgdnohr7n+rEiZP23WkCYHjilR6+EboEnbq/ZQDz4LSbg== + dependencies: + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.3" + debug "4.3.4" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "8.1.0" + he "1.2.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "5.0.1" + ms "2.1.3" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + workerpool "6.2.1" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.npmmirror.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@2.1.3: + version "2.1.3" + resolved "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +negotiator@0.6.3: + version "0.6.3" + resolved "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== + +neo-async@^2.6.2: + version "2.6.2" + resolved "https://registry.npmmirror.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" + integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== + +node-releases@^2.0.18: + version "2.0.18" + resolved "https://registry.npmmirror.com/node-releases/-/node-releases-2.0.18.tgz#f010e8d35e2fe8d6b2944f03f70213ecedc4ca3f" + integrity sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g== + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.npmmirror.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +object-assign@^4: + version "4.1.1" + resolved "https://registry.npmmirror.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== + +object-inspect@^1.13.1: + version "1.13.2" + resolved "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" + integrity sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g== + +on-finished@2.4.1: + version "2.4.1" + resolved "https://registry.npmmirror.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" + integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== + dependencies: + ee-first "1.1.1" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.npmmirror.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + integrity sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww== + dependencies: + ee-first "1.1.1" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.npmmirror.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +p-limit@^2.2.0: + version "2.3.0" + resolved "https://registry.npmmirror.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.npmmirror.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.npmmirror.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.npmmirror.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.npmmirror.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.npmmirror.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.npmmirror.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.npmmirror.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.npmmirror.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.npmmirror.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== + +picocolors@^1.0.1: + version "1.0.1" + resolved "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.1.tgz#a8ad579b571952f0e5d25892de5445bcfe25aaa1" + integrity sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew== + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +pkg-dir@^4.2.0: + version "4.2.0" + resolved "https://registry.npmmirror.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.npmmirror.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== + +punycode@^2.1.0: + version "2.3.1" + resolved "https://registry.npmmirror.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + +qjobs@^1.2.0: + version "1.2.0" + resolved "https://registry.npmmirror.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" + integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== + +qs@6.11.0: + version "6.11.0" + resolved "https://registry.npmmirror.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" + integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== + dependencies: + side-channel "^1.0.4" + +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.npmmirror.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +range-parser@^1.2.1: + version "1.2.1" + resolved "https://registry.npmmirror.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== + +raw-body@2.5.2: + version "2.5.2" + resolved "https://registry.npmmirror.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a" + integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA== + dependencies: + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" + unpipe "1.0.0" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +rechoir@^0.8.0: + version "0.8.0" + resolved "https://registry.npmmirror.com/rechoir/-/rechoir-0.8.0.tgz#49f866e0d32146142da3ad8f0eff352b3215ff22" + integrity sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ== + dependencies: + resolve "^1.20.0" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.npmmirror.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +requires-port@^1.0.0: + version "1.0.0" + resolved "https://registry.npmmirror.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== + +resolve-cwd@^3.0.0: + version "3.0.0" + resolved "https://registry.npmmirror.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" + integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== + dependencies: + resolve-from "^5.0.0" + +resolve-from@^5.0.0: + version "5.0.0" + resolved "https://registry.npmmirror.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" + integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== + +resolve@^1.20.0: + version "1.22.8" + resolved "https://registry.npmmirror.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" + integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== + dependencies: + is-core-module "^2.13.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +rfdc@^1.3.0: + version "1.4.1" + resolved "https://registry.npmmirror.com/rfdc/-/rfdc-1.4.1.tgz#778f76c4fb731d93414e8f925fbecf64cce7f6ca" + integrity sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA== + +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.npmmirror.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + +safe-buffer@^5.1.0: + version "5.2.1" + resolved "https://registry.npmmirror.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": + version "2.1.2" + resolved "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +schema-utils@^3.1.1, schema-utils@^3.2.0: + version "3.3.0" + resolved "https://registry.npmmirror.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe" + integrity sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg== + dependencies: + "@types/json-schema" "^7.0.8" + ajv "^6.12.5" + ajv-keywords "^3.5.2" + +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.npmmirror.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + +serialize-javascript@^6.0.1: + version "6.0.2" + resolved "https://registry.npmmirror.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" + integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== + dependencies: + randombytes "^2.1.0" + +set-function-length@^1.2.1: + version "1.2.2" + resolved "https://registry.npmmirror.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== + +shallow-clone@^3.0.0: + version "3.0.1" + resolved "https://registry.npmmirror.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" + integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== + dependencies: + kind-of "^6.0.2" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.npmmirror.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.npmmirror.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +side-channel@^1.0.4: + version "1.0.6" + resolved "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2" + integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA== + dependencies: + call-bind "^1.0.7" + es-errors "^1.3.0" + get-intrinsic "^1.2.4" + object-inspect "^1.13.1" + +socket.io-adapter@~2.5.2: + version "2.5.5" + resolved "https://registry.npmmirror.com/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz#c7a1f9c703d7756844751b6ff9abfc1780664082" + integrity sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg== + dependencies: + debug "~4.3.4" + ws "~8.17.1" + +socket.io-parser@~4.2.4: + version "4.2.4" + resolved "https://registry.npmmirror.com/socket.io-parser/-/socket.io-parser-4.2.4.tgz#c806966cf7270601e47469ddeec30fbdfda44c83" + integrity sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew== + dependencies: + "@socket.io/component-emitter" "~3.1.0" + debug "~4.3.1" + +socket.io@^4.7.2: + version "4.7.5" + resolved "https://registry.npmmirror.com/socket.io/-/socket.io-4.7.5.tgz#56eb2d976aef9d1445f373a62d781a41c7add8f8" + integrity sha512-DmeAkF6cwM9jSfmp6Dr/5/mfMwb5Z5qRrSXLpo3Fq5SqyU8CMF15jIN4ZhfSwu35ksM1qmHZDQ/DK5XTccSTvA== + dependencies: + accepts "~1.3.4" + base64id "~2.0.0" + cors "~2.8.5" + debug "~4.3.2" + engine.io "~6.5.2" + socket.io-adapter "~2.5.2" + socket.io-parser "~4.2.4" + +source-map-js@^1.0.2: + version "1.2.0" + resolved "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af" + integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg== + +source-map-loader@5.0.0: + version "5.0.0" + resolved "https://registry.npmmirror.com/source-map-loader/-/source-map-loader-5.0.0.tgz#f593a916e1cc54471cfc8851b905c8a845fc7e38" + integrity sha512-k2Dur7CbSLcAH73sBcIkV5xjPV4SzqO1NJ7+XaQl8if3VODDUj3FNchNGpqgJSKbvUfJuhVdv8K2Eu8/TNl2eA== + dependencies: + iconv-lite "^0.6.3" + source-map-js "^1.0.2" + +source-map-support@0.5.21, source-map-support@~0.5.20: + version "0.5.21" + resolved "https://registry.npmmirror.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0, source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +statuses@2.0.1: + version "2.0.1" + resolved "https://registry.npmmirror.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== + +statuses@~1.5.0: + version "1.5.0" + resolved "https://registry.npmmirror.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== + +streamroller@^3.1.5: + version "3.1.5" + resolved "https://registry.npmmirror.com/streamroller/-/streamroller-3.1.5.tgz#1263182329a45def1ffaef58d31b15d13d2ee7ff" + integrity sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw== + dependencies: + date-format "^4.0.14" + debug "^4.3.4" + fs-extra "^8.1.0" + +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-json-comments@3.1.1: + version "3.1.1" + resolved "https://registry.npmmirror.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@8.1.1, supports-color@^8.0.0: + version "8.1.1" + resolved "https://registry.npmmirror.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + +tapable@^2.1.1, tapable@^2.2.0: + version "2.2.1" + resolved "https://registry.npmmirror.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" + integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== + +terser-webpack-plugin@^5.3.10: + version "5.3.10" + resolved "https://registry.npmmirror.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz#904f4c9193c6fd2a03f693a2150c62a92f40d199" + integrity sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w== + dependencies: + "@jridgewell/trace-mapping" "^0.3.20" + jest-worker "^27.4.5" + schema-utils "^3.1.1" + serialize-javascript "^6.0.1" + terser "^5.26.0" + +terser@^5.26.0: + version "5.31.5" + resolved "https://registry.npmmirror.com/terser/-/terser-5.31.5.tgz#e48b7c65f32d2808e7dad803e4586a0bc3829b87" + integrity sha512-YPmas0L0rE1UyLL/llTWA0SiDOqIcAQYLeUj7cJYzXHlRTAnMSg9pPe4VJ5PlKvTrPQsdVFuiRiwyeNlYgwh2Q== + dependencies: + "@jridgewell/source-map" "^0.3.3" + acorn "^8.8.2" + commander "^2.20.0" + source-map-support "~0.5.20" + +tmp@^0.2.1: + version "0.2.3" + resolved "https://registry.npmmirror.com/tmp/-/tmp-0.2.3.tgz#eb783cc22bc1e8bebd0671476d46ea4eb32a79ae" + integrity sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w== + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + +type-is@~1.6.18: + version "1.6.18" + resolved "https://registry.npmmirror.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" + integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== + dependencies: + media-typer "0.3.0" + mime-types "~2.1.24" + +typescript@5.4.3: + version "5.4.3" + resolved "https://registry.npmmirror.com/typescript/-/typescript-5.4.3.tgz#5c6fedd4c87bee01cd7a528a30145521f8e0feff" + integrity sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg== + +ua-parser-js@^0.7.30: + version "0.7.38" + resolved "https://registry.npmmirror.com/ua-parser-js/-/ua-parser-js-0.7.38.tgz#f497d8a4dc1fec6e854e5caa4b2f9913422ef054" + integrity sha512-fYmIy7fKTSFAhG3fuPlubeGaMoAd6r0rSnfEsO5nEY55i26KSLt9EH7PLQiiqPUhNqYIJvSkTy1oArIcXAbPbA== + +undici-types@~6.13.0: + version "6.13.0" + resolved "https://registry.npmmirror.com/undici-types/-/undici-types-6.13.0.tgz#e3e79220ab8c81ed1496b5812471afd7cf075ea5" + integrity sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg== + +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.npmmirror.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.npmmirror.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== + +update-browserslist-db@^1.1.0: + version "1.1.0" + resolved "https://registry.npmmirror.com/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz#7ca61c0d8650766090728046e416a8cde682859e" + integrity sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ== + dependencies: + escalade "^3.1.2" + picocolors "^1.0.1" + +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.npmmirror.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.npmmirror.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== + +vary@^1: + version "1.1.2" + resolved "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== + +void-elements@^2.0.0: + version "2.0.1" + resolved "https://registry.npmmirror.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" + integrity sha512-qZKX4RnBzH2ugr8Lxa7x+0V6XD9Sb/ouARtiasEQCHB1EVU4NXtmHsDDrx1dO4ne5fc3J6EW05BP1Dl0z0iung== + +watchpack@^2.4.1: + version "2.4.1" + resolved "https://registry.npmmirror.com/watchpack/-/watchpack-2.4.1.tgz#29308f2cac150fa8e4c92f90e0ec954a9fed7fff" + integrity sha512-8wrBCMtVhqcXP2Sup1ctSkga6uc2Bx0IIvKyT7yTFier5AXHooSI+QyQQAtTb7+E0IUCCKyTFmXqdqgum2XWGg== + dependencies: + glob-to-regexp "^0.4.1" + graceful-fs "^4.1.2" + +webpack-cli@5.1.4: + version "5.1.4" + resolved "https://registry.npmmirror.com/webpack-cli/-/webpack-cli-5.1.4.tgz#c8e046ba7eaae4911d7e71e2b25b776fcc35759b" + integrity sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg== + dependencies: + "@discoveryjs/json-ext" "^0.5.0" + "@webpack-cli/configtest" "^2.1.1" + "@webpack-cli/info" "^2.0.2" + "@webpack-cli/serve" "^2.0.5" + colorette "^2.0.14" + commander "^10.0.1" + cross-spawn "^7.0.3" + envinfo "^7.7.3" + fastest-levenshtein "^1.0.12" + import-local "^3.0.2" + interpret "^3.1.1" + rechoir "^0.8.0" + webpack-merge "^5.7.3" + +webpack-merge@^4.1.5: + version "4.2.2" + resolved "https://registry.npmmirror.com/webpack-merge/-/webpack-merge-4.2.2.tgz#a27c52ea783d1398afd2087f547d7b9d2f43634d" + integrity sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g== + dependencies: + lodash "^4.17.15" + +webpack-merge@^5.7.3: + version "5.10.0" + resolved "https://registry.npmmirror.com/webpack-merge/-/webpack-merge-5.10.0.tgz#a3ad5d773241e9c682803abf628d4cd62b8a4177" + integrity sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA== + dependencies: + clone-deep "^4.0.1" + flat "^5.0.2" + wildcard "^2.0.0" + +webpack-sources@^3.2.3: + version "3.2.3" + resolved "https://registry.npmmirror.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" + integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== + +webpack@5.91.0: + version "5.91.0" + resolved "https://registry.npmmirror.com/webpack/-/webpack-5.91.0.tgz#ffa92c1c618d18c878f06892bbdc3373c71a01d9" + integrity sha512-rzVwlLeBWHJbmgTC/8TvAcu5vpJNII+MelQpylD4jNERPwpBJOE2lEcko1zJX3QJeLjTTAnQxn/OJ8bjDzVQaw== + dependencies: + "@types/eslint-scope" "^3.7.3" + "@types/estree" "^1.0.5" + "@webassemblyjs/ast" "^1.12.1" + "@webassemblyjs/wasm-edit" "^1.12.1" + "@webassemblyjs/wasm-parser" "^1.12.1" + acorn "^8.7.1" + acorn-import-assertions "^1.9.0" + browserslist "^4.21.10" + chrome-trace-event "^1.0.2" + enhanced-resolve "^5.16.0" + es-module-lexer "^1.2.1" + eslint-scope "5.1.1" + events "^3.2.0" + glob-to-regexp "^0.4.1" + graceful-fs "^4.2.11" + json-parse-even-better-errors "^2.3.1" + loader-runner "^4.2.0" + mime-types "^2.1.27" + neo-async "^2.6.2" + schema-utils "^3.2.0" + tapable "^2.1.1" + terser-webpack-plugin "^5.3.10" + watchpack "^2.4.1" + webpack-sources "^3.2.3" + +which@^1.2.1: + version "1.3.1" + resolved "https://registry.npmmirror.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +which@^2.0.1: + version "2.0.2" + resolved "https://registry.npmmirror.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +wildcard@^2.0.0: + version "2.0.1" + resolved "https://registry.npmmirror.com/wildcard/-/wildcard-2.0.1.tgz#5ab10d02487198954836b6349f74fff961e10f67" + integrity sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ== + +workerpool@6.2.1: + version "6.2.1" + resolved "https://registry.npmmirror.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" + integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +ws@~8.17.1: + version "8.17.1" + resolved "https://registry.npmmirror.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" + integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.npmmirror.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.npmmirror.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.npmmirror.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.npmmirror.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0, yargs@^16.1.1: + version "16.2.0" + resolved "https://registry.npmmirror.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/kotlinpoet/api/kotlinpoet.api b/kotlinpoet/api/kotlinpoet.api index eef2b6132b..b600c98191 100644 --- a/kotlinpoet/api/kotlinpoet.api +++ b/kotlinpoet/api/kotlinpoet.api @@ -434,6 +434,9 @@ public final class com/squareup/kotlinpoet/Import : java/lang/Comparable { public fun toString ()Ljava/lang/String; } +public abstract interface annotation class com/squareup/kotlinpoet/JvmTypeAliasKotlinPoetApi : java/lang/annotation/Annotation { +} + public final class com/squareup/kotlinpoet/KModifier : java/lang/Enum { public static final field ABSTRACT Lcom/squareup/kotlinpoet/KModifier; public static final field ACTUAL Lcom/squareup/kotlinpoet/KModifier; @@ -1253,6 +1256,15 @@ public final class com/squareup/kotlinpoet/jvm/JvmAnnotations { public static final fun volatile (Lcom/squareup/kotlinpoet/PropertySpec$Builder;)Lcom/squareup/kotlinpoet/PropertySpec$Builder; } +public final class com/squareup/kotlinpoet/jvm/alias/JvmClasses { + public static final fun getKotlin (Ljava/lang/Class;)Lkotlin/reflect/KClass; + public static final fun typeName (Ljava/lang/reflect/Type;)Ljava/lang/String; +} + +public final class com/squareup/kotlinpoet/jvm/alias/JvmPath_jvmKt { + public static final fun toJvmFile (Ljava/nio/file/Path;)Ljava/io/File; +} + public final class com/squareup/kotlinpoet/tags/TypeAliasTag { public fun (Lcom/squareup/kotlinpoet/TypeName;)V public final fun getAbbreviatedType ()Lcom/squareup/kotlinpoet/TypeName; diff --git a/kotlinpoet/build.gradle.kts b/kotlinpoet/build.gradle.kts index 48ab9c7213..17de7e1da7 100644 --- a/kotlinpoet/build.gradle.kts +++ b/kotlinpoet/build.gradle.kts @@ -14,6 +14,7 @@ * limitations under the License. */ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl plugins { kotlin("multiplatform") @@ -23,11 +24,12 @@ spotless { kotlin { targetExclude( // Non-Square licensed files - "src/commonMain/kotlin/com/squareup/kotlinpoet/ClassName.kt", - "src/commonTest/kotlin/com/squareup/kotlinpoet/AbstractTypesTest.kt", - "src/commonTest/kotlin/com/squareup/kotlinpoet/ClassNameTest.kt", - "src/commonTest/kotlin/com/squareup/kotlinpoet/TypesEclipseTest.kt", - "src/commonTest/kotlin/com/squareup/kotlinpoet/TypesTest.kt", + "src/*Main/kotlin/com/squareup/kotlinpoet/ClassName.kt", + "src/*Main/kotlin/com/squareup/kotlinpoet/ClassName.*.kt", + "src/*Test/kotlin/com/squareup/kotlinpoet/AbstractTypesTest.kt", + "src/*Test/kotlin/com/squareup/kotlinpoet/ClassNameTest.kt", + "src/*Test/kotlin/com/squareup/kotlinpoet/TypesEclipseTest.kt", + "src/*Test/kotlin/com/squareup/kotlinpoet/TypesTest.kt", ) } } @@ -37,19 +39,46 @@ kotlin { withJava() } + js { + nodejs { + testTask { + useMocha() + } + } + binaries.library() + } + + @OptIn(ExperimentalWasmDsl::class) + wasmJs { + nodejs { + testTask { + useMocha() + } + } + binaries.library() + } + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { allWarningsAsErrors.set(true) optIn.add("com.squareup.kotlinpoet.DelicateKotlinPoetApi") + freeCompilerArgs.add("-Xexpect-actual-classes") } sourceSets { - val commonMain by getting { + commonMain { dependencies { implementation(libs.kotlin.reflect) } } - val commonTest by getting { + + commonTest { + dependencies { + implementation(kotlin("test")) + } + } + + jvmTest { dependencies { implementation(libs.kotlin.junit) implementation(libs.truth) @@ -62,6 +91,17 @@ kotlin { implementation(libs.kotlin.compilerEmbeddable) } } + + val nonJvmMain by creating { + dependsOn(commonMain.get()) + } + + jsMain { + dependsOn(nonJvmMain) + } + wasmJsMain { + dependsOn(nonJvmMain) + } } } diff --git a/kotlinpoet/gradle.properties b/kotlinpoet/gradle.properties index 7258dd1943..045335cee4 100644 --- a/kotlinpoet/gradle.properties +++ b/kotlinpoet/gradle.properties @@ -2,3 +2,4 @@ POM_ARTIFACT_ID=kotlinpoet POM_NAME=KotlinPoet POM_DESCRIPTION=Use beautiful Kotlin code to generate beautiful Kotlin code. POM_PACKAGING=jar +kotlin.mpp.applyDefaultHierarchyTemplate=false diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Annotatable.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Annotatable.kt index 255331058f..356b90c2ab 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Annotatable.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Annotatable.kt @@ -15,6 +15,7 @@ */ package com.squareup.kotlinpoet +import com.squareup.kotlinpoet.jvm.alias.JvmClass import kotlin.reflect.KClass /** A spec or type which can be annotated. */ @@ -42,7 +43,7 @@ public interface Annotatable { message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - public fun addAnnotation(annotation: Class<*>): T = addAnnotation(annotation.asClassName()) + public fun addAnnotation(annotation: JvmClass<*>): T = addAnnotation(annotation.asClassName()) public fun addAnnotation(annotation: KClass<*>): T = addAnnotation(annotation.asClassName()) } diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.kt index a9390923ac..18ad623b09 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.kt @@ -13,17 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@file:JvmName("AnnotationSpecs") +@file:JvmMultifileClass + package com.squareup.kotlinpoet -import java.lang.reflect.Array -import java.util.Objects -import javax.lang.model.element.AnnotationMirror -import javax.lang.model.element.AnnotationValue -import javax.lang.model.element.TypeElement -import javax.lang.model.element.VariableElement -import javax.lang.model.type.TypeMirror -import javax.lang.model.util.SimpleAnnotationValueVisitor8 +import com.squareup.kotlinpoet.jvm.alias.JvmAnnotationMirror +import com.squareup.kotlinpoet.jvm.alias.JvmClass import kotlin.LazyThreadSafetyMode.NONE +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName +import kotlin.jvm.JvmOverloads +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass /** A generated annotation on a declaration. */ @@ -98,7 +99,7 @@ public class AnnotationSpec private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null) return false - if (javaClass != other.javaClass) return false + if (this::class != other::class) return false return toString() == other.toString() } @@ -146,8 +147,8 @@ public class AnnotationSpec private constructor( * `%L` for other types. */ internal fun memberForValue(value: Any) = when (value) { - is Class<*> -> CodeBlock.of("%T::class", value) - is Enum<*> -> CodeBlock.of("%T.%L", value.javaClass, value.name) + is JvmClass<*> -> CodeBlock.of("%T::class", value) + is Enum<*> -> resolveEnumValueCodeBlock(value) is String -> CodeBlock.of("%S", value) is Float -> CodeBlock.of("%Lf", value) is Char -> CodeBlock.of("'%L'", characterLiteralWithoutSingleQuotes(value)) @@ -156,37 +157,6 @@ public class AnnotationSpec private constructor( } } - /** - * Annotation value visitor adding members to the given builder instance. - */ - @OptIn(DelicateKotlinPoetApi::class) - private class Visitor( - val builder: CodeBlock.Builder, - ) : SimpleAnnotationValueVisitor8(builder) { - - override fun defaultAction(o: Any, name: String) = - builder.add(Builder.memberForValue(o)) - - override fun visitAnnotation(a: AnnotationMirror, name: String) = - builder.add("%L", get(a)) - - override fun visitEnumConstant(c: VariableElement, name: String) = - builder.add("%T.%L", c.asType().asTypeName(), c.simpleName) - - override fun visitType(t: TypeMirror, name: String) = - builder.add("%T::class", t.asTypeName()) - - override fun visitArray(values: List, name: String): CodeBlock.Builder { - builder.add("arrayOf(⇥⇥") - values.forEachIndexed { index, value -> - if (index > 0) builder.add(", ") - value.accept(this, name) - } - builder.add("⇤⇤)") - return builder - } - } - public companion object { @DelicateKotlinPoetApi( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + @@ -198,43 +168,7 @@ public class AnnotationSpec private constructor( annotation: Annotation, includeDefaultValues: Boolean = false, ): AnnotationSpec { - try { - @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - val javaAnnotation = annotation as java.lang.annotation.Annotation - val builder = builder(javaAnnotation.annotationType()) - .tag(annotation) - val methods = annotation.annotationType().declaredMethods.sortedBy { it.name } - for (method in methods) { - val value = method.invoke(annotation) - if (!includeDefaultValues) { - if (Objects.deepEquals(value, method.defaultValue)) { - continue - } - } - val member = CodeBlock.builder() - member.add("%L = ", method.name) - if (value.javaClass.isArray) { - member.add("arrayOf(⇥⇥") - for (i in 0.. 0) member.add(", ") - member.add(Builder.memberForValue(Array.get(value, i))) - } - member.add("⇤⇤)") - builder.addMember(member.build()) - continue - } - if (value is Annotation) { - member.add("%L", get(value)) - builder.addMember(member.build()) - continue - } - member.add("%L", Builder.memberForValue(value)) - builder.addMember(member.build()) - } - return builder.build() - } catch (e: Exception) { - throw RuntimeException("Reflecting $annotation failed!", e) - } + return doGet(annotation, includeDefaultValues) } @DelicateKotlinPoetApi( @@ -242,19 +176,8 @@ public class AnnotationSpec private constructor( " the kotlinpoet-metadata APIs instead.", ) @JvmStatic - public fun get(annotation: AnnotationMirror): AnnotationSpec { - val element = annotation.annotationType.asElement() as TypeElement - val builder = builder(element.asClassName()).tag(annotation) - for (executableElement in annotation.elementValues.keys) { - val member = CodeBlock.builder() - val visitor = Visitor(member) - val name = executableElement.simpleName.toString() - member.add("%L = ", name) - val value = annotation.elementValues[executableElement]!! - value.accept(visitor, name) - builder.addMember(member.build()) - } - return builder.build() + public fun get(annotation: JvmAnnotationMirror): AnnotationSpec { + return doGet(annotation) } @JvmStatic public fun builder(type: ClassName): Builder = Builder(type) @@ -266,10 +189,19 @@ public class AnnotationSpec private constructor( "using the kotlinpoet-metadata APIs instead.", ) @JvmStatic - public fun builder(type: Class): Builder = + public fun builder(type: JvmClass): Builder = builder(type.asClassName()) @JvmStatic public fun builder(type: KClass): Builder = builder(type.asClassName()) } } + +internal expect fun resolveEnumValueCodeBlock(value: Enum<*>): CodeBlock + +internal expect fun doGet( + annotation: Annotation, + includeDefaultValues: Boolean, +): AnnotationSpec + +internal expect fun doGet(annotation: JvmAnnotationMirror): AnnotationSpec diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ClassName.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ClassName.kt index 5eeb21b0a3..eeda396e0f 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ClassName.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ClassName.kt @@ -14,16 +14,15 @@ * limitations under the License. */ @file:JvmName("ClassNames") +@file:JvmMultifileClass package com.squareup.kotlinpoet -import java.util.ArrayDeque -import javax.lang.model.element.Element -import javax.lang.model.element.ElementKind -import javax.lang.model.element.NestingKind.MEMBER -import javax.lang.model.element.NestingKind.TOP_LEVEL -import javax.lang.model.element.PackageElement -import javax.lang.model.element.TypeElement +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmTypeElement +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass /** A fully-qualified class name for top-level and member classes. */ @@ -191,11 +190,9 @@ public class ClassName internal constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false + if (other !is ClassName) return false if (!super.equals(other)) return false - other as ClassName - if (names != other.names) return false return true @@ -220,7 +217,7 @@ public class ClassName internal constructor( // Add the package name, like "java.util.concurrent", or "" for no package. var p = 0 - while (p < classNameString.length && Character.isLowerCase(classNameString.codePointAt(p))) { + while (p < classNameString.length && classNameString.codePointAt(p).isLowerCase()) { p = classNameString.indexOf('.', p) + 1 require(p != 0) { "couldn't make a guess for $classNameString" } } @@ -228,7 +225,7 @@ public class ClassName internal constructor( // Add the class names, like "Map" and "Entry". for (part in classNameString.substring(p).split('.')) { - require(part.isNotEmpty() && Character.isUpperCase(part.codePointAt(0))) { + require(part.isNotEmpty() && part.codePointAt(0).isUpperCase()) { "couldn't make a guess for $classNameString" } @@ -249,28 +246,13 @@ public class ClassName internal constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider using" + " the kotlinpoet-metadata APIs instead." ) -@JvmName("get") -public fun Class<*>.asClassName(): ClassName { - require(!isPrimitive) { "primitive types cannot be represented as a ClassName" } - require(Void.TYPE != this) { "'void' type cannot be represented as a ClassName" } - require(!isArray) { "array types cannot be represented as a ClassName" } - val names = mutableListOf() - var c = this - while (true) { - names += c.simpleName - val enclosing = c.enclosingClass ?: break - c = enclosing - } - // Avoid unreliable Class.getPackage(). https://github.com/square/javapoet/issues/295 - val lastDot = c.name.lastIndexOf('.') - if (lastDot != -1) names += c.name.substring(0, lastDot) - names.reverse() - return ClassName(names) -} +public expect fun JvmClass<*>.asClassName(): ClassName + +internal expect fun KClass<*>.qualifiedNameInternal(): String? @JvmName("get") public fun KClass<*>.asClassName(): ClassName { - var qualifiedName = requireNotNull(qualifiedName) { "$this cannot be represented as a ClassName" } + var qualifiedName = requireNotNull(qualifiedNameInternal()) { "$this cannot be represented as a ClassName" } // First, check for Kotlin types whose enclosing class name is a type that is mapped to a JVM // class. Thus, the class backing the nested Kotlin type does not have an enclosing class @@ -288,9 +270,9 @@ public fun KClass<*>.asClassName(): ClassName { "kotlin.String.Companion" -> listOf("kotlin", "String", "Companion") else -> { val names = ArrayDeque() - var target: Class<*>? = java + var target: KClass<*>? = this while (target != null) { - target = target.enclosingClass + target = target.enclosingClass() val dot = qualifiedName.lastIndexOf('.') if (dot == -1) { @@ -311,34 +293,4 @@ public fun KClass<*>.asClassName(): ClassName { return ClassName(names) } -/** Returns the class name for `element`. */ -@DelicateKotlinPoetApi( - message = "Element APIs don't give complete information on Kotlin types. Consider using" + - " the kotlinpoet-metadata APIs instead." -) -@JvmName("get") -public fun TypeElement.asClassName(): ClassName { - fun isClassOrInterface(e: Element) = e.kind.isClass || e.kind.isInterface - - fun getPackage(type: Element): PackageElement { - var t = type - while (t.kind != ElementKind.PACKAGE) { - t = t.enclosingElement - } - return t as PackageElement - } - - val names = mutableListOf() - var e: Element = this - while (isClassOrInterface(e)) { - val eType = e as TypeElement - require(eType.nestingKind.isOneOf(TOP_LEVEL, MEMBER)) { - "unexpected type testing" - } - names += eType.simpleName.toString() - e = eType.enclosingElement - } - names += getPackage(this).qualifiedName.toString() - names.reverse() - return ClassName(names) -} +internal expect fun Enum<*>.declaringClassName(): ClassName diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeBlock.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeBlock.kt index 2f62873753..7fb1e51d13 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeBlock.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeBlock.kt @@ -14,16 +14,14 @@ * limitations under the License. */ @file:JvmName("CodeBlocks") +@file:JvmMultifileClass package com.squareup.kotlinpoet -import java.lang.reflect.Type -import java.text.DecimalFormat -import java.text.DecimalFormatSymbols -import javax.lang.model.element.Element -import javax.lang.model.type.TypeMirror -import kotlin.math.max -import kotlin.reflect.KClass +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName +import kotlin.jvm.JvmOverloads +import kotlin.jvm.JvmStatic /** * A fragment of a .kt file, potentially containing declarations, statements, and documentation. @@ -156,7 +154,7 @@ public class CodeBlock private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null) return false - if (javaClass != other.javaClass) return false + if (this::class != other::class) return false return toString() == other.toString() } @@ -299,7 +297,7 @@ public class CodeBlock private constructor( // Find either the indexed argument, or the relative argument. (0-based). val index: Int if (indexStart < indexEnd) { - index = Integer.parseInt(format.substring(indexStart, indexEnd)) - 1 + index = format.substring(indexStart, indexEnd).toInt() - 1 hasIndexed = true if (args.isNotEmpty()) { indexedParameterCount[index % args.size]++ // modulo is needed, checked below anyway @@ -349,7 +347,7 @@ public class CodeBlock private constructor( 'T' -> this.args += argToType(arg) 'M' -> this.args += arg else -> throw IllegalArgumentException( - String.format("invalid format string: '%s'", format), + "invalid format string: '$format'", ) } } @@ -368,27 +366,6 @@ public class CodeBlock private constructor( private fun argToString(o: Any?) = o?.toString() - private fun formatNumericValue(o: Number): Any? { - val format = DecimalFormatSymbols().apply { - decimalSeparator = '.' - groupingSeparator = '_' - minusSign = '-' - } - - val precision = when (o) { - is Float -> max(o.toBigDecimal().stripTrailingZeros().scale(), 1) - is Double -> max(o.toBigDecimal().stripTrailingZeros().scale(), 1) - else -> 0 - } - - val pattern = when (o) { - is Float, is Double -> "###,##0.0" + "#".repeat(precision - 1) - else -> "###,##0" - } - - return DecimalFormat(pattern, format).format(o) - } - private fun logDeprecationWarning(o: Any) { println( "Deprecation warning: converting $o to TypeName. Conversion of TypeMirror and" + @@ -396,19 +373,8 @@ public class CodeBlock private constructor( ) } - private fun argToType(o: Any?) = when (o) { - is TypeName -> o - is TypeMirror -> { - logDeprecationWarning(o) - o.asTypeName() - } - is Element -> { - logDeprecationWarning(o) - o.asType().asTypeName() - } - is Type -> o.asTypeName() - is KClass<*> -> o.asTypeName() - else -> throw IllegalArgumentException("expected type but was $o") + private fun argToType(o: Any?) = argToType(o) { o1 -> + logDeprecationWarning(o1) } /** @@ -543,3 +509,10 @@ public inline fun buildCodeBlock(builderAction: CodeBlock.Builder.() -> Unit): C public inline fun CodeBlock.Builder.withIndent(builderAction: CodeBlock.Builder.() -> Unit): CodeBlock.Builder { return indent().also(builderAction).unindent() } + +internal expect fun formatNumericValue(o: Number): Any? + +internal expect inline fun argToType( + o: Any?, + logDeprecationWarning: (Any) -> Unit, +): TypeName diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodePoints.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodePoints.kt new file mode 100644 index 0000000000..75c46fc08b --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodePoints.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.jvm.JvmInline + +@JvmInline +internal value class CodePoint(val code: Int) + +internal expect fun String.codePointAt(index: Int): CodePoint + +internal expect fun CodePoint.isLowerCase(): Boolean +internal expect fun CodePoint.isUpperCase(): Boolean + +internal expect fun CodePoint.isJavaIdentifierStart(): Boolean +internal expect fun CodePoint.isJavaIdentifierPart(): Boolean + +internal expect fun CodePoint.charCount(): Int + +internal expect fun StringBuilder.appendCodePoint(codePoint: CodePoint): StringBuilder diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt index 584fde50fa..19abbe6242 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt @@ -15,16 +15,17 @@ */ package com.squareup.kotlinpoet -import java.io.Closeable import kotlin.math.min +internal expect fun initNoPackage(): String + /** Sentinel value that indicates that no user-provided package has been set. */ -private val NO_PACKAGE = String() +private val NO_PACKAGE = initNoPackage() internal val NULLABLE_ANY = ANY.copy(nullable = true) private fun extractMemberName(part: String): String { - require(Character.isJavaIdentifierStart(part[0])) { "not an identifier: $part" } + require(part[0].isJavaIdentifierStart()) { "not an identifier: $part" } for (i in 1..part.length) { if (!part.substring(0, i).isIdentifier) { return part.substring(0, i - 1) @@ -35,7 +36,7 @@ private fun extractMemberName(part: String): String { internal inline fun buildCodeString(builderAction: CodeWriter.() -> Unit): String { val stringBuilder = StringBuilder() - CodeWriter(stringBuilder, columnLimit = Integer.MAX_VALUE).use { + CodeWriter(stringBuilder, columnLimit = Int.MAX_VALUE).use { it.builderAction() } return stringBuilder.toString() @@ -61,7 +62,7 @@ internal class CodeWriter( private val importedTypes: Map = emptyMap(), private val importedMembers: Map> = emptyMap(), columnLimit: Int = 100, -) : Closeable { +) : AutoCloseable { private var out = LineWrapper(out, indent, columnLimit) private var indentLevel = 0 @@ -380,7 +381,7 @@ internal class CodeWriter( val partWithoutLeadingDot = part.substring(1) if (partWithoutLeadingDot.isEmpty()) return false val first = partWithoutLeadingDot[0] - if (!Character.isJavaIdentifierStart(first)) return false + if (!first.isJavaIdentifierStart()) return false val explicit = imports[canonical + "." + extractMemberName(partWithoutLeadingDot)] if (explicit != null) { if (explicit.alias != null) { @@ -713,7 +714,7 @@ internal class CodeWriter( NullAppendable, indent, memberImports, - columnLimit = Integer.MAX_VALUE, + columnLimit = Int.MAX_VALUE, ) emitStep(importsCollector) val generatedImports = mutableMapOf() diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ContextReceivable.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ContextReceivable.kt index 929096bc53..48d322ede6 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ContextReceivable.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ContextReceivable.kt @@ -15,6 +15,8 @@ */ package com.squareup.kotlinpoet +import kotlin.jvm.JvmInline + /** A KotlinPoet spec type that can have a context receiver. */ public interface ContextReceivable { diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/FileSpec.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/FileSpec.kt index dbe6c65f06..254f01a403 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/FileSpec.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/FileSpec.kt @@ -16,23 +16,17 @@ package com.squareup.kotlinpoet import com.squareup.kotlinpoet.AnnotationSpec.UseSiteTarget.FILE -import java.io.ByteArrayInputStream -import java.io.File -import java.io.IOException -import java.io.InputStream -import java.net.URI -import java.nio.charset.StandardCharsets.UTF_8 -import java.nio.file.Path -import javax.annotation.processing.Filer -import javax.tools.JavaFileObject -import javax.tools.JavaFileObject.Kind -import javax.tools.SimpleJavaFileObject -import javax.tools.StandardLocation +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmFile +import com.squareup.kotlinpoet.jvm.alias.JvmFiler +import com.squareup.kotlinpoet.jvm.alias.JvmIOException +import com.squareup.kotlinpoet.jvm.alias.JvmJavaFileObject +import com.squareup.kotlinpoet.jvm.alias.JvmPath +import com.squareup.kotlinpoet.jvm.alias.toJvmFile import kotlin.DeprecationLevel.HIDDEN -import kotlin.io.path.createDirectories -import kotlin.io.path.isDirectory -import kotlin.io.path.notExists -import kotlin.io.path.outputStream +import kotlin.jvm.JvmName +import kotlin.jvm.JvmOverloads +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass /** @@ -79,7 +73,7 @@ public class FileSpec private constructor( append(extension) } - @Throws(IOException::class) + @Throws(JvmIOException::class) public fun writeTo(out: Appendable) { val codeWriter = CodeWriter.withCollectedImports( out = out, @@ -93,7 +87,7 @@ public class FileSpec private constructor( @Deprecated("", level = HIDDEN) @JvmName("writeTo") // For binary compatibility. - public fun oldWriteTo(directory: Path) { + public fun oldWriteTo(directory: JvmPath) { writeTo(directory) } @@ -101,20 +95,14 @@ public class FileSpec private constructor( * Writes this to [directory] as UTF-8 using the standard directory structure * and returns the newly output path. */ - @Throws(IOException::class) - public fun writeTo(directory: Path): Path { - require(directory.notExists() || directory.isDirectory()) { - "path $directory exists but is not a directory." - } - val outputPath = directory.resolve(relativePath) - outputPath.parent.createDirectories() - outputPath.outputStream().bufferedWriter().use(::writeTo) - return outputPath + @Throws(JvmIOException::class) + public fun writeTo(directory: JvmPath): JvmPath { + return writeToPath(directory) } @Deprecated("", level = HIDDEN) @JvmName("writeTo") // For binary compatibility. - public fun oldWriteTo(directory: File) { + public fun oldWriteTo(directory: JvmFile) { writeTo(directory) } @@ -122,31 +110,13 @@ public class FileSpec private constructor( * Writes this to [directory] as UTF-8 using the standard directory structure * and returns the newly output file. */ - @Throws(IOException::class) - public fun writeTo(directory: File): File = writeTo(directory.toPath()).toFile() + @Throws(JvmIOException::class) + public fun writeTo(directory: JvmFile): JvmFile = writeTo(directory.toPath()).toJvmFile() /** Writes this to `filer`. */ - @Throws(IOException::class) - public fun writeTo(filer: Filer) { - val originatingElements = members.asSequence() - .filterIsInstance() - .flatMap { it.originatingElements.asSequence() } - .toSet() - val filerSourceFile = filer.createResource( - StandardLocation.SOURCE_OUTPUT, - packageName, - "$name.$extension", - *originatingElements.toTypedArray(), - ) - try { - filerSourceFile.openWriter().use { writer -> writeTo(writer) } - } catch (e: Exception) { - try { - filerSourceFile.delete() - } catch (_: Exception) { - } - throw e - } + @Throws(JvmIOException::class) + public fun writeTo(filer: JvmFiler) { + writeToFiler(filer, extension) } private fun emit(codeWriter: CodeWriter, collectingImports: Boolean) { @@ -213,7 +183,7 @@ public class FileSpec private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null) return false - if (javaClass != other.javaClass) return false + if (this::class != other::class) return false return toString() == other.toString() } @@ -221,20 +191,8 @@ public class FileSpec private constructor( override fun toString(): String = buildString { writeTo(this) } - public fun toJavaFileObject(): JavaFileObject { - val uri = URI.create(relativePath) - return object : SimpleJavaFileObject(uri, Kind.SOURCE) { - private val lastModified = System.currentTimeMillis() - override fun getCharContent(ignoreEncodingErrors: Boolean): String { - return this@FileSpec.toString() - } - - override fun openInputStream(): InputStream { - return ByteArrayInputStream(getCharContent(true).toByteArray(UTF_8)) - } - - override fun getLastModified() = lastModified - } + public fun toJavaFileObject(): JvmJavaFileObject { + return toJavaFileObjectInternal(toString = { toString() }) } @JvmOverloads @@ -345,11 +303,11 @@ public class FileSpec private constructor( } public fun addImport(constant: Enum<*>): Builder = addImport( - constant.declaringJavaClass.asClassName(), + constant.declaringClassName(), constant.name, ) - public fun addImport(`class`: Class<*>, vararg names: String): Builder = apply { + public fun addImport(`class`: JvmClass<*>, vararg names: String): Builder = apply { require(names.isNotEmpty()) { "names array is empty" } addImport(`class`.asClassName(), names.toList()) } @@ -364,7 +322,7 @@ public class FileSpec private constructor( addImport(className, names.toList()) } - public fun addImport(`class`: Class<*>, names: Iterable): Builder = + public fun addImport(`class`: JvmClass<*>, names: Iterable): Builder = addImport(`class`.asClassName(), names) public fun addImport(`class`: KClass<*>, names: Iterable): Builder = @@ -401,7 +359,7 @@ public class FileSpec private constructor( memberImports.clear() } - public fun addAliasedImport(`class`: Class<*>, `as`: String): Builder = + public fun addAliasedImport(`class`: JvmClass<*>, `as`: String): Builder = addAliasedImport(`class`.asClassName(), `as`) public fun addAliasedImport(`class`: KClass<*>, `as`: String): Builder = @@ -538,7 +496,7 @@ public class FileSpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - override fun addAnnotation(annotation: Class<*>): Builder = super.addAnnotation(annotation) + override fun addAnnotation(annotation: JvmClass<*>): Builder = super.addAnnotation(annotation) @Suppress("RedundantOverride") override fun addAnnotation(annotation: KClass<*>): Builder = super.addAnnotation(annotation) @@ -596,3 +554,15 @@ private val KOTLIN_DEFAULT_IMPORTS = setOf( ) private val KOTLIN_DEFAULT_JVM_IMPORTS = setOf("java.lang") private val KOTLIN_DEFAULT_JS_IMPORTS = setOf("kotlin.js") + +@Throws(JvmIOException::class) +internal expect fun FileSpec.writeToPath(directory: JvmPath): JvmPath + +@Throws(JvmIOException::class) +internal expect fun FileSpec.writeToFiler(filer: JvmFiler, extension: String) + +internal expect inline fun FileSpec.toJavaFileObjectInternal( + crossinline toString: () -> String, +): JvmJavaFileObject + +// Perhaps in the future, support for kotlinx.io API could be added here? diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/FunSpec.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/FunSpec.kt index f42308ea0d..4a79882918 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/FunSpec.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/FunSpec.kt @@ -19,16 +19,16 @@ import com.squareup.kotlinpoet.KModifier.ABSTRACT import com.squareup.kotlinpoet.KModifier.EXPECT import com.squareup.kotlinpoet.KModifier.EXTERNAL import com.squareup.kotlinpoet.KModifier.INLINE -import com.squareup.kotlinpoet.KModifier.VARARG -import java.lang.reflect.Type -import javax.lang.model.element.Element -import javax.lang.model.element.ExecutableElement -import javax.lang.model.element.Modifier -import javax.lang.model.type.DeclaredType -import javax.lang.model.type.ExecutableType -import javax.lang.model.type.TypeVariable -import javax.lang.model.util.Types +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmDeclaredType +import com.squareup.kotlinpoet.jvm.alias.JvmElement +import com.squareup.kotlinpoet.jvm.alias.JvmExecutableElement +import com.squareup.kotlinpoet.jvm.alias.JvmModifier +import com.squareup.kotlinpoet.jvm.alias.JvmType +import com.squareup.kotlinpoet.jvm.alias.JvmTypes import kotlin.DeprecationLevel.WARNING +import kotlin.jvm.JvmOverloads +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass /** A generated function declaration. */ @@ -265,7 +265,7 @@ public class FunSpec private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null) return false - if (javaClass != other.javaClass) return false + if (this::class != other::class) return false return toString() == other.toString() } @@ -321,7 +321,7 @@ public class FunSpec private constructor( public val typeVariables: MutableList = mutableListOf() public val parameters: MutableList = mutableListOf() override val tags: MutableMap, Any> = mutableMapOf() - override val originatingElements: MutableList = mutableListOf() + override val originatingElements: MutableList = mutableListOf() @ExperimentalKotlinPoetApi override val contextReceiverTypes: MutableList = mutableListOf() @@ -334,20 +334,20 @@ public class FunSpec private constructor( this.modifiers += modifiers } - public fun jvmModifiers(modifiers: Iterable) { + public fun jvmModifiers(modifiers: Iterable) { var visibility = KModifier.INTERNAL for (modifier in modifiers) { when (modifier) { - Modifier.PUBLIC -> visibility = KModifier.PUBLIC - Modifier.PROTECTED -> visibility = KModifier.PROTECTED - Modifier.PRIVATE -> visibility = KModifier.PRIVATE - Modifier.ABSTRACT -> this.modifiers += KModifier.ABSTRACT - Modifier.FINAL -> this.modifiers += KModifier.FINAL - Modifier.NATIVE -> this.modifiers += KModifier.EXTERNAL - Modifier.DEFAULT -> Unit - Modifier.STATIC -> addAnnotation(JvmStatic::class) - Modifier.SYNCHRONIZED -> addAnnotation(Synchronized::class) - Modifier.STRICTFP -> addAnnotation(Strictfp::class) + JvmModifier.PUBLIC -> visibility = KModifier.PUBLIC + JvmModifier.PROTECTED -> visibility = KModifier.PROTECTED + JvmModifier.PRIVATE -> visibility = KModifier.PRIVATE + JvmModifier.ABSTRACT -> this.modifiers += ABSTRACT + JvmModifier.FINAL -> this.modifiers += KModifier.FINAL + JvmModifier.NATIVE -> this.modifiers += EXTERNAL + JvmModifier.DEFAULT -> Unit + JvmModifier.STATIC -> addAnnotation(JvmStaticClassName) + JvmModifier.SYNCHRONIZED -> addAnnotation(SynchronizedClassName) + JvmModifier.STRICTFP -> addAnnotation(StrictfpClassName) else -> throw IllegalArgumentException("unexpected fun modifier $modifier") } } @@ -379,12 +379,12 @@ public class FunSpec private constructor( } @JvmOverloads public fun receiver( - receiverType: Type, + receiverType: JvmType, kdoc: CodeBlock = CodeBlock.EMPTY, ): Builder = receiver(receiverType.asTypeName(), kdoc) public fun receiver( - receiverType: Type, + receiverType: JvmType, kdoc: String, vararg args: Any, ): Builder = receiver(receiverType, CodeBlock.of(kdoc, args)) @@ -409,10 +409,10 @@ public class FunSpec private constructor( this.returnKdoc = kdoc } - @JvmOverloads public fun returns(returnType: Type, kdoc: CodeBlock = CodeBlock.EMPTY): Builder = + @JvmOverloads public fun returns(returnType: JvmType, kdoc: CodeBlock = CodeBlock.EMPTY): Builder = returns(returnType.asTypeName(), kdoc) - public fun returns(returnType: Type, kdoc: String, vararg args: Any): Builder = + public fun returns(returnType: JvmType, kdoc: String, vararg args: Any): Builder = returns(returnType.asTypeName(), CodeBlock.of(kdoc, args)) @JvmOverloads public fun returns( @@ -474,7 +474,7 @@ public class FunSpec private constructor( public fun addParameter(name: String, type: TypeName, vararg modifiers: KModifier): Builder = addParameter(ParameterSpec.builder(name, type, *modifiers).build()) - public fun addParameter(name: String, type: Type, vararg modifiers: KModifier): Builder = + public fun addParameter(name: String, type: JvmType, vararg modifiers: KModifier): Builder = addParameter(name, type.asTypeName(), *modifiers) public fun addParameter(name: String, type: KClass<*>, vararg modifiers: KModifier): Builder = @@ -483,7 +483,7 @@ public class FunSpec private constructor( public fun addParameter(name: String, type: TypeName, modifiers: Iterable): Builder = addParameter(ParameterSpec.builder(name, type, modifiers).build()) - public fun addParameter(name: String, type: Type, modifiers: Iterable): Builder = + public fun addParameter(name: String, type: JvmType, modifiers: Iterable): Builder = addParameter(name, type.asTypeName(), modifiers) public fun addParameter( @@ -551,7 +551,7 @@ public class FunSpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - override fun addAnnotation(annotation: Class<*>): Builder = super.addAnnotation(annotation) + override fun addAnnotation(annotation: JvmClass<*>): Builder = super.addAnnotation(annotation) @Suppress("RedundantOverride") override fun addAnnotation(annotation: KClass<*>): Builder = super.addAnnotation(annotation) @@ -600,49 +600,8 @@ public class FunSpec private constructor( " the kotlinpoet-metadata APIs instead.", ) @JvmStatic - public fun overriding(method: ExecutableElement): Builder { - var modifiers: Set = method.modifiers - require( - Modifier.PRIVATE !in modifiers && - Modifier.FINAL !in modifiers && - Modifier.STATIC !in modifiers, - ) { - "cannot override method with modifiers: $modifiers" - } - - val methodName = method.simpleName.toString() - val funBuilder = builder(methodName) - - funBuilder.addModifiers(KModifier.OVERRIDE) - - modifiers = modifiers.toMutableSet() - modifiers.remove(Modifier.ABSTRACT) - funBuilder.jvmModifiers(modifiers) - - method.typeParameters - .map { it.asType() as TypeVariable } - .map { it.asTypeVariableName() } - .forEach { funBuilder.addTypeVariable(it) } - - funBuilder.returns(method.returnType.asTypeName()) - funBuilder.addParameters(ParameterSpec.parametersOf(method)) - if (method.isVarArgs) { - funBuilder.parameters[funBuilder.parameters.lastIndex] = funBuilder.parameters.last() - .toBuilder() - .addModifiers(VARARG) - .build() - } - - if (method.thrownTypes.isNotEmpty()) { - val throwsValueString = method.thrownTypes.joinToString { "%T::class" } - funBuilder.addAnnotation( - AnnotationSpec.builder(Throws::class) - .addMember(throwsValueString, *method.thrownTypes.toTypedArray()) - .build(), - ) - } - - return funBuilder + public fun overriding(method: JvmExecutableElement): Builder { + return doOverriding(method) } @Deprecated( @@ -652,26 +611,19 @@ public class FunSpec private constructor( ) @JvmStatic public fun overriding( - method: ExecutableElement, - enclosing: DeclaredType, - types: Types, + method: JvmExecutableElement, + enclosing: JvmDeclaredType, + types: JvmTypes, ): Builder { - val executableType = types.asMemberOf(enclosing, method) as ExecutableType - val resolvedParameterTypes = executableType.parameterTypes - val resolvedReturnType = executableType.returnType - - val builder = overriding(method) - builder.returns(resolvedReturnType.asTypeName()) - var i = 0 - val size = builder.parameters.size - while (i < size) { - val parameter = builder.parameters[i] - val type = resolvedParameterTypes[i].asTypeName() - builder.parameters[i] = parameter.toBuilder(parameter.name, type).build() - i++ - } - - return builder + return doOverriding(method, enclosing, types) } } } + +internal expect fun doOverriding(method: JvmExecutableElement): FunSpec.Builder + +internal expect fun doOverriding( + method: JvmExecutableElement, + enclosing: JvmDeclaredType, + types: JvmTypes, +): FunSpec.Builder diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/JvmTypeAliasKotlinPoetApi.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/JvmTypeAliasKotlinPoetApi.kt new file mode 100644 index 0000000000..b794a76341 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/JvmTypeAliasKotlinPoetApi.kt @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.annotation.AnnotationTarget.CLASS +import kotlin.annotation.AnnotationTarget.FUNCTION +import kotlin.annotation.AnnotationTarget.PROPERTY +import kotlin.annotation.AnnotationTarget.TYPEALIAS + +/** + * An expected type for JVM to `typealias` only. + */ +@MustBeDocumented +@Retention(AnnotationRetention.BINARY) +@Target(CLASS, FUNCTION, PROPERTY, TYPEALIAS) +@RequiresOptIn( + level = RequiresOptIn.Level.ERROR, + message = "An expected type for JVM to `typealias` only." + + " Don't implement or use it in non-JVM platforms.", +) +public annotation class JvmTypeAliasKotlinPoetApi diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/KModifier.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/KModifier.kt index 81d03570f8..e0bdabd210 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/KModifier.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/KModifier.kt @@ -19,7 +19,6 @@ import com.squareup.kotlinpoet.KModifier.INTERNAL import com.squareup.kotlinpoet.KModifier.PRIVATE import com.squareup.kotlinpoet.KModifier.PROTECTED import com.squareup.kotlinpoet.KModifier.PUBLIC -import java.util.EnumSet public enum class KModifier( internal val keyword: String, @@ -89,4 +88,4 @@ public enum class KModifier( } } -internal val VISIBILITY_MODIFIERS: Set = EnumSet.of(PUBLIC, INTERNAL, PROTECTED, PRIVATE) +internal val VISIBILITY_MODIFIERS: Set = enumSetOf(PUBLIC, INTERNAL, PROTECTED, PRIVATE) diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/LambdaTypeName.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/LambdaTypeName.kt index 9f462f817b..dcb9e1ee47 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/LambdaTypeName.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/LambdaTypeName.kt @@ -15,6 +15,7 @@ */ package com.squareup.kotlinpoet +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass @OptIn(ExperimentalKotlinPoetApi::class) @@ -86,11 +87,9 @@ public class LambdaTypeName private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false + if (other !is LambdaTypeName) return false if (!super.equals(other)) return false - other as LambdaTypeName - if (receiver != other.receiver) return false if (contextReceivers != other.contextReceivers) return false if (returnType != other.returnType) return false diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/LineWrapper.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/LineWrapper.kt index 3a1e9a6b95..17e999a3d6 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/LineWrapper.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/LineWrapper.kt @@ -15,8 +15,6 @@ */ package com.squareup.kotlinpoet -import java.io.Closeable - /** * Implements soft line wrapping on an appendable. To use, append characters using * [LineWrapper.append], which will replace spaces with newlines where necessary. Use @@ -26,7 +24,7 @@ internal class LineWrapper( private val out: Appendable, private val indent: String, private val columnLimit: Int, -) : Closeable { +) : AutoCloseable { private var closed = false diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/MemberName.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/MemberName.kt index c70a10ac0d..01aaa277d0 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/MemberName.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/MemberName.kt @@ -15,6 +15,10 @@ */ package com.squareup.kotlinpoet +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import kotlin.jvm.JvmName +import kotlin.jvm.JvmStatic +import kotlin.jvm.JvmSynthetic import kotlin.reflect.KClass /** @@ -162,7 +166,7 @@ public data class MemberName internal constructor( ) @JvmStatic @JvmName("get") - public fun Class<*>.member(simpleName: String): MemberName = + public fun JvmClass<*>.member(simpleName: String): MemberName = asClassName().member(simpleName) } } diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/MemberSpecHolder.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/MemberSpecHolder.kt index e7d6724b5b..005bb2c603 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/MemberSpecHolder.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/MemberSpecHolder.kt @@ -15,7 +15,7 @@ */ package com.squareup.kotlinpoet -import java.lang.reflect.Type +import com.squareup.kotlinpoet.jvm.alias.JvmType import kotlin.reflect.KClass /** A spec which can contain [PropertySpec]s and [FunSpec]s. */ @@ -38,7 +38,7 @@ public interface MemberSpecHolder { message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - public fun addProperty(name: String, type: Type, vararg modifiers: KModifier): T = + public fun addProperty(name: String, type: JvmType, vararg modifiers: KModifier): T = addProperty(name, type.asTypeName(), *modifiers) public fun addProperty(name: String, type: KClass<*>, vararg modifiers: KModifier): T = @@ -51,7 +51,7 @@ public interface MemberSpecHolder { message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - public fun addProperty(name: String, type: Type, modifiers: Iterable): T = + public fun addProperty(name: String, type: JvmType, modifiers: Iterable): T = addProperty(name, type.asTypeName(), modifiers) public fun addProperty(name: String, type: KClass<*>, modifiers: Iterable): T = diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/NameAllocator.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/NameAllocator.kt index a6c570b9e3..6eaa290255 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/NameAllocator.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/NameAllocator.kt @@ -15,7 +15,7 @@ */ package com.squareup.kotlinpoet -import java.util.UUID +import kotlin.jvm.JvmOverloads /** * Assigns Kotlin identifier names to avoid collisions, keywords, and invalid characters. To use, @@ -116,9 +116,10 @@ public class NameAllocator private constructor( * names. The returned value can be queried multiple times by passing `tag` to * [NameAllocator.get]. */ - @JvmOverloads public fun newName( + @JvmOverloads + public fun newName( suggestion: String, - tag: Any = UUID.randomUUID().toString(), + tag: Any = defaultNewNameTag(), ): String { var result = toJavaIdentifier(suggestion) while (!allocatedNames.add(result)) { @@ -149,23 +150,25 @@ public class NameAllocator private constructor( } } +internal expect fun defaultNewNameTag(): Any + private fun toJavaIdentifier(suggestion: String) = buildString { var i = 0 while (i < suggestion.length) { val codePoint = suggestion.codePointAt(i) if (i == 0 && - !Character.isJavaIdentifierStart(codePoint) && - Character.isJavaIdentifierPart(codePoint) + !codePoint.isJavaIdentifierStart() && + codePoint.isJavaIdentifierPart() ) { append("_") } - val validCodePoint: Int = if (Character.isJavaIdentifierPart(codePoint)) { + val validCodePoint: CodePoint = if (codePoint.isJavaIdentifierPart()) { codePoint } else { - '_'.code + CodePoint('_'.code) } appendCodePoint(validCodePoint) - i += Character.charCount(codePoint) + i += codePoint.charCount() } } diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.kt new file mode 100644 index 0000000000..2dd36ecfbe --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.kt @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("OptionalExpectationAnnotations") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet + +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName +import kotlin.reflect.KClass + +/** [KClass] for [kotlin.jvm.JvmName] */ +internal expect val JvmNameClass: KClass? + +/** [KClass] for [kotlin.jvm.JvmMultifileClass] */ +internal expect val JvmMultifileClassClass: KClass? + +/** [KClass] for [kotlin.jvm.JvmSuppressWildcards] */ +internal expect val JvmSuppressWildcardsClass: KClass? + +/** [KClass] for [kotlin.jvm.JvmInline] */ +internal expect val JvmInlineClass: KClass? + +/** [KClass] for [kotlin.jvm.JvmRecord] */ +internal expect val JvmRecordClass: KClass? + +/** [KClass] for [kotlin.jvm.JvmStatic] */ +internal expect val JvmStaticClass: KClass? + +/** [KClass] for [kotlin.jvm.JvmOverloads] */ +internal expect val JvmOverloadsClass: KClass? + +/** [KClass] for [kotlin.Throws] */ +internal expect val ThrowsClass: KClass? + +/** [KClass] for [kotlin.jvm.Synchronized] */ +internal expect val SynchronizedClass: KClass? + +/** [KClass] for [kotlin.jvm.Strictfp] */ +internal expect val StrictfpClass: KClass? + +/** [KClass] for [kotlin.jvm.JvmField] */ +internal expect val JvmFieldClass: KClass? + +/** [KClass] for [kotlin.jvm.Transient] */ +internal expect val TransientClass: KClass? + +/** [KClass] for [kotlin.concurrent.Volatile] */ +internal expect val VolatileClass: KClass? + +/** [KClass] for [kotlin.jvm.JvmWildcard] */ +internal expect val JvmWildcardClass: KClass? + +/** [ClassName] for [kotlin.jvm.JvmName] */ +internal val JvmNameClassName: ClassName = ClassName("kotlin.jvm", "JvmName") + +/** [ClassName] for [kotlin.jvm.JvmMultifileClass] */ +internal val JvmMultifileClassClassName: ClassName = ClassName("kotlin.jvm", "JvmMultifileClass") + +/** [ClassName] for [kotlin.jvm.JvmSuppressWildcards] */ +internal val JvmSuppressWildcardsClassName: ClassName = ClassName("kotlin.jvm", "JvmSuppressWildcards") + +/** [ClassName] for [kotlin.jvm.JvmInline] */ +internal val JvmInlineClassName: ClassName = ClassName("kotlin.jvm", "JvmInline") + +/** [ClassName] for [kotlin.jvm.JvmRecord] */ +internal val JvmRecordClassName: ClassName = ClassName("kotlin.jvm", "JvmRecord") + +/** [ClassName] for [kotlin.jvm.JvmStatic] */ +internal val JvmStaticClassName: ClassName = ClassName("kotlin.jvm", "JvmStatic") + +/** [ClassName] for [kotlin.jvm.JvmOverloads] */ +internal val JvmOverloadsClassName: ClassName = ClassName("kotlin.jvm", "JvmOverloads") + +/** [ClassName] for [kotlin.Throws] */ +internal val ThrowsClassName: ClassName = ClassName("kotlin", "Throws") + +/** [ClassName] for [kotlin.jvm.Throws] */ +internal val JvmThrowsClassName: ClassName = ClassName("kotlin.jvm", "Throws") + +/** [ClassName] for [kotlin.jvm.Synchronized] */ +internal val SynchronizedClassName: ClassName = ClassName("kotlin.jvm", "Synchronized") + +/** [ClassName] for [kotlin.jvm.Strictfp] */ +internal val StrictfpClassName: ClassName = ClassName("kotlin.jvm", "Strictfp") + +/** [ClassName] for [kotlin.jvm.JvmField] */ +internal val JvmFieldClassName: ClassName = ClassName("kotlin.jvm", "JvmField") + +/** [ClassName] for [kotlin.jvm.Transient] */ +internal val TransientClassName: ClassName = ClassName("kotlin.jvm", "Transient") + +/** [ClassName] for [kotlin.concurrent.Volatile] */ +internal val VolatileClassName: ClassName = ClassName("kotlin.concurrent", "Volatile") + +/** [ClassName] for [kotlin.jvm.Volatile] */ +internal val JvmVolatileClassName: ClassName = ClassName("kotlin.jvm", "Volatile") + +/** [ClassName] for [kotlin.jvm.JvmWildcard] */ +internal val JvmWildcardClassName: ClassName = ClassName("kotlin.jvm", "JvmWildcard") diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/OriginatingElementsHolder.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/OriginatingElementsHolder.kt index 4e877742f3..de118e51a6 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/OriginatingElementsHolder.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/OriginatingElementsHolder.kt @@ -15,24 +15,26 @@ */ package com.squareup.kotlinpoet -import javax.lang.model.element.Element +import com.squareup.kotlinpoet.jvm.JvmDefaultWithCompatibility +import com.squareup.kotlinpoet.jvm.alias.JvmElement +import kotlin.jvm.JvmInline -/** A type that can have originating [elements][Element]. */ +/** A type that can have originating [elements][JvmElement]. */ public interface OriginatingElementsHolder { /** The originating elements of this type. */ - public val originatingElements: List + public val originatingElements: List /** The builder analogue to [OriginatingElementsHolder] types. */ @JvmDefaultWithCompatibility public interface Builder> { /** Mutable map of the current originating elements this builder contains. */ - public val originatingElements: MutableList + public val originatingElements: MutableList /** Adds an [originatingElement] to this type's list of originating elements. */ @Suppress("UNCHECKED_CAST") - public fun addOriginatingElement(originatingElement: Element): T = apply { + public fun addOriginatingElement(originatingElement: JvmElement): T = apply { originatingElements += originatingElement } as T } @@ -41,10 +43,10 @@ public interface OriginatingElementsHolder { internal fun OriginatingElementsHolder.Builder<*>.buildOriginatingElements() = OriginatingElements(originatingElements.toImmutableList()) -internal fun List.buildOriginatingElements() = +internal fun List.buildOriginatingElements() = OriginatingElements(toImmutableList()) @JvmInline internal value class OriginatingElements( - override val originatingElements: List, + override val originatingElements: List, ) : OriginatingElementsHolder diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.kt index 7eaff62a0d..12639aac13 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.kt @@ -18,11 +18,13 @@ package com.squareup.kotlinpoet import com.squareup.kotlinpoet.KModifier.CROSSINLINE import com.squareup.kotlinpoet.KModifier.NOINLINE import com.squareup.kotlinpoet.KModifier.VARARG -import java.lang.reflect.Type -import javax.lang.model.element.ExecutableElement -import javax.lang.model.element.Modifier -import javax.lang.model.element.VariableElement +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmExecutableElement +import com.squareup.kotlinpoet.jvm.alias.JvmModifier +import com.squareup.kotlinpoet.jvm.alias.JvmType +import com.squareup.kotlinpoet.jvm.alias.JvmVariableElement import kotlin.DeprecationLevel.ERROR +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass /** A generated parameter declaration. */ @@ -73,7 +75,7 @@ public class ParameterSpec private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null) return false - if (javaClass != other.javaClass) return false + if (this::class != other::class) return false return toString() == other.toString() } @@ -115,7 +117,7 @@ public class ParameterSpec private constructor( ReplaceWith(""), level = ERROR, ) - public fun jvmModifiers(@Suppress("UNUSED_PARAMETER", "unused") modifiers: Iterable): Builder = apply { + public fun jvmModifiers(@Suppress("UNUSED_PARAMETER", "unused") modifiers: Iterable): Builder = apply { throw IllegalArgumentException("JVM modifiers are not permitted on parameters in Kotlin") } @@ -141,7 +143,7 @@ public class ParameterSpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - override fun addAnnotation(annotation: Class<*>): Builder = super.addAnnotation(annotation) + override fun addAnnotation(annotation: JvmClass<*>): Builder = super.addAnnotation(annotation) @Suppress("RedundantOverride") override fun addAnnotation(annotation: KClass<*>): Builder = super.addAnnotation(annotation) @@ -162,11 +164,8 @@ public class ParameterSpec private constructor( " the kotlinpoet-metadata APIs instead.", ) @JvmStatic - public fun get(element: VariableElement): ParameterSpec { - val name = element.simpleName.toString() - val type = element.asType().asTypeName() - return builder(name, type) - .build() + public fun get(element: JvmVariableElement): ParameterSpec { + return doGet(element) } @DelicateKotlinPoetApi( @@ -174,8 +173,8 @@ public class ParameterSpec private constructor( " the kotlinpoet-metadata APIs instead.", ) @JvmStatic - public fun parametersOf(method: ExecutableElement): List = - method.parameters.map(::get) + public fun parametersOf(method: JvmExecutableElement): List = + doParametersOf(method) @JvmStatic public fun builder( name: String, @@ -185,7 +184,7 @@ public class ParameterSpec private constructor( return Builder(name, type).addModifiers(*modifiers) } - @JvmStatic public fun builder(name: String, type: Type, vararg modifiers: KModifier): Builder = + @JvmStatic public fun builder(name: String, type: JvmType, vararg modifiers: KModifier): Builder = builder(name, type.asTypeName(), *modifiers) @JvmStatic public fun builder( @@ -204,7 +203,7 @@ public class ParameterSpec private constructor( @JvmStatic public fun builder( name: String, - type: Type, + type: JvmType, modifiers: Iterable, ): Builder = builder(name, type.asTypeName(), modifiers) @@ -216,7 +215,7 @@ public class ParameterSpec private constructor( @JvmStatic public fun unnamed(type: KClass<*>): ParameterSpec = unnamed(type.asTypeName()) - @JvmStatic public fun unnamed(type: Type): ParameterSpec = unnamed(type.asTypeName()) + @JvmStatic public fun unnamed(type: JvmType): ParameterSpec = unnamed(type.asTypeName()) @JvmStatic public fun unnamed(type: TypeName): ParameterSpec = Builder("", type).build() } @@ -254,3 +253,7 @@ internal fun List.emit( } emit(")") } + +internal expect fun doParametersOf(method: JvmExecutableElement): List + +internal expect fun doGet(element: JvmVariableElement): ParameterSpec diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.kt index b6bdf79843..2962be73ba 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.kt @@ -14,17 +14,19 @@ * limitations under the License. */ @file:JvmName("ParameterizedTypeNames") +@file:JvmMultifileClass package com.squareup.kotlinpoet -import java.lang.reflect.Modifier -import java.lang.reflect.ParameterizedType -import java.lang.reflect.Type +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmType +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass import kotlin.reflect.KType import kotlin.reflect.KTypeParameter import kotlin.reflect.KTypeProjection -import kotlin.reflect.KVariance public class ParameterizedTypeName internal constructor( private val enclosingType: TypeName?, @@ -71,7 +73,7 @@ public class ParameterizedTypeName internal constructor( public fun plusParameter(typeArgument: KClass<*>): ParameterizedTypeName = plusParameter(typeArgument.asClassName()) - public fun plusParameter(typeArgument: Class<*>): ParameterizedTypeName = + public fun plusParameter(typeArgument: JvmClass<*>): ParameterizedTypeName = plusParameter(typeArgument.asClassName()) override fun emit(out: CodeWriter): CodeWriter { @@ -105,11 +107,9 @@ public class ParameterizedTypeName internal constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false + if (other !is ParameterizedTypeName) return false if (!super.equals(other)) return false - other as ParameterizedTypeName - if (enclosingType != other.enclosingType) return false if (rawType != other.rawType) return false if (typeArguments != other.typeArguments) return false @@ -144,8 +144,8 @@ public class ParameterizedTypeName internal constructor( /** Returns a parameterized type, applying `typeArguments` to `this`. */ @JvmStatic @JvmName("get") - public fun Class<*>.parameterizedBy( - vararg typeArguments: Type, + public fun JvmClass<*>.parameterizedBy( + vararg typeArguments: JvmType, ): ParameterizedTypeName = ParameterizedTypeName(null, asClassName(), typeArguments.map { it.asTypeName() }) @@ -167,8 +167,8 @@ public class ParameterizedTypeName internal constructor( /** Returns a parameterized type, applying `typeArguments` to `this`. */ @JvmStatic @JvmName("get") - public fun Class<*>.parameterizedBy( - typeArguments: Iterable, + public fun JvmClass<*>.parameterizedBy( + typeArguments: Iterable, ): ParameterizedTypeName = ParameterizedTypeName(null, asClassName(), typeArguments.map { it.asTypeName() }) @@ -189,74 +189,17 @@ public class ParameterizedTypeName internal constructor( /** Returns a parameterized type, applying `typeArgument` to `this`. */ @JvmStatic @JvmName("get") - public fun Class<*>.plusParameter( - typeArgument: Class<*>, + public fun JvmClass<*>.plusParameter( + typeArgument: JvmClass<*>, ): ParameterizedTypeName = parameterizedBy(typeArgument) - - /** Returns a parameterized type equivalent to `type`. */ - internal fun get( - type: ParameterizedType, - map: MutableMap, - ): ParameterizedTypeName { - val rawType = (type.rawType as Class<*>).asClassName() - val ownerType = if (type.ownerType is ParameterizedType && - !Modifier.isStatic((type.rawType as Class<*>).modifiers) - ) { - type.ownerType as ParameterizedType - } else { - null - } - - val typeArguments = type.actualTypeArguments.map { get(it, map = map) } - return if (ownerType != null) { - get(ownerType, map = map).nestedClass(rawType.simpleName, typeArguments) - } else { - ParameterizedTypeName(null, rawType, typeArguments) - } - } - - /** Returns a type name equivalent to type with given list of type arguments. */ - internal fun get( - type: KClass<*>, - nullable: Boolean, - typeArguments: List, - ): TypeName { - if (typeArguments.isEmpty()) { - return type.asTypeName().run { if (nullable) copy(nullable = true) else this } - } - - val effectiveType = if (type.java.isArray) Array::class else type - val enclosingClass = type.java.enclosingClass?.kotlin - - return ParameterizedTypeName( - enclosingClass?.let { - get(it, false, typeArguments.drop(effectiveType.typeParameters.size)) - }, - effectiveType.asTypeName(), - typeArguments.take(effectiveType.typeParameters.size).map { (paramVariance, paramType) -> - val typeName = paramType?.asTypeName() ?: return@map STAR - when (paramVariance) { - null -> STAR - KVariance.INVARIANT -> typeName - KVariance.IN -> WildcardTypeName.consumerOf(typeName) - KVariance.OUT -> WildcardTypeName.producerOf(typeName) - } - }, - nullable, - effectiveType.annotations.map { AnnotationSpec.get(it) }, - ) - } } } -/** Returns a parameterized type equivalent to `type`. */ -@DelicateKotlinPoetApi( - message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + - "using the kotlinpoet-metadata APIs instead.", -) -@JvmName("get") -public fun ParameterizedType.asParameterizedTypeName(): ParameterizedTypeName = - ParameterizedTypeName.get(this, mutableMapOf()) +internal expect fun ParameterizedTypeName.Companion.get( + type: KClass<*>, + nullable: Boolean, + typeArguments: List, +): TypeName /** * Returns a [TypeName] equivalent to the given Kotlin KType using reflection, maybe using kotlin-reflect diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/PropertySpec.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/PropertySpec.kt index be903e6b3a..a79caedc14 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/PropertySpec.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/PropertySpec.kt @@ -18,9 +18,11 @@ package com.squareup.kotlinpoet import com.squareup.kotlinpoet.FunSpec.Companion.GETTER import com.squareup.kotlinpoet.FunSpec.Companion.SETTER import com.squareup.kotlinpoet.KModifier.Target.PROPERTY -import java.lang.reflect.Type -import java.util.EnumSet -import javax.lang.model.element.Element +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmElement +import com.squareup.kotlinpoet.jvm.alias.JvmType +import kotlin.jvm.JvmOverloads +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass /** A generated property declaration. */ @@ -106,7 +108,7 @@ public class PropertySpec private constructor( } codeWriter.emitWhereBlock(typeVariables) if (!inline) codeWriter.emit("\n") - val implicitAccessorModifiers = EnumSet.noneOf(KModifier::class.java) + val implicitAccessorModifiers = enumSetOf() for (modifier in implicitModifiers) { // Omit visibility modifiers, accessor visibility will default to the property's visibility. if (modifier !in VISIBILITY_MODIFIERS) { @@ -142,7 +144,7 @@ public class PropertySpec private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null) return false - if (javaClass != other.javaClass) return false + if (this::class != other::class) return false return toString() == other.toString() } @@ -189,7 +191,7 @@ public class PropertySpec private constructor( public val typeVariables: MutableList = mutableListOf() override val tags: MutableMap, Any> = mutableMapOf() override val kdoc: CodeBlock.Builder = CodeBlock.builder() - override val originatingElements: MutableList = mutableListOf() + override val originatingElements: MutableList = mutableListOf() override val annotations: MutableList = mutableListOf() @ExperimentalKotlinPoetApi @@ -250,7 +252,7 @@ public class PropertySpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - public fun receiver(receiverType: Type): Builder = receiver(receiverType.asTypeName()) + public fun receiver(receiverType: JvmType): Builder = receiver(receiverType.asTypeName()) public fun receiver(receiverType: KClass<*>): Builder = receiver(receiverType.asTypeName()) @@ -269,7 +271,7 @@ public class PropertySpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - override fun addAnnotation(annotation: Class<*>): Builder = super.addAnnotation(annotation) + override fun addAnnotation(annotation: JvmClass<*>): Builder = super.addAnnotation(annotation) @Suppress("RedundantOverride") override fun addAnnotation(annotation: KClass<*>): Builder = super.addAnnotation(annotation) @@ -304,7 +306,7 @@ public class PropertySpec private constructor( return Builder(name, type).addModifiers(*modifiers) } - @JvmStatic public fun builder(name: String, type: Type, vararg modifiers: KModifier): Builder = + @JvmStatic public fun builder(name: String, type: JvmType, vararg modifiers: KModifier): Builder = builder(name, type.asTypeName(), *modifiers) @JvmStatic public fun builder( @@ -328,7 +330,7 @@ public class PropertySpec private constructor( @JvmStatic public fun builder( name: String, - type: Type, + type: JvmType, modifiers: Iterable, ): Builder = builder(name, type.asTypeName(), modifiers) diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Taggable.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Taggable.kt index f3313aeadc..3033a4e807 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Taggable.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Taggable.kt @@ -15,6 +15,10 @@ */ package com.squareup.kotlinpoet +import com.squareup.kotlinpoet.jvm.JvmDefaultWithCompatibility +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.kotlin +import kotlin.jvm.JvmInline import kotlin.reflect.KClass /** A type that can be tagged with extra metadata of the user's choice. */ @@ -25,7 +29,7 @@ public interface Taggable { public val tags: Map, Any> get() = emptyMap() /** Returns the tag attached with [type] as a key, or null if no tag is attached with that key. */ - public fun tag(type: Class): T? = tag(type.kotlin) + public fun tag(type: JvmClass): T? = tag(type.kotlin) /** Returns the tag attached with [type] as a key, or null if no tag is attached with that key. */ public fun tag(type: KClass): T? { @@ -48,7 +52,7 @@ public interface Taggable { * Use this API to attach originating elements, debugging, or other application data to a spec * so that you may read it in other APIs or callbacks. */ - public fun tag(type: Class<*>, tag: Any?): T = tag(type.kotlin, tag) + public fun tag(type: JvmClass<*>, tag: Any?): T = tag(type.kotlin, tag) /** * Attaches [tag] to the request using [type] as a key. Tags can be read from a diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeAliasSpec.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeAliasSpec.kt index f9a607fba8..9530997456 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeAliasSpec.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeAliasSpec.kt @@ -19,7 +19,10 @@ import com.squareup.kotlinpoet.KModifier.ACTUAL import com.squareup.kotlinpoet.KModifier.INTERNAL import com.squareup.kotlinpoet.KModifier.PRIVATE import com.squareup.kotlinpoet.KModifier.PUBLIC -import java.lang.reflect.Type +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmType +import kotlin.jvm.JvmOverloads +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass /** A generated typealias declaration */ @@ -47,7 +50,7 @@ public class TypeAliasSpec private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null) return false - if (javaClass != other.javaClass) return false + if (this::class != other::class) return false return toString() == other.toString() } @@ -111,7 +114,7 @@ public class TypeAliasSpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - override fun addAnnotation(annotation: Class<*>): Builder = super.addAnnotation(annotation) + override fun addAnnotation(annotation: JvmClass<*>): Builder = super.addAnnotation(annotation) @Suppress("RedundantOverride") override fun addAnnotation(annotation: KClass<*>): Builder = super.addAnnotation(annotation) @@ -145,7 +148,7 @@ public class TypeAliasSpec private constructor( "using the kotlinpoet-metadata APIs instead.", ) @JvmStatic - public fun builder(name: String, type: Type): Builder = + public fun builder(name: String, type: JvmType): Builder = builder(name, type.asTypeName()) @JvmStatic public fun builder(name: String, type: KClass<*>): Builder = diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeName.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeName.kt index 60dea8bf6c..6acefb31ad 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeName.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeName.kt @@ -14,26 +14,16 @@ * limitations under the License. */ @file:JvmName("TypeNames") +// @file:JvmMultifileClass +// Can't use JvmMultifileClass because of +// err: JvmField can't be applied to top level property of a file annotated with JvmMultifileClass package com.squareup.kotlinpoet -import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy -import java.lang.reflect.GenericArrayType -import java.lang.reflect.ParameterizedType -import java.lang.reflect.Type -import java.lang.reflect.TypeVariable -import java.lang.reflect.WildcardType -import javax.lang.model.element.Modifier -import javax.lang.model.element.TypeElement -import javax.lang.model.element.TypeParameterElement -import javax.lang.model.type.ArrayType -import javax.lang.model.type.DeclaredType -import javax.lang.model.type.ErrorType -import javax.lang.model.type.NoType -import javax.lang.model.type.PrimitiveType -import javax.lang.model.type.TypeKind -import javax.lang.model.type.TypeMirror -import javax.lang.model.util.SimpleTypeVisitor8 +import com.squareup.kotlinpoet.jvm.alias.JvmType +import com.squareup.kotlinpoet.jvm.alias.JvmTypeMirror +import kotlin.jvm.JvmField +import kotlin.jvm.JvmName import kotlin.reflect.KClass import kotlin.reflect.typeOf @@ -95,9 +85,7 @@ public sealed class TypeName constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as TypeName + if (other !is TypeName) return false if (isNullable != other.isNullable) return false if (annotations != other.annotations) return false @@ -130,105 +118,6 @@ public sealed class TypeName constructor( } public companion object { - internal fun get( - mirror: TypeMirror, - typeVariables: Map, - ): TypeName { - return mirror.accept( - object : SimpleTypeVisitor8() { - override fun visitPrimitive(t: PrimitiveType, p: Void?): TypeName { - return when (t.kind) { - TypeKind.BOOLEAN -> BOOLEAN - TypeKind.BYTE -> BYTE - TypeKind.SHORT -> SHORT - TypeKind.INT -> INT - TypeKind.LONG -> LONG - TypeKind.CHAR -> CHAR - TypeKind.FLOAT -> FLOAT - TypeKind.DOUBLE -> DOUBLE - else -> throw AssertionError() - } - } - - override fun visitDeclared(t: DeclaredType, p: Void?): TypeName { - val rawType: ClassName = (t.asElement() as TypeElement).asClassName() - val enclosingType = t.enclosingType - val enclosing = if (enclosingType.kind != TypeKind.NONE && - Modifier.STATIC !in t.asElement().modifiers - ) { - enclosingType.accept(this, null) - } else { - null - } - if (t.typeArguments.isEmpty() && enclosing !is ParameterizedTypeName) { - return rawType - } - - val typeArgumentNames = mutableListOf() - for (typeArgument in t.typeArguments) { - typeArgumentNames += get(typeArgument, typeVariables) - } - return if (enclosing is ParameterizedTypeName) { - enclosing.nestedClass(rawType.simpleName, typeArgumentNames) - } else { - ParameterizedTypeName(null, rawType, typeArgumentNames) - } - } - - override fun visitError(t: ErrorType, p: Void?): TypeName { - return visitDeclared(t, p) - } - - override fun visitArray(t: ArrayType, p: Void?): ParameterizedTypeName { - return ARRAY.parameterizedBy(get(t.componentType, typeVariables)) - } - - override fun visitTypeVariable( - t: javax.lang.model.type.TypeVariable, - p: Void?, - ): TypeName { - return TypeVariableName.get(t, typeVariables.toMutableMap()) - } - - override fun visitWildcard(t: javax.lang.model.type.WildcardType, p: Void?): TypeName { - return WildcardTypeName.get(t, typeVariables) - } - - override fun visitNoType(t: NoType, p: Void?): TypeName { - if (t.kind == TypeKind.VOID) return UNIT - return super.visitUnknown(t, p) - } - - override fun defaultAction(e: TypeMirror?, p: Void?): TypeName { - throw IllegalArgumentException("Unexpected type mirror: " + e!!) - } - }, - null, - ) - } - - internal fun get(type: Type, map: MutableMap): TypeName { - return when (type) { - is Class<*> -> when { - type === Void.TYPE -> UNIT - type === Boolean::class.javaPrimitiveType -> BOOLEAN - type === Byte::class.javaPrimitiveType -> BYTE - type === Short::class.javaPrimitiveType -> SHORT - type === Int::class.javaPrimitiveType -> INT - type === Long::class.javaPrimitiveType -> LONG - type === Char::class.javaPrimitiveType -> CHAR - type === Float::class.javaPrimitiveType -> FLOAT - type === Double::class.javaPrimitiveType -> DOUBLE - type.isArray -> ARRAY.parameterizedBy(get(type.componentType, map)) - else -> type.asClassName() - } - is ParameterizedType -> ParameterizedTypeName.get(type, map) - is WildcardType -> WildcardTypeName.get(type, map) - is TypeVariable<*> -> TypeVariableName.get(type, map) - is GenericArrayType -> ARRAY.parameterizedBy(get(type.genericComponentType, map)) - else -> throw IllegalArgumentException("unexpected type: $type") - } - } } } @@ -334,21 +223,26 @@ public sealed class TypeName constructor( /** [Dynamic] is a singleton `object` type, so this is a shorthand for it in Java. */ @JvmField public val DYNAMIC: Dynamic = Dynamic -/** Returns a [TypeName] equivalent to this [TypeMirror]. */ +/** Returns a [TypeName] equivalent to this [JvmTypeMirror]. */ @DelicateKotlinPoetApi( message = "Mirror APIs don't give complete information on Kotlin types. Consider using" + " the kotlinpoet-metadata APIs instead.", ) @JvmName("get") -public fun TypeMirror.asTypeName(): TypeName = TypeName.get(this, mutableMapOf()) +public fun JvmTypeMirror.asTypeName(): TypeName = asTypeNameInternal() /** Returns a [TypeName] equivalent to this [KClass]. */ @JvmName("get") public fun KClass<*>.asTypeName(): ClassName = asClassName() -/** Returns a [TypeName] equivalent to this [Type]. */ +/** Returns a [TypeName] equivalent to this [JvmType]. */ @JvmName("get") -public fun Type.asTypeName(): TypeName = TypeName.get(this, mutableMapOf()) +public fun JvmType.asTypeName(): TypeName = asTypeNameInternal() + +internal expect fun JvmTypeMirror.asTypeNameInternal(): TypeName + +/** Returns a [TypeName] equivalent to this [JvmType]. */ +internal expect fun JvmType.asTypeNameInternal(): TypeName /** * Returns a [TypeName] equivalent of the reified type parameter [T] using reflection, maybe using kotlin-reflect diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeSpec.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeSpec.kt index de077a716c..c70aa1cdba 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeSpec.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeSpec.kt @@ -29,9 +29,12 @@ import com.squareup.kotlinpoet.KModifier.PROTECTED import com.squareup.kotlinpoet.KModifier.PUBLIC import com.squareup.kotlinpoet.KModifier.SEALED import com.squareup.kotlinpoet.KModifier.VALUE -import java.lang.reflect.Type -import javax.lang.model.element.Element +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmElement +import com.squareup.kotlinpoet.jvm.alias.JvmType import kotlin.DeprecationLevel.ERROR +import kotlin.jvm.JvmOverloads +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass /** A generated class, interface, or enum declaration. */ @@ -422,7 +425,7 @@ public class TypeSpec private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null) return false - if (javaClass != other.javaClass) return false + if (this::class != other::class) return false return toString() == other.toString() } @@ -494,7 +497,7 @@ public class TypeSpec private constructor( override val tags: MutableMap, Any> = mutableMapOf() override val kdoc: CodeBlock.Builder = CodeBlock.builder() - override val originatingElements: MutableList = mutableListOf() + override val originatingElements: MutableList = mutableListOf() override val annotations: MutableList = mutableListOf() @ExperimentalKotlinPoetApi @@ -582,7 +585,7 @@ public class TypeSpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - public fun superclass(superclass: Type): Builder = superclass(superclass.asTypeName()) + public fun superclass(superclass: JvmType): Builder = superclass(superclass.asTypeName()) public fun superclass(superclass: KClass<*>): Builder = superclass(superclass.asTypeName()) @@ -628,7 +631,7 @@ public class TypeSpec private constructor( "using the kotlinpoet-metadata APIs instead.", ) public fun addSuperinterface( - superinterface: Type, + superinterface: JvmType, delegate: CodeBlock = CodeBlock.EMPTY, ): Builder = addSuperinterface(superinterface.asTypeName(), delegate) @@ -725,7 +728,7 @@ public class TypeSpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - override fun addAnnotation(annotation: Class<*>): Builder = super.addAnnotation(annotation) + override fun addAnnotation(annotation: JvmClass<*>): Builder = super.addAnnotation(annotation) @Suppress("RedundantOverride") override fun addAnnotation(annotation: KClass<*>): Builder = super.addAnnotation(annotation) @@ -751,7 +754,7 @@ public class TypeSpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - override fun addProperty(name: String, type: Type, vararg modifiers: KModifier): Builder = + override fun addProperty(name: String, type: JvmType, vararg modifiers: KModifier): Builder = super.addProperty(name, type, *modifiers) @Suppress("RedundantOverride") @@ -766,7 +769,7 @@ public class TypeSpec private constructor( message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + "using the kotlinpoet-metadata APIs instead.", ) - override fun addProperty(name: String, type: Type, modifiers: Iterable): Builder = + override fun addProperty(name: String, type: JvmType, modifiers: Iterable): Builder = super.addProperty(name, type, modifiers) @Suppress("RedundantOverride") diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeVariableName.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeVariableName.kt index 3313b2c9ee..67c88b6deb 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeVariableName.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/TypeVariableName.kt @@ -14,14 +14,15 @@ * limitations under the License. */ @file:JvmName("TypeVariableNames") +@file:JvmMultifileClass package com.squareup.kotlinpoet -import java.lang.reflect.Type -import java.util.Collections -import javax.lang.model.element.TypeParameterElement -import javax.lang.model.type.TypeMirror -import javax.lang.model.type.TypeVariable +import com.squareup.kotlinpoet.jvm.alias.JvmType +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName +import kotlin.jvm.JvmOverloads +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass import kotlin.reflect.KType import kotlin.reflect.KTypeParameter @@ -73,11 +74,9 @@ public class TypeVariableName private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false + if (other !is TypeVariableName) return false if (!super.equals(other)) return false - other as TypeVariableName - if (name != other.name) return false if (bounds != other.bounds) return false if (variance != other.variance) return false @@ -154,12 +153,12 @@ public class TypeVariableName private constructor( @JvmOverloads public operator fun invoke( name: String, - vararg bounds: Type, + vararg bounds: JvmType, variance: KModifier? = null, ): TypeVariableName = of( name = name, - bounds = bounds.map(Type::asTypeName).ifEmpty(::NULLABLE_ANY_LIST), + bounds = bounds.map(JvmType::asTypeName).ifEmpty(::NULLABLE_ANY_LIST), variance = variance, ) @@ -194,7 +193,7 @@ public class TypeVariableName private constructor( @JvmOverloads public operator fun invoke( name: String, - bounds: Iterable, + bounds: Iterable, variance: KModifier? = null, ): TypeVariableName = of( @@ -203,89 +202,10 @@ public class TypeVariableName private constructor( variance, ) - /** - * Make a TypeVariableName for the given TypeMirror. This form is used internally to avoid - * infinite recursion in cases like `Enum>`. When we encounter such a - * thing, we will make a TypeVariableName without bounds and add that to the `typeVariables` - * map before looking up the bounds. Then if we encounter this TypeVariable again while - * constructing the bounds, we can just return it from the map. And, the code that put the entry - * in `variables` will make sure that the bounds are filled in before returning. - */ - internal fun get( - mirror: javax.lang.model.type.TypeVariable, - typeVariables: MutableMap, - ): TypeVariableName { - val element = mirror.asElement() as TypeParameterElement - var typeVariableName: TypeVariableName? = typeVariables[element] - if (typeVariableName == null) { - // Since the bounds field is public, we need to make it an unmodifiableList. But we control - // the List that that wraps, which means we can change it before returning. - val bounds = mutableListOf() - val visibleBounds = Collections.unmodifiableList(bounds) - typeVariableName = TypeVariableName(element.simpleName.toString(), visibleBounds) - typeVariables[element] = typeVariableName - for (typeMirror in element.bounds) { - bounds += get(typeMirror, typeVariables) - } - bounds.remove(ANY) - bounds.remove(JAVA_OBJECT) - if (bounds.isEmpty()) { - bounds.add(NULLABLE_ANY) - } - } - return typeVariableName - } - - /** Returns type variable equivalent to `type`. */ - internal fun get( - type: java.lang.reflect.TypeVariable<*>, - map: MutableMap = mutableMapOf(), - ): TypeVariableName { - var result: TypeVariableName? = map[type] - if (result == null) { - val bounds = mutableListOf() - val visibleBounds = Collections.unmodifiableList(bounds) - result = TypeVariableName(type.name, visibleBounds) - map[type] = result - for (bound in type.bounds) { - bounds += get(bound, map) - } - bounds.remove(ANY) - bounds.remove(JAVA_OBJECT) - if (bounds.isEmpty()) { - bounds.add(NULLABLE_ANY) - } - } - return result - } - internal val NULLABLE_ANY_LIST = listOf(NULLABLE_ANY) - private val JAVA_OBJECT = ClassName("java.lang", "Object") } } -/** Returns type variable equivalent to `mirror`. */ -@DelicateKotlinPoetApi( - message = "Java reflection APIs don't give complete information on Kotlin types. Consider using" + - " the kotlinpoet-metadata APIs instead.", -) -@JvmName("get") -public fun TypeVariable.asTypeVariableName(): TypeVariableName = - (asElement() as TypeParameterElement).asTypeVariableName() - -/** Returns type variable equivalent to `element`. */ -@DelicateKotlinPoetApi( - message = "Element APIs don't give complete information on Kotlin types. Consider using" + - " the kotlinpoet-metadata APIs instead.", -) -@JvmName("get") -public fun TypeParameterElement.asTypeVariableName(): TypeVariableName { - val name = simpleName.toString() - val boundsTypeNames = bounds.map(TypeMirror::asTypeName) - .ifEmpty(TypeVariableName.Companion::NULLABLE_ANY_LIST) - return TypeVariableName.of(name, boundsTypeNames, variance = null) -} - public fun KTypeParameter.asTypeVariableName(): TypeVariableName { return TypeVariableName.of( name = name, diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Util.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Util.kt index d5d28810f1..61cf396859 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Util.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Util.kt @@ -16,22 +16,19 @@ package com.squareup.kotlinpoet import com.squareup.kotlinpoet.CodeBlock.Companion.isPlaceholder -import java.util.Collections +import kotlin.reflect.KClass internal object NullAppendable : Appendable { - override fun append(charSequence: CharSequence) = this - override fun append(charSequence: CharSequence, start: Int, end: Int) = this + override fun append(charSequence: CharSequence?) = this + override fun append(charSequence: CharSequence?, start: Int, end: Int) = this override fun append(c: Char) = this } -internal fun Map.toImmutableMap(): Map = - Collections.unmodifiableMap(LinkedHashMap(this)) +internal expect fun Map.toImmutableMap(): Map -internal fun Collection.toImmutableList(): List = - Collections.unmodifiableList(ArrayList(this)) +internal expect fun Collection.toImmutableList(): List -internal fun Collection.toImmutableSet(): Set = - Collections.unmodifiableSet(LinkedHashSet(this)) +internal expect fun Collection.toImmutableSet(): Set internal inline fun > Collection.toEnumSet(): Set = enumValues().filterTo(mutableSetOf(), this::contains) @@ -63,10 +60,21 @@ internal fun characterLiteralWithoutSingleQuotes(c: Char) = when { c == '\"' -> "\"" // \u0022: double quote (") c == '\'' -> "\\'" // \u0027: single quote (') c == '\\' -> "\\\\" // \u005c: backslash (\) - c.isIsoControl -> String.format("\\u%04x", c.code) + c.isIsoControl -> formatIsoControlCode(c.code) else -> c.toString() } +internal expect fun formatIsoControlCode(code: Int): String + +@ExperimentalStdlibApi +internal val HexFormatWithoutLeadingZeros = HexFormat { + number { + removeLeadingZeros = true + } +} + +internal expect fun Int.toHexStr(): String + internal fun escapeCharacterLiterals(s: String) = buildString { for (c in s) append(characterLiteralWithoutSingleQuotes(c)) } @@ -165,7 +173,14 @@ internal fun CodeBlock.trimTrailingNewLine(replaceWith: Char? = null) = if (isEm } } -private val IDENTIFIER_REGEX = +// TODO Will crash if used `IDENTIFIER_REGEX_VALUE.toRegex()` directly in WasmJs :( +// -> PatternSyntaxException: No such character class +// It works in JS and JVM. +// So I tried: +// Keep the use of Regex in JVM and JS +// and use RegExp directly in WasmJs for matching, +// using it in a similar way as in JS. +internal const val IDENTIFIER_REGEX_VALUE = ( "((\\p{gc=Lu}+|\\p{gc=Ll}+|\\p{gc=Lt}+|\\p{gc=Lm}+|\\p{gc=Lo}+|\\p{gc=Nl}+)+" + "\\d*" + @@ -173,9 +188,8 @@ private val IDENTIFIER_REGEX = "|" + "(`[^\n\r`]+`)" ) - .toRegex() -internal val String.isIdentifier get() = IDENTIFIER_REGEX.matches(this) +internal expect val String.isIdentifier: Boolean // https://kotlinlang.org/docs/reference/keyword-reference.html internal val KEYWORDS = setOf( @@ -317,7 +331,7 @@ internal fun String.escapeAsAlias(validate: Boolean = true): String { val newAlias = StringBuilder("") - if (!Character.isJavaIdentifierStart(first())) { + if (!first().isJavaIdentifierStart()) { newAlias.append('_') } @@ -327,8 +341,8 @@ internal fun String.escapeAsAlias(validate: Boolean = true): String { continue } - if (!Character.isJavaIdentifierPart(ch)) { - newAlias.append("_U").append(Integer.toHexString(ch.code).padStart(4, '0')) + if (!ch.isJavaIdentifierPart()) { + newAlias.append("_U").append(ch.code.toHexStr().padStart(4, '0')) continue } @@ -348,8 +362,8 @@ private fun String.escapeIfAllCharactersAreUnderscore() = if (allCharactersAreUn private fun String.escapeIfNotJavaIdentifier(): String { return if (( - !Character.isJavaIdentifierStart(first()) || - drop(1).any { !Character.isJavaIdentifierPart(it) } + !first().isJavaIdentifierStart() || + drop(1).any { !it.isJavaIdentifierPart() } ) && !alreadyEscaped() ) { @@ -362,3 +376,15 @@ private fun String.escapeIfNotJavaIdentifier(): String { internal fun String.escapeSegmentsIfNecessary(delimiter: Char = '.') = split(delimiter) .filter { it.isNotEmpty() } .joinToString(delimiter.toString()) { it.escapeIfNecessary() } + +internal expect fun > Sequence.toSortedSet(): Set +internal expect fun > List.toSortedSet(): Set +internal expect fun > sortedSetOf(): MutableSet + +internal expect inline fun > enumSetOf(vararg values: E): MutableSet + +internal expect fun KClass<*>.enclosingClass(): KClass<*>? + +internal expect fun Char.isJavaIdentifierStart(): Boolean + +internal expect fun Char.isJavaIdentifierPart(): Boolean diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/WildcardTypeName.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/WildcardTypeName.kt index bd1e0965e9..0d2b343893 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/WildcardTypeName.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/WildcardTypeName.kt @@ -14,15 +14,17 @@ * limitations under the License. */ @file:JvmName("WildcardTypeNames") +@file:JvmMultifileClass package com.squareup.kotlinpoet -import java.lang.reflect.Type -import java.lang.reflect.WildcardType -import javax.lang.model.element.TypeParameterElement +import com.squareup.kotlinpoet.jvm.alias.JvmType +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName +import kotlin.jvm.JvmStatic import kotlin.reflect.KClass -public class WildcardTypeName private constructor( +public class WildcardTypeName internal constructor( outTypes: List, inTypes: List, nullable: Boolean = false, @@ -54,11 +56,9 @@ public class WildcardTypeName private constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false + if (other !is WildcardTypeName) return false if (!super.equals(other)) return false - other as WildcardTypeName - if (outTypes != other.outTypes) return false if (inTypes != other.inTypes) return false @@ -86,7 +86,7 @@ public class WildcardTypeName private constructor( "using the kotlinpoet-metadata APIs instead.", ) @JvmStatic - public fun producerOf(outType: Type): WildcardTypeName = + public fun producerOf(outType: JvmType): WildcardTypeName = producerOf(outType.asTypeName()) @JvmStatic public fun producerOf(outType: KClass<*>): WildcardTypeName = @@ -104,53 +104,10 @@ public class WildcardTypeName private constructor( "using the kotlinpoet-metadata APIs instead.", ) @JvmStatic - public fun consumerOf(inType: Type): WildcardTypeName = + public fun consumerOf(inType: JvmType): WildcardTypeName = consumerOf(inType.asTypeName()) @JvmStatic public fun consumerOf(inType: KClass<*>): WildcardTypeName = consumerOf(inType.asTypeName()) - - internal fun get( - mirror: javax.lang.model.type.WildcardType, - typeVariables: Map, - ): TypeName { - val outType = mirror.extendsBound - return if (outType == null) { - val inType = mirror.superBound - if (inType == null) { - STAR - } else { - consumerOf(get(inType, typeVariables)) - } - } else { - producerOf(get(outType, typeVariables)) - } - } - - internal fun get( - wildcardName: WildcardType, - map: MutableMap, - ): TypeName { - return WildcardTypeName( - wildcardName.upperBounds.map { get(it, map = map) }, - wildcardName.lowerBounds.map { get(it, map = map) }, - ) - } } } - -@DelicateKotlinPoetApi( - message = "Mirror APIs don't give complete information on Kotlin types. Consider using" + - " the kotlinpoet-metadata APIs instead.", -) -@JvmName("get") -public fun javax.lang.model.type.WildcardType.asWildcardTypeName(): TypeName = - WildcardTypeName.get(this, mutableMapOf()) - -@DelicateKotlinPoetApi( - message = "Java reflection APIs don't give complete information on Kotlin types. Consider using" + - " the kotlinpoet-metadata APIs instead.", -) -@JvmName("get") -public fun WildcardType.asWildcardTypeName(): TypeName = - WildcardTypeName.get(this, mutableMapOf()) diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/JvmAnnotations.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/JvmAnnotations.kt index fcaae681a3..b4bf03e7fa 100644 --- a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/JvmAnnotations.kt +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/JvmAnnotations.kt @@ -23,22 +23,37 @@ import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.FunSpec.Companion.isAccessor import com.squareup.kotlinpoet.FunSpec.Companion.isConstructor +import com.squareup.kotlinpoet.JvmFieldClassName +import com.squareup.kotlinpoet.JvmInlineClassName +import com.squareup.kotlinpoet.JvmMultifileClassClassName +import com.squareup.kotlinpoet.JvmNameClassName +import com.squareup.kotlinpoet.JvmOverloadsClassName +import com.squareup.kotlinpoet.JvmRecordClassName +import com.squareup.kotlinpoet.JvmStaticClassName +import com.squareup.kotlinpoet.JvmSuppressWildcardsClassName +import com.squareup.kotlinpoet.JvmThrowsClassName +import com.squareup.kotlinpoet.JvmVolatileClassName +import com.squareup.kotlinpoet.JvmWildcardClassName import com.squareup.kotlinpoet.PropertySpec +import com.squareup.kotlinpoet.StrictfpClassName +import com.squareup.kotlinpoet.SynchronizedClassName +import com.squareup.kotlinpoet.TransientClassName import com.squareup.kotlinpoet.TypeName import com.squareup.kotlinpoet.TypeSpec import com.squareup.kotlinpoet.asTypeName -import java.lang.reflect.Type +import com.squareup.kotlinpoet.jvm.alias.JvmType +import kotlin.jvm.JvmName import kotlin.reflect.KClass public fun FileSpec.Builder.jvmName(name: String): FileSpec.Builder = addAnnotation( - AnnotationSpec.builder(JvmName::class) + AnnotationSpec.builder(JvmNameClassName) .useSiteTarget(FILE) .addMember("%S", name) .build(), ) public fun FileSpec.Builder.jvmMultifileClass(): FileSpec.Builder = addAnnotation( - AnnotationSpec.builder(JvmMultifileClass::class) + AnnotationSpec.builder(JvmMultifileClassClassName) .useSiteTarget(FILE) .build(), ) @@ -47,30 +62,30 @@ public fun TypeSpec.Builder.jvmSuppressWildcards(suppress: Boolean = true): Type addAnnotation(jvmSuppressWildcardsAnnotation(suppress)) private fun jvmSuppressWildcardsAnnotation(suppress: Boolean = true) = - AnnotationSpec.builder(JvmSuppressWildcards::class) + AnnotationSpec.builder(JvmSuppressWildcardsClassName) .apply { if (!suppress) addMember("suppress = false") } .build() -public fun TypeSpec.Builder.jvmInline(): TypeSpec.Builder = addAnnotation(JvmInline::class) +public fun TypeSpec.Builder.jvmInline(): TypeSpec.Builder = addAnnotation(JvmInlineClassName) -public fun TypeSpec.Builder.jvmRecord(): TypeSpec.Builder = addAnnotation(JvmRecord::class) +public fun TypeSpec.Builder.jvmRecord(): TypeSpec.Builder = addAnnotation(JvmRecordClassName) public fun FunSpec.Builder.jvmStatic(): FunSpec.Builder = apply { check(!name.isConstructor) { "Can't apply @JvmStatic to a constructor!" } - addAnnotation(JvmStatic::class) + addAnnotation(JvmStaticClassName) } public fun FunSpec.Builder.jvmOverloads(): FunSpec.Builder = apply { check(!name.isAccessor) { "Can't apply @JvmOverloads to a " + if (name == FunSpec.GETTER) "getter!" else "setter!" } - addAnnotation(JvmOverloads::class) + addAnnotation(JvmOverloadsClassName) } public fun FunSpec.Builder.jvmName(name: String): FunSpec.Builder = apply { check(!this.name.isConstructor) { "Can't apply @JvmName to a constructor!" } addAnnotation( - AnnotationSpec.builder(JvmName::class) + AnnotationSpec.builder(JvmNameClassName) .addMember("%S", name) .build(), ) @@ -79,15 +94,15 @@ public fun FunSpec.Builder.jvmName(name: String): FunSpec.Builder = apply { public fun FunSpec.Builder.throws(vararg exceptionClasses: KClass): FunSpec.Builder = throws(exceptionClasses.map(KClass<*>::asTypeName)) -public fun FunSpec.Builder.throws(vararg exceptionClasses: Type): FunSpec.Builder = - throws(exceptionClasses.map(Type::asTypeName)) +public fun FunSpec.Builder.throws(vararg exceptionClasses: JvmType): FunSpec.Builder = + throws(exceptionClasses.map(JvmType::asTypeName)) public fun FunSpec.Builder.throws(vararg exceptionClasses: TypeName): FunSpec.Builder = throws(exceptionClasses.toList()) public fun FunSpec.Builder.throws(exceptionClasses: Iterable): FunSpec.Builder = addAnnotation( - AnnotationSpec.builder(Throws::class) + AnnotationSpec.builder(JvmThrowsClassName) .apply { exceptionClasses.forEach { addMember("%T::class", it) } } .build(), ) @@ -102,28 +117,28 @@ public fun FunSpec.Builder.jvmSuppressWildcards(suppress: Boolean = true): FunSp public fun FunSpec.Builder.synchronized(): FunSpec.Builder = apply { check(!name.isConstructor) { "Can't apply @Synchronized to a constructor!" } - addAnnotation(Synchronized::class) + addAnnotation(SynchronizedClassName) } -public fun FunSpec.Builder.strictfp(): FunSpec.Builder = addAnnotation(Strictfp::class) +public fun FunSpec.Builder.strictfp(): FunSpec.Builder = addAnnotation(StrictfpClassName) -public fun PropertySpec.Builder.jvmField(): PropertySpec.Builder = addAnnotation(JvmField::class) +public fun PropertySpec.Builder.jvmField(): PropertySpec.Builder = addAnnotation(JvmFieldClassName) -public fun PropertySpec.Builder.jvmStatic(): PropertySpec.Builder = addAnnotation(JvmStatic::class) +public fun PropertySpec.Builder.jvmStatic(): PropertySpec.Builder = addAnnotation(JvmStaticClassName) public fun PropertySpec.Builder.jvmSuppressWildcards( suppress: Boolean = true, ): PropertySpec.Builder = addAnnotation(jvmSuppressWildcardsAnnotation(suppress)) -public fun PropertySpec.Builder.transient(): PropertySpec.Builder = addAnnotation(Transient::class) +public fun PropertySpec.Builder.transient(): PropertySpec.Builder = addAnnotation(TransientClassName) -public fun PropertySpec.Builder.volatile(): PropertySpec.Builder = addAnnotation(Volatile::class) +public fun PropertySpec.Builder.volatile(): PropertySpec.Builder = addAnnotation(JvmVolatileClassName) public fun TypeName.jvmSuppressWildcards(suppress: Boolean = true): TypeName = copy(annotations = this.annotations + jvmSuppressWildcardsAnnotation(suppress)) public fun TypeName.jvmWildcard(): TypeName = - copy(annotations = this.annotations + AnnotationSpec.builder(JvmWildcard::class).build()) + copy(annotations = this.annotations + AnnotationSpec.builder(JvmWildcardClassName).build()) @Suppress("DEPRECATION") @Deprecated( diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/JvmDefaultWithCompatibility.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/JvmDefaultWithCompatibility.kt new file mode 100644 index 0000000000..58cf120986 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/JvmDefaultWithCompatibility.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm + +/** + * A typealias annotation for [kotlin.jvm.JvmDefaultWithCompatibility]. + */ +@OptIn(ExperimentalMultiplatform::class) +@OptionalExpectation +public expect annotation class JvmDefaultWithCompatibility() diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.kt new file mode 100644 index 0000000000..9b19a1353c --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `javax.lang.model.element.AnnotationMirror`. + * + * @author ForteScarlet + */ +public expect interface JvmAnnotationMirror diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.kt new file mode 100644 index 0000000000..4870f45284 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.kt @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("JvmClasses") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet.jvm.alias + +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName +import kotlin.reflect.KClass + +/** + * An expected typealias for `java.lang.reflect.Type`. + * + * @author ForteScarlet + */ +public expect interface JvmType + +public expect fun JvmType.typeName(): String + +/** + * An expected typealias for `java.lang.Class`. + * + * @author ForteScarlet + */ +public expect class JvmClass< + @Suppress("unused") + T : Any, + > : JvmType + +/** + * Convert [JvmClass] to [KClass]. + */ +public expect val JvmClass.kotlin: KClass diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.kt new file mode 100644 index 0000000000..a422dcb69c --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `javax.lang.model.type.DeclaredType`. + * + * @author ForteScarlet + */ +public expect interface JvmDeclaredType diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.kt new file mode 100644 index 0000000000..238a5ec8ad --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `javax.lang.model.element.Element`. + * + * @author ForteScarlet + */ +public expect interface JvmElement + +/** + * An expected typealias for `javax.lang.model.element.TypeElement`. + * + * @author ForteScarlet + */ +public expect interface JvmTypeElement : JvmElement + +/** + * An expected typealias for `javax.lang.model.element.ExecutableElement`. + * + * @author ForteScarlet + */ +public expect interface JvmExecutableElement : JvmElement + +/** + * An expected typealias for `javax.lang.model.element.VariableElement`. + * + * @author ForteScarlet + */ +public expect interface JvmVariableElement : JvmElement diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.kt new file mode 100644 index 0000000000..9eaa0f6f9e --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `java.io.File`. + * + * @author ForteScarlet + */ +public expect class JvmFile { + public fun toPath(): JvmPath +} diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.kt new file mode 100644 index 0000000000..8c6e26ae12 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `javax.annotation.processing.Filer`. + * + * @author ForteScarlet + */ +public expect interface JvmFiler diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmIOException.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmIOException.kt new file mode 100644 index 0000000000..2d88a65147 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmIOException.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `java.io.IOException`. + * + * @author ForteScarlet + */ +public expect class JvmIOException : Exception diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.kt new file mode 100644 index 0000000000..ac9092f913 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `javax.tools.JavaFileObject`. + * + * @author ForteScarlet + */ +public expect interface JvmJavaFileObject diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.kt new file mode 100644 index 0000000000..bb8413c9e3 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.kt @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `javax.lang.model.element.Modifier`. + */ +public expect enum class JvmModifier { + PUBLIC, + PROTECTED, + PRIVATE, + ABSTRACT, + DEFAULT, + STATIC, + FINAL, + TRANSIENT, + VOLATILE, + SYNCHRONIZED, + NATIVE, + STRICTFP, +} diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.kt new file mode 100644 index 0000000000..c9f2e6eb5e --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `java.nio.Path`. + * + * @author ForteScarlet + */ +public expect interface JvmPath + +public expect fun JvmPath.toJvmFile(): JvmFile diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.kt new file mode 100644 index 0000000000..70bb108480 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `javax.lang.model.type.TypeMirror`. + * + * @author ForteScarlet + */ +public expect interface JvmTypeMirror diff --git a/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.kt b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.kt new file mode 100644 index 0000000000..7ed04bcc83 --- /dev/null +++ b/kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.kt @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * An expected typealias for `javax.lang.model.util.Types` + * @author ForteScarlet + */ +public expect interface JvmTypes diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/IdentifierRegexTests.kt b/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/IdentifierRegexTests.kt new file mode 100644 index 0000000000..9933e680b8 --- /dev/null +++ b/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/IdentifierRegexTests.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.test.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class IdentifierRegexTests { + @Test + fun multiplatformIdentifierRegexTest() { + assertTrue("foo".isIdentifier) + assertTrue("bAr1".isIdentifier) + assertFalse("1".isIdentifier) + assertFalse("♦♥♠♣".isIdentifier) + assertTrue("`♦♥♠♣`".isIdentifier) + assertTrue("` ♣ !`".isIdentifier) + assertFalse("€".isIdentifier) + assertTrue("`€`".isIdentifier) + assertTrue("`1`".isIdentifier) + assertFalse("```".isIdentifier) + assertFalse("``".isIdentifier) + assertFalse("\n".isIdentifier) + assertFalse("`\n`".isIdentifier) + assertFalse("\r".isIdentifier) + assertFalse("`\r`".isIdentifier) + assertTrue("when".isIdentifier) + assertTrue("fun".isIdentifier) + assertFalse("".isIdentifier) + } +} diff --git a/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/ClassName.js.kt b/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/ClassName.js.kt new file mode 100644 index 0000000000..283d2a441b --- /dev/null +++ b/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/ClassName.js.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2014 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.reflect.KClass + +@Suppress("Unsupported") // Suppress Unsupported [This reflection API is not supported yet in JavaScript] +internal actual fun KClass<*>.qualifiedNameInternal(): String? { + return qualifiedNameInternalNonJvm() ?: qualifiedName +} diff --git a/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/CodePoints.js.kt b/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/CodePoints.js.kt new file mode 100644 index 0000000000..536cd3f014 --- /dev/null +++ b/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/CodePoints.js.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +internal actual fun String.codePointAt(index: Int): CodePoint { + val str = this + val code = str.asDynamic().codePointAt(index).unsafeCast() + return CodePoint(code) +} + +internal actual fun CodePoint.stringValue(): String = + js("String").fromCodePoint(code).unsafeCast() diff --git a/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/CodeWriter.js.kt b/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/CodeWriter.js.kt new file mode 100644 index 0000000000..b31216f469 --- /dev/null +++ b/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/CodeWriter.js.kt @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +internal actual fun initNoPackage(): String = String() diff --git a/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/Util.js.kt b/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/Util.js.kt new file mode 100644 index 0000000000..b2cc2dd49d --- /dev/null +++ b/kotlinpoet/src/jsMain/kotlin/com/squareup/kotlinpoet/Util.js.kt @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +private val IDENTIFIER_REGEX = IDENTIFIER_REGEX_VALUE.toRegex() + +internal actual val String.isIdentifier: Boolean get() = IDENTIFIER_REGEX.matches(this) diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.jvm.kt new file mode 100644 index 0000000000..a6927effcd --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.jvm.kt @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("AnnotationSpecs") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.AnnotationSpec.Companion.builder +import com.squareup.kotlinpoet.jvm.alias.JvmAnnotationMirror +import com.squareup.kotlinpoet.jvm.alias.JvmTypeElement +import java.util.Objects +import javax.lang.model.element.AnnotationMirror +import javax.lang.model.element.AnnotationValue +import javax.lang.model.element.VariableElement +import javax.lang.model.type.TypeMirror +import javax.lang.model.util.SimpleAnnotationValueVisitor8 + +internal actual fun resolveEnumValueCodeBlock(value: Enum<*>): CodeBlock = + CodeBlock.of("%T.%L", value.javaClass, value.name) + +/** + * Annotation value visitor adding members to the given builder instance. + */ +@OptIn(DelicateKotlinPoetApi::class) +private class AnnotationSpecVisitor( + val builder: CodeBlock.Builder, +) : SimpleAnnotationValueVisitor8(builder) { + + override fun defaultAction(o: Any, name: String) = + builder.add(AnnotationSpec.Builder.memberForValue(o)) + + override fun visitAnnotation(a: AnnotationMirror, name: String) = + builder.add("%L", AnnotationSpec.get(a)) + + override fun visitEnumConstant(c: VariableElement, name: String) = + builder.add("%T.%L", c.asType().asTypeName(), c.simpleName) + + override fun visitType(t: TypeMirror, name: String) = + builder.add("%T::class", t.asTypeName()) + + override fun visitArray(values: List, name: String): CodeBlock.Builder { + builder.add("arrayOf(⇥⇥") + values.forEachIndexed { index, value -> + if (index > 0) builder.add(", ") + value.accept(this, name) + } + builder.add("⇤⇤)") + return builder + } +} + +internal actual fun doGet( + annotation: Annotation, + includeDefaultValues: Boolean, +): AnnotationSpec { + try { + @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") + val javaAnnotation = annotation as java.lang.annotation.Annotation + val builder = builder(javaAnnotation.annotationType()) + .tag(annotation) + val methods = annotation.annotationType().declaredMethods.sortedBy { it.name } + for (method in methods) { + val value = method.invoke(annotation) + if (!includeDefaultValues) { + if (Objects.deepEquals(value, method.defaultValue)) { + continue + } + } + val member = CodeBlock.builder() + member.add("%L = ", method.name) + if (value.javaClass.isArray) { + member.add("arrayOf(⇥⇥") + for (i in 0.. 0) member.add(", ") + member.add(AnnotationSpec.Builder.memberForValue(java.lang.reflect.Array.get(value, i))) + } + member.add("⇤⇤)") + builder.addMember(member.build()) + continue + } + if (value is Annotation) { + member.add("%L", AnnotationSpec.get(value)) + builder.addMember(member.build()) + continue + } + member.add("%L", AnnotationSpec.Builder.memberForValue(value)) + builder.addMember(member.build()) + } + return builder.build() + } catch (e: Exception) { + throw RuntimeException("Reflecting $annotation failed!", e) + } +} + +internal actual fun doGet(annotation: JvmAnnotationMirror): AnnotationSpec { + val element = annotation.annotationType.asElement() as JvmTypeElement + val builder = builder(element.asClassName()).tag(annotation) + for (executableElement in annotation.elementValues.keys) { + val member = CodeBlock.builder() + val visitor = AnnotationSpecVisitor(member) + val name = executableElement.simpleName.toString() + member.add("%L = ", name) + val value = annotation.elementValues[executableElement]!! + value.accept(visitor, name) + builder.addMember(member.build()) + } + return builder.build() +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ClassName.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ClassName.jvm.kt new file mode 100644 index 0000000000..6c3748e7bb --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ClassName.jvm.kt @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2014 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("ClassNames") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.JvmTypeElement +import javax.lang.model.element.Element +import javax.lang.model.element.ElementKind +import javax.lang.model.element.NestingKind.MEMBER +import javax.lang.model.element.NestingKind.TOP_LEVEL +import javax.lang.model.element.PackageElement +import javax.lang.model.element.TypeElement +import kotlin.collections.plusAssign +import kotlin.collections.reverse +import kotlin.reflect.KClass +import kotlin.text.substring + +@DelicateKotlinPoetApi( + message = "Java reflection APIs don't give complete information on Kotlin types. Consider using" + + " the kotlinpoet-metadata APIs instead.", +) +@JvmName("get") +public actual fun JvmClass<*>.asClassName(): ClassName { + require(!isPrimitive) { "primitive types cannot be represented as a ClassName" } + require(Void.TYPE != this) { "'void' type cannot be represented as a ClassName" } + require(!isArray) { "array types cannot be represented as a ClassName" } + val names = mutableListOf() + var c = this + while (true) { + names += c.simpleName + val enclosing = c.enclosingClass ?: break + c = enclosing + } + // Avoid unreliable Class.getPackage(). https://github.com/square/javapoet/issues/295 + val lastDot = c.name.lastIndexOf('.') + if (lastDot != -1) names += c.name.substring(0, lastDot) + names.reverse() + return ClassName(names) +} + +/** Returns the class name for `element`. */ +@DelicateKotlinPoetApi( + message = "Element APIs don't give complete information on Kotlin types. Consider using" + + " the kotlinpoet-metadata APIs instead.", +) +@JvmName("get") +public fun JvmTypeElement.asClassName(): ClassName { + fun isClassOrInterface(e: Element) = e.kind.isClass || e.kind.isInterface + + fun getPackage(type: Element): PackageElement { + var t = type + while (t.kind != ElementKind.PACKAGE) { + t = t.enclosingElement + } + return t as PackageElement + } + + val names = mutableListOf() + var e: Element = this + while (isClassOrInterface(e)) { + val eType = e as TypeElement + require(eType.nestingKind.isOneOf(TOP_LEVEL, MEMBER)) { + "unexpected type testing" + } + names += eType.simpleName.toString() + e = eType.enclosingElement + } + names += getPackage(this).qualifiedName.toString() + names.reverse() + return ClassName(names) +} + +internal actual fun KClass<*>.qualifiedNameInternal(): String? = + qualifiedName + +internal actual fun Enum<*>.declaringClassName(): ClassName = + this.declaringJavaClass.asClassName() diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.jvm.kt new file mode 100644 index 0000000000..198cba1ebb --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.jvm.kt @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2015 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("CodeBlocks") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet + +import java.lang.reflect.Type +import java.text.DecimalFormat +import java.text.DecimalFormatSymbols +import javax.lang.model.element.Element +import javax.lang.model.type.TypeMirror +import kotlin.math.max +import kotlin.reflect.KClass + +internal actual fun formatNumericValue(o: Number): Any? { + val format = DecimalFormatSymbols().apply { + decimalSeparator = '.' + groupingSeparator = '_' + minusSign = '-' + } + + val precision = when (o) { + is Float -> max(o.toBigDecimal().stripTrailingZeros().scale(), 1) + is Double -> max(o.toBigDecimal().stripTrailingZeros().scale(), 1) + else -> 0 + } + + val pattern = when (o) { + is Float, is Double -> "###,##0.0" + "#".repeat(precision - 1) + else -> "###,##0" + } + + return DecimalFormat(pattern, format).format(o) +} + +internal actual inline fun argToType( + o: Any?, + logDeprecationWarning: (Any) -> Unit, +): TypeName = when (o) { + is TypeName -> o + is TypeMirror -> { + logDeprecationWarning(o) + o.asTypeName() + } + + is Element -> { + logDeprecationWarning(o) + o.asType().asTypeName() + } + + is Type -> o.asTypeName() + is KClass<*> -> o.asTypeName() + else -> throw IllegalArgumentException("expected type but was $o") +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodePoints.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodePoints.jvm.kt new file mode 100644 index 0000000000..ff02a2c6ed --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodePoints.jvm.kt @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.text.codePointAt as codePointAtKt + +internal actual fun String.codePointAt(index: Int): CodePoint = + CodePoint(codePointAtKt(index)) + +internal actual fun CodePoint.isLowerCase(): Boolean = + Character.isLowerCase(code) + +internal actual fun CodePoint.isUpperCase(): Boolean = + Character.isUpperCase(code) + +internal actual fun CodePoint.isJavaIdentifierStart(): Boolean = + Character.isJavaIdentifierStart(code) + +internal actual fun CodePoint.isJavaIdentifierPart(): Boolean = + Character.isJavaIdentifierPart(code) + +internal actual fun CodePoint.charCount(): Int { + return Character.charCount(code) +} + +internal actual fun StringBuilder.appendCodePoint(codePoint: CodePoint): StringBuilder { + return appendCodePoint(codePoint.code) +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.jvm.kt new file mode 100644 index 0000000000..b31216f469 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.jvm.kt @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +internal actual fun initNoPackage(): String = String() diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/FileSpec.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/FileSpec.jvm.kt new file mode 100644 index 0000000000..4b88d1d9c4 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/FileSpec.jvm.kt @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmFiler +import com.squareup.kotlinpoet.jvm.alias.JvmIOException +import com.squareup.kotlinpoet.jvm.alias.JvmJavaFileObject +import com.squareup.kotlinpoet.jvm.alias.JvmPath +import java.io.ByteArrayInputStream +import java.io.InputStream +import java.net.URI +import javax.tools.JavaFileObject +import javax.tools.SimpleJavaFileObject +import javax.tools.StandardLocation +import kotlin.io.path.createDirectories +import kotlin.io.path.isDirectory +import kotlin.io.path.notExists +import kotlin.io.path.outputStream +import kotlin.text.Charsets.UTF_8 + +@Throws(JvmIOException::class) +internal actual fun FileSpec.writeToPath(directory: JvmPath): JvmPath { + require(directory.notExists() || directory.isDirectory()) { + "path $directory exists but is not a directory." + } + val outputPath = directory.resolve(relativePath) + outputPath.parent.createDirectories() + outputPath.outputStream().bufferedWriter().use(::writeTo) + return outputPath +} + +@Throws(JvmIOException::class) +internal actual fun FileSpec.writeToFiler(filer: JvmFiler, extension: String) { + val originatingElements = members.asSequence() + .filterIsInstance() + .flatMap { it.originatingElements.asSequence() } + .toSet() + val filerSourceFile = filer.createResource( + StandardLocation.SOURCE_OUTPUT, + packageName, + "$name.$extension", + *originatingElements.toTypedArray(), + ) + try { + filerSourceFile.openWriter().use { writer -> writeTo(writer) } + } catch (e: Exception) { + try { + filerSourceFile.delete() + } catch (_: Exception) { + } + throw e + } +} + +internal actual inline fun FileSpec.toJavaFileObjectInternal( + crossinline toString: () -> String, +): JvmJavaFileObject { + val uri = URI.create(relativePath) + return object : SimpleJavaFileObject(uri, JavaFileObject.Kind.SOURCE) { + private val lastModified = System.currentTimeMillis() + override fun getCharContent(ignoreEncodingErrors: Boolean): String { + return toString() + } + + override fun openInputStream(): InputStream { + return ByteArrayInputStream(getCharContent(true).toByteArray(UTF_8)) + } + + override fun getLastModified() = lastModified + } +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/FunSpec.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/FunSpec.jvm.kt new file mode 100644 index 0000000000..9dbe26e638 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/FunSpec.jvm.kt @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2015 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.FunSpec.Companion.builder +import com.squareup.kotlinpoet.FunSpec.Companion.overriding +import com.squareup.kotlinpoet.jvm.alias.JvmDeclaredType +import com.squareup.kotlinpoet.jvm.alias.JvmExecutableElement +import com.squareup.kotlinpoet.jvm.alias.JvmModifier +import com.squareup.kotlinpoet.jvm.alias.JvmTypes +import javax.lang.model.type.ExecutableType +import javax.lang.model.type.TypeVariable + +internal actual fun doOverriding(method: JvmExecutableElement): FunSpec.Builder { + var modifiers: Set = method.getModifiers() + require( + JvmModifier.PRIVATE !in modifiers && + JvmModifier.FINAL !in modifiers && + JvmModifier.STATIC !in modifiers, + ) { + "cannot override method with modifiers: $modifiers" + } + + val methodName = method.simpleName.toString() + val funBuilder = builder(methodName) + + funBuilder.addModifiers(KModifier.OVERRIDE) + + modifiers = modifiers.toMutableSet() + modifiers.remove(JvmModifier.ABSTRACT) + funBuilder.jvmModifiers(modifiers) + + method.typeParameters + .map { it.asType() as TypeVariable } + .map { it.asTypeVariableName() } + .forEach { funBuilder.addTypeVariable(it) } + + funBuilder.returns(method.returnType.asTypeName()) + funBuilder.addParameters(ParameterSpec.parametersOf(method)) + if (method.isVarArgs) { + funBuilder.parameters[funBuilder.parameters.lastIndex] = funBuilder.parameters.last() + .toBuilder() + .addModifiers(KModifier.VARARG) + .build() + } + + if (method.thrownTypes.isNotEmpty()) { + val throwsValueString = method.thrownTypes.joinToString { "%T::class" } + funBuilder.addAnnotation( + AnnotationSpec.builder(Throws::class) + .addMember(throwsValueString, *method.thrownTypes.toTypedArray()) + .build(), + ) + } + + return funBuilder +} + +internal actual fun doOverriding( + method: JvmExecutableElement, + enclosing: JvmDeclaredType, + types: JvmTypes, +): FunSpec.Builder { + val executableType = types.asMemberOf(enclosing, method) as ExecutableType + val resolvedParameterTypes = executableType.parameterTypes + val resolvedReturnType = executableType.returnType + + val builder = overriding(method) + builder.returns(resolvedReturnType.asTypeName()) + var i = 0 + val size = builder.parameters.size + while (i < size) { + val parameter = builder.parameters[i] + val type = resolvedParameterTypes[i].asTypeName() + builder.parameters[i] = parameter.toBuilder(parameter.name, type).build() + i++ + } + + return builder +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/NameAllocator.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/NameAllocator.jvm.kt new file mode 100644 index 0000000000..ce654e2d89 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/NameAllocator.jvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2015 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import java.util.* + +internal actual fun defaultNewNameTag(): Any = + UUID.randomUUID().toString() diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.jvm.kt new file mode 100644 index 0000000000..6c46ddab49 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.jvm.kt @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:Suppress("unused") + +package com.squareup.kotlinpoet + +import kotlin.reflect.KClass + +internal actual val JvmNameClass: KClass? + get() = JvmName::class +internal actual val JvmMultifileClassClass: KClass? + get() = JvmMultifileClass::class +internal actual val JvmSuppressWildcardsClass: KClass? + get() = JvmSuppressWildcards::class +internal actual val JvmInlineClass: KClass? + get() = JvmInline::class +internal actual val JvmRecordClass: KClass? + get() = JvmRecord::class +internal actual val JvmStaticClass: KClass? + get() = JvmStatic::class +internal actual val JvmOverloadsClass: KClass? + get() = JvmOverloads::class +internal actual val ThrowsClass: KClass? + get() = Throws::class +internal actual val SynchronizedClass: KClass? + get() = Synchronized::class +internal actual val StrictfpClass: KClass? + get() = Strictfp::class +internal actual val JvmFieldClass: KClass? + get() = JvmField::class +internal actual val TransientClass: KClass? + get() = Transient::class +internal actual val VolatileClass: KClass? + get() = kotlin.concurrent.Volatile::class +internal actual val JvmWildcardClass: KClass? + get() = JvmWildcard::class diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.jvm.kt new file mode 100644 index 0000000000..50fc6aabe7 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.jvm.kt @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmExecutableElement +import com.squareup.kotlinpoet.jvm.alias.JvmVariableElement + +internal actual fun doParametersOf(method: JvmExecutableElement): List = + method.parameters.map(ParameterSpec::get) + +internal actual fun doGet(element: JvmVariableElement): ParameterSpec { + val name = element.simpleName.toString() + val type = element.asType().asTypeName() + return ParameterSpec.builder(name, type) + .build() +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.jvm.kt new file mode 100644 index 0000000000..ab22faafea --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.jvm.kt @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2015 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("ParameterizedTypeNames") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet + +import java.lang.reflect.Modifier +import java.lang.reflect.ParameterizedType +import java.lang.reflect.Type +import kotlin.reflect.KClass +import kotlin.reflect.KTypeProjection +import kotlin.reflect.KVariance + +/** Returns a parameterized type equivalent to `type`. */ +@DelicateKotlinPoetApi( + message = "Java reflection APIs don't give complete information on Kotlin types. Consider " + + "using the kotlinpoet-metadata APIs instead.", +) +@JvmName("get") +public fun ParameterizedType.asParameterizedTypeName(): ParameterizedTypeName = + ParameterizedTypeName.get(this, mutableMapOf()) + +/** Returns a parameterized type equivalent to `type`. */ +internal fun ParameterizedTypeName.Companion.get( + type: ParameterizedType, + map: MutableMap, +): ParameterizedTypeName { + val rawType = (type.rawType as Class<*>).asClassName() + val ownerType = if (type.ownerType is ParameterizedType && + !Modifier.isStatic((type.rawType as Class<*>).modifiers) + ) { + type.ownerType as ParameterizedType + } else { + null + } + + val typeArguments = type.actualTypeArguments.map { TypeName.get(it, map = map) } + return if (ownerType != null) { + get(ownerType, map = map).nestedClass(rawType.simpleName, typeArguments) + } else { + ParameterizedTypeName(null, rawType, typeArguments) + } +} + +/** Returns a type name equivalent to type with given list of type arguments. */ +internal actual fun ParameterizedTypeName.Companion.get( + type: KClass<*>, + nullable: Boolean, + typeArguments: List, +): TypeName { + if (typeArguments.isEmpty()) { + return type.asTypeName().run { if (nullable) copy(nullable = true) else this } + } + + val effectiveType = if (type.java.isArray) Array::class else type + val enclosingClass = type.java.enclosingClass?.kotlin + + return ParameterizedTypeName( + enclosingClass?.let { + get(it, false, typeArguments.drop(effectiveType.typeParameters.size)) + }, + effectiveType.asTypeName(), + typeArguments.take(effectiveType.typeParameters.size).map { (paramVariance, paramType) -> + val typeName = paramType?.asTypeName() ?: return@map STAR + when (paramVariance) { + null -> STAR + KVariance.INVARIANT -> typeName + KVariance.IN -> WildcardTypeName.consumerOf(typeName) + KVariance.OUT -> WildcardTypeName.producerOf(typeName) + } + }, + nullable, + effectiveType.annotations.map { AnnotationSpec.get(it) }, + ) +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/TypeName.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/TypeName.jvm.kt new file mode 100644 index 0000000000..a25f9200a8 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/TypeName.jvm.kt @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import com.squareup.kotlinpoet.jvm.alias.JvmType +import com.squareup.kotlinpoet.jvm.alias.JvmTypeElement +import com.squareup.kotlinpoet.jvm.alias.JvmTypeMirror +import java.lang.reflect.GenericArrayType +import java.lang.reflect.ParameterizedType +import java.lang.reflect.TypeVariable +import javax.lang.model.element.Modifier +import javax.lang.model.element.TypeParameterElement +import javax.lang.model.type.ArrayType +import javax.lang.model.type.DeclaredType +import javax.lang.model.type.ErrorType +import javax.lang.model.type.NoType +import javax.lang.model.type.PrimitiveType +import javax.lang.model.type.TypeKind +import javax.lang.model.type.TypeMirror +import javax.lang.model.util.SimpleTypeVisitor8 + +/** Returns a [TypeName] equivalent to this [TypeMirror]. */ +internal actual fun JvmTypeMirror.asTypeNameInternal(): TypeName = TypeName.get(this, mutableMapOf()) + +/** Returns a [TypeName] equivalent to this [JvmType]. */ +internal actual fun JvmType.asTypeNameInternal(): TypeName = TypeName.get(this, mutableMapOf()) + +internal fun TypeName.Companion.get( + mirror: TypeMirror, + typeVariables: Map, +): TypeName { + return mirror.accept( + object : SimpleTypeVisitor8() { + override fun visitPrimitive(t: PrimitiveType, p: Void?): TypeName { + return when (t.kind) { + TypeKind.BOOLEAN -> BOOLEAN + TypeKind.BYTE -> BYTE + TypeKind.SHORT -> SHORT + TypeKind.INT -> INT + TypeKind.LONG -> LONG + TypeKind.CHAR -> CHAR + TypeKind.FLOAT -> FLOAT + TypeKind.DOUBLE -> DOUBLE + else -> throw AssertionError() + } + } + + override fun visitDeclared(t: DeclaredType, p: Void?): TypeName { + val rawType: ClassName = (t.asElement() as JvmTypeElement).asClassName() + val enclosingType = t.enclosingType + val enclosing = if (enclosingType.kind != TypeKind.NONE && + Modifier.STATIC !in t.asElement().modifiers + ) { + enclosingType.accept(this, null) + } else { + null + } + if (t.typeArguments.isEmpty() && enclosing !is ParameterizedTypeName) { + return rawType + } + + val typeArgumentNames = mutableListOf() + for (typeArgument in t.typeArguments) { + typeArgumentNames += get(typeArgument, typeVariables) + } + return if (enclosing is ParameterizedTypeName) { + enclosing.nestedClass(rawType.simpleName, typeArgumentNames) + } else { + ParameterizedTypeName(null, rawType, typeArgumentNames) + } + } + + override fun visitError(t: ErrorType, p: Void?): TypeName { + return visitDeclared(t, p) + } + + override fun visitArray(t: ArrayType, p: Void?): ParameterizedTypeName { + return ARRAY.parameterizedBy(get(t.componentType, typeVariables)) + } + + override fun visitTypeVariable( + t: javax.lang.model.type.TypeVariable, + p: Void?, + ): TypeName { + return TypeVariableName.get(t, typeVariables.toMutableMap()) + } + + override fun visitWildcard(t: javax.lang.model.type.WildcardType, p: Void?): TypeName { + return WildcardTypeName.get(t, typeVariables) + } + + override fun visitNoType(t: NoType, p: Void?): TypeName { + if (t.kind == TypeKind.VOID) return UNIT + return super.visitUnknown(t, p) + } + + override fun defaultAction(e: TypeMirror?, p: Void?): TypeName { + throw IllegalArgumentException("Unexpected type mirror: " + e!!) + } + }, + null, + ) +} + +internal fun TypeName.Companion.get(type: JvmType, map: MutableMap): TypeName { + return when (type) { + is Class<*> -> when { + type === Void.TYPE -> UNIT + type === Boolean::class.javaPrimitiveType -> BOOLEAN + type === Byte::class.javaPrimitiveType -> BYTE + type === Short::class.javaPrimitiveType -> SHORT + type === Int::class.javaPrimitiveType -> INT + type === Long::class.javaPrimitiveType -> LONG + type === Char::class.javaPrimitiveType -> CHAR + type === Float::class.javaPrimitiveType -> FLOAT + type === Double::class.javaPrimitiveType -> DOUBLE + type.isArray -> ARRAY.parameterizedBy(get(type.componentType, map)) + else -> type.asClassName() + } + + is ParameterizedType -> ParameterizedTypeName.get(type, map) + is java.lang.reflect.WildcardType -> WildcardTypeName.get(type, map) + is TypeVariable<*> -> TypeVariableName.get(type, map) + is GenericArrayType -> ARRAY.parameterizedBy(get(type.genericComponentType, map)) + else -> throw IllegalArgumentException("unexpected type: $type") + } +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/TypeVariableName.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/TypeVariableName.jvm.kt new file mode 100644 index 0000000000..5a3177d573 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/TypeVariableName.jvm.kt @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("TypeVariableNames") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmType +import java.util.Collections +import javax.lang.model.element.TypeParameterElement +import javax.lang.model.type.TypeMirror +import javax.lang.model.type.TypeVariable + +private val JAVA_OBJECT = ClassName("java.lang", "Object") + +/** + * Make a TypeVariableName for the given TypeMirror. This form is used internally to avoid + * infinite recursion in cases like `Enum>`. When we encounter such a + * thing, we will make a TypeVariableName without bounds and add that to the `typeVariables` + * map before looking up the bounds. Then if we encounter this TypeVariable again while + * constructing the bounds, we can just return it from the map. And, the code that put the entry + * in `variables` will make sure that the bounds are filled in before returning. + */ +internal fun TypeVariableName.Companion.get( + mirror: javax.lang.model.type.TypeVariable, + typeVariables: MutableMap, +): TypeVariableName { + val element = mirror.asElement() as TypeParameterElement + var typeVariableName: TypeVariableName? = typeVariables[element] + if (typeVariableName == null) { + // Since the bounds field is public, we need to make it an unmodifiableList. But we control + // the List that that wraps, which means we can change it before returning. + val bounds = mutableListOf() + val visibleBounds = Collections.unmodifiableList(bounds) + typeVariableName = TypeVariableName(element.simpleName.toString(), visibleBounds) + typeVariables[element] = typeVariableName + for (typeMirror in element.bounds) { + bounds += TypeName.get(typeMirror, typeVariables) + } + bounds.remove(ANY) + bounds.remove(JAVA_OBJECT) + if (bounds.isEmpty()) { + bounds.add(NULLABLE_ANY) + } + } + return typeVariableName +} + +/** Returns type variable equivalent to `type`. */ +internal fun TypeVariableName.Companion.get( + type: java.lang.reflect.TypeVariable<*>, + map: MutableMap = mutableMapOf(), +): TypeVariableName { + var result: TypeVariableName? = map[type] + if (result == null) { + val bounds = mutableListOf() + val visibleBounds = Collections.unmodifiableList(bounds) + result = TypeVariableName(type.name, visibleBounds) + map[type] = result + for (bound in type.bounds) { + bounds += TypeName.get(bound, map) + } + bounds.remove(ANY) + bounds.remove(JAVA_OBJECT) + if (bounds.isEmpty()) { + bounds.add(NULLABLE_ANY) + } + } + return result +} + +/** Returns type variable equivalent to `mirror`. */ +@DelicateKotlinPoetApi( + message = "Java reflection APIs don't give complete information on Kotlin types. Consider using" + + " the kotlinpoet-metadata APIs instead.", +) +@JvmName("get") +public fun TypeVariable.asTypeVariableName(): TypeVariableName = + (asElement() as TypeParameterElement).asTypeVariableName() + +/** Returns type variable equivalent to `element`. */ +@DelicateKotlinPoetApi( + message = "Element APIs don't give complete information on Kotlin types. Consider using" + + " the kotlinpoet-metadata APIs instead.", +) +@JvmName("get") +public fun TypeParameterElement.asTypeVariableName(): TypeVariableName { + val name = simpleName.toString() + val boundsTypeNames = bounds.map(TypeMirror::asTypeName) + .ifEmpty(TypeVariableName.Companion::NULLABLE_ANY_LIST) + return TypeVariableName.of(name, boundsTypeNames, variance = null) +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/Util.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/Util.jvm.kt new file mode 100644 index 0000000000..f7c2554fae --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/Util.jvm.kt @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import java.util.Collections +import java.util.EnumSet +import java.util.TreeSet +import kotlin.collections.toSortedSet as toSortedSetKt +import kotlin.reflect.KClass +import kotlin.sequences.toSortedSet as toSortedSetKt + +private val IDENTIFIER_REGEX = IDENTIFIER_REGEX_VALUE.toRegex() + +internal actual val String.isIdentifier: Boolean get() = IDENTIFIER_REGEX.matches(this) + +internal actual fun formatIsoControlCode(code: Int): String = + String.format("\\u%04x", code) + +internal actual fun Int.toHexStr(): String = + Integer.toHexString(this) + +internal actual fun Map.toImmutableMap(): Map = + Collections.unmodifiableMap(LinkedHashMap(this)) + +internal actual fun Collection.toImmutableList(): List = + Collections.unmodifiableList(ArrayList(this)) + +internal actual fun Collection.toImmutableSet(): Set = + Collections.unmodifiableSet(LinkedHashSet(this)) + +internal actual fun > Sequence.toSortedSet(): Set = + toSortedSetKt() + +internal actual fun > List.toSortedSet(): Set = + toSortedSetKt() + +internal actual fun > sortedSetOf(): MutableSet = + TreeSet() + +internal actual inline fun > enumSetOf(vararg values: E): MutableSet { + return when { + values.isEmpty() -> EnumSet.noneOf(E::class.java) + values.size == 1 -> EnumSet.of(values[0]) + values.size == 2 -> EnumSet.of(values[0], values[1]) + values.size == 3 -> EnumSet.of(values[0], values[1], values[2]) + values.size == 4 -> EnumSet.of(values[0], values[1], values[2], values[3]) + values.size == 5 -> EnumSet.of(values[0], values[1], values[2], values[3], values[4]) + else -> EnumSet.copyOf(values.toSet()) + } +} + +internal actual fun KClass<*>.enclosingClass(): KClass<*>? = + java.enclosingClass?.kotlin + +internal actual fun Char.isJavaIdentifierStart(): Boolean = + Character.isJavaIdentifierStart(this) + +internal actual fun Char.isJavaIdentifierPart(): Boolean = + Character.isJavaIdentifierPart(this) diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/WildcardTypeName.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/WildcardTypeName.jvm.kt new file mode 100644 index 0000000000..949dbbcdbd --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/WildcardTypeName.jvm.kt @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("WildcardTypeNames") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet + +import java.lang.reflect.Type +import java.lang.reflect.WildcardType +import javax.lang.model.element.TypeParameterElement +import kotlin.jvm.JvmMultifileClass +import kotlin.jvm.JvmName + +@DelicateKotlinPoetApi( + message = "Mirror APIs don't give complete information on Kotlin types. Consider using" + + " the kotlinpoet-metadata APIs instead.", +) +@JvmName("get") +public fun javax.lang.model.type.WildcardType.asWildcardTypeName(): TypeName = + WildcardTypeName.get(this, mutableMapOf()) + +@DelicateKotlinPoetApi( + message = "Java reflection APIs don't give complete information on Kotlin types. Consider using" + + " the kotlinpoet-metadata APIs instead.", +) +@JvmName("get") +public fun WildcardType.asWildcardTypeName(): TypeName = + WildcardTypeName.get(this, mutableMapOf()) + +internal fun WildcardTypeName.Companion.get( + mirror: javax.lang.model.type.WildcardType, + typeVariables: Map, +): TypeName { + val outType = mirror.extendsBound + return if (outType == null) { + val inType = mirror.superBound + if (inType == null) { + STAR + } else { + consumerOf(TypeName.get(inType, typeVariables)) + } + } else { + producerOf(TypeName.get(outType, typeVariables)) + } +} + +internal fun WildcardTypeName.Companion.get( + wildcardName: WildcardType, + map: MutableMap, +): TypeName { + return WildcardTypeName( + wildcardName.upperBounds.map { TypeName.get(it, map = map) }, + wildcardName.lowerBounds.map { TypeName.get(it, map = map) }, + ) +} diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/JvmDefaultWithCompatibility.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/JvmDefaultWithCompatibility.jvm.kt new file mode 100644 index 0000000000..c445390018 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/JvmDefaultWithCompatibility.jvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm + +/** + * A typealias annotation for [kotlin.jvm.JvmDefaultWithCompatibility]. + */ +public actual typealias JvmDefaultWithCompatibility = kotlin.jvm.JvmDefaultWithCompatibility diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.jvm.kt new file mode 100644 index 0000000000..8bd24d1992 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.jvm.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import javax.lang.model.element.AnnotationMirror + +/** + * Type alias for [AnnotationMirror]. + */ +public actual typealias JvmAnnotationMirror = AnnotationMirror diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.jvm.kt new file mode 100644 index 0000000000..2f30e46796 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.jvm.kt @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:JvmName("JvmClasses") +@file:JvmMultifileClass + +package com.squareup.kotlinpoet.jvm.alias + +import java.lang.reflect.Type +import kotlin.jvm.kotlin as kJvmKotlin +import kotlin.reflect.KClass + +/** + * Type alias for [Type]. + */ +public actual typealias JvmType = Type + +public actual fun JvmType.typeName(): String = typeName + +/** + * Type alias for [Class]. + */ +public actual typealias JvmClass = Class + +public actual val JvmClass.kotlin: KClass + get() = kJvmKotlin diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.jvm.kt new file mode 100644 index 0000000000..8a996f58ae --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.jvm.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import javax.lang.model.type.DeclaredType + +/** + * Type alias for [DeclaredType]. + */ +public actual typealias JvmDeclaredType = DeclaredType diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.jvm.kt new file mode 100644 index 0000000000..ce35be5b49 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.jvm.kt @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import javax.lang.model.element.Element +import javax.lang.model.element.ExecutableElement +import javax.lang.model.element.TypeElement +import javax.lang.model.element.VariableElement + +/** + * Type alias for [Element]. + */ +public actual typealias JvmElement = Element + +/** + * Type alias for [TypeElement]. + */ +public actual typealias JvmTypeElement = TypeElement + +/** + * Type alias for [ExecutableElement]. + */ +public actual typealias JvmExecutableElement = ExecutableElement + +/** + * Type alias for [VariableElement]. + */ +public actual typealias JvmVariableElement = VariableElement diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.jvm.kt new file mode 100644 index 0000000000..961351373d --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.jvm.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import java.io.File + +/** + * Type alias for [File]. + */ +public actual typealias JvmFile = File diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.jvm.kt new file mode 100644 index 0000000000..885329fd32 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.jvm.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import javax.annotation.processing.Filer + +/** + * Type alias for [Filer]. + */ +public actual typealias JvmFiler = Filer diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmIOException.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmIOException.kt new file mode 100644 index 0000000000..b85555b793 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmIOException.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +/** + * Type alias for [java.io.IOException]. + */ +public actual typealias JvmIOException = java.io.IOException diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.jvm.kt new file mode 100644 index 0000000000..af0ab4525b --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.jvm.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import javax.tools.JavaFileObject + +/** + * Type alias for [JavaFileObject]. + */ +public actual typealias JvmJavaFileObject = JavaFileObject diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.jvm.kt new file mode 100644 index 0000000000..9fe1908b8e --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.jvm.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import javax.lang.model.element.Modifier + +/** + * Type alias for [javax.lang.model.element.Modifier]. + */ +public actual typealias JvmModifier = Modifier diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.jvm.kt new file mode 100644 index 0000000000..6db3b09712 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.jvm.kt @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import java.nio.file.Path + +/** + * Type alias for [Path]. + */ +public actual typealias JvmPath = Path + +public actual fun JvmPath.toJvmFile(): JvmFile = + toFile() diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.jvm.kt new file mode 100644 index 0000000000..cb352b5e30 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.jvm.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import javax.lang.model.type.TypeMirror + +/** + * Type alias for [TypeMirror]. + */ +public actual typealias JvmTypeMirror = TypeMirror diff --git a/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.jvm.kt b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.jvm.kt new file mode 100644 index 0000000000..abb6f632f0 --- /dev/null +++ b/kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.jvm.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import javax.lang.model.util.Types + +/** + * Type alias for [Types]. + */ +public actual typealias JvmTypes = Types diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/AbstractTypesTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/AbstractTypesTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/AbstractTypesTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/AbstractTypesTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/AnnotatedTypeNameTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/AnnotatedTypeNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/AnnotatedTypeNameTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/AnnotatedTypeNameTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/AnnotationSpecTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/AnnotationSpecTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/AnnotationSpecTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/AnnotationSpecTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/AssertThrows.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/AssertThrows.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/AssertThrows.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/AssertThrows.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/Cased/Weird/Sup.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/Cased/Weird/Sup.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/Cased/Weird/Sup.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/Cased/Weird/Sup.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ClassNameTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ClassNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ClassNameTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ClassNameTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/CodeBlockTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/CodeBlockTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/CodeBlockTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/CodeBlockTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/CrossplatformTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/CrossplatformTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/CrossplatformTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/CrossplatformTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/DelegatedConstructorCallTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/DelegatedConstructorCallTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/DelegatedConstructorCallTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/DelegatedConstructorCallTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ExpectDeclarationsTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ExpectDeclarationsTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ExpectDeclarationsTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ExpectDeclarationsTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ExternalDeclarationsTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ExternalDeclarationsTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ExternalDeclarationsTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ExternalDeclarationsTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/FileReadingTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/FileReadingTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/FileReadingTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/FileReadingTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/FileSpecTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/FileSpecTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/FileSpecTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/FileSpecTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/FileWritingTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/FileWritingTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/FileWritingTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/FileWritingTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/FunSpecTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/FunSpecTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/FunSpecTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/FunSpecTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/KotlinPoetTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/KotlinPoetTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/KotlinPoetTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/KotlinPoetTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/LambdaTypeNameTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/LambdaTypeNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/LambdaTypeNameTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/LambdaTypeNameTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/LineWrapperTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/LineWrapperTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/LineWrapperTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/LineWrapperTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/LineWrappingTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/LineWrappingTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/LineWrappingTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/LineWrappingTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/MemberNameTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/MemberNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/MemberNameTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/MemberNameTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/NameAllocatorTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/NameAllocatorTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/NameAllocatorTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/NameAllocatorTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ParameterSpecTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ParameterSpecTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ParameterSpecTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ParameterSpecTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ParameterizedTypeNameTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ParameterizedTypeNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ParameterizedTypeNameTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ParameterizedTypeNameTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/PropertySpecTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/PropertySpecTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/PropertySpecTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/PropertySpecTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/StringsTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/StringsTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/StringsTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/StringsTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TaggableTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TaggableTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TaggableTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TaggableTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TestFiler.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TestFiler.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TestFiler.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TestFiler.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypeAliasSpecTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypeAliasSpecTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypeAliasSpecTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypeAliasSpecTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypeNameKotlinTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypeNameKotlinTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypeNameKotlinTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypeNameKotlinTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypeSpecTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypeSpecTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypeSpecTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypeSpecTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypeVariableNameTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypeVariableNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypeVariableNameTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypeVariableNameTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypesEclipseTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypesEclipseTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypesEclipseTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypesEclipseTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypesTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypesTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/TypesTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/TypesTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/UtilTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/UtilTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/UtilTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/UtilTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ValueTypeSpecTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ValueTypeSpecTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/ValueTypeSpecTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/ValueTypeSpecTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/WildcardTypeNameTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/WildcardTypeNameTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/WildcardTypeNameTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/WildcardTypeNameTest.kt diff --git a/kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/jvm/JvmAnnotationsTest.kt b/kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/jvm/JvmAnnotationsTest.kt similarity index 100% rename from kotlinpoet/src/commonTest/kotlin/com/squareup/kotlinpoet/jvm/JvmAnnotationsTest.kt rename to kotlinpoet/src/jvmTest/kotlin/com/squareup/kotlinpoet/jvm/JvmAnnotationsTest.kt diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.nonJvm.kt new file mode 100644 index 0000000000..90b4853043 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/AnnotationSpec.nonJvm.kt @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmAnnotationMirror + +internal actual fun resolveEnumValueCodeBlock(value: Enum<*>): CodeBlock = + CodeBlock.of("%T.%L", value::class, value.name) + +internal actual fun doGet( + annotation: Annotation, + includeDefaultValues: Boolean, +): AnnotationSpec { + throw UnsupportedOperationException() +} + +@JvmTypeAliasKotlinPoetApi +internal actual fun doGet(annotation: JvmAnnotationMirror): AnnotationSpec = + throw UnsupportedOperationException() diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ClassName.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ClassName.nonJvm.kt new file mode 100644 index 0000000000..4f66a0a149 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ClassName.nonJvm.kt @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2014 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmClass +import com.squareup.kotlinpoet.jvm.alias.kotlin +import kotlin.reflect.KClass + +@JvmTypeAliasKotlinPoetApi +@DelicateKotlinPoetApi( + message = "Java reflection APIs don't give complete information on Kotlin types. Consider using" + + " the kotlinpoet-metadata APIs instead.", +) +public actual fun JvmClass<*>.asClassName(): ClassName = + kotlin.asClassName() + +internal actual fun Enum<*>.declaringClassName(): ClassName = + this::class.asClassName() + +internal fun KClass<*>.qualifiedNameInternalNonJvm(): String? { + return when (this) { + Any::class -> "kotlin.Any" + Number::class -> "kotlin.Number" + Boolean::class -> "kotlin.Boolean" + Byte::class -> "kotlin.Byte" + Char::class -> "kotlin.Char" + Double::class -> "kotlin.Double" + Enum::class -> "kotlin.Enum" + Float::class -> "kotlin.Float" + Int::class -> "kotlin.Int" + Long::class -> "kotlin.Long" + Short::class -> "kotlin.Short" + String::class -> "kotlin.String" + + else -> null + } +} diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.nonJvm.kt new file mode 100644 index 0000000000..a7f757177e --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.nonJvm.kt @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2015 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.reflect.KClass + +internal actual fun formatNumericValue(o: Number): Any? { + // TODO Format numeric value in non-JVM platform + return o.toString() +} + +internal actual inline fun argToType( + o: Any?, + logDeprecationWarning: (Any) -> Unit, +): TypeName = when (o) { + is TypeName -> o + is KClass<*> -> o.asTypeName() + else -> throw IllegalArgumentException("expected type but was $o") +} diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/CodePoints.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/CodePoints.nonJvm.kt new file mode 100644 index 0000000000..10b7aa58d1 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/CodePoints.nonJvm.kt @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ +internal actual fun StringBuilder.appendCodePoint(codePoint: CodePoint): StringBuilder { + // TODO Is this correct? + val code = codePoint.code + if (code <= Char.MAX_VALUE.code) { + append(code.toChar()) + } else { + append(Char.MIN_HIGH_SURROGATE + ((code - 0x10000) shr 10)) + append(Char.MIN_LOW_SURROGATE + (code and 0x3ff)) + } + return this +} + +internal expect fun CodePoint.stringValue(): String + +// TODO How check Java identifier start use code point? +internal actual fun CodePoint.isJavaIdentifierStart(): Boolean { + if (charCount() != 1) return false + + return stringValue()[0].isJavaIdentifierStart() +} + +// TODO How check Java identifier part use code point? +internal actual fun CodePoint.isJavaIdentifierPart(): Boolean { + if (charCount() != 1) return false + + return stringValue()[0].isJavaIdentifierPart() +} + +// TODO CodePoint.isLowerCase +internal actual fun CodePoint.isLowerCase(): Boolean { + if (charCount() != 1) return false + + return stringValue()[0].isLowerCase() +} + +// TODO CodePoint.isUpperCase +internal actual fun CodePoint.isUpperCase(): Boolean { + if (charCount() != 1) return false + + return stringValue()[0].isUpperCase() +} + +internal actual fun CodePoint.charCount(): Int { + return if (code > Char.MAX_VALUE.code) 2 else 1 +} diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/FileSpec.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/FileSpec.nonJvm.kt new file mode 100644 index 0000000000..20c8cf44e1 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/FileSpec.nonJvm.kt @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmFiler +import com.squareup.kotlinpoet.jvm.alias.JvmIOException +import com.squareup.kotlinpoet.jvm.alias.JvmJavaFileObject +import com.squareup.kotlinpoet.jvm.alias.JvmPath + +@JvmTypeAliasKotlinPoetApi +@Throws(JvmIOException::class) +internal actual fun FileSpec.writeToPath(directory: JvmPath): JvmPath = + throw UnsupportedOperationException() + +@JvmTypeAliasKotlinPoetApi +@Throws(JvmIOException::class) +internal actual fun FileSpec.writeToFiler(filer: JvmFiler, extension: String) { + throw UnsupportedOperationException() +} + +@JvmTypeAliasKotlinPoetApi +internal actual inline fun FileSpec.toJavaFileObjectInternal( + crossinline toString: () -> String, +): JvmJavaFileObject { + throw UnsupportedOperationException() +} diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/FunSpec.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/FunSpec.nonJvm.kt new file mode 100644 index 0000000000..beaff88eec --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/FunSpec.nonJvm.kt @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmDeclaredType +import com.squareup.kotlinpoet.jvm.alias.JvmExecutableElement +import com.squareup.kotlinpoet.jvm.alias.JvmTypes + +@JvmTypeAliasKotlinPoetApi +internal actual fun doOverriding(method: JvmExecutableElement): FunSpec.Builder = + throw UnsupportedOperationException() + +@JvmTypeAliasKotlinPoetApi +internal actual fun doOverriding( + method: JvmExecutableElement, + enclosing: JvmDeclaredType, + types: JvmTypes, +): FunSpec.Builder = + throw UnsupportedOperationException() diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/NameAllocator.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/NameAllocator.nonJvm.kt new file mode 100644 index 0000000000..cd00aaa71c --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/NameAllocator.nonJvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.random.Random +import kotlin.random.nextULong + +internal actual fun defaultNewNameTag(): Any = Random.nextULong().toString() diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.nonJvm.kt new file mode 100644 index 0000000000..44ac3218bd --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/OptionalExpectationAnnotations.nonJvm.kt @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@file:Suppress("unused") + +package com.squareup.kotlinpoet + +import kotlin.reflect.KClass + +internal actual val JvmNameClass: KClass? + get() = null +internal actual val JvmMultifileClassClass: KClass? + get() = null +internal actual val JvmSuppressWildcardsClass: KClass? + get() = null +internal actual val JvmInlineClass: KClass? + get() = null +internal actual val JvmRecordClass: KClass? + get() = null +internal actual val JvmStaticClass: KClass? + get() = null +internal actual val JvmOverloadsClass: KClass? + get() = null +internal actual val ThrowsClass: KClass? + get() = null +internal actual val SynchronizedClass: KClass? + get() = null +internal actual val StrictfpClass: KClass? + get() = null +internal actual val JvmFieldClass: KClass? + get() = null +internal actual val TransientClass: KClass? + get() = null +internal actual val VolatileClass: KClass? + get() = null +internal actual val JvmWildcardClass: KClass? + get() = null diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.nonJvm.kt new file mode 100644 index 0000000000..b90b1583f0 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ParameterSpec.nonJvm.kt @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmExecutableElement +import com.squareup.kotlinpoet.jvm.alias.JvmVariableElement + +@JvmTypeAliasKotlinPoetApi +internal actual fun doParametersOf(method: JvmExecutableElement): List = + emptyList() + +@JvmTypeAliasKotlinPoetApi +internal actual fun doGet(element: JvmVariableElement): ParameterSpec = + throw UnsupportedOperationException() diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.nonJvm.kt new file mode 100644 index 0000000000..e2cbd4f2c1 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/ParameterizedTypeName.nonJvm.kt @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.reflect.KClass +import kotlin.reflect.KTypeProjection +import kotlin.reflect.KVariance + +internal actual fun ParameterizedTypeName.Companion.get( + type: KClass<*>, + nullable: Boolean, + typeArguments: List, +): TypeName { + if (typeArguments.isEmpty()) { + return type.asTypeName().run { if (nullable) copy(nullable = true) else this } + } + + val effectiveType = if (type.isInstance(Array(0) {})) Array::class else type + val enclosingClass: KClass<*>? = effectiveType.enclosingClass() // type.java.enclosingClass?.kotlin + + return ParameterizedTypeName( + enclosingClass?.let { + get(it, false, typeArguments) // .drop(effectiveType.typeParameters.size) + }, + effectiveType.asTypeName(), + typeArguments /* .take(effectiveType.typeParameters.size) */.map { (paramVariance, paramType) -> + val typeName = paramType?.asTypeName() ?: return@map STAR + when (paramVariance) { + null -> STAR + KVariance.INVARIANT -> typeName + KVariance.IN -> WildcardTypeName.consumerOf(typeName) + KVariance.OUT -> WildcardTypeName.producerOf(typeName) + } + }, + nullable, + // effectiveType.annotations.map { AnnotationSpec.get(it) }, + ) +} diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/TypeName.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/TypeName.nonJvm.kt new file mode 100644 index 0000000000..b0113a709a --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/TypeName.nonJvm.kt @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import com.squareup.kotlinpoet.jvm.alias.JvmType +import com.squareup.kotlinpoet.jvm.alias.JvmTypeMirror + +/** Returns a [TypeName] equivalent to this [JvmType]. */ +@JvmTypeAliasKotlinPoetApi +internal actual fun JvmType.asTypeNameInternal(): TypeName = + throw UnsupportedOperationException() + +/** Returns a [TypeName] equivalent to this [JvmTypeMirror]. */ +@JvmTypeAliasKotlinPoetApi +internal actual fun JvmTypeMirror.asTypeNameInternal(): TypeName = + throw UnsupportedOperationException() diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/Util.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/Util.nonJvm.kt new file mode 100644 index 0000000000..a2cf73afff --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/Util.nonJvm.kt @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.reflect.KClass +import kotlin.sequences.toCollection + +internal actual fun formatIsoControlCode(code: Int): String { + return buildString(6) { + append("\\u") + appendFormat04x(code) + } +} + +@OptIn(ExperimentalStdlibApi::class) +internal fun Appendable.appendFormat04x(code: Int) { + val hex = code.toHexString(HexFormatWithoutLeadingZeros) + if (hex.length < 4) { + repeat(4 - hex.length) { append('0') } + } + append(hex) +} + +@OptIn(ExperimentalStdlibApi::class) +internal actual fun Int.toHexStr(): String = + toHexString(HexFormatWithoutLeadingZeros) + +internal actual fun Map.toImmutableMap(): Map = + toMap() + +internal actual fun Collection.toImmutableList(): List = + toList() + +internal actual fun Collection.toImmutableSet(): Set = + toSet() + +internal actual inline fun > enumSetOf(vararg values: E): MutableSet { + return values.toMutableSet() +} + +internal actual fun > Sequence.toSortedSet(): Set = + toCollection(linkedSetOf()) + +internal actual fun > List.toSortedSet(): Set = + toCollection(linkedSetOf()) + +internal actual fun > sortedSetOf(): MutableSet = linkedSetOf() + +internal actual fun KClass<*>.enclosingClass(): KClass<*>? = + null + +internal actual fun Char.isJavaIdentifierStart(): Boolean { + return isLetter() || + this in CharCategory.LETTER_NUMBER || + this == '$' || + this == '_' +} + +internal actual fun Char.isJavaIdentifierPart(): Boolean { + // TODO How check Java identifier part? + // A character may be part of a Java identifier if any of the following conditions are true: + // - [x] it is a letter + // - [x] it is a currency symbol (such as '$') + // - [x] it is a connecting punctuation character (such as '_') + // - [x] it is a digit + // - [x] it is a numeric letter (such as a Roman numeral character) + // - [ ] it is a combining mark + // - [x] it is a non-spacing mark + // - [x] isIdentifierIgnorable returns true for the character + return isLetter() || + isDigit() || + this in CharCategory.LETTER_NUMBER || + this in CharCategory.NON_SPACING_MARK || + this == '_' || + this == '$' || + isIdentifierIgnorable() +} + +internal fun Char.isIdentifierIgnorable(): Boolean { + // The following Unicode characters are ignorable in a Java identifier or a Unicode identifier: + // - ISO control characters that are not whitespace + // - '\u0000' through '\u0008' + // - '\u000E' through '\u001B' + // - '\u007F' through '\u009F' + // - all characters that have the FORMAT general category value + return ( + isISOControl() && ( + this in '\u0000'..'\u0008' || + this in '\u000E'..'\u001B' || + this in '\u007F'..'\u009F' + ) + ) || this in CharCategory.FORMAT +} diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/IOException.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/IOException.nonJvm.kt new file mode 100644 index 0000000000..d4cc1b4429 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/IOException.nonJvm.kt @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +public actual open class JvmIOException : Exception() diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.nonJvm.kt new file mode 100644 index 0000000000..dafd258cbe --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmAnnotationMirror.nonJvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmAnnotationMirror diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.nonJvm.kt new file mode 100644 index 0000000000..d615e5a94a --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.nonJvm.kt @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi +import kotlin.reflect.KClass + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmType + +@JvmTypeAliasKotlinPoetApi +public actual fun JvmType.typeName(): String = + throw UnsupportedOperationException() + +@JvmTypeAliasKotlinPoetApi +public actual class JvmClass< + @Suppress("unused") + T : Any, + > private constructor() : JvmType { + init { + error("JvmClass can't be constructed in a non-JVM platform") + } +} + +@JvmTypeAliasKotlinPoetApi +public actual val JvmClass.kotlin: KClass + get() = throw UnsupportedOperationException() diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.nonJvm.kt new file mode 100644 index 0000000000..335e0436b3 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDeclaredType.nonJvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmDeclaredType diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.nonJvm.kt new file mode 100644 index 0000000000..ff36d8c540 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.nonJvm.kt @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmElement + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmTypeElement : JvmElement + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmExecutableElement : JvmElement + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmVariableElement : JvmElement diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.nonJvm.kt new file mode 100644 index 0000000000..daad350e40 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFile.nonJvm.kt @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual class JvmFile private constructor() { + init { + error("JvmFile can't be constructed in a non-JVM platform") + } + public actual fun toPath(): JvmPath = throw UnsupportedOperationException() +} diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.nonJvm.kt new file mode 100644 index 0000000000..9485b2001a --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmFiler.nonJvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmFiler diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.nonJvm.kt new file mode 100644 index 0000000000..560e0fafe1 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmJavaFileObject.nonJvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmJavaFileObject diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.nonJvm.kt new file mode 100644 index 0000000000..2fd2326229 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmModifier.nonJvm.kt @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +public actual enum class JvmModifier { + PUBLIC, + PROTECTED, + PRIVATE, + ABSTRACT, + DEFAULT, + STATIC, + FINAL, + TRANSIENT, + VOLATILE, + SYNCHRONIZED, + NATIVE, + STRICTFP, +} diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.nonJvm.kt new file mode 100644 index 0000000000..06166683e9 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmPath.nonJvm.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmPath + +@JvmTypeAliasKotlinPoetApi +public actual fun JvmPath.toJvmFile(): JvmFile = + throw UnsupportedOperationException() diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.nonJvm.kt new file mode 100644 index 0000000000..e97de61cf0 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypeMirror.nonJvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmTypeMirror diff --git a/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.nonJvm.kt b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.nonJvm.kt new file mode 100644 index 0000000000..c5bfadf6f6 --- /dev/null +++ b/kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmTypes.nonJvm.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet.jvm.alias + +import com.squareup.kotlinpoet.JvmTypeAliasKotlinPoetApi + +@JvmTypeAliasKotlinPoetApi +public actual interface JvmTypes diff --git a/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/ClassName.wasmJs.kt b/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/ClassName.wasmJs.kt new file mode 100644 index 0000000000..e874a37921 --- /dev/null +++ b/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/ClassName.wasmJs.kt @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +import kotlin.reflect.KClass + +@Suppress("Unsupported") // Suppress Unsupported [This reflection API is not supported yet in JavaScript] +internal actual fun KClass<*>.qualifiedNameInternal(): String? { + val nonJvmQualifier = qualifiedNameInternalNonJvm() + if (nonJvmQualifier != null) return nonJvmQualifier + + return when (this) { + Boolean.Companion::class -> "kotlin.Boolean.Companion" + Byte.Companion::class -> "kotlin.Byte.Companion" + Char.Companion::class -> "kotlin.Char.Companion" + Double.Companion::class -> "kotlin.Double.Companion" + Enum.Companion::class -> "kotlin.Enum.Companion" + Float.Companion::class -> "kotlin.Float.Companion" + Int.Companion::class -> "kotlin.Int.Companion" + Long.Companion::class -> "kotlin.Long.Companion" + Short.Companion::class -> "kotlin.Short.Companion" + String.Companion::class -> "kotlin.String.Companion" + else -> qualifiedName + } +} diff --git a/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/CodePoints.wasmJs.kt b/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/CodePoints.wasmJs.kt new file mode 100644 index 0000000000..feffa63c3c --- /dev/null +++ b/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/CodePoints.wasmJs.kt @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +internal actual fun String.codePointAt(index: Int): CodePoint { + val code = jsCodePointAt(this, index) + return CodePoint(code) +} + +internal actual fun CodePoint.stringValue(): String = + stringFromCodePoint(code) + +@Suppress("UNUSED_PARAMETER") +private fun jsCodePointAt(str: String, index: Int): Int = + js("str.codePointAt(index)") + +@Suppress("UNUSED_PARAMETER") +private fun stringFromCodePoint(code: Int): String = + js("String.fromCodePoint(code)") diff --git a/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/CodeWriter.wasmJs.kt b/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/CodeWriter.wasmJs.kt new file mode 100644 index 0000000000..1cc6687338 --- /dev/null +++ b/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/CodeWriter.wasmJs.kt @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +internal actual fun initNoPackage(): String = "" diff --git a/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/Util.wasmJs.kt b/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/Util.wasmJs.kt new file mode 100644 index 0000000000..e1316b3f05 --- /dev/null +++ b/kotlinpoet/src/wasmJsMain/kotlin/com/squareup/kotlinpoet/Util.wasmJs.kt @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.squareup.kotlinpoet + +private typealias IdentifierMatcher = (String) -> Boolean + +private fun createIdentifierMatcher(): IdentifierMatcher { + val regExp = createRegExp(IDENTIFIER_REGEX_VALUE) + return f@{ input -> + // The logic here is similar to Regex.matches in JS platform. + regExpReset(regExp) + val match = regExpExec(regExp, input) ?: return@f false + + regExpMatchCheck(regExp, match, input) + } +} + +private val identifierMatcher = createIdentifierMatcher() + +internal actual val String.isIdentifier: Boolean get() = identifierMatcher(this) + +@Suppress("UNUSED_PARAMETER") +private fun createRegExp(pattern: String): JsAny = + js("new RegExp(pattern, 'gu')") + +@Suppress("UNUSED_PARAMETER") +private fun regExpReset(regExp: JsAny) { + js("regExp.lastIndex = 0") +} + +@Suppress("UNUSED_PARAMETER", "RedundantNullableReturnType") +private fun regExpExec(regExp: JsAny, input: String): JsAny? = + js("regExp.exec(input)") + +@Suppress("UNUSED_PARAMETER") +private fun regExpMatchCheck( + regExp: JsAny, + regExpMatch: JsAny, + input: String, +): Boolean = + js("regExpMatch.index == 0 && regExp.lastIndex == input.length")