diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json
index 367ed03..8939996 100644
--- a/.dart_tool/package_config.json
+++ b/.dart_tool/package_config.json
@@ -1,6 +1,66 @@
{
"configVersion": 2,
"packages": [
+ {
+ "name": "args",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/args-2.7.0",
+ "packageUri": "lib/",
+ "languageVersion": "3.3"
+ },
+ {
+ "name": "collection",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/collection-1.19.1",
+ "packageUri": "lib/",
+ "languageVersion": "3.4"
+ },
+ {
+ "name": "import_sorter",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/import_sorter-4.6.0",
+ "packageUri": "lib/",
+ "languageVersion": "2.12"
+ },
+ {
+ "name": "path",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/path-1.9.1",
+ "packageUri": "lib/",
+ "languageVersion": "3.4"
+ },
+ {
+ "name": "source_span",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/source_span-1.10.1",
+ "packageUri": "lib/",
+ "languageVersion": "3.1"
+ },
+ {
+ "name": "string_scanner",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/string_scanner-1.4.1",
+ "packageUri": "lib/",
+ "languageVersion": "3.1"
+ },
+ {
+ "name": "term_glyph",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/term_glyph-1.2.2",
+ "packageUri": "lib/",
+ "languageVersion": "3.1"
+ },
+ {
+ "name": "tint",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/tint-2.0.1",
+ "packageUri": "lib/",
+ "languageVersion": "2.18"
+ },
+ {
+ "name": "web",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/web-1.1.1",
+ "packageUri": "lib/",
+ "languageVersion": "3.4"
+ },
+ {
+ "name": "yaml",
+ "rootUri": "file:///Users/christianpauly/.pub-cache/hosted/pub.dev/yaml-3.1.3",
+ "packageUri": "lib/",
+ "languageVersion": "3.4"
+ },
{
"name": "web_multiple_tab_detector",
"rootUri": "../",
@@ -8,7 +68,9 @@
"languageVersion": "2.12"
}
],
- "generated": "2022-02-16T08:12:09.964550Z",
"generator": "pub",
- "generatorVersion": "2.16.1"
+ "generatorVersion": "3.10.4",
+ "flutterRoot": "file:///Users/christianpauly/develop/flutter",
+ "flutterVersion": "3.38.5",
+ "pubCache": "file:///Users/christianpauly/.pub-cache"
}
diff --git a/.dart_tool/package_graph.json b/.dart_tool/package_graph.json
new file mode 100644
index 0000000..c6548c5
--- /dev/null
+++ b/.dart_tool/package_graph.json
@@ -0,0 +1,82 @@
+{
+ "roots": [
+ "web_multiple_tab_detector"
+ ],
+ "packages": [
+ {
+ "name": "web_multiple_tab_detector",
+ "version": "0.3.0",
+ "dependencies": [
+ "web"
+ ],
+ "devDependencies": [
+ "import_sorter"
+ ]
+ },
+ {
+ "name": "import_sorter",
+ "version": "4.6.0",
+ "dependencies": [
+ "args",
+ "tint",
+ "yaml"
+ ]
+ },
+ {
+ "name": "web",
+ "version": "1.1.1",
+ "dependencies": []
+ },
+ {
+ "name": "tint",
+ "version": "2.0.1",
+ "dependencies": []
+ },
+ {
+ "name": "yaml",
+ "version": "3.1.3",
+ "dependencies": [
+ "collection",
+ "source_span",
+ "string_scanner"
+ ]
+ },
+ {
+ "name": "string_scanner",
+ "version": "1.4.1",
+ "dependencies": [
+ "source_span"
+ ]
+ },
+ {
+ "name": "source_span",
+ "version": "1.10.1",
+ "dependencies": [
+ "collection",
+ "path",
+ "term_glyph"
+ ]
+ },
+ {
+ "name": "term_glyph",
+ "version": "1.2.2",
+ "dependencies": []
+ },
+ {
+ "name": "path",
+ "version": "1.9.1",
+ "dependencies": []
+ },
+ {
+ "name": "collection",
+ "version": "1.19.1",
+ "dependencies": []
+ },
+ {
+ "name": "args",
+ "version": "2.7.0",
+ "dependencies": []
+ }
+ ],
+ "configVersion": 1
+}
\ No newline at end of file
diff --git a/.dart_tool/pub/bin/import_sorter/main.dart-3.10.4.snapshot b/.dart_tool/pub/bin/import_sorter/main.dart-3.10.4.snapshot
new file mode 100644
index 0000000..f82c168
Binary files /dev/null and b/.dart_tool/pub/bin/import_sorter/main.dart-3.10.4.snapshot differ
diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml
new file mode 100644
index 0000000..a3e84f8
--- /dev/null
+++ b/.github/workflows/integrate.yml
@@ -0,0 +1,27 @@
+name: Continious Integration
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ merge_group:
+
+concurrency:
+ group: ${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ dart:
+ permissions:
+ contents: read
+ uses: famedly/frontend-ci-templates/.github/workflows/dart.yml@main
+ with:
+ env_file: ".github/workflows/versions.env"
+ secrets:
+ ssh_key: "${{ secrets.CI_SSH_PRIVATE_KEY }}"
+
+ general:
+ permissions:
+ contents: read
+ uses: famedly/frontend-ci-templates/.github/workflows/general.yml@main
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index 92a7abd..0000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-name: Add issues to Product Management Project.
-
-on:
- issues:
- types:
- - opened
-
-jobs:
- add-to-project:
- name: Add issue to project
- runs-on: ubuntu-latest
- steps:
- - uses: actions/add-to-project@v0.5.0
- with:
- # You can target a repository in a different organization
- # to the issue
- project-url: https://github.com/orgs/famedly/projects/4
- github-token: ${{ secrets.ADD_ISSUE_TO_PROJECT_PAT }}
diff --git a/.github/workflows/versions.env b/.github/workflows/versions.env
new file mode 100644
index 0000000..c65fc3a
--- /dev/null
+++ b/.github/workflows/versions.env
@@ -0,0 +1 @@
+dart_version=3.10.4
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
deleted file mode 100644
index 688dab7..0000000
--- a/.gitlab-ci.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-image:
- name: registry.gitlab.com/famedly/containers/flutter-dockerimages:stable
-
-variables:
- GIT_SUBMODULE_STRATEGY: recursive
-
-stages:
-- coverage
-- publish
-
-code_analyze:
- stage: coverage
- script:
- - flutter format lib/ --set-exit-if-changed
- - flutter analyze
diff --git a/lib/src/web.dart b/lib/src/web.dart
index b92b033..a8f6712 100644
--- a/lib/src/web.dart
+++ b/lib/src/web.dart
@@ -16,9 +16,11 @@
* along with this program. If not, see .
*/
-import 'dart:html';
+import 'dart:js_interop';
import 'dart:math';
+import 'package:web/web.dart' as web;
+
String randomString([int length = 50]) {
var result = '';
final chars = 'abcdefghijklmnopqrstuvwxyz-_1234567890=';
@@ -32,7 +34,7 @@ String randomString([int length = 50]) {
int getTabs(String name) {
try {
- final n = int.parse(window.localStorage[name]!);
+ final n = int.parse(web.window.localStorage.getItem(name)!);
return n < 0 ? 0 : n;
} catch (_) {
return 0;
@@ -40,7 +42,7 @@ int getTabs(String name) {
}
void setTabs(String name, int number) {
- window.localStorage[name] = number.toString();
+ web.window.localStorage.setItem(name, number.toString());
}
bool _pongReceived = false;
@@ -50,22 +52,26 @@ void register(String name) {
_instanceId = randomString();
setTabs(name, getTabs(name) + 1);
- window.onUnload.listen((_) {
+ void onunloadCallback(web.Event event) {
setTabs(name, getTabs(name) - 1);
- });
+ }
+
+ web.window.onunload = onunloadCallback.toJS;
- window.onStorage.listen((evt) {
+ void onStorageCallback(web.StorageEvent evt) {
if (evt.key == '$name-ping') {
final val = evt.newValue!;
if (val.split('|')[0] != _instanceId) {
- window.localStorage['$name-pong'] =
- _instanceId + '|' + DateTime.now().toString();
+ web.window.localStorage.setItem(
+ '$name-pong', _instanceId + '|' + DateTime.now().toString());
}
}
if (evt.key == '$name-pong') {
_pongReceived = true;
}
- });
+ }
+
+ web.window.onstorage = onStorageCallback.toJS;
}
Future isSingleTab(String name) async {
@@ -74,8 +80,8 @@ Future isSingleTab(String name) async {
return true;
}
// send ping to other tabs
- window.localStorage['$name-ping'] =
- _instanceId + '|' + DateTime.now().toString();
+ web.window.localStorage
+ .setItem('$name-ping', _instanceId + '|' + DateTime.now().toString());
int counter = 100;
while (!_pongReceived && counter > 0) {
await Future.delayed(Duration(milliseconds: 50));
diff --git a/pubspec.yaml b/pubspec.yaml
index 019d3d3..a406033 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -6,3 +6,7 @@ repository: https://gitlab.com/famedly/libraries/web_multiple_tab_detector
environment:
sdk: ">=2.12.0 <3.0.0"
+dependencies:
+ web: ^1.1.1
+dev_dependencies:
+ import_sorter: ^4.6.0