3 Commits
Author SHA1 Message Date
雷电芽衣 8ba357ffd6 Relicense Ely Office's own code from AGPL-3.0 to MIT
Applied on top of the released v0.1.2 so the tag says MIT, as main does
(271468d). Bundled engines keep their licences: LibreOffice (MPL-2.0),
Git (GPL-2.0) and MuPDF (AGPL-3.0).
2026-10-20 01:33:31 -04:00
ZacharyZhang-NY fde97a01a9 Version 0.1.2 2026-10-09 16:34:52 -04:00
ZacharyZhang-NY b03c9f2853 Updates: opt-in launch check, Check for Updates…, install after a normal quit, from the Gitea release; dmgs carry an Applications link (UPD-1, REL-1) 2026-10-09 16:34:32 -04:00
37 changed files with 943 additions and 703 deletions

No files matched your search

Generated
+16 -16
View File
@@ -1919,7 +1919,7 @@ checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
[[package]] [[package]]
name = "ely-agent" name = "ely-agent"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"ely-platform", "ely-platform",
"ely-ui", "ely-ui",
@@ -1927,7 +1927,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-doc" name = "ely-doc"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"csv", "csv",
@@ -1948,7 +1948,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-files" name = "ely-files"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"ely-platform", "ely-platform",
@@ -2001,14 +2001,14 @@ dependencies = [
[[package]] [[package]]
name = "ely-ipc" name = "ely-ipc"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"log", "log",
] ]
[[package]] [[package]]
name = "ely-lok" name = "ely-lok"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"base64 0.23.1", "base64 0.23.1",
"ely-gpui-component", "ely-gpui-component",
@@ -2028,7 +2028,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-mail" name = "ely-mail"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"ely-platform", "ely-platform",
"ely-ui", "ely-ui",
@@ -2036,7 +2036,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-mark" name = "ely-mark"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.23.1", "base64 0.23.1",
@@ -2058,7 +2058,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-office" name = "ely-office"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"directories", "directories",
@@ -2078,7 +2078,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-pdf" name = "ely-pdf"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"ely-files", "ely-files",
"ely-gpui-component", "ely-gpui-component",
@@ -2094,7 +2094,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-pdf-engine" name = "ely-pdf-engine"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"cc", "cc",
"ely-ipc", "ely-ipc",
@@ -2110,7 +2110,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-platform" name = "ely-platform"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arboard", "arboard",
@@ -2143,7 +2143,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-show" name = "ely-show"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"ely-files", "ely-files",
"ely-gpui-component", "ely-gpui-component",
@@ -2162,7 +2162,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-table" name = "ely-table"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"ely-gpui-component", "ely-gpui-component",
"ely-lok", "ely-lok",
@@ -2178,7 +2178,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-tree" name = "ely-tree"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"ely-files", "ely-files",
"ely-gpui-component", "ely-gpui-component",
@@ -2196,7 +2196,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-ui" name = "ely-ui"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"directories", "directories",
@@ -2214,7 +2214,7 @@ dependencies = [
[[package]] [[package]]
name = "ely-web-content" name = "ely-web-content"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cef", "cef",
+2 -2
View File
@@ -5,10 +5,10 @@ members = ["apps/*", "crates/*"]
exclude = ["engines", "reference"] exclude = ["engines", "reference"]
[workspace.package] [workspace.package]
version = "0.1.1" version = "0.1.2"
edition = "2024" edition = "2024"
rust-version = "1.95" rust-version = "1.95"
license = "AGPL-3.0-or-later" license = "MIT"
publish = false publish = false
[workspace.dependencies] [workspace.dependencies]
+21 -661
View File
@@ -1,661 +1,21 @@
GNU AFFERO GENERAL PUBLIC LICENSE MIT License
Version 3, 19 November 2007
Copyright (c) 2026 Yang Zhang
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Permission is hereby granted, free of charge, to any person obtaining a copy
of this license document, but changing it is not allowed. of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Preamble to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
The GNU Affero General Public License is a free, copyleft license for furnished to do so, subject to the following conditions:
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software. The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
our General Public Licenses are intended to guarantee your freedom to IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
share and change all versions of a program--to make sure it remains free FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
software for all its users. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
When we speak of free software, we are referring to freedom, not OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
price. Our General Public Licenses are designed to make sure that you SOFTWARE.
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.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
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 Affero 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. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
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 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 work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero 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 Affero 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 Affero 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 Affero 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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
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 AGPL, see
<http://www.gnu.org/licenses/>.
+1 -1
View File
@@ -757,7 +757,7 @@ Doc、Table、Show 的 PDF 输出由 LOK 完成,不要求安装 ElyPDF。ElyMa
### 21.1 自有代码默认许可 ### 21.1 自有代码默认许可
本 PRD 对新增应用代码采用 AGPL-3.0-or-later 作为发行默认,便于与 MuPDF 的开源使用路线保持一致。Ely GPUI Components 继续保留现有 MIT/Apache-2.0 许可,不因被应用使用而改写其许可证。[S1] 本 PRD 对新增应用代码采用 MIT 作为发行默认(用户 2026-10-19 定,原为 AGPL-3.0-or-later)。MIT 只管 Ely 的自有代码:链接 MuPDF 的 ElyPDF 发行包整体仍须按 MuPDF 的 AGPL 条款提供对应源码。Ely GPUI Components 继续保留现有 MIT/Apache-2.0 许可,不因被应用使用而改写其许可证。[S1]
第三方代码保持原许可证。不得把 LibreOffice、Git 或其他依赖的版权声明统一替换成 Ely 的声明。最终发行须按实际链接、进程调用、修改和打包方式审查,进程隔离不作为免除许可义务的依据。 第三方代码保持原许可证。不得把 LibreOffice、Git 或其他依赖的版权声明统一替换成 Ely 的声明。最终发行须按实际链接、进程调用、修改和打包方式审查,进程隔离不作为免除许可义务的依据。
+1 -1
View File
@@ -44,4 +44,4 @@ Packages: `packaging/macos/release.sh` writes each app's `.app` and `.dmg`, the
## Licence ## Licence
AGPL-3.0-or-later (`LICENSE`). Third-party components keep their own licences; see `docs/licenses.md`. MIT (`LICENSE`). Third-party components keep their own licences; see `docs/licenses.md`.
+6
View File
@@ -68,6 +68,12 @@ pub trait Closing: Host {
}); });
} }
/// A close or quit stopped: no update installs on it.
fn close_stopped(&mut self, cx: &mut Context<Self>) {
ely_ui::updates::quit_stopped(cx);
self.close_cancelled(cx);
}
fn no_document(&self, cx: &mut Context<Self>) { fn no_document(&self, cx: &mut Context<Self>) {
let text = text(cx, "command.blocked.no_document", &[]); let text = text(cx, "command.blocked.no_document", &[]);
self.toast(text, Severity::Warning, cx); self.toast(text, Severity::Warning, cx);
+3 -3
View File
@@ -87,7 +87,7 @@ pub trait Dialogs: Host {
// Cancel stops the whole close. // Cancel stops the whole close.
let cancelled = move |window: &mut Window, cx: &mut App| { let cancelled = move |window: &mut Window, cx: &mut App| {
owner.update(cx, |host, cx| { owner.update(cx, |host, cx| {
host.close_cancelled(cx); host.close_stopped(cx);
host.dialog_done(window, cx) host.dialog_done(window, cx)
}) })
}; };
@@ -119,7 +119,7 @@ pub trait Dialogs: Host {
let cancelled = move |window: &mut Window, cx: &mut App| { let cancelled = move |window: &mut Window, cx: &mut App| {
owner.update(cx, |host, cx| { owner.update(cx, |host, cx| {
if then.is_some() { if then.is_some() {
host.close_cancelled(cx); host.close_stopped(cx);
} }
host.dialog_done(window, cx) host.dialog_done(window, cx)
}) })
@@ -135,7 +135,7 @@ pub trait Dialogs: Host {
move |host, _, cx| { move |host, _, cx| {
// Reloading ends the close that waited. // Reloading ends the close that waited.
if then.is_some() { if then.is_some() {
host.close_cancelled(cx); host.close_stopped(cx);
} }
host.reload(tab, cx) host.reload(tab, cx)
}, },
+2 -2
View File
@@ -190,7 +190,7 @@ pub trait Saving: Host {
} }
// No save: a close that waited on it stops. // No save: a close that waited on it stops.
if then.is_some() { if then.is_some() {
host.close_cancelled(cx); host.close_stopped(cx);
} }
}) })
}) })
@@ -419,7 +419,7 @@ pub trait Saving: Host {
failed => { failed => {
self.report(id, failed, cx); self.report(id, failed, cx);
if then.is_some() { if then.is_some() {
self.close_cancelled(cx); self.close_stopped(cx);
} }
} }
} }
+160
View File
@@ -0,0 +1,160 @@
//! Puts a downloaded release in place of the running app.
use std::{
io,
path::{Path, PathBuf},
process::{Command, Stdio},
};
/// The `.app` running this process; none in dev builds.
pub fn running_bundle() -> io::Result<Option<PathBuf>> {
let exe = std::env::current_exe()?;
Ok(bundle_of(&exe).map(Path::to_path_buf))
}
fn bundle_of(exe: &Path) -> Option<&Path> {
exe.ancestors().find(|dir| dir.extension().is_some_and(|ext| ext == "app"))
}
/// Replaces `bundle` with the same-named app inside `dmg`.
#[cfg(target_os = "macos")]
pub fn install(dmg: &Path, bundle: &Path) -> io::Result<()> {
let name = bundle.file_name().ok_or_else(|| io::Error::other("the app has no name"))?;
let parent = bundle.parent().ok_or_else(|| io::Error::other("the app has no folder"))?;
let mount = tempfile::tempdir()?;
run(Command::new("hdiutil").args(["attach", "-nobrowse", "-readonly", "-noautoopen", "-mountpoint"]).arg(mount.path()).arg(dmg))?;
let copied = stage(&mount.path().join(name), parent, name);
let detached = run(Command::new("hdiutil").args(["detach", "-force"]).arg(mount.path()));
let staged = copied?;
detached?;
swap(&staged, bundle)
}
#[cfg(not(target_os = "macos"))]
pub fn install(_dmg: &Path, _bundle: &Path) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Unsupported, "installing updates is not built for this platform"))
}
/// Copies the new app beside the old, hidden.
#[cfg(target_os = "macos")]
fn stage(from: &Path, parent: &Path, name: &std::ffi::OsStr) -> io::Result<PathBuf> {
if !from.is_dir() {
return Err(io::Error::new(io::ErrorKind::NotFound, format!("the download holds no {}", name.to_string_lossy())));
}
let staged = parent.join(format!(".{}.new", name.to_string_lossy()));
if staged.exists() {
std::fs::remove_dir_all(&staged)?;
}
run(Command::new("ditto").arg(from).arg(&staged))?;
Ok(staged)
}
/// Puts `staged` at `bundle`; on failure the old returns.
fn swap(staged: &Path, bundle: &Path) -> io::Result<()> {
let name = bundle.file_name().ok_or_else(|| io::Error::other("the app has no name"))?;
let old = bundle.with_file_name(format!(".{}.old", name.to_string_lossy()));
if old.exists() {
std::fs::remove_dir_all(&old)?;
}
std::fs::rename(bundle, &old)?;
if let Err(error) = std::fs::rename(staged, bundle) {
std::fs::rename(&old, bundle)?;
return Err(error);
}
log::info!("install: {} replaced", bundle.display());
// Installed: an old copy left behind is only untidy.
if let Err(error) = std::fs::remove_dir_all(&old) {
log::warn!("install: the old copy at {} stays: {error}", old.display());
}
Ok(())
}
/// Returns once process `pid` has ended.
#[cfg(unix)]
pub fn wait_for_exit(pid: u32) {
while unsafe { libc::kill(pid as libc::pid_t, 0) } == 0 {
std::thread::sleep(std::time::Duration::from_millis(200));
}
}
#[cfg(not(unix))]
pub fn wait_for_exit(_pid: u32) {}
/// Opens `bundle` as a fresh launch.
#[cfg(target_os = "macos")]
pub fn reopen(bundle: &Path) -> io::Result<()> {
run(Command::new("open").arg(bundle))
}
#[cfg(not(target_os = "macos"))]
pub fn reopen(_bundle: &Path) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Unsupported, "reopening after an update is not built for this platform"))
}
/// Runs `command`; a failure carries what it said.
#[cfg(target_os = "macos")]
fn run(command: &mut Command) -> io::Result<()> {
let out = command.stdin(Stdio::null()).output()?;
if out.status.success() {
return Ok(());
}
let said = String::from_utf8_lossy(&out.stderr);
Err(io::Error::other(format!("{:?} failed ({}): {}", command.get_program(), out.status, said.trim())))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_bundle_is_the_nearest_app_folder() {
let exe = Path::new("/Applications/ElyDoc.app/Contents/MacOS/ely-doc");
assert_eq!(bundle_of(exe), Some(Path::new("/Applications/ElyDoc.app")));
assert_eq!(bundle_of(Path::new("/repo/target/debug/ely-doc")), None);
}
#[test]
fn a_swap_replaces_the_app_and_leaves_no_copy() {
let dir = tempfile::tempdir().expect("a temp dir");
let (bundle, staged) = (dir.path().join("ElyDoc.app"), dir.path().join(".ElyDoc.app.new"));
std::fs::create_dir_all(bundle.join("old")).expect("the old app");
std::fs::create_dir_all(staged.join("new")).expect("the new app");
swap(&staged, &bundle).expect("swaps");
assert!(bundle.join("new").exists() && !bundle.join("old").exists());
assert_eq!(std::fs::read_dir(dir.path()).expect("lists").count(), 1, "nothing else is left");
}
#[cfg(target_os = "macos")]
#[test]
fn an_old_copy_that_will_not_go_leaves_the_install_done() {
let dir = tempfile::tempdir().expect("a temp dir");
let (bundle, staged) = (dir.path().join("ElyDoc.app"), dir.path().join(".ElyDoc.app.new"));
std::fs::create_dir_all(&bundle).expect("the old app");
std::fs::write(bundle.join("version"), "old").expect("marks it");
std::fs::create_dir_all(&staged).expect("the new app");
std::fs::write(staged.join("version"), "new").expect("marks it");
run(Command::new("chflags").arg("uchg").arg(bundle.join("version"))).expect("locks a file");
swap(&staged, &bundle).expect("installed although the old copy stays");
assert_eq!(std::fs::read_to_string(bundle.join("version")).expect("reads"), "new");
let old = dir.path().join(".ElyDoc.app.old");
run(Command::new("chflags").arg("nouchg").arg(old.join("version"))).expect("unlocks");
}
#[cfg(target_os = "macos")]
#[test]
fn a_dmg_installs_over_the_app() {
let dir = tempfile::tempdir().expect("a temp dir");
let source = dir.path().join("src");
std::fs::create_dir_all(source.join("ElyDoc.app/Contents")).expect("the new app");
std::fs::write(source.join("ElyDoc.app/Contents/version"), "new").expect("marks it");
let dmg = dir.path().join("ElyDoc.dmg");
run(Command::new("hdiutil").args(["create", "-quiet", "-fs", "HFS+", "-srcfolder"]).arg(&source).arg(&dmg)).expect("a dmg");
let bundle = dir.path().join("Applications/ElyDoc.app");
std::fs::create_dir_all(bundle.join("Contents")).expect("the old app");
std::fs::write(bundle.join("Contents/version"), "old").expect("marks it");
install(&dmg, &bundle).expect("installs");
assert_eq!(std::fs::read_to_string(bundle.join("Contents/version")).expect("reads"), "new");
let empty = dir.path().join("Applications/Other.app");
assert!(install(&dmg, &empty).is_err(), "a dmg without that app is refused");
}
}
+2
View File
@@ -7,12 +7,14 @@ mod dirs;
pub mod env; pub mod env;
pub mod git; pub mod git;
pub mod graphics; pub mod graphics;
pub mod install;
pub mod instance; pub mod instance;
pub mod locale; pub mod locale;
pub mod lock; pub mod lock;
pub mod logging; pub mod logging;
pub mod media; pub mod media;
pub mod print; pub mod print;
pub mod release;
pub mod settings; pub mod settings;
pub mod startup; pub mod startup;
pub mod storage; pub mod storage;
+46
View File
@@ -0,0 +1,46 @@
//! The newest release's files, as the release server lists them.
use anyhow::{Context, Result, bail};
use serde::Deserialize;
#[derive(Deserialize)]
struct Latest {
tag_name: String,
assets: Vec<Asset>,
}
#[derive(Deserialize)]
struct Asset {
name: String,
browser_download_url: String,
}
/// Where the latest release at `api` keeps the file `name`.
pub fn asset_url(api: &str, name: &str) -> Result<String> {
let text = crate::update::fetch(&crate::update::manifest_agent(), api)?
.body_mut()
.with_config()
.limit(1 << 20)
.read_to_string()
.context("cannot read the latest release")?;
asset_in(&text, name)
}
fn asset_in(text: &str, name: &str) -> Result<String> {
let latest: Latest = serde_json::from_str(text).context("the latest release is not valid")?;
match latest.assets.into_iter().find(|asset| asset.name == name) {
Some(asset) => Ok(asset.browser_download_url),
None => bail!("release {} has no {name}", latest.tag_name),
}
}
#[cfg(test)]
mod tests {
#[test]
fn the_named_file_is_found_or_said_missing() {
let text = r#"{"tag_name":"v0.1.2","assets":[{"name":"ely-doc.json","browser_download_url":"https://h/d.json"}]}"#;
assert_eq!(super::asset_in(text, "ely-doc.json").unwrap(), "https://h/d.json");
let missing = super::asset_in(text, "ely-tree.json").unwrap_err().to_string();
assert_eq!(missing, "release v0.1.2 has no ely-tree.json");
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ use serde_json::{Map, Value};
use crate::{AppId, lock::FileLock}; use crate::{AppId, lock::FileLock};
mod shared; mod shared;
pub use shared::{APPEARANCE, AUTHOR, Appearance, LANGUAGE, Language, MOTION, Motion, OMARCHY_SYNC, Shared, word}; pub use shared::{APPEARANCE, AUTHOR, Appearance, CHECK_UPDATES, LANGUAGE, Language, MOTION, Motion, OMARCHY_SYNC, Shared, word};
/// The layout this build reads and writes. /// The layout this build reads and writes.
pub const VERSION: u64 = 1; pub const VERSION: u64 = 1;
@@ -38,6 +38,7 @@ pub const LANGUAGE: &str = "language";
pub const MOTION: &str = "motion"; pub const MOTION: &str = "motion";
pub const OMARCHY_SYNC: &str = "omarchy_sync"; pub const OMARCHY_SYNC: &str = "omarchy_sync";
pub const AUTHOR: &str = "author"; pub const AUTHOR: &str = "author";
pub const CHECK_UPDATES: &str = "check_updates";
/// The shared settings; absent fields take their defaults. /// The shared settings; absent fields take their defaults.
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
@@ -48,6 +49,8 @@ pub struct Shared {
pub omarchy_sync: bool, pub omarchy_sync: bool,
/// Signs comments and changes; empty means the account name. /// Signs comments and changes; empty means the account name.
pub author: String, pub author: String,
/// Asks for a newer release at launch; off unless chosen.
pub check_updates: bool,
} }
impl Default for Shared { impl Default for Shared {
@@ -58,6 +61,7 @@ impl Default for Shared {
motion: Motion::System, motion: Motion::System,
omarchy_sync: true, omarchy_sync: true,
author: String::new(), author: String::new(),
check_updates: false,
} }
} }
} }
@@ -92,6 +96,11 @@ impl Shared {
appearance: pick(fields, APPEARANCE, &Appearance::ALL)?.unwrap_or(defaults.appearance), appearance: pick(fields, APPEARANCE, &Appearance::ALL)?.unwrap_or(defaults.appearance),
language: pick(fields, LANGUAGE, &Language::ALL)?.unwrap_or(defaults.language), language: pick(fields, LANGUAGE, &Language::ALL)?.unwrap_or(defaults.language),
motion: pick(fields, MOTION, &Motion::ALL)?.unwrap_or(defaults.motion), motion: pick(fields, MOTION, &Motion::ALL)?.unwrap_or(defaults.motion),
check_updates: match fields.get(CHECK_UPDATES) {
None => defaults.check_updates,
Some(Value::Bool(on)) => *on,
Some(other) => return Err(wrong(CHECK_UPDATES, other)),
},
omarchy_sync: match fields.get(OMARCHY_SYNC) { omarchy_sync: match fields.get(OMARCHY_SYNC) {
None => defaults.omarchy_sync, None => defaults.omarchy_sync,
Some(Value::Bool(on)) => *on, Some(Value::Bool(on)) => *on,
+3 -2
View File
@@ -63,14 +63,15 @@ fn shared_fields_type_strictly_and_default_when_absent() {
let fields = |text: &str| serde_json::from_str::<serde_json::Map<_, _>>(text).unwrap(); let fields = |text: &str| serde_json::from_str::<serde_json::Map<_, _>>(text).unwrap();
assert_eq!(Shared::from_fields(&fields("{}")).unwrap(), Shared::default()); assert_eq!(Shared::from_fields(&fields("{}")).unwrap(), Shared::default());
let read = Shared::from_fields(&fields( let read = Shared::from_fields(&fields(
r#"{"appearance":"dark","language":"zh-CN","motion":"reduce","omarchy_sync":false,"author":" Ana "}"#, r#"{"appearance":"dark","language":"zh-CN","motion":"reduce","omarchy_sync":false,"author":" Ana ","check_updates":true}"#,
)) ))
.unwrap(); .unwrap();
assert!(read.check_updates && !Shared::default().check_updates, "asked for, never by default");
assert_eq!( assert_eq!(
(read.appearance, read.language, read.motion, read.omarchy_sync, read.author.as_str()), (read.appearance, read.language, read.motion, read.omarchy_sync, read.author.as_str()),
(Appearance::Dark, Language::Chinese, Motion::Reduced, false, "Ana") (Appearance::Dark, Language::Chinese, Motion::Reduced, false, "Ana")
); );
for bad in [r#"{"appearance":"blue"}"#, r#"{"omarchy_sync":"yes"}"#, r#"{"author":3}"#] { for bad in [r#"{"appearance":"blue"}"#, r#"{"omarchy_sync":"yes"}"#, r#"{"author":3}"#, r#"{"check_updates":1}"#] {
assert!(Shared::from_fields(&fields(bad)).is_err(), "{bad}"); assert!(Shared::from_fields(&fields(bad)).is_err(), "{bad}");
} }
} }
+2 -2
View File
@@ -305,7 +305,7 @@ fn secure_host(url: &str) -> Result<String> {
} }
/// GETs `url`, following redirects only to places `secure_host` accepts. /// GETs `url`, following redirects only to places `secure_host` accepts.
fn fetch(agent: &Agent, url: &str) -> Result<Response<Body>> { pub(crate) fn fetch(agent: &Agent, url: &str) -> Result<Response<Body>> {
let mut url = url.to_string(); let mut url = url.to_string();
for _ in 0..=MAX_REDIRECTS { for _ in 0..=MAX_REDIRECTS {
secure_host(&url)?; secure_host(&url)?;
@@ -335,7 +335,7 @@ fn fetch(agent: &Agent, url: &str) -> Result<Response<Body>> {
bail!("too many redirects") bail!("too many redirects")
} }
fn manifest_agent() -> Agent { pub(crate) fn manifest_agent() -> Agent {
Agent::config_builder() Agent::config_builder()
.timeout_global(Some(MANIFEST_TIMEOUT)) .timeout_global(Some(MANIFEST_TIMEOUT))
.max_redirects(0) .max_redirects(0)
+1
View File
@@ -13,6 +13,7 @@ ely-platform.workspace = true
gpui.workspace = true gpui.workspace = true
directories.workspace = true directories.workspace = true
futures.workspace = true futures.workspace = true
semver.workspace = true
gpui_platform.workspace = true gpui_platform.workspace = true
log.workspace = true log.workspace = true
notify.workspace = true notify.workspace = true
+6 -1
View File
@@ -18,6 +18,7 @@ actions!(
CloseTab, CloseTab,
ToggleCommandPalette, ToggleCommandPalette,
OpenSettings, OpenSettings,
CheckForUpdates,
Quit Quit
] ]
); );
@@ -43,7 +44,7 @@ pub fn bind_quit(cx: &mut App) {
} }
/// Quits through the main window's route, if one is set. /// Quits through the main window's route, if one is set.
fn quit(cx: &mut App) { pub(crate) fn quit(cx: &mut App) {
match cx.try_global::<QuitRoute>().map(|route| Rc::clone(&route.0)) { match cx.try_global::<QuitRoute>().map(|route| Rc::clone(&route.0)) {
Some(route) => route(cx), Some(route) => route(cx),
None => cx.quit(), None => cx.quit(),
@@ -171,6 +172,10 @@ pub fn menus(
first.push(MenuItem::separator()); first.push(MenuItem::separator());
} }
first.push(MenuItem::action(i18n::text(cx, "menu.app.settings", &[]), OpenSettings)); first.push(MenuItem::action(i18n::text(cx, "menu.app.settings", &[]), OpenSettings));
// Only an installed app can update itself.
if crate::updates::updater(cx).is_some() {
first.push(MenuItem::action(i18n::text(cx, "menu.app.updates", &[]), CheckForUpdates));
}
first.push(MenuItem::separator()); first.push(MenuItem::separator());
first.push(MenuItem::action(i18n::text(cx, "menu.app.quit", &[("app", app.name())]), Quit)); first.push(MenuItem::action(i18n::text(cx, "menu.app.quit", &[("app", app.name())]), Quit));
let mut menus = vec![ let mut menus = vec![
+6
View File
@@ -24,6 +24,9 @@ use gpui::{App, SharedString};
const EN: &[(&str, &str)] = &[ const EN: &[(&str, &str)] = &[
("menu.app.quit", "Quit {app}"), ("menu.app.quit", "Quit {app}"),
("updates.failed", "The update did not finish: {error}"),
("updates.latest", "{app} {version} is the latest version."),
("menu.app.updates", "Check for Updates…"),
("menu.app.switch", "Open Ely App"), ("menu.app.switch", "Open Ely App"),
("toast.open", "Open"), ("toast.open", "Open"),
("toast.open_failed", "The file did not open: {error}"), ("toast.open_failed", "The file did not open: {error}"),
@@ -76,6 +79,9 @@ const EN: &[(&str, &str)] = &[
const ZH_CN: &[(&str, &str)] = &[ const ZH_CN: &[(&str, &str)] = &[
("menu.app.quit", "退出 {app}"), ("menu.app.quit", "退出 {app}"),
("updates.failed", "更新没有完成:{error}"),
("updates.latest", "{app} {version} 已是最新版本。"),
("menu.app.updates", "检查更新…"),
("menu.app.switch", "打开 Ely 应用"), ("menu.app.switch", "打开 Ely 应用"),
("toast.open", "打开"), ("toast.open", "打开"),
("toast.open_failed", "文件没能打开:{error}"), ("toast.open_failed", "文件没能打开:{error}"),
+10
View File
@@ -9,6 +9,11 @@ pub(super) const EN: &[(&str, &str)] = &[
("settings.appearance.light", "Light"), ("settings.appearance.light", "Light"),
("settings.appearance.dark", "Dark"), ("settings.appearance.dark", "Dark"),
("settings.omarchy", "Follow Omarchy"), ("settings.omarchy", "Follow Omarchy"),
("settings.updates", "Check for updates at launch"),
(
"settings.updates.hint",
"Off, Ely asks its release server for a newer version only when you choose Check for Updates.",
),
("settings.language", "Language"), ("settings.language", "Language"),
("settings.language.system", "System"), ("settings.language.system", "System"),
("settings.language.next", "Applies the next time each app starts"), ("settings.language.next", "Applies the next time each app starts"),
@@ -64,6 +69,11 @@ pub(super) const ZH_CN: &[(&str, &str)] = &[
("settings.appearance.light", "浅色"), ("settings.appearance.light", "浅色"),
("settings.appearance.dark", "深色"), ("settings.appearance.dark", "深色"),
("settings.omarchy", "跟随 Omarchy"), ("settings.omarchy", "跟随 Omarchy"),
("settings.updates", "启动时检查更新"),
(
"settings.updates.hint",
"关闭时,只在你选择“检查更新”时才向发布服务器询问新版本。",
),
("settings.language", "语言"), ("settings.language", "语言"),
("settings.language.system", "跟随系统"), ("settings.language.system", "跟随系统"),
("settings.language.next", "各应用下次启动时生效"), ("settings.language.next", "各应用下次启动时生效"),
+1
View File
@@ -6,6 +6,7 @@ pub mod settings;
mod shell; mod shell;
pub mod tasks; pub mod tasks;
mod theme; mod theme;
pub mod updates;
pub use opening::{launch_files, on_open}; pub use opening::{launch_files, on_open};
pub use run::run; pub use run::run;
+6
View File
@@ -15,6 +15,10 @@ pub fn run<V: Render>(
app: AppId, app: AppId,
root: impl FnOnce(AppId, &mut Window, &mut App) -> Entity<V> + 'static, root: impl FnOnce(AppId, &mut Window, &mut App) -> Entity<V> + 'static,
) { ) {
// As the installer after an update, nothing else runs.
if let Some(code) = crate::updates::installer(app) {
std::process::exit(code);
}
// Before the log: a second copy must not trim it. // Before the log: a second copy must not trim it.
if let Err(error) = ely_platform::instance::hold(app) { if let Err(error) = ely_platform::instance::hold(app) {
startup::fail(app, &format!("{error}")); startup::fail(app, &format!("{error}"));
@@ -77,6 +81,8 @@ fn open<V: Render>(
} }
theme::install(cx); theme::install(cx);
crate::i18n::install(cx); crate::i18n::install(cx);
crate::updates::install(app, cx);
cx.on_action(|_: &crate::commands::CheckForUpdates, cx| crate::updates::check_now(cx));
crate::commands::bind_keys(cx); crate::commands::bind_keys(cx);
crate::commands::bind_quit(cx); crate::commands::bind_quit(cx);
cx.on_action(move |_: &crate::commands::OpenSettings, cx| crate::settings::open(app, cx)); cx.on_action(move |_: &crate::commands::OpenSettings, cx| crate::settings::open(app, cx));
+10 -2
View File
@@ -9,7 +9,7 @@ use ely_gpui_component::{
}; };
use ely_platform::{ use ely_platform::{
AppId, AppId,
settings::{APPEARANCE, AUTHOR, Appearance, LANGUAGE, Language, MOTION, Motion, OMARCHY_SYNC, Store, word}, settings::{APPEARANCE, AUTHOR, Appearance, CHECK_UPDATES, LANGUAGE, Language, MOTION, Motion, OMARCHY_SYNC, Store, word},
}; };
use gpui::{ use gpui::{
AppContext as _, Context, Entity, FocusHandle, Global, IntoElement, ParentElement, Render, SharedString, Styled, AppContext as _, Context, Entity, FocusHandle, Global, IntoElement, ParentElement, Render, SharedString, Styled,
@@ -222,7 +222,7 @@ impl SettingsView {
Motion::Reduced => text(cx, "settings.motion.reduce", &[]), Motion::Reduced => text(cx, "settings.motion.reduce", &[]),
Motion::Full => text(cx, "settings.motion.full", &[]), Motion::Full => text(cx, "settings.motion.full", &[]),
}, MOTION, cx); }, MOTION, cx);
let mut section = SettingsSection::new(text(cx, "settings.general", &[])) let section = SettingsSection::new(text(cx, "settings.general", &[]))
.row(SettingsRow::new(text(cx, "settings.appearance", &[])).control(theme)) .row(SettingsRow::new(text(cx, "settings.appearance", &[])).control(theme))
.row( .row(
SettingsRow::new(text(cx, "settings.language", &[])) SettingsRow::new(text(cx, "settings.language", &[]))
@@ -230,6 +230,14 @@ impl SettingsView {
.control(language), .control(language),
) )
.row(SettingsRow::new(text(cx, "settings.motion", &[])).control(motion)); .row(SettingsRow::new(text(cx, "settings.motion", &[])).control(motion));
let updates = Switch::new("settings-updates", shared.check_updates)
.name(text(cx, "settings.updates", &[]))
.on_change(|on, _, cx| set(CHECK_UPDATES, Value::Bool(on), cx));
let mut section = section.row(
SettingsRow::new(text(cx, "settings.updates", &[]))
.description(text(cx, "settings.updates.hint", &[]))
.control(updates),
);
// Only where Omarchy is installed. // Only where Omarchy is installed.
if ely_platform::omarchy_current_dir().is_some() { if ely_platform::omarchy_current_dir().is_some() {
let follow = Switch::new("settings-omarchy", shared.omarchy_sync) let follow = Switch::new("settings-omarchy", shared.omarchy_sync)
+1
View File
@@ -124,6 +124,7 @@ impl RenderOnce for Shell {
.flex() .flex()
.flex_col() .flex_col()
.child(TitleBar::new("titlebar").title(self.title)) .child(TitleBar::new("titlebar").title(self.title))
.children(crate::updates::updater(cx))
.children(menu_bar(cx)) .children(menu_bar(cx))
.children(self.tabs); .children(self.tabs);
// Panels give way so the content keeps its room. // Panels give way so the content keeps its room.
+27
View File
@@ -102,6 +102,33 @@ fn build(
if !document { if !document {
window.focus(&focus, cx); window.focus(&focus, cx);
} }
if let Some(updates) = crate::updates::updater(cx) {
cx.subscribe(
&updates,
|root: &mut Root, _, news: &crate::updates::UpdateNews, cx| match news {
crate::updates::UpdateNews::Failed(error) => {
let text = crate::i18n::text(cx, "updates.failed", &[("error", error)]);
root.toast(text, Severity::Danger, cx);
}
crate::updates::UpdateNews::Latest => {
let args = [
("app", root.app.name()),
("version", env!("CARGO_PKG_VERSION")),
];
let text = crate::i18n::text(cx, "updates.latest", &args);
root.toast(text, Severity::Success, cx);
}
},
)
.detach();
// A failed install from the last quit says why.
if let Some(note) = updates.update(cx, |updates, _| updates.note.take()) {
let text = crate::i18n::text(cx, "updates.failed", &[("error", &note)]);
cx.defer_in(window, move |root: &mut Root, _, cx| {
root.toast(text, Severity::Danger, cx)
});
}
}
Root { Root {
app, app,
focus, focus,
+428
View File
@@ -0,0 +1,428 @@
//! A newer release: offered, downloaded, installed after quitting.
use std::{
io,
path::{Path, PathBuf},
process::{Command, Stdio},
sync::atomic::AtomicBool,
};
use ely_gpui_component::shell::{UpdateBanner, UpdateState};
use ely_platform::{
AppId,
update::{self, Check, Release},
};
use futures::{StreamExt as _, channel::mpsc};
use gpui::{
App, AppContext as _, Context, Entity, EventEmitter, Global, IntoElement, Render, Window, div,
};
/// The release server's newest release, listed by its API.
const LATEST: &str = "https://git.zacharyzhang.com/api/v1/repos/ZacharyZhang-NY/ElyOffice/releases/latest";
/// The argument that runs this binary as the installer.
const INSTALL: &str = "--ely-install-update";
#[derive(Clone, Debug, PartialEq)]
enum Phase {
Offered,
Fetching(f32),
Fetched(PathBuf),
}
pub struct Updates {
app: AppId,
bundle: PathBuf,
offer: Option<(Release, Phase)>,
dismissed: bool,
/// The download to install once the app has quit.
pending: Option<PathBuf>,
/// Why the last install failed, for the window to say.
pub note: Option<String>,
}
/// What an update says to the window.
pub enum UpdateNews {
Failed(String),
/// A check the user asked for found nothing newer.
Latest,
}
impl EventEmitter<UpdateNews> for Updates {}
struct Updater(Entity<Updates>);
impl Global for Updater {}
/// The app's updater, if it runs from an installed bundle.
pub fn updater(cx: &App) -> Option<Entity<Updates>> {
cx.try_global::<Updater>().map(|updater| updater.0.clone())
}
/// Checks now, as the user asked from the menu.
pub fn check_now(cx: &mut App) {
if let Some(updates) = updater(cx) {
updates.update(cx, |updates, cx| updates.check(true, cx));
}
}
/// The quit an update asked for stopped: install nothing.
pub fn quit_stopped(cx: &mut App) {
if let Some(updates) = updater(cx) {
updates.update(cx, |updates, _| {
if updates.pending.take().is_some() {
log::info!("update: the quit stopped; nothing installs");
}
});
}
}
/// Run as the installer: waits, installs, reopens; the exit code.
pub fn installer(app: AppId) -> Option<i32> {
let args: Vec<String> = std::env::args().collect();
let [_, flag, dmg, bundle, pid] = args.as_slice() else {
return None;
};
if flag != INSTALL {
return None;
}
let Ok(pid) = pid.parse() else {
eprintln!("update: {pid} is not a process number");
return Some(2);
};
ely_platform::install::wait_for_exit(pid);
let installed = ely_platform::install::install(Path::new(dmg), Path::new(bundle));
if let Err(error) = &installed {
// To the app's log; the reopened app shows it.
eprintln!("update: the install failed: {error}");
let note = ely_platform::data_dir(app)
.map_err(io::Error::other)
.and_then(|dir| {
std::fs::create_dir_all(dir.join("updates"))?;
std::fs::write(dir.join("updates/failed.txt"), error.to_string())
});
if let Err(lost) = note {
eprintln!("update: the failure note was not written: {lost}");
}
}
// Last: the note is written before the app reads it.
if let Err(error) = ely_platform::install::reopen(Path::new(bundle)) {
eprintln!("update: the app did not reopen: {error}");
return Some(1);
}
Some(i32::from(installed.is_err()))
}
/// An installed app's updater; checks at launch if chosen.
pub(crate) fn install(app: AppId, cx: &mut App) {
let bundle = match ely_platform::install::running_bundle() {
Ok(Some(bundle)) => bundle,
Ok(None) => return log::info!("update: a dev build; no check"),
Err(error) => return log::warn!("update: the running app is not found: {error}"),
};
match update::install_policy() {
Ok(update::InstallPolicy::SelfManaged) => {}
Ok(update::InstallPolicy::PackageManager) => {
return log::info!("update: the package manager updates this app");
}
Err(error) => return log::warn!("update: {error:#}"),
}
let note = ely_platform::data_dir(app)
.ok()
.map(|dir| dir.join("updates/failed.txt"));
let note = note.and_then(|path| {
std::fs::read_to_string(&path)
.ok()
.inspect(|_| drop(std::fs::remove_file(&path)))
});
let updates = cx.new(|cx| {
cx.on_app_quit(|this: &mut Updates, _| {
this.start_installer();
async {}
})
.detach();
Updates {
app,
bundle,
offer: None,
dismissed: false,
pending: None,
note,
}
});
cx.set_global(Updater(updates.clone()));
// Off by default: no request unless the user chose it.
if crate::settings::current(cx).check_updates {
updates.update(cx, |updates, cx| updates.check(false, cx));
} else {
log::info!("update: no check at launch; it is off in settings");
}
}
/// The app's manifest in the newest release, or the test's.
fn manifest(app: AppId) -> anyhow::Result<String> {
match std::env::var("ELY_UPDATE_MANIFEST") {
Ok(url) => Ok(url),
Err(_) => ely_platform::release::asset_url(LATEST, &format!("{}.json", app.slug())),
}
}
impl Updates {
/// Asks for a newer release; `asked` reports every outcome.
fn check(&mut self, asked: bool, cx: &mut Context<Self>) {
// A download under way or done stays the offer.
if matches!(
self.offer,
Some((_, Phase::Fetching(_) | Phase::Fetched(_)))
) {
log::info!("update: a release is already on its way");
if asked {
self.dismissed = false;
cx.notify();
}
return;
}
let app = self.app;
let current =
semver::Version::parse(env!("CARGO_PKG_VERSION")).expect("the build's version");
// The lookup is a request too: off the window's thread.
let checked = cx.background_spawn(async move { manifest(app).and_then(|url| update::check(&current, &url)) });
cx.spawn(async move |this, cx| {
let checked = checked.await;
this.update(cx, |this, cx| match checked {
Ok(Check::Available(_))
if matches!(
this.offer,
Some((_, Phase::Fetching(_) | Phase::Fetched(_)))
) => {}
Ok(Check::Available(release)) => {
(this.offer, this.dismissed) = (Some((release, Phase::Offered)), false);
cx.notify();
}
Ok(Check::Current) if asked => cx.emit(UpdateNews::Latest),
// At launch a failure only logs; offline is normal.
Err(error) if asked => cx.emit(UpdateNews::Failed(format!("{error:#}"))),
Err(error) => log::warn!("update: the launch check failed: {error:#}"),
Ok(Check::Current) => log::info!("update: nothing newer at launch"),
})
.ok();
})
.detach();
}
fn later(&mut self, cx: &mut Context<Self>) {
self.dismissed = true;
cx.notify();
}
fn download(&mut self, cx: &mut Context<Self>) {
let Some((release, phase)) = self
.offer
.as_mut()
.filter(|(_, phase)| *phase == Phase::Offered)
else {
return;
};
*phase = Phase::Fetching(0.0);
cx.notify();
let (release, app) = (release.clone(), self.app);
let (sender, mut progress) = mpsc::unbounded();
let fetching = release.clone();
let fetched = cx.background_spawn(async move {
let dir = ely_platform::data_dir(app)
.map_err(|error| format!("{error:#}"))?
.join("updates");
if dir.exists() {
std::fs::remove_dir_all(&dir).map_err(|error| error.to_string())?;
}
std::fs::create_dir_all(&dir).map_err(|error| error.to_string())?;
let cancel = AtomicBool::new(false);
let mut tell = |done: u64, total: Option<u64>| {
let part = total
.filter(|total| *total > 0)
.map_or(0.0, |total| done as f32 / total as f32);
sender.unbounded_send(part).ok();
};
let file = update::download(&fetching, &dir, &cancel, update::IDLE_TIMEOUT, &mut tell)
.map_err(|error| format!("{error:#}"))?
.ok_or("the download stopped")?;
update::verify_file(&file, &fetching.sha256).map_err(|error| format!("{error:#}"))?;
Ok::<PathBuf, String>(file)
});
cx.spawn(async move |this, cx| {
while let Some(part) = progress.next().await {
this.update(cx, |this, cx| this.fetching(part, cx)).ok();
}
let fetched = fetched.await;
this.update(cx, |this, cx| this.fetched(&release, fetched, cx))
.ok();
})
.detach();
}
fn fetching(&mut self, part: f32, cx: &mut Context<Self>) {
if let Some((_, phase @ Phase::Fetching(_))) = self.offer.as_mut() {
*phase = Phase::Fetching(part);
cx.notify();
}
}
/// A finished download counts only for the release it fetched.
fn fetched(
&mut self,
release: &Release,
fetched: Result<PathBuf, String>,
cx: &mut Context<Self>,
) {
let Some((offered, phase)) = self
.offer
.as_mut()
.filter(|(offered, _)| offered == release)
else {
return log::warn!("update: a download for another release was dropped");
};
match fetched {
Ok(file) => *phase = Phase::Fetched(file),
Err(error) => {
*phase = Phase::Offered;
cx.emit(UpdateNews::Failed(error));
}
}
log::info!("update: {} is {:?}", offered.version, phase);
cx.notify();
}
/// Quits as usual: unsaved work is asked about first.
fn restart(&mut self, cx: &mut Context<Self>) {
let Some((_, Phase::Fetched(file))) = self.offer.as_ref() else {
return;
};
self.pending = Some(file.clone());
crate::commands::quit(cx);
}
/// At the real quit: the installer waits for this process.
fn start_installer(&mut self) {
let Some(file) = self.pending.take() else {
return;
};
let started = std::env::current_exe().and_then(|exe| {
let mut command = Command::new(exe);
command
.arg(INSTALL)
.arg(&file)
.arg(&self.bundle)
.arg(std::process::id().to_string());
// Its words go to the app's log.
let log = ely_platform::logging::path()
.map(|path| std::fs::OpenOptions::new().append(true).open(path));
let said = match log {
Some(file) => Stdio::from(file?),
None => Stdio::null(),
};
command
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(said);
#[cfg(unix)]
std::os::unix::process::CommandExt::process_group(&mut command, 0);
command.spawn()
});
match started {
Ok(_) => log::info!("update: installs after this quit"),
Err(error) => log::error!("update: the installer did not start: {error}"),
}
}
}
impl Render for Updates {
/// The bar under the title while a release is offered.
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let this = cx.entity();
let Some((release, phase)) = self.offer.as_ref().filter(|_| !self.dismissed) else {
return div().into_any_element();
};
let state = match phase {
Phase::Offered => UpdateState::Available,
Phase::Fetching(done) => UpdateState::Downloading(*done),
Phase::Fetched(_) => UpdateState::Ready,
};
let (download, restart, later) = (this.clone(), this.clone(), this);
let banner = UpdateBanner::new("update-banner", release.version.to_string(), state)
.on_download(move |_, cx| download.update(cx, |this, cx| this.download(cx)))
.on_later(move |_, cx| later.update(cx, |this, cx| this.later(cx)));
match phase {
Phase::Fetched(_) => banner
.on_restart(move |_, cx| restart.update(cx, |this, cx| this.restart(cx)))
.into_any_element(),
_ => banner.into_any_element(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
fn release(version: &str, url: &str) -> Release {
Release {
version: semver::Version::parse(version).expect("a version"),
url: url.into(),
sha256: String::new(),
}
}
#[gpui::test]
fn a_check_brings_back_a_dismissed_download(cx: &mut gpui::TestAppContext) {
let updates = cx.new(|_| Updates {
app: AppId::Tree,
bundle: PathBuf::from("/Applications/ElyTree.app"),
offer: Some((
release("9.0.0", "https://b"),
Phase::Fetched(PathBuf::from("B.dmg")),
)),
dismissed: true,
pending: None,
note: None,
});
updates.update(cx, |updates, cx| updates.check(true, cx));
updates.read_with(cx, |updates, _| {
assert!(!updates.dismissed, "the bar shows again");
assert_eq!(
updates.offer.as_ref().map(|(_, phase)| phase.clone()),
Some(Phase::Fetched(PathBuf::from("B.dmg")))
);
});
}
#[gpui::test]
fn a_download_for_an_older_offer_is_dropped(cx: &mut gpui::TestAppContext) {
let updates = cx.new(|_| Updates {
app: AppId::Tree,
bundle: PathBuf::from("/Applications/ElyTree.app"),
offer: Some((release("9.0.0", "https://b"), Phase::Fetching(0.5))),
dismissed: false,
pending: None,
note: None,
});
updates.update(cx, |updates, cx| {
updates.fetched(
&release("8.0.0", "https://a"),
Ok(PathBuf::from("A.dmg")),
cx,
);
assert_eq!(
updates.offer.as_ref().map(|(_, phase)| phase.clone()),
Some(Phase::Fetching(0.5))
);
updates.fetched(
&release("9.0.0", "https://b"),
Ok(PathBuf::from("B.dmg")),
cx,
);
assert_eq!(
updates.offer.as_ref().map(|(_, phase)| phase.clone()),
Some(Phase::Fetched(PathBuf::from("B.dmg")))
);
});
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
随发行说明发布,每个版本一份。支持某格式不等于支持它的全部功能;下表只写已验证的内容、已知限制与保存行为。 随发行说明发布,每个版本一份。支持某格式不等于支持它的全部功能;下表只写已验证的内容、已知限制与保存行为。
版本:Ely Office 0.1.1(首版六个应用:ElyDoc、ElyTable、ElyShow、ElyPDF、ElyTree、ElyMark)。日期 2026-10-09。 版本:Ely Office 0.1.2(首版六个应用:ElyDoc、ElyTable、ElyShow、ElyPDF、ElyTree、ElyMark)。日期 2026-10-09。
内核:LibreOffice 26.2.6.3(8221e31,加 `patches/libreoffice` 0001–0041);MuPDF 1.28.5(8ad45e9,加 `patches/mupdf` 0001–0005);Git 2.56.0(a018953)与 git-lfs 3.8.0;CEF 154.0.32。 内核:LibreOffice 26.2.6.3(8221e31,加 `patches/libreoffice` 0001–0041);MuPDF 1.28.5(8ad45e9,加 `patches/mupdf` 0001–0005);Git 2.56.0(a018953)与 git-lfs 3.8.0;CEF 154.0.32。
验证机:macOS 27.0 arm64。Windows 与 Linux 未验证。本机没有 Microsoft Office:与 Office 的交叉检查未做(待做)。 验证机:macOS 27.0 arm64。Windows 与 Linux 未验证。本机没有 Microsoft Office:与 Office 的交叉检查未做(待做)。
+2 -2
View File
@@ -4,7 +4,7 @@
## 自有代码 ## 自有代码
Ely Office 的自有代码以 AGPL-3.0-or-later 发布,全文在仓库根的 `LICENSE`,并随每个应用包放在 `Resources/Licenses/LICENSE`。组件库 Ely-GPUI-Components 保留其 MIT/Apache-2.0。 Ely Office 的自有代码以 MIT 发布,全文在仓库根的 `LICENSE`,并随每个应用包放在 `Resources/Licenses/LICENSE`。随包的引擎不随之改许可:ElyPDF 链接的 MuPDF 是 AGPL-3.0,ElyPDF 的发行包整体须按 AGPL 履行(对应源码见上游源码包);ElyDoc、ElyTable、ElyShow 的 LibreOffice 仍为 MPL-2.0 等;ElyTree 带的 Git 仍为 GPL-2.0。组件库 Ely-GPUI-Components 保留其 MIT/Apache-2.0。
## 每个发行版附带 ## 每个发行版附带
@@ -12,7 +12,7 @@ Ely Office 的自有代码以 AGPL-3.0-or-later 发布,全文在仓库根的 `
| --- | --- | --- | | --- | --- | --- |
| `ElyOffice-<版本>-source.tar.gz` | 自有源码、`Cargo.lock`、`rust-toolchain.toml`、ElyMark 网页的 `package-lock.json`、上游补丁(`patches/libreoffice`、`patches/mupdf`)、构建与取上游的脚本(各上游钉在提交,脚本里写明地址与散列)、测试、文档 | `packaging/macos/release.sh` | | `ElyOffice-<版本>-source.tar.gz` | 自有源码、`Cargo.lock`、`rust-toolchain.toml`、ElyMark 网页的 `package-lock.json`、上游补丁(`patches/libreoffice`、`patches/mupdf`)、构建与取上游的脚本(各上游钉在提交,脚本里写明地址与散列)、测试、文档 | `packaging/macos/release.sh` |
| `ElyOffice-<版本>-upstream-source.tar.gz` | 实际编译的 MuPDF 源码(钉住的提交加我们的补丁,AGPL)与随包 Git 的源码(v2.56.0,GPLv2) | 同上;`tests/scripts/release-macos.sh` 核对其中是打过补丁的 MuPDF | | `ElyOffice-<版本>-upstream-source.tar.gz` | 实际编译的 MuPDF 源码(钉住的提交加我们的补丁,AGPL)与随包 Git 的源码(v2.56.0,GPLv2) | 同上;`tests/scripts/release-macos.sh` 核对其中是打过补丁的 MuPDF |
| 各应用包 `Resources/Licenses/` | Ely 的 AGPL 全文;`rust-crates.txt`(链进该应用各二进制的全部 crate 与其许可文件,无许可文件的取标准文本并写明作者);所带引擎的许可与通知(见下) | `packaging/licenses.sh`,缺任何一份即打包失败 | | 各应用包 `Resources/Licenses/` | Ely 的 MIT 全文;`rust-crates.txt`(链进该应用各二进制的全部 crate 与其许可文件,无许可文件的取标准文本并写明作者);所带引擎的许可与通知(见下) | `packaging/licenses.sh`,缺任何一份即打包失败 |
## 第三方,按应用 ## 第三方,按应用
+13 -1
View File
@@ -7,6 +7,7 @@ batch=${1:-1}
dist=${ELY_DIST:-$root/dist} dist=${ELY_DIST:-$root/dist}
version=$(awk -F'"' '/^version = / { print $2; exit }' "$root/Cargo.toml") version=$(awk -F'"' '/^version = / { print $2; exit }' "$root/Cargo.toml")
arch=$(uname -m) arch=$(uname -m)
releases=https://git.zacharyzhang.com/ZacharyZhang-NY/ElyOffice/releases
[ -z "${ELY_NOTARY_PROFILE:-}" ] || [ -n "${ELY_SIGN_IDENTITY:-}" ] || { [ -z "${ELY_NOTARY_PROFILE:-}" ] || [ -n "${ELY_SIGN_IDENTITY:-}" ] || {
echo "release.sh: notarizing needs ELY_SIGN_IDENTITY, a Developer ID" >&2 echo "release.sh: notarizing needs ELY_SIGN_IDENTITY, a Developer ID" >&2
exit 1 exit 1
@@ -28,7 +29,12 @@ awk -F'\t' -v batch="$batch" '$4 == batch { print $1 "\t" $2 }' "$root/packaging
codesign --verify --deep --strict "$dist/$name.app" codesign --verify --deep --strict "$dist/$name.app"
dmg=$dist/$name-$version-$arch.dmg dmg=$dist/$name-$version-$arch.dmg
rm -f "$dmg" rm -f "$dmg"
hdiutil create -quiet -volname "$name" -srcfolder "$dist/$name.app" -format UDZO "$dmg" # The app beside Applications: drag one onto the other.
stage=$(mktemp -d)
ditto "$dist/$name.app" "$stage/$name.app"
ln -s /Applications "$stage/Applications"
hdiutil create -quiet -volname "$name" -srcfolder "$stage" -format UDZO "$dmg"
rm -rf "$stage"
if [ -n "${ELY_NOTARY_PROFILE:-}" ]; then if [ -n "${ELY_NOTARY_PROFILE:-}" ]; then
codesign --force --timestamp --sign "$ELY_SIGN_IDENTITY" "$dmg" codesign --force --timestamp --sign "$ELY_SIGN_IDENTITY" "$dmg"
xcrun notarytool submit "$dmg" --keychain-profile "$ELY_NOTARY_PROFILE" --wait xcrun notarytool submit "$dmg" --keychain-profile "$ELY_NOTARY_PROFILE" --wait
@@ -37,5 +43,11 @@ awk -F'\t' -v batch="$batch" '$4 == batch { print $1 "\t" $2 }' "$root/packaging
echo "release.sh: $dmg is not notarized (no ELY_NOTARY_PROFILE)" >&2 echo "release.sh: $dmg is not notarized (no ELY_NOTARY_PROFILE)" >&2
fi fi
echo "$dmg" echo "$dmg"
# What the app's update check reads from the latest release.
sha=$(shasum -a 256 "$dmg" | cut -d' ' -f1)
url="$releases/download/v$version/$(basename "$dmg")"
printf '{"version": "%s", "assets": {"macos-%s": {"url": "%s", "sha256": "%s"}}}\n' \
"$version" "${arch/arm64/aarch64}" "$url" "$sha" >"$dist/$slug.json"
echo "$dist/$slug.json"
done done
rm -rf "$root/target/release/incremental" rm -rf "$root/target/release/incremental"
+1 -1
View File
@@ -1,3 +1,3 @@
// The published release; downloads live on its release page. // The published release; downloads live on its release page.
export const VERSION = "0.1.1"; export const VERSION = "0.1.2";
export const RELEASES = "https://git.zacharyzhang.com/ZacharyZhang-NY/ElyOffice/releases/latest"; export const RELEASES = "https://git.zacharyzhang.com/ZacharyZhang-NY/ElyOffice/releases/latest";
+2 -2
View File
@@ -10,7 +10,7 @@ const en = {
ElyTree: "Stage lines, commit, read the graph. Git without a terminal.", ElyTree: "Stage lines, commit, read the graph. Git without a terminal.",
ElyMark: "Markdown as you read it. Math and diagrams in place.", ElyMark: "Markdown as you read it. Math and diagrams in place.",
offline: "Works with the network off.", offline: "Works with the network off.",
open: "Open source, under the AGPL.", open: "Open source, under the MIT licence.",
local: "Your files stay in your folders.", local: "Your files stay in your folders.",
download: "Download", download: "Download",
platforms: "Out now for macOS. Windows and Linux are coming soon.", platforms: "Out now for macOS. Windows and Linux are coming soon.",
@@ -46,7 +46,7 @@ const zh: typeof en = {
ElyTree: "按行暂存、提交、看提交图。不用终端的 Git。", ElyTree: "按行暂存、提交、看提交图。不用终端的 Git。",
ElyMark: "写的就是看到的 Markdown。公式与图表就地显示。", ElyMark: "写的就是看到的 Markdown。公式与图表就地显示。",
offline: "断网照常工作。", offline: "断网照常工作。",
open: "开源,AGPL 许可。", open: "开源,MIT 许可。",
local: "文件留在你自己的文件夹里。", local: "文件留在你自己的文件夹里。",
download: "下载", download: "下载",
platforms: "macOS 版已发布。Windows 与 Linux 版即将推出。", platforms: "macOS 版已发布。Windows 与 Linux 版即将推出。",
+2 -2
View File
@@ -6,7 +6,7 @@
次序:S-03、P-01、X-01、D-01、D-02、P-02、P-03、P-04、M-01、X-02、X-03、K-01(Linux、Windows,本机不能运行)、UPD-1、REL-1、REL-2。K-01 不进 0.1.2:只影响 Linux 与 Windows 的 worker,本机不能运行验证,0.1.2 只发 macOS;留在下面的清单里,未勾。T-05 已改一半(审查查出缩放后尺寸不重测),暂放,补丁存在草稿区。 次序:S-03、P-01、X-01、D-01、D-02、P-02、P-03、P-04、M-01、X-02、X-03、K-01(Linux、Windows,本机不能运行)、UPD-1、REL-1、REL-2。K-01 不进 0.1.2:只影响 Linux 与 Windows 的 worker,本机不能运行验证,0.1.2 只发 macOS;留在下面的清单里,未勾。T-05 已改一半(审查查出缩放后尺寸不重测),暂放,补丁存在草稿区。
- [ ] UPD-1 自动更新:应用内检查新版本、下载、校验,经用户同意后替换并重启;发布时生成更新清单,不再要点 GitHub 链接 - [x] UPD-1 自动更新:应用内检查新版本、下载、校验,经用户同意后替换并重启;发布时生成更新清单,不再要点 GitHub 链接 — 启动检查默认关、菜单“检查更新…”、退出后再装、失败记录先于重开、经 Gitea API 找清单;R1–R4 授权、提交点、保存询问、版本绑定、横幅位置、取消退出、记录先后;R5 两处(启动检查失败记日志、以替身 open 断言先后)已修并以变异验证,五轮上限,未再审
- [x] T-01 内核的图块与命中按像素网格,Ely 的光标、选区、表头按文档 twips,越远越错位 — R2.16 已修(图块 twips 与打印 twips 互换) - [x] T-01 内核的图块与命中按像素网格,Ely 的光标、选区、表头按文档 twips,越远越错位 — R2.16 已修(图块 twips 与打印 twips 互换)
- [x] T-02 单元格光标露出边缘即把视图滚到中央,点击与拖选时视图跳动 — R1 拖选中仍滚、超宽格跳回起点;R2 PASS - [x] T-02 单元格光标露出边缘即把视图滚到中央,点击与拖选时视图跳动 — R1 拖选中仍滚、超宽格跳回起点;R2 PASS
@@ -104,5 +104,5 @@
## 0.1.2 发布 ## 0.1.2 发布
- [ ] REL-1 dmg 里有指向“应用程序”的快捷方式,可直接拖入安装(用户 2026-10-09 报) - [x] REL-1 dmg 里有指向“应用程序”的快捷方式,可直接拖入安装(用户 2026-10-09 报) — release.sh 在 dmg 里放“应用程序”替身,随 UPD-1 审查
- [ ] REL-2 修完上列各条后打包、发布 0.1.2,官网指向新发布页 - [ ] REL-2 修完上列各条后打包、发布 0.1.2,官网指向新发布页
+9
View File
@@ -0,0 +1,9 @@
FAIL
crates/ely-ui/src/updates.rs:59 — [P1] 启动检查绕过更新授权与默认设置,违反 PRD.md:113 的“自动检查更新默认关闭”及 QA-25。首次从安装好的 .app 启动、使用空白用户目录时,程序直接请求更新清单;本地端到端测试在任何用户操作之前已收到请求并记录 `offers 9.9.9`。当前设置模型也没有控制该请求的字段。修复方向:加入默认关闭的自动检查设置,启动检查以用户授权和离线设置为条件,并覆盖空白配置下零请求的测试。
crates/ely-ui/src/updates.rs:67 — [P2] 更新检查仅由启动路径调用一次,缺少 PRD.md:113 要求的手动检查入口。具体场景:启动时断网,唯一一次检查失败后,恢复网络并继续使用应用,用户无法重新检查、获得更新横幅或下载更新;`check` 为私有方法,调用点只有第 59 行,菜单与设置均未接入检查动作。修复方向:提供可重复执行的手动检查动作,接入应用界面,并测试首次失败后联网重查。
crates/ely-platform/src/install.rs:65 — [P1] 新包替换成功后,删除旧包的错误被当作整个安装失败返回,更新状态与磁盘事实分离,失败路径也未恢复原版本,违反 PRD §4.2、QA-26。实测在旧包 `Contents/version` 上设置 `chflags uchg` 后调用真实 dmg 安装,结果为 `install=Err(PermissionDenied: Operation not permitted)`、`live=Ok("new")`、`backup=Ok("old")`。调用方因此跳过 `reopen_after_exit` 和正常退出,显示更新失败,原路径却已换成新版;重试还会卡在删除同一旧包。修复方向:明确安装提交点,将提交后的备份清理错误与安装结果分开处理,保证提交前失败恢复旧包、提交后结果与实际版本一致,并加入清理失败的回归用例。
tests/scripts/update.sh:54 — [P2] 重启断言只按命令行中的 .app 路径执行 `pgrep -f`,重启辅助进程也满足条件,测试会把启动失败判为成功。实测仅在临时脚本中通过 PATH 将 `open` 换成 `sleep 30; exit 1`,完整测试仍输出 `ok: ElyTree downloads, installs and reopens its update`;通过断言的唯一进程是 `/bin/sh .../bin/open .../Applications/ElyTree.app`,新版 ElyTree 实际未启动。修复方向:断言新版应用自身的可执行文件身份、不同于旧进程的 PID,以及窗口或启动完成信号;让该 `open` 失败变异稳定触发测试失败。
+7
View File
@@ -0,0 +1,7 @@
FAIL
crates/ely-ui/src/updates.rs:195 — [P1] 安装发生在保存与退出确认之前,违反 PRD.md:113 的“更新前要求保存编辑内容”。实测在 ElyDoc 的 Untitled 1 输入文字,下载更新后按 Restart to update:先出现 `install: .../ElyDoc.app replaced`,随后才出现 `Save changes to Untitled 1?`;此时新包标记已在原路径,旧进程仍持有未保存内容。按 Esc 取消后,截图确认文档继续编辑,新包仍在原路径,更新状态停在 Installing,重启入口消失。证据:`/tmp/upd1-r2-save-only.log`、`/tmp/upd1-r2-evidence-3-ely-doc.log`。修复方向:将保存与退出确认作为替换包和注册重启的前置条件;取消时保留原包与可重试的下载完成状态,并覆盖未保存文档取消更新的回归测试。
crates/ely-ui/src/updates.rs:92 — [P1] 手动重查覆盖正在下载的 release,下载完成回调又直接修改当前 offer 的 phase(第 170–175 行),导致清单版本与待安装文件错配。真实 ElyTree 探针先查询 8.0.0 并开始下载 A.dmg,在 HTTP 服务暂停该下载期间手动重查得到 9.0.0/B.dmg,再放行 A:日志依次记录 `offers 9.0.0`、`update download: 8.0.0 saved .../A.dmg`;随后按 Restart to update,安装后的包标记为 A。用户对新 offer 的重启操作因此安装了此前请求的包。证据:`/tmp/upd1-r2-native.log`、`/tmp/upd1-r2-evidence-0-ely-tree.log`。修复方向:将检查、下载进度、完成结果和安装绑定同一 release 与操作身份,阻止重查覆盖进行中的更新,丢弃过期回调,并覆盖慢下载期间重查的回归测试。
crates/ely-ui/src/shell/root.rs:250 — [P2] 更新横幅被插在包含 TitleBar 的整个应用外壳之前,落入 macOS 原生窗口按钮所在区域,同时失去外壳提供的主题前景色。实测深色 ElyTree 手动检查得到 9.0.0 时,原生红黄绿按钮遮住更新文案开头;横幅其余文字为 RGB(0,0,0),背景为 RGB(48,48,48),截图实测对比度约 1.59:1,低于 PRD.md:750 的 4.5:1。ElyDoc 的就绪横幅也呈现同样遮挡。证据:`/tmp/upd1-r2-banner.log`。修复方向:将横幅放在主题化外壳的标题栏下方,使用主题前景色并保留原生窗口按钮区域;验证深浅主题下文案可读且无重叠。
+7
View File
@@ -0,0 +1,7 @@
FAIL
crates/ely-ui/src/updates.rs:224 — [P1] 取消更新退出后,`pending` 仍保留,下一次普通退出继续安装并重开应用,违反“取消即什么也不装”的修复契约。真实 ElyMark 探针输入未保存文字,下载完成后点击 Restart to update,再点击 Cancel;随后仅从应用菜单选择 Quit ElyMark,并对未保存内容选择 Don't Save,更新标记仍被装入原包,新的应用进程再次启动。日志记录普通退出后的 `update: installs after this quit`;当前回归测试取消后再次点击 Restart,遗漏了这条路径。证据:`/tmp/upd1-r3-cancel.log`、`/tmp/upd1-r3-cancel-app.log`。修复方向:将待安装状态绑定这次更新退出请求,在取消或退出流程中止时清除;保留已下载文件供再次明确点击 Restart,并覆盖取消后普通退出的测试。
crates/ely-ui/src/updates.rs:131 — [P2] 下载中或已下载时手动检查直接返回,使已关闭的更新横幅无法恢复,下载完成后的安装入口随之丢失。真实 ElyTree 探针下载 8.0.0 完成,关闭横幅的 x,再选择 Check for Updates…;检查函数只记录 `a release is already on its way`,`dismissed` 持续为 true,AX 树中 Restart to update 消失,用户在本次运行中无法重新进入安装操作。下载期间关闭横幅同样进入此状态。证据:`/tmp/upd1-r3-dismiss.log`、`/tmp/upd1-r3-tree-dark.log`。修复方向:用户手动检查时重新显示现有下载状态,同时保持该 release 和下载文件的绑定;覆盖下载中及下载完成后关闭横幅再手动检查的回归测试。
crates/ely-ui/src/updates.rs:84 — [P2] 安装失败记录的写入错误被 `.ok()` 丢弃,而安装子进程的 stderr 在第 236 行被重定向到空设备,导致失败静默。以下载目录被清理的状态运行真实安装入口:dmg 与 `updates` 目录均已消失,挂载失败后原应用正常重开,写入 `updates/failed.txt` 因父目录缺失失败;重开窗口没有失败提示,记录文件也不存在。保留记录目录的对照探针能够显示同一安装错误。证据:`/tmp/upd1-r3-missing-parent.log`、`/tmp/upd1-r3-missing-parent-reopened.log`、`/tmp/upd1-r3-failure.log`。修复方向:确保故障记录目录存在,处理记录写入错误,并保证持久化失败时重开的应用仍能展示安装失败;覆盖下载目录被清理的安装失败测试。
+3
View File
@@ -0,0 +1,3 @@
FAIL
crates/ely-ui/src/updates.rs:95 — [P2] 安装失败记录晚于应用重开,失败提示存在竞态。`ely_platform::install::finish` 在 `crates/ely-platform/src/install.rs:80` 先执行 `open`,返回后此处才写 `updates/failed.txt`;重开的应用只在启动时读取一次该文件(第 119–120 行)。真实 ElyTree 探针令 dmg 缺失,经透明包装调用真实 `/usr/bin/open` 并保持其参数和退出码,在启动请求之后暂停安装父进程;等重开窗口完成启动,再恢复安装进程。连续两次均出现:窗口启动时记录尚未写入,随后安装进程写入记录并退出,当前窗口始终没有失败提示,记录留待下次启动才读取。普通调度对照能生成失败提示,说明此次补建目录仍未保证提示交付。证据:`/tmp/upd1-r4-race-1.log`、`/tmp/upd1-r4-race-2.log`、`/tmp/upd1-r4-race-app.log`;复现步骤:`/tmp/upd1-r4-repro.log`。修复方向:失败记录完成写入及错误处理后再重开应用,并增加覆盖该先后顺序、断言本次重开即显示失败提示的回归测试。
+5
View File
@@ -0,0 +1,5 @@
FAIL
crates/ely-ui/src/updates.rs:203 — [P2] 启动自动检查会静默丢弃新增 Gitea 查询路径的错误。`manifest(app)` 在第 188 行先执行,查询失败便跳过负责记录结果的 `update::check`;`asked == false` 时错误进入第 204 行的空分支。实测将临时 HOME 的 `check_updates` 设为 true,启动本轮构建并打包的 ElyTree:Gitea 请求完成并返回 HTTP 200,当前发布缺少 `ely-tree.json`,直接调用生产 `release::asset_url` 得到 `release v0.1.1 has no ely-tree.json`,启动日志却完全没有检查失败记录。API 断网、HTTP 错误和无效响应同样进入此分支,违反出错暴露和关键路径日志规则。证据:`/tmp/upd1-r5-gitea-debug.log`、`/tmp/upd1-r5-gitea-error.log`、`/tmp/upd1-r5-repro.log`。修复方向:对整个 Gitea 查询与清单检查的失败结果记录错误,并覆盖启动查询失败的日志断言。
tests/scripts/update.sh:115 — [P2] 新增顺序回归断言将记录修改时间与进程启动时间都截到整秒,同一秒内先重开、后写记录仍会通过。第 4 轮的生产代码顺序已修正,原版真实 ElyMark 更新脚本通过;随后在临时测试脚本的损坏发布阶段,通过 hdiutil 包装器执行真实 detach,再提前调用真实 `/usr/bin/open`,确认真实应用进程已出现后才让安装器继续写记录,保留全部原有断言。变异日志在 `1791577204130723000` 纳秒确认应用已重开且记录尚不存在,记录修改时间为 `1791577204133946137` 纳秒,完整脚本仍退出 0 并输出成功。独立真实进程探针连续三次也接受了启动后约 250 毫秒才写记录的顺序。证据:`/tmp/upd1-r5-mutation-order.log`、`/tmp/upd1-r5-mutation-test.log`、`/tmp/upd1-r5-time-assertion.log`;复现方法:`/tmp/upd1-r5-repro.log`。修复方向:通过重开入口的事件握手断言启动请求前记录已写好,并验证本次重开窗口显示失败提示,使提前重开的变异稳定失败。
+120
View File
@@ -0,0 +1,120 @@
#!/usr/bin/env bash
# An installed ElyMark updates from a served release, asking first.
set -euo pipefail
root=$(cd "$(dirname "$0")/../.." && pwd)
[ "$(uname)" = Darwin ] || { echo "SKIP: macOS only"; exit 0; }
work=$(mktemp -d)
cleanup() {
pkill -f "$work/Applications/ElyMark.app" 2>/dev/null || true
if [ -n "${server:-}" ]; then
kill "$server" 2>/dev/null || true
wait "$server" 2>/dev/null || true
fi
rm -rf "$work"
}
trap cleanup EXIT
fail() { echo "FAIL: $*" >&2; exit 1; }
ELY_DIST="$work/dist" "$root/packaging/macos/bundle.sh" ely-mark debug >"$work/bundle" 2>&1 || fail "bundle: $(tail -5 "$work/bundle")"
swiftc -O -o "$work/ax-press" "$root/tests/scripts/ax-press.swift"
mkdir -p "$work/Applications" "$work/new" "$work/serve"
ditto "$work/dist/ElyMark.app" "$work/Applications/ElyMark.app"
# The new release: the same app, marked.
ditto "$work/dist/ElyMark.app" "$work/new/ElyMark.app"
touch "$work/new/ElyMark.app/Contents/Resources/ely-update-marker"
codesign --force --deep --sign - "$work/new/ElyMark.app" 2>/dev/null
ln -s /Applications "$work/new/Applications"
hdiutil create -quiet -volname ElyMark -srcfolder "$work/new" -format UDZO "$work/serve/ElyMark.dmg"
port=$(python3 -c 'import socket; s = socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1])')
sha=$(shasum -a 256 "$work/serve/ElyMark.dmg" | cut -d' ' -f1)
key="macos-$(uname -m | sed s/arm64/aarch64/)"
printf '{"version": "9.9.9", "assets": {"%s": {"url": "http://127.0.0.1:%s/ElyMark.dmg", "sha256": "%s"}}}\n' "$key" "$port" "$sha" >"$work/serve/ely-mark.json"
python3 -m http.server "$port" --bind 127.0.0.1 --directory "$work/serve" >"$work/served" 2>&1 &
server=$!
mkdir -p "$work/home"
# The installer's open: says whether the failure note came first.
mkdir -p "$work/bin"
printf '#!/bin/sh\n[ -e "%s" ] && echo before >>"%s" || echo after >>"%s"\nexec /usr/bin/open "$@"\n' \
"$work/home/Library/Application Support/ElyOffice/ely-mark/updates/failed.txt" "$work/opened" "$work/opened" >"$work/bin/open"
chmod +x "$work/bin/open"
start() {
PATH="$work/bin:$PATH" HOME="$work/home" ELY_LOG=info ELY_LOCALE=en ELY_NO_DIALOG=1 ELY_UPDATE_MANIFEST="http://127.0.0.1:$port/ely-mark.json" \
"$work/Applications/ElyMark.app/Contents/MacOS/ely-mark" >"$work/out" 2>&1 &
pid=$!
}
start
[ "$("$work/ax-press" "$pid" none)" != untrusted ] || fail "needs Accessibility permission"
# Off by default: nothing is asked at launch.
for _ in $(seq 60); do grep -q "no check at launch" "$work/out" && break; sleep 0.5; done
grep -q "no check at launch" "$work/out" || fail "the launch check ran: $(grep update "$work/out" | tail -3)"
for _ in $(seq 60); do grep -q 'mark: shown as' "$work/out" && break; sleep 0.5; done
# A new untitled page: it takes keys, autosave skips it.
osascript -e "tell application \"System Events\" to set frontmost of (first process whose unix id is $pid) to true" -e 'delay 1' \
-e 'tell application "System Events" to keystroke "n" using command down' -e 'delay 2' \
-e 'tell application "System Events" to keystroke "unsaved"' >/dev/null
sleep 3
! grep -q GET "$work/served" || fail "asked without being told: $(cat "$work/served")"
press() {
for _ in $(seq 60); do
[ "$("$work/ax-press" "$pid" "$1")" = pressed ] && return 0
sleep 0.5
done
fail "could not press $1: $(grep update "$work/out" | tail -3)"
}
press "Check for Updates…"
for _ in $(seq 60); do grep -q "offers 9.9.9" "$work/out" && break; sleep 0.5; done
grep -q "offers 9.9.9" "$work/out" || fail "no offer: $(grep update "$work/out" | tail -3)"
press Download
press "Restart to update"
# Unsaved text: the question comes first; cancel installs nothing.
press Cancel
sleep 3
kill -0 "$pid" 2>/dev/null || fail "a cancelled quit still quit"
[ ! -e "$work/Applications/ElyMark.app/Contents/Resources/ely-update-marker" ] || fail "installed before the question"
# A plain quit after the cancel installs nothing either.
osascript -e 'tell application "System Events" to keystroke "q" using command down' >/dev/null
press "Don't Save"
for _ in $(seq 60); do kill -0 "$pid" 2>/dev/null || break; sleep 0.5; done
! kill -0 "$pid" 2>/dev/null || fail "the app did not quit"
sleep 8
[ ! -e "$work/Applications/ElyMark.app/Contents/Resources/ely-update-marker" ] || fail "a plain quit installed the update"
! pgrep -f "$(basename "$work")/Applications/ElyMark.app/Contents/MacOS/ely-mark" >/dev/null || fail "a plain quit reopened the app"
# Relaunched: check, download again, and Restart installs.
start
for _ in $(seq 60); do grep -q 'mark: shown as' "$work/out" && break; sleep 0.5; done
press "Check for Updates…"
press Download
press "Restart to update"
for _ in $(seq 60); do kill -0 "$pid" 2>/dev/null || break; sleep 0.5; done
! kill -0 "$pid" 2>/dev/null || fail "the old app did not quit"
# The installer copies once the old app has gone.
for _ in $(seq 120); do [ -e "$work/Applications/ElyMark.app/Contents/Resources/ely-update-marker" ] && break; sleep 0.5; done
[ -e "$work/Applications/ElyMark.app/Contents/Resources/ely-update-marker" ] || fail "the new app is not in place"
# The new app itself, by the path the system resolved.
binary="$(basename "$work")/Applications/ElyMark.app/Contents/MacOS/ely-mark"
for _ in $(seq 40); do pgrep -f "$binary" >/dev/null && break; sleep 0.5; done
fresh=$(pgrep -f "$binary" | head -n 1 || true)
[ -n "$fresh" ] && [ "$fresh" != "$pid" ] || fail "the new app did not open"
[ "$(ls -A "$work/Applications")" = ElyMark.app ] || fail "copies left: $(ls -A "$work/Applications")"
# A broken release: its note is written before the reopen.
pkill -f "$binary" || true
for _ in $(seq 20); do pgrep -f "$binary" >/dev/null || break; sleep 0.5; done
mkdir -p "$work/broken/Other.app"
hdiutil create -quiet -volname Broken -srcfolder "$work/broken" -format UDZO "$work/serve/Broken.dmg"
sha=$(shasum -a 256 "$work/serve/Broken.dmg" | cut -d' ' -f1)
rm -f "$work/opened"
printf '{"version": "9.9.10", "assets": {"%s": {"url": "http://127.0.0.1:%s/Broken.dmg", "sha256": "%s"}}}\n' "$key" "$port" "$sha" >"$work/serve/ely-mark.json"
start
for _ in $(seq 60); do grep -q 'mark: shown as' "$work/out" && break; sleep 0.5; done
press "Check for Updates…"
press Download
press "Restart to update"
note="$work/home/Library/Application Support/ElyOffice/ely-mark/updates/failed.txt"
# Not the old process, which this script started and reaps.
reopened() { pgrep -f "$binary" | grep -vx "$pid" | head -n 1 || true; }
for _ in $(seq 60); do [ -n "$(reopened)" ] && [ -e "$note" ] && break; sleep 0.5; done
grep -q "holds no ElyMark.app" "$note" || fail "no failure note: $(cat "$note" 2>/dev/null)"
[ -n "$(reopened)" ] || fail "the old app did not reopen"
[ "$(head -n 1 "$work/opened")" = before ] || fail "the app reopened before the note was written"
echo "ok: ElyMark downloads, installs and reopens its update"