@swoff/cli 0.3.8 → 0.3.10

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.
Files changed (228) hide show
  1. package/README.md +47 -33
  2. package/dist/__tests__/assemble-sw.test.js +14 -53
  3. package/dist/__tests__/assemble-sw.test.js.map +1 -1
  4. package/dist/__tests__/cli-integration.test.js +119 -11
  5. package/dist/__tests__/cli-integration.test.js.map +1 -1
  6. package/dist/__tests__/config-types.test.js +44 -17
  7. package/dist/__tests__/config-types.test.js.map +1 -1
  8. package/dist/__tests__/file-generators.test.js +3 -3
  9. package/dist/__tests__/file-generators.test.js.map +1 -1
  10. package/dist/__tests__/glob-matcher.test.js +86 -0
  11. package/dist/__tests__/glob-matcher.test.js.map +1 -0
  12. package/dist/__tests__/invalidation-tags.test.js +207 -23
  13. package/dist/__tests__/invalidation-tags.test.js.map +1 -1
  14. package/dist/__tests__/loader.test.js +16 -12
  15. package/dist/__tests__/loader.test.js.map +1 -1
  16. package/dist/__tests__/validator.test.js +140 -100
  17. package/dist/__tests__/validator.test.js.map +1 -1
  18. package/dist/index.js +39 -34
  19. package/dist/index.js.map +1 -1
  20. package/dist/lib/cli/help.js +12 -12
  21. package/dist/lib/cli/help.js.map +1 -1
  22. package/dist/lib/commands/add.js +84 -36
  23. package/dist/lib/commands/add.js.map +1 -1
  24. package/dist/lib/commands/assets.js +37 -0
  25. package/dist/lib/commands/assets.js.map +1 -0
  26. package/dist/lib/commands/clean.js +32 -30
  27. package/dist/lib/commands/clean.js.map +1 -1
  28. package/dist/lib/commands/generate-assets.js +44 -0
  29. package/dist/lib/commands/generate-assets.js.map +1 -0
  30. package/dist/lib/commands/generate-guide.js +22 -29
  31. package/dist/lib/commands/generate-guide.js.map +1 -1
  32. package/dist/lib/commands/generate.js +17 -24
  33. package/dist/lib/commands/generate.js.map +1 -1
  34. package/dist/lib/commands/info.js +41 -48
  35. package/dist/lib/commands/info.js.map +1 -1
  36. package/dist/lib/commands/init.js +27 -13
  37. package/dist/lib/commands/init.js.map +1 -1
  38. package/dist/lib/commands/validate.js +4 -4
  39. package/dist/lib/commands/validate.js.map +1 -1
  40. package/dist/lib/config/loader.js +25 -23
  41. package/dist/lib/config/loader.js.map +1 -1
  42. package/dist/lib/config/validator.js +169 -91
  43. package/dist/lib/config/validator.js.map +1 -1
  44. package/dist/lib/generators/asset-generator/dependency-resolver.js +76 -0
  45. package/dist/lib/generators/asset-generator/dependency-resolver.js.map +1 -0
  46. package/dist/lib/generators/asset-generator/generate.js +111 -0
  47. package/dist/lib/generators/asset-generator/generate.js.map +1 -0
  48. package/dist/lib/generators/asset-generator/guide.js +43 -0
  49. package/dist/lib/generators/asset-generator/guide.js.map +1 -0
  50. package/dist/lib/generators/asset-generator/html-patcher.js +65 -0
  51. package/dist/lib/generators/asset-generator/html-patcher.js.map +1 -0
  52. package/dist/lib/generators/asset-generator/ico-encoder.js +29 -0
  53. package/dist/lib/generators/asset-generator/ico-encoder.js.map +1 -0
  54. package/dist/lib/generators/asset-generator/manifest-patcher.js +23 -0
  55. package/dist/lib/generators/asset-generator/manifest-patcher.js.map +1 -0
  56. package/dist/lib/generators/asset-generator/maskable.js +15 -0
  57. package/dist/lib/generators/asset-generator/maskable.js.map +1 -0
  58. package/dist/lib/generators/asset-generator/rasterize.js +32 -0
  59. package/dist/lib/generators/asset-generator/rasterize.js.map +1 -0
  60. package/dist/lib/generators/asset-generator/sizes.js +25 -0
  61. package/dist/lib/generators/asset-generator/sizes.js.map +1 -0
  62. package/dist/lib/generators/file-generators/api-config.js +6 -0
  63. package/dist/lib/generators/file-generators/api-config.js.map +1 -0
  64. package/dist/lib/generators/file-generators/auth-state.js +2 -34
  65. package/dist/lib/generators/file-generators/auth-state.js.map +1 -1
  66. package/dist/lib/generators/file-generators/auth-store.js +2 -250
  67. package/dist/lib/generators/file-generators/auth-store.js.map +1 -1
  68. package/dist/lib/generators/file-generators/auth-user.js +3 -81
  69. package/dist/lib/generators/file-generators/auth-user.js.map +1 -1
  70. package/dist/lib/generators/file-generators/background-sync.js +2 -57
  71. package/dist/lib/generators/file-generators/background-sync.js.map +1 -1
  72. package/dist/lib/generators/file-generators/cache.js +2 -38
  73. package/dist/lib/generators/file-generators/cache.js.map +1 -1
  74. package/dist/lib/generators/file-generators/client-injector.js +2 -91
  75. package/dist/lib/generators/file-generators/client-injector.js.map +1 -1
  76. package/dist/lib/generators/file-generators/fetch-state.js +6 -0
  77. package/dist/lib/generators/file-generators/fetch-state.js.map +1 -0
  78. package/dist/lib/generators/file-generators/fetch-wrapper.js +3 -267
  79. package/dist/lib/generators/file-generators/fetch-wrapper.js.map +1 -1
  80. package/dist/lib/generators/file-generators/generate-framework-adapters.js +56 -0
  81. package/dist/lib/generators/file-generators/generate-framework-adapters.js.map +1 -0
  82. package/dist/lib/generators/file-generators/generate-hooks.js +4 -3
  83. package/dist/lib/generators/file-generators/generate-hooks.js.map +1 -1
  84. package/dist/lib/generators/file-generators/gql-wrapper.js +3 -145
  85. package/dist/lib/generators/file-generators/gql-wrapper.js.map +1 -1
  86. package/dist/lib/generators/file-generators/guide-generator.js +24 -630
  87. package/dist/lib/generators/file-generators/guide-generator.js.map +1 -1
  88. package/dist/lib/generators/file-generators/invalidation-tags.js +18 -86
  89. package/dist/lib/generators/file-generators/invalidation-tags.js.map +1 -1
  90. package/dist/lib/generators/file-generators/manifest.js +15 -5
  91. package/dist/lib/generators/file-generators/manifest.js.map +1 -1
  92. package/dist/lib/generators/file-generators/mutation-queue.js +3 -285
  93. package/dist/lib/generators/file-generators/mutation-queue.js.map +1 -1
  94. package/dist/lib/generators/file-generators/mutation-state.js +2 -117
  95. package/dist/lib/generators/file-generators/mutation-state.js.map +1 -1
  96. package/dist/lib/generators/file-generators/push.js +6 -139
  97. package/dist/lib/generators/file-generators/push.js.map +1 -1
  98. package/dist/lib/generators/file-generators/pwa-install.js +11 -84
  99. package/dist/lib/generators/file-generators/pwa-install.js.map +1 -1
  100. package/dist/lib/generators/file-generators/quick-readme.js +8 -125
  101. package/dist/lib/generators/file-generators/quick-readme.js.map +1 -1
  102. package/dist/lib/generators/file-generators/reset.js +6 -0
  103. package/dist/lib/generators/file-generators/reset.js.map +1 -0
  104. package/dist/lib/generators/file-generators/server-push.js +3 -124
  105. package/dist/lib/generators/file-generators/server-push.js.map +1 -1
  106. package/dist/lib/generators/file-generators/sw-generator-build.js +8 -9
  107. package/dist/lib/generators/file-generators/sw-generator-build.js.map +1 -1
  108. package/dist/lib/generators/file-generators/sw-injector.js +10 -230
  109. package/dist/lib/generators/file-generators/sw-injector.js.map +1 -1
  110. package/dist/lib/generators/file-generators/type-definitions.js +2 -114
  111. package/dist/lib/generators/file-generators/type-definitions.js.map +1 -1
  112. package/dist/lib/generators/sw-generator.js +10 -20
  113. package/dist/lib/generators/sw-generator.js.map +1 -1
  114. package/dist/lib/generators/sw-sections/activate-handler.js +25 -3
  115. package/dist/lib/generators/sw-sections/activate-handler.js.map +1 -1
  116. package/dist/lib/generators/sw-sections/assemble-sw.js +20 -16
  117. package/dist/lib/generators/sw-sections/assemble-sw.js.map +1 -1
  118. package/dist/lib/generators/sw-sections/background-sync-handler.js +68 -19
  119. package/dist/lib/generators/sw-sections/background-sync-handler.js.map +1 -1
  120. package/dist/lib/generators/sw-sections/config-header.js +2 -2
  121. package/dist/lib/generators/sw-sections/config-header.js.map +1 -1
  122. package/dist/lib/generators/sw-sections/fetch-handler.js +506 -144
  123. package/dist/lib/generators/sw-sections/fetch-handler.js.map +1 -1
  124. package/dist/lib/generators/sw-sections/glob-matcher-code.js.map +1 -0
  125. package/dist/lib/generators/sw-sections/message-handler.js +55 -15
  126. package/dist/lib/generators/sw-sections/message-handler.js.map +1 -1
  127. package/dist/lib/generators/sw-sections/server-push-handler.js +12 -0
  128. package/dist/lib/generators/sw-sections/server-push-handler.js.map +1 -1
  129. package/dist/lib/generators/sw-sections/sw-push.js +67 -0
  130. package/dist/lib/generators/sw-sections/sw-push.js.map +1 -0
  131. package/dist/lib/generators/sw-sections/tag-management.js +65 -23
  132. package/dist/lib/generators/sw-sections/tag-management.js.map +1 -1
  133. package/dist/lib/generators/swoff-files-generator.js +66 -45
  134. package/dist/lib/generators/swoff-files-generator.js.map +1 -1
  135. package/dist/lib/shared/config-types.js +182 -71
  136. package/dist/lib/shared/config-types.js.map +1 -1
  137. package/dist/lib/shared/glob-matcher.js +77 -0
  138. package/dist/lib/shared/glob-matcher.js.map +1 -0
  139. package/dist/lib/utils/tty-status.js +21 -0
  140. package/dist/lib/utils/tty-status.js.map +1 -0
  141. package/dist/runtime/api-config.js +18 -0
  142. package/dist/runtime/api-config.js.map +1 -0
  143. package/dist/runtime/auth-state.js +35 -0
  144. package/dist/runtime/auth-state.js.map +1 -0
  145. package/dist/runtime/auth-store.js +273 -0
  146. package/dist/runtime/auth-store.js.map +1 -0
  147. package/dist/runtime/auth-user.js +168 -0
  148. package/dist/runtime/auth-user.js.map +1 -0
  149. package/dist/runtime/background-sync.js +59 -0
  150. package/dist/runtime/background-sync.js.map +1 -0
  151. package/dist/runtime/cache.js +30 -0
  152. package/dist/runtime/cache.js.map +1 -0
  153. package/dist/runtime/client-injector.js +136 -0
  154. package/dist/runtime/client-injector.js.map +1 -0
  155. package/dist/runtime/fetch-state.js +42 -0
  156. package/dist/runtime/fetch-state.js.map +1 -0
  157. package/dist/runtime/fetch-wrapper.js +355 -0
  158. package/dist/runtime/fetch-wrapper.js.map +1 -0
  159. package/dist/runtime/gql-wrapper.js +135 -0
  160. package/dist/runtime/gql-wrapper.js.map +1 -0
  161. package/dist/runtime/invalidation-tags.js +260 -0
  162. package/dist/runtime/invalidation-tags.js.map +1 -0
  163. package/dist/runtime/mutation-queue.js +304 -0
  164. package/dist/runtime/mutation-queue.js.map +1 -0
  165. package/dist/runtime/mutation-state.js +117 -0
  166. package/dist/runtime/mutation-state.js.map +1 -0
  167. package/dist/runtime/push.js +138 -0
  168. package/dist/runtime/push.js.map +1 -0
  169. package/dist/runtime/pwa-index.js +11 -0
  170. package/dist/runtime/pwa-index.js.map +1 -0
  171. package/dist/runtime/pwa-injector.js +44 -0
  172. package/dist/runtime/pwa-injector.js.map +1 -0
  173. package/dist/runtime/pwa-install.js +83 -0
  174. package/dist/runtime/pwa-install.js.map +1 -0
  175. package/dist/runtime/pwa-prompt.js +54 -0
  176. package/dist/runtime/pwa-prompt.js.map +1 -0
  177. package/dist/runtime/reset.js +148 -0
  178. package/dist/runtime/reset.js.map +1 -0
  179. package/dist/runtime/server-push.js +148 -0
  180. package/dist/runtime/server-push.js.map +1 -0
  181. package/dist/runtime/sw-injector.js +236 -0
  182. package/dist/runtime/sw-injector.js.map +1 -0
  183. package/dist/runtime/type-definitions.js +138 -0
  184. package/dist/runtime/type-definitions.js.map +1 -0
  185. package/dist/runtime/utils.js +27 -0
  186. package/dist/runtime/utils.js.map +1 -0
  187. package/package.json +3 -1
  188. package/templates/react/useAuth.jsx +106 -0
  189. package/templates/react/useAuth.tsx +118 -0
  190. package/templates/{hooks → react}/useBackgroundSync.jsx +6 -4
  191. package/templates/{hooks → react}/useBackgroundSync.tsx +6 -4
  192. package/templates/{hooks → react}/useCacheInvalidation.jsx +2 -2
  193. package/templates/react/useCacheInvalidation.tsx +52 -0
  194. package/templates/react/useCachedFetch.jsx +140 -0
  195. package/templates/react/useCachedFetch.tsx +160 -0
  196. package/templates/react/useIsFetching.jsx +32 -0
  197. package/templates/react/useIsFetching.tsx +32 -0
  198. package/templates/react/useMutation.jsx +141 -0
  199. package/templates/react/useMutation.tsx +180 -0
  200. package/templates/react/useMutationQueue.jsx +69 -0
  201. package/templates/react/useMutationQueue.tsx +83 -0
  202. package/templates/react/useMutationState.jsx +13 -0
  203. package/templates/react/useMutationState.tsx +25 -0
  204. package/templates/react/useNetworkStatus.jsx +61 -0
  205. package/templates/react/useNetworkStatus.tsx +76 -0
  206. package/templates/react/usePrefetch.jsx +32 -0
  207. package/templates/react/usePrefetch.tsx +42 -0
  208. package/templates/{hooks → react}/usePushSubscription.jsx +7 -7
  209. package/templates/{hooks → react}/usePushSubscription.tsx +7 -7
  210. package/templates/{hooks → react}/useSWUpdate.jsx +3 -3
  211. package/templates/{hooks → react}/useSWUpdate.tsx +4 -4
  212. package/templates/react/useSwoffReset.jsx +32 -0
  213. package/templates/react/useSwoffReset.tsx +39 -0
  214. package/templates/hooks/useAuth.jsx +0 -30
  215. package/templates/hooks/useAuth.tsx +0 -30
  216. package/templates/hooks/useCacheInvalidation.tsx +0 -19
  217. package/templates/hooks/useCachedFetch.jsx +0 -94
  218. package/templates/hooks/useCachedFetch.tsx +0 -112
  219. package/templates/hooks/useMutation.jsx +0 -76
  220. package/templates/hooks/useMutation.tsx +0 -97
  221. package/templates/hooks/useMutationQueue.jsx +0 -42
  222. package/templates/hooks/useMutationQueue.tsx +0 -49
  223. package/templates/hooks/useMutationState.jsx +0 -27
  224. package/templates/hooks/useMutationState.tsx +0 -41
  225. package/templates/hooks/useNetworkStatus.jsx +0 -19
  226. package/templates/hooks/useNetworkStatus.tsx +0 -19
  227. package/templates/hooks/usePrefetch.jsx +0 -10
  228. package/templates/hooks/usePrefetch.tsx +0 -25
@@ -0,0 +1,117 @@
1
+ import { T, R } from "./utils.js";
2
+ export function generateMutationStateCode(ctx) {
3
+ const { ext, ts } = ctx;
4
+ return `/**
5
+ * Swoff Mutation State
6
+ * Lightweight in-memory mutation state tracker.
7
+ * Enables per-mutation status UI (loading spinners, error states, success indicators).
8
+ *
9
+ * Usage:
10
+ * import { trackMutation, getMutationState, clearMutationState } from './swoff/mutation-state.${ext}';
11
+ *
12
+ * // After queueing a mutation
13
+ * const id = "mutation-" + crypto.randomUUID();
14
+ * trackMutation(id, "pending");
15
+ *
16
+ * // Check state later
17
+ * const state = getMutationState(id);
18
+ * if (state?.status === "error") { showError(state.error); }
19
+ *
20
+ * // Clear when done
21
+ * clearMutationState(id);
22
+ */
23
+
24
+ export type MutationStatus = "idle" | "pending" | "success" | "error";
25
+
26
+ export interface MutationState {
27
+ id${T(ts, "string")};
28
+ status${T(ts, "MutationStatus")};
29
+ error${T(ts, "Error | null")};
30
+ data${T(ts, "unknown")};
31
+ timestamp${T(ts, "number")};
32
+ }
33
+
34
+ const mutations = new Map<string, MutationState>();
35
+
36
+ let listenerId = 0;
37
+ const listeners = new Map<number, (state: MutationState) => void>();
38
+
39
+ /** Track a mutation with the given ID and initial status. */
40
+ export function trackMutation(id${T(ts, "string")}, status${T(ts, "MutationStatus")} = "idle")${R(ts, "MutationState")}{
41
+ let state = mutations.get(id);
42
+ if (!state) {
43
+ state = { id, status, error: null, data: null, timestamp: Date.now() };
44
+ mutations.set(id, state);
45
+ } else {
46
+ state.status = status;
47
+ state.timestamp = Date.now();
48
+ }
49
+ notifyListeners(state);
50
+ window.dispatchEvent(new CustomEvent("mutation-state-changed", { detail: state }));
51
+ return state;
52
+ }
53
+
54
+ /** Update an existing mutation's state. */
55
+ export function updateMutationState(id${T(ts, "string")}, partial${T(ts, "Partial<MutationState>")})${R(ts, "MutationState | null")}{
56
+ const state = mutations.get(id);
57
+ if (!state) return null;
58
+ Object.assign(state, partial);
59
+ state.timestamp = Date.now();
60
+ notifyListeners(state);
61
+ window.dispatchEvent(new CustomEvent("mutation-state-changed", { detail: state }));
62
+ return state;
63
+ }
64
+
65
+ /** Mark a mutation as successful with optional data. */
66
+ export function resolveMutation(id${T(ts, "string")}, data${T(ts, "unknown")} = null)${R(ts, "void")}{
67
+ updateMutationState(id, { status: "success", data, error: null });
68
+ }
69
+
70
+ /** Mark a mutation as failed with an error. */
71
+ export function rejectMutation(id${T(ts, "string")}, error${T(ts, "Error")})${R(ts, "void")}{
72
+ updateMutationState(id, { status: "error", error });
73
+ }
74
+
75
+ /** Get the current state of a mutation by ID. */
76
+ export function getMutationState(id${T(ts, "string")})${R(ts, "MutationState | undefined")}{
77
+ return mutations.get(id);
78
+ }
79
+
80
+ /** Remove a mutation's state from the tracker. */
81
+ export function clearMutationState(id${T(ts, "string")})${R(ts, "void")}{
82
+ mutations.delete(id);
83
+ }
84
+
85
+ /** Get all tracked mutations. */
86
+ export function getAllMutationStates()${R(ts, "MutationState[]")}{
87
+ return Array.from(mutations.values());
88
+ }
89
+
90
+ /** Get the count of mutations in a given status. */
91
+ export function getMutationCount(status${T(ts, "MutationStatus")})${R(ts, "number")}{
92
+ let count = 0;
93
+ for (const state of mutations.values()) {
94
+ if (state.status === status) count++;
95
+ }
96
+ return count;
97
+ }
98
+
99
+ /** Subscribe to mutation state changes. Returns an unsubscribe function. */
100
+ export function onMutationStateChange(callback${T(ts, "(state: MutationState) => void")})${R(ts, "() => void")}{
101
+ const id = ++listenerId;
102
+ listeners.set(id, callback);
103
+ return () => { listeners.delete(id); };
104
+ }
105
+
106
+ function notifyListeners(state${T(ts, "MutationState")})${R(ts, "void")}{
107
+ for (const cb of listeners.values()) {
108
+ try {
109
+ cb(state);
110
+ } catch {
111
+ // Handle listener errors silently
112
+ }
113
+ }
114
+ }
115
+ `;
116
+ }
117
+ //# sourceMappingURL=mutation-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutation-state.js","sourceRoot":"","sources":["../../src/runtime/mutation-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,UAAU,yBAAyB,CAAC,GAAmB;IAC3D,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC;IACxB,OAAO;;;;;;mGAM0F,GAAG;;;;;;;;;;;;;;;;;MAiBhG,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC;UACX,CAAC,CAAC,EAAE,EAAE,gBAAgB,CAAC;SACxB,CAAC,CAAC,EAAE,EAAE,cAAc,CAAC;QACtB,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;aACX,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC;;;;;;;;;kCASM,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,eAAe,CAAC;;;;;;;;;;;;;;;wCAe9E,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,wBAAwB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,sBAAsB,CAAC;;;;;;;;;;;oCAW/F,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC;;;;;mCAKjE,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC;;;;;qCAKtD,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,2BAA2B,CAAC;;;;;uCAKnD,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC;;;;;wCAK/B,CAAC,CAAC,EAAE,EAAE,iBAAiB,CAAC;;;;;yCAKvB,CAAC,CAAC,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC;;;;;;;;;gDASnC,CAAC,CAAC,EAAE,EAAE,gCAAgC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,YAAY,CAAC;;;;;;gCAM9E,CAAC,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC;;;;;;;;;CAStE,CAAC;AACF,CAAC"}
@@ -0,0 +1,138 @@
1
+ import { T, R, PT, AS } from "./utils.js";
2
+ export function generatePushCode(ctx) {
3
+ const { ext, ts } = ctx;
4
+ const vapidKey = ctx.vapidKey;
5
+ return `/**
6
+ * Swoff Push Notifications
7
+ * Push subscription management with IndexedDB persistence.
8
+ *
9
+ * Usage:
10
+ * import { subscribeToPush, unsubscribeFromPush, isSubscribed } from './swoff/realtime/notifications.${ext}';
11
+ *
12
+ * // Enable (triggers permission prompt)
13
+ * const subscription = await subscribeToPush();
14
+ * await fetch("/api/push/subscribe", {
15
+ * method: "POST",
16
+ * body: JSON.stringify(subscription.toJSON()),
17
+ * });
18
+ *
19
+ * // Disable
20
+ * await unsubscribeFromPush();
21
+ *
22
+ * Window events:
23
+ * push-permission-changed - Permission granted/denied (detail: { permission })
24
+ * push-subscription-changed - Subscribed/unsubscribed (detail: { subscribed })
25
+ */
26
+
27
+ const SUBSCRIPTION_DB = "swoff-push";
28
+ const SUBSCRIPTION_STORE = "subscription";
29
+ // Bump this when adding new indexes/stores for schema migration
30
+ const DB_VERSION = 1;
31
+ const VAPID_PUBLIC_KEY = ${JSON.stringify(vapidKey)};
32
+
33
+ let permissionState${T(ts, "NotificationPermission | undefined")} = typeof Notification !== "undefined" ? Notification.permission : undefined;
34
+
35
+ function openPushDB()${R(ts, "Promise<IDBDatabase>")}{
36
+ return new Promise${PT(ts, "IDBDatabase")}((resolve, reject) => {
37
+ const request = indexedDB.open(SUBSCRIPTION_DB, DB_VERSION);
38
+ request.onupgradeneeded = (e) => {
39
+ const db = (e.target${AS(ts, "IDBOpenDBRequest")}).result;
40
+ if (!db.objectStoreNames.contains(SUBSCRIPTION_STORE)) {
41
+ db.createObjectStore(SUBSCRIPTION_STORE, { keyPath: "id" });
42
+ }
43
+ };
44
+ request.onsuccess = (e) => resolve((e.target${AS(ts, "IDBOpenDBRequest")}).result);
45
+ request.onerror = (e) => reject((e.target${AS(ts, "IDBRequest")}).error);
46
+ });
47
+ }
48
+
49
+ /** Request notification permission from the user. Returns true if granted. */
50
+ export async function requestNotificationPermission()${R(ts, "Promise<boolean>")}{
51
+ if (permissionState === "granted") return true;
52
+ if (permissionState === "denied") return false;
53
+
54
+ const result = await Notification.requestPermission();
55
+ permissionState = result;
56
+ window.dispatchEvent(
57
+ new CustomEvent("push-permission-changed", { detail: { permission: result } }),
58
+ );
59
+ return result === "granted";
60
+ }
61
+
62
+ /** Get the current push subscription, or null if not subscribed. */
63
+ export async function getPushSubscription()${R(ts, "Promise<PushSubscription | null>")}{
64
+ try {
65
+ const registration = await navigator.serviceWorker.ready;
66
+ return await registration.pushManager.getSubscription();
67
+ } catch {
68
+ return null;
69
+ }
70
+ }
71
+
72
+ /** Subscribe to push notifications. Returns the subscription or null if permission denied. Uses the VAPID public key from your swoff.config.json. */
73
+ export async function subscribeToPush()${R(ts, "Promise<PushSubscription | null>")}{
74
+ const granted = await requestNotificationPermission();
75
+ if (!granted) return null;
76
+
77
+ const registration = await navigator.serviceWorker.ready;
78
+ const subscription = await registration.pushManager.subscribe({
79
+ userVisibleOnly: true,
80
+ applicationServerKey: urlBase64ToUint8Array(VAPID_PUBLIC_KEY)${AS(ts, "BufferSource")},
81
+ });
82
+
83
+ const db = await openPushDB();
84
+ const tx = db.transaction(SUBSCRIPTION_STORE, "readwrite");
85
+ tx.objectStore(SUBSCRIPTION_STORE).put({
86
+ id: "current",
87
+ endpoint: subscription.endpoint,
88
+ keys: subscription.toJSON().keys,
89
+ subscribedAt: Date.now(),
90
+ });
91
+ await new Promise<void>((resolve, reject) => {
92
+ tx.oncomplete = () => resolve();
93
+ tx.onerror = () => reject(tx.error);
94
+ });
95
+
96
+ window.dispatchEvent(
97
+ new CustomEvent("push-subscription-changed", { detail: { subscribed: true } }),
98
+ );
99
+
100
+ return subscription;
101
+ }
102
+
103
+ /** Unsubscribe from push notifications. */
104
+ export async function unsubscribeFromPush()${R(ts, "Promise<void>")}{
105
+ const subscription = await getPushSubscription();
106
+ if (!subscription) return;
107
+
108
+ await subscription.unsubscribe();
109
+
110
+ const db = await openPushDB();
111
+ const tx = db.transaction(SUBSCRIPTION_STORE, "readwrite");
112
+ tx.objectStore(SUBSCRIPTION_STORE).delete("current");
113
+ await new Promise<void>((resolve, reject) => {
114
+ tx.oncomplete = () => resolve();
115
+ tx.onerror = () => reject(tx.error);
116
+ });
117
+
118
+ window.dispatchEvent(
119
+ new CustomEvent("push-subscription-changed", { detail: { subscribed: false } }),
120
+ );
121
+ }
122
+
123
+ /** Check if the user is subscribed to push notifications. */
124
+ export async function isSubscribed()${R(ts, "Promise<boolean>")}{
125
+ const sub = await getPushSubscription();
126
+ return sub !== null;
127
+ }
128
+
129
+ /** Convert a base64 VAPID public key to a Uint8Array for pushManager.subscribe(). */
130
+ function urlBase64ToUint8Array(base64String${T(ts, "string")})${R(ts, "Uint8Array")}{
131
+ const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
132
+ const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
133
+ const rawData = atob(base64);
134
+ return Uint8Array.from(rawData, (c) => c.charCodeAt(0));
135
+ }
136
+ `;
137
+ }
138
+ //# sourceMappingURL=push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.js","sourceRoot":"","sources":["../../src/runtime/push.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,UAAU,gBAAgB,CAAC,GAA0C;IACzE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC;IACxB,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,OAAO;;;;;0GAKiG,GAAG;;;;;;;;;;;;;;;;;;;;;2BAqBlF,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;qBAE9B,CAAC,CAAC,EAAE,EAAE,oCAAoC,CAAC;;uBAEzC,CAAC,CAAC,EAAE,EAAE,sBAAsB,CAAC;sBAC9B,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC;;;4BAGf,EAAE,CAAC,EAAE,EAAE,kBAAkB,CAAC;;;;;kDAKJ,EAAE,CAAC,EAAE,EAAE,kBAAkB,CAAC;+CAC7B,EAAE,CAAC,EAAE,EAAE,YAAY,CAAC;;;;;uDAKZ,CAAC,CAAC,EAAE,EAAE,kBAAkB,CAAC;;;;;;;;;;;;;6CAanC,CAAC,CAAC,EAAE,EAAE,kCAAkC,CAAC;;;;;;;;;;yCAU7C,CAAC,CAAC,EAAE,EAAE,kCAAkC,CAAC;;;;;;;mEAOf,EAAE,CAAC,EAAE,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;6CAwB5C,CAAC,CAAC,EAAE,EAAE,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;sCAoB7B,CAAC,CAAC,EAAE,EAAE,kBAAkB,CAAC;;;;;;6CAMlB,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,YAAY,CAAC;;;;;;CAMlF,CAAC;AACF,CAAC"}
@@ -0,0 +1,11 @@
1
+ export function generatePwaIndexCode(ctx) {
2
+ const { ext } = ctx;
3
+ return `/**
4
+ * Swoff PWA
5
+ * Re-exports from PWA sub-modules for convenience imports.
6
+ */
7
+ export { setupPwaInstall } from "./injector.${ext}";
8
+ export { isInstallable, promptInstall } from "./prompt.${ext}";
9
+ `;
10
+ }
11
+ //# sourceMappingURL=pwa-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pwa-index.js","sourceRoot":"","sources":["../../src/runtime/pwa-index.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,GAAmB;IACtD,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAEpB,OAAO;;;;8CAIqC,GAAG;yDACQ,GAAG;CAC3D,CAAC;AACF,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { R } from "./utils.js";
2
+ export function generatePwaInjectorCode(ctx) {
3
+ const { ext, ts } = ctx;
4
+ const preventLine = ctx.preventDefaultInstall ? " e.preventDefault();\n" : "";
5
+ return `/**
6
+ * Swoff PWA Injector
7
+ * Service worker installation event wiring for PWA installability.
8
+ *
9
+ * Usage:
10
+ * import { setupPwaInstall } from './swoff/pwa/injector.${ext}';
11
+ * setupPwaInstall();
12
+ *
13
+ * Window properties:
14
+ * window.deferredInstallPrompt - The captured BeforeInstallPromptEvent
15
+ */
16
+
17
+ /** Set up beforeinstallprompt and appinstalled event listeners. Call once at app startup. */
18
+ export function setupPwaInstall()${R(ts, "void")}{
19
+ window.addEventListener("beforeinstallprompt", (e) => {
20
+ window.deferredInstallPrompt = e as BeforeInstallPromptEvent;
21
+ window.pwaInstallable = true;
22
+
23
+ ${preventLine}
24
+ window.dispatchEvent(
25
+ new CustomEvent("pwa-installable", {
26
+ detail: { isInstallable: true },
27
+ })
28
+ );
29
+ });
30
+
31
+ window.addEventListener("appinstalled", () => {
32
+ window.deferredInstallPrompt = null;
33
+ window.pwaInstallable = false;
34
+
35
+ window.dispatchEvent(
36
+ new CustomEvent("pwa-installed", {
37
+ detail: { outcome: "accepted" },
38
+ })
39
+ );
40
+ });
41
+ }
42
+ `;
43
+ }
44
+ //# sourceMappingURL=pwa-injector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pwa-injector.js","sourceRoot":"","sources":["../../src/runtime/pwa-injector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAE/B,MAAM,UAAU,uBAAuB,CAAC,GAAwD;IAC9F,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC;IACxB,MAAM,WAAW,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjF,OAAO;;;;;6DAKoD,GAAG;;;;;;;;mCAQ7B,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC;;;;;EAK9C,WAAW;;;;;;;;;;;;;;;;;;;CAmBZ,CAAC;AACF,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { R } from "./utils.js";
2
+ export function generatePwaInstallCode(ctx) {
3
+ const { ext, ts } = ctx;
4
+ const preventLine = ctx.preventDefaultInstall ? " e.preventDefault();\n" : "";
5
+ return `/**
6
+ * Swoff PWA Install Support
7
+ * Manual install trigger, installability check, and event listener setup.
8
+ *
9
+ * Usage:
10
+ * import { setupPwaInstall, isInstallable, promptInstall } from './swoff/pwa/prompt.${ext}';
11
+ *
12
+ * setupPwaInstall(); // sets up beforeinstallprompt and appinstalled listeners
13
+ *
14
+ * if (isInstallable()) {
15
+ * const result = await promptInstall();
16
+ * }
17
+ *
18
+ * Window properties:
19
+ * window.deferredInstallPrompt - The captured BeforeInstallPromptEvent
20
+ */
21
+
22
+ /** Set up beforeinstallprompt and appinstalled event listeners. Call once at app startup. */
23
+ export function setupPwaInstall()${R(ts, "void")}{
24
+ window.addEventListener("beforeinstallprompt", (e) => {
25
+ window.deferredInstallPrompt = e as BeforeInstallPromptEvent;
26
+ window.pwaInstallable = true;
27
+
28
+ ${preventLine}
29
+ window.dispatchEvent(
30
+ new CustomEvent("pwa-installable", {
31
+ detail: { isInstallable: true },
32
+ })
33
+ );
34
+ });
35
+
36
+ window.addEventListener("appinstalled", () => {
37
+ window.deferredInstallPrompt = null;
38
+ window.pwaInstallable = false;
39
+
40
+ window.dispatchEvent(
41
+ new CustomEvent("pwa-installed", {
42
+ detail: { outcome: "accepted" },
43
+ })
44
+ );
45
+ });
46
+ }
47
+
48
+ /** Check if the PWA install prompt is available (user has met install criteria). */
49
+ export function isInstallable()${R(ts, "boolean")}{
50
+ return !!window.deferredInstallPrompt;
51
+ }
52
+
53
+ /** Show the browser's native install prompt. Throws if prompt is not available. */
54
+ export async function promptInstall()${R(ts, "Promise<{ outcome: string }>")}{
55
+ if (!window.deferredInstallPrompt) {
56
+ throw new Error("Install prompt not available");
57
+ }
58
+
59
+ const promptEvent = window.deferredInstallPrompt;
60
+ await promptEvent.prompt();
61
+
62
+ const choice = await promptEvent.userChoice;
63
+
64
+ if (choice.outcome === "accepted") {
65
+ window.dispatchEvent(
66
+ new CustomEvent("pwa-installed", {
67
+ detail: { outcome: "accepted" },
68
+ })
69
+ );
70
+ } else {
71
+ window.dispatchEvent(
72
+ new CustomEvent("pwa-dismissed", {
73
+ detail: { outcome: "dismissed" },
74
+ })
75
+ );
76
+ }
77
+
78
+ window.deferredInstallPrompt = null;
79
+ return choice;
80
+ }
81
+ `;
82
+ }
83
+ //# sourceMappingURL=pwa-install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pwa-install.js","sourceRoot":"","sources":["../../src/runtime/pwa-install.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAE/B,MAAM,UAAU,sBAAsB,CAAC,GAAwD;IAC7F,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC;IACxB,MAAM,WAAW,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjF,OAAO;;;;;yFAKgF,GAAG;;;;;;;;;;;;;mCAazD,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC;;;;;EAK9C,WAAW;;;;;;;;;;;;;;;;;;;;;iCAqBoB,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;;;;;uCAKV,CAAC,CAAC,EAAE,EAAE,8BAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B3E,CAAC;AACF,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { R } from "./utils.js";
2
+ export function generatePwaPromptCode(ctx) {
3
+ const { ext, ts } = ctx;
4
+ return `/**
5
+ * Swoff PWA Install Prompt
6
+ * Installability check and manual prompt trigger.
7
+ *
8
+ * Usage:
9
+ * import { isInstallable, promptInstall } from './swoff/pwa/prompt.${ext}';
10
+ *
11
+ * if (isInstallable()) {
12
+ * const result = await promptInstall();
13
+ * }
14
+ *
15
+ * Window properties:
16
+ * window.deferredInstallPrompt - The captured BeforeInstallPromptEvent
17
+ */
18
+
19
+ /** Check if the PWA install prompt is available (user has met install criteria). */
20
+ export function isInstallable()${R(ts, "boolean")}{
21
+ return !!window.deferredInstallPrompt;
22
+ }
23
+
24
+ /** Show the browser's native install prompt. Throws if prompt is not available. */
25
+ export async function promptInstall()${R(ts, "Promise<{ outcome: string }>")}{
26
+ if (!window.deferredInstallPrompt) {
27
+ throw new Error("Install prompt not available");
28
+ }
29
+
30
+ const promptEvent = window.deferredInstallPrompt;
31
+ await promptEvent.prompt();
32
+
33
+ const choice = await promptEvent.userChoice;
34
+
35
+ if (choice.outcome === "accepted") {
36
+ window.dispatchEvent(
37
+ new CustomEvent("pwa-installed", {
38
+ detail: { outcome: "accepted" },
39
+ })
40
+ );
41
+ } else {
42
+ window.dispatchEvent(
43
+ new CustomEvent("pwa-dismissed", {
44
+ detail: { outcome: "dismissed" },
45
+ })
46
+ );
47
+ }
48
+
49
+ window.deferredInstallPrompt = null;
50
+ return choice;
51
+ }
52
+ `;
53
+ }
54
+ //# sourceMappingURL=pwa-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pwa-prompt.js","sourceRoot":"","sources":["../../src/runtime/pwa-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAE/B,MAAM,UAAU,qBAAqB,CAAC,GAAmB;IACvD,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC;IAExB,OAAO;;;;;wEAK+D,GAAG;;;;;;;;;;;iCAW1C,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;;;;;uCAKV,CAAC,CAAC,EAAE,EAAE,8BAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B3E,CAAC;AACF,CAAC"}
@@ -0,0 +1,148 @@
1
+ import { T, R } from "./utils.js";
2
+ export function generateResetCode(ctx) {
3
+ const { ext, ts } = ctx;
4
+ return `/**
5
+ * Swoff Reset
6
+ * Nuclear option: wipe all swoff data (caches, IndexedDB, localStorage),
7
+ * unregister the service worker, then re-register from scratch.
8
+ *
9
+ * Usage:
10
+ * import { resetSwoff } from './swoff/reset.${ext}';
11
+ *
12
+ * // Full reset (default)
13
+ * const result = await resetSwoff();
14
+ * console.log(result.unregistered, result.reregistered, result.warnings);
15
+ *
16
+ * // Selective reset — keep caches but reset IDB + SW
17
+ * await resetSwoff({ clearCache: false });
18
+ *
19
+ * Events dispatched:
20
+ * swoff:reset-start — before any cleanup begins
21
+ * swoff:reset-complete — after everything finishes (detail: { unregistered, reregistered, warnings })
22
+ */
23
+
24
+ import { initServiceWorker } from "./sw/injector.${ext}";
25
+
26
+ export interface ResetSwoffOptions {
27
+ /** Clear all Cache Storage caches (default: true) */
28
+ clearCache${T(ts, "boolean")};
29
+ /** Delete all swoff-* IndexedDB databases (default: true) */
30
+ clearIdb${T(ts, "boolean")};
31
+ /** Clear localStorage keys like swRegisteredVersion (default: true) */
32
+ clearStorage${T(ts, "boolean")};
33
+ /** Unregister SW then re-register (default: true) */
34
+ unregisterSW${T(ts, "boolean")};
35
+ }
36
+
37
+ const DEFAULT_OPTIONS: ResetSwoffOptions = {
38
+ clearCache: true,
39
+ clearIdb: true,
40
+ clearStorage: true,
41
+ unregisterSW: true,
42
+ };
43
+
44
+ const KNOWN_DB_NAMES = [
45
+ "swoff-auth",
46
+ "swoff-auth-user",
47
+ "swoff-queue",
48
+ "swoff-cache-tags",
49
+ "swoff-push",
50
+ ];
51
+
52
+ /** Delete all known swoff-* IndexedDB databases. Also tries indexedDB.databases() API to catch any unknown swoff-* databases. */
53
+ async function deleteSwoffDatabases(warnings${T(ts, "string[]")})${R(ts, "Promise<void>")}{
54
+ const dbNames = [...KNOWN_DB_NAMES];
55
+
56
+ // Use the modern databases() API if available to catch unknown swoff-* DBs
57
+ try {
58
+ const allDbs = await indexedDB.databases?.();
59
+ if (allDbs) {
60
+ for (const db of allDbs) {
61
+ if (db.name && db.name.startsWith("swoff-") && !dbNames.includes(db.name)) {
62
+ dbNames.push(db.name);
63
+ }
64
+ }
65
+ }
66
+ } catch { /* not supported — use known list */ }
67
+
68
+ for (const name of dbNames) {
69
+ try {
70
+ indexedDB.deleteDatabase(name);
71
+ } catch (e) {
72
+ warnings.push(\`Failed to delete database "\${name}": \${e}\`);
73
+ }
74
+ }
75
+ }
76
+
77
+ /** Nuclear reset: wipes all swoff-persisted data, unregisters the SW, then re-registers from scratch. Returns detailed results. */
78
+ export async function resetSwoff(opts${T(ts, "Partial<ResetSwoffOptions>")} = {})${R(ts, "Promise<{ unregistered: boolean; reregistered: boolean; warnings: string[] }>")}{
79
+ const options${T(ts, "ResetSwoffOptions")} = { ...DEFAULT_OPTIONS, ...opts };
80
+ const warnings${T(ts, "string[]")} = [];
81
+
82
+ window.dispatchEvent(new CustomEvent("swoff:reset-start"));
83
+
84
+ // 1. Clear Cache Storage
85
+ if (options.clearCache) {
86
+ try {
87
+ if (typeof caches !== "undefined") {
88
+ const keys = await caches.keys();
89
+ await Promise.all(keys.map((k) => caches.delete(k)));
90
+ }
91
+ } catch (e) {
92
+ warnings.push(\`Failed to clear caches: \${e}\`);
93
+ }
94
+ }
95
+
96
+ // 2. Delete IndexedDB databases
97
+ if (options.clearIdb) {
98
+ await deleteSwoffDatabases(warnings);
99
+ }
100
+
101
+ // 3. Clear localStorage
102
+ if (options.clearStorage) {
103
+ try {
104
+ localStorage.removeItem("swRegisteredVersion");
105
+ } catch (e) {
106
+ warnings.push(\`Failed to clear localStorage: \${e}\`);
107
+ }
108
+ }
109
+
110
+ // 4. Unregister SW
111
+ let unregistered = false;
112
+ if (options.unregisterSW) {
113
+ try {
114
+ if ("serviceWorker" in navigator) {
115
+ const reg = await navigator.serviceWorker.getRegistration();
116
+ if (reg) {
117
+ unregistered = await reg.unregister();
118
+ }
119
+ }
120
+ } catch (e) {
121
+ warnings.push(\`Failed to unregister SW: \${e}\`);
122
+ }
123
+
124
+ // Always clear the version marker before re-registering so initServiceWorker
125
+ // detects a fresh install rather than trying to reuse a stale registration
126
+ try {
127
+ localStorage.removeItem("swRegisteredVersion");
128
+ } catch { /* ignore */ }
129
+ }
130
+
131
+ // 5. Re-register SW
132
+ let reregistered = false;
133
+ if (options.unregisterSW) {
134
+ try {
135
+ await initServiceWorker();
136
+ reregistered = true;
137
+ } catch (e) {
138
+ warnings.push(\`Failed to re-register SW: \${e}\`);
139
+ }
140
+ }
141
+
142
+ const result = { unregistered, reregistered, warnings };
143
+ window.dispatchEvent(new CustomEvent("swoff:reset-complete", { detail: result }));
144
+ return result;
145
+ }
146
+ `;
147
+ }
148
+ //# sourceMappingURL=reset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.js","sourceRoot":"","sources":["../../src/runtime/reset.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACnD,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC;IACxB,OAAO;;;;;;iDAMwC,GAAG;;;;;;;;;;;;;;mDAcD,GAAG;;;;cAIxC,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;;YAElB,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;;gBAEZ,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;;gBAEhB,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;8CAmBc,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;uCAyBlD,CAAC,CAAC,EAAE,EAAE,4BAA4B,CAAE,SAAS,CAAC,CAAC,EAAE,EAAE,+EAA+E,CAAC;iBACzJ,CAAC,CAAC,EAAE,EAAE,mBAAmB,CAAC;kBACzB,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkElC,CAAC;AACF,CAAC"}