@capuchoo/updater 0.1.1 → 0.2.0

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/README.md CHANGED
@@ -29,14 +29,14 @@ does not hear it within `appReadyTimeout` (10 s), it concludes the bundle crashe
29
29
  the previous one — so gating this call behind a condition, or awaiting a network request before it,
30
30
  reverts working updates. It is not a gate on auto-update.
31
31
 
32
- ### 2. Configure the plugin through `capuchoUpdaterConfig()`
32
+ ### 2. Configure the plugin through `capuchooUpdaterConfig()`
33
33
 
34
34
  ```ts
35
35
  // capacitor.config.ts
36
- import { capuchoUpdaterConfig } from "@capuchoo/updater/capacitor";
36
+ import { capuchooUpdaterConfig } from "@capuchoo/updater/capacitor";
37
37
 
38
38
  plugins: {
39
- CapacitorUpdater: capuchoUpdaterConfig({
39
+ CapacitorUpdater: capuchooUpdaterConfig({
40
40
  apiUrl: process.env.VITE_UPDATE_API_URL,
41
41
  channel: process.env.VITE_UPDATE_CHANNEL,
42
42
  }),
@@ -52,7 +52,7 @@ interface CapacitorUpdaterPluginConfig {
52
52
  responseTimeout: number;
53
53
  allowModifyUrl: boolean;
54
54
  }
55
- declare function capuchoUpdaterConfig(options: UpdaterPluginOptions): CapacitorUpdaterPluginConfig;
55
+ declare function capuchooUpdaterConfig(options: UpdaterPluginOptions): CapacitorUpdaterPluginConfig;
56
56
  //#endregion
57
- export { CapacitorUpdaterPluginConfig, UpdaterMode, UpdaterPluginOptions, capuchoUpdaterConfig };
57
+ export { CapacitorUpdaterPluginConfig, UpdaterMode, UpdaterPluginOptions, capuchooUpdaterConfig };
58
58
  //# sourceMappingURL=capacitor-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capacitor-config.d.ts","names":[],"sources":["../src/capacitor-config.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAmBY;UAEK;;EAEf;;EAEA;;;;;;EAMA;EACA,OAAO;;EAEP;EACA;;;;;;EAMA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGc,qBAAqB,SAAS,uBAAuB"}
1
+ {"version":3,"file":"capacitor-config.d.ts","names":[],"sources":["../src/capacitor-config.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAmBY;UAEK;;EAEf;;EAEA;;;;;;EAMA;EACA,OAAO;;EAEP;EACA;;;;;;EAMA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGc,sBAAsB,SAAS,uBAAuB"}
@@ -1,7 +1,7 @@
1
1
  //#region src/capacitor-config.ts
2
- function capuchoUpdaterConfig(options) {
2
+ function capuchooUpdaterConfig(options) {
3
3
  const apiUrl = options.apiUrl.replace(/\/+$/, "");
4
- if (!apiUrl) throw new Error("capuchoUpdaterConfig: apiUrl is empty. Set VITE_UPDATE_API_URL for this flavour before building, otherwise the app ships with updates disabled.");
4
+ if (!apiUrl) throw new Error("capuchooUpdaterConfig: apiUrl is empty. Set VITE_UPDATE_API_URL for this flavour before building, otherwise the app ships with updates disabled.");
5
5
  return {
6
6
  autoUpdate: (options.mode ?? "onlyDownload") === "onlyDownload" ? "onlyDownload" : false,
7
7
  updateUrl: `${apiUrl}/api/update`,
@@ -16,6 +16,6 @@ function capuchoUpdaterConfig(options) {
16
16
  };
17
17
  }
18
18
  //#endregion
19
- export { capuchoUpdaterConfig };
19
+ export { capuchooUpdaterConfig };
20
20
 
21
21
  //# sourceMappingURL=capacitor-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"capacitor-config.js","names":[],"sources":["../src/capacitor-config.ts"],"sourcesContent":["/**\n * Builds the `CapacitorUpdater` plugin block for `capacitor.config.ts`.\n *\n * This exists because the plugin's `autoUpdate` mode has to agree with how the\n * app drives updates, and getting it wrong fails in a way that is very hard to\n * diagnose. The app template shipped `autoUpdate: true` while also calling\n * `download()` and `set()` from JavaScript: the plugin applied bundles on its\n * own schedule at the same time as the UI was downloading them, so a device\n * could download the same bundle twice, or reload mid-prompt.\n *\n * `\"onlyDownload\"` is the mode this package is written for. The plugin fetches\n * the bundle in the background and raises `updateAvailable`; the app decides\n * when to apply it. Pass `mode: \"manual\"` to disable background downloads\n * entirely and drive everything from `useUpdater`.\n *\n * Imported from `capacitor.config.ts`, so it must stay free of any runtime or\n * DOM dependency.\n */\n\nexport type UpdaterMode = \"onlyDownload\" | \"manual\";\n\nexport interface UpdaterPluginOptions {\n /** Base URL of the Capucho backend. No trailing slash needed. */\n apiUrl: string;\n /** Channel this build defaults to. */\n channel: string;\n /**\n * Version the plugin reports as the built-in bundle. Pass the app's\n * package.json version - if this is stale, the server compares against the\n * wrong baseline and re-serves bundles the device already has.\n */\n version: string;\n mode?: UpdaterMode;\n /** Milliseconds the plugin waits for `notifyAppReady` before rolling back. */\n appReadyTimeout?: number;\n responseTimeout?: number;\n /**\n * Whether the app may point the plugin at a different server at runtime.\n * Leave off in production: it lets anything running in the WebView redirect\n * update downloads.\n */\n allowModifyUrl?: boolean;\n}\n\nexport interface CapacitorUpdaterPluginConfig {\n autoUpdate: boolean | \"onlyDownload\";\n updateUrl: string;\n statsUrl: string;\n channelUrl: string;\n defaultChannel: string;\n version: string;\n directUpdate: boolean;\n appReadyTimeout: number;\n responseTimeout: number;\n allowModifyUrl: boolean;\n}\n\nexport function capuchoUpdaterConfig(options: UpdaterPluginOptions): CapacitorUpdaterPluginConfig {\n const apiUrl = options.apiUrl.replace(/\\/+$/, \"\");\n\n if (!apiUrl) {\n // The plugin accepts an empty updateUrl and then silently never checks for\n // updates, which is the worst possible outcome. Fail the build instead.\n throw new Error(\n \"capuchoUpdaterConfig: apiUrl is empty. Set VITE_UPDATE_API_URL for this \" +\n \"flavour before building, otherwise the app ships with updates disabled.\",\n );\n }\n\n const mode = options.mode ?? \"onlyDownload\";\n\n return {\n // \"manual\" means the plugin does nothing on its own.\n autoUpdate: mode === \"onlyDownload\" ? \"onlyDownload\" : false,\n updateUrl: `${apiUrl}/api/update`,\n statsUrl: `${apiUrl}/api/stats`,\n channelUrl: `${apiUrl}/api/channel_self`,\n defaultChannel: options.channel,\n version: options.version,\n // The app shows a prompt and calls set() itself; letting the plugin apply\n // the bundle immediately would reload the WebView under the user.\n directUpdate: false,\n appReadyTimeout: options.appReadyTimeout ?? 10_000,\n responseTimeout: options.responseTimeout ?? 30_000,\n allowModifyUrl: options.allowModifyUrl ?? false,\n };\n}\n"],"mappings":";AAyDA,SAAgB,qBAAqB,SAA6D;CAChG,MAAM,SAAS,QAAQ,OAAO,QAAQ,QAAQ,EAAE;CAEhD,IAAI,CAAC,QAGH,MAAM,IAAI,MACR,iJAEF;CAKF,OAAO;EAEL,aAJW,QAAQ,QAAQ,oBAIN,iBAAiB,iBAAiB;EACvD,WAAW,GAAG,OAAO;EACrB,UAAU,GAAG,OAAO;EACpB,YAAY,GAAG,OAAO;EACtB,gBAAgB,QAAQ;EACxB,SAAS,QAAQ;EAGjB,cAAc;EACd,iBAAiB,QAAQ,mBAAmB;EAC5C,iBAAiB,QAAQ,mBAAmB;EAC5C,gBAAgB,QAAQ,kBAAkB;CAC5C;AACF"}
1
+ {"version":3,"file":"capacitor-config.js","names":[],"sources":["../src/capacitor-config.ts"],"sourcesContent":["/**\n * Builds the `CapacitorUpdater` plugin block for `capacitor.config.ts`.\n *\n * This exists because the plugin's `autoUpdate` mode has to agree with how the\n * app drives updates, and getting it wrong fails in a way that is very hard to\n * diagnose. The app template shipped `autoUpdate: true` while also calling\n * `download()` and `set()` from JavaScript: the plugin applied bundles on its\n * own schedule at the same time as the UI was downloading them, so a device\n * could download the same bundle twice, or reload mid-prompt.\n *\n * `\"onlyDownload\"` is the mode this package is written for. The plugin fetches\n * the bundle in the background and raises `updateAvailable`; the app decides\n * when to apply it. Pass `mode: \"manual\"` to disable background downloads\n * entirely and drive everything from `useUpdater`.\n *\n * Imported from `capacitor.config.ts`, so it must stay free of any runtime or\n * DOM dependency.\n */\n\nexport type UpdaterMode = \"onlyDownload\" | \"manual\";\n\nexport interface UpdaterPluginOptions {\n /** Base URL of the Capucho backend. No trailing slash needed. */\n apiUrl: string;\n /** Channel this build defaults to. */\n channel: string;\n /**\n * Version the plugin reports as the built-in bundle. Pass the app's\n * package.json version - if this is stale, the server compares against the\n * wrong baseline and re-serves bundles the device already has.\n */\n version: string;\n mode?: UpdaterMode;\n /** Milliseconds the plugin waits for `notifyAppReady` before rolling back. */\n appReadyTimeout?: number;\n responseTimeout?: number;\n /**\n * Whether the app may point the plugin at a different server at runtime.\n * Leave off in production: it lets anything running in the WebView redirect\n * update downloads.\n */\n allowModifyUrl?: boolean;\n}\n\nexport interface CapacitorUpdaterPluginConfig {\n autoUpdate: boolean | \"onlyDownload\";\n updateUrl: string;\n statsUrl: string;\n channelUrl: string;\n defaultChannel: string;\n version: string;\n directUpdate: boolean;\n appReadyTimeout: number;\n responseTimeout: number;\n allowModifyUrl: boolean;\n}\n\nexport function capuchooUpdaterConfig(options: UpdaterPluginOptions): CapacitorUpdaterPluginConfig {\n const apiUrl = options.apiUrl.replace(/\\/+$/, \"\");\n\n if (!apiUrl) {\n // The plugin accepts an empty updateUrl and then silently never checks for\n // updates, which is the worst possible outcome. Fail the build instead.\n throw new Error(\n \"capuchooUpdaterConfig: apiUrl is empty. Set VITE_UPDATE_API_URL for this \" +\n \"flavour before building, otherwise the app ships with updates disabled.\",\n );\n }\n\n const mode = options.mode ?? \"onlyDownload\";\n\n return {\n // \"manual\" means the plugin does nothing on its own.\n autoUpdate: mode === \"onlyDownload\" ? \"onlyDownload\" : false,\n updateUrl: `${apiUrl}/api/update`,\n statsUrl: `${apiUrl}/api/stats`,\n channelUrl: `${apiUrl}/api/channel_self`,\n defaultChannel: options.channel,\n version: options.version,\n // The app shows a prompt and calls set() itself; letting the plugin apply\n // the bundle immediately would reload the WebView under the user.\n directUpdate: false,\n appReadyTimeout: options.appReadyTimeout ?? 10_000,\n responseTimeout: options.responseTimeout ?? 30_000,\n allowModifyUrl: options.allowModifyUrl ?? false,\n };\n}\n"],"mappings":";AAyDA,SAAgB,sBAAsB,SAA6D;CACjG,MAAM,SAAS,QAAQ,OAAO,QAAQ,QAAQ,EAAE;CAEhD,IAAI,CAAC,QAGH,MAAM,IAAI,MACR,kJAEF;CAKF,OAAO;EAEL,aAJW,QAAQ,QAAQ,oBAIN,iBAAiB,iBAAiB;EACvD,WAAW,GAAG,OAAO;EACrB,UAAU,GAAG,OAAO;EACpB,YAAY,GAAG,OAAO;EACtB,gBAAgB,QAAQ;EACxB,SAAS,QAAQ;EAGjB,cAAc;EACd,iBAAiB,QAAQ,mBAAmB;EAC5C,iBAAiB,QAAQ,mBAAmB;EAC5C,gBAAgB,QAAQ,kBAAkB;CAC5C;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capuchoo/updater",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "App-side runtime for Capucho OTA and native updates in Capacitor apps",
5
5
  "keywords": [
6
6
  "capacitor",
@@ -42,7 +42,7 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@capuchoo/core": "^0.1.1"
45
+ "@capuchoo/core": "^0.1.2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@capacitor/app": "^8.0.0",