diff --git a/lib/src/capabilities_json.dart b/lib/src/capabilities_json.dart new file mode 100644 index 0000000..2d71919 --- /dev/null +++ b/lib/src/capabilities_json.dart @@ -0,0 +1,227 @@ +const capabilitiesJson = ''' +{ + "profiles": { + "default": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "Unknown", + "7": "Unknown", + "8": "Unknown", + "11": "CP851", + "12": "CP853", + "13": "CP857", + "14": "CP737", + "15": "ISO_8859-7", + "16": "CP1252", + "17": "CP866", + "18": "CP852", + "19": "CP858", + "20": "Unknown", + "21": "CP874", + "22": "Unknown", + "23": "Unknown", + "24": "Unknown", + "25": "Unknown", + "26": "Unknown", + "30": "TCVN-3-1", + "31": "TCVN-3-2", + "32": "CP720", + "33": "CP775", + "34": "CP855", + "35": "CP861", + "36": "CP862", + "37": "CP864", + "38": "CP869", + "39": "ISO_8859-2", + "40": "ISO_8859-15", + "41": "CP1098", + "42": "CP774", + "43": "CP772", + "44": "CP1125", + "45": "CP1250", + "46": "CP1251", + "47": "CP1253", + "48": "CP1254", + "49": "CP1255", + "50": "CP1256", + "51": "CP1257", + "52": "CP1258", + "53": "RK1048", + "66": "Unknown", + "67": "Unknown", + "68": "Unknown", + "69": "Unknown", + "70": "Unknown", + "71": "Unknown", + "72": "Unknown", + "73": "Unknown", + "74": "Unknown", + "75": "Unknown", + "82": "Unknown", + "254": "Unknown", + "255": "Unknown" + }, + "vendor": "Generic", + "model": "Default", + "description": "Default ESC/POS profile" + }, + + "XP-N160I": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "CP1252", + "7": "CP737", + "8": "CP862", + "9": "Unknown", + "10": "Unknown", + "16": "CP1252", + "17": "CP866", + "18": "CP852", + "19": "CP858", + "20": "Unknown", + "21": "Unknown", + "22": "Unknown", + "23": "Unknown", + "24": "CP747", + "25": "CP1257", + "27": "CP1258", + "28": "CP864", + "29": "CP1001", + "30": "Unknown", + "31": "Unknown", + "32": "CP1255", + "50": "CP437", + "51": "CP932", + "52": "CP437", + "53": "CP858", + "54": "CP858", + "55": "CP860", + "56": "CP861", + "57": "CP863", + "58": "CP865", + "59": "CP866", + "60": "CP855", + "61": "CP857", + "62": "CP862", + "63": "CP864", + "64": "CP737", + "65": "CP851", + "66": "CP869", + "67": "CP928", + "68": "CP772", + "69": "CP774", + "70": "CP874", + "71": "CP1252", + "72": "CP1250", + "73": "CP1251", + "74": "CP3840", + "75": "CP3841", + "76": "CP3843", + "77": "CP3844", + "78": "CP3845", + "79": "CP3846", + "80": "CP3847", + "81": "CP3848", + "82": "CP1001", + "83": "CP2001", + "84": "CP3001", + "85": "CP3002", + "86": "CP3011", + "87": "CP3012", + "88": "CP3021", + "89": "CP3041" + }, + "vendor": "Xprinter", + "model": "XP-N160I", + "description": "" + }, + + "RP80USE": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "CP1251", + "7": "CP866", + "8": "Unknown", + "9": "Unknown", + "10": "Unknown", + "15": "CP862", + "16": "CP1252", + "17": "CP1253", + "18": "CP852", + "19": "CP858", + "20": "Unknown", + "21": "Unknown", + "22": "CP864", + "23": "ISO_8859-1", + "24": "CP737", + "25": "CP1257", + "26": "Unknown", + "27": "CP720", + "28": "CP855", + "29": "CP857", + "30": "CP1250", + "31": "CP775", + "32": "CP1254", + "34": "CP1256", + "35": "CP1258", + "36": "ISO_8859-2", + "37": "ISO_8859-3", + "38": "ISO_8859-4", + "39": "ISO_8859-5", + "40": "ISO_8859-6", + "41": "ISO_8859-7", + "42": "ISO_8859-8", + "43": "ISO_8859-9", + "44": "ISO_8859-15", + "45": "Unknown", + "46": "CP856", + "47": "CP874" + }, + "vendor": "Rongta", + "model": "RP80USE", + "description": "" + }, + + "TP806L": { + "codePages": { + "0": "PC437", + "1": "Katakana", + "2": "PC850", + "3": "PC860", + "4": "PC863", + "5": "PC865", + "13": "PC857", + "14": "PC737", + "15": "ISO8859-7", + "16": "WPC1252", + "17": "PC866", + "18": "PC852", + "19": "PC858", + "20": "KU42", + "32": "PC720", + "37": "PC864", + "50": "WPC1256", + "63": "ISO-8859-6" + }, + "vendor": "HPRT", + "model": "TP806L", + "description": "" + } + } +} +'''; \ No newline at end of file diff --git a/lib/src/capability_profile.dart b/lib/src/capability_profile.dart index 019bae2..84b5d0f 100644 --- a/lib/src/capability_profile.dart +++ b/lib/src/capability_profile.dart @@ -7,8 +7,9 @@ */ import 'dart:convert' show json; -import 'dart:convert' show utf8; -import 'package:flutter/services.dart' show rootBundle; + +import 'package:esc_pos_utils/src/capabilities_json.dart'; +// import 'package:flutter/services.dart' show rootBundle; class CodePage { CodePage(this.id, this.name); @@ -21,8 +22,7 @@ class CapabilityProfile { /// Public factory static Future load({String name = 'default'}) async { - final content = await rootBundle - .loadString('packages/esc_pos_utils/resources/capabilities.json'); + final content = capabilitiesJson; Map capabilities = json.decode(content); var profile = capabilities['profiles'][name]; @@ -48,16 +48,11 @@ class CapabilityProfile { throw Exception("The CapabilityProfile isn't initialized"); } - return codePages - .firstWhere((cp) => cp.name == codePage, - orElse: () => throw Exception( - "Code Page '$codePage' isn't defined for this profile")) - .id; + return codePages.firstWhere((cp) => cp.name == codePage, orElse: () => throw Exception("Code Page '$codePage' isn't defined for this profile")).id; } static Future> getAvailableProfiles() async { - final content = await rootBundle - .loadString('packages/esc_pos_utils/resources/capabilities.json'); + final content = capabilitiesJson; Map capabilities = json.decode(content); var profiles = capabilities['profiles']; diff --git a/pubspec.lock b/pubspec.lock index 3447480..2c6e9c5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,72 +5,74 @@ packages: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: a92e39b291073bb840a72cf43d96d2a63c74e9a485d227833e8ea0054d16ad16 + url: "https://pub.dev" source: hosted version: "3.1.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.17.1" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c + url: "https://pub.dev" source: hosted version: "3.0.1" csslib: dependency: transitive description: name: csslib - url: "https://pub.dartlang.org" + sha256: f857285c8dc0b4f2f77b49a1c083ff8c75223a7549de20f3e607df58cf497a43 + url: "https://pub.dev" source: hosted version: "0.17.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -85,56 +87,80 @@ packages: dependency: "direct main" description: name: gbk_codec - url: "https://pub.dartlang.org" + sha256: "3af5311fc9393115e3650ae6023862adf998051a804a08fb804f042724999f61" + url: "https://pub.dev" source: hosted version: "0.4.0" hex: dependency: "direct main" description: name: hex - url: "https://pub.dartlang.org" + sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a" + url: "https://pub.dev" source: hosted version: "0.2.0" html: dependency: transitive description: name: html - url: "https://pub.dartlang.org" + sha256: bfef906cbd4e78ef49ae511d9074aebd1d2251482ef601a280973e8b58b51bbf + url: "https://pub.dev" source: hosted version: "0.15.0" image: dependency: "direct main" description: name: image - url: "https://pub.dartlang.org" + sha256: bb9f31e29110ca9ed55d371256d0dab5ee622896aca7330d007fc1a36aaba732 + url: "https://pub.dev" source: hosted version: "3.0.5" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" + source: hosted + version: "0.12.15" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.3" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: b1e35bcd00e0ab63a4883d7d76461da7477dcac3ab82fa0ab894be729d579032 + url: "https://pub.dev" source: hosted version: "4.3.0" sky_engine: @@ -146,64 +172,73 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "0.4.3" + version: "0.5.1" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: "78bc0a9ed038e65944b95f4c5d3a72a607d63e1a9f1e8281fa0cfe9d2811c279" + url: "https://pub.dev" source: hosted version: "5.3.0" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0"