Skip to content

Access manager #2

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

Merged
merged 2 commits into from
Jun 1, 2023
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: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Files and directories created by pub
.dart_tool/
.packages
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock

Expand All @@ -12,10 +11,7 @@ pubspec.lock
doc/api/

# Avoid committing generated Javascript files:
*.dart.js
*.info.json # Produced by the --dump-info flag.
*.js # When generated by dart2js. Don't specify *.js if your
# project includes source files written in JavaScript.
*.js_
*.js.deps
*.js.map
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ cd flutter_sdk_tutorial
flutter packages get
```

- Add your pub/sub keys to `app_state.dart` which can be found in the `\lib\utils` directory.
- Add your pub/sub keys to `keys.dart` which can be found in the `\lib\utils` directory.

- Run the application in Chrome: `flutter run -d chrome`. You can also run the app with any target device you have configured Flutter for, for example an Android emulator or iPhone simulator.

Expand Down
1 change: 0 additions & 1 deletion flutter_sdk_tutorial/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ migrate_working_dir/
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"inputs":[],"outputs":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"inputs":[],"outputs":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"inputs":[],"outputs":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"packages/cupertino_icons/assets/CupertinoIcons.ttf":["packages/cupertino_icons/assets/CupertinoIcons.ttf"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"family":"MaterialIcons","fonts":[{"asset":"fonts/MaterialIcons-Regular.otf"}]},{"family":"packages/cupertino_icons/CupertinoIcons","fonts":[{"asset":"packages/cupertino_icons/assets/CupertinoIcons.ttf"}]}]
17,041 changes: 17,041 additions & 0 deletions flutter_sdk_tutorial/build/flutter_assets/NOTICES

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions flutter_sdk_tutorial/build/web/.last_build_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c3081ada40b8aad21981c9b91bfc51f1
1 change: 1 addition & 0 deletions flutter_sdk_tutorial/build/web/assets/AssetManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"packages/cupertino_icons/assets/CupertinoIcons.ttf":["packages/cupertino_icons/assets/CupertinoIcons.ttf"]}
1 change: 1 addition & 0 deletions flutter_sdk_tutorial/build/web/assets/FontManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"family":"MaterialIcons","fonts":[{"asset":"fonts/MaterialIcons-Regular.otf"}]},{"family":"packages/cupertino_icons/CupertinoIcons","fonts":[{"asset":"packages/cupertino_icons/assets/CupertinoIcons.ttf"}]}]
17,041 changes: 17,041 additions & 0 deletions flutter_sdk_tutorial/build/web/assets/NOTICES

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
281 changes: 281 additions & 0 deletions flutter_sdk_tutorial/build/web/canvaskit/canvaskit.js

Large diffs are not rendered by default.

Binary file not shown.
21 changes: 21 additions & 0 deletions flutter_sdk_tutorial/build/web/canvaskit/profiling/canvaskit.js

Large diffs are not rendered by default.

Binary file not shown.
Binary file added flutter_sdk_tutorial/build/web/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions flutter_sdk_tutorial/build/web/features.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"features": [
"Send a message",
"Receive a message (You might need to open a new tab)",
"Change your friendly name",
"Be in a chat with 3 or more people"
]
}
157 changes: 157 additions & 0 deletions flutter_sdk_tutorial/build/web/flutter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
* This script installs service_worker.js to provide PWA functionality to
* application. For more information, see:
* https://developers.google.com/web/fundamentals/primers/service-workers
*/

if (!_flutter) {
var _flutter = {};
}
_flutter.loader = null;

(function() {
"use strict";
class FlutterLoader {
/**
* Creates a FlutterLoader, and initializes its instance methods.
*/
constructor() {
// TODO: Move the below methods to "#private" once supported by all the browsers
// we support. In the meantime, we use the "revealing module" pattern.

// Watchdog to prevent injecting the main entrypoint multiple times.
this._scriptLoaded = null;

// Resolver for the pending promise returned by loadEntrypoint.
this._didCreateEngineInitializerResolve = null;

// Called by Flutter web.
// Bound to `this` now, so "this" is preserved across JS <-> Flutter jumps.
this.didCreateEngineInitializer = this._didCreateEngineInitializer.bind(this);
}

/**
* Initializes the main.dart.js with/without serviceWorker.
* @param {*} options
* @returns a Promise that will eventually resolve with an EngineInitializer,
* or will be rejected with the error caused by the loader.
*/
loadEntrypoint(options) {
const {
entrypointUrl = "main.dart.js",
serviceWorker,
} = (options || {});
return this._loadWithServiceWorker(entrypointUrl, serviceWorker);
}

/**
* Resolves the promise created by loadEntrypoint.
* Called by Flutter through the public `didCreateEngineInitializer` method,
* which is bound to the correct instance of the FlutterLoader on the page.
* @param {*} engineInitializer
*/
_didCreateEngineInitializer(engineInitializer) {
if (typeof this._didCreateEngineInitializerResolve != "function") {
console.warn("Do not call didCreateEngineInitializer by hand. Start with loadEntrypoint instead.");
}
this._didCreateEngineInitializerResolve(engineInitializer);
// Remove the public method after it's done, so Flutter Web can hot restart.
delete this.didCreateEngineInitializer;
}

_loadEntrypoint(entrypointUrl) {
if (!this._scriptLoaded) {
this._scriptLoaded = new Promise((resolve, reject) => {
let scriptTag = document.createElement("script");
scriptTag.src = entrypointUrl;
scriptTag.type = "application/javascript";
// Cache the resolve, so it can be called from Flutter.
// Note: Flutter hot restart doesn't re-create this promise, so this
// can only be called once. Instead, we need to model this as a stream
// of `engineCreated` events coming from Flutter that are handled by JS.
this._didCreateEngineInitializerResolve = resolve;
scriptTag.addEventListener("error", reject);
document.body.append(scriptTag);
});
}

return this._scriptLoaded;
}

_waitForServiceWorkerActivation(serviceWorker, entrypointUrl) {
if (!serviceWorker || serviceWorker.state == "activated") {
if (!serviceWorker) {
console.warn("Cannot activate a null service worker. Falling back to plain <script> tag.");
} else {
console.debug("Service worker already active.");
}
return this._loadEntrypoint(entrypointUrl);
}
return new Promise((resolve, _) => {
serviceWorker.addEventListener("statechange", () => {
if (serviceWorker.state == "activated") {
console.debug("Installed new service worker.");
resolve(this._loadEntrypoint(entrypointUrl));
}
});
});
}

_loadWithServiceWorker(entrypointUrl, serviceWorkerOptions) {
if (!("serviceWorker" in navigator) || serviceWorkerOptions == null) {
console.warn("Service worker not supported (or configured). Falling back to plain <script> tag.", serviceWorkerOptions);
return this._loadEntrypoint(entrypointUrl);
}

const {
serviceWorkerVersion,
timeoutMillis = 4000,
} = serviceWorkerOptions;

let serviceWorkerUrl = "flutter_service_worker.js?v=" + serviceWorkerVersion;
let loader = navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {
if (!reg.active && (reg.installing || reg.waiting)) {
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
let sw = reg.installing || reg.waiting;
return this._waitForServiceWorkerActivation(sw, entrypointUrl);
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console.debug("New service worker available.");
return reg.update().then((reg) => {
console.debug("Service worker updated.");
let sw = reg.installing || reg.waiting || reg.active;
return this._waitForServiceWorkerActivation(sw, entrypointUrl);
});
} else {
// Existing service worker is still good.
console.debug("Loading app from service worker.");
return this._loadEntrypoint(entrypointUrl);
}
});

// Timeout race promise
let timeout;
if (timeoutMillis > 0) {
timeout = new Promise((resolve, _) => {
setTimeout(() => {
if (!this._scriptLoaded) {
console.warn("Failed to load app from service worker. Falling back to plain <script> tag.");
resolve(this._loadEntrypoint(entrypointUrl));
}
}, timeoutMillis);
});
}

return Promise.race([loader, timeout]);
}
}

_flutter.loader = new FlutterLoader();
}());
Loading