yourjs-box 1.8.0 → 1.9.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.
- package/README.md +27 -13
- package/dist/yourjs-box.full.js +199 -25
- package/dist/yourjs-box.js +7 -7
- package/dist/yourjs-box.min.js +7 -7
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Worker or the page itself. TypeScript works too.
|
|
|
7
7
|
**[Live demo](https://westc.github.io/yourjs-box/)** ·
|
|
8
8
|
[Examples](https://westc.github.io/yourjs-box/examples/)
|
|
9
9
|
|
|
10
|
-

|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
@@ -35,6 +35,9 @@ script is also available from unpkg at
|
|
|
35
35
|
A comment line that ends with `\\` is a header. Headers split the code into
|
|
36
36
|
blocks which are run one at a time each time the run button is clicked (or
|
|
37
37
|
<kbd>Ctrl</kbd>/<kbd>Cmd</kbd>+<kbd>Enter</kbd> is pressed in the editor).
|
|
38
|
+
<kbd>Ctrl</kbd>/<kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>Enter</kbd> (or **Run all
|
|
39
|
+
blocks** in the **⋯** menu) runs all of the remaining blocks, one after
|
|
40
|
+
another and in order with any hidden blocks.
|
|
38
41
|
|
|
39
42
|
Hovering over code that already ran shows a "Copy to editor" button which
|
|
40
43
|
copies that code into the editor so that it can be run again, as is or modified.
|
|
@@ -43,8 +46,8 @@ If the editor already has code in it you are asked before it is replaced.
|
|
|
43
46
|
### Toolbar
|
|
44
47
|
|
|
45
48
|
- The **⋯** button opens a menu (see below).
|
|
46
|
-
- **Clear** removes everything from the
|
|
47
|
-
`console.clear()`.
|
|
49
|
+
- **Clear** (or <kbd>Ctrl</kbd>+<kbd>L</kbd>) removes everything from the
|
|
50
|
+
console. Code can also call `console.clear()`.
|
|
48
51
|
- The **layout** button switches between showing the editor beside or below
|
|
49
52
|
the console.
|
|
50
53
|
- **Full screen** shows the console using the whole screen. If the browser
|
|
@@ -62,6 +65,7 @@ If the editor already has code in it you are asked before it is replaced.
|
|
|
62
65
|
code that hasn't been run yet comes back. Hidden blocks aren't in the
|
|
63
66
|
history.
|
|
64
67
|
- The **⋯** menu has:
|
|
68
|
+
- **Run all blocks**, which runs all of the remaining blocks.
|
|
65
69
|
- **Text size**, which is remembered for every console on the same site.
|
|
66
70
|
- **Open**, which loads a JavaScript (or TypeScript) file as the code that the console starts
|
|
67
71
|
with (its hidden blocks are hidden and Reset goes back to it).
|
|
@@ -78,7 +82,7 @@ If the editor already has code in it you are asked before it is replaced.
|
|
|
78
82
|
- **Reset**, which clears the console and puts the original code back into
|
|
79
83
|
the editor. In worker mode this also stops any code that is still running
|
|
80
84
|
(eg. an infinite loop) by starting a new worker.
|
|
81
|
-
- **About
|
|
85
|
+
- **About YourJS Box**
|
|
82
86
|
|
|
83
87
|
### Right-Clicking Values
|
|
84
88
|
|
|
@@ -219,7 +223,7 @@ npm install vue@3.5.43 ace-builds@1.44.0 prismjs@1.30.0 prism-themes@1.9.0 acorn
|
|
|
219
223
|
npm install @babel/standalone@7.29.9
|
|
220
224
|
```
|
|
221
225
|
|
|
222
|
-
The About window lists the versions that each version of
|
|
226
|
+
The About window lists the versions that each version of YourJS Box uses.
|
|
223
227
|
|
|
224
228
|
### Console Functions
|
|
225
229
|
|
|
@@ -228,6 +232,22 @@ The About window lists the versions that each version of JS Box uses.
|
|
|
228
232
|
`timeLog()`, `timeEnd()`, `trace()`, `group()`, `groupCollapsed()`,
|
|
229
233
|
`groupEnd()` and `clear()` are all shown in the console.
|
|
230
234
|
|
|
235
|
+
Like the browser's console, the first argument can use format specifiers:
|
|
236
|
+
`%s` (string), `%d` or `%i` (integer), `%f` (number), `%o` and `%O` (a value
|
|
237
|
+
that can be expanded), `%c` (CSS styles for the text after it) and `%%` (a
|
|
238
|
+
percent sign). For example:
|
|
239
|
+
|
|
240
|
+
```js
|
|
241
|
+
console.log('%cHello%c, %s!', 'color: white; background: #1a73e8; padding: 2px 6px; border-radius: 4px', '', 'world');
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Like the browser, `%c` only allows CSS for things like colors, fonts, borders,
|
|
245
|
+
margins and padding, and never anything that loads a URL.
|
|
246
|
+
|
|
247
|
+
A message that is the same as the one logged right before it is shown once with
|
|
248
|
+
a count instead of being repeated. Messages that include objects are always
|
|
249
|
+
shown again since the objects may have changed.
|
|
250
|
+
|
|
231
251
|
### Loading
|
|
232
252
|
|
|
233
253
|
Like `<img loading="lazy">`, a console isn't loaded until it is about to be
|
|
@@ -327,6 +347,8 @@ Install the development dependencies by running `npm install`.
|
|
|
327
347
|
`--dry-run` to see what it would do or `--skip-tests` to skip the tests.
|
|
328
348
|
- `npm run record-demo` records `demo.gif` (shown at the top of this README)
|
|
329
349
|
from the built files. It needs [ffmpeg](https://ffmpeg.org/).
|
|
350
|
+
- `npm run og-image` makes `og-image.png` (the picture shown when the landing
|
|
351
|
+
page is shared) from the built files.
|
|
330
352
|
- `npm run purge-cdn` purges jsDelivr's cache so that URLs like
|
|
331
353
|
`yourjs-box@1` point to the latest version right away.
|
|
332
354
|
- In VS Code, **Terminal → Run Task…** has tasks for all of these
|
|
@@ -343,15 +365,7 @@ The options are kept in the URL so the page can be reloaded or shared as is.
|
|
|
343
365
|
|
|
344
366
|
Ideas for future versions, roughly from easiest to hardest:
|
|
345
367
|
|
|
346
|
-
- **Format specifiers:** support `%s`, `%d`, `%i`, `%f`, `%o`, `%O` and `%c`
|
|
347
|
-
(CSS styles) in `console.log()` and the other logging functions.
|
|
348
|
-
- **Repeated messages:** show identical messages logged in a row once with a
|
|
349
|
-
count, like the browser's console.
|
|
350
|
-
- **Run all:** run every remaining block with <kbd>Ctrl</kbd> /
|
|
351
|
-
<kbd>⌘</kbd> + <kbd>Shift</kbd> + <kbd>Enter</kbd> or from the
|
|
352
|
-
**⋯** menu.
|
|
353
368
|
- **`data-autorun`:** run every visible block when the page loads.
|
|
354
|
-
- **Clear shortcut:** clear the console with <kbd>Ctrl</kbd> + <kbd>L</kbd>.
|
|
355
369
|
- **Autocomplete:** turn on Ace's keyword and snippet completion in the editor.
|
|
356
370
|
- **`data-remember`:** save the editor's code and history in the browser so
|
|
357
371
|
that they are still there after a reload.
|