@gramlot/gramlot 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ [
2
+ {
3
+ "name": "@genrojs/bag",
4
+ "text": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to the Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n\ngenro-bag-js\nCopyright 2025 Softwell S.r.l.\n\nThis product includes software developed at Softwell S.r.l.\n(https://www.softwell.it/).\n\nLicensed under the Apache License, Version 2.0.\n"
5
+ },
6
+ {
7
+ "name": "@genrojs/builders",
8
+ "text": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to the Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n\ngenro-dom-js\nCopyright 2025 Softwell S.r.l.\n\nThis product includes software developed at Softwell S.r.l.\n(https://www.softwell.it/).\n\nLicensed under the Apache License, Version 2.0.\n"
9
+ },
10
+ {
11
+ "name": "@genrojs/tytx",
12
+ "text": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright 2025 Softwell S.r.l.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\nGenro Project\nCopyright 2025-2026 Softwell S.r.l.\n\nThis product includes software developed by Softwell S.r.l.\n\nLicensed under the Apache License 2.0.\nYou may obtain a copy of the License at:\n\n https://www.apache.org/licenses/LICENSE-2.0\n"
13
+ },
14
+ {
15
+ "name": "@msgpack/msgpack",
16
+ "text": "Copyright 2019 The MessagePack Community.\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n"
17
+ },
18
+ {
19
+ "name": "@xmldom/xmldom",
20
+ "text": "Copyright 2019 - present Christopher J. Brody and other contributors, as listed in: https://github.com/xmldom/xmldom/graphs/contributors\nCopyright 2012 - 2017 @jindw <jindw@xidea.org> and other contributors, as listed in: https://github.com/jindw/xmldom/graphs/contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
21
+ },
22
+ {
23
+ "name": "big.js",
24
+ "text": "The MIT License (MIT)\r\n=====================\r\n\r\nCopyright © `<2024>` `Michael Mclaughlin`\r\n\r\nPermission is hereby granted, free of charge, to any person\r\nobtaining a copy of this software and associated documentation\r\nfiles (the “Software”), to deal in the Software without\r\nrestriction, including without limitation the rights to use,\r\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the\r\nSoftware is furnished to do so, subject to the following\r\nconditions:\r\n\r\nThe above copyright notice and this permission notice shall be\r\nincluded in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\r\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r\nOTHER DEALINGS IN THE SOFTWARE.\r\n\r\n"
25
+ },
26
+ {
27
+ "name": "decimal.js",
28
+ "text": "The MIT Licence.\r\n\r\nCopyright (c) 2025 Michael Mclaughlin\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining\r\na copy of this software and associated documentation files (the\r\n'Software'), to deal in the Software without restriction, including\r\nwithout limitation the rights to use, copy, modify, merge, publish,\r\ndistribute, sublicense, and/or sell copies of the Software, and to\r\npermit persons to whom the Software is furnished to do so, subject to\r\nthe following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be\r\nincluded in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\r\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n\r\n"
29
+ },
30
+ {
31
+ "name": "Gramlot",
32
+ "text": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to the Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n\nGramlot\nCopyright 2025-2026 Softwell S.r.l.\n\nThis product includes software developed at Softwell S.r.l.\n(https://www.softwell.it/), originally in Genro Pages and Genro DOM JS.\nThe original Genro DOM JS notice states: Copyright 2025 Softwell S.r.l.\n\nLicensed under the Apache License, Version 2.0.\n"
33
+ }
34
+ ]
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@gramlot/gramlot",
3
+ "version": "0.2.1",
4
+ "description": "Declarative HTML/SVG interfaces with live data binding, authored in JavaScript or Python.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/gramlot-org/gramlot.git",
9
+ "directory": "js"
10
+ },
11
+ "type": "module",
12
+ "scripts": {
13
+ "test": "node --test tests/*.test.js tests/binding-contracts/gramlot-quiet-write.test.mjs tests/upstream-regressions/builder-symbolic-attribute.test.mjs",
14
+ "build": "node scripts/build-runtime.mjs",
15
+ "test:host": "node --test tests/host.test.js",
16
+ "prepack": "node scripts/build-runtime.mjs"
17
+ },
18
+ "dependencies": {
19
+ "@genrojs/bag": ">=0.10.1",
20
+ "@genrojs/builders": ">=0.4.1",
21
+ "@genrojs/tytx": ">=0.16.1"
22
+ },
23
+ "devDependencies": {
24
+ "c8": "10.1.3",
25
+ "esbuild": "0.28.2",
26
+ "jsdom": "27.0.1"
27
+ },
28
+ "exports": {
29
+ ".": "./src/index.js",
30
+ "./server": "./src/adapters/index.js",
31
+ "./runtime": "./dist/gramlot.js",
32
+ "./page": "./src/adapters/page.js",
33
+ "./host": "./src/adapters/host.js"
34
+ },
35
+ "files": [
36
+ "LICENSE",
37
+ "NOTICE",
38
+ "src",
39
+ "dist"
40
+ ],
41
+ "engines": {
42
+ "node": ">=22"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ }
47
+ }
@@ -0,0 +1,93 @@
1
+ import {realpath, stat} from 'node:fs/promises';
2
+ import {basename, dirname, extname, isAbsolute, join, relative, resolve, sep} from 'node:path';
3
+ import {pathToFileURL} from 'node:url';
4
+ import {Host, PageNotFound} from './host.js';
5
+ import {InvalidResourceName, SEGMENT, parseRequires} from './resources.js';
6
+
7
+ const inside = (filename, folder) => {
8
+ const rel = relative(folder, filename);
9
+ return rel === '' || !(rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel));
10
+ };
11
+
12
+ // RFC 3986 unreserved characters stay literal, as with Python urllib.parse.quote(safe='').
13
+ const encodeSegment = segment => encodeURIComponent(segment)
14
+ .replace(/[!'()*]/g, character => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
15
+
16
+ /** Real path of filename, or null when it does not exist. */
17
+ async function realFile(filename) {
18
+ try {
19
+ const real = await realpath(filename);
20
+ return (await stat(real)).isFile() ? real : null;
21
+ } catch (error) {
22
+ if (['ENOENT', 'ENOTDIR'].includes(error.code)) return null;
23
+ throw error;
24
+ }
25
+ }
26
+
27
+ /** Minimal reference Host on one pages folder, with APIs shared by Node.js and Bun.
28
+ * The Python counterpart is src/gramlot/server/file_host.py. Page path foo: the
29
+ * file page foo.js first, then the folder page foo/foo.js; the file wins when both
30
+ * exist. Beside the page file: foo.css (CSS), foo_aux.js (JS module exporting
31
+ * Logic, group null) and foo.md (README). The _aux suffix is reserved. There are
32
+ * no resource levels: a name in css_requires/js_requires raises
33
+ * InvalidResourceName. Modules are trusted ESM application files; runtime module
34
+ * caching applies.
35
+ */
36
+ export class FileHost extends Host {
37
+ constructor(pagesDir, options = {}) {
38
+ super(options);
39
+ this._pagesDir = resolve(pagesDir);
40
+ }
41
+
42
+ get pagesDir() { return this._pagesDir; }
43
+
44
+ /** Map a/b to a/b.js, else a/b/b.js, below the real pages folder. */
45
+ async locatePage(path) {
46
+ const trimmed = path.replace(/^\/+|\/+$/g, '');
47
+ const parts = trimmed ? trimmed.split('/') : ['index'];
48
+ if (parts.some(part => !SEGMENT.test(part)) || parts.at(-1).endsWith('_aux')) {
49
+ throw new PageNotFound('Invalid page path');
50
+ }
51
+ let root;
52
+ try {
53
+ root = await realpath(this.pagesDir);
54
+ } catch (error) {
55
+ if (['ENOENT', 'ENOTDIR'].includes(error.code)) throw new PageNotFound('Page not found');
56
+ throw error;
57
+ }
58
+ const name = `${parts.at(-1)}.js`;
59
+ for (const candidate of [join(root, ...parts.slice(0, -1), name), join(root, ...parts, name)]) {
60
+ const real = await realFile(candidate);
61
+ if (real && inside(real, root)) return candidate;
62
+ }
63
+ throw new PageNotFound('Page not found');
64
+ }
65
+
66
+ async resolvePage(path) {
67
+ return (await import(pathToFileURL(await this.locatePage(path)).href)).Page;
68
+ }
69
+
70
+ /** Page.css URLs as written, then the companions foo.css and foo_aux.js. */
71
+ async resolveResources(path, PageClass) {
72
+ if (parseRequires(PageClass.css_requires).length || parseRequires(PageClass.js_requires).length) {
73
+ throw new InvalidResourceName('requires need a Host with a resource system');
74
+ }
75
+ const pageFile = await this.locatePage(path);
76
+ const stem = join(dirname(pageFile), basename(pageFile, extname(pageFile)));
77
+ const css = [...PageClass.css], js = [];
78
+ if (await realFile(`${stem}.css`)) css.push(await this.url(`${stem}.css`));
79
+ if (await realFile(`${stem}_aux.js`)) js.push({url: await this.url(`${stem}_aux.js`), group: null});
80
+ return {css, js};
81
+ }
82
+
83
+ /** Root-relative URL of a file below the pages folder, one encoded segment per
84
+ * folder; a file whose real path leaves the folder raises an Error. */
85
+ async url(filename) {
86
+ const root = await realpath(this.pagesDir);
87
+ const parts = relative(root, filename).split(sep);
88
+ if (!inside(await realpath(filename), root)) {
89
+ throw new Error(`Resource leaves the pages folder: ${parts.join('/')}`);
90
+ }
91
+ return '/' + parts.map(encodeSegment).join('/');
92
+ }
93
+ }
@@ -0,0 +1,128 @@
1
+ import {GramlotBuilder} from '../builder/gramlot-builder.js';
2
+ import {Page, sourceMethod} from './page.js';
3
+ import {loadOrder} from './resources.js';
4
+
5
+ export class PageExpired extends Error {}
6
+ export class PageNotFound extends Error {}
7
+ /** An unknown remote Source method, as the Python `SourceNotFound`. */
8
+ export class SourceNotFound extends Error {}
9
+ export class HostCapacity extends Error {}
10
+
11
+ const scriptJson = value => JSON.stringify(value).replaceAll('<', '\\u003c');
12
+
13
+ /** 16 random bytes in URL-safe base64 without padding, as Python secrets.token_urlsafe(16). */
14
+ function createNonce() {
15
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
16
+ return btoa(String.fromCharCode(...bytes)).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
17
+ }
18
+
19
+ /** Add the mount prefix once to a root-relative URL (/…, not //…); relative and
20
+ * absolute URLs stay as written. */
21
+ const prefixed = (prefix, url) => url.startsWith('/') && !url.startsWith('//') ? prefix + url : url;
22
+
23
+ /** Neutral host: no Node/Bun imports or server startup side effects. The core never
24
+ * searches files: override resolvePage and resolveResources in concrete integrations;
25
+ * FileHost implements them on one pages folder. Adapters supply request ownership.
26
+ */
27
+ export class Host {
28
+ constructor({runtimeUrl = '/assets/gramlot.js', mainUrl = '/gramlot/main', sourceUrl = '/gramlot/source',
29
+ closeUrl = '/gramlot/close',
30
+ rootId = 'gramlot-root', pageTtl = 1800, maxPages = 1000} = {}) {
31
+ if (typeof pageTtl !== 'number' || pageTtl <= 0 ||
32
+ !Number.isFinite(performance.now() + pageTtl * 1000) ||
33
+ !Number.isSafeInteger(maxPages) || maxPages < 1) {
34
+ throw new TypeError('Page TTL must be finite and positive; capacity must be a positive safe integer');
35
+ }
36
+ Object.assign(this, {runtimeUrl, mainUrl, sourceUrl, closeUrl, rootId, pageTtl, maxPages});
37
+ this.pages = new Map();
38
+ }
39
+
40
+ /** The Page class of path, or PageNotFound. */
41
+ async resolvePage(path) { throw new PageNotFound(`Page not found: ${path}`); }
42
+
43
+ /** {css: [url], js: [{url, group}]} in load order and without mount prefix, or PageNotFound. */
44
+ async resolveResources(path, PageClass) { throw new PageNotFound(`Page resources not found: ${path}`); }
45
+
46
+ prune() {
47
+ const now = performance.now();
48
+ for (const [id, record] of this.pages) if (record.expires <= now) this.pages.delete(id);
49
+ }
50
+
51
+ /** Register a page independently of its HTTP or Worker transport. */
52
+ async registerPage(path, {owner = null} = {}) {
53
+ const PageClass = await this.resolvePage(path);
54
+ if (typeof PageClass !== 'function' || !(PageClass.prototype instanceof Page)) {
55
+ throw new TypeError('Page modules must export a subclass of Page');
56
+ }
57
+ const resources = loadOrder(await this.resolveResources(path, PageClass));
58
+ this.prune();
59
+ if (this.pages.size >= this.maxPages) throw new HostCapacity('Page registry capacity reached');
60
+ const pageId = crypto.randomUUID().replaceAll('-', '');
61
+ this.pages.set(pageId, {PageClass, owner, expires: performance.now() + this.pageTtl * 1000});
62
+ return {pageId, title: PageClass.title, resources};
63
+ }
64
+
65
+ /** Register the page and return its bootstrap. prefix is the mount prefix chosen
66
+ * by the adapter, added once to the root-relative bootstrap URLs. */
67
+ async openPage(path, {owner = null, prefix = ''} = {}) {
68
+ if (typeof prefix !== 'string') throw new TypeError('Mount prefix must be a string');
69
+ const {pageId, title, resources} = await this.registerPage(path, {owner});
70
+ try {
71
+ const nonce = createNonce();
72
+ // The CSS links and the JS modules reach the page through PageBootstrap (§4.12, D9).
73
+ const bootstrap = scriptJson({
74
+ config: {pageId, mainUrl: prefixed(prefix, this.mainUrl), sourceUrl: prefixed(prefix, this.sourceUrl),
75
+ closeUrl: prefixed(prefix, this.closeUrl), rootId: this.rootId},
76
+ resources: {css: resources.css.map(url => prefixed(prefix, url)),
77
+ js: resources.js.map(({url, group}) => ({url: prefixed(prefix, url), group}))},
78
+ });
79
+ const document = new GramlotBuilder();
80
+ const root = document.root.html();
81
+ const head = root.head();
82
+ head.meta({charset: 'utf-8'});
83
+ head.title(title);
84
+ const body = root.body();
85
+ body.div({id: this.rootId});
86
+ body.script(`import {PageBootstrap} from ${scriptJson(prefixed(prefix, this.runtimeUrl))};` +
87
+ `await new PageBootstrap(${bootstrap}).run();`,
88
+ {type: 'module', nonce});
89
+ const html = document.render({doctype: true});
90
+ return {pageId, html, nonce};
91
+ } catch (error) {
92
+ this.closePage(pageId, {owner});
93
+ throw error;
94
+ }
95
+ }
96
+
97
+ async main(pageId, {owner = null} = {}) {
98
+ return this.buildSource(pageId, null, {}, owner);
99
+ }
100
+
101
+ /** A remote Source; `params` null or omitted is `{}`, as in Python (an adapter passes null when a request has none). */
102
+ async source(pageId, method, params = null, {owner = null} = {}) {
103
+ if (typeof method !== 'string' || method === 'main') throw new SourceNotFound('Unknown Source method');
104
+ if (params !== null && (typeof params !== 'object' || Array.isArray(params))) {
105
+ throw new TypeError('Source params must be an object');
106
+ }
107
+ return this.buildSource(pageId, method, params ?? {}, owner);
108
+ }
109
+
110
+ async buildSource(pageId, method, params, owner) {
111
+ this.prune();
112
+ const record = this.pages.get(pageId);
113
+ if (!record || record.owner !== owner) throw new PageExpired('Unknown, expired or unowned page');
114
+ const page = new record.PageClass();
115
+ page.pageId = pageId;
116
+ const callable = method === null ? page.main : sourceMethod(page, method);
117
+ if (!callable) throw new SourceNotFound(`Unknown Source method: ${method}`);
118
+ const builder = new record.PageClass.sourceBuilder();
119
+ const result = await callable.call(page, builder.root, params);
120
+ if (result !== undefined && result !== null) throw new TypeError('Source methods populate root and return no value');
121
+ return builder.toTytx();
122
+ }
123
+
124
+ closePage(pageId, {owner = null} = {}) {
125
+ if (this.pages.get(pageId)?.owner === owner) this.pages.delete(pageId);
126
+ }
127
+
128
+ }
@@ -0,0 +1,6 @@
1
+ // Server entry point: deliberately not re-exported by the browser entry point.
2
+ export {Page, source} from './page.js';
3
+ export {Host, PageExpired, PageNotFound, SourceNotFound, HostCapacity} from './host.js';
4
+ export {GramlotBuilder} from '../builder/gramlot-builder.js';
5
+ export {FileHost} from './file-host.js';
6
+ export {InvalidResourceName, parseRequires} from './resources.js';
@@ -0,0 +1,32 @@
1
+ import {GramlotBuilder} from '../builder/gramlot-builder.js';
2
+
3
+ const SOURCE_METHOD = Symbol('gramlot.source');
4
+
5
+ /** Explicit method registration, equivalent to Python @source without syntax transforms. */
6
+ export function source(method) {
7
+ if (typeof method !== 'function') throw new TypeError('source requires a method');
8
+ method[SOURCE_METHOD] = true;
9
+ return method;
10
+ }
11
+
12
+ export function sourceMethod(page, name) {
13
+ if (typeof name !== 'string' || !/^[A-Za-z][\w]*$/.test(name)) return null;
14
+ for (let proto = Object.getPrototypeOf(page); proto; proto = Object.getPrototypeOf(proto)) {
15
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
16
+ if (descriptor) return descriptor.value?.[SOURCE_METHOD] ? descriptor.value : null;
17
+ }
18
+ return null;
19
+ }
20
+
21
+ /** Host-side page base; unrelated to browser view components. */
22
+ export class Page {
23
+ static title = 'Gramlot';
24
+ static css = [];
25
+ static css_requires = '';
26
+ static js_requires = '';
27
+ static sourceBuilder = GramlotBuilder;
28
+
29
+ main(root) {
30
+ throw new Error('Page.main(root) must be implemented');
31
+ }
32
+ }
@@ -0,0 +1,73 @@
1
+ /** Resource names and bootstrap load order; no file lookup and no HTTP engine.
2
+ * The Python counterpart is src/gramlot/server/resources.py; both apply the same
3
+ * rules. css_requires/js_requires names are interpreted by a Host with a resource
4
+ * system, not by the core.
5
+ */
6
+ /** One segment of a resource or page name. */
7
+ export const SEGMENT = /^[A-Za-z0-9_-]+$/;
8
+ const EXTENSION = /^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)+$/;
9
+ // Unicode White_Space property (U+FEFF excluded); the Python parser strips the same characters.
10
+ export const SPACES = '\u0009\u000a\u000b\u000c\u000d \u0085  ' +
11
+ '           ' +
12
+ '

   ';
13
+
14
+ /** A page declares its resources in an invalid way. */
15
+ export class InvalidResourceName extends Error {}
16
+
17
+ function checkName(name) {
18
+ if (name.includes(':')) throw new InvalidResourceName(`Resource name "${name}": 'name:media' is not supported`);
19
+ const segments = name.split('/');
20
+ if (segments.some(segment => EXTENSION.test(segment))) {
21
+ throw new InvalidResourceName(`Resource name "${name}": names have no extension`);
22
+ }
23
+ if (!segments.every(segment => SEGMENT.test(segment))) {
24
+ throw new InvalidResourceName(`Invalid resource name "${name}": use '/'-separated segments ` +
25
+ "of letters, digits, '_' or '-'");
26
+ }
27
+ }
28
+
29
+ /** Strip the SPACES characters at both ends, as Python str.strip(SPACES). */
30
+ function stripSpaces(text) {
31
+ let start = 0, end = text.length;
32
+ while (start < end && SPACES.includes(text[start])) start++;
33
+ while (end > start && SPACES.includes(text[end - 1])) end--;
34
+ return text.slice(start, end);
35
+ }
36
+
37
+ /** Parse css_requires/js_requires: comma-separated resource names.
38
+ * Spaces around a name (SPACES), empty tokens and later duplicates are ignored.
39
+ */
40
+ export function parseRequires(text) {
41
+ if (typeof text !== 'string') throw new InvalidResourceName('Resource requirements must be a comma-separated string');
42
+ const names = [];
43
+ for (const token of text.split(',')) {
44
+ const name = stripSpaces(token);
45
+ if (!name || names.includes(name)) continue;
46
+ checkName(name);
47
+ names.push(name);
48
+ }
49
+ return names;
50
+ }
51
+
52
+ /** Keep each key once, in its last position. */
53
+ function lastOccurrence(items, key) {
54
+ const last = new Map(items.map((item, index) => [key(item), index]));
55
+ return items.filter((item, index) => last.get(key(item)) === index);
56
+ }
57
+
58
+ /** {css: [url], js: [{url, group}]} with each URL once, in its last position.
59
+ * The same JS URL with two different groups raises InvalidResourceName (C03):
60
+ * it is the same file declared under two names.
61
+ */
62
+ export function loadOrder(resources) {
63
+ const groups = new Map();
64
+ for (const entry of resources.js) {
65
+ if (!groups.has(entry.url)) groups.set(entry.url, entry.group);
66
+ const group = groups.get(entry.url);
67
+ if (group !== entry.group) {
68
+ throw new InvalidResourceName(`JS resource "${entry.url}" is declared with two groups: ` +
69
+ `${JSON.stringify(group)} and ${JSON.stringify(entry.group)}`);
70
+ }
71
+ }
72
+ return {css: lastOccurrence(resources.css, url => url), js: lastOccurrence(resources.js, entry => entry.url)};
73
+ }