@tutti-os/desktop-update-admission 0.0.266

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 (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +112 -0
  3. package/dist/chunk-GONYAEKF.js +139 -0
  4. package/dist/chunk-GONYAEKF.js.map +1 -0
  5. package/dist/chunk-LV67FBCG.js +112 -0
  6. package/dist/chunk-LV67FBCG.js.map +1 -0
  7. package/dist/chunk-TRALK3GT.js +33 -0
  8. package/dist/chunk-TRALK3GT.js.map +1 -0
  9. package/dist/chunk-X4U7GODT.js +134 -0
  10. package/dist/chunk-X4U7GODT.js.map +1 -0
  11. package/dist/chunk-ZQTIYDGZ.js +603 -0
  12. package/dist/chunk-ZQTIYDGZ.js.map +1 -0
  13. package/dist/contracts/index.d.ts +97 -0
  14. package/dist/contracts/index.js +15 -0
  15. package/dist/contracts/index.js.map +1 -0
  16. package/dist/core/index.d.ts +19 -0
  17. package/dist/core/index.js +13 -0
  18. package/dist/core/index.js.map +1 -0
  19. package/dist/development/index.d.ts +133 -0
  20. package/dist/development/index.js +289 -0
  21. package/dist/development/index.js.map +1 -0
  22. package/dist/development/mock-server-cli.d.ts +1 -0
  23. package/dist/development/mock-server-cli.js +67 -0
  24. package/dist/development/mock-server-cli.js.map +1 -0
  25. package/dist/electron-main/index.d.ts +38 -0
  26. package/dist/electron-main/index.js +498 -0
  27. package/dist/electron-main/index.js.map +1 -0
  28. package/dist/i18n/index.d.ts +64 -0
  29. package/dist/i18n/index.js +74 -0
  30. package/dist/i18n/index.js.map +1 -0
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +25 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/mandatory-updater/index.d.ts +23 -0
  35. package/dist/mandatory-updater/index.js +10 -0
  36. package/dist/mandatory-updater/index.js.map +1 -0
  37. package/dist/preload/index.d.ts +9 -0
  38. package/dist/preload/index.js +30 -0
  39. package/dist/preload/index.js.map +1 -0
  40. package/dist/react/index.d.ts +13 -0
  41. package/dist/react/index.js +116 -0
  42. package/dist/react/index.js.map +1 -0
  43. package/package.json +98 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025-2026 The Tutti Authors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @tutti-os/desktop-update-admission
2
+
3
+ Product-neutral minimum-version admission and forced desktop update mechanics
4
+ shared by Tutti Desktop and TSH Desktop.
5
+
6
+ The package owns the client contract, response validation, startup and
7
+ foreground admission lifecycle, mandatory updater lease, Electron upgrade
8
+ window binding, preload API factory, shared React presentation, and default
9
+ i18n resources.
10
+
11
+ Consumers still own:
12
+
13
+ - policy transport (`outboundFetch` for Tutti, desktopd for TSH)
14
+ - release-feed resolution and the concrete updater driver
15
+ - normal update preferences and scheduling
16
+ - product download URLs, logging sinks, window assets, and business-window
17
+ enumeration
18
+
19
+ The server remains authoritative for deciding whether the installed version is
20
+ allowed. The client compares the updater target with the returned minimum only
21
+ to prevent installing a release that cannot satisfy the active policy.
22
+
23
+ ## Development scenarios
24
+
25
+ Both desktop hosts resolve one immutable client scenario from the
26
+ `DESKTOP_UPDATE_ADMISSION_*` environment variables. Packaged applications
27
+ ignore these variables before parsing them. Invalid enabled scenarios fail
28
+ startup instead of falling back to production values.
29
+
30
+ Client-owned variables are:
31
+
32
+ | Variable | Meaning |
33
+ | ------------------------------------------------- | ----------------------------------------------------------------------------------- |
34
+ | `DESKTOP_UPDATE_ADMISSION_DEV` | Enables the unpackaged-only scenario. |
35
+ | `DESKTOP_UPDATE_ADMISSION_CURRENT_VERSION` | Supplies the one current version used by admission requests and the updater driver. |
36
+ | `DESKTOP_UPDATE_ADMISSION_LATEST_VERSION` | Supplies the updater target for available/downloaded outcomes. |
37
+ | `DESKTOP_UPDATE_ADMISSION_UPDATER` | Selects `available`, `downloaded`, `unavailable`, `error`, or `targetBelowMinimum`. |
38
+ | `DESKTOP_UPDATE_ADMISSION_DOWNLOAD` | Selects `success` or `error`. |
39
+ | `DESKTOP_UPDATE_ADMISSION_INSTALL` | Selects `simulated` or `error`; neither performs a real installation. |
40
+ | `DESKTOP_UPDATE_ADMISSION_FOREGROUND_INTERVAL_MS` | Overrides the foreground admission interval with an integer of at least 100 ms. |
41
+ | `DESKTOP_UPDATE_ADMISSION_TRANSPORT` | Selects `in-process` (default) or `loopback`. |
42
+ | `DESKTOP_UPDATE_ADMISSION_MOCK_SERVER_URL` | Supplies the exact `http://127.0.0.1` origin required by loopback clients. |
43
+
44
+ Policy variables are parsed by the in-process client checker or by the
45
+ standalone loopback server, never by both:
46
+
47
+ | Variable | Meaning |
48
+ | ------------------------------------------- | ----------------------------------------------------------------------------------------------- |
49
+ | `DESKTOP_UPDATE_ADMISSION_MINIMUM_VERSION` | Supplies the default minimum for policy steps that require one. |
50
+ | `DESKTOP_UPDATE_ADMISSION_POLICY` | Selects one policy outcome. |
51
+ | `DESKTOP_UPDATE_ADMISSION_POLICY_SEQUENCE` | Selects a comma-separated per-client outcome sequence such as `upgradeRequired@1.1.0,disabled`. |
52
+ | `DESKTOP_UPDATE_ADMISSION_SCENARIO` | Selects one named policy scenario instead of individual policy fields. |
53
+ | `DESKTOP_UPDATE_ADMISSION_MOCK_SERVER_PORT` | Selects the loopback CLI port; omit it for an ephemeral port. |
54
+
55
+ The shortest startup-blocking scenario is:
56
+
57
+ ```bash
58
+ DESKTOP_UPDATE_ADMISSION_DEV=1 \
59
+ DESKTOP_UPDATE_ADMISSION_POLICY=upgradeRequired \
60
+ DESKTOP_UPDATE_ADMISSION_CURRENT_VERSION=1.0.0 \
61
+ DESKTOP_UPDATE_ADMISSION_MINIMUM_VERSION=1.1.0 \
62
+ DESKTOP_UPDATE_ADMISSION_LATEST_VERSION=1.2.0 \
63
+ DESKTOP_UPDATE_ADMISSION_UPDATER=available
64
+ ```
65
+
66
+ Policy sequences make cross-request behavior deterministic. For example,
67
+ `upgradeRequired@1.1.0,disabled` releases the block on retry, while
68
+ `allowed@1.0.0,upgradeRequired@1.1.0` allows startup and prompts after the
69
+ foreground interval.
70
+
71
+ Named scenarios are also available:
72
+
73
+ - `startup-force-success`
74
+ - `startup-policy-timeout`
75
+ - `startup-updater-unavailable`
76
+ - `startup-target-below-minimum`
77
+ - `startup-download-error`
78
+ - `retry-policy-released`
79
+ - `foreground-upgrade-required`
80
+
81
+ The default `in-process` transport parses client and policy variables in one
82
+ process for fast state-machine tests.
83
+
84
+ To exercise the real HTTP path, give policy variables only to the loopback
85
+ server:
86
+
87
+ ```bash
88
+ DESKTOP_UPDATE_ADMISSION_DEV=1 \
89
+ DESKTOP_UPDATE_ADMISSION_POLICY=upgradeRequired \
90
+ DESKTOP_UPDATE_ADMISSION_MINIMUM_VERSION=1.4.0 \
91
+ DESKTOP_UPDATE_ADMISSION_MOCK_SERVER_PORT=43210 \
92
+ pnpm exec desktop-update-admission-mock-server
93
+ ```
94
+
95
+ Then start a client with only client-owned variables:
96
+
97
+ ```bash
98
+ DESKTOP_UPDATE_ADMISSION_DEV=1 \
99
+ DESKTOP_UPDATE_ADMISSION_CURRENT_VERSION=1.0.0 \
100
+ DESKTOP_UPDATE_ADMISSION_TRANSPORT=loopback \
101
+ DESKTOP_UPDATE_ADMISSION_MOCK_SERVER_URL=http://127.0.0.1:43210
102
+ ```
103
+
104
+ The loopback client defaults its updater to `unavailable`. To exercise a forced
105
+ updater flow, add `DESKTOP_UPDATE_ADMISSION_UPDATER=available` and
106
+ `DESKTOP_UPDATE_ADMISSION_LATEST_VERSION=1.5.0` to the client command. Policy
107
+ variables supplied to a loopback client are rejected so an HTTP test cannot
108
+ accidentally gain a second policy source.
109
+
110
+ The server binds only to `127.0.0.1`. Simulated installation never invokes a
111
+ real installer or application restart and is rendered as a distinct
112
+ development-only completion state.
@@ -0,0 +1,139 @@
1
+ import {
2
+ updaterTargetMeetsMinimum
3
+ } from "./chunk-LV67FBCG.js";
4
+
5
+ // src/mandatory-updater/mandatoryUpdaterSession.ts
6
+ import { AsyncLocalStorage } from "node:async_hooks";
7
+ var MandatoryUpdateTargetError = class extends Error {
8
+ latestVersion;
9
+ minimumVersion;
10
+ constructor(latestVersion, minimumVersion) {
11
+ super(
12
+ `mandatory update target ${latestVersion ?? "unknown"} is below ${minimumVersion}`
13
+ );
14
+ this.name = "MandatoryUpdateTargetError";
15
+ this.latestVersion = latestVersion;
16
+ this.minimumVersion = minimumVersion;
17
+ }
18
+ };
19
+ function createMandatoryUpdaterLeaseManager(options) {
20
+ const mandatoryContext = new AsyncLocalStorage();
21
+ const normalRestoreContext = new AsyncLocalStorage();
22
+ let mandatoryOwner = null;
23
+ const assertAccess = () => {
24
+ if (mandatoryOwner && mandatoryContext.getStore() !== mandatoryOwner) {
25
+ throw new Error(
26
+ "application updater is owned by the mandatory update session"
27
+ );
28
+ }
29
+ };
30
+ return {
31
+ assertAccess,
32
+ isMandatoryAccess: () => mandatoryOwner !== null && mandatoryContext.getStore() === mandatoryOwner && normalRestoreContext.getStore() !== mandatoryOwner,
33
+ async acquire(input) {
34
+ if (mandatoryOwner) {
35
+ throw new Error("a mandatory update session is already active");
36
+ }
37
+ const owner = /* @__PURE__ */ Symbol(
38
+ `mandatory-update:${input.policyRevision}:${input.minimumVersion}`
39
+ );
40
+ mandatoryOwner = owner;
41
+ const configurationToRestore = options.captureNormalConfiguration();
42
+ try {
43
+ await options.suspendNormalUpdates();
44
+ } catch (error) {
45
+ if (mandatoryOwner === owner) {
46
+ mandatoryOwner = null;
47
+ }
48
+ throw error;
49
+ }
50
+ let target = input;
51
+ let released = false;
52
+ let releasePromise = null;
53
+ const run = (operation) => {
54
+ if (released || mandatoryOwner !== owner) {
55
+ return Promise.reject(
56
+ new Error("mandatory update session is no longer active")
57
+ );
58
+ }
59
+ return mandatoryContext.run(owner, operation);
60
+ };
61
+ const assertTargetVersion = (update) => {
62
+ if (!updaterTargetMeetsMinimum(
63
+ update.latestVersion,
64
+ target.minimumVersion
65
+ )) {
66
+ throw new MandatoryUpdateTargetError(
67
+ update.latestVersion,
68
+ target.minimumVersion
69
+ );
70
+ }
71
+ };
72
+ const assertTargetWhenPresent = (update) => {
73
+ if (update.status === "available" || update.status === "downloaded") {
74
+ assertTargetVersion(update);
75
+ }
76
+ };
77
+ return {
78
+ retarget: (nextTarget) => {
79
+ if (released || mandatoryOwner !== owner) {
80
+ throw new Error("mandatory update session is no longer active");
81
+ }
82
+ target = nextTarget;
83
+ },
84
+ prepare: () => run(async () => {
85
+ const update = await options.prepareMandatoryUpdate({
86
+ channel: target.channel,
87
+ policy: "prompt"
88
+ });
89
+ assertTargetWhenPresent(update);
90
+ return update;
91
+ }),
92
+ downloadUpdate: () => run(async () => {
93
+ const update = await options.downloadUpdate();
94
+ if (update.status === "downloaded") {
95
+ assertTargetVersion(update);
96
+ }
97
+ return update;
98
+ }),
99
+ installUpdate: () => run(async () => {
100
+ assertTargetVersion(options.getState());
101
+ await options.installUpdate();
102
+ }),
103
+ release: (releaseOptions) => {
104
+ if (releasePromise) {
105
+ return releasePromise;
106
+ }
107
+ releasePromise = (async () => {
108
+ released = true;
109
+ if (mandatoryOwner !== owner) {
110
+ return;
111
+ }
112
+ try {
113
+ if (releaseOptions?.restoreNormal !== false && configurationToRestore) {
114
+ await mandatoryContext.run(
115
+ owner,
116
+ () => normalRestoreContext.run(
117
+ owner,
118
+ () => options.restoreNormalConfiguration(configurationToRestore)
119
+ )
120
+ );
121
+ }
122
+ } finally {
123
+ if (mandatoryOwner === owner) {
124
+ mandatoryOwner = null;
125
+ }
126
+ }
127
+ })();
128
+ return releasePromise;
129
+ }
130
+ };
131
+ }
132
+ };
133
+ }
134
+
135
+ export {
136
+ MandatoryUpdateTargetError,
137
+ createMandatoryUpdaterLeaseManager
138
+ };
139
+ //# sourceMappingURL=chunk-GONYAEKF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mandatory-updater/mandatoryUpdaterSession.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type {\n ConfigureDesktopUpdatesInput,\n DesktopUpdateState,\n MandatoryDesktopUpdateSession,\n MandatoryDesktopUpdateTarget\n} from \"../contracts/index.ts\";\nimport { updaterTargetMeetsMinimum } from \"../core/index.ts\";\n\nexport class MandatoryUpdateTargetError extends Error {\n public readonly latestVersion: string | null;\n public readonly minimumVersion: string;\n\n public constructor(latestVersion: string | null, minimumVersion: string) {\n super(\n `mandatory update target ${latestVersion ?? \"unknown\"} is below ${minimumVersion}`\n );\n this.name = \"MandatoryUpdateTargetError\";\n this.latestVersion = latestVersion;\n this.minimumVersion = minimumVersion;\n }\n}\n\nexport interface MandatoryUpdaterLeaseManager {\n assertAccess(): void;\n isMandatoryAccess(): boolean;\n acquire(\n input: MandatoryDesktopUpdateTarget\n ): Promise<MandatoryDesktopUpdateSession>;\n}\n\nexport function createMandatoryUpdaterLeaseManager<\n TNormalConfiguration\n>(options: {\n captureNormalConfiguration(): TNormalConfiguration | null;\n suspendNormalUpdates(): Promise<void>;\n prepareMandatoryUpdate(\n input: ConfigureDesktopUpdatesInput\n ): Promise<DesktopUpdateState>;\n downloadUpdate(): Promise<DesktopUpdateState>;\n installUpdate(): Promise<void>;\n getState(): DesktopUpdateState;\n restoreNormalConfiguration(\n configuration: TNormalConfiguration\n ): Promise<void>;\n}): MandatoryUpdaterLeaseManager {\n const mandatoryContext = new AsyncLocalStorage<symbol>();\n const normalRestoreContext = new AsyncLocalStorage<symbol>();\n let mandatoryOwner: symbol | null = null;\n\n const assertAccess = (): void => {\n if (mandatoryOwner && mandatoryContext.getStore() !== mandatoryOwner) {\n throw new Error(\n \"application updater is owned by the mandatory update session\"\n );\n }\n };\n\n return {\n assertAccess,\n isMandatoryAccess: () =>\n mandatoryOwner !== null &&\n mandatoryContext.getStore() === mandatoryOwner &&\n normalRestoreContext.getStore() !== mandatoryOwner,\n async acquire(input) {\n if (mandatoryOwner) {\n throw new Error(\"a mandatory update session is already active\");\n }\n const owner = Symbol(\n `mandatory-update:${input.policyRevision}:${input.minimumVersion}`\n );\n mandatoryOwner = owner;\n const configurationToRestore = options.captureNormalConfiguration();\n try {\n await options.suspendNormalUpdates();\n } catch (error) {\n if (mandatoryOwner === owner) {\n mandatoryOwner = null;\n }\n throw error;\n }\n\n let target = input;\n let released = false;\n let releasePromise: Promise<void> | null = null;\n const run = <T>(operation: () => Promise<T>): Promise<T> => {\n if (released || mandatoryOwner !== owner) {\n return Promise.reject(\n new Error(\"mandatory update session is no longer active\")\n );\n }\n return mandatoryContext.run(owner, operation);\n };\n const assertTargetVersion = (update: DesktopUpdateState): void => {\n if (\n !updaterTargetMeetsMinimum(\n update.latestVersion,\n target.minimumVersion\n )\n ) {\n throw new MandatoryUpdateTargetError(\n update.latestVersion,\n target.minimumVersion\n );\n }\n };\n const assertTargetWhenPresent = (update: DesktopUpdateState): void => {\n if (update.status === \"available\" || update.status === \"downloaded\") {\n assertTargetVersion(update);\n }\n };\n\n return {\n retarget: (nextTarget) => {\n if (released || mandatoryOwner !== owner) {\n throw new Error(\"mandatory update session is no longer active\");\n }\n target = nextTarget;\n },\n prepare: () =>\n run(async () => {\n const update = await options.prepareMandatoryUpdate({\n channel: target.channel,\n policy: \"prompt\"\n });\n assertTargetWhenPresent(update);\n return update;\n }),\n downloadUpdate: () =>\n run(async () => {\n const update = await options.downloadUpdate();\n if (update.status === \"downloaded\") {\n assertTargetVersion(update);\n }\n return update;\n }),\n installUpdate: () =>\n run(async () => {\n assertTargetVersion(options.getState());\n await options.installUpdate();\n }),\n release: (releaseOptions) => {\n if (releasePromise) {\n return releasePromise;\n }\n releasePromise = (async () => {\n released = true;\n if (mandatoryOwner !== owner) {\n return;\n }\n try {\n if (\n releaseOptions?.restoreNormal !== false &&\n configurationToRestore\n ) {\n await mandatoryContext.run(owner, () =>\n normalRestoreContext.run(owner, () =>\n options.restoreNormalConfiguration(configurationToRestore)\n )\n );\n }\n } finally {\n if (mandatoryOwner === owner) {\n mandatoryOwner = null;\n }\n }\n })();\n return releasePromise;\n }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MAC9B,QAAQ,2BAA2B,sBAAsB;AAAA,kBAC3D;AAAA,gBACF;AAAA,cACF;AAAA,YACF,UAAE;AACA,kBAAI,mBAAmB,OAAO;AAC5B,iCAAiB;AAAA,cACnB;AAAA,YACF;AAAA,UACF,GAAG;AACH,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,112 @@
1
+ // src/core/minimumVersion.ts
2
+ function parseManagedVersion(value) {
3
+ const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-rc\.(0|[1-9]\d*))?$/u.exec(
4
+ value.trim()
5
+ );
6
+ if (!match) {
7
+ return null;
8
+ }
9
+ return {
10
+ major: match[1],
11
+ minor: match[2],
12
+ patch: match[3],
13
+ rc: match[4] === void 0 ? null : match[4]
14
+ };
15
+ }
16
+ function compareNumericIdentifier(left, right) {
17
+ if (left.length !== right.length) {
18
+ return left.length < right.length ? -1 : 1;
19
+ }
20
+ return left === right ? 0 : left < right ? -1 : 1;
21
+ }
22
+ function compareManagedVersions(left, right) {
23
+ for (const key of ["major", "minor", "patch"]) {
24
+ if (left[key] !== right[key]) {
25
+ return compareNumericIdentifier(left[key], right[key]);
26
+ }
27
+ }
28
+ if (left.rc === right.rc) {
29
+ return 0;
30
+ }
31
+ if (left.rc === null) {
32
+ return 1;
33
+ }
34
+ if (right.rc === null) {
35
+ return -1;
36
+ }
37
+ return compareNumericIdentifier(left.rc, right.rc);
38
+ }
39
+ function updaterTargetMeetsMinimum(releaseVersion, minimumVersion) {
40
+ if (!releaseVersion) {
41
+ return false;
42
+ }
43
+ const release = parseManagedVersion(releaseVersion);
44
+ const minimum = parseManagedVersion(minimumVersion);
45
+ return Boolean(
46
+ release && minimum && compareManagedVersions(release, minimum) >= 0
47
+ );
48
+ }
49
+ function resolveMinimumVersionRuntimeTarget(platform, architecture) {
50
+ const normalizedPlatform = platform === "darwin" ? "macos" : platform === "win32" ? "windows" : platform === "linux" ? "linux" : null;
51
+ const normalizedArchitecture = architecture === "arm64" ? "arm64" : architecture === "x64" ? "x64" : null;
52
+ if (!normalizedPlatform || !normalizedArchitecture) {
53
+ return null;
54
+ }
55
+ return {
56
+ architecture: normalizedArchitecture,
57
+ platform: normalizedPlatform
58
+ };
59
+ }
60
+ function shouldCheckMinimumVersionAfterForeground(input) {
61
+ return !(input.disposed || !input.checksEnabled || input.foregroundPrompted || input.startupBlocked || input.now - input.lastCheckAt < input.foregroundCheckIntervalMs);
62
+ }
63
+ function validateMinimumVersionResponse(value, request) {
64
+ if (!value || typeof value !== "object") {
65
+ throw new Error("minimum version response must be an object");
66
+ }
67
+ const response = value;
68
+ if (response.product !== request.product || response.platform !== request.platform || response.architecture !== request.architecture || response.currentVersion !== request.currentVersion) {
69
+ throw new Error("minimum version response identity does not match request");
70
+ }
71
+ if (typeof response.policyRevision !== "string" || response.policyRevision.trim() === "") {
72
+ throw new Error("minimum version response has invalid policy revision");
73
+ }
74
+ if (response.channel === "unmanaged") {
75
+ if (response.decision !== "notApplicable" || response.reason !== "unmanagedPrerelease" || response.minimumVersion !== "" || response.policySource !== "") {
76
+ throw new Error("minimum version response has invalid unmanaged policy");
77
+ }
78
+ return response;
79
+ }
80
+ if (response.channel !== "stable" && response.channel !== "rc") {
81
+ throw new Error("minimum version response has invalid channel");
82
+ }
83
+ if (response.decision === "notApplicable") {
84
+ if (!["productDisabled", "unsupportedRelease"].includes(
85
+ String(response.reason)
86
+ ) || response.minimumVersion !== "" || response.policySource !== "") {
87
+ throw new Error(
88
+ "minimum version response has invalid non-applicable policy"
89
+ );
90
+ }
91
+ return response;
92
+ }
93
+ if (response.decision !== "allowed" && response.decision !== "upgradeRequired") {
94
+ throw new Error("minimum version response has invalid decision");
95
+ }
96
+ const pattern = response.channel === "rc" ? /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-rc\.(0|[1-9]\d*)$/u : /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u;
97
+ const expectedReason = response.decision === "allowed" ? "meetsMinimum" : "belowMinimum";
98
+ if (typeof response.minimumVersion !== "string" || !pattern.test(response.minimumVersion) || !["defaultMinimum", "platformOverride"].includes(
99
+ String(response.policySource)
100
+ ) || response.reason !== expectedReason) {
101
+ throw new Error("minimum version response has invalid managed policy");
102
+ }
103
+ return response;
104
+ }
105
+
106
+ export {
107
+ updaterTargetMeetsMinimum,
108
+ resolveMinimumVersionRuntimeTarget,
109
+ shouldCheckMinimumVersionAfterForeground,
110
+ validateMinimumVersionResponse
111
+ };
112
+ //# sourceMappingURL=chunk-LV67FBCG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/minimumVersion.ts"],"sourcesContent":["import type {\n DesktopArchitecture,\n DesktopPlatform,\n DesktopProduct,\n MinimumVersionCheckRequest,\n MinimumVersionCheckResponse\n} from \"../contracts/index.ts\";\n\ntype ManagedVersion = {\n major: string;\n minor: string;\n patch: string;\n rc: string | null;\n};\n\nfunction parseManagedVersion(value: string): ManagedVersion | null {\n const match =\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-rc\\.(0|[1-9]\\d*))?$/u.exec(\n value.trim()\n );\n if (!match) {\n return null;\n }\n return {\n major: match[1]!,\n minor: match[2]!,\n patch: match[3]!,\n rc: match[4] === undefined ? null : match[4]\n };\n}\n\nfunction compareNumericIdentifier(left: string, right: string): number {\n if (left.length !== right.length) {\n return left.length < right.length ? -1 : 1;\n }\n return left === right ? 0 : left < right ? -1 : 1;\n}\n\nfunction compareManagedVersions(\n left: ManagedVersion,\n right: ManagedVersion\n): number {\n for (const key of [\"major\", \"minor\", \"patch\"] as const) {\n if (left[key] !== right[key]) {\n return compareNumericIdentifier(left[key], right[key]);\n }\n }\n if (left.rc === right.rc) {\n return 0;\n }\n if (left.rc === null) {\n return 1;\n }\n if (right.rc === null) {\n return -1;\n }\n return compareNumericIdentifier(left.rc, right.rc);\n}\n\nexport function updaterTargetMeetsMinimum(\n releaseVersion: string | null,\n minimumVersion: string\n): boolean {\n if (!releaseVersion) {\n return false;\n }\n const release = parseManagedVersion(releaseVersion);\n const minimum = parseManagedVersion(minimumVersion);\n return Boolean(\n release && minimum && compareManagedVersions(release, minimum) >= 0\n );\n}\n\nexport function resolveMinimumVersionRuntimeTarget(\n platform: NodeJS.Platform,\n architecture: string\n): {\n platform: DesktopPlatform;\n architecture: DesktopArchitecture;\n} | null {\n const normalizedPlatform =\n platform === \"darwin\"\n ? \"macos\"\n : platform === \"win32\"\n ? \"windows\"\n : platform === \"linux\"\n ? \"linux\"\n : null;\n const normalizedArchitecture =\n architecture === \"arm64\" ? \"arm64\" : architecture === \"x64\" ? \"x64\" : null;\n if (!normalizedPlatform || !normalizedArchitecture) {\n return null;\n }\n return {\n architecture: normalizedArchitecture,\n platform: normalizedPlatform\n };\n}\n\nexport function shouldCheckMinimumVersionAfterForeground(input: {\n disposed: boolean;\n checksEnabled: boolean;\n foregroundCheckIntervalMs: number;\n foregroundPrompted: boolean;\n startupBlocked: boolean;\n lastCheckAt: number;\n now: number;\n}): boolean {\n return !(\n input.disposed ||\n !input.checksEnabled ||\n input.foregroundPrompted ||\n input.startupBlocked ||\n input.now - input.lastCheckAt < input.foregroundCheckIntervalMs\n );\n}\n\nexport function validateMinimumVersionResponse<TProduct extends DesktopProduct>(\n value: unknown,\n request: MinimumVersionCheckRequest<TProduct>\n): MinimumVersionCheckResponse<TProduct> {\n if (!value || typeof value !== \"object\") {\n throw new Error(\"minimum version response must be an object\");\n }\n const response = value as Record<string, unknown>;\n if (\n response.product !== request.product ||\n response.platform !== request.platform ||\n response.architecture !== request.architecture ||\n response.currentVersion !== request.currentVersion\n ) {\n throw new Error(\"minimum version response identity does not match request\");\n }\n if (\n typeof response.policyRevision !== \"string\" ||\n response.policyRevision.trim() === \"\"\n ) {\n throw new Error(\"minimum version response has invalid policy revision\");\n }\n if (response.channel === \"unmanaged\") {\n if (\n response.decision !== \"notApplicable\" ||\n response.reason !== \"unmanagedPrerelease\" ||\n response.minimumVersion !== \"\" ||\n response.policySource !== \"\"\n ) {\n throw new Error(\"minimum version response has invalid unmanaged policy\");\n }\n return response as unknown as MinimumVersionCheckResponse<TProduct>;\n }\n if (response.channel !== \"stable\" && response.channel !== \"rc\") {\n throw new Error(\"minimum version response has invalid channel\");\n }\n if (response.decision === \"notApplicable\") {\n if (\n ![\"productDisabled\", \"unsupportedRelease\"].includes(\n String(response.reason)\n ) ||\n response.minimumVersion !== \"\" ||\n response.policySource !== \"\"\n ) {\n throw new Error(\n \"minimum version response has invalid non-applicable policy\"\n );\n }\n return response as unknown as MinimumVersionCheckResponse<TProduct>;\n }\n if (\n response.decision !== \"allowed\" &&\n response.decision !== \"upgradeRequired\"\n ) {\n throw new Error(\"minimum version response has invalid decision\");\n }\n const pattern =\n response.channel === \"rc\"\n ? /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)-rc\\.(0|[1-9]\\d*)$/u\n : /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$/u;\n const expectedReason =\n response.decision === \"allowed\" ? \"meetsMinimum\" : \"belowMinimum\";\n if (\n typeof response.minimumVersion !== \"string\" ||\n !pattern.test(response.minimumVersion) ||\n ![\"defaultMinimum\", \"platformOverride\"].includes(\n String(response.policySource)\n ) ||\n response.reason !== expectedReason\n ) {\n throw new Error(\"minimum version response has invalid managed policy\");\n }\n return response as unknown as MinimumVersionCheckResponse<TProduct>;\n}\n"],"mappings":";AAeA,SAAS,oBAAoB,OAAsC;AACjE,QAAM,QACJ,oEAAoE;AAAA,IAClE,MAAM,KAAK;AAAA,EACb;AACF,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,OAAO,MAAM,CAAC;AAAA,IACd,OAAO,MAAM,CAAC;AAAA,IACd,OAAO,MAAM,CAAC;AAAA,IACd,IAAI,MAAM,CAAC,MA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C,kBAAkB,kBAAkB,EAAE;AAAA,IACtC,OAAO,SAAS,YAAY;AAAA,EAC9B,KACA,SAAS,WAAW,gBACpB;AACA,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,33 @@
1
+ // src/contracts/index.ts
2
+ var desktopUpdatePolicies = ["off", "prompt", "auto"];
3
+ var desktopUpdateChannels = ["stable", "rc"];
4
+ var desktopUpdateStatuses = [
5
+ "disabled",
6
+ "unsupported",
7
+ "idle",
8
+ "checking",
9
+ "available",
10
+ "downloading",
11
+ "downloaded",
12
+ "up_to_date",
13
+ "error"
14
+ ];
15
+ var desktopProducts = ["tsh-desktop", "tutti-desktop"];
16
+ var desktopUpdateAdmissionIpcChannels = {
17
+ exit: "desktop-update-admission:exit",
18
+ getState: "desktop-update-admission:get-state",
19
+ later: "desktop-update-admission:later",
20
+ manualDownload: "desktop-update-admission:manual-download",
21
+ retry: "desktop-update-admission:retry",
22
+ start: "desktop-update-admission:start",
23
+ state: "desktop-update-admission:state"
24
+ };
25
+
26
+ export {
27
+ desktopUpdatePolicies,
28
+ desktopUpdateChannels,
29
+ desktopUpdateStatuses,
30
+ desktopProducts,
31
+ desktopUpdateAdmissionIpcChannels
32
+ };
33
+ //# sourceMappingURL=chunk-TRALK3GT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/contracts/index.ts"],"sourcesContent":["export const desktopUpdatePolicies = [\"off\", \"prompt\", \"auto\"] as const;\nexport type DesktopUpdatePolicy = (typeof desktopUpdatePolicies)[number];\n\nexport const desktopUpdateChannels = [\"stable\", \"rc\"] as const;\nexport type DesktopUpdateChannel = (typeof desktopUpdateChannels)[number];\n\nexport const desktopUpdateStatuses = [\n \"disabled\",\n \"unsupported\",\n \"idle\",\n \"checking\",\n \"available\",\n \"downloading\",\n \"downloaded\",\n \"up_to_date\",\n \"error\"\n] as const;\nexport type DesktopUpdateStatus = (typeof desktopUpdateStatuses)[number];\n\nexport interface ConfigureDesktopUpdatesInput {\n channel: DesktopUpdateChannel;\n policy: DesktopUpdatePolicy;\n}\n\nexport interface DesktopUpdateState {\n channel: DesktopUpdateChannel;\n checkedAt: string | null;\n currentVersion: string;\n downloadedBytes: number | null;\n downloadPercent: number | null;\n latestVersion: string | null;\n message: string | null;\n policy: DesktopUpdatePolicy;\n releaseDate: string | null;\n releaseName: string | null;\n releaseNotesUrl: string | null;\n status: DesktopUpdateStatus;\n totalBytes: number | null;\n}\n\nexport const desktopProducts = [\"tsh-desktop\", \"tutti-desktop\"] as const;\nexport type DesktopProduct = (typeof desktopProducts)[number];\nexport type DesktopPlatform = \"macos\" | \"windows\" | \"linux\";\nexport type DesktopArchitecture = \"arm64\" | \"x64\";\n\nexport interface MinimumVersionCheckRequest<\n TProduct extends DesktopProduct = DesktopProduct\n> {\n product: TProduct;\n platform: DesktopPlatform;\n architecture: DesktopArchitecture;\n currentVersion: string;\n}\n\nexport type MinimumVersionDecision =\n | \"allowed\"\n | \"upgradeRequired\"\n | \"notApplicable\";\n\nexport interface MinimumVersionCheckResponse<\n TProduct extends DesktopProduct = DesktopProduct\n> extends MinimumVersionCheckRequest<TProduct> {\n channel: DesktopUpdateChannel | \"unmanaged\";\n minimumVersion: string;\n decision: MinimumVersionDecision;\n reason:\n | \"unmanagedPrerelease\"\n | \"productDisabled\"\n | \"unsupportedRelease\"\n | \"belowMinimum\"\n | \"meetsMinimum\";\n policySource: \"\" | \"defaultMinimum\" | \"platformOverride\";\n policyRevision: string;\n}\n\nexport type MinimumVersionUpgradePhase =\n | \"blocked\"\n | \"checking\"\n | \"ready\"\n | \"downloading\"\n | \"downloaded\"\n | \"simulationComplete\"\n | \"error\"\n | \"released\";\n\nexport type MinimumVersionUpgradeError =\n | \"releaseBelowMinimum\"\n | \"updateUnavailable\"\n | \"policyCheckFailed\"\n | \"installFailed\"\n | \"updateFailed\";\n\nexport interface MinimumVersionUpgradeState<\n TProduct extends DesktopProduct = DesktopProduct\n> {\n phase: MinimumVersionUpgradePhase;\n check: MinimumVersionCheckResponse<TProduct>;\n update: DesktopUpdateState;\n message: MinimumVersionUpgradeError | null;\n}\n\nexport interface MandatoryDesktopUpdateTarget {\n channel: DesktopUpdateChannel;\n minimumVersion: string;\n policyRevision: string;\n}\n\nexport interface MandatoryDesktopUpdateSession {\n retarget(input: MandatoryDesktopUpdateTarget): void;\n prepare(): Promise<DesktopUpdateState>;\n downloadUpdate(): Promise<DesktopUpdateState>;\n installUpdate(): Promise<void>;\n release(options?: { restoreNormal?: boolean }): Promise<void>;\n}\n\nexport interface MinimumVersionAppUpdateService {\n getState(): DesktopUpdateState;\n acquireMandatorySession(\n input: MandatoryDesktopUpdateTarget\n ): Promise<MandatoryDesktopUpdateSession>;\n subscribe(listener: (state: DesktopUpdateState) => void): () => void;\n}\n\nexport interface DesktopUpdateAdmissionRuntime {\n checksEnabled: boolean;\n currentVersion: string;\n development: boolean;\n foregroundCheckIntervalMs: number;\n}\n\nexport const desktopUpdateAdmissionIpcChannels = {\n exit: \"desktop-update-admission:exit\",\n getState: \"desktop-update-admission:get-state\",\n later: \"desktop-update-admission:later\",\n manualDownload: \"desktop-update-admission:manual-download\",\n retry: \"desktop-update-admission:retry\",\n start: \"desktop-update-admission:start\",\n state: \"desktop-update-admission:state\"\n} as const;\n\nexport interface DesktopMinimumVersionApi {\n getState(): Promise<MinimumVersionUpgradeState | null>;\n start(): Promise<MinimumVersionUpgradeState | null>;\n retry(): Promise<MinimumVersionUpgradeState | null>;\n later(): Promise<void>;\n openManualDownload(): Promise<void>;\n exit(): Promise<void>;\n onState(listener: (state: MinimumVersionUpgradeState) => void): () => void;\n}\n"],"mappings":";AAAO,IAAM,wBAAwB,CAAC,OAAO,UAAU,MAAM;AAGtD,IAAM,wBAAwB,CAAC,UAAU,IAAI;AAG7C,IAAM,wBAAwB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAwBO,IAAM,kBAAkB,CAAC,eAAe,eAAe;AA0FvD,IAAM,oCAAoC;AAAA,EAC/C,MAAM;AAAA,EACN,UAAU;AAAA,EACV,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;","names":[]}