apps 0.0.1-beta.143 → 0.0.1-beta.148

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 (79) hide show
  1. package/README.md +14 -0
  2. package/check-publish.mjs +0 -1
  3. package/framework-reference.json +1 -1
  4. package/js/{chunk-IWLFLMIL.js → chunk-4XXHO5UG.js} +3966 -1760
  5. package/js/{chunk-NXUNFV44.js → chunk-63BS5GBH.js} +9 -14
  6. package/js/{chunk-2XEQYDQY.js → chunk-A6FRLRCN.js} +0 -1
  7. package/js/{chunk-PASOVDON.js → chunk-ALZDZ3ZT.js} +9 -30
  8. package/js/{chunk-H4JK7UTH.js → chunk-CQCY3OZS.js} +8 -49
  9. package/js/{chunk-V6OUBNL4.js → chunk-CWAPV2TN.js} +4 -6
  10. package/js/{chunk-RW5EXIO6.js → chunk-DX5DD6Z2.js} +8 -17
  11. package/js/{chunk-B54D6AN7.js → chunk-E2PVLAGK.js} +7 -15
  12. package/js/{chunk-LRXY54YF.js → chunk-EXL6F456.js} +1 -1
  13. package/js/{chunk-Y3QPWYHC.js → chunk-FWK2WTJB.js} +4 -5
  14. package/js/{chunk-2OGVSUNI.js → chunk-GWFQCQB5.js} +2 -2
  15. package/js/chunk-HEFJFDU4.js +87 -0
  16. package/js/{chunk-XRNSAU62.js → chunk-I7MYW7IK.js} +2 -2
  17. package/js/{chunk-ADG72XX3.js → chunk-JLHRRTRH.js} +6 -13
  18. package/js/{chunk-K24M6LZ7.js → chunk-MXFPSMNM.js} +2 -2
  19. package/js/{chunk-INQON4A2.js → chunk-OA4UYCJ4.js} +2 -2
  20. package/js/{chunk-3RIEA22Q.js → chunk-PUMGAWHB.js} +24 -43
  21. package/js/{chunk-W6V5OIHB.js → chunk-SEJXUMGT.js} +267 -1
  22. package/js/{chunk-RUSVGD5N.js → chunk-SXYFFXHM.js} +2 -2
  23. package/js/{chunk-BHSWVS3Q.js → chunk-UT2CBMW3.js} +4 -1
  24. package/js/{chunk-XAOJP46A.js → chunk-XR7KZNKD.js} +1 -1
  25. package/js/{chunk-TMYRAFMC.js → chunk-ZWFMEH2Y.js} +18 -1
  26. package/js/client.js +31 -14
  27. package/js/contracts.js +3 -4
  28. package/js/effect.js +14 -15
  29. package/js/graphql.js +16 -19
  30. package/js/host.js +14 -17
  31. package/js/index.js +10 -16
  32. package/js/mcp/effect.js +15 -16
  33. package/js/mcp.js +17 -18
  34. package/js/openapi.js +14 -22
  35. package/js/react.js +122 -3
  36. package/js/skills/effect.js +3 -4
  37. package/js/skills.js +17 -24
  38. package/js/ui/auth/contracts.js +5 -1
  39. package/js/ui/auth.js +7 -4
  40. package/js/ui/contracts.js +52 -5
  41. package/js/ui/serving.js +55 -17
  42. package/package.json +1 -1
  43. package/runtime.json +1 -1
  44. package/types/app-cache/src/index.d.ts +1 -40
  45. package/types/app-data/src/contracts/database.d.ts +0 -21
  46. package/types/apps/src/client.d.ts +3 -0
  47. package/types/apps/src/contracts/desktop-errors.d.ts +46 -0
  48. package/types/apps/src/contracts/desktop.d.ts +228 -0
  49. package/types/apps/src/contracts/ui-auth.d.ts +4 -1
  50. package/types/apps/src/contracts/ui.d.ts +43 -1
  51. package/types/apps/src/implementation/desktop.d.ts +85 -0
  52. package/types/apps/src/implementation/ui-serving.d.ts +13 -1
  53. package/types/apps/src/react.d.ts +29 -0
  54. package/types/apps/src/ui-serving.d.ts +1 -1
  55. package/types/telemetry/src/app-records.d.ts +0 -24
  56. package/types/telemetry/src/browser-operations.d.ts +0 -8
  57. package/types/telemetry/src/browser-performance.d.ts +0 -2
  58. package/types/telemetry/src/browser-request-timing.d.ts +0 -1
  59. package/types/telemetry/src/browser.d.ts +0 -10
  60. package/types/telemetry/src/config.d.ts +0 -8
  61. package/types/telemetry/src/context.d.ts +0 -6
  62. package/types/telemetry/src/index.d.ts +0 -1
  63. package/types/telemetry/src/keepalive.d.ts +0 -44
  64. package/types/telemetry/src/layer.d.ts +0 -8
  65. package/types/telemetry/src/measurements.d.ts +0 -8
  66. package/types/telemetry/src/ownership.d.ts +0 -45
  67. package/types/telemetry/src/pending-span.d.ts +0 -2
  68. package/types/telemetry/src/recorded-failure.d.ts +0 -26
  69. package/types/telemetry/src/relay.d.ts +0 -29
  70. package/types/telemetry/src/span-attributes.d.ts +0 -38
  71. package/types/telemetry/src/trace-context.d.ts +0 -6
  72. package/types/telemetry/src/transport.d.ts +0 -10
  73. package/types/utils/src/api-error.d.ts +0 -22
  74. package/types/utils/src/connection-failure.d.ts +0 -10
  75. package/types/utils/src/random-uuid.d.ts +0 -5
  76. package/types/utils/src/recorded-message.d.ts +0 -15
  77. package/types/utils/src/schema-definitions.d.ts +0 -6
  78. package/types/utils/src/user-facing-error.d.ts +0 -19
  79. package/js/chunk-QLUWYCOT.js +0 -2325
package/js/openapi.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  protocolOperations,
10
10
  protocolRouter
11
- } from "./chunk-XRNSAU62.js";
11
+ } from "./chunk-I7MYW7IK.js";
12
12
  import {
13
13
  OpenapiCompileError,
14
14
  OpenapiCompileErrorCode,
@@ -29,15 +29,15 @@ import {
29
29
  isOpenapiTextMedia,
30
30
  openapiBinaryResultSchema,
31
31
  openapiMediaKind
32
- } from "./chunk-NXUNFV44.js";
32
+ } from "./chunk-63BS5GBH.js";
33
33
  import {
34
34
  failOnNetworkRefusal
35
- } from "./chunk-K24M6LZ7.js";
36
- import "./chunk-XAOJP46A.js";
35
+ } from "./chunk-MXFPSMNM.js";
36
+ import "./chunk-XR7KZNKD.js";
37
37
  import {
38
38
  nativeOperation,
39
39
  routerDeclaration
40
- } from "./chunk-B54D6AN7.js";
40
+ } from "./chunk-E2PVLAGK.js";
41
41
  import {
42
42
  accountProviderError,
43
43
  bodyUpstreamError,
@@ -47,7 +47,7 @@ import {
47
47
  providerErrorDetail,
48
48
  statedUpstream,
49
49
  toPromise
50
- } from "./chunk-RUSVGD5N.js";
50
+ } from "./chunk-SXYFFXHM.js";
51
51
  import {
52
52
  ApiErrorRecovery,
53
53
  ApiErrorResponse,
@@ -58,29 +58,28 @@ import {
58
58
  RouterMeta,
59
59
  cacheLimits,
60
60
  defaultOpenapiErrorLimits
61
- } from "./chunk-LRXY54YF.js";
62
- import "./chunk-2XEQYDQY.js";
61
+ } from "./chunk-EXL6F456.js";
62
+ import "./chunk-A6FRLRCN.js";
63
63
  import {
64
64
  jsonSchema,
65
65
  lazyJsonSchemaDecoder,
66
66
  once,
67
67
  wrap
68
- } from "./chunk-ADG72XX3.js";
68
+ } from "./chunk-JLHRRTRH.js";
69
69
  import {
70
70
  owned
71
- } from "./chunk-H4JK7UTH.js";
71
+ } from "./chunk-CQCY3OZS.js";
72
72
  import {
73
73
  FetchHttpClient_exports
74
- } from "./chunk-2OGVSUNI.js";
74
+ } from "./chunk-GWFQCQB5.js";
75
75
  import "./chunk-6XBOKQ4E.js";
76
76
  import {
77
77
  JsonObject
78
78
  } from "./chunk-7A4ZSEM3.js";
79
- import "./chunk-QLUWYCOT.js";
80
79
  import {
81
80
  HttpClientRequest_exports,
82
81
  HttpClient_exports
83
- } from "./chunk-IWLFLMIL.js";
82
+ } from "./chunk-4XXHO5UG.js";
84
83
  import {
85
84
  Base64_exports,
86
85
  Clock_exports,
@@ -1963,8 +1962,7 @@ var segments = (path) => (path.split(/[?#]/)[0] ?? path).split("/").map((segment
1963
1962
  var resourceSegments = (path) => segments(path).filter(
1964
1963
  (segment) => !version.test(segment) && segment.toLowerCase() !== "api" && !(segment.startsWith("{") && segment.endsWith("}")) && camel(segment) !== ""
1965
1964
  );
1966
- var groupOf = (input) => camel(input.tag ?? "") || camel(resourceSegments(input.path)[0] ?? "") || // Keep "root" for an operation on `/` or a path of only versions and parameters.
1967
- "root";
1965
+ var groupOf = (input) => camel(input.tag ?? "") || camel(resourceSegments(input.path)[0] ?? "") || "root";
1968
1966
  var fallbackLeaf = (input, group) => {
1969
1967
  const resources = resourceSegments(input.path).map(camel);
1970
1968
  const others = resources.filter((segment) => segment !== group);
@@ -2791,7 +2789,6 @@ var compileOpenApiDocument = (entry, inputDocument, options = {}) => {
2791
2789
  fallback
2792
2790
  };
2793
2791
  },
2794
- // Expected failures stay typed; anything else is a defect in the importer, not the definition.
2795
2792
  catch: (error) => error instanceof OpenapiCompileError ? Exit_exports.fail(error) : Schema_exports.isSchemaError(error) ? Exit_exports.fail(
2796
2793
  new OpenapiCompileError({
2797
2794
  code: "invalid_document",
@@ -5567,10 +5564,7 @@ var download = (url, context) => Effect_exports.gen(function* () {
5567
5564
  });
5568
5565
  var sourceDocument = (options, context) => Effect_exports.gen(function* () {
5569
5566
  return patchOpenapi(
5570
- "url" in options.source ? yield* download(options.source.url, context) : (
5571
- // A copy the compilation can own, as a tree.
5572
- Schema_exports.decodeUnknownSync(JsonObject)(JSON.parse(JSON.stringify(options.source.document)))
5573
- ),
5567
+ "url" in options.source ? yield* download(options.source.url, context) : Schema_exports.decodeUnknownSync(JsonObject)(JSON.parse(JSON.stringify(options.source.document))),
5574
5568
  options.patches
5575
5569
  );
5576
5570
  });
@@ -5912,7 +5906,6 @@ var liveOpenapiRouter = (options) => {
5912
5906
  name: operation.name,
5913
5907
  description: operation.description,
5914
5908
  readOnly: readOnly(operation),
5915
- // The app's `kinds`, or the HTTP method Executor sends.
5916
5909
  kindConfirmed: true,
5917
5910
  ...operation.tags === void 0 ? {} : { tags: operation.tags }
5918
5911
  });
@@ -6056,7 +6049,6 @@ var openapiRouter = (options, kinds = {}) => Effect_exports.runPromise(
6056
6049
  var openapiOperationNames = (document) => Effect_exports.runPromise(
6057
6050
  Effect_exports.suspend(
6058
6051
  () => compiledOperationNames(
6059
- // A copy the reader can own, as a tree.
6060
6052
  Schema_exports.decodeUnknownSync(JsonObject)(JSON.parse(JSON.stringify(document)))
6061
6053
  )
6062
6054
  )
package/js/react.js CHANGED
@@ -1,15 +1,17 @@
1
1
  import {
2
2
  AsyncResult_exports,
3
3
  AtomRegistry_exports,
4
+ desktop,
4
5
  queryCommitted
5
- } from "./chunk-W6V5OIHB.js";
6
+ } from "./chunk-SEJXUMGT.js";
7
+ import "./chunk-HEFJFDU4.js";
6
8
  import {
7
9
  Option_exports
8
10
  } from "./chunk-NXEGROI6.js";
9
11
  import "./chunk-CZ7CSFO4.js";
10
12
 
11
13
  // src/react.ts
12
- import { useEffect, useLayoutEffect, useState } from "react";
14
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
13
15
  var useAppQuery = (atom) => {
14
16
  const [state, setState] = useState();
15
17
  useEffect(() => {
@@ -31,6 +33,123 @@ var useAppQuery = (atom) => {
31
33
  error: result._tag === "Failure" ? "Could not load app data." : void 0
32
34
  };
33
35
  };
36
+ var shortcutTurns = /* @__PURE__ */ new Map();
37
+ var inShortcutTurn = (accelerator, step) => {
38
+ const turn = (shortcutTurns.get(accelerator) ?? Promise.resolve()).then(step);
39
+ shortcutTurns.set(accelerator, turn);
40
+ void turn.then(() => {
41
+ if (shortcutTurns.get(accelerator) === turn) shortcutTurns.delete(accelerator);
42
+ });
43
+ };
44
+ var strandedShortcuts = /* @__PURE__ */ new Map();
45
+ var removeShortcut = async (accelerator, remove) => {
46
+ const removed = await remove().then(
47
+ () => true,
48
+ () => false
49
+ );
50
+ const stranded = strandedShortcuts.get(accelerator) ?? /* @__PURE__ */ new Set();
51
+ if (removed) stranded.delete(remove);
52
+ else stranded.add(remove);
53
+ if (stranded.size === 0) strandedShortcuts.delete(accelerator);
54
+ else strandedShortcuts.set(accelerator, stranded);
55
+ };
56
+ var removeStranded = async (accelerator) => {
57
+ for (const remove of strandedShortcuts.get(accelerator) ?? []) {
58
+ await removeShortcut(accelerator, remove);
59
+ }
60
+ };
61
+ var useDesktopShortcut = (accelerator, handler) => {
62
+ const latest = useRef(handler);
63
+ useLayoutEffect(() => {
64
+ latest.current = handler;
65
+ });
66
+ const [failure, setFailure] = useState();
67
+ useEffect(() => {
68
+ if (!desktop.available) return;
69
+ let active = true;
70
+ let remove;
71
+ inShortcutTurn(accelerator, async () => {
72
+ if (!active) return;
73
+ setFailure(void 0);
74
+ await removeStranded(accelerator);
75
+ await desktop.shortcuts.register(accelerator, () => {
76
+ if (active) latest.current();
77
+ }).then(
78
+ (registered) => {
79
+ remove = registered;
80
+ },
81
+ (error) => {
82
+ if (active) setFailure({ accelerator, error });
83
+ }
84
+ );
85
+ });
86
+ return () => {
87
+ active = false;
88
+ inShortcutTurn(accelerator, async () => {
89
+ if (remove !== void 0) await removeShortcut(accelerator, remove);
90
+ });
91
+ };
92
+ }, [accelerator]);
93
+ return failure?.accelerator === accelerator ? failure.error : void 0;
94
+ };
95
+ var useDesktopPermission = (name) => {
96
+ const [state, setState] = useState();
97
+ useEffect(() => {
98
+ let active = true;
99
+ const read = () => void desktop.permission(name).then(
100
+ (value) => {
101
+ if (active) setState({ name, value });
102
+ },
103
+ () => void 0
104
+ );
105
+ read();
106
+ const stop = desktop.window.onFocus(read);
107
+ return () => {
108
+ active = false;
109
+ stop();
110
+ };
111
+ }, [name]);
112
+ return state?.name === name ? state.value : void 0;
113
+ };
114
+ var useDesktopBadge = (count) => {
115
+ const [failure, setFailure] = useState();
116
+ useEffect(() => {
117
+ if (!desktop.available) return;
118
+ let active = true;
119
+ void desktop.badge.set(count).then(
120
+ () => {
121
+ if (active) setFailure(void 0);
122
+ },
123
+ (error) => {
124
+ if (active) setFailure({ count, error });
125
+ }
126
+ );
127
+ return () => {
128
+ active = false;
129
+ };
130
+ }, [count]);
131
+ useEffect(
132
+ () => () => {
133
+ if (desktop.available) void desktop.badge.set(null).catch(() => void 0);
134
+ },
135
+ []
136
+ );
137
+ return failure?.count === count ? failure.error : void 0;
138
+ };
139
+ var useDesktopWindowEvent = (type, handler) => {
140
+ const latest = useRef(handler);
141
+ useLayoutEffect(() => {
142
+ latest.current = handler;
143
+ });
144
+ useEffect(
145
+ () => type === "blur" ? desktop.window.onBlur(() => latest.current()) : desktop.window.onFocus(() => latest.current()),
146
+ [type]
147
+ );
148
+ };
34
149
  export {
35
- useAppQuery
150
+ useAppQuery,
151
+ useDesktopBadge,
152
+ useDesktopPermission,
153
+ useDesktopShortcut,
154
+ useDesktopWindowEvent
36
155
  };
@@ -1,11 +1,10 @@
1
1
  import {
2
2
  folderSkillsEffect,
3
3
  skillFromFiles
4
- } from "../chunk-XAOJP46A.js";
5
- import "../chunk-2XEQYDQY.js";
4
+ } from "../chunk-XR7KZNKD.js";
5
+ import "../chunk-A6FRLRCN.js";
6
6
  import "../chunk-6XBOKQ4E.js";
7
- import "../chunk-QLUWYCOT.js";
8
- import "../chunk-IWLFLMIL.js";
7
+ import "../chunk-4XXHO5UG.js";
9
8
  import "../chunk-NXEGROI6.js";
10
9
  import "../chunk-CZ7CSFO4.js";
11
10
  export {
package/js/skills.js CHANGED
@@ -1,27 +1,27 @@
1
1
  import {
2
2
  catalogCache,
3
3
  catalogScope
4
- } from "./chunk-Y3QPWYHC.js";
5
- import "./chunk-PASOVDON.js";
4
+ } from "./chunk-FWK2WTJB.js";
5
+ import "./chunk-ALZDZ3ZT.js";
6
6
  import {
7
7
  failOnNetworkRefusal
8
- } from "./chunk-K24M6LZ7.js";
8
+ } from "./chunk-MXFPSMNM.js";
9
9
  import {
10
10
  folderSkillsEffect,
11
11
  skillFromFiles
12
- } from "./chunk-XAOJP46A.js";
12
+ } from "./chunk-XR7KZNKD.js";
13
13
  import {
14
14
  accountProviderError,
15
15
  fromPromise,
16
16
  httpProviderError,
17
17
  method,
18
18
  toPromise
19
- } from "./chunk-RUSVGD5N.js";
19
+ } from "./chunk-SXYFFXHM.js";
20
20
  import {
21
21
  NetworkRefused,
22
22
  ProviderError,
23
23
  networkRefusalStatus
24
- } from "./chunk-LRXY54YF.js";
24
+ } from "./chunk-EXL6F456.js";
25
25
  import {
26
26
  AppSkillMetadata,
27
27
  AppSkillSource,
@@ -31,21 +31,20 @@ import {
31
31
  SkillLoadFailed,
32
32
  SkillServiceName,
33
33
  skillLoadLimits
34
- } from "./chunk-2XEQYDQY.js";
34
+ } from "./chunk-A6FRLRCN.js";
35
35
  import {
36
36
  wrap
37
- } from "./chunk-ADG72XX3.js";
38
- import "./chunk-H4JK7UTH.js";
37
+ } from "./chunk-JLHRRTRH.js";
38
+ import "./chunk-CQCY3OZS.js";
39
39
  import {
40
40
  FetchHttpClient_exports
41
- } from "./chunk-2OGVSUNI.js";
41
+ } from "./chunk-GWFQCQB5.js";
42
42
  import "./chunk-6XBOKQ4E.js";
43
43
  import "./chunk-7A4ZSEM3.js";
44
- import "./chunk-QLUWYCOT.js";
45
44
  import {
46
45
  HttpBody_exports,
47
46
  HttpClient_exports
48
- } from "./chunk-IWLFLMIL.js";
47
+ } from "./chunk-4XXHO5UG.js";
49
48
  import {
50
49
  Base64_exports,
51
50
  Effect_exports,
@@ -653,7 +652,6 @@ var reader = (transport) => Effect_exports.gen(function* () {
653
652
  headers,
654
653
  body: HttpBody_exports.uint8Array(request.body, request.headers?.["Content-Type"])
655
654
  })).pipe(
656
- // `ctx.fetch` rejects with a network refusal; any other failed request got no answer.
657
655
  Effect_exports.mapError(
658
656
  (error) => Schema_exports.is(NetworkRefused)(error.cause) ? refusal(error.cause) : failed("request")
659
657
  )
@@ -797,21 +795,16 @@ var cachedSkillDirectories = (cache, transport, options, commit) => fromPromise(
797
795
  key: ["apps/githubSkills/directories", 1, options.repo, commit, options.path ?? null],
798
796
  schema: wrap(SkillDirectories, false),
799
797
  freshFor: "7 days",
800
- // Executor's own loader: the app's cache runs it natively, so only its requests are upstream.
801
798
  load: toPromise(
802
- (context) => (
803
- // Keep the author's fetch and this read's token, as every other request in it does.
804
- reader({ fetch: transport.fetch, signal: context.signal }).pipe(
805
- Effect_exports.flatMap(
806
- (remote) => skillDirectories(
807
- githubRequests(remote, options.repo, options.token),
808
- commit,
809
- options.path
810
- )
799
+ (context) => reader({ fetch: transport.fetch, signal: context.signal }).pipe(
800
+ Effect_exports.flatMap(
801
+ (remote) => skillDirectories(
802
+ githubRequests(remote, options.repo, options.token),
803
+ commit,
804
+ options.path
811
805
  )
812
806
  )
813
807
  ),
814
- // A cache may call the loader as a Promise; its own signal cancels that load.
815
808
  (context) => context.signal
816
809
  )
817
810
  }).pipe(
@@ -5,7 +5,11 @@ import {
5
5
  AppSignInFailure,
6
6
  AppSignInId,
7
7
  appSignInCallbackPath
8
- } from "../../chunk-BHSWVS3Q.js";
8
+ } from "../../chunk-UT2CBMW3.js";
9
+ import "../../chunk-ZWFMEH2Y.js";
10
+ import "../../chunk-HEFJFDU4.js";
11
+ import "../../chunk-7A4ZSEM3.js";
12
+ import "../../chunk-4XXHO5UG.js";
9
13
  import "../../chunk-NXEGROI6.js";
10
14
  import "../../chunk-CZ7CSFO4.js";
11
15
  export {
package/js/ui/auth.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  appRedirect,
4
4
  appSignInCallback,
5
5
  appSignInFailed
6
- } from "../chunk-INQON4A2.js";
6
+ } from "../chunk-OA4UYCJ4.js";
7
7
  import {
8
8
  AppReturnPath,
9
9
  AppSignInCallback,
@@ -11,9 +11,12 @@ import {
11
11
  AppSignInFailure,
12
12
  AppSignInId,
13
13
  appSignInCallbackPath
14
- } from "../chunk-BHSWVS3Q.js";
15
- import "../chunk-2OGVSUNI.js";
16
- import "../chunk-IWLFLMIL.js";
14
+ } from "../chunk-UT2CBMW3.js";
15
+ import "../chunk-ZWFMEH2Y.js";
16
+ import "../chunk-HEFJFDU4.js";
17
+ import "../chunk-GWFQCQB5.js";
18
+ import "../chunk-7A4ZSEM3.js";
19
+ import "../chunk-4XXHO5UG.js";
17
20
  import "../chunk-NXEGROI6.js";
18
21
  import "../chunk-CZ7CSFO4.js";
19
22
  export {
@@ -1,25 +1,72 @@
1
1
  import {
2
2
  AppUiApi,
3
+ AppUiPagesManifest,
3
4
  UiContext,
4
5
  UiFailed,
5
6
  UiForbidden,
6
7
  UiOperation,
7
8
  UiSnapshot,
8
9
  UiUnauthorized,
9
- UiVersionChanged
10
- } from "../chunk-TMYRAFMC.js";
10
+ UiVersionChanged,
11
+ appIconRoute,
12
+ appMenuBarRoute,
13
+ appUiDocuments,
14
+ appUiIcon,
15
+ appUiIconMaxBytes,
16
+ appUiPagesAsset
17
+ } from "../chunk-ZWFMEH2Y.js";
18
+ import {
19
+ desktopAppBridgeGlobal,
20
+ desktopBadgeMaximum,
21
+ desktopBridgeVersion,
22
+ desktopHostBridgeGlobal,
23
+ desktopInstallLink,
24
+ desktopLinkProtocol,
25
+ desktopMaximumWindows,
26
+ desktopMenuBarTitleMaxLength,
27
+ desktopNotificationPathKey,
28
+ desktopPermissions,
29
+ desktopShortcutEvent,
30
+ desktopWindowEvent,
31
+ desktopWindowSize,
32
+ executorServerIdentityPath,
33
+ loopbackHostname,
34
+ parseDesktopInstallLink
35
+ } from "../chunk-HEFJFDU4.js";
11
36
  import "../chunk-7A4ZSEM3.js";
12
- import "../chunk-QLUWYCOT.js";
13
- import "../chunk-IWLFLMIL.js";
37
+ import "../chunk-4XXHO5UG.js";
14
38
  import "../chunk-NXEGROI6.js";
15
39
  import "../chunk-CZ7CSFO4.js";
16
40
  export {
17
41
  AppUiApi,
42
+ AppUiPagesManifest,
18
43
  UiContext,
19
44
  UiFailed,
20
45
  UiForbidden,
21
46
  UiOperation,
22
47
  UiSnapshot,
23
48
  UiUnauthorized,
24
- UiVersionChanged
49
+ UiVersionChanged,
50
+ appIconRoute,
51
+ appMenuBarRoute,
52
+ appUiDocuments,
53
+ appUiIcon,
54
+ appUiIconMaxBytes,
55
+ appUiPagesAsset,
56
+ desktopAppBridgeGlobal,
57
+ desktopBadgeMaximum,
58
+ desktopBridgeVersion,
59
+ desktopHostBridgeGlobal,
60
+ desktopInstallLink,
61
+ desktopLinkProtocol,
62
+ desktopMaximumWindows,
63
+ desktopMenuBarTitleMaxLength,
64
+ desktopNotificationPathKey,
65
+ desktopPermissions,
66
+ desktopShortcutEvent,
67
+ desktopWindowEvent,
68
+ desktopWindowSize,
69
+ executorServerIdentityPath,
70
+ loopbackHostname,
71
+ parseDesktopInstallLink
25
72
  };
package/js/ui/serving.js CHANGED
@@ -1,23 +1,27 @@
1
1
  import {
2
2
  appPrivateHeaders
3
- } from "../chunk-INQON4A2.js";
4
- import "../chunk-BHSWVS3Q.js";
3
+ } from "../chunk-OA4UYCJ4.js";
4
+ import "../chunk-UT2CBMW3.js";
5
5
  import {
6
+ AppUiPagesManifest,
6
7
  UiContext,
7
8
  UiFailed,
8
- UiForbidden
9
- } from "../chunk-TMYRAFMC.js";
9
+ UiForbidden,
10
+ appUiDocuments,
11
+ appUiIcon,
12
+ appUiPagesAsset
13
+ } from "../chunk-ZWFMEH2Y.js";
14
+ import "../chunk-HEFJFDU4.js";
10
15
  import {
11
16
  CurrentTelemetryConfig
12
- } from "../chunk-H4JK7UTH.js";
13
- import "../chunk-2OGVSUNI.js";
17
+ } from "../chunk-CQCY3OZS.js";
18
+ import "../chunk-GWFQCQB5.js";
14
19
  import "../chunk-6XBOKQ4E.js";
15
20
  import "../chunk-7A4ZSEM3.js";
16
- import "../chunk-QLUWYCOT.js";
17
21
  import {
18
22
  HttpServerRequest_exports,
19
23
  HttpServerResponse_exports
20
- } from "../chunk-IWLFLMIL.js";
24
+ } from "../chunk-4XXHO5UG.js";
21
25
  import {
22
26
  Effect_exports,
23
27
  Option_exports,
@@ -8538,7 +8542,7 @@ var appFile = (options) => Effect_exports.gen(function* () {
8538
8542
  Effect_exports.mapError(() => new UiForbidden())
8539
8543
  );
8540
8544
  const path = Option_exports.getOrUndefined(assetPath(pathname.slice(1)));
8541
- const file = pathname === "/" || path === void 0 || path === "index.html" ? void 0 : yield* options.asset(path);
8545
+ const file = pathname === "/" || path === void 0 || hostOwned(path) ? void 0 : yield* options.asset(path);
8542
8546
  if (file !== void 0 && "body" in file)
8543
8547
  return Option_exports.some(
8544
8548
  HttpServerResponse_exports.uint8Array(file.body, {
@@ -8559,12 +8563,15 @@ var appDocument = (options) => Effect_exports.gen(function* () {
8559
8563
  contentType: "text/html",
8560
8564
  headers: appPrivateHeaders
8561
8565
  });
8562
- const document = yield* options.asset("index.html");
8566
+ const document = yield* options.asset(appUiDocuments[options.document ?? "main"].asset);
8563
8567
  if (document === void 0 || !("body" in document))
8564
- return HttpServerResponse_exports.text("This app has no UI.", {
8565
- status: 404,
8566
- headers: appPrivateHeaders
8567
- });
8568
+ return HttpServerResponse_exports.text(
8569
+ options.document === "menuBar" ? "This app has no menu-bar page." : "This app has no UI.",
8570
+ {
8571
+ status: 404,
8572
+ headers: appPrivateHeaders
8573
+ }
8574
+ );
8568
8575
  const context = JSON.stringify(
8569
8576
  Schema_exports.encodeSync(UiContext)({ version: options.version, accounts: options.accountIds })
8570
8577
  ).replaceAll("<", "\\u003c");
@@ -8597,6 +8604,35 @@ var storedAppFile = (stored, read) => {
8597
8604
  )
8598
8605
  };
8599
8606
  };
8607
+ var hostOwned = (path) => path === "index.html" || path.startsWith("_executor/");
8608
+ var appIcon = (asset, build) => Effect_exports.gen(function* () {
8609
+ if (asset === void 0)
8610
+ return HttpServerResponse_exports.empty({ status: 404, headers: appPrivateHeaders });
8611
+ const headers = {
8612
+ ...appPrivateHeaders,
8613
+ "content-security-policy": "default-src 'none'; style-src 'unsafe-inline'; form-action 'none'; frame-ancestors 'none'"
8614
+ };
8615
+ if (!("body" in asset)) return yield* storedFile(asset, "private, no-cache", headers);
8616
+ const request = yield* HttpServerRequest_exports.HttpServerRequest;
8617
+ const etag = `W/"${encodeURIComponent(build)}/${encodeURIComponent(appUiIcon.asset)}"`;
8618
+ const cached = { ...headers, "cache-control": "private, no-cache", vary: "Cookie", etag };
8619
+ return etagMatches(request.headers["if-none-match"], etag) ? HttpServerResponse_exports.empty({ status: 304, headers: cached }) : HttpServerResponse_exports.uint8Array(asset.body, {
8620
+ contentType: "image/svg+xml",
8621
+ headers: cached
8622
+ });
8623
+ });
8624
+ var appUiPages = (asset) => Effect_exports.gen(function* () {
8625
+ const manifest = yield* asset(appUiPagesAsset);
8626
+ if (manifest !== void 0) {
8627
+ if (!("body" in manifest)) return yield* new UiFailed({ reason: "unavailable" });
8628
+ const pages = yield* Schema_exports.decodeUnknownEffect(Schema_exports.fromJsonString(AppUiPagesManifest))(
8629
+ new TextDecoder().decode(manifest.body)
8630
+ ).pipe(Effect_exports.mapError(() => new UiFailed({ reason: "unavailable" })));
8631
+ return { main: true, ...pages };
8632
+ }
8633
+ const main = yield* asset(appUiDocuments.main.asset);
8634
+ return { main: main !== void 0, menuBar: false, icon: false };
8635
+ });
8600
8636
  var assetPath = (path) => Option_exports.liftThrowable(() => path.split("/").map(decodeURIComponent).join("/"))();
8601
8637
  var etagMatches = (header, etag) => header?.split(",").some(
8602
8638
  (candidate) => candidate.trim() === "*" || candidate.trim().replace(/^W\//, "") === etag.replace(/^W\//, "")
@@ -8618,11 +8654,11 @@ var requestedRange = (header, ifRange, etag, size) => {
8618
8654
  if (end < start) return void 0;
8619
8655
  return { start, end };
8620
8656
  };
8621
- var storedFile = (file, cacheControl) => Effect_exports.gen(function* () {
8657
+ var storedFile = (file, cacheControl, base = appPrivateHeaders) => Effect_exports.gen(function* () {
8622
8658
  const request = yield* HttpServerRequest_exports.HttpServerRequest;
8623
8659
  const etag = `"${file.etag}"`;
8624
8660
  const headers = {
8625
- ...appPrivateHeaders,
8661
+ ...base,
8626
8662
  "cache-control": cacheControl,
8627
8663
  vary: "Cookie",
8628
8664
  etag,
@@ -8653,7 +8689,7 @@ var storedFile = (file, cacheControl) => Effect_exports.gen(function* () {
8653
8689
  });
8654
8690
  });
8655
8691
  var appAsset = (asset, build, path) => Effect_exports.gen(function* () {
8656
- if (asset === void 0 || path === "index.html")
8692
+ if (asset === void 0 || hostOwned(path))
8657
8693
  return HttpServerResponse_exports.empty({ status: 404, headers: appPrivateHeaders });
8658
8694
  const immutable = "private, max-age=31536000, immutable";
8659
8695
  if (!("body" in asset)) return yield* storedFile(asset, immutable);
@@ -8671,6 +8707,8 @@ export {
8671
8707
  appAsset,
8672
8708
  appDocument,
8673
8709
  appFile,
8710
+ appIcon,
8711
+ appUiPages,
8674
8712
  assetPath,
8675
8713
  storedAppFile
8676
8714
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps",
3
- "version": "0.0.1-beta.143",
3
+ "version": "0.0.1-beta.148",
4
4
  "description": "TypeScript apps with typed tools, accounts, storage, and UI.",
5
5
  "type": "module",
6
6
  "sideEffects": false,