Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Restructure project for single import #97

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions example/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'dart:async';
import 'dart:convert';

import 'package:stomp_dart_client/stomp.dart';
import 'package:stomp_dart_client/stomp_config.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';

void onConnect(StompFrame frame) {
stompClient.subscribe(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/_connect_api.dart → lib/src/connect_api.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'dart:async';

import 'package:stomp_dart_client/stomp_config.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

import 'stomp_config.dart';

Future<WebSocketChannel> connect(StompConfig config) {
throw UnsupportedError('No implementation of the connect api provided');
}
3 changes: 2 additions & 1 deletion lib/src/_connect_html.dart → lib/src/connect_html.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';
import 'dart:html';

import 'package:stomp_dart_client/stomp_config.dart';
import 'package:web_socket_channel/html.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

import 'stomp_config.dart';

Future<WebSocketChannel> connect(StompConfig config) {
final completer = Completer<HtmlWebSocketChannel>();
final webSocket = WebSocket(config.connectUrl)
Expand Down
3 changes: 2 additions & 1 deletion lib/src/_connect_io.dart → lib/src/connect_io.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';
import 'dart:io';

import 'package:stomp_dart_client/stomp_config.dart';
import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

import 'stomp_config.dart';

Future<WebSocketChannel> connect(StompConfig config) async {
try {
var webSocket = WebSocket.connect(
Expand Down
2 changes: 1 addition & 1 deletion lib/parser.dart → lib/src/parser.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:stomp_dart_client/stomp_frame.dart';
import 'stomp_frame.dart';

abstract class Parser {
late bool escapeHeaders;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:stomp_dart_client/parser.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
import 'package:stomp_dart_client/stomp_parser.dart';
import '../parser.dart';
import '../stomp_frame.dart';
import '../stomp_parser.dart';

class SockJSParser implements Parser {
SockJSParser({
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/stomp.dart → lib/src/stomp.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'dart:async';
import 'dart:typed_data';

import 'package:stomp_dart_client/stomp_config.dart';
import 'package:stomp_dart_client/stomp_exception.dart';
import 'package:stomp_dart_client/stomp_handler.dart';
import 'stomp_config.dart';
import 'stomp_exception.dart';
import 'stomp_handler.dart';

class StompClient {
StompClient({required this.config});
Expand Down
4 changes: 2 additions & 2 deletions lib/stomp_config.dart → lib/src/stomp_config.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';

import 'package:stomp_dart_client/sock_js/sock_js_utils.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
import 'sock_js/sock_js_utils.dart';
import 'stomp_frame.dart';

typedef StompFrameCallback = void Function(StompFrame);
typedef StompBeforeConnectCallback = Future<void> Function();
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 10 additions & 9 deletions lib/stomp_handler.dart → lib/src/stomp_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import 'dart:async';
import 'dart:math';
import 'dart:typed_data';

import 'package:stomp_dart_client/parser.dart';
import 'package:stomp_dart_client/sock_js/sock_js_parser.dart';
import 'package:stomp_dart_client/stomp_config.dart';
import 'package:stomp_dart_client/stomp_exception.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
import 'package:stomp_dart_client/stomp_parser.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

import 'src/_connect_api.dart'
if (dart.library.html) 'src/_connect_html.dart'
if (dart.library.io) 'src/_connect_io.dart' as platform;
import 'parser.dart';
import 'sock_js/sock_js_parser.dart';
import 'stomp_config.dart';
import 'stomp_exception.dart';
import 'stomp_frame.dart';
import 'stomp_parser.dart';

import 'connect_api.dart'
if (dart.library.html) 'connect_html.dart'
if (dart.library.io) 'connect_io.dart' as platform;

typedef StompUnsubscribe = void Function({
Map<String, String>? unsubscribeHeaders,
Expand Down
6 changes: 3 additions & 3 deletions lib/stomp_parser.dart → lib/src/stomp_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:stomp_dart_client/parser.dart';
import 'package:stomp_dart_client/stomp_config.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
import 'stomp_config.dart';
import 'stomp_frame.dart';
import 'parser.dart';

typedef _ParseByteFunction = void Function(int);

Expand Down
9 changes: 9 additions & 0 deletions lib/stomp_dart_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export 'src/parser.dart';
export 'src/stomp_config.dart';
export 'src/stomp_exception.dart';
export 'src/stomp_frame.dart';
export 'src/stomp_handler.dart';
export 'src/stomp_parser.dart';
export 'src/stomp.dart';
export 'src/sock_js/sock_js_parser.dart';
export 'src/sock_js/sock_js_utils.dart';
3 changes: 1 addition & 2 deletions test/sock_js_parser_test.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:convert';

import 'package:stomp_dart_client/sock_js/sock_js_parser.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:test/test.dart';

void main() {
Expand Down
2 changes: 1 addition & 1 deletion test/sock_js_utils_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:stomp_dart_client/sock_js/sock_js_utils.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:test/test.dart';

void main() {
Expand Down
9 changes: 5 additions & 4 deletions test/stomp_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import 'dart:async';
import 'package:test/test.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

import 'package:stomp_dart_client/stomp_config.dart';
import 'package:stomp_dart_client/src/_connect_api.dart'
if (dart.library.html) '../lib/src/_connect_html.dart'
if (dart.library.io) '../lib/src/_connect_io.dart' as platform;
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:stomp_dart_client/src/connect_api.dart'
if (dart.library.html) 'package:stomp_dart_client/src/connect_html.dart'
if (dart.library.io) 'package:stomp_dart_client/src/connect_io.dart'
as platform;

void main() {
group('StompConfig', () {
Expand Down
7 changes: 2 additions & 5 deletions test/stomp_handler_test.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'dart:async';

import 'package:stomp_dart_client/stomp_config.dart';
import 'package:stomp_dart_client/stomp_exception.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
import 'package:stomp_dart_client/stomp_handler.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';

Expand All @@ -22,7 +19,7 @@ void main() {
import 'dart:async';
import 'dart:convert';
import 'package:web_socket_channel/io.dart';
import 'package:stomp_dart_client/stomp_parser.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:stream_channel/stream_channel.dart';

Future<void> hybridMain(StreamChannel channel) async {
Expand Down
3 changes: 1 addition & 2 deletions test/stomp_parser_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:stomp_dart_client/stomp_frame.dart';
import 'package:stomp_dart_client/stomp_parser.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:test/test.dart';

void main() {
Expand Down
16 changes: 6 additions & 10 deletions test/stomp_test.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import 'dart:async';

import 'package:stomp_dart_client/stomp.dart';
import 'package:stomp_dart_client/stomp_config.dart';
import 'package:stomp_dart_client/stomp_exception.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
import 'package:stomp_dart_client/stomp_handler.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';

Expand All @@ -21,9 +17,9 @@ void main() {
import 'dart:async';
import 'dart:convert';
import 'package:web_socket_channel/io.dart';
import 'package:stomp_dart_client/stomp_parser.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:stream_channel/stream_channel.dart';

Future<void> hybridMain(StreamChannel channel) async {
final server = await HttpServer.bind("localhost", 0);
server.transform(WebSocketTransformer()).listen((webSocket) {
Expand All @@ -40,7 +36,7 @@ void main() {
"MESSAGE\nsubscription:${frame.headers['id']}\nmessage-id:123\ndestination:/foo\n\nThis is the message body\x00");
} else if (frame.headers['destination'] == '/bar') {
webSocketChannel.sink.add(utf8.encode(
"MESSAGE\nsubscription:${frame.headers['id']}\nmessage-id:123\ndestination:/bar\n\nThis is the message body\x00"));
"MESSAGE\nsubscription:${frame.headers['id']}\nmessage-id:123\ndestination:/bar\n\nThis is the message body\x00"));
}
} else if (frame.command == 'UNSUBSCRIBE' ||
frame.command == 'SEND') {
Expand Down Expand Up @@ -94,9 +90,9 @@ void main() {
import 'dart:async';
import 'dart:convert';
import 'package:web_socket_channel/io.dart';
import 'package:stomp_dart_client/stomp_parser.dart';
import 'package:stomp_dart_client/stomp_dart_client.dart';
import 'package:stream_channel/stream_channel.dart';

Future<void> hybridMain(StreamChannel channel) async {
final server = await HttpServer.bind("localhost", 0);
server.transform(WebSocketTransformer()).listen((webSocket) {
Expand Down
Loading