expo-task-manager 57.0.22 → 57.0.23
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/CHANGELOG.md +6 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/taskManager/TaskService.java +14 -1
- package/build/TaskManager.d.ts.map +1 -1
- package/build/TaskManager.js +6 -4
- package/build/TaskManager.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/{57.0.22/expo.modules.taskmanager-57.0.22-sources.jar → 57.0.23/expo.modules.taskmanager-57.0.23-sources.jar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/{57.0.22/expo.modules.taskmanager-57.0.22.aar → 57.0.23/expo.modules.taskmanager-57.0.23.aar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/{57.0.22/expo.modules.taskmanager-57.0.22.module → 57.0.23/expo.modules.taskmanager-57.0.23.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/{57.0.22/expo.modules.taskmanager-57.0.22.pom → 57.0.23/expo.modules.taskmanager-57.0.23.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.23/expo.modules.taskmanager-57.0.23.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/maven-metadata.xml.sha512 +1 -1
- package/package.json +4 -4
- package/src/TaskManager.ts +6 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/57.0.22/expo.modules.taskmanager-57.0.22.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 57.0.23 — 2026-11-12
|
|
14
|
+
|
|
15
|
+
### 💡 Others
|
|
16
|
+
|
|
17
|
+
- [Android] Fix JS timers, and anything built on them such as `fetch()`, hanging in background tasks on React Native 0.86 and later. The headless task that keeps timers alive no longer finishes as soon as it starts. ([#51306](https://github.com/expo/expo/pull/51306) by [@zocario](https://github.com/zocario))
|
|
18
|
+
|
|
13
19
|
## 57.0.22 — 2026-11-05
|
|
14
20
|
|
|
15
21
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'host.exp.exponent'
|
|
7
|
-
version = '57.0.
|
|
7
|
+
version = '57.0.23'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.taskmanager"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 23
|
|
13
|
-
versionName "57.0.
|
|
13
|
+
versionName "57.0.23"
|
|
14
14
|
consumerProguardFiles 'proguard-rules.pro'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -58,6 +58,9 @@ public class TaskService implements SingletonModule, TaskServiceInterface {
|
|
|
58
58
|
private static final String TAG = "TaskService";
|
|
59
59
|
private static final String SHARED_PREFERENCES_NAME = "TaskManagerModule";
|
|
60
60
|
private static final int MAX_TASK_EXECUTION_TIME_MS = 15000; // 15 seconds
|
|
61
|
+
// Upper bound for the headless task that keeps JS timers alive, in case no finish path runs.
|
|
62
|
+
// Matches the 10 minutes JobScheduler gives a job.
|
|
63
|
+
private static final long HEADLESS_TASK_TIMEOUT_MS = 10 * 60 * 1000;
|
|
61
64
|
|
|
62
65
|
private WeakReference<Context> mContextRef;
|
|
63
66
|
private TaskManagerUtilsInterface mTaskManagerUtils;
|
|
@@ -431,6 +434,7 @@ public class TaskService implements SingletonModule, TaskServiceInterface {
|
|
|
431
434
|
success -> {
|
|
432
435
|
if (!success) {
|
|
433
436
|
sEvents.remove(appScopeKey);
|
|
437
|
+
maybeFinishHeadlessTask(appScopeKey);
|
|
434
438
|
mTasksAndEventsRepository.removeEvents(appScopeKey);
|
|
435
439
|
|
|
436
440
|
// Host unreachable? Unregister all tasks for that app.
|
|
@@ -651,11 +655,20 @@ public class TaskService implements SingletonModule, TaskServiceInterface {
|
|
|
651
655
|
HeadlessJsTaskConfig taskConfig = new HeadlessJsTaskConfig(
|
|
652
656
|
"expo-task-manager",
|
|
653
657
|
new WritableNativeMap(),
|
|
654
|
-
|
|
658
|
+
HEADLESS_TASK_TIMEOUT_MS, // finished by maybeFinishHeadlessTask, the timeout is a safety net
|
|
655
659
|
true // allow in foreground to avoid exceptions if app returns
|
|
656
660
|
);
|
|
657
661
|
|
|
658
662
|
UiThreadUtil.runOnUiThread(() -> {
|
|
663
|
+
// The events may be done already, e.g. when the cold-start listener fires late.
|
|
664
|
+
if (!sEvents.containsKey(appScopeKey)) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
// Don't replace a keepalive that is still running, its ID would never be finished.
|
|
668
|
+
Integer runningTaskId = sHeadlessTaskIds.get(appScopeKey);
|
|
669
|
+
if (runningTaskId != null && headlessContext.isTaskRunning(runningTaskId)) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
659
672
|
try {
|
|
660
673
|
int taskId = headlessContext.startTask(taskConfig);
|
|
661
674
|
sHeadlessTaskIds.put(appScopeKey, taskId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskManager.d.ts","sourceRoot":"","sources":["../src/TaskManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TaskManager.d.ts","sourceRoot":"","sources":["../src/TaskManager.ts"],"names":[],"mappings":"AAeA;;;GAG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GD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAO7F;AAGD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAM1E;AAGD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOzE;AAGD;;;;GAIG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM7D;AAoCD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEzD"}
|
package/build/TaskManager.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { LegacyEventEmitter, Platform, UnavailabilityError } from 'expo-modules-core';
|
|
2
2
|
import { AppRegistry } from 'react-native';
|
|
3
3
|
import ExpoTaskManager from './ExpoTaskManager';
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// On Android, TaskService starts this headless task in native code to keep JS timers
|
|
5
|
+
// alive during background task execution, and finishes it natively once the task is done
|
|
6
|
+
// (or after a timeout).
|
|
7
|
+
// The JS side must never settle: a resolved promise makes AppRegistry call
|
|
8
|
+
// notifyTaskFinished, which ends the task right away and pauses timers again.
|
|
7
9
|
if (Platform.OS === 'android') {
|
|
8
|
-
AppRegistry.registerHeadlessTask('expo-task-manager', () =>
|
|
10
|
+
AppRegistry.registerHeadlessTask('expo-task-manager', () => () => new Promise(() => { }));
|
|
9
11
|
}
|
|
10
12
|
const tasks = new Map();
|
|
11
13
|
function _validate(taskName) {
|
package/build/TaskManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskManager.js","sourceRoot":"","sources":["../src/TaskManager.ts"],"names":[],"mappings":"AAAA,OAAO,EA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AM,EAAE,CAAC,CAAC;YAC7E,yFAAyF;YACzF,mGAAmG;YACnG,MAAM,eAAe,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,eAAe,CAAC,gBAAgB,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import { LegacyEventEmitter, Platform, UnavailabilityError } from 'expo-modules-core';\nimport { AppRegistry } from 'react-native';\n\nimport ExpoTaskManager from './ExpoTaskManager';\n\n// Register a no-op headless task so that HeadlessJsTaskContext.startTask()\n// doesn't log a warning. On Android, TaskService registers a headless task\n// in native code to keep JS timers alive during background task execution.\nif (Platform.OS === 'android') {\n AppRegistry.registerHeadlessTask('expo-task-manager', () => async () => {});\n}\n\n// @needsAudit @docsMissing\n/**\n * Error object that can be received through [`TaskManagerTaskBody`](#taskmanagertaskbody) when the\n * task fails.\n */\nexport interface TaskManagerError {\n code: string | number;\n message: string;\n}\n\n// @needsAudit\n/**\n * Represents the object that is passed to the task executor.\n */\nexport interface TaskManagerTaskBody<T = unknown> {\n /**\n * An object of data passed to the task executor. Its properties depend on the type of the task.\n */\n data: T;\n\n /**\n * Error object if the task failed or `null` otherwise.\n */\n error: TaskManagerError | null;\n\n /**\n * Additional details containing unique ID of task event and name of the task.\n */\n executionInfo: TaskManagerTaskBodyExecutionInfo;\n}\n\n// @needsAudit\n/**\n * Additional details about execution provided in `TaskManagerTaskBody`.\n */\nexport interface TaskManagerTaskBodyExecutionInfo {\n /**\n * State of the application.\n * @platform ios\n */\n appState?: 'active' | 'background' | 'inactive';\n /**\n * Unique ID of task event.\n */\n eventId: string;\n /**\n * Name of the task.\n */\n taskName: string;\n}\n\n// @needsAudit\n/**\n * Represents an already registered task.\n */\nexport interface TaskManagerTask {\n /**\n * Name that the task is registered with.\n */\n taskName: string;\n\n /**\n * Type of the task which depends on how the task was registered.\n */\n taskType: string;\n\n /**\n * Provides `options` that the task was registered with.\n */\n options: any;\n}\n\n/**\n * @deprecated Use `TaskManagerTask` instead.\n * @hidden\n */\nexport interface RegisteredTask extends TaskManagerTask {}\n\n// @needsAudit\n/**\n * Type of task executor – a function that handles the task.\n */\nexport type TaskManagerTaskExecutor<T = any> = (body: TaskManagerTaskBody<T>) => Promise<any>;\n\nconst tasks: Map<string, TaskManagerTaskExecutor<any>> = new Map<\n string,\n TaskManagerTaskExecutor<any>\n>();\n\nfunction _validate(taskName: unknown) {\n if (!taskName || typeof taskName !== 'string') {\n throw new TypeError('`taskName` must be a non-empty string.');\n }\n}\n\n// @needsAudit\n/**\n * Defines task function. It must be called in the global scope of your JavaScript bundle.\n * In particular, it cannot be called in any of React lifecycle methods like `componentDidMount`.\n * This limitation is due to the fact that when the application is launched in the background,\n * we need to spin up your JavaScript app, run your task and then shut down — no views are mounted\n * in this scenario.\n *\n * @param taskName Name of the task. It must be the same as the name you provided when registering the task.\n * @param taskExecutor A function that will be invoked when the task with given `taskName` is executed.\n */\nexport function defineTask<T = unknown>(\n taskName: string,\n taskExecutor: TaskManagerTaskExecutor<T>\n) {\n if (!taskName || typeof taskName !== 'string') {\n console.warn(`TaskManager.defineTask: 'taskName' argument must be a non-empty string.`);\n return;\n }\n if (!taskExecutor || typeof taskExecutor !== 'function') {\n console.warn(`TaskManager.defineTask: 'task' argument must be a function.`);\n return;\n }\n tasks.set(taskName, taskExecutor);\n}\n\n// @needsAudit\n/**\n * Checks whether the task is already defined.\n *\n * @param taskName Name of the task.\n */\nexport function isTaskDefined(taskName: string): boolean {\n return tasks.has(taskName);\n}\n\n// @needsAudit\n/**\n * Determine whether the task is registered. Registered tasks are stored in a persistent storage and\n * preserved between sessions.\n *\n * @param taskName Name of the task.\n * @returns A promise which resolves to `true` if a task with the given name is registered, otherwise `false`.\n */\nexport async function isTaskRegisteredAsync(taskName: string): Promise<boolean> {\n if (!ExpoTaskManager.isTaskRegisteredAsync) {\n throw new UnavailabilityError('TaskManager', 'isTaskRegisteredAsync');\n }\n\n _validate(taskName);\n return ExpoTaskManager.isTaskRegisteredAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Retrieves `options` associated with the task, that were passed to the function registering the task\n * (e.g. `Location.startLocationUpdatesAsync`).\n *\n * @param taskName Name of the task.\n * @return A promise which fulfills with the `options` object that was passed while registering task\n * with given name or `null` if task couldn't be found.\n */\nexport async function getTaskOptionsAsync<TaskOptions>(taskName: string): Promise<TaskOptions> {\n if (!ExpoTaskManager.getTaskOptionsAsync) {\n throw new UnavailabilityError('TaskManager', 'getTaskOptionsAsync');\n }\n\n _validate(taskName);\n return ExpoTaskManager.getTaskOptionsAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Provides information about tasks registered in the app.\n *\n * @returns A promise which fulfills with an array of tasks registered in the app.\n * @example\n * ```js\n * [\n * {\n * taskName: 'location-updates-task-name',\n * taskType: 'location',\n * options: {\n * accuracy: Location.Accuracy.High,\n * showsBackgroundLocationIndicator: false,\n * },\n * },\n * {\n * taskName: 'geofencing-task-name',\n * taskType: 'geofencing',\n * options: {\n * regions: [...],\n * },\n * },\n * ]\n * ```\n */\nexport async function getRegisteredTasksAsync(): Promise<TaskManagerTask[]> {\n if (!ExpoTaskManager.getRegisteredTasksAsync) {\n throw new UnavailabilityError('TaskManager', 'getRegisteredTasksAsync');\n }\n\n return ExpoTaskManager.getRegisteredTasksAsync();\n}\n\n// @needsAudit\n/**\n * Unregisters task from the app, so the app will not be receiving updates for that task anymore.\n * _It is recommended to use methods specialized by modules that registered the task, eg.\n * [`Location.stopLocationUpdatesAsync`](./location/#expolocationstoplocationupdatesasynctaskname)._\n *\n * @param taskName Name of the task to unregister.\n * @return A promise which fulfills as soon as the task is unregistered.\n */\nexport async function unregisterTaskAsync(taskName: string): Promise<void> {\n if (!ExpoTaskManager.unregisterTaskAsync) {\n throw new UnavailabilityError('TaskManager', 'unregisterTaskAsync');\n }\n\n _validate(taskName);\n await ExpoTaskManager.unregisterTaskAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Unregisters all tasks registered for the running app. You may want to call this when the user is\n * signing out and you no longer need to track his location or run any other background tasks.\n * @return A promise which fulfills as soon as all tasks are completely unregistered.\n */\nexport async function unregisterAllTasksAsync(): Promise<void> {\n if (!ExpoTaskManager.unregisterAllTasksAsync) {\n throw new UnavailabilityError('TaskManager', 'unregisterAllTasksAsync');\n }\n\n await ExpoTaskManager.unregisterAllTasksAsync();\n}\n\nif (ExpoTaskManager) {\n const eventEmitter = new LegacyEventEmitter(ExpoTaskManager);\n eventEmitter.addListener<TaskManagerTaskBody>(\n ExpoTaskManager.EVENT_NAME,\n async ({ data, error, executionInfo }) => {\n const { eventId, taskName } = executionInfo;\n const taskExecutor = tasks.get(taskName);\n let result: any = null;\n\n if (taskExecutor) {\n try {\n // Execute JS task\n result = await taskExecutor({ data, error, executionInfo });\n } catch (error) {\n console.error(`TaskManager: Task \"${taskName}\" failed:`, error);\n } finally {\n // Notify manager the task is finished.\n await ExpoTaskManager.notifyTaskFinishedAsync(taskName, { eventId, result });\n }\n } else {\n console.warn(\n `TaskManager: Execution of \"${taskName}\" was requested but looks like it is not defined. Available tasks: [${[...tasks.keys()].join(', ')}]. Make sure that \"TaskManager.defineTask\" is called during initialization phase.`\n );\n // No tasks defined -> we need to notify about finish anyway.\n await ExpoTaskManager.notifyTaskFinishedAsync(taskName, { eventId, result });\n // We should also unregister such tasks automatically as the task might have been removed\n // from the app or just renamed - in that case it needs to be registered again (with the new name).\n await ExpoTaskManager.unregisterTaskAsync(taskName);\n }\n }\n );\n}\n\n// @needsAudit\n/**\n * Determine if the `TaskManager` API can be used in this app.\n * @return A promise which fulfills with `true` if the API can be used, and `false` otherwise.\n * With Expo Go, `TaskManager` is not available on Android, and does not support background execution on iOS.\n * Use a development build to avoid limitations: https://expo.fyi/dev-client.\n * On the web, it always returns `false`.\n */\nexport async function isAvailableAsync(): Promise<boolean> {\n return ExpoTaskManager.isAvailable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AG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mFAAmF,CAC7N,CAAC;YACF,6DAA6D;YAC7D,MAAM,eAAe,CAAC,uBAAuB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7E,yFAAyF;YACzF,mGAAmG;YACnG,MAAM,eAAe,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,eAAe,CAAC,gBAAgB,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import { LegacyEventEmitter, Platform, UnavailabilityError } from 'expo-modules-core';\nimport { AppRegistry } from 'react-native';\n\nimport ExpoTaskManager from './ExpoTaskManager';\n\n// On Android, TaskService starts this headless task in native code to keep JS timers\n// alive during background task execution, and finishes it natively once the task is done\n// (or after a timeout).\n// The JS side must never settle: a resolved promise makes AppRegistry call\n// notifyTaskFinished, which ends the task right away and pauses timers again.\nif (Platform.OS === 'android') {\n AppRegistry.registerHeadlessTask('expo-task-manager', () => () => new Promise(() => {}));\n}\n\n// @needsAudit @docsMissing\n/**\n * Error object that can be received through [`TaskManagerTaskBody`](#taskmanagertaskbody) when the\n * task fails.\n */\nexport interface TaskManagerError {\n code: string | number;\n message: string;\n}\n\n// @needsAudit\n/**\n * Represents the object that is passed to the task executor.\n */\nexport interface TaskManagerTaskBody<T = unknown> {\n /**\n * An object of data passed to the task executor. Its properties depend on the type of the task.\n */\n data: T;\n\n /**\n * Error object if the task failed or `null` otherwise.\n */\n error: TaskManagerError | null;\n\n /**\n * Additional details containing unique ID of task event and name of the task.\n */\n executionInfo: TaskManagerTaskBodyExecutionInfo;\n}\n\n// @needsAudit\n/**\n * Additional details about execution provided in `TaskManagerTaskBody`.\n */\nexport interface TaskManagerTaskBodyExecutionInfo {\n /**\n * State of the application.\n * @platform ios\n */\n appState?: 'active' | 'background' | 'inactive';\n /**\n * Unique ID of task event.\n */\n eventId: string;\n /**\n * Name of the task.\n */\n taskName: string;\n}\n\n// @needsAudit\n/**\n * Represents an already registered task.\n */\nexport interface TaskManagerTask {\n /**\n * Name that the task is registered with.\n */\n taskName: string;\n\n /**\n * Type of the task which depends on how the task was registered.\n */\n taskType: string;\n\n /**\n * Provides `options` that the task was registered with.\n */\n options: any;\n}\n\n/**\n * @deprecated Use `TaskManagerTask` instead.\n * @hidden\n */\nexport interface RegisteredTask extends TaskManagerTask {}\n\n// @needsAudit\n/**\n * Type of task executor – a function that handles the task.\n */\nexport type TaskManagerTaskExecutor<T = any> = (body: TaskManagerTaskBody<T>) => Promise<any>;\n\nconst tasks: Map<string, TaskManagerTaskExecutor<any>> = new Map<\n string,\n TaskManagerTaskExecutor<any>\n>();\n\nfunction _validate(taskName: unknown) {\n if (!taskName || typeof taskName !== 'string') {\n throw new TypeError('`taskName` must be a non-empty string.');\n }\n}\n\n// @needsAudit\n/**\n * Defines task function. It must be called in the global scope of your JavaScript bundle.\n * In particular, it cannot be called in any of React lifecycle methods like `componentDidMount`.\n * This limitation is due to the fact that when the application is launched in the background,\n * we need to spin up your JavaScript app, run your task and then shut down — no views are mounted\n * in this scenario.\n *\n * @param taskName Name of the task. It must be the same as the name you provided when registering the task.\n * @param taskExecutor A function that will be invoked when the task with given `taskName` is executed.\n */\nexport function defineTask<T = unknown>(\n taskName: string,\n taskExecutor: TaskManagerTaskExecutor<T>\n) {\n if (!taskName || typeof taskName !== 'string') {\n console.warn(`TaskManager.defineTask: 'taskName' argument must be a non-empty string.`);\n return;\n }\n if (!taskExecutor || typeof taskExecutor !== 'function') {\n console.warn(`TaskManager.defineTask: 'task' argument must be a function.`);\n return;\n }\n tasks.set(taskName, taskExecutor);\n}\n\n// @needsAudit\n/**\n * Checks whether the task is already defined.\n *\n * @param taskName Name of the task.\n */\nexport function isTaskDefined(taskName: string): boolean {\n return tasks.has(taskName);\n}\n\n// @needsAudit\n/**\n * Determine whether the task is registered. Registered tasks are stored in a persistent storage and\n * preserved between sessions.\n *\n * @param taskName Name of the task.\n * @returns A promise which resolves to `true` if a task with the given name is registered, otherwise `false`.\n */\nexport async function isTaskRegisteredAsync(taskName: string): Promise<boolean> {\n if (!ExpoTaskManager.isTaskRegisteredAsync) {\n throw new UnavailabilityError('TaskManager', 'isTaskRegisteredAsync');\n }\n\n _validate(taskName);\n return ExpoTaskManager.isTaskRegisteredAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Retrieves `options` associated with the task, that were passed to the function registering the task\n * (e.g. `Location.startLocationUpdatesAsync`).\n *\n * @param taskName Name of the task.\n * @return A promise which fulfills with the `options` object that was passed while registering task\n * with given name or `null` if task couldn't be found.\n */\nexport async function getTaskOptionsAsync<TaskOptions>(taskName: string): Promise<TaskOptions> {\n if (!ExpoTaskManager.getTaskOptionsAsync) {\n throw new UnavailabilityError('TaskManager', 'getTaskOptionsAsync');\n }\n\n _validate(taskName);\n return ExpoTaskManager.getTaskOptionsAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Provides information about tasks registered in the app.\n *\n * @returns A promise which fulfills with an array of tasks registered in the app.\n * @example\n * ```js\n * [\n * {\n * taskName: 'location-updates-task-name',\n * taskType: 'location',\n * options: {\n * accuracy: Location.Accuracy.High,\n * showsBackgroundLocationIndicator: false,\n * },\n * },\n * {\n * taskName: 'geofencing-task-name',\n * taskType: 'geofencing',\n * options: {\n * regions: [...],\n * },\n * },\n * ]\n * ```\n */\nexport async function getRegisteredTasksAsync(): Promise<TaskManagerTask[]> {\n if (!ExpoTaskManager.getRegisteredTasksAsync) {\n throw new UnavailabilityError('TaskManager', 'getRegisteredTasksAsync');\n }\n\n return ExpoTaskManager.getRegisteredTasksAsync();\n}\n\n// @needsAudit\n/**\n * Unregisters task from the app, so the app will not be receiving updates for that task anymore.\n * _It is recommended to use methods specialized by modules that registered the task, eg.\n * [`Location.stopLocationUpdatesAsync`](./location/#expolocationstoplocationupdatesasynctaskname)._\n *\n * @param taskName Name of the task to unregister.\n * @return A promise which fulfills as soon as the task is unregistered.\n */\nexport async function unregisterTaskAsync(taskName: string): Promise<void> {\n if (!ExpoTaskManager.unregisterTaskAsync) {\n throw new UnavailabilityError('TaskManager', 'unregisterTaskAsync');\n }\n\n _validate(taskName);\n await ExpoTaskManager.unregisterTaskAsync(taskName);\n}\n\n// @needsAudit\n/**\n * Unregisters all tasks registered for the running app. You may want to call this when the user is\n * signing out and you no longer need to track his location or run any other background tasks.\n * @return A promise which fulfills as soon as all tasks are completely unregistered.\n */\nexport async function unregisterAllTasksAsync(): Promise<void> {\n if (!ExpoTaskManager.unregisterAllTasksAsync) {\n throw new UnavailabilityError('TaskManager', 'unregisterAllTasksAsync');\n }\n\n await ExpoTaskManager.unregisterAllTasksAsync();\n}\n\nif (ExpoTaskManager) {\n const eventEmitter = new LegacyEventEmitter(ExpoTaskManager);\n eventEmitter.addListener<TaskManagerTaskBody>(\n ExpoTaskManager.EVENT_NAME,\n async ({ data, error, executionInfo }) => {\n const { eventId, taskName } = executionInfo;\n const taskExecutor = tasks.get(taskName);\n let result: any = null;\n\n if (taskExecutor) {\n try {\n // Execute JS task\n result = await taskExecutor({ data, error, executionInfo });\n } catch (error) {\n console.error(`TaskManager: Task \"${taskName}\" failed:`, error);\n } finally {\n // Notify manager the task is finished.\n await ExpoTaskManager.notifyTaskFinishedAsync(taskName, { eventId, result });\n }\n } else {\n console.warn(\n `TaskManager: Execution of \"${taskName}\" was requested but looks like it is not defined. Available tasks: [${[...tasks.keys()].join(', ')}]. Make sure that \"TaskManager.defineTask\" is called during initialization phase.`\n );\n // No tasks defined -> we need to notify about finish anyway.\n await ExpoTaskManager.notifyTaskFinishedAsync(taskName, { eventId, result });\n // We should also unregister such tasks automatically as the task might have been removed\n // from the app or just renamed - in that case it needs to be registered again (with the new name).\n await ExpoTaskManager.unregisterTaskAsync(taskName);\n }\n }\n );\n}\n\n// @needsAudit\n/**\n * Determine if the `TaskManager` API can be used in this app.\n * @return A promise which fulfills with `true` if the API can be used, and `false` otherwise.\n * With Expo Go, `TaskManager` is not available on Android, and does not support background execution on iOS.\n * Use a development build to avoid limitations: https://expo.fyi/dev-client.\n * On the web, it always returns `false`.\n */\nexport async function isAvailableAsync(): Promise<boolean> {\n return ExpoTaskManager.isAvailableAsync();\n}\n"]}
|
package/expo-module.config.json
CHANGED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7491daaeb1d6c61e79ee0112d9a0a6be
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ccb75ff6e4f30a8d8252ebfac0c329936d5158aa
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1e2e40138d06f96b1ffbbd3cca0f904fd57429d8370434d917fc581d9960e88a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
69774d74f582d57e2afaebdeb54b2e124d7ad295c1a8dfd193e3f3638995399859b8ed3682be7879768e3be18213f6ca1a8be8424253d314a39e17846837ed70
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0acb2c081b0161aa7071b5922d2e404a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
de7a9da090d1e07ce8251bf4a138880fd8bae627
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
74281eea9d95692929943d27e934eef788952b5a8c17fa8fb6a173d422618724
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c4df6b535969deebddd047d3a1423d23c4f14ccba6e6fe56810cfdc5b7215057cdf368fa866bbb7b69b9399cf82aa86483e66df8610a7a8196cf302cbd16b70f
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.taskmanager",
|
|
6
|
-
"version": "57.0.
|
|
6
|
+
"version": "57.0.23",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
],
|
|
34
34
|
"files": [
|
|
35
35
|
{
|
|
36
|
-
"name": "expo.modules.taskmanager-57.0.
|
|
37
|
-
"url": "expo.modules.taskmanager-57.0.
|
|
38
|
-
"size":
|
|
39
|
-
"sha512": "
|
|
40
|
-
"sha256": "
|
|
41
|
-
"sha1": "
|
|
42
|
-
"md5": "
|
|
36
|
+
"name": "expo.modules.taskmanager-57.0.23.aar",
|
|
37
|
+
"url": "expo.modules.taskmanager-57.0.23.aar",
|
|
38
|
+
"size": 67603,
|
|
39
|
+
"sha512": "c4df6b535969deebddd047d3a1423d23c4f14ccba6e6fe56810cfdc5b7215057cdf368fa866bbb7b69b9399cf82aa86483e66df8610a7a8196cf302cbd16b70f",
|
|
40
|
+
"sha256": "74281eea9d95692929943d27e934eef788952b5a8c17fa8fb6a173d422618724",
|
|
41
|
+
"sha1": "de7a9da090d1e07ce8251bf4a138880fd8bae627",
|
|
42
|
+
"md5": "0acb2c081b0161aa7071b5922d2e404a"
|
|
43
43
|
}
|
|
44
44
|
]
|
|
45
45
|
},
|
|
@@ -90,13 +90,13 @@
|
|
|
90
90
|
],
|
|
91
91
|
"files": [
|
|
92
92
|
{
|
|
93
|
-
"name": "expo.modules.taskmanager-57.0.
|
|
94
|
-
"url": "expo.modules.taskmanager-57.0.
|
|
95
|
-
"size":
|
|
96
|
-
"sha512": "
|
|
97
|
-
"sha256": "
|
|
98
|
-
"sha1": "
|
|
99
|
-
"md5": "
|
|
93
|
+
"name": "expo.modules.taskmanager-57.0.23.aar",
|
|
94
|
+
"url": "expo.modules.taskmanager-57.0.23.aar",
|
|
95
|
+
"size": 67603,
|
|
96
|
+
"sha512": "c4df6b535969deebddd047d3a1423d23c4f14ccba6e6fe56810cfdc5b7215057cdf368fa866bbb7b69b9399cf82aa86483e66df8610a7a8196cf302cbd16b70f",
|
|
97
|
+
"sha256": "74281eea9d95692929943d27e934eef788952b5a8c17fa8fb6a173d422618724",
|
|
98
|
+
"sha1": "de7a9da090d1e07ce8251bf4a138880fd8bae627",
|
|
99
|
+
"md5": "0acb2c081b0161aa7071b5922d2e404a"
|
|
100
100
|
}
|
|
101
101
|
]
|
|
102
102
|
},
|
|
@@ -110,13 +110,13 @@
|
|
|
110
110
|
},
|
|
111
111
|
"files": [
|
|
112
112
|
{
|
|
113
|
-
"name": "expo.modules.taskmanager-57.0.
|
|
114
|
-
"url": "expo.modules.taskmanager-57.0.
|
|
115
|
-
"size":
|
|
116
|
-
"sha512": "
|
|
117
|
-
"sha256": "
|
|
118
|
-
"sha1": "
|
|
119
|
-
"md5": "
|
|
113
|
+
"name": "expo.modules.taskmanager-57.0.23-sources.jar",
|
|
114
|
+
"url": "expo.modules.taskmanager-57.0.23-sources.jar",
|
|
115
|
+
"size": 24345,
|
|
116
|
+
"sha512": "69774d74f582d57e2afaebdeb54b2e124d7ad295c1a8dfd193e3f3638995399859b8ed3682be7879768e3be18213f6ca1a8be8424253d314a39e17846837ed70",
|
|
117
|
+
"sha256": "1e2e40138d06f96b1ffbbd3cca0f904fd57429d8370434d917fc581d9960e88a",
|
|
118
|
+
"sha1": "ccb75ff6e4f30a8d8252ebfac0c329936d5158aa",
|
|
119
|
+
"md5": "7491daaeb1d6c61e79ee0112d9a0a6be"
|
|
120
120
|
}
|
|
121
121
|
]
|
|
122
122
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ba99799067a1644b015935806467e6e5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dbb17796d47f2ff1502e25c63adb4f44d6d56ead
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bef2f15b5b47b680303e2d6650db601d429239b023551ca1cc534b5b810cd16e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
68e233ac31e0f9c2c836f289e17778648a681d349cb144c50a75ad056702d0de182f7e66a3d1f4510947dbde953221284bcd1441a9eb2858e586a4f80a16972d
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>host.exp.exponent</groupId>
|
|
11
11
|
<artifactId>expo.modules.taskmanager</artifactId>
|
|
12
|
-
<version>57.0.
|
|
12
|
+
<version>57.0.23</version>
|
|
13
13
|
<packaging>aar</packaging>
|
|
14
14
|
<name>expo.modules.taskmanager</name>
|
|
15
15
|
<url>https://github.com/expo/expo</url>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b3a0e90a2496ebf905ac5e907c233f0b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
99ea7ff35b4ce377ad18167512ed3a66ee7d8712
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e4f42acbcab3e304c3aa618ef2ccab5fce46845428c448e53c0dd33d227f09f6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e99c19ab4852a5e79b47389ba5b25247c4629c80794145c260c860f9378247fe7edb4c1275a2dae71cd4ba4e0a1e5399209ee6f564f929949c62f5c285ef0f5a
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>host.exp.exponent</groupId>
|
|
4
4
|
<artifactId>expo.modules.taskmanager</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>57.0.
|
|
7
|
-
<release>57.0.
|
|
6
|
+
<latest>57.0.23</latest>
|
|
7
|
+
<release>57.0.23</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>57.0.
|
|
9
|
+
<version>57.0.23</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20261112131751</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
7dec854859d381e8dfdf67f37017725b
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
43759bd22568fe14fbb1eca782b59567b6d8f0c2
|
package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/maven-metadata.xml.sha256
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c968b604046d087132894b2cfa85addb37ac3c84533240fd5ba26e895cca4bf0
|
package/local-maven-repo/host/exp/exponent/expo.modules.taskmanager/maven-metadata.xml.sha512
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
092fd930c0bebd40f1bd9fca4500963ff1afe8fe0eb417a6d26fe4fa69756dd9cccafffc9cb403461c19013aca0e4c95b9fdbd824d01d4b146c517e85a77b7fc
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-task-manager",
|
|
3
|
-
"version": "57.0.
|
|
3
|
+
"version": "57.0.23",
|
|
4
4
|
"description": "Expo module that provides support for tasks that can run in the background.",
|
|
5
5
|
"main": "build/TaskManager.js",
|
|
6
6
|
"types": "build/TaskManager.d.ts",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^22.14.0",
|
|
31
|
-
"expo": "
|
|
32
|
-
"expo
|
|
31
|
+
"expo-module-scripts": "56.0.3",
|
|
32
|
+
"expo": "57.0.33"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"expo": "*",
|
|
36
36
|
"react-native": "*"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "968a9dcec304789b2ccc1a41ef5d301938e91478",
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "expo-module build",
|
|
41
41
|
"clean": "expo-module clean",
|
package/src/TaskManager.ts
CHANGED
|
@@ -3,11 +3,13 @@ import { AppRegistry } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import ExpoTaskManager from './ExpoTaskManager';
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
// On Android, TaskService starts this headless task in native code to keep JS timers
|
|
7
|
+
// alive during background task execution, and finishes it natively once the task is done
|
|
8
|
+
// (or after a timeout).
|
|
9
|
+
// The JS side must never settle: a resolved promise makes AppRegistry call
|
|
10
|
+
// notifyTaskFinished, which ends the task right away and pauses timers again.
|
|
9
11
|
if (Platform.OS === 'android') {
|
|
10
|
-
AppRegistry.registerHeadlessTask('expo-task-manager', () =>
|
|
12
|
+
AppRegistry.registerHeadlessTask('expo-task-manager', () => () => new Promise(() => {}));
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
// @needsAudit @docsMissing
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
54a93c9d98da903dd30ffa3c75ab4002
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f943bedce9533e9a53229ea7061738cd333d65f6
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
edffcb333d5b061261d6de59ff8fd1437b7aadd5533e6361e7620379f81c4467
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1dda34fc5fd0a154fc6669e778d8fa387e9f84cd1a4e6de386065cb7cb1eccfa14a77a4517a9093b2a8c425889a8918aa9f74e7fac54cef38f65cd97bf7cdfc5
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
9b34c279d6401169f8f4b24dfa797bfc
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cfa5551df3633130122b8f439cc7663c152cb6a0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
db5259126c23fa165f2968fc00b713df178bd6e84a27ed035f43888e513f3395
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
9301f7b273515624d556631662e643582927e4c5673b2999294cd1f5a392f57b4c0465404ea7929b16f7d649ea0be97c74781ed44f26c01f5ddb37de19aa47e0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
d93f77541a1024aeb4376b5ee6b306da
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ea4677fc5246f5f6e96f0eb9582df6fe6ff98138
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dbabfbf75b35524483b8211c540a1c70eb418744daa5379553bc06ac4ef0b490
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
762477f51eb139d8521ecd720f9f59e9d65cc9c96c8b028ed231c4d011536b342fabe5d64b47647ecdcd48437c04af1b6bcc4a388b81f0ab3a7374aac2f7ad28
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
c120488148c05bdc9c9f79c6d69f55c8
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4112280a9fb509d1bc58e07d4efc379a2567d1e2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
9a633878a2edecba386363fe91282dd4fc34c8249e4c2656c97dd9ea4c1c3102
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cfdd53a7ba7a14d731295b5d12eacf5dba37434d701a7cd76340ffa43e0514b70c114dd5387724ef109ad83136a42ae586999634cb55c3df479b3eee189182b9
|