Skip to content

Commit 6f1be35

Browse files
authored
feat(shorebird_code_push): rewrite Dart API (#225)
1 parent 8e7ec5a commit 6f1be35

28 files changed

+2301
-851
lines changed

.github/workflows/main.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
matrix:
5959
crate: ${{ fromJSON(needs.changes.outputs.needs_rust_build) }}
6060

61-
runs-on: ubuntu-latest
61+
runs-on: macos-latest
6262

6363
name: 🦀 Build ${{ matrix.crate }}
6464

@@ -98,12 +98,7 @@ jobs:
9898
working_directory: ${{ matrix.package }}
9999

100100
ci:
101-
needs:
102-
[
103-
semantic_pull_request,
104-
build_flutter_packages,
105-
build_rust_crates,
106-
]
101+
needs: [semantic_pull_request, build_flutter_packages, build_rust_crates]
107102
if: ${{ always() }}
108103

109104
runs-on: ubuntu-latest

library/include/updater.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
#endif
1515

1616

17+
/**
18+
* An unknown error occurred while updating. The update was not installed.
19+
* This is a catch-all for errors that don't fit into the other categories.
20+
*/
21+
#define SHOREBIRD_UPDATE_ERROR -1
22+
23+
/**
24+
* No update is available (e.g. the app is already up-to-date)
25+
*/
26+
#define SHOREBIRD_NO_UPDATE 0
27+
28+
/**
29+
* An update was installed successfully. It will boot from the update on the
30+
* next app launch.
31+
*/
32+
#define SHOREBIRD_UPDATE_INSTALLED 1
33+
34+
/**
35+
* An error occurred while updating. The update was not installed.
36+
*/
37+
#define SHOREBIRD_UPDATE_HAD_ERROR 2
38+
39+
/**
40+
* The downloaded patch was not installed because it was invalid.
41+
*/
42+
#define SHOREBIRD_UPDATE_IS_BAD_PATCH 3
43+
1744
/**
1845
* Struct containing configuration parameters for the updater.
1946
* Passed to all updater functions.
@@ -69,6 +96,11 @@ typedef struct FileCallbacks {
6996
void (*close)(void *file_handle);
7097
} FileCallbacks;
7198

99+
typedef struct UpdateResult {
100+
int32_t status;
101+
const char *message;
102+
} UpdateResult;
103+
72104
#ifdef __cplusplus
73105
extern "C" {
74106
#endif // __cplusplus
@@ -114,7 +146,9 @@ SHOREBIRD_EXPORT char *shorebird_next_boot_patch_path(void);
114146
* If this function is called with a non-null pointer, it must be a pointer
115147
* returned by the updater library.
116148
*/
117-
SHOREBIRD_EXPORT void shorebird_free_string(char *c_string);
149+
SHOREBIRD_EXPORT void shorebird_free_string(const char *c_string);
150+
151+
SHOREBIRD_EXPORT void shorebird_free_update_result(struct UpdateResult *result);
118152

119153
/**
120154
* Check for an update. Returns true if an update is available.
@@ -126,6 +160,12 @@ SHOREBIRD_EXPORT bool shorebird_check_for_update(void);
126160
*/
127161
SHOREBIRD_EXPORT void shorebird_update(void);
128162

163+
/**
164+
* Synchronously download an update if one is available.
165+
* Returns an [UpdateResult] indicating whether the update was successful.
166+
*/
167+
SHOREBIRD_EXPORT const struct UpdateResult *shorebird_update_with_result(void);
168+
129169
/**
130170
* Start a thread to download an update if one is available.
131171
*/

0 commit comments

Comments
 (0)