Release Minimize Tools 0.1.0
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
release/*.zip
|
||||||
|
release/*.zip.sha256
|
||||||
|
coverage/
|
||||||
|
playwright-report/
|
||||||
|
test-results/
|
||||||
|
*.tsbuildinfo
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@add-ideas:registry=https://git.add-ideas.de/api/packages/lotobo/npm/
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 0.1.0 - 2026-09-01
|
||||||
|
|
||||||
|
- Add bounded structure-aware JSON/XML and textual delta debugging
|
||||||
|
- Add literal, syntax, focused JSON Schema, isolated regex, and restricted local
|
||||||
|
XSLT failure predicates
|
||||||
|
- Add JSON Schema failure-signature preservation, cancellation, budgets,
|
||||||
|
progress, trace inspection, and deterministic case/report export
|
||||||
|
- Add Toolbox shell integration, offline PWA support, documentation, and
|
||||||
|
Chromium/Firefox coverage
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Run `npm ci`, `npm run check`, and `npm run test:browser` before proposing a change. Keep processing local, preserve explicit limits, and include fixtures for every parser boundary.
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<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 General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Licences
|
||||||
|
|
||||||
|
The application is GPL-3.0-or-later. Generated release artifacts include an exact runtime dependency licence inventory in `npm-runtime-licenses.txt`.
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# Minimize Tools
|
||||||
|
|
||||||
|
Reduce a failing input while repeatedly proving that the selected failure still
|
||||||
|
occurs. Minimize Tools is a local-first delta-debugging module in the add·ideas
|
||||||
|
Toolbox.
|
||||||
|
|
||||||
|
## v0.1.0 capabilities
|
||||||
|
|
||||||
|
- Minimize plain text by lines, lexical tokens, and Unicode code points
|
||||||
|
- Apply structure-aware reductions before textual delta debugging for bounded
|
||||||
|
JSON and XML inputs
|
||||||
|
- Preserve a literal marker, invalid JSON/XML state, an isolated regular
|
||||||
|
expression match or time threshold, a focused JSON Schema failure, a local
|
||||||
|
XSLT exception, or a marker in XSLT output
|
||||||
|
- Preserve the first JSON Schema failing path and rule by default, preventing a
|
||||||
|
reduction from silently changing to an easier unrelated violation
|
||||||
|
- Run regular expressions in a disposable same-origin worker with a hard safety
|
||||||
|
timeout; cancel any run and retain the last complete result
|
||||||
|
- Enforce explicit predicate-test and wall-time budgets and show every accepted
|
||||||
|
size reduction
|
||||||
|
- Export the minimized case and a deterministic report containing the predicate,
|
||||||
|
engine version, limits, and reduction trace
|
||||||
|
|
||||||
|
## Honest scope
|
||||||
|
|
||||||
|
The JSON Schema predicate implements a documented focused subset: common types,
|
||||||
|
properties, required/additional properties, items, enum/const, size, and numeric
|
||||||
|
bounds. Unsupported keywords fail closed; remote references and formats are not
|
||||||
|
silently approximated. The XSLT predicate uses the browser's XSLT 1.0 processor
|
||||||
|
when available and rejects imports, includes, href targets, DOCTYPE declarations,
|
||||||
|
and external-resource XPath functions. XSLT tests are additionally capped at 200.
|
||||||
|
|
||||||
|
Minimization finds a locally minimal case under the attempted transformations
|
||||||
|
and budget, not a mathematically globally shortest input. Regex timing depends on
|
||||||
|
the browser and device. Inputs are capped at 2 MiB, runs at 2,000 tests and 30
|
||||||
|
seconds, regex worker execution at one second, and stylesheets at 128 KiB.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm ci
|
||||||
|
npm run check
|
||||||
|
npm run test:browser
|
||||||
|
```
|
||||||
|
|
||||||
|
`npm run release:artifact` creates a deterministic release ZIP and SHA-256
|
||||||
|
sidecar after all checks pass.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GPL-3.0-or-later. See [LICENSE](LICENSE).
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Security
|
||||||
|
|
||||||
|
Please report vulnerabilities privately to the repository owner. Do not attach sensitive source files to public issues. Imported inputs are untrusted; parsers must remain bounded and must not execute active content or fetch external resources.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Corresponding source
|
||||||
|
|
||||||
|
The corresponding source for Minimize Tools 0.1.0 is available at:
|
||||||
|
|
||||||
|
https://git.add-ideas.de/lotobo/minimize-tools/src/tag/v0.1.0
|
||||||
|
|
||||||
|
Build with Node.js 22, npm 11, `npm ci`, and `npm run release:artifact`.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Third-party notices
|
||||||
|
|
||||||
|
Minimize Tools 0.1.0 directly depends on these runtime packages:
|
||||||
|
|
||||||
|
| Package | Pinned version | Declared licence |
|
||||||
|
| -------------------------------- | -------------: | ---------------- |
|
||||||
|
| `@add-ideas/toolbox-contract` | 0.2.3 | Apache-2.0 |
|
||||||
|
| `@add-ideas/toolbox-helpers` | 0.1.0 | GPL-3.0-or-later |
|
||||||
|
| `@add-ideas/toolbox-shell-react` | 0.2.3 | Apache-2.0 |
|
||||||
|
| `react` | 19.2.8 | MIT |
|
||||||
|
| `react-dom` | 19.2.8 | MIT |
|
||||||
|
|
||||||
|
This table covers direct production dependencies, not transitive packages or development tooling. During a release build, the exact non-development dependency tree and discovered licence texts are generated from the lockfile into `LICENSES/npm-runtime-licenses.txt` and included in the release ZIP. Copyright and licence terms remain with their respective authors.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Accessibility
|
||||||
|
|
||||||
|
All inputs, limits, presets, and actions use labelled native controls with
|
||||||
|
visible keyboard focus. Progress and errors use live text status rather than
|
||||||
|
colour alone. Source, predicate, and result regions follow document order and
|
||||||
|
stack on narrower screens; long source and trace content remains scrollable.
|
||||||
|
|
||||||
|
Light, dark, and system themes inherit the shared Toolbox shell. Reduced-motion
|
||||||
|
preferences disable transitions. Cancellation is keyboard reachable and the
|
||||||
|
last completed result remains available while a new run is active.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Architecture
|
||||||
|
|
||||||
|
The framework-independent engine applies a deterministic sequence of reductions:
|
||||||
|
normalization, structure-aware JSON/XML candidates, line chunks, lexical-token
|
||||||
|
chunks, and Unicode code-point chunks. Every smaller candidate must independently
|
||||||
|
satisfy the async predicate before it replaces the current result. Candidate
|
||||||
|
outcomes are memoized, accepted transitions are recorded, and an AbortSignal,
|
||||||
|
test budget, and deadline are checked throughout.
|
||||||
|
|
||||||
|
JSON candidates are parsed with depth/node/key limits. XML rejects DOCTYPE and
|
||||||
|
is manipulated as inert DOM nodes. The focused JSON Schema validator returns a
|
||||||
|
stable first-issue signature. Regex work runs in a disposable module worker; a
|
||||||
|
non-returning expression causes worker termination. Restricted XSLT evaluation
|
||||||
|
uses the browser API on the main thread, so it has smaller source/test limits and
|
||||||
|
explicitly rejects resource-loading constructs.
|
||||||
|
|
||||||
|
Limits are 2 MiB input, 2,000 predicate tests, 30 seconds per run, 100,000 JSON
|
||||||
|
nodes, 128 KiB XSLT, 200 XSLT tests, and at most one second of regex worker time.
|
||||||
|
The engine reports budget exhaustion instead of claiming a globally minimal
|
||||||
|
result.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Privacy and security
|
||||||
|
|
||||||
|
Selected files, predicates, intermediate candidates, and results remain in page
|
||||||
|
memory. There is no upload, telemetry, analytics, remote reference resolution,
|
||||||
|
external font, or account. The production policy restricts network connections
|
||||||
|
to the same origin and browser tests reject unexpected requests.
|
||||||
|
|
||||||
|
JSON and XML are inert data; dangerous JSON keys and XML document types are
|
||||||
|
rejected. Regular expressions execute in a same-origin worker that can be
|
||||||
|
terminated. XSLT is limited to a local, bounded stylesheet and rejects imports,
|
||||||
|
includes, hrefs, DOCTYPE, and known external-resource functions. Browser-native
|
||||||
|
XSLT is synchronous and cannot be pre-empted mid-call, so only trusted local
|
||||||
|
stylesheets should be tested despite those safeguards.
|
||||||
|
|
||||||
|
A reduced input demonstrates only the recorded predicate. It is not proof that
|
||||||
|
the original root cause, security impact, timing characteristic on another
|
||||||
|
machine, or standards conformance remains identical. Review the exported trace
|
||||||
|
and keep failure-signature preservation enabled where available.
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import js from "@eslint/js";
|
||||||
|
import globals from "globals";
|
||||||
|
import reactHooks from "eslint-plugin-react-hooks";
|
||||||
|
import reactRefresh from "eslint-plugin-react-refresh";
|
||||||
|
import tseslint from "typescript-eslint";
|
||||||
|
|
||||||
|
export default tseslint.config(
|
||||||
|
{
|
||||||
|
ignores: [
|
||||||
|
"dist",
|
||||||
|
"release",
|
||||||
|
"coverage",
|
||||||
|
"test-results",
|
||||||
|
"playwright-report",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||||
|
files: ["**/*.{ts,tsx}"],
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 2023,
|
||||||
|
globals: { ...globals.browser, ...globals.worker },
|
||||||
|
},
|
||||||
|
plugins: { "react-hooks": reactHooks, "react-refresh": reactRefresh },
|
||||||
|
rules: {
|
||||||
|
...reactHooks.configs.recommended.rules,
|
||||||
|
"react-refresh/only-export-components": [
|
||||||
|
"warn",
|
||||||
|
{ allowConstantExport: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["scripts/**/*.mjs", "playwright.config.ts"],
|
||||||
|
languageOptions: { globals: globals.node },
|
||||||
|
},
|
||||||
|
);
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Reduce failing inputs while preserving a local failure predicate."
|
||||||
|
/>
|
||||||
|
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
||||||
|
<link rel="manifest" href="./manifest.webmanifest" />
|
||||||
|
<meta name="theme-color" content="#29255f" />
|
||||||
|
<title>Minimize Tools</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="./src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Generated
+3500
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"name": "minimize-tools",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Reduce failing inputs while preserving a bounded local failure predicate.",
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
|
"author": "Albrecht Degering",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://git.add-ideas.de/lotobo/minimize-tools.git"
|
||||||
|
},
|
||||||
|
"homepage": "https://git.add-ideas.de/lotobo/minimize-tools",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://git.add-ideas.de/lotobo/minimize-tools/issues"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"predev": "npm run manifest:generate",
|
||||||
|
"dev": "vite",
|
||||||
|
"prebuild": "npm run release:prepare && npm run manifest:generate",
|
||||||
|
"build": "tsc -b && vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"typecheck": "tsc -b --pretty false",
|
||||||
|
"lint": "eslint . --max-warnings=0",
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"format:check": "prettier --check .",
|
||||||
|
"test": "vitest run",
|
||||||
|
"test:watch": "vitest",
|
||||||
|
"test:browser": "playwright test",
|
||||||
|
"manifest:generate": "node scripts/generate-toolbox-manifest.mjs",
|
||||||
|
"manifest:check": "node scripts/generate-toolbox-manifest.mjs --check",
|
||||||
|
"release:prepare": "node scripts/prepare-release-files.mjs",
|
||||||
|
"toolbox:check": "toolbox-check dist",
|
||||||
|
"package:release": "node scripts/package-release.mjs",
|
||||||
|
"check": "npm run manifest:check && npm run typecheck && npm run lint && npm run format:check && npm run test && npm run build && npm run toolbox:check",
|
||||||
|
"release:artifact": "npm run check && npm run test:browser && npm run package:release -- --force"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@add-ideas/toolbox-contract": "0.2.3",
|
||||||
|
"@add-ideas/toolbox-helpers": "0.1.0",
|
||||||
|
"@add-ideas/toolbox-shell-react": "0.2.3",
|
||||||
|
"react": "19.2.8",
|
||||||
|
"react-dom": "19.2.8"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@add-ideas/toolbox-testkit": "0.2.3",
|
||||||
|
"@eslint/js": "10.0.1",
|
||||||
|
"@playwright/test": "1.62.1",
|
||||||
|
"@testing-library/jest-dom": "6.9.1",
|
||||||
|
"@testing-library/react": "16.3.2",
|
||||||
|
"@testing-library/user-event": "14.6.1",
|
||||||
|
"@types/node": "25.9.5",
|
||||||
|
"@types/react": "19.2.17",
|
||||||
|
"@types/react-dom": "19.2.5",
|
||||||
|
"@vitejs/plugin-react": "6.0.3",
|
||||||
|
"eslint": "10.7.0",
|
||||||
|
"eslint-plugin-react-hooks": "7.1.1",
|
||||||
|
"eslint-plugin-react-refresh": "0.5.2",
|
||||||
|
"globals": "17.7.0",
|
||||||
|
"jsdom": "29.1.1",
|
||||||
|
"prettier": "3.9.5",
|
||||||
|
"typescript": "6.0.3",
|
||||||
|
"typescript-eslint": "8.64.0",
|
||||||
|
"vite": "8.2.2",
|
||||||
|
"vitest": "4.1.11"
|
||||||
|
},
|
||||||
|
"packageManager": "npm@11.17.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { defineConfig, devices } from "@playwright/test";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: "./tests/browser",
|
||||||
|
fullyParallel: false,
|
||||||
|
workers: 1,
|
||||||
|
timeout: 120_000,
|
||||||
|
expect: { timeout: 10_000 },
|
||||||
|
reporter: [["list"]],
|
||||||
|
use: { baseURL: "http://127.0.0.1:4200", trace: "retain-on-failure" },
|
||||||
|
webServer: {
|
||||||
|
command: "npm run build && node scripts/serve-test.mjs",
|
||||||
|
url: "http://127.0.0.1:4200",
|
||||||
|
reuseExistingServer: !process.env.CI,
|
||||||
|
timeout: 180_000,
|
||||||
|
},
|
||||||
|
projects: [
|
||||||
|
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
|
||||||
|
{ name: "firefox", use: { ...devices["Desktop Firefox"] } },
|
||||||
|
],
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 0.1.0 - 2026-09-01
|
||||||
|
|
||||||
|
- Add bounded structure-aware JSON/XML and textual delta debugging
|
||||||
|
- Add literal, syntax, focused JSON Schema, isolated regex, and restricted local
|
||||||
|
XSLT failure predicates
|
||||||
|
- Add JSON Schema failure-signature preservation, cancellation, budgets,
|
||||||
|
progress, trace inspection, and deterministic case/report export
|
||||||
|
- Add Toolbox shell integration, offline PWA support, documentation, and
|
||||||
|
Chromium/Firefox coverage
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Run `npm ci`, `npm run check`, and `npm run test:browser` before proposing a change. Keep processing local, preserve explicit limits, and include fixtures for every parser boundary.
|
||||||
+674
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<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 General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Licences
|
||||||
|
|
||||||
|
The application is GPL-3.0-or-later. Generated release artifacts include an exact runtime dependency licence inventory in `npm-runtime-licenses.txt`.
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,51 @@
|
|||||||
|
# Minimize Tools
|
||||||
|
|
||||||
|
Reduce a failing input while repeatedly proving that the selected failure still
|
||||||
|
occurs. Minimize Tools is a local-first delta-debugging module in the add·ideas
|
||||||
|
Toolbox.
|
||||||
|
|
||||||
|
## v0.1.0 capabilities
|
||||||
|
|
||||||
|
- Minimize plain text by lines, lexical tokens, and Unicode code points
|
||||||
|
- Apply structure-aware reductions before textual delta debugging for bounded
|
||||||
|
JSON and XML inputs
|
||||||
|
- Preserve a literal marker, invalid JSON/XML state, an isolated regular
|
||||||
|
expression match or time threshold, a focused JSON Schema failure, a local
|
||||||
|
XSLT exception, or a marker in XSLT output
|
||||||
|
- Preserve the first JSON Schema failing path and rule by default, preventing a
|
||||||
|
reduction from silently changing to an easier unrelated violation
|
||||||
|
- Run regular expressions in a disposable same-origin worker with a hard safety
|
||||||
|
timeout; cancel any run and retain the last complete result
|
||||||
|
- Enforce explicit predicate-test and wall-time budgets and show every accepted
|
||||||
|
size reduction
|
||||||
|
- Export the minimized case and a deterministic report containing the predicate,
|
||||||
|
engine version, limits, and reduction trace
|
||||||
|
|
||||||
|
## Honest scope
|
||||||
|
|
||||||
|
The JSON Schema predicate implements a documented focused subset: common types,
|
||||||
|
properties, required/additional properties, items, enum/const, size, and numeric
|
||||||
|
bounds. Unsupported keywords fail closed; remote references and formats are not
|
||||||
|
silently approximated. The XSLT predicate uses the browser's XSLT 1.0 processor
|
||||||
|
when available and rejects imports, includes, href targets, DOCTYPE declarations,
|
||||||
|
and external-resource XPath functions. XSLT tests are additionally capped at 200.
|
||||||
|
|
||||||
|
Minimization finds a locally minimal case under the attempted transformations
|
||||||
|
and budget, not a mathematically globally shortest input. Regex timing depends on
|
||||||
|
the browser and device. Inputs are capped at 2 MiB, runs at 2,000 tests and 30
|
||||||
|
seconds, regex worker execution at one second, and stylesheets at 128 KiB.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm ci
|
||||||
|
npm run check
|
||||||
|
npm run test:browser
|
||||||
|
```
|
||||||
|
|
||||||
|
`npm run release:artifact` creates a deterministic release ZIP and SHA-256
|
||||||
|
sidecar after all checks pass.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GPL-3.0-or-later. See [LICENSE](LICENSE).
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Security
|
||||||
|
|
||||||
|
Please report vulnerabilities privately to the repository owner. Do not attach sensitive source files to public issues. Imported inputs are untrusted; parsers must remain bounded and must not execute active content or fetch external resources.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Corresponding source
|
||||||
|
|
||||||
|
The corresponding source for Minimize Tools 0.1.0 is available at:
|
||||||
|
|
||||||
|
https://git.add-ideas.de/lotobo/minimize-tools/src/tag/v0.1.0
|
||||||
|
|
||||||
|
Build with Node.js 22, npm 11, `npm ci`, and `npm run release:artifact`.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Third-party notices
|
||||||
|
|
||||||
|
Minimize Tools 0.1.0 directly depends on these runtime packages:
|
||||||
|
|
||||||
|
| Package | Pinned version | Declared licence |
|
||||||
|
| -------------------------------- | -------------: | ---------------- |
|
||||||
|
| `@add-ideas/toolbox-contract` | 0.2.3 | Apache-2.0 |
|
||||||
|
| `@add-ideas/toolbox-helpers` | 0.1.0 | GPL-3.0-or-later |
|
||||||
|
| `@add-ideas/toolbox-shell-react` | 0.2.3 | Apache-2.0 |
|
||||||
|
| `react` | 19.2.8 | MIT |
|
||||||
|
| `react-dom` | 19.2.8 | MIT |
|
||||||
|
|
||||||
|
This table covers direct production dependencies, not transitive packages or development tooling. During a release build, the exact non-development dependency tree and discovered licence texts are generated from the lockfile into `LICENSES/npm-runtime-licenses.txt` and included in the release ZIP. Copyright and licence terms remain with their respective authors.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Accessibility
|
||||||
|
|
||||||
|
All inputs, limits, presets, and actions use labelled native controls with
|
||||||
|
visible keyboard focus. Progress and errors use live text status rather than
|
||||||
|
colour alone. Source, predicate, and result regions follow document order and
|
||||||
|
stack on narrower screens; long source and trace content remains scrollable.
|
||||||
|
|
||||||
|
Light, dark, and system themes inherit the shared Toolbox shell. Reduced-motion
|
||||||
|
preferences disable transitions. Cancellation is keyboard reachable and the
|
||||||
|
last completed result remains available while a new run is active.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Architecture
|
||||||
|
|
||||||
|
The framework-independent engine applies a deterministic sequence of reductions:
|
||||||
|
normalization, structure-aware JSON/XML candidates, line chunks, lexical-token
|
||||||
|
chunks, and Unicode code-point chunks. Every smaller candidate must independently
|
||||||
|
satisfy the async predicate before it replaces the current result. Candidate
|
||||||
|
outcomes are memoized, accepted transitions are recorded, and an AbortSignal,
|
||||||
|
test budget, and deadline are checked throughout.
|
||||||
|
|
||||||
|
JSON candidates are parsed with depth/node/key limits. XML rejects DOCTYPE and
|
||||||
|
is manipulated as inert DOM nodes. The focused JSON Schema validator returns a
|
||||||
|
stable first-issue signature. Regex work runs in a disposable module worker; a
|
||||||
|
non-returning expression causes worker termination. Restricted XSLT evaluation
|
||||||
|
uses the browser API on the main thread, so it has smaller source/test limits and
|
||||||
|
explicitly rejects resource-loading constructs.
|
||||||
|
|
||||||
|
Limits are 2 MiB input, 2,000 predicate tests, 30 seconds per run, 100,000 JSON
|
||||||
|
nodes, 128 KiB XSLT, 200 XSLT tests, and at most one second of regex worker time.
|
||||||
|
The engine reports budget exhaustion instead of claiming a globally minimal
|
||||||
|
result.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Privacy and security
|
||||||
|
|
||||||
|
Selected files, predicates, intermediate candidates, and results remain in page
|
||||||
|
memory. There is no upload, telemetry, analytics, remote reference resolution,
|
||||||
|
external font, or account. The production policy restricts network connections
|
||||||
|
to the same origin and browser tests reject unexpected requests.
|
||||||
|
|
||||||
|
JSON and XML are inert data; dangerous JSON keys and XML document types are
|
||||||
|
rejected. Regular expressions execute in a same-origin worker that can be
|
||||||
|
terminated. XSLT is limited to a local, bounded stylesheet and rejects imports,
|
||||||
|
includes, hrefs, DOCTYPE, and known external-resource functions. Browser-native
|
||||||
|
XSLT is synchronous and cannot be pre-empted mid-call, so only trusted local
|
||||||
|
stylesheets should be tested despite those safeguards.
|
||||||
|
|
||||||
|
A reduced input demonstrates only the recorded predicate. It is not proof that
|
||||||
|
the original root cause, security impact, timing characteristic on another
|
||||||
|
machine, or standards conformance remains identical. Review the exported trace
|
||||||
|
and keep failure-signature preservation enabled where available.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="Minimize Tools"><path fill="#5b4ec4" d="M11 4h30l12 12v44H11z"/><path fill="#fff" opacity=".28" d="M41 4v14h12"/><path fill="#fff" d="M17 29h11v5h-5.4l7.2 7.2-3.6 3.6-7.2-7.2V43h-5V29zm30 0v14h-5v-5.4l-7.2 7.2-3.6-3.6 7.2-7.2H33v-5z"/></svg>
|
||||||
|
After Width: | Height: | Size: 325 B |
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "Minimize Tools",
|
||||||
|
"short_name": "Minimize",
|
||||||
|
"description": "Reduce failing inputs while preserving the failure locally.",
|
||||||
|
"start_url": "./",
|
||||||
|
"scope": "./",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "#f6f7fb",
|
||||||
|
"theme_color": "#29255f",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "./favicon.svg",
|
||||||
|
"sizes": "any",
|
||||||
|
"type": "image/svg+xml",
|
||||||
|
"purpose": "any maskable"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
const CACHE_PREFIX = "minimize-tools-shell-";
|
||||||
|
const CACHE_NAME = CACHE_PREFIX + "0.1.0";
|
||||||
|
const CORE = ["./", "./manifest.webmanifest", "./favicon.svg"];
|
||||||
|
self.addEventListener("install", (event) => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.open(CACHE_NAME).then(async (cache) => {
|
||||||
|
await cache.addAll(CORE);
|
||||||
|
const html = await (await fetch("./")).text();
|
||||||
|
const assets = [...html.matchAll(/(?:src|href)="(\.\/assets\/[^"]+)"/g)]
|
||||||
|
.map((match) => match[1])
|
||||||
|
.filter(Boolean);
|
||||||
|
await cache.addAll(assets);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
self.skipWaiting();
|
||||||
|
});
|
||||||
|
self.addEventListener("activate", (event) => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches
|
||||||
|
.keys()
|
||||||
|
.then((keys) =>
|
||||||
|
Promise.all(
|
||||||
|
keys
|
||||||
|
.filter((key) => key.startsWith(CACHE_PREFIX) && key !== CACHE_NAME)
|
||||||
|
.map((key) => caches.delete(key)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.then(() => self.clients.claim()),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
self.addEventListener("fetch", (event) => {
|
||||||
|
if (event.request.method !== "GET") return;
|
||||||
|
const url = new URL(event.request.url);
|
||||||
|
if (
|
||||||
|
url.origin !== self.location.origin ||
|
||||||
|
!url.pathname.startsWith(new URL(self.registration.scope).pathname)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
event.respondWith(
|
||||||
|
caches.match(event.request).then(
|
||||||
|
(cached) =>
|
||||||
|
cached ??
|
||||||
|
fetch(event.request).then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
|
const copy = response.clone();
|
||||||
|
void caches
|
||||||
|
.open(CACHE_NAME)
|
||||||
|
.then((cache) => cache.put(event.request, copy));
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://git.add-ideas.de/lotobo/toolbox-sdk/raw/branch/main/schemas/toolbox-app.v1.schema.json",
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "de.add-ideas.minimize-tools",
|
||||||
|
"name": "Minimize Tools",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Reduce failing inputs while preserving the failure locally.",
|
||||||
|
"entry": "./",
|
||||||
|
"icon": "./favicon.svg",
|
||||||
|
"categories": ["developer", "data", "testing"],
|
||||||
|
"tags": [
|
||||||
|
"minimize",
|
||||||
|
"delta-debugging",
|
||||||
|
"reproducer",
|
||||||
|
"json-schema",
|
||||||
|
"xslt",
|
||||||
|
"regex"
|
||||||
|
],
|
||||||
|
"integration": {
|
||||||
|
"contextVersion": 1,
|
||||||
|
"launchModes": ["navigate", "new-tab"],
|
||||||
|
"embedding": "unsupported"
|
||||||
|
},
|
||||||
|
"requirements": {
|
||||||
|
"secureContext": false,
|
||||||
|
"workers": true,
|
||||||
|
"indexedDb": false,
|
||||||
|
"crossOriginIsolated": false,
|
||||||
|
"topLevelContext": false
|
||||||
|
},
|
||||||
|
"privacy": {
|
||||||
|
"processing": "local",
|
||||||
|
"fileUploads": true,
|
||||||
|
"telemetry": false,
|
||||||
|
"label": "Inputs and predicates stay in this browser; nothing is uploaded."
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"repository": "https://git.add-ideas.de/lotobo/minimize-tools",
|
||||||
|
"license": "GPL-3.0-or-later"
|
||||||
|
},
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"id": "source",
|
||||||
|
"label": "Source",
|
||||||
|
"url": "https://git.add-ideas.de/lotobo/minimize-tools"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { readFile, writeFile } from "node:fs/promises";
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { format } from "prettier";
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||||
|
const sourcePath = path.join(root, "src/toolbox/manifest.source.json");
|
||||||
|
const outputPath = path.join(root, "public/toolbox-app.json");
|
||||||
|
const source = JSON.parse(await readFile(sourcePath, "utf8"));
|
||||||
|
const pkg = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
||||||
|
const versionSource = await readFile(path.join(root, "src/version.ts"), "utf8");
|
||||||
|
const appVersion = /^export const APP_VERSION = "([^"]+)";$/mu.exec(
|
||||||
|
versionSource,
|
||||||
|
)?.[1];
|
||||||
|
const repository = "https://git.add-ideas.de/lotobo/" + pkg.name;
|
||||||
|
if (source.version !== pkg.version || appVersion !== pkg.version)
|
||||||
|
throw new Error("Version identity drift");
|
||||||
|
if (
|
||||||
|
source.id !== "de.add-ideas." + pkg.name ||
|
||||||
|
source.source?.repository !== repository ||
|
||||||
|
source.source?.license !== "GPL-3.0-or-later"
|
||||||
|
)
|
||||||
|
throw new Error("Manifest source identity is invalid");
|
||||||
|
const serialized = await format(JSON.stringify(source), {
|
||||||
|
filepath: outputPath,
|
||||||
|
});
|
||||||
|
if (process.argv.includes("--check")) {
|
||||||
|
if ((await readFile(outputPath, "utf8").catch(() => "")) !== serialized)
|
||||||
|
throw new Error("public/toolbox-app.json is stale");
|
||||||
|
console.log("Toolbox manifest is synchronized");
|
||||||
|
} else {
|
||||||
|
await writeFile(outputPath, serialized);
|
||||||
|
console.log("Generated public/toolbox-app.json");
|
||||||
|
}
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { execFile } from "node:child_process";
|
||||||
|
import {
|
||||||
|
access,
|
||||||
|
chmod,
|
||||||
|
copyFile,
|
||||||
|
cp,
|
||||||
|
lstat,
|
||||||
|
mkdir,
|
||||||
|
mkdtemp,
|
||||||
|
readFile,
|
||||||
|
readdir,
|
||||||
|
rename,
|
||||||
|
rm,
|
||||||
|
utimes,
|
||||||
|
writeFile,
|
||||||
|
} from "node:fs/promises";
|
||||||
|
import os from "node:os";
|
||||||
|
import path from "node:path";
|
||||||
|
import { promisify } from "node:util";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
const execute = promisify(execFile);
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||||
|
const pkg = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
||||||
|
const argument = (name, fallback) => {
|
||||||
|
const index = process.argv.indexOf(name);
|
||||||
|
return index >= 0 ? process.argv[index + 1] : fallback;
|
||||||
|
};
|
||||||
|
const output = path.resolve(
|
||||||
|
root,
|
||||||
|
argument("--output", "release/" + pkg.name + "-" + pkg.version + ".zip"),
|
||||||
|
);
|
||||||
|
const checksumOutput = output + ".sha256";
|
||||||
|
const force = process.argv.includes("--force");
|
||||||
|
if (
|
||||||
|
path.extname(output).toLowerCase() !== ".zip" ||
|
||||||
|
output === root ||
|
||||||
|
output === path.parse(output).root
|
||||||
|
)
|
||||||
|
throw new Error("Unsafe release target");
|
||||||
|
const exists = (file) =>
|
||||||
|
access(file).then(
|
||||||
|
() => true,
|
||||||
|
() => false,
|
||||||
|
);
|
||||||
|
if (!force && ((await exists(output)) || (await exists(checksumOutput))))
|
||||||
|
throw new Error("Release output exists");
|
||||||
|
const input = path.join(root, "dist");
|
||||||
|
for (const name of [
|
||||||
|
"index.html",
|
||||||
|
"manifest.webmanifest",
|
||||||
|
"sw.js",
|
||||||
|
"toolbox-app.json",
|
||||||
|
"favicon.svg",
|
||||||
|
"README.md",
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"CONTRIBUTING.md",
|
||||||
|
"LICENSE",
|
||||||
|
"SECURITY.md",
|
||||||
|
"SOURCE.md",
|
||||||
|
"THIRD_PARTY_NOTICES.md",
|
||||||
|
"LICENSES/README.md",
|
||||||
|
"LICENSES/npm-runtime-licenses.txt",
|
||||||
|
"docs/ACCESSIBILITY.md",
|
||||||
|
"docs/ARCHITECTURE.md",
|
||||||
|
"docs/PRIVACY-SECURITY.md",
|
||||||
|
]) {
|
||||||
|
const details = await lstat(path.join(input, name)).catch(() => null);
|
||||||
|
if (!details?.isFile() || details.isSymbolicLink())
|
||||||
|
throw new Error("Missing release file: " + name);
|
||||||
|
}
|
||||||
|
const manifest = JSON.parse(
|
||||||
|
await readFile(path.join(input, "toolbox-app.json"), "utf8"),
|
||||||
|
);
|
||||||
|
const repository = "https://git.add-ideas.de/lotobo/" + pkg.name;
|
||||||
|
if (
|
||||||
|
manifest.id !== "de.add-ideas." + pkg.name ||
|
||||||
|
manifest.version !== pkg.version ||
|
||||||
|
manifest.entry !== "./" ||
|
||||||
|
manifest.icon !== "./favicon.svg" ||
|
||||||
|
manifest.source?.repository !== repository
|
||||||
|
)
|
||||||
|
throw new Error("Packaged manifest identity is invalid");
|
||||||
|
if (
|
||||||
|
/\b(?:src|href)=["']\//iu.test(
|
||||||
|
await readFile(path.join(input, "index.html"), "utf8"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
throw new Error("Root-absolute asset reference");
|
||||||
|
async function collect(directory, prefix = "") {
|
||||||
|
const files = [];
|
||||||
|
for (const entry of (await readdir(directory, { withFileTypes: true })).sort(
|
||||||
|
(a, b) => a.name.localeCompare(b.name),
|
||||||
|
)) {
|
||||||
|
const absolute = path.join(directory, entry.name);
|
||||||
|
const relative = prefix ? prefix + "/" + entry.name : entry.name;
|
||||||
|
if (entry.isSymbolicLink())
|
||||||
|
throw new Error("Symlink in release: " + relative);
|
||||||
|
if (entry.isDirectory()) files.push(...(await collect(absolute, relative)));
|
||||||
|
else if (entry.isFile()) files.push({ absolute, relative });
|
||||||
|
else throw new Error("Unsupported release entry: " + relative);
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
const sourceFiles = await collect(input);
|
||||||
|
for (const file of sourceFiles)
|
||||||
|
if (
|
||||||
|
file.relative.endsWith(".map") ||
|
||||||
|
/(?:^|\/)(?:\.env(?:\.|$)|id_rsa|id_ed25519|.*\.pem$|.*\.key$)/iu.test(
|
||||||
|
file.relative,
|
||||||
|
) ||
|
||||||
|
file.relative.split("/").includes("..")
|
||||||
|
)
|
||||||
|
throw new Error("Forbidden release entry: " + file.relative);
|
||||||
|
await mkdir(path.dirname(output), { recursive: true });
|
||||||
|
const stagingRoot = await mkdtemp(
|
||||||
|
path.join(os.tmpdir(), pkg.name + "-release-"),
|
||||||
|
);
|
||||||
|
const publicationRoot = await mkdtemp(
|
||||||
|
path.join(path.dirname(output), "." + pkg.name + "-publish-"),
|
||||||
|
);
|
||||||
|
const stagedTree = path.join(stagingRoot, "tree");
|
||||||
|
const stagedArchive = path.join(stagingRoot, path.basename(output));
|
||||||
|
try {
|
||||||
|
await cp(input, stagedTree, { recursive: true });
|
||||||
|
const timestamp = new Date("1980-01-01T00:00:00.000Z");
|
||||||
|
for (const file of await collect(stagedTree)) {
|
||||||
|
await chmod(file.absolute, 0o644);
|
||||||
|
await utimes(file.absolute, timestamp, timestamp);
|
||||||
|
}
|
||||||
|
await execute(
|
||||||
|
"zip",
|
||||||
|
[
|
||||||
|
"-X",
|
||||||
|
"-q",
|
||||||
|
"-9",
|
||||||
|
stagedArchive,
|
||||||
|
...sourceFiles.map((file) => file.relative),
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd: stagedTree,
|
||||||
|
env: { ...process.env, TZ: "UTC" },
|
||||||
|
maxBuffer: 1024 * 1024,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const archive = await readFile(stagedArchive);
|
||||||
|
const digest = createHash("sha256").update(archive).digest("hex");
|
||||||
|
const stagedChecksum = stagedArchive + ".sha256";
|
||||||
|
await writeFile(stagedChecksum, digest + " " + path.basename(output) + "\n");
|
||||||
|
const publicationArchive = path.join(publicationRoot, path.basename(output));
|
||||||
|
const publicationChecksum = publicationArchive + ".sha256";
|
||||||
|
await copyFile(stagedArchive, publicationArchive);
|
||||||
|
await copyFile(stagedChecksum, publicationChecksum);
|
||||||
|
if (force) {
|
||||||
|
await rm(output, { force: true });
|
||||||
|
await rm(checksumOutput, { force: true });
|
||||||
|
}
|
||||||
|
await rename(publicationArchive, output);
|
||||||
|
await rename(publicationChecksum, checksumOutput);
|
||||||
|
console.log("Created " + path.relative(root, output) + "\nSHA-256 " + digest);
|
||||||
|
} finally {
|
||||||
|
await rm(stagingRoot, { recursive: true, force: true });
|
||||||
|
await rm(publicationRoot, { recursive: true, force: true });
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { cp, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||||
|
const destination = path.join(root, "public");
|
||||||
|
for (const name of [
|
||||||
|
"LICENSE",
|
||||||
|
"README.md",
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"CONTRIBUTING.md",
|
||||||
|
"SECURITY.md",
|
||||||
|
"SOURCE.md",
|
||||||
|
"THIRD_PARTY_NOTICES.md",
|
||||||
|
]) {
|
||||||
|
await readFile(path.join(root, name));
|
||||||
|
await cp(path.join(root, name), path.join(destination, name));
|
||||||
|
}
|
||||||
|
for (const directory of ["LICENSES", "docs"]) {
|
||||||
|
const output = path.join(destination, directory);
|
||||||
|
await rm(output, { recursive: true, force: true });
|
||||||
|
await cp(path.join(root, directory), output, { recursive: true });
|
||||||
|
}
|
||||||
|
const lock = JSON.parse(
|
||||||
|
await readFile(path.join(root, "package-lock.json"), "utf8"),
|
||||||
|
);
|
||||||
|
const sections = [];
|
||||||
|
for (const [location, locked] of Object.entries(lock.packages ?? {}).sort(
|
||||||
|
([a], [b]) => a.localeCompare(b),
|
||||||
|
)) {
|
||||||
|
if (!location.includes("node_modules/") || locked.dev === true) continue;
|
||||||
|
const packageDirectory = path.join(root, location);
|
||||||
|
const details = JSON.parse(
|
||||||
|
await readFile(path.join(packageDirectory, "package.json"), "utf8"),
|
||||||
|
);
|
||||||
|
const candidates = (await readdir(packageDirectory))
|
||||||
|
.filter((name) => /^(?:licen[cs]e|copying|notice)(?:\.|$)/iu.test(name))
|
||||||
|
.sort();
|
||||||
|
const texts = [];
|
||||||
|
for (const candidate of candidates) {
|
||||||
|
try {
|
||||||
|
texts.push(
|
||||||
|
"--- " +
|
||||||
|
candidate +
|
||||||
|
" ---\n" +
|
||||||
|
(await readFile(path.join(packageDirectory, candidate), "utf8")),
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
/* directory */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sections.push(
|
||||||
|
"=".repeat(78) +
|
||||||
|
"\n" +
|
||||||
|
details.name +
|
||||||
|
"@" +
|
||||||
|
details.version +
|
||||||
|
"\nDeclared licence: " +
|
||||||
|
(details.license ?? locked.license ?? "See upstream") +
|
||||||
|
"\n" +
|
||||||
|
"=".repeat(78) +
|
||||||
|
"\n" +
|
||||||
|
(texts.join("\n\n") || "See upstream package metadata."),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await mkdir(path.join(destination, "LICENSES"), { recursive: true });
|
||||||
|
await writeFile(
|
||||||
|
path.join(destination, "LICENSES/npm-runtime-licenses.txt"),
|
||||||
|
sections.join("\n\n").trimEnd() + "\n",
|
||||||
|
);
|
||||||
|
console.log("Prepared release documentation");
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { createServer } from "node:http";
|
||||||
|
import { readFile, stat } from "node:fs/promises";
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
const root = path.resolve(
|
||||||
|
path.dirname(fileURLToPath(import.meta.url)),
|
||||||
|
"..",
|
||||||
|
"dist",
|
||||||
|
);
|
||||||
|
const prefix = "/deep/nested/minimize/";
|
||||||
|
const types = new Map([
|
||||||
|
[".css", "text/css; charset=utf-8"],
|
||||||
|
[".html", "text/html; charset=utf-8"],
|
||||||
|
[".js", "text/javascript; charset=utf-8"],
|
||||||
|
[".json", "application/json; charset=utf-8"],
|
||||||
|
[".webmanifest", "application/manifest+json; charset=utf-8"],
|
||||||
|
[".svg", "image/svg+xml"],
|
||||||
|
[".md", "text/markdown; charset=utf-8"],
|
||||||
|
[".txt", "text/plain; charset=utf-8"],
|
||||||
|
[".wasm", "application/wasm"],
|
||||||
|
[".png", "image/png"],
|
||||||
|
[".jpg", "image/jpeg"],
|
||||||
|
[".webp", "image/webp"],
|
||||||
|
]);
|
||||||
|
const headers = {
|
||||||
|
"Content-Security-Policy":
|
||||||
|
"default-src 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; form-action 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; media-src 'self' blob:; connect-src 'self'; worker-src 'self' blob:; manifest-src 'self'",
|
||||||
|
"Cross-Origin-Opener-Policy": "same-origin",
|
||||||
|
"Cross-Origin-Resource-Policy": "same-origin",
|
||||||
|
"Permissions-Policy":
|
||||||
|
"camera=(), microphone=(), geolocation=(), usb=(), payment=()",
|
||||||
|
"Referrer-Policy": "no-referrer",
|
||||||
|
"X-Content-Type-Options": "nosniff",
|
||||||
|
};
|
||||||
|
const server = createServer(async (request, response) => {
|
||||||
|
try {
|
||||||
|
const url = new URL(request.url ?? "/", "http://127.0.0.1");
|
||||||
|
const relative = decodeURIComponent(url.pathname).startsWith(prefix)
|
||||||
|
? decodeURIComponent(url.pathname).slice(prefix.length)
|
||||||
|
: decodeURIComponent(url.pathname).replace(/^\/+/, "");
|
||||||
|
const normalized = path.posix.normalize(relative || "index.html");
|
||||||
|
if (
|
||||||
|
normalized === ".." ||
|
||||||
|
normalized.startsWith("../") ||
|
||||||
|
path.isAbsolute(normalized)
|
||||||
|
) {
|
||||||
|
response.writeHead(400).end("Bad request");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let file = path.join(root, normalized);
|
||||||
|
if ((await stat(file).catch(() => null))?.isDirectory())
|
||||||
|
file = path.join(file, "index.html");
|
||||||
|
const content = await readFile(file);
|
||||||
|
response.writeHead(200, {
|
||||||
|
"Content-Type":
|
||||||
|
types.get(path.extname(file)) ?? "application/octet-stream",
|
||||||
|
"Cache-Control": "no-cache",
|
||||||
|
...headers,
|
||||||
|
});
|
||||||
|
response.end(content);
|
||||||
|
} catch {
|
||||||
|
response.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
||||||
|
response.end("Not found");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
server.listen(4200, "127.0.0.1", () => console.log("Test server ready"));
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
import { lazy, Suspense, useState } from "react";
|
||||||
|
import { AppShell } from "@add-ideas/toolbox-shell-react";
|
||||||
|
import "@add-ideas/toolbox-shell-react/styles.css";
|
||||||
|
import "./styles.css";
|
||||||
|
import { ErrorBoundary } from "./components/ErrorBoundary";
|
||||||
|
import { HelpDialog } from "./components/HelpDialog";
|
||||||
|
import { manifest } from "./toolbox/manifest";
|
||||||
|
|
||||||
|
const Workbench = lazy(async () => ({
|
||||||
|
default: (await import("./components/Workbench")).Workbench,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export function App() {
|
||||||
|
const [helpOpen, setHelpOpen] = useState(false);
|
||||||
|
return (
|
||||||
|
<ErrorBoundary>
|
||||||
|
<AppShell
|
||||||
|
app={manifest}
|
||||||
|
manifestUrl="./toolbox-app.json"
|
||||||
|
helpAction={{ onClick: () => setHelpOpen(true) }}
|
||||||
|
>
|
||||||
|
<Suspense
|
||||||
|
fallback={
|
||||||
|
<p className="loading" role="status">
|
||||||
|
Preparing Minimize Tools…
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Workbench />
|
||||||
|
</Suspense>
|
||||||
|
</AppShell>
|
||||||
|
<HelpDialog open={helpOpen} onClose={() => setHelpOpen(false)} />
|
||||||
|
</ErrorBoundary>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Component, type ErrorInfo, type ReactNode } from "react";
|
||||||
|
|
||||||
|
export class ErrorBoundary extends Component<
|
||||||
|
{ children: ReactNode },
|
||||||
|
{ error?: Error }
|
||||||
|
> {
|
||||||
|
state: { error?: Error } = {};
|
||||||
|
static getDerivedStateFromError(error: Error) {
|
||||||
|
return { error };
|
||||||
|
}
|
||||||
|
componentDidCatch(error: Error, info: ErrorInfo) {
|
||||||
|
console.error("Application failure", error, info);
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
if (this.state.error)
|
||||||
|
return (
|
||||||
|
<main className="fatal">
|
||||||
|
<h1>Minimize Tools could not continue</h1>
|
||||||
|
<p>{this.state.error.message}</p>
|
||||||
|
<button type="button" onClick={() => location.reload()}>
|
||||||
|
Reload
|
||||||
|
</button>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { useEffect, useRef } from "react";
|
||||||
|
|
||||||
|
export function HelpDialog({
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
}) {
|
||||||
|
const dialog = useRef<HTMLDialogElement>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
const node = dialog.current;
|
||||||
|
if (!node) return;
|
||||||
|
if (open && !node.open) node.showModal();
|
||||||
|
if (!open && node.open) node.close();
|
||||||
|
}, [open]);
|
||||||
|
return (
|
||||||
|
<dialog
|
||||||
|
ref={dialog}
|
||||||
|
className="help-dialog"
|
||||||
|
onClose={onClose}
|
||||||
|
onCancel={onClose}
|
||||||
|
aria-labelledby="help-title"
|
||||||
|
>
|
||||||
|
<div className="dialog-heading">
|
||||||
|
<div>
|
||||||
|
<p className="eyebrow">Local-first help</p>
|
||||||
|
<h2 id="help-title">About Minimize Tools</h2>
|
||||||
|
</div>
|
||||||
|
<button type="button" onClick={onClose} aria-label="Close help">
|
||||||
|
×
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
Repeatedly remove structure, lines, tokens, and characters while proving
|
||||||
|
that your selected failure predicate still holds.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Inputs and predicates stay on this device. Test and time budgets are
|
||||||
|
hard limits; regular expressions run in a disposable worker. A small
|
||||||
|
result proves only the chosen predicate, so preserve its failure
|
||||||
|
signature whenever the option is available.
|
||||||
|
</p>
|
||||||
|
</dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,596 @@
|
|||||||
|
import { useMemo, useRef, useState, type ChangeEvent } from "react";
|
||||||
|
import {
|
||||||
|
stableStringify,
|
||||||
|
triggerBlobDownload,
|
||||||
|
} from "@add-ideas/toolbox-helpers";
|
||||||
|
import {
|
||||||
|
byteLength,
|
||||||
|
minimizeInput,
|
||||||
|
type InputStructure,
|
||||||
|
type MinimizeProgress,
|
||||||
|
type MinimizeResult,
|
||||||
|
} from "../minimize/engine";
|
||||||
|
import {
|
||||||
|
createPredicate,
|
||||||
|
type PredicateKind,
|
||||||
|
type PredicateRecipe,
|
||||||
|
type RegexEvaluator,
|
||||||
|
type RegexOutcome,
|
||||||
|
} from "../minimize/predicates";
|
||||||
|
|
||||||
|
const JSON_SAMPLE = `{
|
||||||
|
"request": {
|
||||||
|
"id": 0,
|
||||||
|
"label": "keep the same failing constraint"
|
||||||
|
},
|
||||||
|
"unrelated": [1, 2, 3],
|
||||||
|
"debug": true
|
||||||
|
}`;
|
||||||
|
|
||||||
|
const JSON_SCHEMA = `{
|
||||||
|
"type": "object",
|
||||||
|
"required": ["request"],
|
||||||
|
"properties": {
|
||||||
|
"request": {
|
||||||
|
"type": "object",
|
||||||
|
"required": ["id"],
|
||||||
|
"properties": {
|
||||||
|
"id": { "type": "integer", "minimum": 1 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
const XML_SAMPLE = `<case>
|
||||||
|
<metadata removable="yes"><author>local</author></metadata>
|
||||||
|
<payload><message>BOOM</message><noise>discard me</noise></payload>
|
||||||
|
</case>`;
|
||||||
|
|
||||||
|
const XSLT_SAMPLE = `<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
<xsl:output method="text"/>
|
||||||
|
<xsl:template match="/">
|
||||||
|
<xsl:if test="//message = 'BOOM'">
|
||||||
|
<xsl:message terminate="yes">reproduced</xsl:message>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:text>ok</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>`;
|
||||||
|
|
||||||
|
interface WorkerReply {
|
||||||
|
id: number;
|
||||||
|
matched?: boolean;
|
||||||
|
elapsedMs?: number;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class RegexRunner {
|
||||||
|
private worker?: Worker;
|
||||||
|
private sequence = 0;
|
||||||
|
|
||||||
|
private open(): Worker {
|
||||||
|
this.worker ??= new Worker(
|
||||||
|
new URL("../minimize/regex.worker.ts", import.meta.url),
|
||||||
|
{ type: "module" },
|
||||||
|
);
|
||||||
|
return this.worker;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(): void {
|
||||||
|
this.worker?.terminate();
|
||||||
|
this.worker = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly evaluate: RegexEvaluator = (
|
||||||
|
candidate,
|
||||||
|
pattern,
|
||||||
|
flags,
|
||||||
|
thresholdMs,
|
||||||
|
signal,
|
||||||
|
) =>
|
||||||
|
new Promise<RegexOutcome>((resolve, reject) => {
|
||||||
|
if (signal.aborted) {
|
||||||
|
reject(new DOMException("Minimization was cancelled.", "AbortError"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const worker = this.open();
|
||||||
|
const id = ++this.sequence;
|
||||||
|
let settled = false;
|
||||||
|
const finish = (callback: () => void) => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
clearTimeout(timer);
|
||||||
|
signal.removeEventListener("abort", abort);
|
||||||
|
callback();
|
||||||
|
};
|
||||||
|
const abort = () => {
|
||||||
|
this.close();
|
||||||
|
finish(() =>
|
||||||
|
reject(new DOMException("Minimization was cancelled.", "AbortError")),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const safetyMs = Math.min(1_000, Math.max(100, thresholdMs * 4));
|
||||||
|
const timer = window.setTimeout(() => {
|
||||||
|
this.close();
|
||||||
|
finish(() =>
|
||||||
|
resolve({ matched: false, elapsedMs: thresholdMs, timedOut: true }),
|
||||||
|
);
|
||||||
|
}, safetyMs);
|
||||||
|
worker.onmessage = (event: MessageEvent<WorkerReply>) => {
|
||||||
|
if (event.data.id !== id) return;
|
||||||
|
finish(() => {
|
||||||
|
if (event.data.error) reject(new SyntaxError(event.data.error));
|
||||||
|
else
|
||||||
|
resolve({
|
||||||
|
matched: event.data.matched === true,
|
||||||
|
elapsedMs: event.data.elapsedMs ?? 0,
|
||||||
|
timedOut: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
worker.onerror = () => {
|
||||||
|
this.close();
|
||||||
|
finish(() => reject(new Error("The isolated regex worker failed.")));
|
||||||
|
};
|
||||||
|
signal.addEventListener("abort", abort, { once: true });
|
||||||
|
worker.postMessage({ id, candidate, pattern, flags });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function download(text: string, filename: string, mediaType: string) {
|
||||||
|
triggerBlobDownload(new Blob([text], { type: mediaType }), filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
function extension(structure: InputStructure): string {
|
||||||
|
return structure === "json" ? "json" : structure === "xml" ? "xml" : "txt";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Workbench() {
|
||||||
|
const [source, setSource] = useState(JSON_SAMPLE);
|
||||||
|
const [sourceName, setSourceName] = useState("schema-failure.json");
|
||||||
|
const [structure, setStructure] = useState<InputStructure>("json");
|
||||||
|
const [predicateKind, setPredicateKind] =
|
||||||
|
useState<PredicateKind>("json-schema-fails");
|
||||||
|
const [needle, setNeedle] = useState("BOOM");
|
||||||
|
const [pattern, setPattern] = useState("^(a+)+$");
|
||||||
|
const [flags, setFlags] = useState("u");
|
||||||
|
const [thresholdMs, setThresholdMs] = useState(25);
|
||||||
|
const [schema, setSchema] = useState(JSON_SCHEMA);
|
||||||
|
const [stylesheet, setStylesheet] = useState(XSLT_SAMPLE);
|
||||||
|
const [preserveSignature, setPreserveSignature] = useState(true);
|
||||||
|
const [maxTests, setMaxTests] = useState(500);
|
||||||
|
const [maxSeconds, setMaxSeconds] = useState(10);
|
||||||
|
const [result, setResult] = useState<MinimizeResult>();
|
||||||
|
const [resultRecipe, setResultRecipe] = useState<PredicateRecipe>();
|
||||||
|
const [resultLimits, setResultLimits] = useState<{
|
||||||
|
maxTests: number;
|
||||||
|
maxSeconds: number;
|
||||||
|
}>();
|
||||||
|
const [resultStructure, setResultStructure] =
|
||||||
|
useState<InputStructure>("text");
|
||||||
|
const [progress, setProgress] = useState<MinimizeProgress>();
|
||||||
|
const [running, setRunning] = useState(false);
|
||||||
|
const [error, setError] = useState<string>();
|
||||||
|
const controller = useRef<AbortController | undefined>(undefined);
|
||||||
|
const regexRunner = useRef<RegexRunner | undefined>(undefined);
|
||||||
|
|
||||||
|
const recipe: PredicateRecipe = {
|
||||||
|
kind: predicateKind,
|
||||||
|
needle,
|
||||||
|
pattern,
|
||||||
|
flags,
|
||||||
|
thresholdMs,
|
||||||
|
schema,
|
||||||
|
stylesheet,
|
||||||
|
preserveFailureSignature: preserveSignature,
|
||||||
|
};
|
||||||
|
|
||||||
|
const report = useMemo(
|
||||||
|
() =>
|
||||||
|
result
|
||||||
|
? `${stableStringify(
|
||||||
|
{
|
||||||
|
minimizer: result.version,
|
||||||
|
structure: resultStructure,
|
||||||
|
predicate: resultRecipe,
|
||||||
|
limits: resultLimits,
|
||||||
|
originalBytes: byteLength(result.original),
|
||||||
|
minimizedBytes: byteLength(result.minimized),
|
||||||
|
tests: result.tests,
|
||||||
|
accepted: result.accepted,
|
||||||
|
exhausted: result.exhausted,
|
||||||
|
steps: result.steps,
|
||||||
|
},
|
||||||
|
2,
|
||||||
|
{ maxTextChars: 2 * 1024 * 1024, maxDepth: 16, maxNodes: 20_000 },
|
||||||
|
)}\n`
|
||||||
|
: "",
|
||||||
|
[result, resultLimits, resultRecipe, resultStructure],
|
||||||
|
);
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
controller.current?.abort();
|
||||||
|
regexRunner.current?.close();
|
||||||
|
const nextController = new AbortController();
|
||||||
|
const runner = new RegexRunner();
|
||||||
|
controller.current = nextController;
|
||||||
|
regexRunner.current = runner;
|
||||||
|
setRunning(true);
|
||||||
|
setProgress(undefined);
|
||||||
|
setError(undefined);
|
||||||
|
try {
|
||||||
|
const predicate = createPredicate(recipe, runner.evaluate);
|
||||||
|
const next = await minimizeInput(
|
||||||
|
source,
|
||||||
|
{
|
||||||
|
structure,
|
||||||
|
maxTests:
|
||||||
|
predicateKind === "xslt-throws" ||
|
||||||
|
predicateKind === "xslt-output-contains"
|
||||||
|
? Math.min(maxTests, 200)
|
||||||
|
: maxTests,
|
||||||
|
maxSeconds,
|
||||||
|
},
|
||||||
|
predicate,
|
||||||
|
nextController.signal,
|
||||||
|
setProgress,
|
||||||
|
);
|
||||||
|
setResult(next);
|
||||||
|
setResultRecipe(structuredClone(recipe));
|
||||||
|
setResultLimits({
|
||||||
|
maxTests:
|
||||||
|
predicateKind === "xslt-throws" ||
|
||||||
|
predicateKind === "xslt-output-contains"
|
||||||
|
? Math.min(maxTests, 200)
|
||||||
|
: maxTests,
|
||||||
|
maxSeconds,
|
||||||
|
});
|
||||||
|
setResultStructure(structure);
|
||||||
|
} catch (reason) {
|
||||||
|
if (!(reason instanceof DOMException && reason.name === "AbortError"))
|
||||||
|
setError(
|
||||||
|
reason instanceof Error ? reason.message : "Minimization failed.",
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
runner.close();
|
||||||
|
if (controller.current === nextController) {
|
||||||
|
setRunning(false);
|
||||||
|
controller.current = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancel = () => controller.current?.abort();
|
||||||
|
|
||||||
|
const openFile = async (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const file = event.target.files?.[0];
|
||||||
|
event.target.value = "";
|
||||||
|
if (!file) return;
|
||||||
|
if (file.size > 2 * 1024 * 1024) {
|
||||||
|
setError("Input file exceeds 2 MiB.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSource(await file.text());
|
||||||
|
setSourceName(file.name);
|
||||||
|
setStructure(
|
||||||
|
file.name.toLowerCase().endsWith(".json")
|
||||||
|
? "json"
|
||||||
|
: file.name.toLowerCase().endsWith(".xml")
|
||||||
|
? "xml"
|
||||||
|
: "text",
|
||||||
|
);
|
||||||
|
setError(undefined);
|
||||||
|
};
|
||||||
|
|
||||||
|
const applyPreset = (name: "json" | "xml" | "regex") => {
|
||||||
|
if (name === "json") {
|
||||||
|
setSource(JSON_SAMPLE);
|
||||||
|
setSourceName("schema-failure.json");
|
||||||
|
setStructure("json");
|
||||||
|
setPredicateKind("json-schema-fails");
|
||||||
|
setSchema(JSON_SCHEMA);
|
||||||
|
} else if (name === "xml") {
|
||||||
|
setSource(XML_SAMPLE);
|
||||||
|
setSourceName("xslt-case.xml");
|
||||||
|
setStructure("xml");
|
||||||
|
setPredicateKind("xslt-throws");
|
||||||
|
setStylesheet(XSLT_SAMPLE);
|
||||||
|
} else {
|
||||||
|
setSource(`${"a".repeat(5_000)}!`);
|
||||||
|
setSourceName("regex-case.txt");
|
||||||
|
setStructure("text");
|
||||||
|
setPredicateKind("regex-slow");
|
||||||
|
setPattern("^(a+)+$");
|
||||||
|
setFlags("u");
|
||||||
|
setThresholdMs(25);
|
||||||
|
}
|
||||||
|
setError(undefined);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="workbench">
|
||||||
|
<section className="hero">
|
||||||
|
<div>
|
||||||
|
<p className="eyebrow">Failure-preserving delta debugging</p>
|
||||||
|
<h1>Minimize Tools</h1>
|
||||||
|
<p>
|
||||||
|
Reduce a local reproducer while repeatedly proving that the same
|
||||||
|
selected failure remains.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span className="privacy-pill">Bounded · cancellable · local</span>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="preset-row" aria-label="Example minimizations">
|
||||||
|
<button type="button" onClick={() => applyPreset("json")}>
|
||||||
|
JSON Schema failure
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={() => applyPreset("xml")}>
|
||||||
|
XSLT failure
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={() => applyPreset("regex")}>
|
||||||
|
Slow regex input
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="work-grid">
|
||||||
|
<article className="panel input-panel">
|
||||||
|
<div className="panel-heading">
|
||||||
|
<div>
|
||||||
|
<h2>Failing input</h2>
|
||||||
|
<p>
|
||||||
|
{sourceName} · {byteLength(source).toLocaleString()} bytes
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<label className="button file-button">
|
||||||
|
Open file
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
data-testid="source-file"
|
||||||
|
onChange={(event) => void openFile(event)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<label>
|
||||||
|
Structure
|
||||||
|
<select
|
||||||
|
value={structure}
|
||||||
|
onChange={(event) =>
|
||||||
|
setStructure(event.target.value as InputStructure)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<option value="text">Text / lines</option>
|
||||||
|
<option value="json">JSON</option>
|
||||||
|
<option value="xml">XML</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
aria-label="Failing input"
|
||||||
|
value={source}
|
||||||
|
onChange={(event) => setSource(event.target.value)}
|
||||||
|
rows={22}
|
||||||
|
spellCheck={false}
|
||||||
|
/>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article className="panel predicate-panel">
|
||||||
|
<div className="panel-heading">
|
||||||
|
<div>
|
||||||
|
<h2>Failure predicate</h2>
|
||||||
|
<p>The original must satisfy this before any reduction begins.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label>
|
||||||
|
Predicate
|
||||||
|
<select
|
||||||
|
aria-label="Failure predicate"
|
||||||
|
value={predicateKind}
|
||||||
|
onChange={(event) =>
|
||||||
|
setPredicateKind(event.target.value as PredicateKind)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<option value="contains">Input contains marker</option>
|
||||||
|
<option value="json-schema-fails">
|
||||||
|
Focused JSON Schema fails
|
||||||
|
</option>
|
||||||
|
<option value="invalid-json">Input remains invalid JSON</option>
|
||||||
|
<option value="invalid-xml">Input remains invalid XML</option>
|
||||||
|
<option value="regex-matches">Regex still matches</option>
|
||||||
|
<option value="regex-slow">Regex reaches time threshold</option>
|
||||||
|
<option value="xslt-throws">Safe local XSLT throws</option>
|
||||||
|
<option value="xslt-output-contains">
|
||||||
|
XSLT output contains marker
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
{predicateKind === "contains" ||
|
||||||
|
predicateKind === "xslt-output-contains" ? (
|
||||||
|
<label>
|
||||||
|
Marker
|
||||||
|
<input
|
||||||
|
value={needle}
|
||||||
|
onChange={(event) => setNeedle(event.target.value)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
) : null}
|
||||||
|
{predicateKind === "json-schema-fails" ? (
|
||||||
|
<>
|
||||||
|
<label className="check-row">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={preserveSignature}
|
||||||
|
onChange={(event) =>
|
||||||
|
setPreserveSignature(event.target.checked)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
Preserve the first failing path and rule
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Focused JSON Schema
|
||||||
|
<textarea
|
||||||
|
aria-label="JSON Schema"
|
||||||
|
value={schema}
|
||||||
|
onChange={(event) => setSchema(event.target.value)}
|
||||||
|
rows={14}
|
||||||
|
spellCheck={false}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
{predicateKind === "regex-matches" ||
|
||||||
|
predicateKind === "regex-slow" ? (
|
||||||
|
<div className="compact-grid">
|
||||||
|
<label>
|
||||||
|
Regular expression
|
||||||
|
<input
|
||||||
|
value={pattern}
|
||||||
|
onChange={(event) => setPattern(event.target.value)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Flags
|
||||||
|
<input
|
||||||
|
value={flags}
|
||||||
|
maxLength={8}
|
||||||
|
onChange={(event) => setFlags(event.target.value)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Slow threshold (ms; worker safety limit ≤ 1 s)
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min="1"
|
||||||
|
max="500"
|
||||||
|
value={thresholdMs}
|
||||||
|
onChange={(event) =>
|
||||||
|
setThresholdMs(Number(event.target.value))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
{predicateKind === "xslt-throws" ||
|
||||||
|
predicateKind === "xslt-output-contains" ? (
|
||||||
|
<label>
|
||||||
|
Local XSLT (imports, includes, external resource functions and
|
||||||
|
hrefs are rejected)
|
||||||
|
<textarea
|
||||||
|
aria-label="Local XSLT"
|
||||||
|
value={stylesheet}
|
||||||
|
onChange={(event) => setStylesheet(event.target.value)}
|
||||||
|
rows={14}
|
||||||
|
spellCheck={false}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
) : null}
|
||||||
|
<div className="compact-grid limits">
|
||||||
|
<label>
|
||||||
|
Maximum predicate tests
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min="1"
|
||||||
|
max="2000"
|
||||||
|
value={maxTests}
|
||||||
|
onChange={(event) => setMaxTests(Number(event.target.value))}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Maximum seconds
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min="1"
|
||||||
|
max="30"
|
||||||
|
value={maxSeconds}
|
||||||
|
onChange={(event) => setMaxSeconds(Number(event.target.value))}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="action-row">
|
||||||
|
<button
|
||||||
|
className="primary-button"
|
||||||
|
type="button"
|
||||||
|
disabled={running}
|
||||||
|
onClick={() => void run()}
|
||||||
|
>
|
||||||
|
{running ? "Minimizing…" : "Minimize reproducer"}
|
||||||
|
</button>
|
||||||
|
<button type="button" disabled={!running} onClick={cancel}>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{running && progress ? (
|
||||||
|
<p className="running" role="status">
|
||||||
|
{progress.stage} · {progress.tests} tests · {progress.accepted}{" "}
|
||||||
|
accepted · {byteLength(progress.candidate).toLocaleString()} bytes
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
{error ? (
|
||||||
|
<p className="error" role="alert">
|
||||||
|
{error} The previous result was retained.
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="panel result-panel" aria-live="polite">
|
||||||
|
<div className="panel-heading">
|
||||||
|
<div>
|
||||||
|
<h2>Smallest reproduced case</h2>
|
||||||
|
<p>
|
||||||
|
{result
|
||||||
|
? `${byteLength(result.original).toLocaleString()} → ${byteLength(result.minimized).toLocaleString()} bytes · ${result.tests} tests · ${result.accepted} accepted${result.exhausted ? " · budget reached" : ""}`
|
||||||
|
: "Run a verified predicate to produce a result."}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{result ? (
|
||||||
|
<div className="action-row">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() =>
|
||||||
|
download(
|
||||||
|
result.minimized,
|
||||||
|
`minimized.${extension(resultStructure)}`,
|
||||||
|
"text/plain;charset=utf-8",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Download case
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() =>
|
||||||
|
download(
|
||||||
|
report,
|
||||||
|
"minimization-report.json",
|
||||||
|
"application/json",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Download report
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
<textarea
|
||||||
|
aria-label="Minimized result"
|
||||||
|
readOnly
|
||||||
|
value={result?.minimized ?? ""}
|
||||||
|
rows={16}
|
||||||
|
spellCheck={false}
|
||||||
|
/>
|
||||||
|
{result ? (
|
||||||
|
<details>
|
||||||
|
<summary>Accepted reductions ({result.steps.length})</summary>
|
||||||
|
<ol className="step-list">
|
||||||
|
{result.steps.map((step, index) => (
|
||||||
|
<li key={`${step.test}-${index}`}>
|
||||||
|
{step.stage}: {step.beforeBytes.toLocaleString()} →{" "}
|
||||||
|
{step.afterBytes.toLocaleString()} bytes (test {step.test})
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
|
</details>
|
||||||
|
) : null}
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { StrictMode } from "react";
|
||||||
|
import { createRoot } from "react-dom/client";
|
||||||
|
import { App } from "./App";
|
||||||
|
|
||||||
|
createRoot(document.getElementById("root")!).render(
|
||||||
|
<StrictMode>
|
||||||
|
<App />
|
||||||
|
</StrictMode>,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ("serviceWorker" in navigator && import.meta.env.PROD) {
|
||||||
|
window.addEventListener("load", () => {
|
||||||
|
const url = new URL("./sw.js", document.baseURI);
|
||||||
|
void navigator.serviceWorker
|
||||||
|
.register(url, { scope: new URL("./", document.baseURI).pathname })
|
||||||
|
.catch(() => undefined);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,411 @@
|
|||||||
|
import { safeJsonParse } from "@add-ideas/toolbox-helpers";
|
||||||
|
|
||||||
|
export const MINIMIZER_VERSION = "structured-ddmin-v1";
|
||||||
|
export const MAX_INPUT_BYTES = 2 * 1024 * 1024;
|
||||||
|
export const MAX_TESTS = 2_000;
|
||||||
|
export const MAX_SECONDS = 30;
|
||||||
|
|
||||||
|
export type InputStructure = "text" | "json" | "xml";
|
||||||
|
|
||||||
|
export interface MinimizeOptions {
|
||||||
|
structure: InputStructure;
|
||||||
|
maxTests: number;
|
||||||
|
maxSeconds: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReductionStep {
|
||||||
|
stage: "normalize" | "structure" | "lines" | "tokens" | "characters";
|
||||||
|
beforeBytes: number;
|
||||||
|
afterBytes: number;
|
||||||
|
test: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MinimizeProgress {
|
||||||
|
candidate: string;
|
||||||
|
tests: number;
|
||||||
|
accepted: number;
|
||||||
|
stage: ReductionStep["stage"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MinimizeResult {
|
||||||
|
version: typeof MINIMIZER_VERSION;
|
||||||
|
original: string;
|
||||||
|
minimized: string;
|
||||||
|
tests: number;
|
||||||
|
accepted: number;
|
||||||
|
exhausted: boolean;
|
||||||
|
steps: ReductionStep[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FailurePredicate = (
|
||||||
|
candidate: string,
|
||||||
|
signal: AbortSignal,
|
||||||
|
) => boolean | Promise<boolean>;
|
||||||
|
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
|
export function byteLength(value: string): number {
|
||||||
|
return encoder.encode(value).byteLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function assertInput(value: string): string {
|
||||||
|
if (byteLength(value) > MAX_INPUT_BYTES)
|
||||||
|
throw new RangeError("Input exceeds the 2 MiB minimization limit.");
|
||||||
|
if (value.includes("\0")) throw new SyntaxError("Input contains NUL bytes.");
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function abortError(message = "Minimization was cancelled."): DOMException {
|
||||||
|
return new DOMException(message, "AbortError");
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertOptions(options: MinimizeOptions): void {
|
||||||
|
if (
|
||||||
|
!Number.isInteger(options.maxTests) ||
|
||||||
|
options.maxTests < 1 ||
|
||||||
|
options.maxTests > MAX_TESTS
|
||||||
|
)
|
||||||
|
throw new RangeError(
|
||||||
|
`Test budget must be 1–${MAX_TESTS.toLocaleString()}.`,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
!Number.isFinite(options.maxSeconds) ||
|
||||||
|
options.maxSeconds <= 0 ||
|
||||||
|
options.maxSeconds > MAX_SECONDS
|
||||||
|
)
|
||||||
|
throw new RangeError(
|
||||||
|
`Time budget must be above 0 and at most ${MAX_SECONDS} seconds.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function splitLines(value: string): string[] {
|
||||||
|
return value.match(/.*?(?:\r\n|\n|\r|$)/gu)?.filter(Boolean) ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function splitTokens(value: string): string[] {
|
||||||
|
return value.match(/\s+|[\p{L}\p{N}_]+|[^\s\p{L}\p{N}_]/gu) ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsonText(value: unknown): string {
|
||||||
|
return JSON.stringify(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function boundedJson(value: string): unknown {
|
||||||
|
return safeJsonParse(value, {
|
||||||
|
maxTextChars: MAX_INPUT_BYTES,
|
||||||
|
maxDepth: 64,
|
||||||
|
maxNodes: 100_000,
|
||||||
|
rejectDangerousKeys: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
type JsonPath = Array<string | number>;
|
||||||
|
|
||||||
|
function jsonAt(root: unknown, path: JsonPath): unknown {
|
||||||
|
let value = root;
|
||||||
|
for (const part of path)
|
||||||
|
value = Array.isArray(value)
|
||||||
|
? value[part as number]
|
||||||
|
: (value as Record<string, unknown>)[part as string];
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsonVariants(source: string): string[] {
|
||||||
|
let value: unknown;
|
||||||
|
try {
|
||||||
|
value = boundedJson(source);
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const paths: JsonPath[] = [[]];
|
||||||
|
for (
|
||||||
|
let cursor = 0;
|
||||||
|
cursor < paths.length && paths.length < 1_000;
|
||||||
|
cursor += 1
|
||||||
|
) {
|
||||||
|
const current = jsonAt(value, paths[cursor]!);
|
||||||
|
if (Array.isArray(current))
|
||||||
|
current.forEach((_item, index) => paths.push([...paths[cursor]!, index]));
|
||||||
|
else if (current !== null && typeof current === "object")
|
||||||
|
Object.keys(current).forEach((key) =>
|
||||||
|
paths.push([...paths[cursor]!, key]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const variants = new Set<string>();
|
||||||
|
const add = (next: unknown) => {
|
||||||
|
const text = jsonText(next);
|
||||||
|
if (byteLength(text) < byteLength(source)) variants.add(text);
|
||||||
|
};
|
||||||
|
for (const path of paths) {
|
||||||
|
if (variants.size >= 1_000) break;
|
||||||
|
const current = jsonAt(value, path);
|
||||||
|
if (Array.isArray(current) && current.length) {
|
||||||
|
for (let groups = 2; groups <= Math.min(current.length, 8); groups *= 2) {
|
||||||
|
const chunk = Math.ceil(current.length / groups);
|
||||||
|
for (let start = 0; start < current.length; start += chunk) {
|
||||||
|
const clone = structuredClone(value);
|
||||||
|
const target = jsonAt(clone, path) as unknown[];
|
||||||
|
target.splice(start, chunk);
|
||||||
|
add(clone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (current !== null && typeof current === "object") {
|
||||||
|
const keys = Object.keys(current);
|
||||||
|
for (let groups = 2; groups <= Math.min(keys.length, 8); groups *= 2) {
|
||||||
|
const chunk = Math.ceil(keys.length / groups);
|
||||||
|
for (let start = 0; start < keys.length; start += chunk) {
|
||||||
|
const clone = structuredClone(value);
|
||||||
|
const target = jsonAt(clone, path) as Record<string, unknown>;
|
||||||
|
keys.slice(start, start + chunk).forEach((key) => delete target[key]);
|
||||||
|
add(clone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (path.length) {
|
||||||
|
for (const replacement of [null, "", 0, false]) {
|
||||||
|
const clone = structuredClone(value);
|
||||||
|
const parent = jsonAt(clone, path.slice(0, -1));
|
||||||
|
const key = path.at(-1)!;
|
||||||
|
if (Array.isArray(parent)) parent[key as number] = replacement;
|
||||||
|
else (parent as Record<string, unknown>)[key as string] = replacement;
|
||||||
|
add(clone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [...variants].sort(
|
||||||
|
(left, right) => byteLength(left) - byteLength(right),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseXml(value: string): XMLDocument | undefined {
|
||||||
|
if (/<!DOCTYPE/iu.test(value)) return undefined;
|
||||||
|
const document = new DOMParser().parseFromString(value, "application/xml");
|
||||||
|
return document.querySelector("parsererror") ? undefined : document;
|
||||||
|
}
|
||||||
|
|
||||||
|
type NodePath = number[];
|
||||||
|
|
||||||
|
function nodeAt(root: Node, path: NodePath): Node | undefined {
|
||||||
|
let node: Node | undefined = root;
|
||||||
|
for (const index of path) node = node?.childNodes[index];
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
function xmlVariants(source: string): string[] {
|
||||||
|
const document = parseXml(source);
|
||||||
|
const root = document?.documentElement;
|
||||||
|
if (!root) return [];
|
||||||
|
const paths: NodePath[] = [[]];
|
||||||
|
for (
|
||||||
|
let cursor = 0;
|
||||||
|
cursor < paths.length && paths.length < 500;
|
||||||
|
cursor += 1
|
||||||
|
) {
|
||||||
|
const node = nodeAt(root, paths[cursor]!);
|
||||||
|
if (!node) continue;
|
||||||
|
for (let index = 0; index < node.childNodes.length; index += 1)
|
||||||
|
paths.push([...paths[cursor]!, index]);
|
||||||
|
}
|
||||||
|
const variants = new Set<string>();
|
||||||
|
const add = (clone: Element) => {
|
||||||
|
const text = new XMLSerializer().serializeToString(clone);
|
||||||
|
if (byteLength(text) < byteLength(source)) variants.add(text);
|
||||||
|
};
|
||||||
|
for (const path of paths) {
|
||||||
|
if (variants.size >= 1_000) break;
|
||||||
|
const original = nodeAt(root, path);
|
||||||
|
if (!original) continue;
|
||||||
|
if (path.length) {
|
||||||
|
const clone = root.cloneNode(true) as Element;
|
||||||
|
nodeAt(clone, path)?.parentNode?.removeChild(nodeAt(clone, path)!);
|
||||||
|
add(clone);
|
||||||
|
}
|
||||||
|
if (original.nodeType === Node.ELEMENT_NODE) {
|
||||||
|
const element = original as Element;
|
||||||
|
for (const attribute of Array.from(element.attributes)) {
|
||||||
|
const clone = root.cloneNode(true) as Element;
|
||||||
|
(nodeAt(clone, path) as Element | undefined)?.removeAttributeNS(
|
||||||
|
attribute.namespaceURI,
|
||||||
|
attribute.localName,
|
||||||
|
);
|
||||||
|
add(clone);
|
||||||
|
}
|
||||||
|
if (element.childNodes.length) {
|
||||||
|
const clone = root.cloneNode(true) as Element;
|
||||||
|
(nodeAt(clone, path) as Element).replaceChildren();
|
||||||
|
add(clone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [...variants].sort(
|
||||||
|
(left, right) => byteLength(left) - byteLength(right),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function minimizeInput(
|
||||||
|
input: string,
|
||||||
|
options: MinimizeOptions,
|
||||||
|
predicate: FailurePredicate,
|
||||||
|
signal: AbortSignal,
|
||||||
|
onProgress?: (progress: MinimizeProgress) => void,
|
||||||
|
): Promise<MinimizeResult> {
|
||||||
|
assertInput(input);
|
||||||
|
assertOptions(options);
|
||||||
|
const started = Date.now();
|
||||||
|
const deadline = started + options.maxSeconds * 1_000;
|
||||||
|
let tests = 0;
|
||||||
|
let accepted = 0;
|
||||||
|
let exhausted = false;
|
||||||
|
let current = input;
|
||||||
|
let stage: ReductionStep["stage"] = "normalize";
|
||||||
|
const steps: ReductionStep[] = [];
|
||||||
|
const cache = new Map<string, boolean>();
|
||||||
|
const preserveValidSyntax =
|
||||||
|
options.structure === "json"
|
||||||
|
? (() => {
|
||||||
|
try {
|
||||||
|
boundedJson(input);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
: options.structure === "xml"
|
||||||
|
? parseXml(input) !== undefined
|
||||||
|
: false;
|
||||||
|
|
||||||
|
const evaluate = async (candidate: string): Promise<boolean> => {
|
||||||
|
if (signal.aborted) throw abortError();
|
||||||
|
if (tests >= options.maxTests || Date.now() >= deadline) {
|
||||||
|
exhausted = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const cached = cache.get(candidate);
|
||||||
|
if (cached !== undefined) return cached;
|
||||||
|
tests += 1;
|
||||||
|
if (
|
||||||
|
preserveValidSyntax &&
|
||||||
|
((options.structure === "json" &&
|
||||||
|
(() => {
|
||||||
|
try {
|
||||||
|
boundedJson(candidate);
|
||||||
|
return false;
|
||||||
|
} catch {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})()) ||
|
||||||
|
(options.structure === "xml" && !parseXml(candidate)))
|
||||||
|
) {
|
||||||
|
cache.set(candidate, false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const result = await predicate(candidate, signal);
|
||||||
|
cache.set(candidate, result);
|
||||||
|
if (tests % 20 === 0)
|
||||||
|
onProgress?.({ candidate: current, tests, accepted, stage });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!(await evaluate(current)))
|
||||||
|
throw new TypeError(
|
||||||
|
"The original input does not satisfy the selected failure predicate.",
|
||||||
|
);
|
||||||
|
|
||||||
|
const accept = async (
|
||||||
|
candidate: string,
|
||||||
|
nextStage: ReductionStep["stage"],
|
||||||
|
): Promise<boolean> => {
|
||||||
|
if (byteLength(candidate) >= byteLength(current)) return false;
|
||||||
|
if (!(await evaluate(candidate))) return false;
|
||||||
|
const beforeBytes = byteLength(current);
|
||||||
|
current = candidate;
|
||||||
|
accepted += 1;
|
||||||
|
stage = nextStage;
|
||||||
|
steps.push({
|
||||||
|
stage,
|
||||||
|
beforeBytes,
|
||||||
|
afterBytes: byteLength(current),
|
||||||
|
test: tests,
|
||||||
|
});
|
||||||
|
onProgress?.({ candidate: current, tests, accepted, stage });
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.structure === "json") {
|
||||||
|
try {
|
||||||
|
await accept(jsonText(boundedJson(current)), "normalize");
|
||||||
|
} catch {
|
||||||
|
/* the selected predicate may intentionally target invalid JSON */
|
||||||
|
}
|
||||||
|
} else if (options.structure === "xml") {
|
||||||
|
const parsed = parseXml(current);
|
||||||
|
if (parsed)
|
||||||
|
await accept(
|
||||||
|
new XMLSerializer().serializeToString(parsed.documentElement),
|
||||||
|
"normalize",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const structuredVariants =
|
||||||
|
options.structure === "json"
|
||||||
|
? jsonVariants
|
||||||
|
: options.structure === "xml"
|
||||||
|
? xmlVariants
|
||||||
|
: undefined;
|
||||||
|
if (structuredVariants) {
|
||||||
|
stage = "structure";
|
||||||
|
let changed = true;
|
||||||
|
while (changed && !exhausted) {
|
||||||
|
changed = false;
|
||||||
|
for (const candidate of structuredVariants(current)) {
|
||||||
|
if (await accept(candidate, "structure")) {
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (exhausted) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const reduceUnits = async (
|
||||||
|
split: (value: string) => string[],
|
||||||
|
nextStage: ReductionStep["stage"],
|
||||||
|
) => {
|
||||||
|
stage = nextStage;
|
||||||
|
let units = split(current);
|
||||||
|
let granularity = 2;
|
||||||
|
while (units.length >= 2 && !exhausted) {
|
||||||
|
const chunk = Math.ceil(units.length / granularity);
|
||||||
|
let changed = false;
|
||||||
|
for (let start = 0; start < units.length; start += chunk) {
|
||||||
|
const kept = units.slice(0, start).concat(units.slice(start + chunk));
|
||||||
|
const candidate = kept.join("");
|
||||||
|
if (await accept(candidate, nextStage)) {
|
||||||
|
units = split(current);
|
||||||
|
granularity = Math.max(2, granularity - 1);
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (exhausted) break;
|
||||||
|
}
|
||||||
|
if (!changed) {
|
||||||
|
if (granularity >= units.length) break;
|
||||||
|
granularity = Math.min(units.length, granularity * 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await reduceUnits(splitLines, "lines");
|
||||||
|
await reduceUnits(splitTokens, "tokens");
|
||||||
|
await reduceUnits((value) => Array.from(value), "characters");
|
||||||
|
onProgress?.({ candidate: current, tests, accepted, stage });
|
||||||
|
return {
|
||||||
|
version: MINIMIZER_VERSION,
|
||||||
|
original: input,
|
||||||
|
minimized: current,
|
||||||
|
tests,
|
||||||
|
accepted,
|
||||||
|
exhausted,
|
||||||
|
steps,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,438 @@
|
|||||||
|
import { safeJsonParse } from "@add-ideas/toolbox-helpers";
|
||||||
|
import { MAX_INPUT_BYTES } from "./engine";
|
||||||
|
|
||||||
|
export type PredicateKind =
|
||||||
|
| "contains"
|
||||||
|
| "json-schema-fails"
|
||||||
|
| "invalid-json"
|
||||||
|
| "invalid-xml"
|
||||||
|
| "regex-matches"
|
||||||
|
| "regex-slow"
|
||||||
|
| "xslt-throws"
|
||||||
|
| "xslt-output-contains";
|
||||||
|
|
||||||
|
export interface PredicateRecipe {
|
||||||
|
kind: PredicateKind;
|
||||||
|
needle?: string;
|
||||||
|
pattern?: string;
|
||||||
|
flags?: string;
|
||||||
|
thresholdMs?: number;
|
||||||
|
schema?: string;
|
||||||
|
stylesheet?: string;
|
||||||
|
preserveFailureSignature?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegexOutcome {
|
||||||
|
matched: boolean;
|
||||||
|
elapsedMs: number;
|
||||||
|
timedOut: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RegexEvaluator = (
|
||||||
|
candidate: string,
|
||||||
|
pattern: string,
|
||||||
|
flags: string,
|
||||||
|
thresholdMs: number,
|
||||||
|
signal: AbortSignal,
|
||||||
|
) => Promise<RegexOutcome>;
|
||||||
|
|
||||||
|
type JsonSchema = boolean | Record<string, unknown>;
|
||||||
|
|
||||||
|
function object(value: unknown): Record<string, unknown> | undefined {
|
||||||
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
||||||
|
? (value as Record<string, unknown>)
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deepEqual(left: unknown, right: unknown): boolean {
|
||||||
|
if (Object.is(left, right)) return true;
|
||||||
|
if (Array.isArray(left) && Array.isArray(right))
|
||||||
|
return (
|
||||||
|
left.length === right.length &&
|
||||||
|
left.every((item, index) => deepEqual(item, right[index]))
|
||||||
|
);
|
||||||
|
const leftObject = object(left);
|
||||||
|
const rightObject = object(right);
|
||||||
|
if (!leftObject || !rightObject) return false;
|
||||||
|
const leftKeys = Object.keys(leftObject).sort();
|
||||||
|
const rightKeys = Object.keys(rightObject).sort();
|
||||||
|
return (
|
||||||
|
leftKeys.length === rightKeys.length &&
|
||||||
|
leftKeys.every(
|
||||||
|
(key, index) =>
|
||||||
|
key === rightKeys[index] &&
|
||||||
|
deepEqual(leftObject[key], rightObject[key]),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const SUPPORTED_SCHEMA_KEYS = new Set([
|
||||||
|
"$schema",
|
||||||
|
"$id",
|
||||||
|
"title",
|
||||||
|
"description",
|
||||||
|
"default",
|
||||||
|
"examples",
|
||||||
|
"type",
|
||||||
|
"enum",
|
||||||
|
"const",
|
||||||
|
"required",
|
||||||
|
"properties",
|
||||||
|
"additionalProperties",
|
||||||
|
"items",
|
||||||
|
"minItems",
|
||||||
|
"maxItems",
|
||||||
|
"minLength",
|
||||||
|
"maxLength",
|
||||||
|
"minimum",
|
||||||
|
"maximum",
|
||||||
|
"exclusiveMinimum",
|
||||||
|
"exclusiveMaximum",
|
||||||
|
"multipleOf",
|
||||||
|
]);
|
||||||
|
|
||||||
|
function assertSchema(
|
||||||
|
schema: unknown,
|
||||||
|
path = "$",
|
||||||
|
depth = 0,
|
||||||
|
): asserts schema is JsonSchema {
|
||||||
|
if (depth > 32) throw new RangeError("JSON Schema exceeds 32 levels.");
|
||||||
|
if (typeof schema === "boolean") return;
|
||||||
|
const value = object(schema);
|
||||||
|
if (!value)
|
||||||
|
throw new TypeError(`${path} must be a schema object or boolean.`);
|
||||||
|
for (const key of Object.keys(value))
|
||||||
|
if (!SUPPORTED_SCHEMA_KEYS.has(key))
|
||||||
|
throw new TypeError(`${path}: unsupported JSON Schema keyword ${key}.`);
|
||||||
|
if (value.type !== undefined) {
|
||||||
|
const types = Array.isArray(value.type) ? value.type : [value.type];
|
||||||
|
if (
|
||||||
|
!types.length ||
|
||||||
|
types.some(
|
||||||
|
(type) =>
|
||||||
|
typeof type !== "string" ||
|
||||||
|
![
|
||||||
|
"null",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"array",
|
||||||
|
"number",
|
||||||
|
"integer",
|
||||||
|
"string",
|
||||||
|
].includes(type),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
throw new TypeError(`${path}.type is unsupported.`);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
value.required !== undefined &&
|
||||||
|
(!Array.isArray(value.required) ||
|
||||||
|
value.required.some((item) => typeof item !== "string"))
|
||||||
|
)
|
||||||
|
throw new TypeError(`${path}.required must be an array of strings.`);
|
||||||
|
if (value.enum !== undefined && !Array.isArray(value.enum))
|
||||||
|
throw new TypeError(`${path}.enum must be an array.`);
|
||||||
|
if (
|
||||||
|
value.additionalProperties !== undefined &&
|
||||||
|
typeof value.additionalProperties !== "boolean"
|
||||||
|
)
|
||||||
|
throw new TypeError(
|
||||||
|
`${path}.additionalProperties must be true or false in the focused subset.`,
|
||||||
|
);
|
||||||
|
for (const key of [
|
||||||
|
"minimum",
|
||||||
|
"maximum",
|
||||||
|
"exclusiveMinimum",
|
||||||
|
"exclusiveMaximum",
|
||||||
|
"multipleOf",
|
||||||
|
] as const)
|
||||||
|
if (
|
||||||
|
value[key] !== undefined &&
|
||||||
|
(typeof value[key] !== "number" || !Number.isFinite(value[key]))
|
||||||
|
)
|
||||||
|
throw new TypeError(`${path}.${key} must be a finite number.`);
|
||||||
|
if (typeof value.multipleOf === "number" && value.multipleOf <= 0)
|
||||||
|
throw new TypeError(`${path}.multipleOf must be above zero.`);
|
||||||
|
for (const key of ["minItems", "maxItems", "minLength", "maxLength"] as const)
|
||||||
|
if (
|
||||||
|
value[key] !== undefined &&
|
||||||
|
(typeof value[key] !== "number" ||
|
||||||
|
!Number.isInteger(value[key]) ||
|
||||||
|
value[key] < 0)
|
||||||
|
)
|
||||||
|
throw new TypeError(`${path}.${key} must be a non-negative integer.`);
|
||||||
|
for (const [minimum, maximum] of [
|
||||||
|
["minItems", "maxItems"],
|
||||||
|
["minLength", "maxLength"],
|
||||||
|
["minimum", "maximum"],
|
||||||
|
] as const)
|
||||||
|
if (
|
||||||
|
typeof value[minimum] === "number" &&
|
||||||
|
typeof value[maximum] === "number" &&
|
||||||
|
value[minimum] > value[maximum]
|
||||||
|
)
|
||||||
|
throw new TypeError(`${path}.${minimum} exceeds ${maximum}.`);
|
||||||
|
if (value.properties !== undefined) {
|
||||||
|
const properties = object(value.properties);
|
||||||
|
if (!properties)
|
||||||
|
throw new TypeError(`${path}.properties must be an object.`);
|
||||||
|
for (const [key, child] of Object.entries(properties))
|
||||||
|
assertSchema(child, `${path}.properties.${key}`, depth + 1);
|
||||||
|
}
|
||||||
|
if (value.items !== undefined)
|
||||||
|
assertSchema(value.items, `${path}.items`, depth + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesType(value: unknown, type: string): boolean {
|
||||||
|
if (type === "null") return value === null;
|
||||||
|
if (type === "array") return Array.isArray(value);
|
||||||
|
if (type === "object") return object(value) !== undefined;
|
||||||
|
if (type === "integer")
|
||||||
|
return typeof value === "number" && Number.isInteger(value);
|
||||||
|
return typeof value === type;
|
||||||
|
}
|
||||||
|
|
||||||
|
function firstIssue(
|
||||||
|
value: unknown,
|
||||||
|
schema: JsonSchema,
|
||||||
|
path = "$",
|
||||||
|
depth = 0,
|
||||||
|
): string | undefined {
|
||||||
|
if (typeof schema === "boolean")
|
||||||
|
return schema ? undefined : `${path}:false-schema`;
|
||||||
|
if (depth > 64) return `${path}:depth`;
|
||||||
|
if (schema.type !== undefined) {
|
||||||
|
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
||||||
|
if (!types.some((type) => matchesType(value, type as string)))
|
||||||
|
return `${path}:type`;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
Array.isArray(schema.enum) &&
|
||||||
|
!schema.enum.some((item) => deepEqual(item, value))
|
||||||
|
)
|
||||||
|
return `${path}:enum`;
|
||||||
|
if (Object.hasOwn(schema, "const") && !deepEqual(schema.const, value))
|
||||||
|
return `${path}:const`;
|
||||||
|
if (typeof value === "string") {
|
||||||
|
if (
|
||||||
|
typeof schema.minLength === "number" &&
|
||||||
|
Array.from(value).length < schema.minLength
|
||||||
|
)
|
||||||
|
return `${path}:minLength`;
|
||||||
|
if (
|
||||||
|
typeof schema.maxLength === "number" &&
|
||||||
|
Array.from(value).length > schema.maxLength
|
||||||
|
)
|
||||||
|
return `${path}:maxLength`;
|
||||||
|
}
|
||||||
|
if (typeof value === "number" && Number.isFinite(value)) {
|
||||||
|
if (typeof schema.minimum === "number" && value < schema.minimum)
|
||||||
|
return `${path}:minimum`;
|
||||||
|
if (typeof schema.maximum === "number" && value > schema.maximum)
|
||||||
|
return `${path}:maximum`;
|
||||||
|
if (
|
||||||
|
typeof schema.exclusiveMinimum === "number" &&
|
||||||
|
value <= schema.exclusiveMinimum
|
||||||
|
)
|
||||||
|
return `${path}:exclusiveMinimum`;
|
||||||
|
if (
|
||||||
|
typeof schema.exclusiveMaximum === "number" &&
|
||||||
|
value >= schema.exclusiveMaximum
|
||||||
|
)
|
||||||
|
return `${path}:exclusiveMaximum`;
|
||||||
|
if (
|
||||||
|
typeof schema.multipleOf === "number" &&
|
||||||
|
(schema.multipleOf <= 0 ||
|
||||||
|
Math.abs(
|
||||||
|
value / schema.multipleOf - Math.round(value / schema.multipleOf),
|
||||||
|
) > 1e-9)
|
||||||
|
)
|
||||||
|
return `${path}:multipleOf`;
|
||||||
|
}
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
if (typeof schema.minItems === "number" && value.length < schema.minItems)
|
||||||
|
return `${path}:minItems`;
|
||||||
|
if (typeof schema.maxItems === "number" && value.length > schema.maxItems)
|
||||||
|
return `${path}:maxItems`;
|
||||||
|
if (schema.items !== undefined)
|
||||||
|
for (let index = 0; index < value.length; index += 1) {
|
||||||
|
const issue = firstIssue(
|
||||||
|
value[index],
|
||||||
|
schema.items as JsonSchema,
|
||||||
|
`${path}[${index}]`,
|
||||||
|
depth + 1,
|
||||||
|
);
|
||||||
|
if (issue) return issue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const record = object(value);
|
||||||
|
if (record) {
|
||||||
|
const required = Array.isArray(schema.required) ? schema.required : [];
|
||||||
|
const missing = required.find(
|
||||||
|
(key) => !Object.hasOwn(record, key as string),
|
||||||
|
);
|
||||||
|
if (missing !== undefined) return `${path}:required:${String(missing)}`;
|
||||||
|
const properties = object(schema.properties) ?? {};
|
||||||
|
for (const [key, child] of Object.entries(properties))
|
||||||
|
if (Object.hasOwn(record, key)) {
|
||||||
|
const issue = firstIssue(
|
||||||
|
record[key],
|
||||||
|
child as JsonSchema,
|
||||||
|
`${path}.${key}`,
|
||||||
|
depth + 1,
|
||||||
|
);
|
||||||
|
if (issue) return issue;
|
||||||
|
}
|
||||||
|
if (schema.additionalProperties === false) {
|
||||||
|
const extra = Object.keys(record).find(
|
||||||
|
(key) => !Object.hasOwn(properties, key),
|
||||||
|
);
|
||||||
|
if (extra !== undefined) return `${path}:additionalProperties:${extra}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseJson(value: string): unknown {
|
||||||
|
return safeJsonParse(value, {
|
||||||
|
maxTextChars: MAX_INPUT_BYTES,
|
||||||
|
maxDepth: 64,
|
||||||
|
maxNodes: 100_000,
|
||||||
|
rejectDangerousKeys: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseXml(value: string): XMLDocument | undefined {
|
||||||
|
if (/<!DOCTYPE/iu.test(value)) return undefined;
|
||||||
|
const document = new DOMParser().parseFromString(value, "application/xml");
|
||||||
|
return document.querySelector("parsererror") ? undefined : document;
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertSafeStylesheet(source: string): XMLDocument {
|
||||||
|
if (new TextEncoder().encode(source).byteLength > 128 * 1024)
|
||||||
|
throw new RangeError("XSLT is limited to 128 KiB.");
|
||||||
|
const document = parseXml(source);
|
||||||
|
if (!document)
|
||||||
|
throw new SyntaxError("XSLT is not well-formed XML or contains a DOCTYPE.");
|
||||||
|
const root = document.documentElement;
|
||||||
|
if (
|
||||||
|
root.namespaceURI !== "http://www.w3.org/1999/XSL/Transform" ||
|
||||||
|
!["stylesheet", "transform"].includes(root.localName)
|
||||||
|
)
|
||||||
|
throw new TypeError(
|
||||||
|
"The stylesheet root must be xsl:stylesheet or xsl:transform.",
|
||||||
|
);
|
||||||
|
for (const element of Array.from(
|
||||||
|
document.getElementsByTagNameNS(
|
||||||
|
"http://www.w3.org/1999/XSL/Transform",
|
||||||
|
"*",
|
||||||
|
),
|
||||||
|
)) {
|
||||||
|
if (["include", "import"].includes(element.localName))
|
||||||
|
throw new TypeError("xsl:include and xsl:import are disabled.");
|
||||||
|
for (const attribute of Array.from(element.attributes)) {
|
||||||
|
if (attribute.localName === "href")
|
||||||
|
throw new TypeError("External stylesheet/output hrefs are disabled.");
|
||||||
|
if (
|
||||||
|
/\b(?:document|unparsed-text|collection)\s*\(/iu.test(attribute.value)
|
||||||
|
)
|
||||||
|
throw new TypeError("External-resource XPath functions are disabled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
function xsltOutput(
|
||||||
|
xml: string,
|
||||||
|
stylesheet: XMLDocument,
|
||||||
|
): { threw: boolean; output: string } {
|
||||||
|
const document = parseXml(xml);
|
||||||
|
if (!document) return { threw: false, output: "" };
|
||||||
|
if (typeof XSLTProcessor === "undefined")
|
||||||
|
throw new TypeError("This browser does not provide the XSLTProcessor API.");
|
||||||
|
try {
|
||||||
|
const processor = new XSLTProcessor();
|
||||||
|
processor.importStylesheet(stylesheet);
|
||||||
|
const result = processor.transformToDocument(document);
|
||||||
|
return {
|
||||||
|
threw: false,
|
||||||
|
output: new XMLSerializer().serializeToString(result),
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return { threw: true, output: "" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createPredicate(
|
||||||
|
recipe: PredicateRecipe,
|
||||||
|
evaluateRegex: RegexEvaluator,
|
||||||
|
): (candidate: string, signal: AbortSignal) => Promise<boolean> {
|
||||||
|
if (recipe.kind === "contains") {
|
||||||
|
if (!recipe.needle) throw new TypeError("A non-empty marker is required.");
|
||||||
|
return async (candidate) => candidate.includes(recipe.needle!);
|
||||||
|
}
|
||||||
|
if (recipe.kind === "invalid-json")
|
||||||
|
return async (candidate) => {
|
||||||
|
try {
|
||||||
|
parseJson(candidate);
|
||||||
|
return false;
|
||||||
|
} catch {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (recipe.kind === "invalid-xml")
|
||||||
|
return async (candidate) => !parseXml(candidate);
|
||||||
|
if (recipe.kind === "json-schema-fails") {
|
||||||
|
if (!recipe.schema)
|
||||||
|
throw new TypeError("A focused JSON Schema is required.");
|
||||||
|
const schema = parseJson(recipe.schema);
|
||||||
|
assertSchema(schema);
|
||||||
|
let baselineIssue: string | undefined;
|
||||||
|
return async (candidate) => {
|
||||||
|
try {
|
||||||
|
const issue = firstIssue(parseJson(candidate), schema);
|
||||||
|
if (!issue) return false;
|
||||||
|
if (recipe.preserveFailureSignature !== false) {
|
||||||
|
baselineIssue ??= issue;
|
||||||
|
return issue === baselineIssue;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (recipe.kind === "regex-matches" || recipe.kind === "regex-slow") {
|
||||||
|
if (!recipe.pattern)
|
||||||
|
throw new TypeError("A regular expression is required.");
|
||||||
|
const flags = recipe.flags ?? "u";
|
||||||
|
if (/[^dgimsuvy]/u.test(flags) || new Set(flags).size !== flags.length)
|
||||||
|
throw new TypeError(
|
||||||
|
"Regular-expression flags are invalid or duplicated.",
|
||||||
|
);
|
||||||
|
const threshold = Math.max(1, Math.min(500, recipe.thresholdMs ?? 25));
|
||||||
|
return async (candidate, signal) => {
|
||||||
|
const result = await evaluateRegex(
|
||||||
|
candidate,
|
||||||
|
recipe.pattern!,
|
||||||
|
flags,
|
||||||
|
threshold,
|
||||||
|
signal,
|
||||||
|
);
|
||||||
|
return recipe.kind === "regex-matches"
|
||||||
|
? !result.timedOut && result.matched
|
||||||
|
: result.timedOut || result.elapsedMs >= threshold;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!recipe.stylesheet)
|
||||||
|
throw new TypeError("A local XSLT stylesheet is required.");
|
||||||
|
const stylesheet = assertSafeStylesheet(recipe.stylesheet);
|
||||||
|
if (recipe.kind === "xslt-output-contains" && !recipe.needle)
|
||||||
|
throw new TypeError("An XSLT output marker is required.");
|
||||||
|
return async (candidate) => {
|
||||||
|
const result = xsltOutput(candidate, stylesheet);
|
||||||
|
return recipe.kind === "xslt-throws"
|
||||||
|
? result.threw
|
||||||
|
: !result.threw && result.output.includes(recipe.needle!);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/// <reference lib="webworker" />
|
||||||
|
|
||||||
|
interface Request {
|
||||||
|
id: number;
|
||||||
|
candidate: string;
|
||||||
|
pattern: string;
|
||||||
|
flags: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.onmessage = (event: MessageEvent<Request>) => {
|
||||||
|
const { id, candidate, pattern, flags } = event.data;
|
||||||
|
try {
|
||||||
|
const expression = new RegExp(pattern, flags);
|
||||||
|
const started = performance.now();
|
||||||
|
const matched = expression.test(candidate);
|
||||||
|
self.postMessage({
|
||||||
|
id,
|
||||||
|
matched,
|
||||||
|
elapsedMs: performance.now() - started,
|
||||||
|
});
|
||||||
|
} catch (reason) {
|
||||||
|
self.postMessage({
|
||||||
|
id,
|
||||||
|
error:
|
||||||
|
reason instanceof Error ? reason.message : "Regex evaluation failed.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export {};
|
||||||
+594
@@ -0,0 +1,594 @@
|
|||||||
|
:root {
|
||||||
|
font-family:
|
||||||
|
Inter,
|
||||||
|
ui-sans-serif,
|
||||||
|
system-ui,
|
||||||
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
"Segoe UI",
|
||||||
|
sans-serif;
|
||||||
|
color: #242233;
|
||||||
|
background: #f3f4f8;
|
||||||
|
font-synthesis: none;
|
||||||
|
--surface: #fff;
|
||||||
|
--surface-muted: #f3f1fa;
|
||||||
|
--line: #d8d6e5;
|
||||||
|
--ink-muted: #66637a;
|
||||||
|
--accent: #5b4ec4;
|
||||||
|
--accent-dark: #4336a4;
|
||||||
|
--danger: #a5263d;
|
||||||
|
--warning: #8a5700;
|
||||||
|
--success: #187148;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-toolbox-theme="dark"] {
|
||||||
|
color: #f0eff8;
|
||||||
|
background: #15141b;
|
||||||
|
--surface: #211f29;
|
||||||
|
--surface-muted: #2a2735;
|
||||||
|
--line: #454153;
|
||||||
|
--ink-muted: #b9b5c8;
|
||||||
|
--accent: #a99cff;
|
||||||
|
--accent-dark: #c0b7ff;
|
||||||
|
--danger: #ff91a2;
|
||||||
|
--warning: #ffd078;
|
||||||
|
--success: #78d7a9;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not([data-toolbox-theme="light"]) {
|
||||||
|
color: #f0eff8;
|
||||||
|
background: #15141b;
|
||||||
|
--surface: #211f29;
|
||||||
|
--surface-muted: #2a2735;
|
||||||
|
--line: #454153;
|
||||||
|
--ink-muted: #b9b5c8;
|
||||||
|
--accent: #a99cff;
|
||||||
|
--accent-dark: #c0b7ff;
|
||||||
|
--danger: #ff91a2;
|
||||||
|
--warning: #ffd078;
|
||||||
|
--success: #78d7a9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
min-width: 320px;
|
||||||
|
min-height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background: inherit;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
color: inherit;
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
.button,
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 0.72rem;
|
||||||
|
background: var(--surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
.button {
|
||||||
|
min-height: 2.65rem;
|
||||||
|
padding: 0.58rem 0.9rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 750;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover,
|
||||||
|
.button:hover {
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.55;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:focus-visible,
|
||||||
|
input:focus-visible,
|
||||||
|
select:focus-visible,
|
||||||
|
textarea:focus-visible,
|
||||||
|
.button:focus-within {
|
||||||
|
outline: 3px solid color-mix(in srgb, var(--accent) 36%, transparent);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 2.55rem;
|
||||||
|
padding: 0.55rem 0.65rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
resize: vertical;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||||
|
font-size: 0.84rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
tab-size: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workbench {
|
||||||
|
width: min(100%, 90rem);
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 1.4rem clamp(0.75rem, 2.5vw, 2rem) 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero,
|
||||||
|
.panel-heading,
|
||||||
|
.source-grid,
|
||||||
|
.option-grid,
|
||||||
|
.tabs,
|
||||||
|
.workspace-grid,
|
||||||
|
.range-inputs {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1.2rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
p {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin-bottom: 0.35rem;
|
||||||
|
font-size: clamp(1.85rem, 4vw, 3rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-size: 1.16rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero > div > p:last-child {
|
||||||
|
max-width: 52rem;
|
||||||
|
margin-bottom: 0;
|
||||||
|
color: var(--ink-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.eyebrow {
|
||||||
|
margin-bottom: 0.28rem;
|
||||||
|
color: var(--accent-dark);
|
||||||
|
font-size: 0.74rem;
|
||||||
|
font-weight: 850;
|
||||||
|
letter-spacing: 0.09em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.privacy-pill,
|
||||||
|
.count-pill {
|
||||||
|
flex: none;
|
||||||
|
border: 1px solid color-mix(in srgb, var(--success) 48%, var(--line));
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 0.48rem 0.72rem;
|
||||||
|
color: var(--success);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
margin-bottom: 0.85rem;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 1rem;
|
||||||
|
background: var(--surface);
|
||||||
|
box-shadow: 0 0.45rem 1.4rem color-mix(in srgb, #151126 7%, transparent);
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-heading {
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.85rem;
|
||||||
|
margin-bottom: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-heading p {
|
||||||
|
margin: 0.2rem 0 0;
|
||||||
|
color: var(--ink-muted);
|
||||||
|
font-size: 0.88rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-button {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-button input {
|
||||||
|
position: absolute;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
overflow: hidden;
|
||||||
|
clip: rect(0 0 0 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-grid,
|
||||||
|
.option-grid {
|
||||||
|
align-items: end;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.65rem;
|
||||||
|
margin-bottom: 0.72rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-grid label,
|
||||||
|
.option-grid label,
|
||||||
|
.panel-heading label {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.28rem;
|
||||||
|
min-width: 10rem;
|
||||||
|
color: var(--ink-muted);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 750;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-grid label {
|
||||||
|
flex: 1 1 14rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option-grid label {
|
||||||
|
flex: 1 1 10rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-button {
|
||||||
|
border-color: var(--accent);
|
||||||
|
background: var(--accent);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-toolbox-theme="dark"] .primary-button {
|
||||||
|
color: #17131f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
gap: 0.35rem;
|
||||||
|
overflow-x: auto;
|
||||||
|
margin: 0 0 0.85rem;
|
||||||
|
padding: 0.1rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs button {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs button[aria-pressed="true"] {
|
||||||
|
border-color: var(--accent);
|
||||||
|
background: var(--surface-muted);
|
||||||
|
color: var(--accent-dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-grid {
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-grid > * {
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1 1 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-scroll {
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-scroll:focus-visible {
|
||||||
|
outline: 3px solid color-mix(in srgb, var(--accent) 36%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 0.84rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
padding: 0.55rem;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1;
|
||||||
|
background: var(--surface-muted);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody tr:last-child > * {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-table {
|
||||||
|
min-width: 70rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-table input,
|
||||||
|
.field-table select {
|
||||||
|
min-width: 8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flag-cell label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.35rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flag-cell label + label {
|
||||||
|
margin-top: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flag-cell input {
|
||||||
|
width: auto;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.range-inputs {
|
||||||
|
gap: 0.35rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.range-inputs input {
|
||||||
|
min-width: 6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-button {
|
||||||
|
min-height: 2.3rem;
|
||||||
|
padding: 0.4rem 0.62rem;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.danger {
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.records {
|
||||||
|
max-height: 42rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.records td {
|
||||||
|
max-width: 18rem;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.export-panel textarea {
|
||||||
|
min-height: 30rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.violation-list {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
|
||||||
|
gap: 0.55rem;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.violation-list li {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.7rem;
|
||||||
|
border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
|
||||||
|
border-radius: 0.7rem;
|
||||||
|
padding: 0.58rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.violation-list strong {
|
||||||
|
color: var(--danger);
|
||||||
|
font-size: 0.78rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning,
|
||||||
|
.error,
|
||||||
|
.success,
|
||||||
|
.empty {
|
||||||
|
margin: 0.65rem 0 0;
|
||||||
|
font-size: 0.88rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning {
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
|
||||||
|
border-radius: 0.72rem;
|
||||||
|
background: color-mix(in srgb, var(--danger) 8%, var(--surface));
|
||||||
|
padding: 0.66rem;
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.success {
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
color: var(--ink-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-gap {
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preset-row,
|
||||||
|
.action-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.55rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preset-row {
|
||||||
|
margin-bottom: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.82fr);
|
||||||
|
align-items: start;
|
||||||
|
gap: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-grid > * {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-panel > label,
|
||||||
|
.predicate-panel > label,
|
||||||
|
.compact-grid label {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.3rem;
|
||||||
|
margin-bottom: 0.7rem;
|
||||||
|
color: var(--ink-muted);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 750;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-panel > label:first-of-type {
|
||||||
|
max-width: 15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(6rem, 0.32fr);
|
||||||
|
gap: 0.55rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-grid label:first-child:last-child,
|
||||||
|
.compact-grid label:nth-child(3) {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.check-row {
|
||||||
|
display: flex !important;
|
||||||
|
grid-template-columns: auto 1fr;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.check-row input {
|
||||||
|
width: auto;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.limits {
|
||||||
|
margin-top: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.running {
|
||||||
|
margin: 0.75rem 0 0;
|
||||||
|
color: var(--accent-dark);
|
||||||
|
font-weight: 750;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-panel textarea {
|
||||||
|
min-height: 18rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-list {
|
||||||
|
max-height: 18rem;
|
||||||
|
overflow: auto;
|
||||||
|
padding-left: 1.5rem;
|
||||||
|
color: var(--ink-muted);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
details {
|
||||||
|
margin-top: 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
summary {
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 750;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading,
|
||||||
|
.fatal {
|
||||||
|
width: min(100%, 90rem);
|
||||||
|
margin: 2rem auto;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-dialog {
|
||||||
|
width: min(38rem, calc(100vw - 2rem));
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 1rem;
|
||||||
|
background: var(--surface);
|
||||||
|
color: inherit;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-dialog::backdrop {
|
||||||
|
background: rgb(16 14 25 / 58%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 860px) {
|
||||||
|
.hero,
|
||||||
|
.workspace-grid {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.privacy-pill {
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-grid > * {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-heading {
|
||||||
|
align-items: flex-start;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.work-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
scroll-behavior: auto !important;
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import "@testing-library/jest-dom/vitest";
|
||||||
|
import { afterEach } from "vitest";
|
||||||
|
import { cleanup } from "@testing-library/react";
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
cleanup();
|
||||||
|
localStorage.clear();
|
||||||
|
});
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://git.add-ideas.de/lotobo/toolbox-sdk/raw/branch/main/schemas/toolbox-app.v1.schema.json",
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "de.add-ideas.minimize-tools",
|
||||||
|
"name": "Minimize Tools",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Reduce failing inputs while preserving the failure locally.",
|
||||||
|
"entry": "./",
|
||||||
|
"icon": "./favicon.svg",
|
||||||
|
"categories": ["developer", "data", "testing"],
|
||||||
|
"tags": [
|
||||||
|
"minimize",
|
||||||
|
"delta-debugging",
|
||||||
|
"reproducer",
|
||||||
|
"json-schema",
|
||||||
|
"xslt",
|
||||||
|
"regex"
|
||||||
|
],
|
||||||
|
"integration": {
|
||||||
|
"contextVersion": 1,
|
||||||
|
"launchModes": ["navigate", "new-tab"],
|
||||||
|
"embedding": "unsupported"
|
||||||
|
},
|
||||||
|
"requirements": {
|
||||||
|
"secureContext": false,
|
||||||
|
"workers": true,
|
||||||
|
"indexedDb": false,
|
||||||
|
"crossOriginIsolated": false,
|
||||||
|
"topLevelContext": false
|
||||||
|
},
|
||||||
|
"privacy": {
|
||||||
|
"processing": "local",
|
||||||
|
"fileUploads": true,
|
||||||
|
"telemetry": false,
|
||||||
|
"label": "Inputs and predicates stay in this browser; nothing is uploaded."
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"repository": "https://git.add-ideas.de/lotobo/minimize-tools",
|
||||||
|
"license": "GPL-3.0-or-later"
|
||||||
|
},
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"id": "source",
|
||||||
|
"label": "Source",
|
||||||
|
"url": "https://git.add-ideas.de/lotobo/minimize-tools"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { defineToolboxApp, parseToolboxApp } from "@add-ideas/toolbox-contract";
|
||||||
|
import source from "./manifest.source.json";
|
||||||
|
|
||||||
|
export const manifest = defineToolboxApp(parseToolboxApp(source));
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export const APP_VERSION = "0.1.0";
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
import { expect, test, type Page } from "@playwright/test";
|
||||||
|
|
||||||
|
const ORIGIN = "http://127.0.0.1:4200";
|
||||||
|
|
||||||
|
async function watchLocalOnly(page: Page) {
|
||||||
|
const external: string[] = [];
|
||||||
|
await page.route("**/*", async (route) => {
|
||||||
|
const url = new URL(route.request().url());
|
||||||
|
if (url.origin !== ORIGIN) {
|
||||||
|
external.push(url.href);
|
||||||
|
await route.abort();
|
||||||
|
} else await route.continue();
|
||||||
|
});
|
||||||
|
return external;
|
||||||
|
}
|
||||||
|
|
||||||
|
test("minimizes a JSON failure at a nested path without network access", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await page.setViewportSize({ width: 1800, height: 1000 });
|
||||||
|
const external = await watchLocalOnly(page);
|
||||||
|
await page.goto("/deep/nested/minimize/");
|
||||||
|
await expect(
|
||||||
|
page.getByRole("heading", { name: "Minimize Tools" }),
|
||||||
|
).toBeVisible();
|
||||||
|
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||||
|
await expect(page.getByLabel("Minimized result")).toHaveValue(
|
||||||
|
'{"request":{"id":0}}',
|
||||||
|
);
|
||||||
|
await expect(page.getByText(/→.*bytes · \d+ tests/u)).toBeVisible();
|
||||||
|
expect(external).toEqual([]);
|
||||||
|
expect(
|
||||||
|
await page
|
||||||
|
.locator(".toolbox-shell__main")
|
||||||
|
.evaluate((node) => getComputedStyle(node).width),
|
||||||
|
).toBe("1440px");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("runs regular expressions in a worker and keeps the complete result", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await page.goto("/deep/nested/minimize/");
|
||||||
|
await page.getByLabel("Structure").selectOption("text");
|
||||||
|
await page.getByLabel("Failure predicate").selectOption("regex-matches");
|
||||||
|
await page.getByLabel("Failing input").fill("noise TARGET more noise");
|
||||||
|
await page.getByLabel("Regular expression").fill("TARGET");
|
||||||
|
await page.getByLabel(/Slow threshold/u).fill("100");
|
||||||
|
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||||
|
await expect(page.getByLabel("Minimized result")).toHaveValue("TARGET");
|
||||||
|
await page.getByLabel("Regular expression").fill("[");
|
||||||
|
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||||
|
await expect(page.getByRole("alert")).toContainText("retained");
|
||||||
|
await expect(page.getByLabel("Minimized result")).toHaveValue("TARGET");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("reduces XML against the restricted browser XSLT predicate", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await page.goto("/deep/nested/minimize/");
|
||||||
|
await page.getByRole("button", { name: "XSLT failure" }).click();
|
||||||
|
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||||
|
await expect(page.getByLabel("Minimized result")).toContainText("BOOM");
|
||||||
|
await expect(page.getByLabel("Minimized result")).not.toContainText(
|
||||||
|
"metadata",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("downloads the minimized case and exact predicate report", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await page.goto("/deep/nested/minimize/");
|
||||||
|
await page.getByRole("button", { name: "Minimize reproducer" }).click();
|
||||||
|
await expect(page.getByLabel("Minimized result")).not.toHaveValue("");
|
||||||
|
const caseDownload = page.waitForEvent("download");
|
||||||
|
await page.getByRole("button", { name: "Download case" }).click();
|
||||||
|
expect((await caseDownload).suggestedFilename()).toBe("minimized.json");
|
||||||
|
const reportDownload = page.waitForEvent("download");
|
||||||
|
await page.getByRole("button", { name: "Download report" }).click();
|
||||||
|
expect((await reportDownload).suggestedFilename()).toBe(
|
||||||
|
"minimization-report.json",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("integrates help, themes, identity, headers and offline reload", async ({
|
||||||
|
page,
|
||||||
|
request,
|
||||||
|
context,
|
||||||
|
}) => {
|
||||||
|
await page.goto("/deep/nested/minimize/");
|
||||||
|
await page.getByRole("button", { name: "Help" }).click();
|
||||||
|
await expect(
|
||||||
|
page.getByRole("dialog", { name: "About Minimize Tools" }),
|
||||||
|
).toContainText("predicate");
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
await page.getByRole("button", { name: "Personalize" }).click();
|
||||||
|
await page.getByRole("button", { name: "Dark" }).click();
|
||||||
|
await expect(page.locator(".toolbox-shell").first()).toHaveAttribute(
|
||||||
|
"data-toolbox-theme",
|
||||||
|
"dark",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
await page.evaluate(async () =>
|
||||||
|
Boolean(await navigator.serviceWorker.ready),
|
||||||
|
),
|
||||||
|
).toBe(true);
|
||||||
|
const index = await request.get("/deep/nested/minimize/");
|
||||||
|
expect(index.headers()["content-security-policy"]).toContain(
|
||||||
|
"connect-src 'self'",
|
||||||
|
);
|
||||||
|
expect(await index.text()).not.toMatch(/\b(?:src|href)=["']\//u);
|
||||||
|
const manifest = await request.get("/deep/nested/minimize/toolbox-app.json");
|
||||||
|
await expect(manifest.json()).resolves.toMatchObject({
|
||||||
|
id: "de.add-ideas.minimize-tools",
|
||||||
|
version: "0.1.0",
|
||||||
|
privacy: { processing: "local", telemetry: false },
|
||||||
|
});
|
||||||
|
await context.setOffline(true);
|
||||||
|
await page.reload();
|
||||||
|
await expect(
|
||||||
|
page.getByRole("heading", { name: "Minimize Tools" }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { render, screen, waitFor } from "@testing-library/react";
|
||||||
|
import userEvent from "@testing-library/user-event";
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { Workbench } from "../../src/components/Workbench";
|
||||||
|
|
||||||
|
describe("Minimize workbench", () => {
|
||||||
|
it("minimizes the focused JSON Schema example", async () => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
render(<Workbench />);
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole("button", { name: "Minimize reproducer" }),
|
||||||
|
);
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(
|
||||||
|
(screen.getByLabelText("Minimized result") as HTMLTextAreaElement)
|
||||||
|
.value,
|
||||||
|
).toContain('"id":0'),
|
||||||
|
);
|
||||||
|
expect(screen.getByText(/bytes · \d+ tests/u)).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps the last complete result after a predicate error", async () => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
render(<Workbench />);
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole("button", { name: "Minimize reproducer" }),
|
||||||
|
);
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(screen.getByLabelText("Minimized result")).not.toHaveValue(""),
|
||||||
|
);
|
||||||
|
const previous = (
|
||||||
|
screen.getByLabelText("Minimized result") as HTMLTextAreaElement
|
||||||
|
).value;
|
||||||
|
await user.selectOptions(
|
||||||
|
screen.getByLabelText("Failure predicate"),
|
||||||
|
"contains",
|
||||||
|
);
|
||||||
|
const marker = screen.getByLabelText("Marker");
|
||||||
|
await user.clear(marker);
|
||||||
|
await user.type(marker, "NOT PRESENT");
|
||||||
|
await user.click(
|
||||||
|
screen.getByRole("button", { name: "Minimize reproducer" }),
|
||||||
|
);
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(screen.getByRole("alert")).toHaveTextContent(/retained/u),
|
||||||
|
);
|
||||||
|
expect(screen.getByLabelText("Minimized result")).toHaveValue(previous);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { minimizeInput } from "../../src/minimize/engine";
|
||||||
|
import {
|
||||||
|
createPredicate,
|
||||||
|
type RegexEvaluator,
|
||||||
|
} from "../../src/minimize/predicates";
|
||||||
|
|
||||||
|
const unusedRegex: RegexEvaluator = async () => ({
|
||||||
|
matched: false,
|
||||||
|
elapsedMs: 0,
|
||||||
|
timedOut: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("minimization engine", () => {
|
||||||
|
it("removes XML structure while preserving a literal marker", async () => {
|
||||||
|
const input = `<case><noise a="1">discard</noise><payload><message>BOOM</message><also>discard</also></payload></case>`;
|
||||||
|
const predicate = createPredicate(
|
||||||
|
{ kind: "contains", needle: "BOOM" },
|
||||||
|
unusedRegex,
|
||||||
|
);
|
||||||
|
const result = await minimizeInput(
|
||||||
|
input,
|
||||||
|
{ structure: "xml", maxTests: 300, maxSeconds: 5 },
|
||||||
|
predicate,
|
||||||
|
new AbortController().signal,
|
||||||
|
);
|
||||||
|
expect(result.minimized).toContain("BOOM");
|
||||||
|
expect(result.minimized.length).toBeLessThan(input.length);
|
||||||
|
expect(
|
||||||
|
new DOMParser()
|
||||||
|
.parseFromString(result.minimized, "application/xml")
|
||||||
|
.querySelector("parsererror"),
|
||||||
|
).toBeNull();
|
||||||
|
expect(result.steps.length).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps the original JSON Schema failure signature", async () => {
|
||||||
|
const input = JSON.stringify({
|
||||||
|
request: { id: 0, label: "noise" },
|
||||||
|
unrelated: [1, 2, 3],
|
||||||
|
});
|
||||||
|
const predicate = createPredicate(
|
||||||
|
{
|
||||||
|
kind: "json-schema-fails",
|
||||||
|
preserveFailureSignature: true,
|
||||||
|
schema: JSON.stringify({
|
||||||
|
type: "object",
|
||||||
|
required: ["request"],
|
||||||
|
properties: {
|
||||||
|
request: {
|
||||||
|
type: "object",
|
||||||
|
required: ["id"],
|
||||||
|
properties: { id: { type: "integer", minimum: 1 } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
unusedRegex,
|
||||||
|
);
|
||||||
|
const result = await minimizeInput(
|
||||||
|
input,
|
||||||
|
{ structure: "json", maxTests: 500, maxSeconds: 5 },
|
||||||
|
predicate,
|
||||||
|
new AbortController().signal,
|
||||||
|
);
|
||||||
|
expect(JSON.parse(result.minimized)).toEqual({ request: { id: 0 } });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("minimizes malformed syntax and reports budget exhaustion", async () => {
|
||||||
|
const predicate = createPredicate({ kind: "invalid-json" }, unusedRegex);
|
||||||
|
const result = await minimizeInput(
|
||||||
|
'{"large": [1,2,}',
|
||||||
|
{ structure: "json", maxTests: 1, maxSeconds: 5 },
|
||||||
|
predicate,
|
||||||
|
new AbortController().signal,
|
||||||
|
);
|
||||||
|
expect(result.exhausted).toBe(true);
|
||||||
|
expect(result.tests).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("rejects a baseline that does not reproduce and honours cancellation", async () => {
|
||||||
|
await expect(
|
||||||
|
minimizeInput(
|
||||||
|
"safe",
|
||||||
|
{ structure: "text", maxTests: 20, maxSeconds: 2 },
|
||||||
|
createPredicate({ kind: "contains", needle: "BOOM" }, unusedRegex),
|
||||||
|
new AbortController().signal,
|
||||||
|
),
|
||||||
|
).rejects.toThrow(/does not satisfy/u);
|
||||||
|
const controller = new AbortController();
|
||||||
|
controller.abort();
|
||||||
|
await expect(
|
||||||
|
minimizeInput(
|
||||||
|
"BOOM",
|
||||||
|
{ structure: "text", maxTests: 20, maxSeconds: 2 },
|
||||||
|
createPredicate({ kind: "contains", needle: "BOOM" }, unusedRegex),
|
||||||
|
controller.signal,
|
||||||
|
),
|
||||||
|
).rejects.toMatchObject({ name: "AbortError" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses isolated regex outcomes and fails closed on unsafe schemas/XSLT", async () => {
|
||||||
|
const slow = createPredicate(
|
||||||
|
{ kind: "regex-slow", pattern: "a+", flags: "u", thresholdMs: 20 },
|
||||||
|
async () => ({ matched: false, elapsedMs: 20, timedOut: false }),
|
||||||
|
);
|
||||||
|
expect(await slow("aaaa", new AbortController().signal)).toBe(true);
|
||||||
|
expect(() =>
|
||||||
|
createPredicate(
|
||||||
|
{
|
||||||
|
kind: "json-schema-fails",
|
||||||
|
schema: '{"$ref":"https://invalid/schema.json"}',
|
||||||
|
},
|
||||||
|
unusedRegex,
|
||||||
|
),
|
||||||
|
).toThrow(/unsupported.*\$ref/iu);
|
||||||
|
expect(() =>
|
||||||
|
createPredicate(
|
||||||
|
{
|
||||||
|
kind: "xslt-throws",
|
||||||
|
stylesheet:
|
||||||
|
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:include href="https://invalid/x.xsl"/></xsl:stylesheet>',
|
||||||
|
},
|
||||||
|
unusedRegex,
|
||||||
|
),
|
||||||
|
).toThrow(/include/u);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
|
"target": "ES2023",
|
||||||
|
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"types": ["vite/client"],
|
||||||
|
"allowArbitraryExtensions": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"erasableSyntaxOnly": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"strict": true,
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true
|
||||||
|
},
|
||||||
|
"include": ["src", "tests"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.app.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.node.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
"target": "ES2023",
|
||||||
|
"lib": ["ES2023"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"types": ["node"],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"vite.config.ts",
|
||||||
|
"playwright.config.ts",
|
||||||
|
"eslint.config.mjs",
|
||||||
|
"scripts/**/*.mjs"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference types="vitest/config" />
|
||||||
|
import { defineConfig } from "vite";
|
||||||
|
import react from "@vitejs/plugin-react";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
base: "./",
|
||||||
|
plugins: [react()],
|
||||||
|
test: {
|
||||||
|
environment: "jsdom",
|
||||||
|
setupFiles: "./src/test/setup.ts",
|
||||||
|
css: true,
|
||||||
|
maxWorkers: 2,
|
||||||
|
restoreMocks: true,
|
||||||
|
exclude: ["tests/browser/**", "node_modules/**", "dist/**"],
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user