node-turbo 1.2.6 → 1.3.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024-2025 Walter Krivanek
3
+ Copyright (c) 2024-2026 Walter Krivanek
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -55,11 +55,11 @@ node-turbo has been tested with 100% code coverage with the following engines/li
55
55
 
56
56
  | Name | Version(s) |
57
57
  | :--- | :--- |
58
- | [Hotwire Turbo](https://turbo.hotwired.dev/) | 7.3.0 - 8.0.18 |
58
+ | [Hotwire Turbo](https://turbo.hotwired.dev/) | 7.3.0 - 8.0.23 |
59
59
  | [Node.js](https://nodejs.org/) | 16.6 - 22.20.0 |
60
- | [Koa](https://koajs.com/) | 2.14.2 - 3.0.1 |
61
- | [Express](https://expressjs.com/) | 4.18.2 - 5.1.0 |
62
- | [ws](https://github.com/websockets/ws) | 8.15.1 - 8.18.3 |
60
+ | [Koa](https://koajs.com/) | 2.14.2 - 3.1.2 |
61
+ | [Express](https://expressjs.com/) | 4.18.2 - 5.2.1 |
62
+ | [ws](https://github.com/websockets/ws) | 8.15.1 - 8.19.0 |
63
63
 
64
64
  ## API docs
65
65
  See [`/docs/API.md`](./docs/API.md) for a documentation of all node-turbo classes and functions.
@@ -216,15 +216,15 @@ Result:
216
216
 
217
217
  ##### Using the Node.js streams API
218
218
  If you want to use the [Node.js streams API](https://nodejs.org/docs/latest/api/stream.html) with Turbo Streams, you can
219
- create a Readable stream instance which reads Turbo Stream messages.
219
+ create a `PassThrough` stream instance which reads Turbo Stream messages.
220
220
 
221
221
  ```javascript
222
222
  import { TurboStream } from 'node-turbo';
223
223
 
224
224
  const ts = new TurboStream();
225
- const readable = ts.createReadableStream();
225
+ const nStream = ts.createNodeStream();
226
226
 
227
- readable.pipe(process.stdout);
227
+ nStream.pipe(process.stdout);
228
228
 
229
229
  // These elements get piped immediately:
230
230
  ts
@@ -459,9 +459,9 @@ const wss = new WebSocketServer({ port: 8080 });
459
459
 
460
460
  wss.on('connection', function connection(ws) {
461
461
  const ts = new TurboStream();
462
- const readable = ts.createReadableStream();
462
+ const nStream = ts.createNodeStream();
463
463
  const wsStream = createWebSocketStream(ws, { encoding: 'utf8' });
464
- readable.pipe(wsStream);
464
+ nStream.pipe(wsStream);
465
465
 
466
466
  ts
467
467
  .append('target-id', '<p>My content</p>')
@@ -508,8 +508,8 @@ const httpServer = http.createServer((req, res) => {
508
508
 
509
509
  // You can also use the streams API.
510
510
  setTimeout(() => {
511
- const stream = ssets.createReadableStream();
512
- stream.pipe(res);
511
+ const nStream = ssets.createNodeStream();
512
+ nStream.pipe(res);
513
513
  ssets.prependAll('.stream', '<p>Prepend!</p>');
514
514
  }, 2000);
515
515
 
@@ -529,7 +529,7 @@ const httpServer = http.createServer((req, res) => {
529
529
  padding: 10px;
530
530
  }
531
531
  </style>
532
- <script type="module" src="https://unpkg.com/@hotwired/turbo@8.0.12/dist/turbo.es2017-esm.js"></script>
532
+ <script type="module" src="https://unpkg.com/@hotwired/turbo@8.0.23/dist/turbo.es2017-esm.js"></script>
533
533
  <script>
534
534
  var eventSource = new EventSource('/sse');
535
535
  eventSource.onmessage = function(event) {
@@ -616,7 +616,7 @@ app.use(async (ctx, next) => {
616
616
  padding: 10px;
617
617
  }
618
618
  </style>
619
- <script type="module" src="https://unpkg.com/@hotwired/turbo@8.0.12/dist/turbo.es2017-esm.js"></script>
619
+ <script type="module" src="https://unpkg.com/@hotwired/turbo@8.0.23/dist/turbo.es2017-esm.js"></script>
620
620
  <script>
621
621
  var eventSource = new EventSource('/sse');
622
622
  eventSource.onmessage = function(event) {
@@ -693,7 +693,7 @@ app.get('/', async (req, res) => {
693
693
  padding: 10px;
694
694
  }
695
695
  </style>
696
- <script type="module" src="https://unpkg.com/@hotwired/turbo@8.0.12/dist/turbo.es2017-esm.js"></script>
696
+ <script type="module" src="https://unpkg.com/@hotwired/turbo@8.0.23/dist/turbo.es2017-esm.js"></script>
697
697
  <script>
698
698
  var eventSource = new EventSource('/sse');
699
699
  eventSource.onmessage = function(event) {
@@ -720,4 +720,4 @@ app.listen(config.port);
720
720
  ```
721
721
  ## License
722
722
 
723
- node-turbo is © 2024-2025 Walter Krivanek and released under the [MIT license](https://mit-license.org).
723
+ node-turbo is © 2024-2026 Walter Krivanek and released under the [MIT license](https://mit-license.org).
package/docs/API.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # node-turbo API documentation
2
2
 
3
- Version 1.2.6
3
+ Version 1.3.0
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -26,7 +26,7 @@ Version 1.2.6
26
26
  - [turbostream.flush()](#turbostreamflush)
27
27
  - [turbostream.custom(action, target, content)](#turbostreamcustomaction-target-content)
28
28
  - [turbostream.customAll(action, targets, content)](#turbostreamcustomallaction-targets-content)
29
- - [turbostream.createReadableStream(opts, opts.continuous, streamOptions)](#turbostreamcreatereadablestreamopts-optscontinuous-streamoptions)
29
+ - [turbostream.createNodeStream(opts, streamOptions)](#turbostreamcreatenodestreamopts-streamoptions)
30
30
  - [turbostream.append(targetOrAttributes, content)](#turbostreamappendtargetorattributes-content)
31
31
  - [turbostream.appendAll(targetsOrAttributes, content)](#turbostreamappendalltargetsorattributes-content)
32
32
  - [turbostream.prepend(targetOrAttributes, content)](#turbostreamprependtargetorattributes-content)
@@ -54,7 +54,7 @@ Version 1.2.6
54
54
  - [turboelement.renderAttributesAsHtml()](#turboelementrenderattributesashtml)
55
55
  - [turboelement.validate()](#turboelementvalidate)
56
56
  - [turboelement.render()](#turboelementrender)
57
- - [Class: TurboReadable](#class-turboreadable)
57
+ - [Class: TurboReadable (deprecated)](#class-turboreadable)
58
58
  - [new TurboReadable(turboStream[, opts])](#new-turboreadableturbostream-opts)
59
59
  - [turboreadable._turboStream](#turboreadable_turbostream)
60
60
  - [turboreadable._boundPush](#turboreadable_boundpush)
@@ -92,7 +92,7 @@ Version 1.2.6
92
92
  - [sseturbostream.eventName](#sseturbostreameventname)
93
93
  - [sseturbostream.render()](#sseturbostreamrender)
94
94
  - [sseturbostream.renderSseEvent(raw)](#sseturbostreamrendersseeventraw)
95
- - [sseturbostream.createReadableStream()](#sseturbostreamcreatereadablestream)
95
+ - [sseturbostream.createNodeStream()](#sseturbostreamcreatenodestream)
96
96
  - [sseturbostream.event(eventName)](#sseturbostreameventeventname)
97
97
  - [node-turbo/errors](#node-turboerrors)
98
98
  - [Class: ValidationError](#class-validationerror)
@@ -271,16 +271,16 @@ Adds a Turbo Stream Element with a custom action, targeting multiple DOM element
271
271
 
272
272
  Returns: {TurboStream} The instance for chaining.
273
273
 
274
- #### turbostream.createReadableStream(opts, opts.continuous, streamOptions)
274
+ #### turbostream.createNodeStream(opts, streamOptions)
275
275
 
276
276
  - `opts` {Object<String, String>} The options for stream creation.
277
- - `opts.continuous` {Boolean} If true, a TurboReadable instance is returned.
278
- If false, a readable stream created from the buffered items is returned.
277
+ - `opts.continuous` {Boolean} If true, a {node:stream~PassThrough} instance is returned.
278
+ If false, a {node:stream~Readable} created from the buffered items is returned.
279
279
  - `streamOptions` {Object<String, String>} The options for the readable stream itself.
280
280
 
281
- Creates a readable stream.
281
+ Creates either a {node:stream~Readable} or {node:stream~PassThrough} stream instance.
282
282
 
283
- Returns: {stream.Readable | TurboReadable} Either a readable stream or a TurboReadable instance.
283
+ Returns: {node:stream~Readable | {node:stream~PassThrough}} Either a readable stream or a TurboReadable instance.
284
284
 
285
285
  #### turbostream.append(targetOrAttributes, content)
286
286
 
@@ -510,6 +510,9 @@ Render function to implement.
510
510
 
511
511
  ### Class: TurboReadable
512
512
 
513
+ > [!WARNING]
514
+ > Deprecated since v1.3.0!
515
+
513
516
  ```javascript
514
517
  import { TurboReadable } from 'node-turbo';
515
518
  ```
@@ -688,7 +691,7 @@ Adds the element to the buffer, if config.buffer === true.
688
691
  Fires the event 'element' with the added element.
689
692
  > - clear()
690
693
  Clears the buffer.
691
- > - createReadableStream(opts, opts.continuous, streamOptions)
694
+ > - createNodeStream(opts, streamOptions)
692
695
  Creates a readable stream.
693
696
  > - custom(action, target, content)
694
697
  Adds a Turbo Stream Element with a custom action.
@@ -752,7 +755,7 @@ Adds the element to the buffer, if config.buffer === true.
752
755
  Fires the event 'element' with the added element.
753
756
  > - clear()
754
757
  Clears the buffer.
755
- > - createReadableStream(opts, opts.continuous, streamOptions)
758
+ > - createNodeStream(opts, streamOptions)
756
759
  Creates a readable stream.
757
760
  > - custom(action, target, content)
758
761
  Adds a Turbo Stream Element with a custom action.
@@ -851,7 +854,7 @@ Adds the element to the buffer, if config.buffer === true.
851
854
  Fires the event 'element' with the added element.
852
855
  > - clear()
853
856
  Clears the buffer.
854
- > - createReadableStream(opts, opts.continuous, streamOptions)
857
+ > - createNodeStream(opts, streamOptions)
855
858
  Creates a readable stream.
856
859
  > - custom(action, target, content)
857
860
  Adds a Turbo Stream Element with a custom action.
@@ -942,15 +945,15 @@ Returns: {String | null} The rendered SSE or null if there were no elements in t
942
945
 
943
946
  - `raw` {String} The raw HTML string.
944
947
 
945
- Takes a HTML fragment string and converts it to an SSE event message.
948
+ Takes an HTML fragment string and converts it to an SSE event message.
946
949
 
947
950
  Returns: {String | null} The converted SSE event message or null if no string has been passed.
948
951
 
949
- #### sseturbostream.createReadableStream()
952
+ #### sseturbostream.createNodeStream()
950
953
 
951
- Creates a {TurboReadable} instance, which pipes to a {node:stream~Transform} to add SSE specific syntax.
954
+ Creates a {node:stream~PassThrough} instance, which passes Turbo Stream elements through as SSE messages.
952
955
 
953
- Returns: {node:stream.Transform} The Transform stream instance.
956
+ Returns: {node:stream~PassThrough} The PassThrough stream instance.
954
957
 
955
958
  #### sseturbostream.event(eventName)
956
959
 
@@ -1050,4 +1053,4 @@ Gets thrown when invalid attributes are discovered.
1050
1053
 
1051
1054
  ***
1052
1055
 
1053
- node-turbo is © 2024-2025 by Walter Krivanek and released under the [MIT license](https://mit-license.org).
1056
+ node-turbo is © 2024-2026 by Walter Krivanek and released under the [MIT license](https://mit-license.org).