diff --git a/baidudrive/Makefile b/baidudrive/Makefile index 98f847e1..905434bd 100644 --- a/baidudrive/Makefile +++ b/baidudrive/Makefile @@ -10,8 +10,8 @@ include $(TOPDIR)/rules.mk PKG_ARCH_BAIDUDRIVE:=$(ARCH) PKG_NAME:=baidudrive -PKG_VERSION:=baidudrive-runtime-v1.0.5 -PKG_RELEASE:=8 +PKG_VERSION:=linkeasefull-runtime-v3.0.6 +PKG_RELEASE:=9 PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/istoreos/istoreos-app-hub/releases/download/baidudrive-runtime-v$(PKG_VERSION)/ PKG_HASH:=skip diff --git a/linkease-common-bin/Makefile b/linkease-common-bin/Makefile index a33ef1ce..b8ef44e7 100644 --- a/linkease-common-bin/Makefile +++ b/linkease-common-bin/Makefile @@ -12,7 +12,7 @@ PKG_ARCH_LINKEASE:=$(ARCH) PKG_NAME:=linkease-common-bin # use PKG_SOURCE_DATE instead of PKG_VERSION for compitable PKG_SOURCE_DATE:=1.7.5 -PKG_RELEASE:=4 +PKG_RELEASE:=5 ARCH_HEXCODE:= ifeq ($(ARCH),x86_64) @@ -28,7 +28,7 @@ else ifeq ($(ARCH),mipsel) ARCH_HEXCODE=1b0c endif -PKG_SOURCE_VERSION:=b5383a43aa18185cc32c759d2b8536c235fe54aa +PKG_SOURCE_VERSION:=9f351503d4320bb3767c300bc677a85c5685c9ba PKG_SOURCE:=linkease-common-bin-$(PKG_SOURCE_DATE)-linux-$(PKG_ARCH_LINKEASE).tar.gz PKG_SOURCE_URL:=https://github.com/istoreos/istoreos-app-hub/releases/download/linkease-runtime-v$(PKG_SOURCE_DATE)/ PKG_BUILD_DIR:=$(BUILD_DIR)/linkease-common-bin-$(PKG_SOURCE_DATE)-linux-$(PKG_ARCH_LINKEASE) diff --git a/linkease/Makefile b/linkease/Makefile index cd062823..574545ca 100644 --- a/linkease/Makefile +++ b/linkease/Makefile @@ -12,7 +12,7 @@ PKG_ARCH_LINKEASE:=$(ARCH) PKG_NAME:=linkease # use PKG_SOURCE_DATE instead of PKG_VERSION for compitable PKG_SOURCE_DATE:=1.7.5 -PKG_RELEASE:=7 +PKG_RELEASE:=8 ARCH_HEXCODE:= ifeq ($(ARCH),x86_64) @@ -28,7 +28,7 @@ else ifeq ($(ARCH),mipsel) ARCH_HEXCODE=1b0c endif -PKG_SOURCE_VERSION:=b5383a43aa18185cc32c759d2b8536c235fe54aa +PKG_SOURCE_VERSION:=9f351503d4320bb3767c300bc677a85c5685c9ba PKG_SOURCE:=linkease-bin-$(PKG_SOURCE_DATE)-linux-$(PKG_ARCH_LINKEASE).tar.gz PKG_SOURCE_URL:=https://github.com/istoreos/istoreos-app-hub/releases/download/linkease-runtime-v$(PKG_SOURCE_DATE)/ PKG_BUILD_DIR:=$(BUILD_DIR)/linkease-bin-$(PKG_SOURCE_DATE)-linux-$(PKG_ARCH_LINKEASE) diff --git a/linkeasefull/Makefile b/linkeasefull/Makefile index 4f163abf..4bfff1f8 100644 --- a/linkeasefull/Makefile +++ b/linkeasefull/Makefile @@ -11,7 +11,7 @@ PKG_ARCH_LINKEASE:=$(ARCH) PKG_NAME:=linkeasefull # use PKG_SOURCE_DATE instead of PKG_VERSION for compitable PKG_SOURCE_DATE:=3.0.5 -PKG_RELEASE:=6 +PKG_RELEASE:=7 ARCH_HEXCODE:= ifeq ($(ARCH),x86_64) @@ -24,7 +24,7 @@ LINKEASE_RUNTIME_ARCH:=arm64 PKG_HASH:=skip endif -PKG_SOURCE_VERSION:=b5383a43aa18185cc32c759d2b8536c235fe54aa +PKG_SOURCE_VERSION:=9f351503d4320bb3767c300bc677a85c5685c9ba PKG_SOURCE:=linkease-runtime-$(PKG_SOURCE_DATE)-linux-$(LINKEASE_RUNTIME_ARCH).tar.gz PKG_SOURCE_URL:=https://github.com/istoreos/istoreos-app-hub/releases/download/linkeasefull-runtime-v$(PKG_SOURCE_DATE)/ PKG_BUILD_DIR:=$(BUILD_DIR)/linkease-runtime-$(PKG_SOURCE_DATE)-linux-$(LINKEASE_RUNTIME_ARCH) diff --git a/luci-app-nezhav1/Makefile b/luci-app-nezhav1/Makefile index 1fadeb73..b3bf886c 100644 --- a/luci-app-nezhav1/Makefile +++ b/luci-app-nezhav1/Makefile @@ -15,7 +15,7 @@ LUCI_TITLE:=Nezha Agent is the client version 2 of the Nezha Panel. LUCI_DEPENDS:=+nezha-agentv1 LUCI_PKGARCH:=all PKG_VERSION:=30.0 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_MAINTAINER:= include $(TOPDIR)/feeds/luci/luci.mk diff --git a/luci-app-nezhav1/luasrc/controller/nezha-agent.lua b/luci-app-nezhav1/luasrc/controller/nezha-agent.lua index 5295f1fc..03f8dcb8 100644 --- a/luci-app-nezhav1/luasrc/controller/nezha-agent.lua +++ b/luci-app-nezhav1/luasrc/controller/nezha-agent.lua @@ -1,11 +1,14 @@ module("luci.controller.nezha-agent", package.seeall) function index() - if not nixio.fs.access("/etc/config/nezha-agent") then - return - end - entry({"admin", "services", "nezha-agent"}, cbi("nezha-agent"), _("Nezha Agent"), 300).dependent = true - entry({"admin","services","nezha-agent","status"},call("act_status")).leaf=true + if not nixio.fs.access("/etc/config/nezha-agent") then + return + end + local page = entry({"admin", "services", "nezha-agent"}, cbi("nezha-agent"), nil, 300) + page.dependent = true + page.hidden = true + page.index = false -- 不在菜单索引中显示 + entry({"admin","services","nezha-agent","status"},call("act_status")).leaf=true end function trim(s) diff --git a/luci-app-openclaw/LICENSE b/luci-app-openclaw/LICENSE index f11cd790..f288702d 100644 --- a/luci-app-openclaw/LICENSE +++ b/luci-app-openclaw/LICENSE @@ -1,26 +1,674 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 -Copyright (c) 2025-2026 10000ge10000 -Project: luci-app-openclaw — OpenClaw AI Gateway LuCI Plugin for OpenWrt + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. + Preamble -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. -You should have received a copy of the GNU General Public License -along with this program. If not, see . + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. -The full text of the GNU General Public License version 3 is available at: -https://www.gnu.org/licenses/gpl-3.0.html -SOFTWARE. + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. -This project integrates with OpenClaw (https://github.com/nicepkg/openclaw), -which is licensed under its own terms. Node.js runtime downloaded during setup -is subject to the Node.js license (https://github.com/nodejs/node/blob/main/LICENSE). + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/luci-app-openclaw/Makefile b/luci-app-openclaw/Makefile index 00dabdc4..6061cb91 100644 --- a/luci-app-openclaw/Makefile +++ b/luci-app-openclaw/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclaw PKG_VERSION:=$(strip $(shell cat $(CURDIR)/VERSION 2>/dev/null || echo "1.0.0")) -PKG_RELEASE:=23 +PKG_RELEASE:=24 PKG_MAINTAINER:=10000ge10000 <10000ge10000@users.noreply.github.com> PKG_LICENSE:=GPL-3.0 diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index a174b1f1..3aa82157 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall -PKG_VERSION:=26.8.11 -PKG_RELEASE:=214 +PKG_VERSION:=26.8.12 +PKG_RELEASE:=215 PKG_PO_VERSION:=$(PKG_VERSION) PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua index cc43be8f..5c331768 100644 --- a/luci-app-passwall/luasrc/controller/passwall.lua +++ b/luci-app-passwall/luasrc/controller/passwall.lua @@ -1246,7 +1246,7 @@ function add_shunt_rule() if add_name then local has = uci:get(appname, uid) if has then - http_write_json_error({ message = "This ID already exists." }) + http_write_json_error({ message = i18n.translate("This ID already exists.") }) return end else diff --git a/luci-app-passwall/luasrc/view/passwall/rule/shunt_rule_list.htm b/luci-app-passwall/luasrc/view/passwall/rule/shunt_rule_list.htm index e3c694cc..a0ee9570 100644 --- a/luci-app-passwall/luasrc/view/passwall/rule/shunt_rule_list.htm +++ b/luci-app-passwall/luasrc/view/passwall/rule/shunt_rule_list.htm @@ -245,11 +245,12 @@ table td, .table .td { btn.disabled = false; } if (x && x.status === 200) { - origin_group_shunt_rule_order[group] = get_shunt_rule_order(group); +// origin_group_shunt_rule_order[group] = get_shunt_rule_order(group); alert("<%:Saved current page order successfully.%>"); - if (btn) { - btn.style.display = "none"; - } +// if (btn) { +// btn.style.display = "none"; +// } + window.location.reload(); } else { alert("<%:Save failed!%>"); } diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 72d7b95a..d4a020fd 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -1142,6 +1142,9 @@ msgstr "分流规则组" msgid "Please note attention to the priority, the higher the order, the higher the priority." msgstr "请注意优先级问题,排序越上面优先级越高。" +msgid "This ID already exists." +msgstr "该 ID 已存在。" + msgid "Update..." msgstr "更新中" diff --git a/luci-app-passwall/root/usr/share/passwall/iptables.sh b/luci-app-passwall/root/usr/share/passwall/iptables.sh index 34a8ceb4..ed90cfc3 100755 --- a/luci-app-passwall/root/usr/share/passwall/iptables.sh +++ b/luci-app-passwall/root/usr/share/passwall/iptables.sh @@ -46,6 +46,8 @@ FWI=$(uci -q get firewall.passwall.path 2>/dev/null) FAKE_IP="198.18.0.0/15" FAKE_IP_6="fc00::/18" +USE_GEOVIEW=0 + factor() { if [ -z "$1" ] || [ -z "$2" ]; then echo "" @@ -392,6 +394,28 @@ load_acl() { shunt6_set_name="psw_${sid}_shunt6" ipset -! create $shunt_set_name nethash maxelem 1048576 timeout 172800 ipset -! create $shunt6_set_name nethash family inet6 maxelem 1048576 timeout 172800 + # 预加载分流规则 ip 到 ipset + local GEOIP_CODE="" + local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') + local shunt_group shunt_id + if [ "${use_shunt_tcp}" = "1" ]; then + shunt_group=$(config_n_get $tcp_node shunt_group) + elif [ "${use_shunt_udp}" = "1" ]; then + shunt_group=$(config_n_get $udp_node shunt_group) + fi + for shunt_id in $shunt_ids; do + [ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue + config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | grep -v "^#" | sed -e "/^$/d" | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | sed -e "s/^/add $shunt_set_name &/g" -e "s/$/ timeout 0/g" | ipset -! -R + config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | grep -v "^#" | sed -e "/^$/d" | grep -E "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}" | sed -e "s/^/add $shunt6_set_name &/g" -e "s/$/ timeout 0/g" | ipset -! -R + [ "$USE_GEOVIEW" = "1" ] && { + local geoip_code=$(config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | sed -e "/^$/d" | grep -E "^geoip:" | grep -v "^geoip:private" | sed -E 's/^geoip:(.*)/\1/' | sed ':a;N;$!ba;s/\n/,/g') + [ -n "$geoip_code" ] && GEOIP_CODE="${GEOIP_CODE:+$GEOIP_CODE,}$geoip_code" + } + done + if [ -n "$GEOIP_CODE" ]; then + get_geoip $GEOIP_CODE ipv4 | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | sed -e "s/^/add $shunt_set_name &/g" -e "s/$/ timeout 0/g" | ipset -! -R + get_geoip $GEOIP_CODE ipv6 | grep -E "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}" | sed -e "s/^/add $shunt6_set_name &/g" -e "s/$/ timeout 0/g" | ipset -! -R + fi } } [ -n "${dns_redirect_port}" ] && dns_redirect=${dns_redirect_port} @@ -891,7 +915,7 @@ add_firewall_rule() { local USE_BLOCK_LIST_ALL=${USE_BLOCK_LIST} local _TCP_NODE=$(config_t_get global tcp_node) local _UDP_NODE=$(config_t_get global udp_node) - local USE_GEOVIEW=$(config_t_get global_rules enable_geoview) + USE_GEOVIEW=$(config_t_get global_rules enable_geoview) [ -z "$(first_type $(config_t_get global_app geoview_file) geoview)" ] && USE_GEOVIEW=0 [ -n "$_TCP_NODE" ] && [ "$(config_n_get $_TCP_NODE protocol)" = "_shunt" ] && USE_SHUNT_TCP=1 && USE_SHUNT_NODE=1 @@ -957,7 +981,7 @@ add_firewall_rule() { [ "$USE_SHUNT_NODE" = "1" ] && { local GEOIP_CODE="" local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') - local shunt_group + local shunt_group shunt_id if [ "${USE_SHUNT_TCP}" = "1" ]; then shunt_group=$(config_n_get $_TCP_NODE shunt_group) elif [ "${USE_SHUNT_UDP}" = "1" ]; then diff --git a/luci-app-passwall/root/usr/share/passwall/nftables.sh b/luci-app-passwall/root/usr/share/passwall/nftables.sh index 21c4428c..ad5b10fe 100755 --- a/luci-app-passwall/root/usr/share/passwall/nftables.sh +++ b/luci-app-passwall/root/usr/share/passwall/nftables.sh @@ -52,6 +52,8 @@ FWI=$(uci -q get firewall.passwall.path 2>/dev/null) FAKE_IP="198.18.0.0/15" FAKE_IP_6="fc00::/18" +USE_GEOVIEW=0 + factor() { local ports="$1" if [ -z "$1" ] || [ -z "$2" ] || [ "$ports" = "1:65535" ]; then @@ -453,6 +455,28 @@ load_acl() { gen_nftset $shunt_set_name_static ipv4_addr 0 gen_nftset $shunt6_set_name ipv6_addr "2d" gen_nftset $shunt6_set_name_static ipv6_addr 0 + # 预加载分流规则 ip 到 nftset + local GEOIP_CODE="" + local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') + local shunt_group shunt_id + if [ "${use_shunt_tcp}" = "1" ]; then + shunt_group=$(config_n_get $tcp_node shunt_group) + elif [ "${use_shunt_udp}" = "1" ]; then + shunt_group=$(config_n_get $udp_node shunt_group) + fi + for shunt_id in $shunt_ids; do + [ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue + config_n_get $shunt_id ip_list | sed 's/#.*//' | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | insert_nftset $shunt_set_name_static + config_n_get $shunt_id ip_list | sed 's/#.*//' | grep -E "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}" | insert_nftset $shunt6_set_name_static + [ "$USE_GEOVIEW" = "1" ] && { + local geoip_code=$(config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | sed -e "/^$/d" | grep -E "^geoip:" | grep -v "^geoip:private" | sed -E 's/^geoip:(.*)/\1/' | sed ':a;N;$!ba;s/\n/,/g') + [ -n "$geoip_code" ] && GEOIP_CODE="${GEOIP_CODE:+$GEOIP_CODE,}$geoip_code" + } + done + if [ -n "$GEOIP_CODE" ]; then + get_geoip $GEOIP_CODE ipv4 | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | insert_nftset $shunt_set_name_static + get_geoip $GEOIP_CODE ipv6 | grep -E "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}" | insert_nftset $shunt6_set_name_static + fi } } [ -n "${dns_redirect_port}" ] && dns_redirect=${dns_redirect_port} @@ -954,7 +978,8 @@ add_firewall_rule() { if [ -f $RULES_PATH/chnroute.nft ] && [ -s $RULES_PATH/chnroute.nft ] && [ $(awk 'END{print NR}' $RULES_PATH/chnroute.nft) -ge 8 ]; then nft -f $RULES_PATH/chnroute.nft else - cat $RULES_PATH/chnroute | tr -s '\n' | sed 's/#.*//' | gen_nftset $NFTSET_CHN_STATIC ipv4_addr 0 + gen_nftset $NFTSET_CHN_STATIC ipv4_addr 0 + cat $RULES_PATH/chnroute | tr -s '\n' | sed 's/#.*//' | insert_nftset $NFTSET_CHN_STATIC fi gen_nftset $NFTSET_BLACK ipv4_addr "2d" gen_nftset $NFTSET_BLACK_STATIC ipv4_addr 0 @@ -975,7 +1000,8 @@ add_firewall_rule() { #echolog "使用缓存加载chnroute6..." nft -f $RULES_PATH/chnroute6.nft else - cat $RULES_PATH/chnroute6 | tr -s '\n' | sed 's/#.*//' | gen_nftset $NFTSET_CHN6_STATIC ipv6_addr 0 + gen_nftset $NFTSET_CHN6_STATIC ipv6_addr 0 + cat $RULES_PATH/chnroute6 | tr -s '\n' | sed 's/#.*//' | insert_nftset $NFTSET_CHN6_STATIC fi gen_nftset $NFTSET_BLACK6 ipv6_addr "2d" gen_nftset $NFTSET_BLACK6_STATIC ipv6_addr 0 @@ -993,7 +1019,7 @@ add_firewall_rule() { local USE_BLOCK_LIST_ALL=${USE_BLOCK_LIST} local _TCP_NODE=$(config_t_get global tcp_node) local _UDP_NODE=$(config_t_get global udp_node) - local USE_GEOVIEW=$(config_t_get global_rules enable_geoview) + USE_GEOVIEW=$(config_t_get global_rules enable_geoview) [ -z "$(first_type $(config_t_get global_app geoview_file) geoview)" ] && USE_GEOVIEW=0 [ -n "$_TCP_NODE" ] && [ "$(config_n_get $_TCP_NODE protocol)" = "_shunt" ] && USE_SHUNT_TCP=1 && USE_SHUNT_NODE=1 @@ -1059,7 +1085,7 @@ add_firewall_rule() { [ "$USE_SHUNT_NODE" = "1" ] && { local GEOIP_CODE="" local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') - local shunt_group + local shunt_group shunt_id if [ "${USE_SHUNT_TCP}" = "1" ]; then shunt_group=$(config_n_get $_TCP_NODE shunt_group) elif [ "${USE_SHUNT_UDP}" = "1" ]; then diff --git a/luci-theme-footstrap/Makefile b/luci-theme-footstrap/Makefile index f638dd5d..5019a34a 100644 --- a/luci-theme-footstrap/Makefile +++ b/luci-theme-footstrap/Makefile @@ -17,15 +17,15 @@ LUCI_NAME:=luci-theme-footstrap FOOTSTRAP_VERSION?= ifneq ($(FOOTSTRAP_VERSION),) PKG_VERSION:=$(FOOTSTRAP_VERSION) -PKG_RELEASE:=13 +PKG_RELEASE:=14 endif LUCI_TITLE:=Footstrap Theme -# +luci-base is the WHOLE list. The self-updater used to hard-require `curl`, which is NOT in -# OpenWrt's default package set (the base image ships uclient-fetch), so the update button -# failed on a stock router; it falls back to uclient-fetch rather than pull curl onto an 8 MB -# device for one API call. jsonfilter and sha256sum ARE in the base image. Do not add a -# runtime dep for a convenience tool — fall back instead. +# +luci-base is the WHOLE list, and keeping it that way is the constraint. Nothing this package +# ships fetches anything at run time any more (the self-updater is retired), so there is no second +# name to justify — and the rule that got it here stands: the one convenience tool that ever wanted +# a dep was `curl`, which is NOT in OpenWrt's default set, on an 8 MB device, for one API call. Fall +# back to what the base image has (uclient-fetch, jsonfilter, sha256sum) or do without. LUCI_DEPENDS:=+luci-base LUCI_PKGARCH:=all # Else luci.mk defaults these to LuCI's own, and the package claims MAINTAINER "OpenWrt LuCI @@ -159,7 +159,8 @@ endef # build-css.sh reads it from $(CURDIR) and writes into the build tree. cat/awk only, no host # toolchain: that is why it runs on an OpenWrt buildbot. # 2. Stamp the git-derived version into the theme JS (fs-version.js — the string the Appearance tab -# shows). Skipped when PKG_VERSION is empty, leaving '0.0.0-dev'. +# shows). Unconditional: with PKG_VERSION empty it falls back to PKG_SRC_VERSION, which luci.mk +# always defines, so only an un-built source checkout keeps the literal '0.0.0-dev'. # # THE CATALOGUE IS luci.mk's BUSINESS, and nothing here compiles it. `po/` is the directory # LUCI_LANGUAGES globs, so luci.mk emits one `luci-i18n-footstrap-` package per language the @@ -190,9 +191,9 @@ define Build/Prepare/luci-theme-footstrap $(SHELL) $(CURDIR)/mangle-tokens.sh \ $(PKG_BUILD_DIR)/htdocs/luci-static/footstrap/cascade.css \ $(CURDIR)/htdocs/luci-static/resources $(CURDIR)/ucode - # Templates are 58% comments and shipped them all. jsmin/terser strip the JS, build-css.sh the + # Templates are mostly comments and shipped them all. jsmin/terser strip the JS, build-css.sh the # CSS; the .ut files were simply never included in that trade. Only `{# … #}` goes — see the - # script for why the ucode-code `/* … */` deliberately stays. -16 KB of 39, git keeps every word, + # script for why the ucode-code `/* … */` deliberately stays. -22 KB of 60, git keeps every word, # and dev-sync.sh does NOT run this: a router you are debugging on keeps its comments. $(SHELL) $(CURDIR)/strip-templates.sh $(PKG_BUILD_DIR)/ucode # …and the same for the shell under root/ (71% and 95% comment lines). Whole-line `#` only. diff --git a/luci-theme-footstrap/build-apk.sh b/luci-theme-footstrap/build-apk.sh index 0d86edb1..68048c7c 100755 --- a/luci-theme-footstrap/build-apk.sh +++ b/luci-theme-footstrap/build-apk.sh @@ -1,6 +1,6 @@ #!/bin/sh # Build luci-theme-footstrap as an OpenWrt .apk via the SDK. -# The theme is noarch (CSS/JS/templates/fonts only), so the package installs on any +# The theme is noarch (CSS, JS and templates only — it ships no fonts), so the package installs on any # router of that release whatever its CPU architecture. # # ./build-apk.sh # download SDK if needed, then build @@ -13,9 +13,15 @@ # has never heard of owfeed — and this is the only way to find out that it does. set -e -REL="${OPENWRT_RELEASE:-25.12.2}" +# The point release and the compiler are both baked into the SDK's filename, so this default goes +# stale twice over: downloads.openwrt.org keeps only the CURRENT point release of a branch (older +# ones move to archive.openwrt.org and the fetch 404s), and a toolchain bump changes gcc-14.3.0. +# Kept in step with owfeed.lock's `point:` for the 25.12 branch — that file is what the release +# actually builds against. Override for any other: OPENWRT_RELEASE=24.10.8 sh build-apk.sh, and +# OPENWRT_SDK_FILE=… when the compiler string differs too. +REL="${OPENWRT_RELEASE:-25.12.5}" SDK_BASE="https://downloads.openwrt.org/releases/${REL}/targets/mediatek/filogic" -SDK_FILE="openwrt-sdk-${REL}-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64.tar.zst" +SDK_FILE="${OPENWRT_SDK_FILE:-openwrt-sdk-${REL}-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64.tar.zst}" SDK_URL="$SDK_BASE/$SDK_FILE" # MUST be a case-sensitive fs (ext4/…), NOT an NTFS/9p Windows mount. BUILD_DIR="${BUILD_DIR:-/tmp/ow-footstrap-build}" diff --git a/luci-theme-footstrap/build-css.sh b/luci-theme-footstrap/build-css.sh index d7b63cf7..f3342357 100755 --- a/luci-theme-footstrap/build-css.sh +++ b/luci-theme-footstrap/build-css.sh @@ -7,7 +7,7 @@ # order within a dir. A later layer beats an earlier one whatever the specificity, so # nothing needs !important to override base (declared in styles/00-header.css). # -# Minified unless --dev: ~287 KB of source -> ~111 KB (-61%). uhttpd serves CSS with NO +# Minified unless --dev: ~468 KB of source -> ~136 KB (-71%). uhttpd serves CSS with NO # gzip, so every byte is a wire byte. Comments and whitespace go; a selector or a # declaration is never rewritten, which is why LuCI's csstidy stays off (it mangles # :has()/color-mix()). Needs only cat/awk, so an OpenWrt buildbot can run it. diff --git a/luci-theme-footstrap/dev-sync.sh b/luci-theme-footstrap/dev-sync.sh index ea8f7b91..46af51b8 100755 --- a/luci-theme-footstrap/dev-sync.sh +++ b/luci-theme-footstrap/dev-sync.sh @@ -22,9 +22,9 @@ scp -q "$D"/ucode/template/themes/$N/*.ut "$R":/usr/share/ucode/luci/templ ssh "$R" "mkdir -p /usr/share/ucode/luci/template/themes/$N/partials" scp -q "$D"/ucode/template/themes/$N/partials/*.ut "$R":/usr/share/ucode/luci/template/themes/$N/partials/ -# shared static (cascade.css, fonts, logo). The doodle wallpapers are NOT here and not in the -# package: they are downloaded on demand from GitHub (fs-prefs.js installWallpaper), so the dev -# router deliberately starts without them — that is the state to test the download dialog in. +# shared static: cascade.css and the two logo files, which is all this directory holds. No +# wallpapers — the doodles this theme once downloaded from GitHub are gone, and nothing in the +# package fetches anything at run time; the Background axis paints an SVG the admin uploads. scp -qr "$D"/htdocs/luci-static/$N/* "$R":/www/luci-static/$N/ # EVERY resource JS, by GLOB — never by name. This used to list the four files @@ -41,17 +41,27 @@ tar -C "$D/htdocs/luci-static/resources" -cf - . | ssh "$R" "mkdir -p /www/luci- # Build/Prepare) so the Footstrap tab shows a real version instead of "(dev)". The FILE NAME is part # of the contract: FS_VERSION lives in fs-version.js and moving it means changing every sed. FS_V="$(git -C "$D" describe --tags --always 2>/dev/null | sed 's/^v//')" -# if-form, not `[ -n ] && ssh`: under set -e a failed &&-list aborts the whole sync when git -# describe yields nothing (a copied tree without .git). expr refuses a tag with -# sed/shell-special characters rather than interpolating it. +# if-form, not `[ -n ] && ssh`: under `set -e` a bare `&&`-list whose LAST command fails is what +# aborts, so `[ -n "$FS_V" ] && ssh …` would take the sync down whenever git describe yielded +# nothing (a copied tree without .git). An `&&` used to guard an ASSIGNMENT is a different shape and +# is safe — stage.sh:41 and update-po.sh:39 rely on that. expr refuses a tag with sed/shell-special +# characters rather than interpolating it. if [ -n "$FS_V" ] && expr "$FS_V" : '[0-9A-Za-z._-]*$' >/dev/null; then ssh "$R" "sed -i \"s#const FS_VERSION *= *'[^']*'#const FS_VERSION = '$FS_V'#\" /www/luci-static/resources/fs-version.js" fi -# The catalogue, which the PACKAGE compiles in Build/Prepare. po2lmo is a luci-base host tool, -# absent from a dev machine by default, so this is best-effort: without it the strings stay -# English and the sync still succeeds. (Build it once from the pinned luci commit: cc -o po2lmo -# po2lmo.c lib/lmo.c lib/plural_formula.c.) Same basename as the package — see the Makefile. +# The catalogue. Nothing in Build/Prepare compiles it, and the RELEASE does not come from luci.mk +# either: owfeed bundles the catalogues inside the theme package (owfeed.yml), so a dev router gets +# them from nowhere unless this sync makes them. po2lmo is a luci-base host tool, absent from a dev +# machine by default, so this is best-effort: without it the strings stay English and the sync still +# succeeds. (Build it once from the pinned luci checkout: make -C modules/luci-base/src po2lmo — +# plural_formula.c is GENERATED by contrib/lemon, so a bare cc over the .c files cannot work.) +# +# THE BASENAME IS `footstrap-theme`, matching owfeed.yml and NOT the po file's own name: lmo_load_ +# catalog globs *..lmo so any basename loads, and a v0.8.4 router still owns footstrap.ru.lmo +# through the old luci-i18n package, where the same path would be a file conflict. Sync under a +# different name and the dev router carries two archives for the same msgids, with glob order +# deciding which one the page shows. if command -v po2lmo >/dev/null 2>&1; then ssh "$R" "mkdir -p /usr/lib/lua/luci/i18n" for po in "$D"/po/*/*.po; do diff --git a/luci-theme-footstrap/htdocs/luci-static/resources/fs-appearance.js b/luci-theme-footstrap/htdocs/luci-static/resources/fs-appearance.js index 91faf8b4..6abf2b45 100644 --- a/luci-theme-footstrap/htdocs/luci-static/resources/fs-appearance.js +++ b/luci-theme-footstrap/htdocs/luci-static/resources/fs-appearance.js @@ -11,8 +11,8 @@ * * WHERE IT LIVES. It used to be a popover hanging off a button in the chrome; it is now a TAB on * System -> System (admin/system/system), beside General Settings / Logging / Time Synchronization - * / Language and Style — the page an admin already opens to set the things that are not network. The axes had outgrown a floating panel — eighteen of them, nine - * carrying a colour field, a swatch and a contrast readout — and a dialog that has to trap Tab, + * / Language and Style — the page an admin already opens to set the things that are not network. The axes had outgrown a floating panel — twenty-one of + * them, nine carrying a colour field, a swatch and a contrast readout — and a dialog that has to trap Tab, * place itself against a viewport edge and stay inside a 320px column is the wrong container for * that. Keeping BOTH would have meant every axis rendered twice, which is the failure this file's * own history is made of. @@ -46,9 +46,12 @@ * the current look to the ROUTER for other browsers. That distinction is the whole model * (docs/design-system.md) and it is why this page has no Save/Reset footer of LuCI's own. */ function render() { - /* still a promise: the view awaits it, and keeping the shape means a future asynchronous step - * (or the caller) needs no change. */ - return Promise.resolve(build()); + /* A promise, and the build runs INSIDE it rather than as its argument: `Promise.resolve(build())` + * evaluates build() synchronously, so a throw in it unwound out of render() before mount() could + * attach .catch/.finally — leaving mount()'s _building flag set for the life of the document. The + * tab then never built again on that page and nothing was logged, which is both channels silent + * at once. Deferred like this, the same throw lands in the .catch that exists for it. */ + return Promise.resolve().then(build); } function build() { @@ -219,15 +222,15 @@ function build() { /* the STRENGTH half of the Tint — how strong the hue reads. Only meaningful in hue mode: a * hex canvas IS the colour asked for, with no chroma of ours to scale. CSS hides it in the * other two states (no tint at all, or a hex one). */ - /* NOT "Density": that is the UI-density segment above, and this string is both the visible + /* NOT "Density": that is the UI-density select above, and this string is both the visible * caption AND the control's aria-label, so two rows would read "Density" and a screen reader - * would announce "Density, radio group" and "Density, slider" with nothing to tell them + * would announce "Density, combo box" and "Density, slider" with nothing to tell them * apart. */ group(_('Tint strength', 'footstrap'), (label) => sliderCtl(prefs.currentTintStrength(), 0, 200, bump(repaint(prefs.applyTintStrength)), label, { step: 5, - fmt: (v) => v + '%' - }), { cls: 'fs-ap-tint fs-ap-density' }), + unit: '%' + }), { cls: 'fs-ap-tint fs-ap-tintstr' }), /* recolours the accented CONTROLS (buttons/toggles/sliders/focus rings), not the canvas the * way Tint does. Measured as TEXT on a card, which is the use that fails first: as a fill it @@ -487,8 +490,21 @@ function build() { const saveErr = E('div', { 'class': 'fs-ap-err', 'role': 'alert', 'hidden': '' }); /* the Save button IS the status: match -> disabled "Saved as default", diverged -> enabled - * "Save as default". Called after every axis change (via bump). */ + * "Save as default". Called after every axis change (via bump). + * + * Unless this browser refuses storage, in which case the status would be a lie in both halves: + * nothing was written, so every current*() reads the ROUTER default back and the comparison is + * true however far the page has been dragged from it. Say what is actually true instead — the + * axes apply and are forgotten on reload — and leave the button enabled, because pushing this + * browser's look to the router is the one thing that still works here. */ function refreshSave() { + if (prefs.storageBroken()) { + saveBtn.disabled = false; + saveBtn.textContent = _('Save as default', 'footstrap'); + saveErr.textContent = _('This browser is not storing preferences (site data is blocked), so a change here lasts until you reload. Saving as default still works and applies to every browser.', 'footstrap'); + saveErr.hidden = false; + return; + } const saved = prefs.matchesSavedDefault(); saveBtn.disabled = saved; saveBtn.textContent = saved ? _('Saved as default', 'footstrap') : _('Save as default', 'footstrap'); @@ -615,8 +631,9 @@ function build() { open = !open; prefs.lsSet(key, open ? 'on' : 'off'); paint(); - /* the colour controls read the COMPUTED cascade, and a hidden element computes nothing - * useful — so the readouts are filled when the group becomes visible, not before */ + /* Refreshed on OPEN because the axes below it may have moved while it was collapsed — + * a palette switch or a preset changes what every readout says. Cheap and skipped + * while closed: nothing in that fold is on screen to be wrong. */ if (open) refreshColours(); }); paint(); @@ -637,10 +654,11 @@ function build() { section(_('Defaults', 'footstrap'), defaults) ]); - /* The colour controls read the COMPUTED cascade, which needs them in the document — so the first - * fill cannot happen while the tree is still being assembled above. The view appends this - * element synchronously on return, so a microtask is late enough and early enough: late enough - * that the probe resolves, early enough that nothing has painted a blank field. */ + /* The first fill, deferred one microtask so the tree above is finished being assembled. It does + * NOT wait for the form to be in the document, and does not need to: every value a readout shows + * comes back through widgets.probeColor(), which keeps its own hidden probe attached to + * and resolves the cascade there — so this runs while the form is still detached (mount() appends + * it a microtask later) and still reads the live palette. */ Promise.resolve().then(refreshColours); return page; } @@ -666,7 +684,9 @@ function takeReturn() { return true; } catch (e) { return false; } } -const MARK = 'fs-ap'; /* the built form's own class; also how mount() knows it is already there */ +const MARK = 'fs-ap'; +/* how long the stock view gets to render its tabs before a missing group counts as a failure */ +const TAB_DEADLINE = 5000; /* the built form's own class; also how mount() knows it is already there */ const TAB = 'fs-appearance'; /* the pane's data-tab, which ui.tabs' click handler matches on */ let _routeObserver = null, _viewObserver = null, _observedView = null, _building = false; @@ -692,11 +712,31 @@ function stopWatch() { * yet is a page still rendering, not a page without tabs. * * The flag and the sibling are the whole test, deliberately: the panes themselves are NOT required - * to be found here. On the stock System page they are not direct children of the marked element at - * all — the map nests them a level deeper — so a `:scope > .cbi-tabcontainer` check found none and - * the tab was never added, silently, on a page that plainly has tabs. */ + * to be found here, and a check for them by CLASS is what failed. A modern pane carries no class at + * all — form.js gives it `data-tab` and `data-tab-title` and nothing else, and `.cbi-tabcontainer` + * is luci-compat vocabulary from the Lua CBI — so `:scope > .cbi-tabcontainer` matched nothing on a + * page that plainly has tabs, and the tab was never added, silently. ui.tabs itself marks + * `panes[0].parentNode`, so the panes ARE this element's children; they are simply not identifiable + * that way. */ +/* Tab groups that belong to the page we just LEFT. The router stamps body[data-page] before the + * incoming view renders, and on a warm route #view still holds the outgoing page's DOM at that + * moment — so mount() found ITS tab strip and appended the whole Appearance form, plus a live, + * clickable "Footstrap"
  • , to another page's tabs. Measured arriving at System -> System from + * Network -> DHCP: two builds for one arrival, and for 66 ms on localhost (an RTT or more on a real + * router, since the window is the incoming view's load()) the tab sat on the DHCP strip and opened + * all 24 Appearance rows when clicked. Every group present at the moment of the stamp is therefore + * disqualified; the incoming view's own group is a fresh element and is not in this set. */ +const _staleGroups = new WeakSet(); +function disqualifyCurrentGroups() { + const view = document.getElementById('view'); + if (!view) return; + for (const g of view.querySelectorAll('[data-initialized="true"]')) + _staleGroups.add(g); +} + function tabGroup(view) { for (const g of view.querySelectorAll('[data-initialized="true"]')) { + if (_staleGroups.has(g)) continue; const menu = g.previousElementSibling; if (menu?.classList.contains('cbi-tabmenu')) return { group: g, menu }; @@ -739,8 +779,10 @@ function mount() { const title = 'Footstrap'; /* data-tab-active is deliberately absent: the stock page opens on whichever tab it * opened on before, and a theme has no business taking that over. */ + /* The same shape a stock pane has, which is `data-tab` + `data-tab-title` and no class: + * ui.tabs.switchTab reads the attributes, and the `cbi-tabcontainer` class this used to + * carry is luci-compat's, styled by no rule this theme ships. */ t.group.appendChild(E('div', { - 'class': 'cbi-tabcontainer', 'data-tab': TAB, 'data-tab-title': title }, [ form ])); @@ -764,13 +806,32 @@ function watch() { _viewObserver = new MutationObserver(mount); _viewObserver.observe(view, { childList: true, subtree: true }); mount(); + /* A DEADLINE on the one failure that is otherwise perfectly silent. tabGroup() reads three + * private ui.tabs facts — the `data-initialized` marker, the `cbi-tabmenu` class on the menu it + * inserts, and `cbi-tab-disabled` on the items — and one of those has already moved between + * 24.10 and 25.12 (`data-tab-group` was dropped with no announcement). If any of the three we do + * read goes the same way, mount() simply returns early on every mutation: the stock page renders + * perfectly, nothing throws, and every Appearance axis becomes unreachable. Say it once, after + * the page has had time to render. */ + window.setTimeout(() => { + const v = document.getElementById('view'); + if (!onPage() || !v || v.querySelector('.' + MARK) || _building) return; + console.error('footstrap: the Appearance tab could not be attached — this page has tabs, but ' + + 'ui.tabs no longer marks them the way fs-appearance.js looks for. Every Appearance axis ' + + 'is unreachable until that is updated.'); + }, TAB_DEADLINE); } /* Called by menu-footstrap-common's init, once. Everything route-dependent hangs off the data-page * observer inside. */ function wire() { if (_routeObserver || !document.body) return; - _routeObserver = new MutationObserver(() => (onPage() ? watch() : stopWatch())); + _routeObserver = new MutationObserver(() => { + /* BEFORE deciding anything: whatever is in #view at the moment data-page changes belongs to + * the page being left (see _staleGroups). */ + disqualifyCurrentGroups(); + return onPage() ? watch() : stopWatch(); + }); _routeObserver.observe(document.body, { attributes: true, attributeFilter: [ 'data-page' ] }); if (onPage()) watch(); } diff --git a/luci-theme-footstrap/htdocs/luci-static/resources/fs-chrome.js b/luci-theme-footstrap/htdocs/luci-static/resources/fs-chrome.js index 62fa89b7..e6d4cd62 100644 --- a/luci-theme-footstrap/htdocs/luci-static/resources/fs-chrome.js +++ b/luci-theme-footstrap/htdocs/luci-static/resources/fs-chrome.js @@ -151,7 +151,7 @@ function resolveLen(token, dflt) { * stylesheet's widths in two different places. Reaching for these means the measurement failed. */ const GEOM_DFLT = { contentMin: 500, sidebarW: 224, railW: 68, contentPad: 56 }; -let _geom = null, _geomDensity = null; +let _geom = null, _geomDensity = null, _geomWarned = false; function shellGeometry() { const density = document.documentElement.getAttribute('data-density') || ''; if (_geom && _geomDensity === density) return _geom; @@ -170,7 +170,19 @@ function shellGeometry() { * absent token reports 0 for all four (an abs-positioned empty div with `width:auto` shrinks to * 0, and 0 is finite, so the per-read fallback above never fires). Neither can be seen in the * numbers one at a time; the RELATION between them is what gives it away. */ - _geom = (g.railW > 0 && g.railW < g.sidebarW && g.contentMin > 0) ? g : Object.assign({}, GEOM_DFLT); + const sane = (g.railW > 0 && g.railW < g.sidebarW && g.contentMin > 0); + /* SAY SO when it fires. The fallback keeps the chrome laid out, which is right — but it lays it + * out on the literals CLAUDE.md forbids copying into JS, so from there on the sidebar folds at a + * width nobody chose while the page still LOOKS correct. Silent, that is how a renamed token + * ships green; one console line is the difference between a mystery and a grep. Once per + * document — this runs on every resize and every mutation. */ + if (!sane && !_geomWarned) { + _geomWarned = true; + console.error('footstrap: the chrome widths did not read back from the stylesheet (got ' + + JSON.stringify(g) + ') — falling back to the built-in defaults. A --fs-* width token was ' + + 'renamed, or a foreign sheet is reaching the measurement probe.'); + } + _geom = sane ? g : Object.assign({}, GEOM_DFLT); return _geom; } @@ -236,8 +248,8 @@ function fitChrome() { } /* The cluster's own escalation, for EVERY bar — the top layout at any width, and the sidebar - * layout once fitShell has stamped data-narrow. It runs after the menu's, because on the top - * layout .fs-bar-stack has by then given the menu its own row and taken it out of the sum. */ + * layout once fitShell has stamped data-narrow. It runs after the menu's, so that when the menu + * did NOT fit, .fs-bar-stack has already given it a row of its own. */ if (bar && (topBar || document.documentElement.hasAttribute('data-narrow'))) fitCluster(bar, menu); } @@ -268,8 +280,12 @@ function fitCluster(bar, menu) { /* Add the widths up rather than read positions: the bar is align-items:center over children of * differing heights, so offsetTop differs even on ONE row — the same trap the menu measurement - * documents above. The menu is excluded because it owns a full-width row of its own in every bar - * (`ul.nav { flex: 1 1 100% }`), so it is never what the cluster competes with. */ + * documents above. The menu is excluded either way. Where it wraps to a row of its own it plainly + * is not competing (`ul.nav { flex: 1 1 100% }` — the sidebar-layout bar, and the top bar once + * .fs-bar-stack is set); where it does share the brand's row, un-stacked at `flex: 1 1 auto` + * (theme/50-toplayout.css), it is the one child that SHRINKS, so counting its current width would + * report the cluster as not fitting whenever the menu happened to be wide. What the cluster has to + * fit beside is the brand and the other actions. */ function clusterFitsBrandRow(bar, menu) { const cs = getComputedStyle(bar); const gap = parseFloat(cs.columnGap) || 0; @@ -292,8 +308,7 @@ function clusterFitsBrandRow(bar, menu) { * MutationObserver already watches — and it re-fits SYNCHRONOUSLY (rule 2), where the copy here * deferred through fit.schedule(), i.e. the duplicate was strictly the slower path into the same * work. #tabmenu is a sibling of #view rather than inside it, but nothing writes it except - * renderChrome(), which schedules a fit itself. Resize is fs-fit's ResizeObserver on #view (with a - * window-resize fallback where there is no RO). */ + * renderChrome(), which schedules a fit itself. Resize is fs-fit's ResizeObserver on #view. */ /* modes -> #modemenu; drives the injected renderMainMenu for the active mode */ function renderModeMenu(node, renderMainMenu) { diff --git a/luci-theme-footstrap/htdocs/luci-static/resources/fs-fit.js b/luci-theme-footstrap/htdocs/luci-static/resources/fs-fit.js index b5f2faf2..194835be 100644 --- a/luci-theme-footstrap/htdocs/luci-static/resources/fs-fit.js +++ b/luci-theme-footstrap/htdocs/luci-static/resources/fs-fit.js @@ -44,13 +44,11 @@ function schedule() { /* Watch an element's size. Any change re-fits everything — the fitters are cheap and few. */ function watch(el) { if (!el) return; - if (!_ro) { - if (!window.ResizeObserver) { /* no RO: fall back to the window */ - window.addEventListener('resize', schedule); - return; - } - _ro = new ResizeObserver(schedule); - } + /* No feature test: the shipped CSS needs :has() and container queries, both years younger than + * ResizeObserver in every engine, so a browser that can render this theme at all has it. The + * window-resize fallback that used to sit here was worse than nothing anyway — it cannot see a + * rail collapse or a layout toggle, which is the pair this file uses an observer FOR. */ + if (!_ro) _ro = new ResizeObserver(schedule); _ro.observe(el); } diff --git a/luci-theme-footstrap/htdocs/luci-static/resources/fs-menutree.js b/luci-theme-footstrap/htdocs/luci-static/resources/fs-menutree.js index 02d23924..21f52eb2 100644 --- a/luci-theme-footstrap/htdocs/luci-static/resources/fs-menutree.js +++ b/luci-theme-footstrap/htdocs/luci-static/resources/fs-menutree.js @@ -138,8 +138,8 @@ function readonlyForSegs(segs) { } /* The view class a menu node instantiates, or null if the node isn't SPA-able. The Status→Overview - * `template` node maps to view.status.index (its server template just instantiates that — see - * ensureOverviewHelpers in fs-router.js). Shared by navigate() and the hover prefetch. */ + * `template` node maps to view.status.index (its server template just instantiates that — the + * globals that template also defines are fs-overview.js's, see ensureOverviewHelpers there). Shared by navigate() and the hover prefetch. */ function viewClassFor(node) { if (!node || !node.action || node.satisfied === false) return null; diff --git a/luci-theme-footstrap/htdocs/luci-static/resources/fs-overview.js b/luci-theme-footstrap/htdocs/luci-static/resources/fs-overview.js index c1fbd50d..ba9ab342 100644 --- a/luci-theme-footstrap/htdocs/luci-static/resources/fs-overview.js +++ b/luci-theme-footstrap/htdocs/luci-static/resources/fs-overview.js @@ -19,15 +19,13 @@ * silenced it, but only after it had already been downloaded and run — a theme package reaching * into another module's namespace, which is exactly what this project refuses to do to third-party * apps (docs/conventions.md, the three zones). It is a chrome module now, loaded by the chrome, so a router on - * another theme never sees it at all. + * another theme never sees it at all — which is why nothing below re-checks `L.env.media`: the file + * cannot be reached except through this theme's own footer partial, and a gate for that is a gate + * for a state that cannot occur. * * WHAT THAT COST, and why the code below looks the way it does: the old location bought two timing * guarantees for free, because LuCI evaluated the file INSIDE index.load(). Both had to be paid for * explicitly — see ensureOverviewHelpers() and patchOverview() at the bottom. */ -function isFootstrapTheme() { - return String(L.env.media || '').indexOf('footstrap') >= 0; -} - /* section title -> grid role. _() with NO msgctxt on purpose: these must resolve to exactly what * luci-mod-status resolves to, or the titles stop matching. Built once — it used to cost an * allocation plus three _() lookups per poll tick. */ @@ -39,7 +37,17 @@ function sectionTitle(sec) { * grid never applied on 24.10 at all — measured on the dev container: every section tagged * `none`, `.fs-ovl` never built, silently. */ const h = sec.querySelector('.cbi-title h3, :scope > h3'); - return (h && h.firstChild) ? String(h.firstChild.nodeValue || '').trim() : ''; + if (!h) return ''; + /* The first non-empty TEXT node, not `firstChild`. That heading is not text-only any more: 25.12 + * appends a hide/show inside the same

    , and `firstChild` lands on the title today only + * because upstream happened to put the words first. One reordering there and every section reads + * as an empty title — the grid silently stops being built, with the page still rendering fine. */ + for (const n of h.childNodes) { + if (n.nodeType !== 3) continue; + const t = String(n.nodeValue || '').trim(); + if (t) return t; + } + return ''; } /* the wrapper we built, so the poll-tick fast path costs one property read */ @@ -126,7 +134,7 @@ function watch() { * The empty `.cbi-section` wrapper stock used to build around this include is gone with it, and so * is the `.fs-ovl-marker` element that existed only to let CSS hide that wrapper. */ function wire() { - if (_routeObserver || !isFootstrapTheme() || !document.body) + if (_routeObserver || !document.body) return; _routeObserver = new MutationObserver(() => { if ((document.body.getAttribute('data-page') || '') === 'admin-status-overview') @@ -188,11 +196,21 @@ function fillSection(inc, container, res) { } let _inflight = null; +/* WHICH containers the in-flight run is filling. The guard below is module-level because the + * duplicate load it kills is module-level, but the frames are per RENDER — so joining a run blindly + * joined one that fills SOMEBODY ELSE'S frames. Reproduced: double-click Status → Overview 100 ms + * apart, or leave and return inside the first-load window, and the second arrival's sections stayed + * at their birth `display:none` for a full poll interval (measured 5.9 s against 0.4 s on a single + * arrival) — it had "joined" a run that was filling the frames the content swap had just detached. + * Stock LuCI has no such guard and each render fetches its own data, so the blank page is ours. */ +let _inflightFor = null; function pollProgressive(includes, containers, first_load) { - /* A run is already fetching exactly this data — join it instead of starting a second - * stampede of the same RPCs. This is what kills the duplicate load. */ - if (_inflight) + /* A run is already fetching exactly this data, FOR THESE FRAMES — join it instead of starting a + * second stampede of the same RPCs. This is what kills the duplicate load. A run for older + * frames is left to finish into the detached nodes it owns, which costs nothing and is simpler + * than cancelling RPCs that are already in flight. */ + if (_inflight && _inflightFor === containers) return first_load ? Promise.resolve() : _inflight; const run = network.flushCache().then(() => Promise.all( @@ -214,7 +232,11 @@ function pollProgressive(includes, containers, first_load) { if (ssi) { ssi.style.display = ''; ssi.classList.add('fade-in'); } }); - _inflight = run.finally(() => { _inflight = null; }); + _inflight = run.finally(() => { + /* only if it is still OURS: a newer render may have replaced it while this one was running */ + if (_inflightFor === containers) { _inflight = null; _inflightFor = null; } + }); + _inflightFor = containers; /* NOBODY AWAITS THIS ON THE FIRST LOAD — the line below hands the caller a fresh * Promise.resolve() so index.render() can return at once — so a rejection here has no handler * and surfaces as an unhandled rejection in the console. `run` rejects for one ordinary reason: diff --git a/luci-theme-footstrap/htdocs/luci-static/resources/fs-prefs.js b/luci-theme-footstrap/htdocs/luci-static/resources/fs-prefs.js index 044aa478..439c66d5 100644 --- a/luci-theme-footstrap/htdocs/luci-static/resources/fs-prefs.js +++ b/luci-theme-footstrap/htdocs/luci-static/resources/fs-prefs.js @@ -27,9 +27,19 @@ * tint back off). Every axis therefore records the chosen value, including the off/default one, the * way `layout` always has. lsDel is reserved for resetToSaved(), which drops back to the router * default on purpose. */ -function lsGet(k) { try { return localStorage.getItem(k); } catch (e) { return null; } } -function lsSet(k, v) { try { localStorage.setItem(k, v); } catch (e) {} } -function lsDel(k) { try { localStorage.removeItem(k); } catch (e) {} } +/* A browser can REFUSE storage outright — "block all cookies" for this address in Chrome/Safari, + * dom.storage.enabled=false in Firefox, a partitioned WebView — and then every access throws. The + * three helpers below still swallow it, because an axis that cannot be remembered must still be + * allowed to APPLY; what they no longer do is keep quiet about it. Without this flag the page told a + * flat lie: each control took effect, nothing was written, current*() then read null and fell back + * to the router default, so matchesSavedDefault() was true and the Save button sat there DISABLED + * reading "Saved as default" while the page was painted in three axes the router default does not + * carry — and a reload dropped all of them. The Appearance tab asks this and says so once. */ +let _lsBroken = false; +function storageBroken() { return _lsBroken; } +function lsGet(k) { try { return localStorage.getItem(k); } catch (e) { _lsBroken = true; return null; } } +function lsSet(k, v) { try { localStorage.setItem(k, v); } catch (e) { _lsBroken = true; } } +function lsDel(k) { try { localStorage.removeItem(k); } catch (e) { _lsBroken = true; } } /* A stored JSON ARRAY, or [] — the shape the two REMEMBERED LISTS use (the search palette's recent * paths, the menu's open sections). lsGet above owns the try/catch around localStorage itself; this @@ -45,7 +55,7 @@ function lsGetArr(k) { } /* the router-wide defaults the server stamped (head.ut). Read at RUNTIME so current*() reports the - * effective default when this browser has no localStorage — the popover's controls then show what + * effective default when this browser has no localStorage — the Appearance tab's controls then show what * the page is actually painted as, not a phantom "auto". */ function sd(k) { try { return (window.__fsSD || {})[k]; } catch (e) { return undefined; } } @@ -371,7 +381,7 @@ function applyPalette(val) { * The list is what VALIDATES a stored value, so a value added to the CSS and not to this array is * one head.ut pre-paints and the live applier then rejects: the page would paint it and the first * touch of any other control would take it away. Adding one means this line, the head.ut whitelist, - * the segmented control in fs-appearance.js and the rules in 15-wallpaper.css. + * the Wallpaper select in fs-appearance.js and the rules in 15-wallpaper.css. * * A router upgrading from a version with the downloaded `cats`/`dinos` doodles reads its stored * value here, finds it is not in the list, and falls to 'off' — the files those named are not in @@ -576,8 +586,8 @@ function applyAutoCollapse(val) { document.dispatchEvent(new CustomEvent('fs-autocollapse', { detail: { on } })); } -/* The sidebar rail's collapsed flag. The BUTTON that flips it is chrome (fs-chrome.js): only the - * stored state belongs to the preference layer, and fs-update.js needs the ls* helpers anyway. +/* The sidebar rail's collapsed flag. The BUTTON that flips it is chrome (fs-chrome.js); only the + * stored state belongs to the preference layer. * NOT part of the router-wide defaults — it is a transient chrome collapse, not an appearance * choice, so it is absent from snapshotAxes()/resetToSaved() below. */ function applyRail(on) { @@ -609,7 +619,10 @@ const AXIS_KEYS = [ /* Tint density: the STRENGTH of the router-identity Tint (the hue washed onto --fs-bg), a per-browser * axis paired with the Tint hue — the hue picks the colour, this picks how strong it reads. * --fs-tint-strength is a multiplier on the tint chroma (03-palettes.css): 100% = the designed - * strength, 0% = none, up to 200%. It only bites while a Tint hue is set (data-tint), and it is + * strength, up to 200%. 0 is not quite "no tint": the palette's canvas carries a slight cast of its + * own and the relative colour that applies the tint replaces chroma outright, so 0 leaves a neutral + * canvas at the same lightness rather than the untinted one (03-palettes.css measures it). Clearing + * the Tint hue is the real off. It only bites while a Tint hue is set (data-tint), and it is * hidden and moot under the File wallpaper, where the tint resets to neutral (the photo covers the * canvas). A normal per-browser axis: localStorage ?? router default ?? built-in; head.ut pre-paints * it; stored explicitly (incl. the 100 default) so it can override a router default, like the hues. @@ -700,7 +713,7 @@ function snapshotAxes() { }; } /* The RESOLVED router default (UCI value if set, else the built-in), in snapshotAxes() string form, - * so the popover can grey the Save button out when this browser already shows exactly it. Seeded + * so the Appearance tab can grey the Save button out when this browser already shows exactly it. Seeded * from window.__fsSD at load and replaced with the just-saved snapshot after saveAsDefault(), so a * save flips the match to true without a reload. * @@ -745,7 +758,7 @@ function matchesSavedDefault() { return Object.keys(cur).every((k) => cur[k] === _savedDefault[k]); } -/* ---- /etc/config/footstrap is written by Save-as-default AND BY NOTHING ELSE ------------------- +/* ---- no AXIS reaches /etc/config/footstrap except through Save-as-default ---------------------- * EVERY axis is per-browser and reaches the router only through this button. Two of them used to * write through the moment they changed — `wallpaper` on every pick, `photo_dim` on every drag — * on the argument that the File photo is router-side, so "which wallpaper shows it" and "how dim" @@ -789,10 +802,11 @@ function resetToSaved() { /* The built-in defaults, written through the ordinary appliers so each one validates its own value * and stamps :root the way it always does. Stated here rather than derived: a "default" is only a - * default because it is the value a bare :root paints, and the three that already have a named - * const (rounding, tint strength, photo dim) use it, so the numbers cannot drift from the CSS. */ + * default because it is the value a bare :root paints, and the five that already have a named + * const (rounding, tint strength, photo dim, pattern size, pattern strength) use it, so the numbers + * cannot drift from the CSS. */ function resetToBuiltin() { - /* TOP, not sidebar: the bar is what a bare :root paints (header.ut stamps it when uci says + /* TOP, not sidebar: the bar is what a bare :root paints (head.ut stamps it when uci says * nothing), so it is what "the theme as it ships" means. This said 'sidebar' after the default * flipped and nothing caught it — the button quietly reset to a layout that is no longer the * default, which is the one thing this button must not do. */ @@ -955,6 +969,7 @@ function uploadPattern(file) { * as making every other device paint it, which is the wallpaper axis and Save-as-default. */ .then(() => _uciSet('footstrap', 'settings', { pattern: tok })) .then(() => _uciCommit('footstrap')) + .catch((e) => _rollbackUpload(PAT_PATH, e)) .then(() => { /* switch THIS browser onto it — the ordinary axis path, localStorage only */ applyWallpaper('pattern'); @@ -967,8 +982,7 @@ function uploadPattern(file) { /* Remove: delete the file, blank the token (uci `set` to '', not delete — the scoped ACL grants * set/commit only), clear the tile live. */ function removePattern() { - return _fileRemove(PAT_PATH) - .catch(() => null) /* already gone is success — still blank the token below */ + return _removeServed(PAT_PATH) .then(() => _uciSet('footstrap', 'settings', { pattern: '' })) .then(() => _uciCommit('footstrap')) .then(() => { _applyPattern(''); }); @@ -990,11 +1004,33 @@ const BG_SERVE = '/luci-static/footstrap/bg'; /* the uhttpd symlink to BG_PATH ( const BG_MAX_SIDE = 1920; /* cap the longest side — a router serves this off flash with no gzip, and 1080p covers the screens LuCI is actually admin'd from; still crisp full-screen, far fewer flash/wire bytes */ const BG_QUALITY = 0.9; const BG_SRC_MAX = 25 * 1024 * 1024; /* refuse a source this big before decoding (decode-bomb guard) */ -const _fileRemove = rpc.declare({ object: 'file', method: 'remove', params: [ 'path' ], reject: true }); +/* NO `reject: true` here, unlike every other declare in this file, and that is the whole point: with + * it the caller gets an Error whose only account of WHY is a sentence with the ubus code inside it, + * so "the file was already gone" and "the router refused to delete it" arrive indistinguishable — + * and both callers below used to swallow the rejection whole and report success. Without it the + * promise resolves with the ubus status as a NUMBER (rpc.js hands back `msg.result[0]`), which is a + * signal this code can actually branch on. */ +const _fileRemoveStatus = rpc.declare({ object: 'file', method: 'remove', params: [ 'path' ] }); + +/* Delete, treating "not found" as done. Anything else is a real refusal — a read-only or full + * overlay, an immutable flag, a path replaced by a non-empty directory — and it must NOT be reported + * as a removal: the file stays on flash and stays fetchable WITHOUT A SESSION through the /www + * symlink, which is precisely what an admin removing a background for privacy reasons believes they + * have just stopped. */ +const UBUS_NOT_FOUND = 4; +function _removeServed(path) { + return _fileRemoveStatus(path).then((res) => { + const code = (typeof res === 'number') ? res : parseInt(res, 10); + if (code === 0 || code === UBUS_NOT_FOUND || isNaN(code)) return; + return Promise.reject(new Error( + _('The router refused to delete the file (ubus status %d).', 'footstrap').format(code))); + }); +} /* cgi-upload writes the file mode 0600, and uhttpd refuses to SERVE a file that is not * world-readable (measured: 0600 -> 403, 0644 -> 200), so make it 0644 before it can be fetched. The - * rpcd ACL grants exec on exactly `/bin/chmod 644 /etc/footstrap/login-bg` — one fixed command, no - * argument the caller controls. */ + * rpcd ACL grants exec on exactly two fixed commands — `/bin/chmod 644 /etc/footstrap/login-bg` and + * `/bin/chmod 644 /etc/footstrap/pattern.svg`, the two files this module uploads — with no argument + * the caller controls. */ const _fileExec = rpc.declare({ object: 'file', method: 'exec', params: [ 'command', 'params' ], reject: true }); /* …and the ubus status is only half of it: `file.exec` reports the COMMAND's exit status inside the * payload, so a chmod that ran and failed still comes back as a successful call. Unchecked, the @@ -1015,7 +1051,7 @@ function _chmodServeable(path) { const BG_TOKEN_RE = /^[a-f0-9]{6,64}$/; /* the token the server last saved (window.__fsSD.login_bg), validated to the same hex charset the - * head.ut sanitiser and pre-paint use — so the popover shows the current background and builds a + * head.ut sanitiser and pre-paint use — so the Appearance tab shows the current background and builds a * cache-busted preview src. '' = none. */ function currentLoginBg() { const t = sd('login_bg'); @@ -1041,10 +1077,10 @@ function _applyLoginBg(tok) { * sits in — it escapes as an uncaught error and leaves the promise pending FOREVER. Two real ways * out of `onload`: `getContext('2d')` answers null when the canvas cannot be backed (out of memory * on a low-RAM box is the case this decodes a 25 MB source on), and drawImage/toBlob can throw on - * their own. The caller is fs-appearance's file picker, which disables "Choose image" and relabels + * their own. The caller is the Appearance tab's file picker, which disables "Choose image" and relabels * it "Uploading…" before the call and restores both in a `.finally()` — so a pending promise means - * that button stays disabled and lying for the life of the page. The popover is built ONCE, in - * init(), so nothing short of a reload gets it back. */ + * that button stays disabled and lying until the form is rebuilt, which mount() does only when the + * stock view re-renders: the next arrival at System -> System, not this one. */ function _downscale(file) { return new Promise((resolve, reject) => { const url = URL.createObjectURL(file); @@ -1069,6 +1105,23 @@ function _downscale(file) { }); } +/* An upload that has landed but could not be RECORDED must not stay on the router. The two paths + * below write the file first (cgi-upload) and the token second (uci), and the second half can fail + * on its own: no `settings` section yet, a narrowed uci ACL, ubus busy. The page then showed the + * rpc error — honest as far as it went — while the image sat in /etc/footstrap at mode 0644 and was + * served to ANYONE at /luci-static/footstrap/bg, because the /www symlink does not depend on the + * token. Worse, Remove is hidden exactly when the token is empty, so the page offered no way to + * delete what it had just published. Roll the file back instead, and report the failure that + * started it — a rollback that itself fails is appended, because at that point the admin has to + * know the file is there. */ +function _rollbackUpload(path, cause) { + return _removeServed(path).then( + () => Promise.reject(cause), + () => Promise.reject(new Error(String((cause && cause.message) || cause) + ' — ' + + _('the uploaded file could not be removed either; it is still on the router.', 'footstrap'))) + ); +} + /* Upload flow: validate -> canvas re-encode -> multipart POST to cgi-io's cgi-upload (the same * endpoint L.ui.uploadFile uses; session carried in the `sessionid` FIELD, path in `filename`, bytes * in `filedata`) -> take the md5 `checksum` from the JSON reply as the cache-bust token -> save it in @@ -1100,6 +1153,7 @@ function uploadLoginBg(file) { * here would re-point every other device's default from one admin's upload, silently. */ .then(() => _uciSet('footstrap', 'settings', { login_bg: tok })) .then(() => _uciCommit('footstrap')) + .catch((e) => _rollbackUpload(BG_PATH, e)) .then(() => { /* switch THIS browser to the photo — the ordinary axis path, localStorage only */ applyWallpaper('file'); @@ -1112,8 +1166,7 @@ function uploadLoginBg(file) { /* Remove: delete the file, blank the token (uci `set` to '', not delete — the scoped ACL grants * set/commit only), clear the background live. */ function removeLoginBg() { - return _fileRemove(BG_PATH) - .catch(() => null) /* already gone is success — still blank the token below */ + return _removeServed(BG_PATH) .then(() => _uciSet('footstrap', 'settings', { login_bg: '' })) .then(() => _uciCommit('footstrap')) .then(() => { _applyLoginBg(''); }); @@ -1122,7 +1175,7 @@ function removeLoginBg() { return baseclass.extend({ /* the storage helpers */ - lsGet, lsSet, lsDel, lsGetArr, + lsGet, lsSet, lsDel, lsGetArr, storageBroken, currentMode, applyMode, guardDarkStamp, currentPalette, applyPalette, diff --git a/luci-theme-footstrap/htdocs/luci-static/resources/fs-router.js b/luci-theme-footstrap/htdocs/luci-static/resources/fs-router.js index be6ef22f..c02bc8ce 100644 --- a/luci-theme-footstrap/htdocs/luci-static/resources/fs-router.js +++ b/luci-theme-footstrap/htdocs/luci-static/resources/fs-router.js @@ -47,9 +47,34 @@ const _viewIntervals = (window.__fsViewIntervals || (window.__fsViewIntervals = }; })(); function clearViewIntervals() { - const keep = (L.Poll && L.Poll.timer) || null; + /* `L.Poll.timer` is the id of LuCI's OWN 1 s tick, and it is private state — `add`/`remove`/ + * `start`/`stop`/`active` are the documented surface, and upstream has already marked the whole + * `L.Poll` alias deprecated (`'require poll'` is its replacement, and neither 24.10 nor 25.12 + * ships poll.js yet, so the alias is still the only way in). If that field ever goes, `keep` + * becomes null and this sweep would clear LuCI's tick along with the view's timers — every poll + * on every later page silently dead, from a rename we did not notice. So the missing field is + * not a null: it is a reason to do NOTHING, once, loudly. A view's leftover interval outliving + * its page costs a wasted RPC; killing the global tick costs the router's live data. */ + /* Asked through the DOCUMENTED half first: active() says whether LuCI's tick is running at all, + * and `timer` is deleted by stop() — so an absent field is the ordinary "nothing to protect" + * case on a page with no pollers, not a sign that upstream moved it. The anomaly worth reporting + * is the pair disagreeing: a tick that is running while the id it runs on has no name we know. + * Then do NOTHING, once, loudly: a view's leftover interval outliving its page costs a wasted + * RPC, whereas clearing LuCI's own tick costs every live value on every later page. */ + const running = (typeof L.Poll.active === 'function') ? L.Poll.active() : (L.Poll.timer != null); + if (running && L.Poll.timer == null) { + if (!_pollTimerWarned) { + _pollTimerWarned = true; + console.error('footstrap: LuCI is polling but L.Poll.timer is not readable — leaving view ' + + 'intervals alone rather than risking its tick. fs-router.js needs updating for this ' + + 'luci-base.'); + } + return; + } + const keep = running ? L.Poll.timer : null; _viewIntervals.forEach((id) => { if (id !== keep) window.clearInterval(id); }); } +let _pollTimerWarned = false; let _wired = false; /* The pathname whose view is CURRENTLY rendered — popstate compares against it to tell a real @@ -64,7 +89,7 @@ let _navGen = 0; * The two layouts scroll different elements: the sidebar layout pins .fs-shell to 100dvh and gives * overflow-y to .fs-main (#maincontent), the top layout lets the document scroll. A browser restores * an INNER scrollable region only across full loads, never on a same-document traversal — measured - * (docs/spa-router.md §2): Back opened the incoming page at 0, because the swap empties #view, + * (docs/spa-router.md, "Scroll"): Back opened the incoming page at 0, because the swap empties #view, * scrollHeight collapses and the browser clamps scrollTop. * * The DOCUMENT scroller was left to the browser's own scrollRestoration ('auto') on the grounds that @@ -116,28 +141,75 @@ function saveScroll() { } /* Put the scrollers back where the entry left them — but only once the incoming view has grown that - * much height (docs/spa-router.md §5: restoring before the content exists is clamped to 0 and reads as + * much height (docs/spa-router.md, "Scroll": restoring before the content exists is clamped to 0 and reads as * "worked"). The view renders behind an RPC, so poll by frame; a newer navigation cancels via the * generation, and a page that never reaches the old height again is simply left at the top. Each * offset is waited for on its OWN scroller, so a layout switched between the two entries restores * whichever half it can rather than blocking on the half that no longer scrolls. */ function restoreScroll(pos, gen) { if (!pos || (!pos.win && !pos.main)) return; - let tries = 300; /* ~5 s at 60 fps — outlasts a slow RPC without polling forever */ + /* A DEADLINE, not a frame count: this was 300 frames called "~5 s", which holds only at 60 Hz — + * the same budget is 10 s on a 30 Hz panel. Frames stay the tick (they are when a paint could + * have changed the height); time decides when to stop waiting for an RPC that is not coming. */ + const until = Date.now() + 5000; + + /* THE USER OUTRANKS THE SAVED POSITION. Waiting up to five seconds for a slow view to grow means + * the reader may have started using the page in the meantime — and jumping them somewhere else + * two seconds after they began reading is worse than opening at the top, which is what a full + * load does anyway. So any sign that the scroll is THEIRS cancels the restore for good. + * + * Two kinds of sign, because neither covers the other. The three input events are intent even + * when nothing moves yet (a wheel tick on a page too short to scroll, a touch that becomes a + * drag); `scroll` is the catch-all for everything they cannot see — a scrollbar drag, a + * trackpad fling, Find-in-page, an anchor jump, assistive tech. `scroll` also fires for OUR + * OWN writes, asynchronously, so a flag around the write would still be false by the time it + * arrives: the position we last wrote is remembered instead, and a scroll that lands exactly + * there is ours. Landing there by hand is indistinguishable and costs nothing — it is the + * position we were restoring to. + * + * Passive listeners: this must never sit in front of the scroll it is watching for. */ + let cancelled = false, wroteWin = -1, wroteMain = -1; + const stop = () => { cancelled = true; off(); }; + const onScroll = (ev) => { + const t = ev.target; + const now = (t === document || t === document.documentElement || t === document.body) + ? Math.round(window.scrollY) : (t && t.scrollTop); + if (now === wroteWin || now === wroteMain) return; /* our own write coming back */ + stop(); + }; + /* the keys that scroll, and only those: typing in a field must not cancel anything */ + const SCROLL_KEYS = new Set([ 'PageUp', 'PageDown', 'Home', 'End', 'ArrowUp', 'ArrowDown', ' ', 'Spacebar' ]); + const onKey = (ev) => { if (SCROLL_KEYS.has(ev.key)) stop(); }; + const opts = { passive: true, capture: true }; + function off() { + window.removeEventListener('wheel', stop, opts); + window.removeEventListener('touchstart', stop, opts); + window.removeEventListener('keydown', onKey, opts); + window.removeEventListener('scroll', onScroll, opts); + } + window.addEventListener('wheel', stop, opts); + window.addEventListener('touchstart', stop, opts); + window.addEventListener('keydown', onKey, opts); + /* capture, so the inner scroller (#maincontent in the sidebar layout) is seen too: `scroll` + * does not bubble from an element, but it does travel down the capture phase. */ + window.addEventListener('scroll', onScroll, opts); + (function tick() { - if (gen !== _navGen || --tries < 0) return; + if (cancelled) return; + if (gen !== _navGen || Date.now() > until) { off(); return; } const de = document.documentElement; const sc = document.getElementById('maincontent'); let pending = false; if (pos.main) { - if (sc && sc.scrollHeight - sc.clientHeight >= pos.main) sc.scrollTop = pos.main; + if (sc && sc.scrollHeight - sc.clientHeight >= pos.main) { wroteMain = pos.main; sc.scrollTop = pos.main; } else pending = true; } if (pos.win) { - if (de.scrollHeight - de.clientHeight >= pos.win) window.scrollTo(0, pos.win); + if (de.scrollHeight - de.clientHeight >= pos.win) { wroteWin = pos.win; window.scrollTo(0, pos.win); } else pending = true; } if (pending) requestAnimationFrame(tick); + else off(); })(); } @@ -276,38 +348,43 @@ function pragmaDeps(src) { return out; } -/* SIX CLASS NAMES HAVE NO FILE, and fetching one is a guaranteed 404 in the user's console. luci.js - * seeds its class registry with them at load — `const classes = { baseclass: Class, dom: DOM, - * poll: Poll, request: Request, session: Session, view: View }` — so require() answers them from - * memory and never asks the network, while `ls /www/luci-static/resources` has no baseclass.js, - * dom.js, poll.js, request.js or session.js at all. Every view file's pragmas name `view` and - * `baseclass`, so a dependency walk hits this on its very first step: measured, warming the recents - * at idle put 404s for view.js and poll.js in the console of every page load, and the first hover - * added baseclass.js. A require() that 404s is noise this theme refuses to make, and the same - * standard applies here. +/* WHICH CLASS NAMES ARE WORTH A PREFETCH, and the answer is the DOTTED ones — that is the whole + * rule now, and it used to be a hardcoded list of the six names luci.js seeds its registry with + * (`baseclass`, `dom`, `poll`, `request`, `session`, `view`). Those have no file, so fetching one is + * a guaranteed 404 in the user's console — measured before the list existed: warming the recents at + * idle put 404s for view.js and poll.js into every page load, and the first hover added baseclass.js. + * The list worked, and it was a literal copied out of luci.js rather than a guess about it, but it + * was still a copy: a seventh built-in would cost one 404 per name per session until this file + * caught up with a release of somebody else's software. * - * A future LuCI adding a seventh built-in would cost one 404 per session — `_prefetched` makes it - * at most one — and the list is a literal from luci.js, not a guess about it. */ -const BUILTIN_CLASSES = new Set([ 'baseclass', 'dom', 'poll', 'request', 'session', 'view' ]); - -/* Is this class already instantiated? require() attaches its singleton to the LuCI prototype - * (`ptr[parts[idx]] = instance`), so a SINGLE-segment name reads back as L[name] — which covers the - * libs a loaded page has already pulled in (ui, form, uci, rpc, fs, validation, and network/firewall - * once some network page has been open). Skipping them spends no request on a cache hit nobody needs. - * `instanceof L.Class` rather than a truthiness test: L.env, L.url and L.get are members too, and a - * dep whose name collided with one of those would otherwise be skipped without ever being loaded — - * which is why this cannot be the guard for the six above either: they are seeded as CONSTRUCTORS - * (and under other names — L.Poll, L.Request, L.Class), so no `instanceof` probe sees them. A DOTTED - * name (tools.network) is not attached unless its parent already exists, so it is simply fetched — - * and those are the ones the win comes from. */ + * The shape of the names answers it without the copy. A LuCI class name is a path — `tools.widgets` + * is tools/widgets.js — so a name with no dot is either one of those six virtual classes or one of + * the flat libraries (`ui`, `form`, `network`, `uci`, `rpc`, `fs`, `validation`), and those are + * already loaded by the time any prefetch runs: this theme's own chrome requires `network` for the + * overview grid, which drags in firewall/uci/rpc/validation, and `ui` comes with the widgets. + * Measured on the stand from three different landing pages, including the lightest one there is + * (System -> Reboot): all eight flat libraries were already instances on arrival, and driving the + * prefetch walk over seven pages fetched 10 files, every one of them nested. So the flat half of the + * namespace is worth nothing to prefetch and can never be worth a 404 — declining it outright costs + * nothing measurable, needs no list, and a future built-in is covered before it ships. + * + * The dotted half is still asked properly: require() attaches a class at its path (`ptr[parts[i]] = + * instance`), so `tools.widgets` reads back as L.tools.widgets once some form page has pulled it, + * and a second navigation there spends no request at all. `instanceof L.Class` rather than a + * truthiness test: L.env, L.url and L.get are members too. */ function classLoaded(name) { - if (BUILTIN_CLASSES.has(name)) return true; - try { return name.indexOf('.') < 0 && window.L[name] instanceof window.L.Class; } + if (name.indexOf('.') < 0) return true; + try { + let ptr = window.L; + for (const part of name.split('.')) { + ptr = ptr[part]; + if (ptr == null) return false; + } + return ptr instanceof window.L.Class; + } catch (e) { return false; } } -/* view classes already required, i.e. the ones LuCI has an instance cached for. A class NOT in - * here is rendered by the require() itself (see navigate). */ const _seen = new Set(); const _prefetched = new Set(); /* className -> the promise of ITS OWN body being in the HTTP cache; navigate() waits on that. @@ -490,7 +567,7 @@ function navigate(pathname, push, kbd) { * when View.__init__ replaces it there is nothing to see, and the string arrives already * translated in the ~40 languages this theme ships no catalogue for (the chrome rule — a * context-free msgid is how we inherit luci-base's translation). */ - if (!_seen.has(tree.viewClassFor(node))) { + if (!_seen.has(className)) { const vp = document.getElementById('view'); if (vp) { const s = document.createElement('div'); @@ -541,7 +618,11 @@ function navigate(pathname, push, kbd) { try { fn(rsegs); } catch (e) { console.error('footstrap: a navigation callback threw', e); } } - try { if (typeof ui.hideModal === 'function') ui.hideModal(); } catch (e) {} + /* ui hard-requires into this module and ui.js defines hideModal unconditionally, so there is no + * feature to test; what is caught is a modal's own teardown throwing, which must not take the + * navigation with it. Reported, not swallowed — the same rule as the loop above. */ + try { ui.hideModal(); } + catch (e) { console.error('footstrap: hideModal threw during a navigation', e); } /* point the runtime env at the new node so views, tabs and highlighting read the right * path. For a fully-matched leaf, request == dispatch path. */ @@ -579,8 +660,8 @@ function navigate(pathname, push, kbd) { * correctly returns — one dead Back press per stray click. A full load has no such trap. */ if (push) { const same = pathname === window.location.pathname; - if (_curId == null) _curId = newEntryId(); - /* a NEW entry gets a new id; re-navigating in place keeps the entry and therefore its id */ + /* a NEW entry gets a new id; re-navigating in place keeps the entry and therefore its id + * (seed() adopted one before wire() made this function reachable, so there is always one) */ if (!same) _curId = newEntryId(); history[same ? 'replaceState' : 'pushState']({ fsnav: true, fsid: _curId }, '', pathname); } @@ -601,7 +682,7 @@ function navigate(pathname, push, kbd) { * * A popstate replay resets nothing on purpose: BOTH scrollers are restored there from _scrollMem — * see restoreScroll(). scrollRestoration is left at 'auto': the UA's own attempt lands before the - * swap and is undone by it (§2), so it neither helps nor hurts, and 'manual' would only take away + * swap and is undone by it (see restoreScroll above), so it neither helps nor hurts, and 'manual' would only take away * the case that does work — a genuine full load. */ if (push) { window.scrollTo(0, 0); @@ -613,7 +694,8 @@ function navigate(pathname, push, kbd) { * renderChrome() has just done `#topmenu.innerHTML = ''`, so the very the user activated with * Enter no longer exists: focus falls back to , the next Tab restarts at the skip link, and * nothing says the page changed — URL, title and #view all moved in silence. So do what a real - * navigation would, and where matters (Sutton's five-prototype study, docs/spa-router.md §3): a KEYBOARD + * navigation would, and where matters (Sutton's five-prototype study, docs/spa-router.md, + * "Accessibility of a route change"): a KEYBOARD * activation (ev.detail === 0) moves focus to the skip link — a small target whose :focus overlay * tells a sighted keyboard user where they are, with Enter jumping straight to the content; its * text differs from the live region's announcement below, so the double announcement complements @@ -664,7 +746,15 @@ function navigate(pathname, push, kbd) { * repairStaleRender() a mess that only exists because a require in flight cannot be stopped. */ if (gen !== _navGen) return null; _seen.add(className); - return RT.require(className); + /* NAME THE OWNER for the length of this require. On a first visit the require IS the render, + * so any