code-playpad 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- <!-- GENERATED by scripts/sync-java.mjs from java-online-compiler@0.31.0 (1e282082ba6882cd5be2b0f512ee0c64544799b4). Do not edit. -->
1
+ <!-- GENERATED by scripts/sync-java.mjs from java-online-compiler@0.34.1 (f3698375f3087bcbeeae3f7736746cd0c807c689). Do not edit. -->
2
2
 
3
- > This is the compatibility table of the Java engine that code-playpad ships (engine 0.31.0).
3
+ > This is the compatibility table of the Java engine that code-playpad ships (engine 0.34.1).
4
4
  > Paths such as `tests/…`, `SPEC.md` and `docs/…` refer to the engine's source (`java-engine/` in code-playpad's repository), which is not part of the package.
5
5
 
6
- # Compatibility — engine 0.31.0 (Stage A, compact source files, objects, numbers and control flow, collections, lambdas, practice mode, String, format, regex, Math, Random, System, Scanner and IO.readln, inheritance, interfaces, Object, instanceof, enums, records, exceptions, hash order, fixed collections, TreeMap, TreeSet, LinkedList, Stack, lambdas, method references, generic classes and methods, var, annotations, varargs, anonymous classes, streams, subList, local classes, raw types, float, byte and short, pattern matching, sealed classes, BigInteger, BigDecimal, EnumMap, EnumSet, fast I/O, static imports, initializer blocks, text blocks, enum constant bodies, Interface.super, ListIterator, reversed views, access-ordered LinkedHashMap, var lambda parameters, array clone, library subclasses, bridge methods, Vector, Hashtable, StringBuffer, StringJoiner, java.util.regex, outer.new, BitSet, parallel streams, java.time dates, AbstractList)
6
+ # Compatibility — engine 0.34.1 (Stage A, compact source files, objects, numbers and control flow, collections, lambdas, practice mode, String, format, regex, Math, Random, System, Scanner and IO.readln, inheritance, interfaces, Object, instanceof, enums, records, exceptions, hash order, fixed collections, TreeMap, TreeSet, LinkedList, Stack, lambdas, method references, generic classes and methods, var, annotations, varargs, anonymous classes, streams, subList, local classes, raw types, float, byte and short, pattern matching, sealed classes, BigInteger, BigDecimal, EnumMap, EnumSet, fast I/O, static imports, initializer blocks, text blocks, enum constant bodies, Interface.super, ListIterator, reversed views, access-ordered LinkedHashMap, var lambda parameters, array clone, library subclasses, bridge methods, Vector, Hashtable, StringBuffer, StringJoiner, java.util.regex, outer.new, BitSet, parallel streams, java.time dates, AbstractList, LocalTime, LocalDateTime, Duration)
7
7
 
8
8
  This document records what the engine accepts, what it rejects, and the evidence that it behaves like Java. Every method of every library class, with its status and the tests that call it, is in docs/feature-manifest.json (`npm run manifest`). The reference is Java SE 25 (SPEC.md §4), and what the engine implements is **a documented subset of Java 25**, not "Java 25".
9
9
 
@@ -17,7 +17,7 @@ Every feature has one status:
17
17
  > - **Golden programs:** all 47 in `tests/programs` (the SPEC.md §4.1 Stage A corpus among them) match byte for byte: stdout, stderr, and exit code.
18
18
  > - **Recorded snippets:** all 1636 cases in `tests/jdk-cases` match. 1613 match byte for byte (once the JDK's own stack frames are removed, as *Known divergences* explains); the other 23 are listed under *Known divergences*, each with the narrower comparison the tests apply to it.
19
19
  > - **Practice corpus:** all 10 Stage 4 programs in `tests/corpus` (docs/practice-corpus.md) run and match.
20
- > - **Field corpus:** 336 of 339 programs written as learners and solvers write Java, kept whether or not the engine supports them, match the JDK exactly. None runs differently; 1 is rejected as unsupported (`Thread`), 2 stop on an engine limitation and none on the instruction limit (`corpus/REPORT.md`, docs/corpus-harness.md).
20
+ > - **Field corpus:** 337 of 339 programs written as learners and solvers write Java, kept whether or not the engine supports them, match the JDK exactly. None runs differently; 1 is rejected as unsupported (`Thread`), 1 stops on an engine limitation and none on the instruction limit (`corpus/REPORT.md`, docs/corpus-harness.md).
21
21
 
22
22
  ## Program structure
23
23
 
@@ -27,7 +27,7 @@ Every feature has one status:
27
27
  | **Several top-level classes** | Supported | Any number, in any order, each with its own fields, methods and constructors. `duplicate class: Node`. A public class need not match the file name (source-file mode allows it). |
28
28
  | **Member classes**: `static` nested and inner | Supported with limits | `static class Node` inside `Main`, or an inner class, whose instances hold their enclosing instance (`this$0`) and can use its fields and methods by simple name. `new Inner()` needs an enclosing instance (`non-static variable this cannot be referenced from a static context`). Names: `Main$Node` at run time, `Node` in diagnostics, `Main.Node` as a qualified type. Classes nest to any depth (`static class MyList<T> { class Node { T val; } }`): an inner class reaches each enclosing instance through javac's `this$N` fields, so NPE messages name them as the JDK does. An inner class of a generic class, seen from outside it, keeps its outer class's type variables. `Outer.this` names an enclosing instance. `outer.new Inner()` (JLS 15.9.2) gives the enclosing instance explicitly, with javac's `NullPointerException` for a null one and `qualified new of static class`; with an anonymous class body, or of a generic class or a generic class's inner class, it is unsupported. |
29
29
  | **Launch protocol** (Java 25) | Supported | The first top-level class runs if it has a `main`, otherwise the class named after the file (`can't find class: Main` if there is none). `main(String[])` is preferred over `main()`. Either may be `static` or an instance method, and need not be `public` (but not `private`). An instance `main` runs on an instance made with the no-argument constructor, which may be private (`can't find no argument constructor in class: A`). `String... args` and `String args[]` are accepted; `args` is empty. |
30
- | Methods: parameters, `return`, recursion, overloading; `static` and instance | Supported | Overload resolution follows JLS 15.12.2: the strict phase, then the boxing phase, then the most specific method, with javac's "cannot be applied", "no suitable method", and "ambiguous" reports. Calls are `f(x)`, `this.f(x)`, `obj.f(x)`, `Node.f(x)`, or an enclosing class's `f(x)`. Using an instance member from a static context gives javac's `non-static … cannot be referenced from a static context`. |
30
+ | Methods: parameters, `return`, recursion, overloading; `static` and instance | Supported | Overload resolution follows JLS 15.12.2: the strict phase, then the boxing phase, then the most specific method, with javac's "cannot be applied", "no suitable method", and "ambiguous" reports. An ambiguous call names the two methods javac names (its most-specific fold over each class's methods, last declared first: `sb.append(null)` names `append(CharSequence)` and `append(char[])`). An argument that is a generic call whose result only an implicit lambda or an inexact method reference decides (`collect(groupingBy(f, TreeMap::new, counting()))`, `collect(collectingAndThen(toList(), l -> …))`) does not count for applicability (JLS 15.12.2.2) for any overloaded method or constructor, the program's own included: it fits every parameter its type variable's bound allows, so `show(String)` beats `show(Object)` and `show(String)`/`show(Integer)` is ambiguous, then fails with javac's `inference variable R has incompatible bounds` and its `where` clause. Calls are `f(x)`, `this.f(x)`, `obj.f(x)`, `Node.f(x)`, or an enclosing class's `f(x)`. Using an instance member from a static context gives javac's `non-static … cannot be referenced from a static context`. |
31
31
  | **Constructors** | Supported with limits | Overloaded, with javac's resolution errors (`constructor Point in class Point cannot be applied to given types;`, `no suitable constructor found for Point(String)`, `reference to Pair is ambiguous`). A class without one gets the default constructor. `this(...)` as the first statement, with `recursive constructor invocation` detected. Statements before `this(...)` (Java 25's flexible constructor bodies) and `super(...)` are unsupported. |
32
32
  | `new C(args)` | Supported | Objects have identity: `==`, `!=`, `null`, and `Object.equals(Object)` by reference. |
33
33
  | Fields: `static` and instance, `final`, initializers, `this.x`, `obj.x`, `Node.x` | Supported | Defaults are 0, false, null. Instance initializers run at the start of each constructor that does not call `this(...)`, in source order. `final` fields with constant initializers are constants. `illegal forward reference` and `self-reference in initializer` follow JLS 8.3.3. Blank `final` fields must be assigned exactly once by every constructor: `variable y might not have been initialized`, `might already have been assigned`, `might be assigned in loop`, `not initialized in the default constructor`. |
@@ -43,7 +43,7 @@ Every feature has one status:
43
43
  | `getClass()`, `X.class` | Supported with limits | A `Class` value per class: `getName()` (`Main$Node`, `[I`), `getSimpleName()` (`Node`, `int[]`), `isInterface()`, `isArray()`, printing as `class Main$Node`, and `==` between classes, as `equals` methods use it. `X.class` is a `Class<X>` (so `new EnumMap<>(Day.class)` infers its key type); `Class<?>` may be declared. The reflection methods are unsupported. |
44
44
  | Running a file, and programs in several files (JEP 458) | Supported with limits | Behaves like `java <entry>` in source-file mode. The program's other `.java` files (`Session.java` beside `Main.java`) are compiled as the JDK's launcher compiles them: a file when the program first names the class it is named after, so a file nothing names is never compiled, and its errors never reported. Each file has its own imports. A class of the entry file wins over another file's of the same name. Errors and stack traces name each file (`Session.java:2: error: …`, `at Session.describe(Session.java:5)`); where the JDK prints another file's absolute path on disk, the engine prints its name. A file's warnings print again when the program first uses one of its classes, as the launcher's second compilation prints them (a class literal, `Helper.class`, is not counted as a use). Limits: 32 files, 500,000 characters per file and 1,000,000 together. A requested entry that is not among the files fails as `java Missing.java` does (`Error: Could not find or load main class Missing.java`); another file never runs in its place. A `.java` file in a folder (`src/Session.java`, `lib\\Session.java`) is reported by name as not supported, an engine rule for its source sets rather than the JDK's, instead of being left out. Unsupported: `package` declarations, folders, another compact source file with a `main`, and using another file's secondary class (one not named after its file) from outside that file, which the JDK finds only if that file happened to be compiled first. |
45
45
  | No class / no usable main | Supported | `error: no class declared in source file`; `error: can't find main(String[]) or main() method in class: Main`; `error: can't find class: Main`; for a compact file, `compact source file does not have main method in the form of void main() or void main(String[] args)` |
46
- | `import`: single-type and on-demand | Supported with limits | `import java.util.List;` and `import java.util.*;` for the supported java.util classes (see *Library*); the java.lang ones need no import. A compact source file sees java.util without imports, as Java 25's implicit `import module java.base` gives it. A wrong name gets javac's error: `package java.utill does not exist`, or `cannot find symbol` with `location: package java.util`. Real JDK classes outside the subset (`LocalTime`, `UUID`, …) are unsupported where they are used. Fully qualified names work without an import, in types and in expressions, for every package the subset has: `java.util.stream.IntStream.range(0, 3)`, `java.util.Map.Entry.comparingByKey()`; `java.time.LocalTime.of(...)` is unsupported, not `cannot find symbol`. Classes of java.io, java.math, java.util.function and java.util.stream that the subset has are imported the same way. |
46
+ | `import`: single-type and on-demand | Supported with limits | `import java.util.List;` and `import java.util.*;` for the supported java.util classes (see *Library*); the java.lang ones need no import. A compact source file sees java.util without imports, as Java 25's implicit `import module java.base` gives it. A wrong name gets javac's error: `package java.utill does not exist`, or `cannot find symbol` with `location: package java.util`. Real JDK classes outside the subset (`Instant`, `UUID`, …) are unsupported where they are used. Fully qualified names work without an import, in types and in expressions, for every package the subset has: `java.util.stream.IntStream.range(0, 3)`, `java.util.Map.Entry.comparingByKey()`; `java.time.Instant.now()` is unsupported, not `cannot find symbol`. Classes of java.io, java.math, java.util.function and java.util.stream that the subset has are imported the same way. |
47
47
  | `import static`: single and on-demand (JLS 7.5.3, 7.5.4) | Supported | Methods and fields of the supported classes: `import static java.lang.Math.*;`, `import static java.lang.System.out;`, `import static java.util.stream.Collectors.*;`, `import static java.util.Map.entry;`, and member types (`import static java.util.Map.Entry;`). A simple name means the program's own local, field or method first, then a single import, then an on-demand one (JLS 6.4.1). A method of the class or an enclosing one, Object's included, hides every import of that name, so `toString(a)` with `Arrays.*` imported is javac's `method toString in class Object cannot be applied`. Overloads from several on-demand imports are resolved together (`sort(int[])` from Arrays, `sort(List)` from Collections). javac's errors: `reference to MAX_VALUE is ambiguous` (fields, and methods equally specific in two classes), `cannot find symbol` with `symbol: static foo`, a missing class or package, `static import only from classes and interfaces`. Imported constants are constants (switch labels). Importing from a JDK class outside the subset (`TimeUnit`) is fine until a name from it is used, which is unsupported. |
48
48
  | Variable-arity methods and constructors (`int... xs`, JLS 8.4.1) | Supported | Chosen in the third phase of overload resolution, as javac chooses (`f(int)` over `f(int...)`, `g(Integer)` over `g(int...)`); the trailing arguments go into a new array, or an array is passed as it is. javac's `varargs parameter must be the last parameter`, `varargs mismatch; …`, and its `[unchecked]` warnings for a parameter type the run cannot check: `Possible heap pollution from parameterized vararg type T` at the declaration and `unchecked generic array creation for varargs parameter of type List<Integer>[]` at the call, unless the method is `@SafeVarargs`. |
49
49
  | **Anonymous classes** (JLS 15.9.5) | Supported with limits | `new Comparator<Integer>() { public int compare(...) { ... } }`, `new Shape("sq") { double area() { ... } }`, `new Iterator<>() { ... }`: extending a class of the program (its constructor's arguments passed on) or a built-in exception, or implementing an interface of the program or the library's `Comparable`, `Comparator`, `Iterable`, `Iterator` and functional interfaces (`Runnable`, `Function`, …), with fields, methods, `@Override`, and the diamond inferred from where the object goes. Named as javac names them (`Main$1`, `Main$Holder$1`, `Main$2$1`, in source order per enclosing class), so stack traces, `getClass().getName()` and `<anonymous Main$1>` in diagnostics match; `getSimpleName()` is empty. They capture effectively final locals of the code around them into javac's `val$x` fields (NPE messages say `"this.val$s"`) and use the enclosing instance's members. javac's errors: `<anonymous Main$1> is not abstract and does not override abstract method …`, `anonymous class implements interface; cannot have arguments`, `cannot inherit from final F`, `local variables referenced from an inner class must be final or effectively final`. Extending an inner class or a library class is unsupported. |
@@ -110,7 +110,7 @@ Every feature has one status:
110
110
  | `java.io.PrintWriter`, `BufferedWriter`, `OutputStreamWriter`, `StringWriter` | Supported | Over `System.out`, `System.err`, each other, or a `StringWriter`: every `print`/`println` overload, `printf`, `format`, `write`, `append`, `newLine`, `flush`, `close`, `checkError`, autoflush. They buffer as the JDK's do (ADR 0016): what is not flushed when the program ends is lost, and exactly the part the JDK writes out reaches the output (4,000 unflushed lines print their first 24,576 bytes). `PrintWriter` never throws `IOException`; the others do, after `close`. File names and charsets are unsupported, as is `StringWriter.getBuffer()`. |
111
111
  | `java.util.StringTokenizer` | Supported | `hasMoreTokens`, `nextToken`, `nextToken(delimiters)`, `hasMoreElements`, `nextElement`, `countTokens`; the default delimiters `" \t\n\r\f"`, custom ones, and returning delimiters as tokens. `NoSuchElementException` at the end; the JDK's `NullPointerException`s for a null string or delimiters. |
112
112
  | `java.io.StreamTokenizer` | Supported with limits | `nextToken`, the public fields `ttype`, `nval` and `sval`, `TT_EOF`, `TT_EOL`, `TT_NUMBER`, `TT_WORD`, `pushBack`, `lineno`, `toString`, and the syntax methods (`wordChars`, `whitespaceChars`, `ordinaryChar(s)`, `commentChar`, `quoteChar`, `parseNumbers`, `resetSyntax`, `eolIsSignificant`, `lowerCaseMode`). Numbers have the JDK's exact values, including its rounding of long digit strings. `slashStarComments` and `slashSlashComments` are unsupported. |
113
- | `System.out` / `System.err`: `print` and `println` | Supported | Overloads are resolved as in javac across all nine (`println` also has a no-argument form): `println('x')` prints the char, `println(charArray)` prints the characters, and other arrays print as `type@hash`. `println(null)` is ambiguous, as in Java, and so is a generic call whose result only an implicit lambda or an inexact method reference decides (`println(stream.collect(collectingAndThen(toList(), l -> …)))`: such arguments do not count for applicability, JLS 15.12.2.2), with javac's two errors. |
113
+ | `System.out` / `System.err`: `print` and `println` | Supported | Overloads are resolved as in javac across all nine (`println` also has a no-argument form): `println('x')` prints the char, `println(charArray)` prints the characters, and other arrays print as `type@hash`. `println(null)` is ambiguous, as in Java, and so is a generic call whose result only an implicit lambda or an inexact method reference decides (`println(stream.collect(collectingAndThen(toList(), l -> …)))`), with javac's two errors; one a constructor reference decides (`println(stream.collect(groupingBy(f, TreeMap::new, counting())))`) chooses `println(String)` and fails, as javac does (see Methods). |
114
114
  | `System.out` / `System.err` as values; `flush()`, `close()`, `checkError()` | Supported | Passed to `PrintWriter` or `OutputStreamWriter` as the `OutputStream` they are. `System.out` prints at once, so `flush()` has nothing to do. Closing it, directly or through a writer over it, drops everything printed to it afterwards, as on the JDK; a closed `System.err` drops an uncaught exception's trace too. `PrintStream` as a declared type, `write` and `append` are unsupported. |
115
115
  | `System.out` / `System.err`: `printf(String, Object...)`, `format(String, Object...)` | Supported with limits | As `String.format`, below. The call is a statement: the `PrintStream` it returns cannot be used (`System.out.printf(...).println()` is unsupported). The `Locale` overloads are unsupported. |
116
116
  | `String.length()`, `charAt(int)`, `equals(Object)`, `isEmpty()`, `toCharArray()`, `compareTo(String)` | Supported | `equals` boxes primitives, so `"x".equals(5)` is `false`, as in Java. `compareTo` gives the JDK's values (the first differing character's difference, else the length difference) and its NPE messages. These need no Java library. |
@@ -136,7 +136,7 @@ Every feature has one status:
136
136
  | `StringJoiner` | Supported | `add` (null is `"null"`), `merge`, `setEmptyValue`, `length`, `toString`; constructors with a delimiter, or with a prefix and suffix too, and the JDK's `The delimiter must not be null`. |
137
137
  | `Map.Entry` | Supported | `getKey`, `getValue`, `setValue`, `equals`, `hashCode` (key's hash xor value's), `toString` (`k=v`). Named `Map.Entry`, or `Entry` after `import java.util.Map.Entry;`. |
138
138
  | `HashSet`, `Set`, `LinkedHashSet` | Supported with limits | `add`, `contains`, `remove`, `size`, `isEmpty`, `clear`, `addAll`, `containsAll`, `equals`, `hashCode`, `iterator`, `toArray`, `toString`. `removeAll` and `retainAll`. Constructors `()`, `(int)`, `(int, float)`, `(Collection)`, sized as the JDK sizes them, so their order is the JDK's too. A `HashSet` is a `HashMap` of its elements, as in the JDK, and iterates in the same order; `LinkedHashSet` in insertion order. Membership is exact, and a `Set<List<Integer>>` compares lists by content. `LinkedHashSet`'s `reversed()` and its `addFirst`/`getFirst` family are unsupported. |
139
- | `List.of`, `Set.of`, `Map.of`, `Map.ofEntries`, `Map.entry`, `copyOf` | Supported with limits | Immutable, as the JDK's: changing one is `UnsupportedOperationException`, null elements are `NullPointerException` (with the JDK's message for each size class: `Cannot invoke "Object.hashCode()" because "pk" is null` from a `Map.of` of several entries), `get` out of range is `Index: 1 Size: 1` or `Index 5 out of bounds for length 3`, duplicates are `IllegalArgumentException: duplicate element: 1` / `duplicate key: k`. `List.of` iterates in order. The JDK randomizes the order of a `Set.of` or `Map.of` on every run, so iterating or printing one of more than one element is an engine limitation; lookups, `size` and `equals` are exact. |
139
+ | `List.of`, `Set.of`, `Map.of`, `Map.ofEntries`, `Map.entry`, `copyOf` | Supported with limits | Immutable, as the JDK's: changing one is `UnsupportedOperationException`, null elements are `NullPointerException` (with the JDK's message for each size class: `Cannot invoke "Object.hashCode()" because "pk" is null` from a `Map.of` of several entries), `get` out of range is `Index: 1 Size: 1` or `Index 5 out of bounds for length 3`, duplicates are `IllegalArgumentException: duplicate element: 1` / `duplicate key: k`. `List.of` iterates in order. **Their order is the JDK's** (ADR 0026): a `Set.of` or `Map.of` lays its elements out by `hashCode()` and is read from a start and in a direction that a salt chosen once per run decides, as the JDK chooses it at startup. So the order differs from run to run, as on the JDK, and every order the engine prints is one the JDK prints (checked against every output of 248 JDK runs); a program whose output does not depend on the order prints what the JDK prints. `Set.copyOf` goes through a HashSet first, as the JDK's does. Elements hashed by identity (objects without `hashCode()`) are an engine limitation where the order shows; lookups, `size` and `equals` are exact. |
140
140
  | `Arrays.asList` | Supported | A fixed-size list over the array itself: `set` and the array see each other's changes, `add` and `remove` are `UnsupportedOperationException`, `Collections.sort` sorts the array. `Arrays.asList(intArray)` is a `List<int[]>` of one element, as in Java. |
141
141
  | `Collections` | Supported with limits | `sort`, `reverse`, `swap`, `max`, `min` (natural order or a `Comparator`), `frequency`, `addAll`, `fill`, `shuffle` (with a seeded `Random`, the JDK's permutation), `nCopies`, `emptyList`, `emptySet`, `emptyMap`, `singletonList`, `singleton`, `singletonMap`, `reverseOrder` (with or without a comparator), `binarySearch` (natural order or a `Comparator`, probing the middle elements the JDK probes), `disjoint`, and the `unmodifiableList`, `Set`, `Map` and `Collection` views, with the JDK's exceptions (`List length = -1`, `Index: 1, Size: 1`, `NoSuchElementException` from `max` of an empty collection). `rotate`, `copy`, `indexOfSubList`, the synchronized and checked views and the rest are unsupported. |
142
142
  | `toArray()`, `toArray(T[])` | Supported | On every collection: a new `Object[]`, or the given array when the elements fit (the next slot set to null), else a new array of its type; an element it cannot hold is the JDK's `ArrayStoreException: arraycopy: element type mismatch: …`. |
@@ -146,12 +146,12 @@ Every feature has one status:
146
146
  | `Collectors` | Supported with limits | `toList`, `toUnmodifiableList`, `toSet`, `toCollection`, `toMap` (two, three or four arguments; a duplicate key is the JDK's `IllegalStateException: Duplicate key a (attempted merging values 1 and 1)`), `groupingBy` (one, two or three arguments), `partitioningBy` (`{false=..., true=...}`), `counting` (a `Long`), `summingInt`/`Long`/`Double`, `averagingInt`/`Long`/`Double`, `summarizingInt`/`Long`/`Double`, `joining` (with a delimiter, prefix and suffix), `mapping`, `filtering`, `flatMapping`, `collectingAndThen`, `reducing`, `minBy`, `maxBy`, `teeing` (`downstream1`, `merger` NPE messages). Maps are filled as the JDK fills them (`groupingBy` through `computeIfAbsent`, so a `HashMap` prints in the JDK's order). `toUnmodifiableSet`/`Map` and the concurrent collectors are unsupported. Type arguments are inferred as javac infers them in the common forms: `collect(Collectors.toList())`, `groupingBy(w -> w.charAt(0), TreeMap::new, Collectors.counting())`, `collectingAndThen(Collectors.toList(), List::size)`. |
147
147
  | `Optional`, `OptionalInt`, `OptionalLong`, `OptionalDouble`, `IntSummaryStatistics` (and `Long`, `Double`) | Supported | `of`, `ofNullable`, `empty`, `get`/`getAsInt`/…, `isPresent`, `isEmpty`, `orElse`, `orElseGet`, `orElseThrow` (with or without a supplier), `ifPresent`, `ifPresentOrElse`, `map`, `flatMap`, `filter`, `or`, `stream`; printed as `Optional[3]`, `Optional.empty`, `OptionalDouble[1.5]`; `NoSuchElementException: No value present`. The statistics' `getCount`, `getSum`, `getMin`, `getMax`, `getAverage`, `accept`, and `IntSummaryStatistics{count=3, sum=80, min=20, average=26.666667, max=30}`. |
148
148
  | `BitSet` | Supported | `set`, `clear`, `flip` (one bit or a range, `set(i, boolean)`), `get` (a bit, or a range as a new BitSet), `length`, `size`, `isEmpty`, `cardinality`, `nextSetBit`, `nextClearBit`, `previousSetBit`, `previousClearBit`, `and`, `or`, `xor`, `andNot`, `intersects`, `clone`, `valueOf(long[])`, `toLongArray`, `stream`, `toString` (`{1, 3, 64}`), `equals` and `hashCode` (the JDK's). Its words as the JDK lays them out: `size()` starts at 64 (or the bits asked for, rounded up to 64), grows to twice as many words or what is needed, and `clone()` trims it unless the size came from the constructor. The JDK's messages: `bitIndex < 0: -1`, `fromIndex: 5 > toIndex: 3`, `nbits < 0: -1`. |
149
- | **`java.time` dates** (ADR 0025) | Supported with limits | `LocalDate` (`of`, `parse`, `ofEpochDay`, `ofYearDay`, `now()` from the browser's clock, the getters, `plus`/`minus` days, weeks, months and years (the day clamped to the month: `2024-01-31` plus a month is `2024-02-29`), `plus(long, ChronoUnit)`, `plus(Period)`, `with…`, `isBefore`/`isAfter`/`isEqual`, `until`, `datesUntil`, `format`, `toString` with the JDK's year signs, `hashCode`, Comparable), `Period` (`between` with the JDK's borrow, `of…`, the getters, `normalized`, `multipliedBy`, `P1Y2M3D`), `DayOfWeek` and `Month` (`of`, `getValue`, `plus`, `minus`, `length`), `ChronoUnit` (`between` for the date units; a time unit is the JDK's `UnsupportedTemporalTypeException: Unsupported unit: Hours`), and `DateTimeFormatter` (`ofPattern` with the date letters `y u M L d D E` and quoted text, `ISO_LOCAL_DATE`). Parsing resolves as the JDK's: an `ofPattern` formatter clamps `31/04` to April 30, `ISO_LOCAL_DATE` rejects `2024-02-30`; the JDK's `DateTimeException` and `DateTimeParseException` messages, with the cause. A switch on `DayOfWeek`, `Month`, `ChronoUnit` or `RoundingMode` takes their constants as labels. Times (`LocalTime`, `LocalDateTime`, `Instant`, `Duration`), time zones, other pattern letters, `getDisplayName` and printing a formatter are unsupported or engine limitations. |
149
+ | **`java.time`** (ADRs 0025, 0029) | Supported with limits | `LocalDate` (`of`, `parse`, `ofEpochDay`, `ofYearDay`, `now()` from the browser's clock, the getters, `plus`/`minus` days, weeks, months and years (the day clamped to the month: `2024-01-31` plus a month is `2024-02-29`), `plus(long, TemporalUnit)`, `plus(TemporalAmount)`, `with…`, `atTime`, `atStartOfDay`, `isBefore`/`isAfter`/`isEqual`, `until`, `datesUntil`, `format`, `toString` with the JDK's year signs, `hashCode`, Comparable). `LocalTime` (`of`, `ofSecondOfDay`, `ofNanoOfDay`, `parse`, `now()`, `MIN`/`MAX`/`MIDNIGHT`/`NOON`, the getters, `plus`/`minus` hours to nanoseconds around the clock, `with…`, `truncatedTo`, `until`, `atDate`, `toSecondOfDay`, `toNanoOfDay`, `format`, `toString` as the JDK's: `09:05`, `01:02:03.400`, `01:02:03.000000007`). `LocalDateTime` (`of` with all its overloads, `parse`, `now()`, the date's and the time's getters and `with…`, `plus`/`minus` from years to nanoseconds with the days carried, `until` that leaves out an incomplete last day, `truncatedTo`, `toLocalDate`/`toLocalTime`, `format`, `2024-01-31T22:30`). `Duration` (`of…`, `between` two times or date-times, `parse`, `plus`/`minus`, `multipliedBy`, `dividedBy`, `negated`, `abs`, `truncatedTo`, `to…` and `to…Part`, `PT2H15M` and `PT-1M-29.5S`, long overflow as the JDK's `ArithmeticException`). `Period` (`between` with the JDK's borrow, `of…`, the getters, `normalized`, `multipliedBy`, `P1Y2M3D`), `DayOfWeek` and `Month` (`of`, `getValue`, `plus`, `minus`, `length`), `ChronoUnit` (`between` for any of the three types; a unit a type does not have is the JDK's `UnsupportedTemporalTypeException: Unsupported unit: Hours`), and `DateTimeFormatter` (`ofPattern` with the letters `y u M L d D E H h k K m s S n a` and quoted text, `ISO_LOCAL_DATE`, `ISO_LOCAL_TIME`, `ISO_LOCAL_DATE_TIME`). The parameter types are the JDK's interfaces (`Temporal`, `TemporalAmount`, `TemporalUnit`, `TemporalAccessor`), which a program can name. Mixing types works as on the JDK: `Duration.between(time, dateTime)` takes the date-time's time, the other way round is `Unable to obtain LocalDateTime from TemporalAccessor`, and `date.plus(duration)` is `Unsupported unit: Seconds`. Parsing resolves as the JDK's: an `ofPattern` formatter clamps `31/04` to April 30, the ISO ones reject `2024-02-30`, `h` needs `a`; the JDK's `DateTimeException` and `DateTimeParseException` messages, with the cause, and helpful `NullPointerException` messages. A switch on `DayOfWeek`, `Month`, `ChronoUnit` or `RoundingMode` takes their constants as labels. `now()` reads the clock to the millisecond (the JDK's to the microsecond). `Instant`, time zones and offsets, other pattern letters, optional sections, `getDisplayName` and printing a formatter are unsupported or engine limitations, as is a parse whose JDK message lists fields it could not resolve (the JDK's order of them changes from run to run). |
150
150
  | `EnumMap`, `EnumSet` | Supported | An enum's constants in ordinal order. `EnumMap(Class)`, `(EnumMap)`, `(Map)` (an empty non-EnumMap is `IllegalArgumentException: Specified map is empty`), with every `Map` method; a null key is the JDK's NPE on `put` and simply absent on `get`, `containsKey` and `remove`. `EnumSet.noneOf`, `allOf`, `of` (one to five constants, or varargs), `range` (`C > A` when reversed), `complementOf`, `copyOf` (`Collection is empty`), `clone`, with every `Set` method plus `removeAll` and `retainAll`; its iterator walks a snapshot, so removing while iterating never fails, as on the JDK. `getClass()` is `java.util.EnumMap` and `java.util.RegularEnumSet` (`JumboEnumSet` above 64 constants). |
151
151
  | `java.math.BigInteger` | Supported | `ZERO`, `ONE`, `TWO`, `TEN`, `valueOf` (sharing -16..16 as the JDK does, so `valueOf(1) == ONE`), `new BigInteger(String[, radix])` with the JDK's messages (`Zero length BigInteger`, `For input string: "x10"` naming the failing digit group, `Radix out of range`, `Illegal embedded sign character`); `add`, `subtract`, `multiply`, `divide`, `remainder`, `mod`, `divideAndRemainder`, `pow`, `modPow`, `modInverse`, `gcd`, `abs`, `negate`, `signum`, `sqrt`, `min`, `max`, `compareTo`, `equals`, `hashCode` (the JDK's), `toString` (any radix), the `…Value` and `…ValueExact` conversions, bit operations (`shiftLeft`, `and`, `testBit`, `bitLength`, `bitCount`, …), `isProbablePrime`, `nextProbablePrime`, with the JDK's `ArithmeticException` messages. `%d`, `%x` and `%o` format it (signed: `-ff`). Comparable, so it sorts and keys TreeMaps; content-equal in HashMaps. Non-ASCII digits are an engine limitation; `probablePrime` and `toByteArray` are unsupported. |
152
152
  | `java.math.BigDecimal`, `RoundingMode`, `MathContext` | Supported | A BigInteger unscaled value and a scale, as the JDK's: `new BigDecimal(String)` (with its messages), `(double)` (the double's exact value: `0.1000000000000000055511151231257827021181583404541015625`), `(int)`, `(long)`, `(BigInteger[, scale])`, `valueOf(double)` (via `Double.toString`), `valueOf(long[, scale])` (sharing 0..10 as the JDK does); `add`, `subtract`, `multiply` (scale rules as documented), `divide` exact (the preferred scale, or the smallest that holds the quotient: `5 / 0.25` is `2E+1`; `Non-terminating decimal expansion; no exact representable decimal result.`), with a scale and `RoundingMode`, or a `MathContext`; `divideToIntegralValue`, `remainder`, `setScale` (`Rounding necessary`), `round`, `sqrt`, `pow`, `movePointLeft`/`Right`, `scaleByPowerOfTen`, `stripTrailingZeros`, `precision`, `unscaledValue`, `compareTo` (by value) and `equals` (value and scale: `1.10` is not `1.1`), `hashCode` (the JDK's), `toString` (scientific when the JDK's is: `1E+2`, `1.234E-7`), `toPlainString`, the conversions. All eight `RoundingMode`s (`values()`, `valueOf`, `name`, `ordinal`) and `MathContext` (`DECIMAL32`, `DECIMAL64`, `DECIMAL128`, `UNLIMITED`, its constructors). `%f`, `%e` and `%g` format a BigDecimal from its exact digits. Scanner's `nextBigInteger` and `nextBigDecimal` read them. The `MathContext` forms of `add` and the other arithmetic, `ulp` and `toEngineeringString` are unsupported. |
153
153
  | `Iterator`, `ListIterator`, `Iterable`, `Collection` | Supported | `hasNext`, `next`, `remove`, with the JDK's `NoSuchElementException`, `IllegalStateException` and `ConcurrentModificationException`; a `ListIterator` adds `hasPrevious`, `previous`, `nextIndex`, `previousIndex`, `set` and `add`. `Collection`'s `removeAll` and `retainAll` on every collection (`UnsupportedOperationException` on the immutable and unmodifiable ones). `parallelStream()` is a parallel stream (*Streams*). `spliterator` is unsupported. |
154
- | `StringBuilder`, `StringBuffer` | Supported | `append` (every supported type, `char[]`, and objects through their `toString()`), `insert`, `delete`, `deleteCharAt`, `replace`, `reverse` (surrogate pairs stay in order), `charAt`, `setCharAt`, `setLength`, `length`, `isEmpty`, `indexOf`, `lastIndexOf`, `substring`, `compareTo`, `equals` and `hashCode` (identity), `toString`, and `capacity`, `ensureCapacity`, `trimToSize` with the JDK's sizes (16, `n`, or a String's length + 16; growing to twice + 2, or what is needed; `append(double)` makes room for 24 chars first, `append(float)` for 15). Constructors `()`, `(int)`, `(String)`. `StringBuffer` has the same methods and its own class. Index errors with the JDK's messages: `Index 10 out of bounds for length 3`, `Range [4, 3) out of bounds for length 3`, `String index out of range: -1`. |
154
+ | `StringBuilder`, `StringBuffer` | Supported | `append` (every supported type, `char[]` and a range of one, a `CharSequence` and a range of one, a `StringBuffer`, and objects through their `toString()`, with javac's overloads), `insert`, `delete`, `deleteCharAt`, `replace`, `reverse` (surrogate pairs stay in order), `charAt`, `setCharAt`, `setLength`, `length`, `isEmpty`, `indexOf`, `lastIndexOf`, `substring`, `compareTo`, `equals` and `hashCode` (identity), `toString`, and `capacity`, `ensureCapacity`, `trimToSize` with the JDK's sizes (16, `n`, or a String's length + 16; growing to twice + 2, or what is needed; `append(double)` makes room for 24 chars first, `append(float)` for 15). Constructors `()`, `(int)`, `(String)`. `StringBuffer` has the same methods and its own class. Index errors with the JDK's messages: `Index 10 out of bounds for length 3`, `Range [4, 3) out of bounds for length 3`, `String index out of range: -1`. |
155
155
  | `Number`, `Integer`, `Long`, `Double`, `Float`, `Byte`, `Short`, `Boolean` methods | Supported with limits | `Number` is the numeric wrappers' superclass, with `byteValue`, `shortValue`, `intValue`, `longValue`, `floatValue` and `doubleValue` (`List<Number>`, `T extends Number`, `List<? extends Number>`; `new Number()` is javac's `Number is abstract; cannot be instantiated`). Statics: `parseInt` and `parseLong` (with a radix), `parseDouble`, `parseBoolean`, `valueOf`, `toString`, `compare`, `max`, `min`, `sum`, `signum`, `bitCount`, `toBinaryString`, `toHexString`, `toOctalString`, `numberOfLeadingZeros`, `numberOfTrailingZeros`, `highestOneBit`, `reverse`, `hashCode`, `isNaN`, `isInfinite`, `isFinite`, `logicalAnd`, `logicalOr`, `logicalXor`. On boxed values: `intValue`, `longValue`, `doubleValue`, `charValue`, `booleanValue`, `isNaN`, `isInfinite`, `compareTo`, `equals`, `hashCode`, `toString`. The JDK's `NumberFormatException` messages: `For input string: "12a"`, `… under radix 16`, `Cannot parse null string`, `empty String`. `Float`: `parseFloat` (rounded once, never through double), `floatToIntBits`, `floatToRawIntBits`, `intBitsToFloat`, and Double's other statics; `Float.valueOf` never caches, as on the JDK. `Byte` and `Short`: `parseByte`/`parseShort` (with a radix; `Value out of range. Value:"128" Radix:10`), `toUnsignedInt`, `toUnsignedLong`, and the caches (every `Byte`, `Short` in -128..127). `parseDouble` and `parseFloat` read hexadecimal strings, and report `multiple points` as the JDK does. |
156
156
  | `Character` methods | Supported with limits | `isLetter`, `isDigit`, `isLetterOrDigit`, `isAlphabetic`, `isUpperCase`, `isLowerCase`, `isWhitespace`, `isSpaceChar`, `toUpperCase`, `toLowerCase` (the `char` and `int` forms), `getNumericValue`, `digit`, `forDigit`, `valueOf`, `toString`, `compare`, `hashCode`, `toChars` (`Not a valid Unicode code point: 0x110000`). Exact for Latin-1 (U+0000 to U+00FF), whose answers were recorded from JDK 25: `é` is a letter, `ÿ` upper-cases to `Ÿ`, and `ß` stays `ß`. Other characters are an engine limitation (SPEC.md §4.2.2). |
157
157
  | `Arrays` | Supported with limits | `toString`, `deepToString`, `sort` (whole or a range, for every primitive array but `boolean[]`, and object arrays; objects in natural order or by a `Comparator`, stably), `fill` (whole or a range), `equals`, `hashCode`, `deepEquals`, `deepHashCode`, `binarySearch`, and `copyOf` and `copyOfRange` (an object array's copy keeps its class: a `String[]` stays a `String[]`). The JDK's exceptions: `fromIndex(2) > toIndex(1)`, `Array index out of range: 4`, `ArrayStoreException: java.lang.Integer`, and `Cannot read the array length because "a" is null`. `asList` is below. `stream` is below. Sorting a primitive array with a comparator is javac's `no suitable method` error. Sorting an object array that contains null is an engine limitation. |
@@ -249,7 +249,7 @@ Where reproducing the JDK would mean guessing, the engine stops instead: `Stoppe
249
249
  | The program | Why the engine stops |
250
250
  | --- | --- |
251
251
  | Iterates over or prints a `HashMap` or `HashSet` of more than one element whose keys are hashed by identity (objects of a class without `hashCode()`, enums, arrays) | The JDK's identity hash codes, and so its order, differ on every run. `LinkedHashMap`/`LinkedHashSet` iterate in insertion order and need no hash codes |
252
- | Iterates over or prints a `Set.of`, `Set.copyOf`, `Map.of` or `Map.copyOf` of more than one element, or a hash table filled from one | The JDK randomizes their order on every run |
252
+ | Iterates over or prints a `Set.of`, `Set.copyOf`, `Map.of` or `Map.copyOf` of objects hashed by identity, or a hash table filled from one | Their layout depends on identity hash codes, which differ on every JDK run |
253
253
  | Iterates over a `HashMap` or `HashSet` after removing keys from a bucket of 9 or more colliding keys, or where such a bucket holds many keys with equal hash codes | The JDK rebalances the bucket's tree (or orders equal hashes by identity); that part of its order is not reproduced |
254
254
  | Changes an `ArrayDeque` while iterating over it | The JDK's result depends on its internal array layout |
255
255
  | Orders objects of its own classes (`PriorityQueue`, `Arrays.sort`) | The JDK's `ClassCastException` names the class loader with an identity hash |
package/README.md CHANGED
@@ -9,7 +9,7 @@ entirely in the reader's browser. No backend, no iframe, no sign-up.
9
9
  **[Live demo →](https://code-playpad.swengr.com)**
10
10
 
11
11
  ```html
12
- <script type="module" src="https://cdn.jsdelivr.net/npm/code-playpad@0.6.0/dist/standalone.js"></script>
12
+ <script type="module" src="https://cdn.jsdelivr.net/npm/code-playpad@0.7.0/dist/standalone.js"></script>
13
13
 
14
14
  <code-playpad height="auto">
15
15
  print("hello from a static page")
@@ -171,28 +171,33 @@ actually sent.
171
171
  | Python | **166.3 KB** | Pyodide, about **6.0 MB** (a 3.3 MB wasm file and a 2.4 MB standard library) | 165.8 KB |
172
172
  | JavaScript | **180.4 KB** | nothing | 179.9 KB |
173
173
  | TypeScript | **227.3 KB** (0.5.2: with the 46.9 KB transform) | nothing (before 0.5.2: Sucrase from esm.sh, 72 KB) | 179.9 KB |
174
- | Java | **277.4 KB** (0.6.0: engine 0.31) | nothing | 216.4 KB |
175
- | Java, with collections | **372.5 KB** (0.6.0) | nothing | 233.2 KB |
176
- | All four | 476.9 KB (0.6.0) | Pyodide | 273.9 KB |
174
+ | Java | **279.8 KB** (0.7.0: engine 0.34) | nothing | 216.4 KB |
175
+ | Java, with collections | **363.4 KB** (0.7.0) | nothing | 233.2 KB |
176
+ | All four | 467.8 KB (0.7.0) | Pyodide | 273.9 KB |
177
177
 
178
178
  - **Every row includes a 144.5 KB shared base:** the editor (CodeMirror) and
179
179
  the widget, the same as in 0.3.0.
180
180
  - **Each language adds:**
181
181
  - Python: 21.7 KB.
182
182
  - JavaScript/TypeScript: 35.9 KB.
183
- - Java: 132.8 KB (the 113.8 KB engine plus 19 KB of Java syntax
183
+ - Java: 135.2 KB (the 116.2 KB engine plus 19 KB of Java syntax
184
184
  highlighting).
185
185
  - The first Java program that uses collections, `StringBuilder` or another
186
- library class also adds the 95.1 KB Java library, once per page.
187
- - The Java figures for 0.6.0 are the 0.4.0 measurements plus what the
188
- engine's two chunks grew by in the build's gzip sizes (engines 0.28 to
189
- 0.31 added the collection staples, library subclasses, the tutorial APIs,
190
- regex, java.time dates and more).
186
+ library class also adds the 83.6 KB Java library, once per page.
187
+ - Since 0.7.0, four parts of the library load only for the first program
188
+ that uses them: `java.time` 11.5 KB, `java.math` 6.7 KB,
189
+ `Pattern`/`Matcher` 2.7 KB and `BitSet` 2.3 KB. The rows above leave
190
+ them out.
191
+ - The Java figures for 0.7.0 are the 0.4.0 measurements plus what the
192
+ engine's two chunks changed by in the build's gzip sizes (engines 0.28
193
+ to 0.34 added the collection staples, library subclasses, the tutorial
194
+ APIs, regex, java.time and more; 0.32 moved the rarely used classes out
195
+ of the library).
191
196
  - **Java grew** from 0.3.0 because the subset did, from basic Java to most of
192
197
  what practice programs use (see the version history). The owner treats
193
198
  download size as secondary to coverage. The package's size checks still
194
- catch accidental growth: 128 KiB for the Java chunk and 96 KiB for its
195
- library.
199
+ catch accidental growth: 128 KiB for the Java chunk, 96 KiB for its
200
+ library and 16 KiB for each part of it.
196
201
  - **Languages load lazily.** A Java page never fetches the Python or
197
202
  JavaScript runtimes, and Python and JavaScript pages never fetch Java. As a
198
203
  result, Python-only and JavaScript-only pages are the same size as in 0.3.0.
@@ -212,7 +217,7 @@ actually sent.
212
217
  ### From a CDN — nothing to install
213
218
 
214
219
  ```html
215
- <script type="module" src="https://cdn.jsdelivr.net/npm/code-playpad@0.6.0/dist/standalone.js"></script>
220
+ <script type="module" src="https://cdn.jsdelivr.net/npm/code-playpad@0.7.0/dist/standalone.js"></script>
216
221
  ```
217
222
 
218
223
  This is the `standalone` build: CodeMirror is bundled in, so a static blog post
@@ -843,9 +848,40 @@ warms every other page on the site.
843
848
 
844
849
  ## Version history
845
850
 
846
- Markup and API written against 0.1.3 still work on 0.6.0, with one exception, in
851
+ Markup and API written against 0.1.3 still work on 0.7.0, with one exception, in
847
852
  0.5.1: an `entry` that names none of a widget's files is now an error.
848
853
 
854
+ ### 0.7.0
855
+
856
+ Java engine 0.31.0 → 0.34.1, each change checked against JDK 25. Nothing
857
+ else changed: Python, JavaScript and TypeScript, the element's API and its
858
+ markup are as in 0.6.0.
859
+
860
+ - **`LocalTime`, `LocalDateTime` and `Duration`.** Times, date-times and
861
+ durations, with the JDK's printing (`09:05`, `2024-01-31T22:30`,
862
+ `PT2H15M`), arithmetic and messages. `DateTimeFormatter` formats and
863
+ parses times (`HH:mm`, `h:mm a`, `ISO_LOCAL_DATE_TIME`).
864
+ - **`Set.of` and `Map.of` print in the JDK's order.** Iterating or printing
865
+ one used to stop as an engine limitation. It now gives one of the orders
866
+ JDK 25 gives, varying between runs as the JDK's does. Sets of objects
867
+ hashed by identity still stop.
868
+ - **A smaller Java library download.** `java.time`, `BigInteger` and
869
+ `BigDecimal`, `Pattern`/`Matcher` and `BitSet` are now chunks of their own.
870
+ Each is loaded only by the first program on a page that uses it (2–12 KB
871
+ gzipped each). The library chunk drops from 95.1 to 83.6 KB gzipped.
872
+ - **Overloaded calls follow javac's rule for open generic arguments.** An
873
+ argument like `stream.collect(groupingBy(f, TreeMap::new, counting()))`
874
+ or `collect(collectingAndThen(toList(), l -> …))` is left open while
875
+ javac chooses an overload, for every method and constructor, the
876
+ program's own included, not only `println`. So calls javac rejects,
877
+ such as `sb.append(…)` of one, now get javac's errors instead of running.
878
+ Ambiguity errors name the same two methods javac names
879
+ (`sb.append(null)`), and `StringBuilder.append` has all of the JDK's
880
+ overloads.
881
+ - **Fully qualified static fields.** `java.math.BigInteger.TWO` and
882
+ `java.time.LocalTime.NOON` work without an import, as static methods
883
+ named that way already did.
884
+
849
885
  ### 0.6.0
850
886
 
851
887
  Java engine 0.27.1 → 0.31.0: the rest of what practice programs commonly use,
package/dist/cdn.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! code-playpad 0.6.0: CDN entry, loads dist/standalone.js of this exact version */
2
- export * from "https://cdn.jsdelivr.net/npm/code-playpad@0.6.0/dist/standalone.js";
1
+ /*! code-playpad 0.7.0: CDN entry, loads dist/standalone.js of this exact version */
2
+ export * from "https://cdn.jsdelivr.net/npm/code-playpad@0.7.0/dist/standalone.js";
@@ -1,4 +1,4 @@
1
- async function e(e){try{return await t(e)}catch(t){return console.warn(`[code-playpad] CodeMirror unavailable, using plain textarea:`,t),n(e)}}async function t(e){let[t,n,r,i,a,o]=await Promise.all([import(`@codemirror/view`),import(`@codemirror/state`),import(`@codemirror/commands`),import(`@codemirror/language`),import(`@codemirror/autocomplete`),import(`@codemirror/theme-one-dark`)]),{EditorView:s,keymap:c,lineNumbers:l,highlightActiveLine:u,highlightActiveLineGutter:d,highlightSpecialChars:f,drawSelection:p,rectangularSelection:m,crosshairCursor:h}=t,{EditorState:g,Compartment:_}=n,{defaultKeymap:v,history:y,historyKeymap:b,indentWithTab:x}=r,{syntaxHighlighting:S,defaultHighlightStyle:C,indentOnInput:w,bracketMatching:T,foldGutter:E,foldKeymap:D}=i,{autocompletion:O,closeBrackets:k,closeBracketsKeymap:A,completionKeymap:j}=a,M=new _,N=new _,P=new _,F=[s.theme({"&":{color:`#1f2328`,backgroundColor:`#ffffff`},".cm-gutters":{backgroundColor:`#f6f8fa`,color:`#8b949e`,border:`none`},".cm-activeLine":{backgroundColor:`#f6f8fa88`},".cm-activeLineGutter":{backgroundColor:`#eaeef2`},".cm-cursor":{borderLeftColor:`#1f2328`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`#cfe3ff`}}),S(C,{fallback:!0})],I=e=>e?o.oneDark:F,L=c.of([{key:`Mod-Enter`,preventDefault:!0,run:()=>(e.onRun?.(),!0)},{key:`Shift-Enter`,preventDefault:!0,run:()=>(e.onRun?.(),!0)}]),R=e.dark,z=e.readOnly,B=e.language??[],V=t=>g.create({doc:t,extensions:[l(),d(),f(),y(),E(),p(),g.allowMultipleSelections.of(!0),w(),T(),k(),O(),m(),h(),u(),L,c.of([...A,...v,...b,...D,...j,x]),s.lineWrapping,P.of(B),M.of(I(R)),N.of(g.readOnly.of(z)),s.updateListener.of(t=>{t.docChanged&&e.onChange?.(t.state.doc.toString())})]}),H=new s({parent:e.parent,state:V(e.doc)}),U=new Map,W=e.name??``;return{fallback:!1,getCode:()=>H.state.doc.toString(),setCode(e){H.dispatch({changes:{from:0,to:H.state.doc.length,insert:e}})},openFile(e,t){if(e===W)return;U.set(W,H.state);let n=U.get(e);H.setState(n??V(t)),W=e,n&&H.dispatch({effects:[M.reconfigure(I(R)),N.reconfigure(g.readOnly.of(z)),P.reconfigure(B)]})},fileCode(e,t){if(e===W)return H.state.doc.toString();let n=U.get(e);return n?n.doc.toString():t},forgetFiles(e){for(let t of[...U.keys()])e.includes(t)||U.delete(t)},setTheme(e){R=e,H.dispatch({effects:M.reconfigure(I(R))})},setReadOnly(e){z=e,H.dispatch({effects:N.reconfigure(g.readOnly.of(z))})},setLanguage(e){B=e,H.dispatch({effects:P.reconfigure(B)})},focus:()=>H.focus(),destroy:()=>H.destroy()}}function n(e){let t=document.createElement(`textarea`);t.className=`cp-fallback-editor`,t.spellcheck=!1,t.value=e.doc,t.readOnly=e.readOnly,t.addEventListener(`input`,()=>e.onChange?.(t.value)),t.addEventListener(`keydown`,t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&(t.preventDefault(),e.onRun?.())}),e.parent.appendChild(t);let n=new Map,r=e.name??``;return{fallback:!0,getCode:()=>t.value,setCode:e=>{t.value=e},openFile(e,i){e!==r&&(n.set(r,t.value),t.value=n.get(e)??i,r=e)},fileCode(e,i){return e===r?t.value:n.get(e)??i},forgetFiles(e){for(let t of[...n.keys()])e.includes(t)||n.delete(t)},setTheme:()=>{},setReadOnly:e=>{t.readOnly=e},setLanguage:()=>{},focus:()=>t.focus(),destroy:()=>t.remove()}}var r=new Map,i=new Map;function a(e,t){r.set(e,t)}function o(){return[...r.keys()]}function s(e){let t=i.get(e);if(t)return t;let n=r.get(e);if(!n)return Promise.reject(Error(`Unknown runtime "${e}". Registered: ${o().join(`, `)||`none`}`));let a=n().catch(t=>{throw i.delete(e),t});return i.set(e,a),a}a(`python`,()=>import(`./pyodide-5mtewJ6F.js`).then(e=>e.pythonRuntime)),a(`javascript`,()=>import(`./javascript-BIBG4Etb.js`).then(e=>e.javascriptRuntime)),a(`typescript`,()=>import(`./javascript-BIBG4Etb.js`).then(e=>e.typescriptRuntime)),a(`java`,()=>import(`./java-xCWvYPkx.js`).then(e=>e.javaRuntime));var c=class extends Error{constructor(e=`Execution stopped`){super(e),this.name=`RunStopped`}},l=class extends Error{constructor(e=`Web Workers are unavailable in this page`){super(e),this.name=`WorkerUnavailable`}},u=new WeakSet,d=String.raw`
1
+ async function e(e){try{return await t(e)}catch(t){return console.warn(`[code-playpad] CodeMirror unavailable, using plain textarea:`,t),n(e)}}async function t(e){let[t,n,r,i,a,o]=await Promise.all([import(`@codemirror/view`),import(`@codemirror/state`),import(`@codemirror/commands`),import(`@codemirror/language`),import(`@codemirror/autocomplete`),import(`@codemirror/theme-one-dark`)]),{EditorView:s,keymap:c,lineNumbers:l,highlightActiveLine:u,highlightActiveLineGutter:d,highlightSpecialChars:f,drawSelection:p,rectangularSelection:m,crosshairCursor:h}=t,{EditorState:g,Compartment:_}=n,{defaultKeymap:v,history:y,historyKeymap:b,indentWithTab:x}=r,{syntaxHighlighting:S,defaultHighlightStyle:C,indentOnInput:w,bracketMatching:T,foldGutter:E,foldKeymap:D}=i,{autocompletion:O,closeBrackets:k,closeBracketsKeymap:A,completionKeymap:j}=a,M=new _,N=new _,P=new _,F=[s.theme({"&":{color:`#1f2328`,backgroundColor:`#ffffff`},".cm-gutters":{backgroundColor:`#f6f8fa`,color:`#8b949e`,border:`none`},".cm-activeLine":{backgroundColor:`#f6f8fa88`},".cm-activeLineGutter":{backgroundColor:`#eaeef2`},".cm-cursor":{borderLeftColor:`#1f2328`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`#cfe3ff`}}),S(C,{fallback:!0})],I=e=>e?o.oneDark:F,L=c.of([{key:`Mod-Enter`,preventDefault:!0,run:()=>(e.onRun?.(),!0)},{key:`Shift-Enter`,preventDefault:!0,run:()=>(e.onRun?.(),!0)}]),R=e.dark,z=e.readOnly,B=e.language??[],V=t=>g.create({doc:t,extensions:[l(),d(),f(),y(),E(),p(),g.allowMultipleSelections.of(!0),w(),T(),k(),O(),m(),h(),u(),L,c.of([...A,...v,...b,...D,...j,x]),s.lineWrapping,P.of(B),M.of(I(R)),N.of(g.readOnly.of(z)),s.updateListener.of(t=>{t.docChanged&&e.onChange?.(t.state.doc.toString())})]}),H=new s({parent:e.parent,state:V(e.doc)}),U=new Map,W=e.name??``;return{fallback:!1,getCode:()=>H.state.doc.toString(),setCode(e){H.dispatch({changes:{from:0,to:H.state.doc.length,insert:e}})},openFile(e,t){if(e===W)return;U.set(W,H.state);let n=U.get(e);H.setState(n??V(t)),W=e,n&&H.dispatch({effects:[M.reconfigure(I(R)),N.reconfigure(g.readOnly.of(z)),P.reconfigure(B)]})},fileCode(e,t){if(e===W)return H.state.doc.toString();let n=U.get(e);return n?n.doc.toString():t},forgetFiles(e){for(let t of[...U.keys()])e.includes(t)||U.delete(t)},setTheme(e){R=e,H.dispatch({effects:M.reconfigure(I(R))})},setReadOnly(e){z=e,H.dispatch({effects:N.reconfigure(g.readOnly.of(z))})},setLanguage(e){B=e,H.dispatch({effects:P.reconfigure(B)})},focus:()=>H.focus(),destroy:()=>H.destroy()}}function n(e){let t=document.createElement(`textarea`);t.className=`cp-fallback-editor`,t.spellcheck=!1,t.value=e.doc,t.readOnly=e.readOnly,t.addEventListener(`input`,()=>e.onChange?.(t.value)),t.addEventListener(`keydown`,t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&(t.preventDefault(),e.onRun?.())}),e.parent.appendChild(t);let n=new Map,r=e.name??``;return{fallback:!0,getCode:()=>t.value,setCode:e=>{t.value=e},openFile(e,i){e!==r&&(n.set(r,t.value),t.value=n.get(e)??i,r=e)},fileCode(e,i){return e===r?t.value:n.get(e)??i},forgetFiles(e){for(let t of[...n.keys()])e.includes(t)||n.delete(t)},setTheme:()=>{},setReadOnly:e=>{t.readOnly=e},setLanguage:()=>{},focus:()=>t.focus(),destroy:()=>t.remove()}}var r=new Map,i=new Map;function a(e,t){r.set(e,t)}function o(){return[...r.keys()]}function s(e){let t=i.get(e);if(t)return t;let n=r.get(e);if(!n)return Promise.reject(Error(`Unknown runtime "${e}". Registered: ${o().join(`, `)||`none`}`));let a=n().catch(t=>{throw i.delete(e),t});return i.set(e,a),a}a(`python`,()=>import(`./pyodide-CdDlM0du.js`).then(e=>e.pythonRuntime)),a(`javascript`,()=>import(`./javascript-CSfl5gbA.js`).then(e=>e.javascriptRuntime)),a(`typescript`,()=>import(`./javascript-CSfl5gbA.js`).then(e=>e.typescriptRuntime)),a(`java`,()=>import(`./java-DIL6bxPF.js`).then(e=>e.javaRuntime));var c=class extends Error{constructor(e=`Execution stopped`){super(e),this.name=`RunStopped`}},l=class extends Error{constructor(e=`Web Workers are unavailable in this page`){super(e),this.name=`WorkerUnavailable`}},u=new WeakSet,d=String.raw`
2
2
  :host {
3
3
  --cp-bg: #ffffff;
4
4
  --cp-fg: #1f2328;
package/dist/element.js CHANGED
@@ -1 +1 @@
1
- import{n as e,t}from"./element-9sv2r5Jv.js";export{t as CodePlayPadElement,e as defineCodePlayPad};
1
+ import{n as e,t}from"./element-DaStU7U7.js";export{t as CodePlayPadElement,e as defineCodePlayPad};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,f as r,h as i,i as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./element-9sv2r5Jv.js";import{n as m,o as h,r as g,t as _}from"./config-D9w0xYhX.js";export{f as CodePlayPadElement,_ as PYODIDE_VERSION,p as RunStopped,n as WorkerUnavailable,u as allProgress,a as clearSnippet,m as configurePython,g as configureTypeScript,i as createEditor,s as defineCodePlayPad,e as getProgress,r as getRuntime,l as listRuntimes,c as loadSnippet,h as pyodideAssetUrls,o as registerRuntime,d as saveSnippet,t as setProgress};
1
+ import{a as e,c as t,d as n,f as r,h as i,i as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./element-DaStU7U7.js";import{n as m,o as h,r as g,t as _}from"./config-D9w0xYhX.js";export{f as CodePlayPadElement,_ as PYODIDE_VERSION,p as RunStopped,n as WorkerUnavailable,u as allProgress,a as clearSnippet,m as configurePython,g as configureTypeScript,i as createEditor,s as defineCodePlayPad,e as getProgress,r as getRuntime,l as listRuntimes,c as loadSnippet,h as pyodideAssetUrls,o as registerRuntime,d as saveSnippet,t as setProgress};