@legendapp/spark 0.0.1-next.4 → 0.0.1-next.6

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 (132) hide show
  1. package/README.md +1 -1
  2. package/customize.ts +2 -0
  3. package/html.ts +1 -0
  4. package/markdown.ts +1 -0
  5. package/package.json +22 -13
  6. package/patches/dependencies.json +10 -4
  7. package/patches/react-native-enriched-html@1.1.1.patch +854 -0
  8. package/patches/{react-native-enriched-markdown@1.0.2.patch → react-native-enriched-markdown@1.1.1.patch} +2560 -1983
  9. package/schema.json +104 -0
  10. package/skills/spark/SKILL.md +56 -0
  11. package/skills/spark/UPGRADING.md +254 -0
  12. package/vendor/node_modules/@legendapp/spark-ai/package.json +4 -4
  13. package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.cjs +11 -0
  14. package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.d.cts +2 -0
  15. package/vendor/node_modules/@legendapp/spark-ai/src/invocations.ts +2 -19
  16. package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -3
  17. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -3
  18. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +4 -4
  19. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +3 -0
  20. package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +31 -11
  21. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-ai.cjs +108 -0
  22. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-artifacts.js +315 -0
  23. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-cli.cjs +75 -0
  24. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-github.cjs +133 -0
  25. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-policy.cjs +102 -0
  26. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-provider.cjs +2 -0
  27. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-worker.cjs +273 -0
  28. package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +54 -29
  29. package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
  30. package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +128 -0
  31. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-patch.cjs +30 -1
  32. package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +16 -7
  33. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -0
  34. package/vendor/node_modules/@legendapp/spark-cli/dist/js-runtime.cjs +96 -0
  35. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +152 -0
  36. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +15 -0
  37. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +184 -0
  38. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.d.cts +16 -0
  39. package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +2 -0
  40. package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager-config.js +41 -0
  41. package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager.js +13 -0
  42. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -0
  43. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +40 -9
  44. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +19 -19
  45. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.ps1 +87 -0
  46. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.sh +107 -0
  47. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-downloads.tsv +13 -0
  48. package/vendor/node_modules/@legendapp/spark-cli/dist/sdk-install.js +8 -3
  49. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +102 -0
  50. package/vendor/node_modules/@legendapp/spark-cli/package.json +6 -4
  51. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/.claude/skills/spark/SKILL.md +9 -0
  52. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/AGENTS.md +4 -0
  53. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/CLAUDE.md +4 -0
  54. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/README.md +15 -0
  55. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +46 -2
  56. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/.claude/skills/spark/SKILL.md +9 -0
  57. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/AGENTS.md +4 -0
  58. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/CLAUDE.md +4 -0
  59. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/README.md +15 -0
  60. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +45 -2
  61. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/.claude/skills/spark/SKILL.md +9 -0
  62. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/AGENTS.md +4 -0
  63. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/CLAUDE.md +4 -0
  64. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/README.md +15 -0
  65. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +46 -2
  66. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -3
  67. package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -3
  68. package/vendor/node_modules/@legendapp/spark-commands/package.json +6 -6
  69. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -3
  70. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +14 -1
  71. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -2
  72. package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize-hooks.ts +17 -0
  73. package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize.ts +117 -0
  74. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +20 -1
  75. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +3 -2
  76. package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +14 -0
  77. package/vendor/node_modules/@legendapp/spark-desktop-config/customize-provider.cjs +16 -0
  78. package/vendor/node_modules/@legendapp/spark-desktop-config/customize.cjs +16 -0
  79. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +4 -4
  80. package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +104 -0
  81. package/vendor/node_modules/@legendapp/spark-desktop-host/SparkCustomize.mm +517 -0
  82. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +4 -3
  83. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -3
  84. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.mm +3 -1
  85. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.h +3 -0
  86. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.mm +1 -1
  87. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -3
  88. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +5 -4
  89. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -4
  90. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +62 -25
  91. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -5
  92. package/vendor/node_modules/@legendapp/spark-documents/package.json +8 -8
  93. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -3
  94. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -3
  95. package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.h +1 -0
  96. package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.mm +11 -10
  97. package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -3
  98. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -3
  99. package/vendor/node_modules/@legendapp/spark-html/package.json +24 -0
  100. package/vendor/node_modules/@legendapp/spark-html/src/Html.tsx +22 -0
  101. package/vendor/node_modules/@legendapp/spark-html/src/HtmlInput.tsx +102 -0
  102. package/vendor/node_modules/@legendapp/spark-html/src/index.ts +4 -0
  103. package/vendor/node_modules/@legendapp/spark-html/src/types.ts +4 -0
  104. package/vendor/node_modules/@legendapp/spark-markdown/package.json +24 -0
  105. package/vendor/node_modules/@legendapp/spark-markdown/src/Markdown.tsx +24 -0
  106. package/vendor/node_modules/@legendapp/spark-markdown/src/MarkdownInput.tsx +111 -0
  107. package/vendor/node_modules/@legendapp/spark-markdown/src/index.ts +4 -0
  108. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -3
  109. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -3
  110. package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -3
  111. package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -3
  112. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +18 -0
  113. package/vendor/node_modules/@legendapp/spark-rich-text/src/components.tsx +52 -0
  114. package/vendor/node_modules/@legendapp/spark-rich-text/src/index.ts +4 -0
  115. package/vendor/node_modules/@legendapp/spark-rich-text/src/types.ts +24 -0
  116. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.macos.ts +55 -0
  117. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.ts +13 -0
  118. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputValue.ts +14 -0
  119. package/vendor/node_modules/@legendapp/spark-rich-text/src/value.ts +16 -0
  120. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -3
  121. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  122. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +5 -5
  123. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  124. package/vendor/node_modules/@legendapp/spark-system/package.json +3 -3
  125. package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -3
  126. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +102 -14
  127. package/vendor/node_modules/@legendapp/spark-ui/package.json +3 -3
  128. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +5 -0
  129. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +12 -4
  130. package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -3
  131. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  132. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-desktop-shortcuts",
3
- "version": "0.0.1-next.4",
3
+ "version": "0.0.1-next.6",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -10,7 +10,7 @@
10
10
  "*.podspec"
11
11
  ],
12
12
  "peerDependencies": {
13
- "react": "19.1.4",
13
+ "react": "^19.1.0",
14
14
  "react-native": "0.81.6"
15
15
  },
16
16
  "codegenConfig": {
@@ -40,7 +40,7 @@
40
40
  ]
41
41
  },
42
42
  "dependencies": {
43
- "@legendapp/spark-desktop-app": "0.0.1-next.4"
43
+ "@legendapp/spark-desktop-app": "0.0.1-next.6"
44
44
  },
45
45
  "private": true
46
46
  }
@@ -556,12 +556,13 @@ static void LegendPrepareWindowForDisplay(NSWindow *window, NSString *background
556
556
 
557
557
  static void LegendApplyContentLayoutMode(NSWindow *window, NSNumber *maskNumber, BOOL usesTitlebarBackground)
558
558
  {
559
- if (usesTitlebarBackground) {
559
+ NSString *contentLayoutMode = objc_getAssociatedObject(window, &LegendContentLayoutModeKey);
560
+ if ([contentLayoutMode isEqualToString:@"fullSize"] || (usesTitlebarBackground && ![contentLayoutMode isEqualToString:@"contentLayoutGuide"])) {
560
561
  window.styleMask = window.styleMask | NSWindowStyleMaskFullSizeContentView;
561
562
  return;
562
563
  }
563
564
 
564
- if (maskNumber && (maskNumber.unsignedIntegerValue & NSWindowStyleMaskFullSizeContentView) == 0) {
565
+ if ([contentLayoutMode isEqualToString:@"contentLayoutGuide"] || (maskNumber && (maskNumber.unsignedIntegerValue & NSWindowStyleMaskFullSizeContentView) == 0)) {
565
566
  window.styleMask = window.styleMask & ~NSWindowStyleMaskFullSizeContentView;
566
567
  }
567
568
  }
@@ -683,7 +684,7 @@ static void LegendApplyWindowOptions(NSWindow *window, NSDictionary *options)
683
684
  LegendApplyWindowBackgroundColor(window, backgroundColor);
684
685
 
685
686
  RCTUIView *rootView = LegendManagedRootView(window);
686
- if (usesTitlebarBackground && rootView) {
687
+ if ((usesTitlebarBackground || contentLayoutMode.length > 0) && rootView) {
687
688
  LegendEnsureRootViewContainer(window, rootView);
688
689
  LegendSizeRootViewToWindow(rootView, window);
689
690
  }
@@ -2292,7 +2293,7 @@ willBeInsertedIntoToolbar:(BOOL)flag
2292
2293
  }
2293
2294
  [rootView removeFromSuperview];
2294
2295
  targetWindow.contentView = rootView;
2295
- if (usesTitlebarBackground) {
2296
+ if (usesTitlebarBackground || contentLayoutMode.length > 0) {
2296
2297
  LegendEnsureRootViewContainer(targetWindow, rootView);
2297
2298
  }
2298
2299
  LegendApplyWindowBackgroundColor(targetWindow, backgroundColor);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-desktop-windows",
3
- "version": "0.0.1-next.4",
3
+ "version": "0.0.1-next.6",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -10,7 +10,7 @@
10
10
  "*.podspec"
11
11
  ],
12
12
  "peerDependencies": {
13
- "react": "19.1.4",
13
+ "react": "^19.1.0",
14
14
  "react-native": "0.81.6"
15
15
  },
16
16
  "codegenConfig": {
@@ -40,8 +40,8 @@
40
40
  ]
41
41
  },
42
42
  "dependencies": {
43
- "@legendapp/spark-desktop-app": "0.0.1-next.4",
44
- "@legendapp/spark-window-options": "0.0.1-next.4",
43
+ "@legendapp/spark-desktop-app": "0.0.1-next.6",
44
+ "@legendapp/spark-window-options": "0.0.1-next.6",
45
45
  "@legendapp/state": "^3.0.0-beta.42"
46
46
  },
47
47
  "private": true
@@ -33,8 +33,8 @@ export async function openWindow(options: WindowOpenOptions): Promise<WindowInfo
33
33
  try {
34
34
  const info = await windowCall("completeOpen", snapshot, isInfo);
35
35
  // Common chrome is applied first; explicit AppKit groups own their corresponding fields.
36
- if (!snapshot.macos) return publicInfo(info);
37
- await updateMacOSWindow(snapshot.id, snapshot.macos);
36
+ if (!snapshot.macos && snapshot.appearance === undefined && snapshot.backgroundColor === undefined) return publicInfo(info);
37
+ await updateMacOSWindow(snapshot.id, snapshot);
38
38
  // The window now exists: reflect the applied chrome, but a transient read-back
39
39
  // failure must not discard a window that opened successfully, so fall back to info.
40
40
  try { return await getWindow(snapshot.id); } catch { return publicInfo(info); }
@@ -57,7 +57,7 @@ export async function setWindowOptions(id: string, options: WindowUpdateOptions)
57
57
  if (!snapshot.macos || Object.keys(snapshot).some(key => key !== "macos")) {
58
58
  await windowCommand("options", { id, options: snapshot });
59
59
  }
60
- if (snapshot.macos) await updateMacOSWindow(id, snapshot.macos);
60
+ if (Platform.OS === "macos" && (snapshot.macos || snapshot.appearance !== undefined || snapshot.backgroundColor !== undefined)) await updateMacOSWindow(id, snapshot);
61
61
  }
62
62
  /** Portable frame change. Animated moves are macOS-only: pass `macos.durationMs` and the call rejects on Windows rather than ignoring the request. */
63
63
  export async function setWindowBounds(id: string, value: WindowBounds, options: SetWindowBoundsOptions = {}): Promise<void> {
@@ -113,43 +113,80 @@ export async function addWindowListener<K extends keyof WindowEventMap>(id: stri
113
113
  try { listener(payload as WindowEventMap[K]); } catch (cause) { report(options, cause); }
114
114
  }, [type]);
115
115
  }
116
- const guards = new Map<string, AsyncRegistration>();
116
+ interface CloseGuardOwner {
117
+ handler: () => boolean | Promise<boolean>;
118
+ options: WindowListenerOptions;
119
+ stopped: boolean;
120
+ registration: AsyncRegistration;
121
+ }
122
+ interface CloseGuard {
123
+ owner?: CloseGuardOwner;
124
+ acquire(handler: CloseGuardOwner["handler"], options: WindowListenerOptions): AsyncRegistration;
125
+ }
126
+ const guards = new Map<string, CloseGuard>();
117
127
  const creatingGuards = new Set<string>();
118
128
  const orphanGuards = new Map<string, AsyncRegistration>();
119
129
  let guardSequence = 0;
120
- /** Each window accepts one close guard; a second registration rejects E_BUSY until the first is removed. Removal is idempotent. */
130
+ /** One owner per window. Replacement waits for removal; native protection survives the handoff. */
121
131
  export async function beforeWindowClose(id: string, handler: () => boolean | Promise<boolean>, options: WindowListenerOptions = {}): Promise<AsyncRegistration> {
122
132
  windowId(id); object(options, "guard options"); keys(options, ["onError"]);
123
133
  if (typeof handler !== "function" || (options.onError !== undefined && typeof options.onError !== "function")) throw new SparkError("E_INVALID_ARGUMENT", "Expected window close callbacks");
124
- if (orphanGuards.has(id)) { await orphanGuards.get(id)!.remove(); orphanGuards.delete(id); }
125
- if (guards.has(id) || creatingGuards.has(id)) throw new SparkError("E_BUSY", "Window already has a close guard");
134
+ if (creatingGuards.has(id)) throw new SparkError("E_BUSY", "Window already has a close guard");
126
135
  creatingGuards.add(id);
136
+ try {
137
+ if (orphanGuards.has(id)) { await orphanGuards.get(id)!.remove(); orphanGuards.delete(id); }
138
+ const existing = guards.get(id);
139
+ if (existing) {
140
+ if (existing.owner && !existing.owner.stopped) throw new SparkError("E_BUSY", "Window already has a close guard");
141
+ if (existing.owner) await existing.owner.registration.remove();
142
+ if (guards.get(id) === existing) return existing.acquire(handler, options);
143
+ }
144
+ return await createCloseGuard(id, handler, options);
145
+ } finally { creatingGuards.delete(id); }
146
+ }
147
+ async function createCloseGuard(id: string, handler: CloseGuardOwner["handler"], options: WindowListenerOptions): Promise<AsyncRegistration> {
127
148
  const guardId = `close-${Date.now()}-${++guardSequence}`;
128
- let stopped = false, instance: string | undefined, request: number | undefined, latestRequest = 0;
149
+ let closed = false, instance: string | undefined, request: number | undefined, latestRequest = 0;
129
150
  let subscription: ReturnType<typeof onDesktopEvent>;
130
- try { subscription = onDesktopEvent(event => {
131
- if (stopped || event.windowId !== id || event.instanceId !== instance) return;
132
- if (event.type === "closed") { stopped = true; subscription.remove(); guards.delete(id); return; }
151
+ const stop = () => { closed = true; request = undefined; subscription.remove(); if (guards.get(id) === guard) guards.delete(id); };
152
+ const guard: CloseGuard = { acquire(handler, options) {
153
+ const owner: CloseGuardOwner = { handler, options, stopped: false, registration: asyncRegistration(() => {
154
+ owner.stopped = true; request = undefined;
155
+ }, async () => {
156
+ // Keep the native dispatcher installed for this window instance. Re-arming
157
+ // acknowledges removal and cancels pending decisions without an unguarded gap.
158
+ try { if (!closed && instance) await windowCommand("closeGuard", { id, instanceId: instance, guardId, enabled: true }); }
159
+ catch (cause) { if (nativeError(cause).code !== "E_NOT_FOUND") throw cause; stop(); }
160
+ if (guard.owner === owner) guard.owner = undefined;
161
+ }) };
162
+ guard.owner = owner;
163
+ return owner.registration;
164
+ } };
165
+ const registration = guard.acquire(handler, options);
166
+ subscription = onDesktopEvent(event => {
167
+ if (closed || event.windowId !== id || event.instanceId !== instance) return;
168
+ if (event.type === "closed") { stop(); return; }
133
169
  if (event.guardId !== guardId) return;
134
- if (event.type === "closeGuardTimeout") { request = undefined; report(options, new SparkError("E_TIMEOUT", "Window close guard exceeded 30 seconds")); return; }
170
+ const owner = guard.owner;
171
+ if (event.type === "closeGuardTimeout") { request = undefined; if (owner && !owner.stopped) report(owner.options, new SparkError("E_TIMEOUT", "Window close guard exceeded 30 seconds")); return; }
135
172
  if (event.type !== "beforeClose" || !Number.isSafeInteger(event.requestId) || (event.requestId as number) <= latestRequest) return;
136
173
  const current = latestRequest = request = event.requestId as number;
137
- void Promise.resolve().then(() => stopped ? false : handler()).catch(cause => { report(options, cause); return false; }).then(async allow => {
138
- if (stopped || request !== current) return;
139
- await windowCommand("replyClose", { id, instanceId: instance, guardId, requestId: current, allow: allow === true });
140
- }).catch(cause => report(options, cause)).finally(() => { if (request === current) request = undefined; });
141
- }, { types: ["closed", "beforeClose", "closeGuardTimeout"], target: { field: "windowId", value: id } }); } catch (cause) { creatingGuards.delete(id); throw cause; }
142
- const registration = asyncRegistration(() => { stopped = true; subscription.remove(); }, async () => {
143
- try { if (instance) await windowCommand("closeGuard", { id, instanceId: instance, guardId, enabled: false }); }
144
- catch (cause) { if (nativeError(cause).code !== "E_NOT_FOUND") throw cause; }
145
- if (guards.get(id) === registration) guards.delete(id);
146
- });
174
+ void Promise.resolve().then(() => owner ? !owner.stopped && owner.handler() : true).catch(cause => { if (owner && !owner.stopped) report(owner.options, cause); return false; }).then(async allow => {
175
+ if (closed || request !== current) return;
176
+ await windowCommand("replyClose", { id, instanceId: instance, guardId, requestId: current, allow: guard.owner === owner && allow === true });
177
+ }).catch(cause => { if (owner && !owner.stopped) report(owner.options, cause); }).finally(() => { if (request === current) request = undefined; });
178
+ }, { types: ["closed", "beforeClose", "closeGuardTimeout"], target: { field: "windowId", value: id } });
147
179
  try {
148
180
  instance = (await windowCall("observe", { id }, isInfo)).instanceId;
149
181
  await windowCommand("closeGuard", { id, instanceId: instance, guardId, enabled: true });
150
- if (!stopped) guards.set(id, registration); return registration;
182
+ if (!closed) guards.set(id, guard);
183
+ return registration;
151
184
  } catch (cause) {
152
- try { await registration.remove(); } catch (cleanup) { orphanGuards.set(id, registration); report(options, cleanup); }
185
+ const cleanup = asyncRegistration(stop, async () => {
186
+ try { if (instance) await windowCommand("closeGuard", { id, instanceId: instance, guardId, enabled: false }); }
187
+ catch (cause) { if (nativeError(cause).code !== "E_NOT_FOUND") throw cause; }
188
+ });
189
+ try { await cleanup.remove(); } catch (error) { orphanGuards.set(id, cleanup); report(options, error); }
153
190
  throw cause;
154
- } finally { creatingGuards.delete(id); }
191
+ }
155
192
  }
@@ -2,7 +2,7 @@ import { Platform } from "react-native";
2
2
  import { SparkError, invokeNative, parseNativeResult } from "@legendapp/spark-desktop-app/src/contracts";
3
3
  import { menuItems } from "@legendapp/spark-desktop-app/src/contracts/menu";
4
4
  import Native from "./window-manager/NativeWindowManager";
5
- import type { MacOSWindowOptions, WindowOpenOptions } from "./types";
5
+ import type { WindowOpenOptions, WindowUpdateOptions } from "./types";
6
6
  export function macosNative() {
7
7
  if (Platform.OS !== "macos") throw new SparkError("E_UNSUPPORTED_PLATFORM", "This operation requires macOS");
8
8
  if (!Native) throw new SparkError("E_MODULE_UNAVAILABLE", "The macOS window module is unavailable");
@@ -12,9 +12,11 @@ export async function macosCommand(operation: () => Promise<string>): Promise<vo
12
12
  const result = parseNativeResult(await invokeNative(operation), (value): value is { success: boolean; message?: string } => !!value && typeof value === "object" && typeof (value as any).success === "boolean");
13
13
  if (!result.success) throw new SparkError("E_NATIVE", result.message ?? "macOS window operation failed");
14
14
  }
15
- export function macosOptions(options: MacOSWindowOptions | undefined): Record<string, unknown> {
16
- if (!options) return {};
15
+ export function macosOptions({ macos: options, appearance, backgroundColor }: Pick<WindowOpenOptions, "macos" | "appearance" | "backgroundColor">): Record<string, unknown> {
17
16
  const result: Record<string, unknown> = {}, style: Record<string, unknown> = {};
17
+ if (appearance !== undefined) style.appearance = appearance;
18
+ if (backgroundColor !== undefined) style.backgroundColor = backgroundColor;
19
+ if (!options) return { windowStyle: style };
18
20
  if (options.representedUri !== undefined) result.representedURL = options.representedUri;
19
21
  if (options.restoreOnLaunch !== undefined) result.restoreOnLaunch = options.restoreOnLaunch;
20
22
  if (options.startupSplitView !== undefined) style.startupSplitView = options.startupSplitView;
@@ -46,8 +48,8 @@ export function macosOptions(options: MacOSWindowOptions | undefined): Record<st
46
48
  return result;
47
49
  }
48
50
  export async function createMacOSWindow(options: WindowOpenOptions): Promise<void> {
49
- await macosCommand(() => macosNative().openWindow(JSON.stringify({ ...macosOptions(options.macos), identifier: options.id, moduleName: options.component, initialProperties: options.props ?? {}, title: options.title, deferOrderFront: true, sparkOverlay: options.kind === "overlay" })));
51
+ await macosCommand(() => macosNative().openWindow(JSON.stringify({ ...macosOptions(options), identifier: options.id, moduleName: options.component, initialProperties: options.props ?? {}, title: options.title, deferOrderFront: true, sparkOverlay: options.kind === "overlay" })));
50
52
  }
51
- export async function updateMacOSWindow(id: string, options: MacOSWindowOptions): Promise<void> {
53
+ export async function updateMacOSWindow(id: string, options: WindowUpdateOptions): Promise<void> {
52
54
  await macosCommand(() => macosNative().setWindowOptions(id, JSON.stringify(macosOptions(options))));
53
55
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-documents",
3
- "version": "0.0.1-next.4",
3
+ "version": "0.0.1-next.6",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "main": "src/index.tsx",
@@ -8,15 +8,15 @@
8
8
  "src"
9
9
  ],
10
10
  "dependencies": {
11
- "@legendapp/spark-file-dialog": "0.0.1-next.4",
12
- "@legendapp/spark-file-system": "0.0.1-next.4",
13
- "@legendapp/spark-native-menu": "0.0.1-next.4",
14
- "@legendapp/spark-desktop-app": "0.0.1-next.4",
15
- "@legendapp/spark-desktop-windows": "0.0.1-next.4",
16
- "@legendapp/spark-desktop-links": "0.0.1-next.4"
11
+ "@legendapp/spark-file-dialog": "0.0.1-next.6",
12
+ "@legendapp/spark-file-system": "0.0.1-next.6",
13
+ "@legendapp/spark-native-menu": "0.0.1-next.6",
14
+ "@legendapp/spark-desktop-app": "0.0.1-next.6",
15
+ "@legendapp/spark-desktop-windows": "0.0.1-next.6",
16
+ "@legendapp/spark-desktop-links": "0.0.1-next.6"
17
17
  },
18
18
  "peerDependencies": {
19
- "react": "19.1.4",
19
+ "react": "^19.1.0",
20
20
  "react-native": "0.81.6"
21
21
  }
22
22
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-drag-drop",
3
- "version": "0.0.1-next.4",
3
+ "version": "0.0.1-next.6",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "react-native": "src/index.tsx",
@@ -12,7 +12,7 @@
12
12
  "react-native.config.js"
13
13
  ],
14
14
  "peerDependencies": {
15
- "react": "19.1.4",
15
+ "react": "^19.1.0",
16
16
  "react-native": "0.81.6"
17
17
  },
18
18
  "codegenConfig": {
@@ -39,7 +39,7 @@
39
39
  ]
40
40
  },
41
41
  "dependencies": {
42
- "@legendapp/spark-desktop-app": "0.0.1-next.4"
42
+ "@legendapp/spark-desktop-app": "0.0.1-next.6"
43
43
  },
44
44
  "private": true
45
45
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-file-dialog",
3
- "version": "0.0.1-next.4",
3
+ "version": "0.0.1-next.6",
4
4
  "main": "src/index",
5
5
  "react-native": "src/index",
6
6
  "codegenConfig": {
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "peerDependencies": {
21
- "react": "19.1.4",
21
+ "react": "^19.1.0",
22
22
  "react-native": "0.81.6"
23
23
  },
24
24
  "license": "MIT",
@@ -45,6 +45,6 @@
45
45
  },
46
46
  "private": true,
47
47
  "dependencies": {
48
- "@legendapp/spark-desktop-app": "0.0.1-next.4"
48
+ "@legendapp/spark-desktop-app": "0.0.1-next.6"
49
49
  }
50
50
  }
@@ -18,6 +18,7 @@ enum SparkTransferTestFailure {
18
18
  SparkFailBackupRemoval = 1 << 5,
19
19
  SparkFailStageCleanup = 1 << 6,
20
20
  };
21
+ void SparkSetRemoveTestHook(void (^hook)(void));
21
22
  void SparkSetTransferTestFailures(unsigned failures, BOOL forceCrossVolumeMove);
22
23
  #endif
23
24
  /** Copies or moves, replacing the destination only when overwrite is set. An existing destination otherwise conflicts with NSFileWriteFileExistsError, including a dangling link. Self-transfers and overlapping paths reject. Transfers stage beside the destination before publication; cross-volume moves copy then delete. A cross-volume source-cleanup failure can leave a partial source; source-cleanup and backup-cleanup errors report committed and retained paths. */
@@ -6,6 +6,8 @@
6
6
  #import <stdio.h>
7
7
 
8
8
  #if defined(SPARK_FILE_MUTATIONS_TESTING)
9
+ static void (^SparkRemoveTestHook)(void);
10
+ void SparkSetRemoveTestHook(void (^hook)(void)) { SparkRemoveTestHook = [hook copy]; }
9
11
  static unsigned SparkTransferTestFailures;
10
12
  static BOOL SparkForceCrossVolumeMove;
11
13
  void SparkSetTransferTestFailures(unsigned failures, BOOL forceCrossVolumeMove) {
@@ -202,14 +204,13 @@ BOOL SparkRemoveFile(NSURL *url, BOOL recursive, NSError **error) {
202
204
  userInfo:@{NSUnderlyingErrorKey: [NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:nil]}];
203
205
  return NO;
204
206
  }
205
- NSFileManager *fm = NSFileManager.defaultManager;
206
- if (S_ISDIR(info.st_mode) && !recursive) {
207
- NSArray *children = [fm contentsOfDirectoryAtPath:url.path error:error];
208
- if (!children) return NO;
209
- if (children.count) {
210
- if (error) *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:ENOTEMPTY userInfo:nil];
211
- return NO;
212
- }
213
- }
214
- return [fm removeItemAtURL:url error:error];
207
+ #if defined(SPARK_FILE_MUTATIONS_TESTING)
208
+ if (SparkRemoveTestHook) { void (^hook)(void) = SparkRemoveTestHook; SparkRemoveTestHook = nil; hook(); }
209
+ #endif
210
+ if (recursive && S_ISDIR(info.st_mode)) return [NSFileManager.defaultManager removeItemAtURL:url error:error];
211
+ // The OS checks emptiness atomically; never recursively remove a concurrent child.
212
+ if ((S_ISDIR(info.st_mode) ? rmdir(url.fileSystemRepresentation) : unlink(url.fileSystemRepresentation)) == 0) return YES;
213
+ int code = errno;
214
+ if (code != ENOENT && code != ENOTDIR && error) *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:nil];
215
+ return NO;
215
216
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-file-system",
3
- "version": "0.0.1-next.4",
3
+ "version": "0.0.1-next.6",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -12,7 +12,7 @@
12
12
  "react-native.config.js"
13
13
  ],
14
14
  "peerDependencies": {
15
- "react": "19.1.4",
15
+ "react": "^19.1.0",
16
16
  "react-native": "0.81.6"
17
17
  },
18
18
  "codegenConfig": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  },
45
45
  "dependencies": {
46
- "@legendapp/spark-desktop-app": "0.0.1-next.4"
46
+ "@legendapp/spark-desktop-app": "0.0.1-next.6"
47
47
  },
48
48
  "private": true
49
49
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-global-shortcuts",
3
- "version": "0.0.1-next.4",
3
+ "version": "0.0.1-next.6",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -12,7 +12,7 @@
12
12
  "react-native.config.js"
13
13
  ],
14
14
  "peerDependencies": {
15
- "react": "19.1.4",
15
+ "react": "^19.1.0",
16
16
  "react-native": "0.81.6"
17
17
  },
18
18
  "codegenConfig": {
@@ -41,7 +41,7 @@
41
41
  ]
42
42
  },
43
43
  "dependencies": {
44
- "@legendapp/spark-desktop-app": "0.0.1-next.4"
44
+ "@legendapp/spark-desktop-app": "0.0.1-next.6"
45
45
  },
46
46
  "private": true
47
47
  }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@legendapp/spark-html",
3
+ "version": "0.0.1-next.6",
4
+ "private": true,
5
+ "license": "MIT",
6
+ "main": "src/index.ts",
7
+ "react-native": "src/index.ts",
8
+ "files": [
9
+ "src"
10
+ ],
11
+ "peerDependencies": {
12
+ "react": "^19.1.0",
13
+ "react-native": "0.81.6",
14
+ "react-native-enriched-html": "1.1.1"
15
+ },
16
+ "dependencies": {
17
+ "@legendapp/spark-rich-text": "0.0.1-next.6"
18
+ },
19
+ "peerDependenciesMeta": {
20
+ "react-native-enriched-html": {
21
+ "optional": true
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,22 @@
1
+ import { StyleSheet, type StyleProp, type TextStyle, type ViewProps } from "react-native";
2
+ import { EnrichedText, type EnrichedTextHtmlStyle } from "react-native-enriched-html";
3
+
4
+ export interface HtmlProps extends Omit<ViewProps, "children" | "style"> {
5
+ value?: string;
6
+ children?: string;
7
+ style?: StyleProp<TextStyle>;
8
+ htmlStyle?: EnrichedTextHtmlStyle;
9
+ selectable?: boolean;
10
+ onLinkPress?(event: { url: string }): void;
11
+ }
12
+
13
+ export function Html({ value, children, style, selectable = true, ...props }: HtmlProps) {
14
+ return (
15
+ <EnrichedText
16
+ {...props}
17
+ children={value ?? children ?? ""}
18
+ style={StyleSheet.flatten(style)}
19
+ selectable={selectable}
20
+ />
21
+ );
22
+ }
@@ -0,0 +1,102 @@
1
+ import { useImperativeHandle, useRef, useState } from "react";
2
+ import { StyleSheet, Text, View, type NativeSyntheticEvent } from "react-native";
3
+ import { EnrichedTextInput, type EnrichedTextInputInstance } from "react-native-enriched-html";
4
+ import {
5
+ FormattingButtons,
6
+ InputPreview,
7
+ useInputValue,
8
+ useInputShortcuts,
9
+ type FormattingAction,
10
+ } from "@legendapp/spark-rich-text";
11
+ import { Html } from "./Html";
12
+ import type { HtmlInputProps } from "./types";
13
+
14
+ export function HtmlInput(props: HtmlInputProps) {
15
+ return <HtmlEditor {...props} />;
16
+ }
17
+
18
+ export function EditableHtml(props: HtmlInputProps) {
19
+ return <HtmlEditor {...props} preview />;
20
+ }
21
+
22
+ function HtmlEditor({
23
+ value,
24
+ onChangeText,
25
+ placeholder,
26
+ autoFocus,
27
+ onFocus,
28
+ onBlur,
29
+ style,
30
+ ref,
31
+ formatting,
32
+ onRequestLink,
33
+ accessibilityLabel,
34
+ testID,
35
+ preview = false,
36
+ }: HtmlInputProps & { preview?: boolean }) {
37
+ const input = useRef<EnrichedTextInputInstance | null>(null);
38
+ const initialValue = useRef(value).current;
39
+ const selection = useRef({ start: 0, end: 0, text: "" });
40
+ const [editing, setEditing] = useState(false);
41
+ const format = (action: FormattingAction) => {
42
+ const url = action === "link" ? onRequestLink?.() : undefined;
43
+ input.current?.focus();
44
+ if (action === "link") {
45
+ if (url)
46
+ input.current?.setLink(
47
+ selection.current.start,
48
+ selection.current.end,
49
+ selection.current.text || url,
50
+ url,
51
+ );
52
+ } else if (action === "bold") input.current?.toggleBold();
53
+ else if (action === "italic") input.current?.toggleItalic();
54
+ else if (action === "unorderedList") input.current?.toggleUnorderedList();
55
+ else input.current?.toggleOrderedList();
56
+ };
57
+ useInputShortcuts(input, editing, formatting ? { onFormat: format, linkEnabled: !!onRequestLink } : undefined);
58
+ const change = useInputValue(value, (next) => input.current?.setValue(next), onChangeText);
59
+ useImperativeHandle(ref, () => ({ focus: () => input.current?.focus(), blur: () => input.current?.blur() }), []);
60
+ const inputStyle = StyleSheet.flatten([{ minHeight: 44, padding: 0, fontSize: 16 }, style]);
61
+ return (
62
+ <View>
63
+ {formatting && <FormattingButtons linkEnabled={!!onRequestLink} onFormat={format} />}
64
+ <View>
65
+ <EnrichedTextInput
66
+ ref={input}
67
+ defaultValue={initialValue}
68
+ scrollEnabled={false}
69
+ autoFocus={autoFocus}
70
+ placeholder={placeholder}
71
+ style={inputStyle}
72
+ accessibilityLabel={accessibilityLabel}
73
+ testID={testID}
74
+ onChangeHtml={(event: NativeSyntheticEvent<{ value: string }>) => change(event.nativeEvent.value)}
75
+ onChangeSelection={(event: NativeSyntheticEvent<{ start: number; end: number; text: string }>) => {
76
+ selection.current = event.nativeEvent;
77
+ }}
78
+ onFocus={() => {
79
+ setEditing(true);
80
+ onFocus?.();
81
+ }}
82
+ onBlur={() => {
83
+ setEditing(false);
84
+ onBlur?.();
85
+ }}
86
+ onKeyPress={(event: NativeSyntheticEvent<{ key: string }>) => {
87
+ if (event.nativeEvent.key === "Escape") input.current?.blur();
88
+ }}
89
+ />
90
+ {preview && (
91
+ <InputPreview editing={editing} style={style}>
92
+ {value ? (
93
+ <Html value={value} style={inputStyle} selectable={false} />
94
+ ) : (
95
+ <Text style={[inputStyle, { color: "#888" }]}>{placeholder}</Text>
96
+ )}
97
+ </InputPreview>
98
+ )}
99
+ </View>
100
+ </View>
101
+ );
102
+ }
@@ -0,0 +1,4 @@
1
+ export { Html } from "./Html";
2
+ export type { HtmlProps } from "./Html";
3
+ export { HtmlInput, EditableHtml } from "./HtmlInput";
4
+ export type { HtmlInputProps, HtmlInputRef } from "./types";
@@ -0,0 +1,4 @@
1
+ import type { RichTextInputProps, RichTextInputRef } from "@legendapp/spark-rich-text";
2
+
3
+ export interface HtmlInputProps extends RichTextInputProps {}
4
+ export type HtmlInputRef = RichTextInputRef;
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@legendapp/spark-markdown",
3
+ "version": "0.0.1-next.6",
4
+ "private": true,
5
+ "license": "MIT",
6
+ "main": "src/index.ts",
7
+ "react-native": "src/index.ts",
8
+ "files": [
9
+ "src"
10
+ ],
11
+ "peerDependencies": {
12
+ "react": "^19.1.0",
13
+ "react-native": "0.81.6",
14
+ "react-native-enriched-markdown": "1.1.1"
15
+ },
16
+ "dependencies": {
17
+ "@legendapp/spark-rich-text": "0.0.1-next.6"
18
+ },
19
+ "peerDependenciesMeta": {
20
+ "react-native-enriched-markdown": {
21
+ "optional": true
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ import { StyleSheet, type StyleProp, type TextStyle, type ViewProps } from "react-native";
2
+ import { EnrichedMarkdownText, type MarkdownStyle } from "react-native-enriched-markdown";
3
+
4
+ export interface MarkdownProps extends Omit<ViewProps, "children" | "style"> {
5
+ value?: string;
6
+ children?: string;
7
+ style?: StyleProp<TextStyle>;
8
+ markdownStyle?: MarkdownStyle;
9
+ selectable?: boolean;
10
+ onLinkPress?(event: { url: string }): void;
11
+ }
12
+
13
+ export function Markdown({ value, children, style, selectable = true, ...props }: MarkdownProps) {
14
+ return (
15
+ <EnrichedMarkdownText
16
+ {...props}
17
+ markdown={value ?? children ?? ""}
18
+ containerStyle={StyleSheet.flatten(style)}
19
+ selectable={selectable}
20
+ allowTrailingMargin={false}
21
+ enableTaskListItemToggle={false}
22
+ />
23
+ );
24
+ }