@legendapp/spark 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/skills/spark/UPGRADING.md +58 -0
- package/skills/spark/storage-settings.md +2 -28
- package/skills/spark/ui.md +27 -1
- package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-audio/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +43 -24
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +4 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/publish-directory.js +32 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release-app.js +139 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +21 -21
- package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +61 -41
- package/vendor/node_modules/@legendapp/spark-cli/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-codex/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.cjs +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.d.cts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +16 -5
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-processes/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +122 -334
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/rows.tsx +183 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-system/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-tray/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +2 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +17 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +10 -8
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +7 -6
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +10 -9
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +6 -4
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/switch.tsx +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +16 -4
- package/vendor/node_modules/@legendapp/spark-updates/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
- /package/{settings-window.ts → ui-settings.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"./ui/swipe": "./ui-swipe.ts",
|
|
65
65
|
"./ui/symbol": "./ui-symbol.ts",
|
|
66
66
|
"./ui/popover": "./ui-popover.ts",
|
|
67
|
+
"./ui/settings": "./ui-settings.ts",
|
|
67
68
|
"./ui/sheet": "./ui-sheet.ts",
|
|
68
69
|
"./ui/table": "./ui-table.ts",
|
|
69
70
|
"./ui/progress": "./ui-progress.ts",
|
|
70
71
|
"./ui/search": "./ui-search.ts",
|
|
71
|
-
"./settings/window": "./settings-window.ts",
|
|
72
72
|
"./settings/observable": "./settings-observable.ts",
|
|
73
73
|
"./ui/classnames": "./ui-classnames.ts",
|
|
74
74
|
"./contracts": "./contracts.ts",
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
"spark": {
|
|
189
189
|
"nativePatchRequirements": {
|
|
190
190
|
"schema": 1,
|
|
191
|
-
"frameworkVersion": "0.0.
|
|
191
|
+
"frameworkVersion": "0.0.5",
|
|
192
192
|
"packages": {
|
|
193
193
|
"@react-native-runtimes/core": {
|
|
194
194
|
"version": "0.1.0-alpha.2",
|
|
@@ -554,3 +554,61 @@ inactive-target configuration remains accepted.
|
|
|
554
554
|
|
|
555
555
|
The SecureStore original-import adapter remains held for verification and is not
|
|
556
556
|
included in 0.0.4.
|
|
557
|
+
|
|
558
|
+
## 0.0.5
|
|
559
|
+
|
|
560
|
+
Breaking: yes. macOS settings windows move from
|
|
561
|
+
`@legendapp/spark/settings/window` to `@legendapp/spark/ui/settings` (#561).
|
|
562
|
+
|
|
563
|
+
1. Change settings window imports and re-exports to the new path. Install
|
|
564
|
+
`@legendapp/list` in the app if it is missing. Keep the window registration
|
|
565
|
+
with `createSettingsWindowOptions()` and pass the registered `windowId`.
|
|
566
|
+
2. Replace the `pages` array and render callbacks with `SettingsPage` children.
|
|
567
|
+
Keep each page's ID and title, and add an SF Symbol name as `icon`. Remove any
|
|
568
|
+
`backgroundClassName`, `contentBackgroundClassName`, `contentMinWidth`,
|
|
569
|
+
`sidebarMinWidth` and `estimatedItemSize` props from the window. Move any page
|
|
570
|
+
actions into the page content.
|
|
571
|
+
3. Place rows in `SettingsSection` cards in place of `SettingsCard` and
|
|
572
|
+
`SettingsRowGroup`. Change row `title` to `label` and put custom controls in
|
|
573
|
+
the row's children in place of `control`. Built-in switch, select, segmented
|
|
574
|
+
and image choice rows take the app's `value` and `onValueChange`.
|
|
575
|
+
|
|
576
|
+
**Before**
|
|
577
|
+
|
|
578
|
+
```tsx
|
|
579
|
+
import { SettingsRow, SettingsWindow } from "@legendapp/spark/settings/window";
|
|
580
|
+
|
|
581
|
+
<SettingsWindow windowId="settings" pages={[
|
|
582
|
+
{ id: "general", title: "General", render: () => <SettingsRow title="Theme" control={<ThemePicker />} /> },
|
|
583
|
+
]} />
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
**After**
|
|
587
|
+
|
|
588
|
+
```tsx
|
|
589
|
+
import { SettingsPage, SettingsRow, SettingsSection, SettingsWindow } from "@legendapp/spark/ui/settings";
|
|
590
|
+
|
|
591
|
+
<SettingsWindow windowId="settings">
|
|
592
|
+
<SettingsPage id="general" title="General" icon="gearshape">
|
|
593
|
+
<SettingsSection title="Appearance">
|
|
594
|
+
<SettingsRow label="Theme"><ThemePicker /></SettingsRow>
|
|
595
|
+
</SettingsSection>
|
|
596
|
+
</SettingsPage>
|
|
597
|
+
</SettingsWindow>
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
Standalone forms can import `Switch` from `@legendapp/spark/ui` with a boolean
|
|
601
|
+
`value`, `onValueChange` and an accessibility label. Use
|
|
602
|
+
`Select variant="borderless"` on macOS and web.
|
|
603
|
+
|
|
604
|
+
Run `spark upgrade`, `spark doctor`, and the app's typecheck and tests. Rebuild
|
|
605
|
+
custom macOS hosts and check sidebar selection, scrolling between pages, and
|
|
606
|
+
settings value persistence after reopening the window.
|
|
607
|
+
|
|
608
|
+
- macOS driver flows isolate app state and reattach after the main React host
|
|
609
|
+
reloads. Use the per-flow failure bundle to diagnose errors (#560).
|
|
610
|
+
- macOS packaging verifies the signed app's load paths, signing settings and
|
|
611
|
+
bundle contents. Check apps with custom native dependencies using
|
|
612
|
+
`bun run release:check <project-directory> <signed.app>` from the Spark
|
|
613
|
+
source checkout. Local rebuilds keep the last complete output available until
|
|
614
|
+
the new app is ready (#562).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Storage and settings
|
|
2
2
|
|
|
3
|
-
Exports: `@legendapp/spark/settings`, `/settings/observable`, `/
|
|
3
|
+
Exports: `@legendapp/spark/settings`, `/settings/observable`, `/secure-storage`, `/sqlite`.
|
|
4
4
|
|
|
5
5
|
## Pick the right store
|
|
6
6
|
|
|
@@ -52,33 +52,7 @@ try {
|
|
|
52
52
|
}
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`/settings/window` builds a macOS-style preferences window: a sidebar of pages (`SettingsWindow`, or `VirtualizedSettingsWindow` for long pages) whose content is `SettingsPage` > `SettingsSection` > `SettingsRow` (`title`, optional `description`, and a `control`). Register the window with `createSettingsWindowOptions()`: it opens hidden and `SettingsWindow` shows it once its native layout is ready. `windowId` must match the registered ID and cannot change while mounted. Selection is uncontrolled (`defaultPageId`) or controlled (`selectedPageId` + `onSelectionChange`). Requires the `@legendapp/list` peer.
|
|
58
|
-
|
|
59
|
-
```tsx
|
|
60
|
-
import { SettingsPage, SettingsRow, SettingsSection, SettingsWindow, createSettingsWindowOptions } from '@legendapp/spark/settings/window';
|
|
61
|
-
import { createWindowsNavigator } from '@legendapp/spark/windows';
|
|
62
|
-
import { Switch } from 'react-native';
|
|
63
|
-
|
|
64
|
-
function General() {
|
|
65
|
-
return (
|
|
66
|
-
<SettingsPage>
|
|
67
|
-
<SettingsSection title="Startup" first>
|
|
68
|
-
<SettingsRow title="Open at login" control={<Switch value={false} onValueChange={() => {}} />} />
|
|
69
|
-
</SettingsSection>
|
|
70
|
-
</SettingsPage>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function Settings() {
|
|
75
|
-
return <SettingsWindow windowId="settings" pages={[{ id: 'general', title: 'General', render: () => <General /> }]} />;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const windows = createWindowsNavigator({
|
|
79
|
-
settings: { id: 'settings', component: Settings, options: createSettingsWindowOptions() },
|
|
80
|
-
});
|
|
81
|
-
```
|
|
55
|
+
For settings window composition, see `/ui/settings` in [UI components](ui.md).
|
|
82
56
|
|
|
83
57
|
## Platforms
|
|
84
58
|
|
package/skills/spark/ui.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# UI components
|
|
2
2
|
|
|
3
|
-
Exports: `@legendapp/spark/ui`, `/ui/uniwind`, `/ui/classnames`, `/ui/search`, `/ui/sidebar`, `/ui/split-view`, `/ui/swipe`, `/ui/glass`, `/ui/symbol`, `/ui/progress`, `/ui/popover`, `/ui/table`, `/ui/sheet`, `/webview`, `/markdown`, `/html`.
|
|
3
|
+
Exports: `@legendapp/spark/ui`, `/ui/uniwind`, `/ui/classnames`, `/ui/search`, `/ui/sidebar`, `/ui/split-view`, `/ui/swipe`, `/ui/glass`, `/ui/symbol`, `/ui/progress`, `/ui/popover`, `/ui/table`, `/ui/sheet`, `/ui/settings`, `/webview`, `/markdown`, `/html`.
|
|
4
4
|
|
|
5
5
|
## Rules
|
|
6
6
|
|
|
@@ -8,6 +8,8 @@ Exports: `@legendapp/spark/ui`, `/ui/uniwind`, `/ui/classnames`, `/ui/search`, `
|
|
|
8
8
|
- `Button`, `TextInput`, `Select` and `SegmentedControl` (from `/ui`, or `/ui/uniwind` for className styling) render native AppKit/WinUI controls and work on iOS/Android/web through Expo UI or React Native.
|
|
9
9
|
- `Checkbox` (`value`/`onValueChange`, string label children) is macOS, Windows (WinUI `CheckBox`) and web; check `getControlAvailability('checkbox')`. `Button variant="disclosure"` (requires `expanded`) is macOS and web only. `RadioGroup` (`options`/`value`/`onValueChange` like Select, `orientation` `vertical`/`horizontal`, `size` `regular`/`small`/`mini`) is macOS (`NSButton` radios) and web only; check `getControlAvailability('radio-group')`. On macOS, buttons and checkboxes size themselves; give no fixed width unless you want one.
|
|
10
10
|
- `Button` takes `symbol` (an SF Symbol before the title; macOS only) and `size` (`regular`/`small`/`mini`; macOS, and web as smaller text). Elsewhere they report `E_UNSUPPORTED_PLATFORM` and render the disabled fallback; a symbol missing on the running macOS reports `E_NOT_FOUND`.
|
|
11
|
+
- `Switch` takes a boolean `value` and `onValueChange`. It uses the platform React Native switch, including `NSSwitch` on macOS. Label it with `accessibilityLabel`.
|
|
12
|
+
- `Select variant="borderless"` removes the bezel on macOS and web. Windows, iOS and Android report `E_UNSUPPORTED_PLATFORM` and show the current value in a disabled fallback.
|
|
11
13
|
- `SegmentedControl` takes `size` (`regular`/`small`) and `distribution` (`fit`/`fill`). `Sidebar` takes `listStyle="plain"` for lists inside content.
|
|
12
14
|
- `TextInput` is single-line unless `multiline` (an `NSTextView` on macOS; Return inserts a newline) and takes `placeholder`. It is either controlled (`value`) or uncontrolled (`defaultValue`), never both; switching needs a remount.
|
|
13
15
|
- `Select`/`SegmentedControl` never auto-select the first option when `value` is missing. Values are unique strings.
|
|
@@ -42,6 +44,30 @@ export function Preferences() {
|
|
|
42
44
|
}
|
|
43
45
|
```
|
|
44
46
|
|
|
47
|
+
## Settings windows on macOS
|
|
48
|
+
|
|
49
|
+
Use `@legendapp/spark/ui/settings` with `@legendapp/list` installed. Register a hidden window with `createSettingsWindowOptions()` and pass the registered `windowId` to `SettingsWindow` (also exported as `VirtualizedSettingsWindow`). The sidebar scrolls the shared list and follows its current page. Use `defaultPageId` or `selectedPageId` with `onSelectionChange`. Other platforms throw `E_UNSUPPORTED_PLATFORM` on render.
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { useState } from 'react';
|
|
53
|
+
import { SettingsPage, SettingsSection, SettingsSwitchRow, SettingsWindow } from '@legendapp/spark/ui/settings';
|
|
54
|
+
|
|
55
|
+
export function Preferences() {
|
|
56
|
+
const [wrap, setWrap] = useState(false);
|
|
57
|
+
return (
|
|
58
|
+
<SettingsWindow windowId="settings">
|
|
59
|
+
<SettingsPage id="editor" title="Editor" icon="square.and.pencil">
|
|
60
|
+
<SettingsSection title="Reading">
|
|
61
|
+
<SettingsSwitchRow label="Wrap long lines" value={wrap} onValueChange={setWrap} />
|
|
62
|
+
</SettingsSection>
|
|
63
|
+
</SettingsPage>
|
|
64
|
+
</SettingsWindow>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Add `SettingsSelectRow`, `SettingsSegmentedRow`, or `SettingsImageChoiceRow` for controlled choices. Each image option has a `label`, `value`, and one React Native `image` source. Rows accept an optional `description` and `info` tooltip. Pass a custom control as children of `SettingsRow`, or put a full-width custom element directly in a section.
|
|
70
|
+
|
|
45
71
|
## WebView, Markdown and HTML
|
|
46
72
|
|
|
47
73
|
- `/webview` is a Spark-owned subset over `react-native-webview@16.0.0` (WebKit on macOS, not Chromium). Upstream platform-specific props reject; import `react-native-webview` directly if you need its full surface. Nothing native is exposed to pages: define a navigation policy and expose only intended message handlers.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-ai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
9
|
-
"@legendapp/spark-processes": "0.0.
|
|
8
|
+
"@legendapp/spark-desktop-app": "0.0.5",
|
|
9
|
+
"@legendapp/spark-processes": "0.0.5"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"react": "^19.2.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-audio",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"react-native": "src/index",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
},
|
|
38
38
|
"private": true,
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
40
|
+
"@legendapp/spark-desktop-app": "0.0.5"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-auth-session",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"react-native": "src/index",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"src"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@legendapp/spark-desktop-links": "0.0.
|
|
11
|
+
"@legendapp/spark-desktop-links": "0.0.5",
|
|
12
12
|
"base64-js": "1.5.1",
|
|
13
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
13
|
+
"@legendapp/spark-desktop-app": "0.0.5"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react-native": "0.83.10",
|
|
@@ -12,7 +12,8 @@ import { copyHelpers } from "./helpers.js";
|
|
|
12
12
|
import { lacksMacOSPod, readAppConfig } from "./project.js";
|
|
13
13
|
import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, readdirSync, rmSync, writeFileSync, openSync, closeSync, } from "node:fs";
|
|
14
14
|
import path from "node:path";
|
|
15
|
-
import { registerRuntime } from "./local.js";
|
|
15
|
+
import { readRuntime, registerRuntime } from "./local.js";
|
|
16
|
+
import { publishDirectory } from "./publish-directory.js";
|
|
16
17
|
import { binary, doctor, run } from "./commands.js";
|
|
17
18
|
import { prepareConfig, entryFile, digest, hashFiles, nativePreparationInputs, nativeProjectFingerprint, localSigningIdentity, nativePackages, readJson, runtimeFor, selection, stateFile, writeJson, validateBuildModules, goConfigurationIssues, } from "./project.js";
|
|
18
19
|
export async function analyze(root) {
|
|
@@ -223,11 +224,12 @@ async function buildUnlocked(root, mode, force) {
|
|
|
223
224
|
const resultFile = stateFile(root, `${mode}-build.json`);
|
|
224
225
|
const { preparation, nativeConfig, nativeRoot, workspace } = await prepareMacOS(root, chosen, force);
|
|
225
226
|
const existing = existsSync(resultFile) ? readJson(resultFile) : undefined;
|
|
227
|
+
const publishedRuntime = existing && readRuntime(existing.app);
|
|
226
228
|
if (!force && existing) {
|
|
227
229
|
if (existing.runtime.fingerprint === runtime.fingerprint &&
|
|
228
230
|
existing.preparation?.fingerprint === preparation.fingerprint &&
|
|
229
231
|
existing.product === path.basename(existing.app) &&
|
|
230
|
-
|
|
232
|
+
publishedRuntime?.fingerprint === runtime.fingerprint) {
|
|
231
233
|
console.log(`Reusing ${existing.app}`);
|
|
232
234
|
return existing;
|
|
233
235
|
}
|
|
@@ -235,7 +237,7 @@ async function buildUnlocked(root, mode, force) {
|
|
|
235
237
|
const reasons = force ? ["forced build"] : !existing ? ["no cached app"] : [
|
|
236
238
|
...preparationChanges(existing.preparation, preparation),
|
|
237
239
|
...(existing.runtime.fingerprint !== runtime.fingerprint ? ["runtime inputs changed"] : []),
|
|
238
|
-
...(
|
|
240
|
+
...(publishedRuntime?.fingerprint !== existing.runtime.fingerprint ? ["published app does not match its receipt"] : []),
|
|
239
241
|
...(existing.product !== path.basename(existing.app) ? ["cached app product is unverified"] : []),
|
|
240
242
|
];
|
|
241
243
|
console.log(`Building ${mode} runtime: ${reasons.join("; ")}.`);
|
|
@@ -273,14 +275,6 @@ async function buildUnlocked(root, mode, force) {
|
|
|
273
275
|
if (!existsSync(path.join(products, product)))
|
|
274
276
|
throw new Error(`Build completed without ${product}.`);
|
|
275
277
|
const destination = stateFile(root, `products/macos-${runtime.arch}/${mode}/${product}`);
|
|
276
|
-
rmSync(path.dirname(destination), { recursive: true, force: true });
|
|
277
|
-
mkdirSync(path.dirname(destination), { recursive: true });
|
|
278
|
-
cpSync(path.join(products, product), destination, { recursive: true, verbatimSymlinks: true });
|
|
279
|
-
if (mode === "release" &&
|
|
280
|
-
!existsSync(path.join(destination, "Contents/Resources/main.jsbundle")))
|
|
281
|
-
throw new Error("Standalone build is missing its JavaScript bundle.");
|
|
282
|
-
if (mode === "release")
|
|
283
|
-
checkReleaseTestDriver(destination, nativeConfig.macos?.testDriverInRelease === true);
|
|
284
278
|
const result = {
|
|
285
279
|
app: destination,
|
|
286
280
|
// Older receipts may record a stale bundle selected from DerivedData.
|
|
@@ -295,20 +289,45 @@ async function buildUnlocked(root, mode, force) {
|
|
|
295
289
|
}
|
|
296
290
|
if (productionHash)
|
|
297
291
|
result.runtime.fingerprint = digest(result.runtime.fingerprint + productionHash);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
292
|
+
const target = path.dirname(destination);
|
|
293
|
+
const staging = `${target}.staging`;
|
|
294
|
+
const stagedApp = path.join(staging, product);
|
|
295
|
+
rmSync(staging, { recursive: true, force: true });
|
|
296
|
+
mkdirSync(staging, { recursive: true });
|
|
297
|
+
try {
|
|
298
|
+
cpSync(path.join(products, product), stagedApp, { recursive: true, verbatimSymlinks: true });
|
|
299
|
+
if (mode === "release") {
|
|
300
|
+
if (!existsSync(path.join(stagedApp, "Contents/Resources/main.jsbundle")))
|
|
301
|
+
throw new Error("Standalone build is missing its JavaScript bundle.");
|
|
302
|
+
checkReleaseTestDriver(stagedApp, nativeConfig.macos?.testDriverInRelease === true);
|
|
303
|
+
const plist = path.join(stagedApp, "Contents/Info.plist");
|
|
304
|
+
const info = JSON.parse(await run(root, ["plutil", "-convert", "json", "-o", "-", plist], { capture: true }));
|
|
305
|
+
const ats = info.NSAppTransportSecurity;
|
|
306
|
+
if (ats && "NSAllowsLocalNetworking" in ats) {
|
|
307
|
+
const key = Object.keys(ats).length === 1
|
|
308
|
+
? "NSAppTransportSecurity" : "NSAppTransportSecurity.NSAllowsLocalNetworking";
|
|
309
|
+
await run(root, ["plutil", "-remove", key, plist], { capture: true });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// prebuild can update package/config fields; cache the actual post-generation inputs.
|
|
313
|
+
writeJson(path.join(stagedApp, "Contents/Resources/spark-runtime.json"), result.runtime);
|
|
314
|
+
if (mode === "release")
|
|
315
|
+
await prepareCustomizeArtifacts(root, result.runtime, stagedApp);
|
|
316
|
+
copyHelpers(root, stagedApp, readAppConfig(root).expo?.extra?.spark?.helpers);
|
|
317
|
+
if (mode === "release") {
|
|
318
|
+
// Hermes is prebuilt, so Xcode's app/Pod compiler settings cannot strip it.
|
|
319
|
+
const hermes = path.join(stagedApp, "Contents/Frameworks/hermes.framework/Versions/Current/hermes");
|
|
320
|
+
if (existsSync(hermes))
|
|
321
|
+
await run(root, ["strip", "-S", "-x", hermes], { capture: true });
|
|
322
|
+
}
|
|
323
|
+
// Development apps can opt into a local identity for same-team native plugins.
|
|
324
|
+
// Standalone outputs remain ad-hoc until `spark package` signs its staging copy.
|
|
325
|
+
await run(root, ["codesign", "--force", "--deep", "--sign", localSigningIdentity(root, mode), stagedApp], { capture: true });
|
|
326
|
+
publishDirectory(staging, target, stateFile(root, "tools"));
|
|
327
|
+
}
|
|
328
|
+
finally {
|
|
329
|
+
rmSync(staging, { recursive: true, force: true });
|
|
308
330
|
}
|
|
309
|
-
// Development apps can opt into a local identity for same-team native plugins.
|
|
310
|
-
// Standalone outputs remain ad-hoc until `spark package` signs its staging copy.
|
|
311
|
-
await run(root, ["codesign", "--force", "--deep", "--sign", localSigningIdentity(root, mode), destination], { capture: true });
|
|
312
331
|
writeJson(resultFile, result);
|
|
313
332
|
console.log(`Built ${destination}`);
|
|
314
333
|
return result;
|
|
@@ -106,6 +106,9 @@ const migrations = [
|
|
|
106
106
|
{ version: '0.0.4', automatic: false, breaking: true, apply(context) {
|
|
107
107
|
context.manualStep('Quit older builds, back up macOS file/MMKV data, keep bundle identifiers stable, and rebuild custom hosts. First launch automatically migrates owned legacy data to ~/Library/Application Support/<bundle id>/Spark; ambiguous sources and IO errors stop startup. Review any reported conflict without overwriting data, then verify file/MMKV values and relaunch persistence; see the linked upgrade notes.');
|
|
108
108
|
} },
|
|
109
|
+
{ version: '0.0.5', automatic: false, breaking: true, apply(context) {
|
|
110
|
+
context.manualStep('For macOS settings windows, replace @legendapp/spark/settings/window with @legendapp/spark/ui/settings, install @legendapp/list if missing, and migrate the pages and rows to the new JSX API. See the linked upgrade notes and verify the settings window after rebuilding custom macOS hosts.');
|
|
111
|
+
} },
|
|
109
112
|
];
|
|
110
113
|
|
|
111
114
|
/** @param {string} root */
|
|
@@ -7,7 +7,7 @@ import path from "node:path";
|
|
|
7
7
|
import { build } from "./build.js";
|
|
8
8
|
import { credentials, notaryAuth } from "./credentials.js";
|
|
9
9
|
import { run } from "./commands.js";
|
|
10
|
-
import {
|
|
10
|
+
import { releaseAppExpectation, signApp, validateApp } from "./signing.js";
|
|
11
11
|
import { digest, readJson, stateFile, writeJson } from "./project.js";
|
|
12
12
|
export function artifactHash(file) {
|
|
13
13
|
const hash = createHash("sha256");
|
|
@@ -68,14 +68,9 @@ async function packageUnlocked(root, options, deps) {
|
|
|
68
68
|
const config = readAppConfig(root).expo;
|
|
69
69
|
if (config.extra?.spark?.updates && !result.runtime.modules["@legendapp/spark-updates"])
|
|
70
70
|
throw new Error("Updates are configured but the module was pruned. Import @legendapp/spark/updates from the app entry.");
|
|
71
|
-
const entitlements = distributionEntitlements(appEntitlements(root, result.runtime.modules));
|
|
72
|
-
if (!config.macos?.bundleIdentifier || !config.version)
|
|
73
|
-
throw new Error("Packaging requires macos.bundleIdentifier and version");
|
|
74
|
-
const byPath = config.extra?.spark?.signing?.macos?.entitlementsByPath ?? {};
|
|
75
71
|
const info = JSON.parse(await execute(root, ["plutil", "-convert", "json", "-o", "-", path.join(result.app, "Contents/Info.plist")], { capture: true }));
|
|
76
|
-
const expected =
|
|
77
|
-
|
|
78
|
-
throw new Error("Bundle identifier and release version metadata must be configured before packaging.");
|
|
72
|
+
const expected = releaseAppExpectation(root, result.runtime, config, info.CFBundleVersion);
|
|
73
|
+
const { entitlements, byPath } = expected;
|
|
79
74
|
const inputHash = artifactHash(result.app);
|
|
80
75
|
const key = digest(JSON.stringify({ recipe: 1, inputHash, identity: identity.hash, entitlements, byPath }));
|
|
81
76
|
const folder = stateFile(root, `packaging/${key}`);
|
|
@@ -90,6 +85,7 @@ async function packageUnlocked(root, options, deps) {
|
|
|
90
85
|
if (!existsSync(app) || artifactHash(app) !== state.stagedHash || !existsSync(upload) || createHash("sha256").update(readFileSync(upload)).digest("hex") !== state.archiveHash) {
|
|
91
86
|
throw new Error(`The staged notarization artifacts changed. Preserve ${statePath} for submission recovery; rebuild from clean inputs before retrying.`);
|
|
92
87
|
}
|
|
88
|
+
await validateApp(root, app, identity, expected, false, execute);
|
|
93
89
|
}
|
|
94
90
|
else {
|
|
95
91
|
rmSync(app, { recursive: true, force: true });
|
|
@@ -14,7 +14,7 @@ import { existsSync, readFileSync, readdirSync, realpathSync, } from "node:fs";
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { readJson, writeJson } from "./json.js";
|
|
16
16
|
export { readJson, writeJson };
|
|
17
|
-
export const VERSION = "0.0.
|
|
17
|
+
export const VERSION = "0.0.5";
|
|
18
18
|
export function digest(value) {
|
|
19
19
|
return createHash("sha256").update(value).digest("hex");
|
|
20
20
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { existsSync, mkdirSync, renameSync, rmSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
// Node's rename cannot replace a nonempty directory. macOS can exchange their names.
|
|
6
|
+
const source = `#include <stdio.h>
|
|
7
|
+
int main(int argc, char **argv) {
|
|
8
|
+
if (argc != 3) return 2;
|
|
9
|
+
if (renamex_np(argv[1], argv[2], RENAME_SWAP) == 0) return 0;
|
|
10
|
+
perror("Cannot swap Spark build directories");
|
|
11
|
+
return 1;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
export function publishDirectory(staged, target, tools) {
|
|
15
|
+
if (!existsSync(target)) {
|
|
16
|
+
renameSync(staged, target);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const tool = path.join(tools, `swap-${createHash("sha256").update(source).digest("hex").slice(0, 16)}`);
|
|
20
|
+
if (!existsSync(tool)) {
|
|
21
|
+
mkdirSync(tools, { recursive: true });
|
|
22
|
+
const pending = `${tool}.${process.pid}.tmp`;
|
|
23
|
+
try {
|
|
24
|
+
execFileSync("xcrun", ["clang", "-x", "c", "-o", pending, "-"], { input: source });
|
|
25
|
+
renameSync(pending, tool);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
rmSync(pending, { force: true });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
execFileSync(tool, [staged, target]);
|
|
32
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export function checkReleasePayload(app, runner, info) {
|
|
4
|
+
const runtime = path.join(app, "Contents/Resources/spark-runtime.json");
|
|
5
|
+
if (!existsSync(runtime))
|
|
6
|
+
throw new Error("Distribution app is missing spark-runtime.json.");
|
|
7
|
+
if (!runner) {
|
|
8
|
+
const bundle = path.join(app, "Contents/Resources/main.jsbundle");
|
|
9
|
+
if (!existsSync(bundle))
|
|
10
|
+
throw new Error("Distribution app is missing its JavaScript bundle.");
|
|
11
|
+
if (readFileSync(bundle).subarray(0, 8).toString("hex") !== "c61fbc03c103191f") {
|
|
12
|
+
throw new Error("The release main.jsbundle must contain Hermes bytecode.");
|
|
13
|
+
}
|
|
14
|
+
const ats = info.NSAppTransportSecurity;
|
|
15
|
+
if (ats?.NSAllowsLocalNetworking === true || ats?.NSAllowsArbitraryLoads === true) {
|
|
16
|
+
throw new Error("The release Info.plist allows local networking or arbitrary loads.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
for (const entry of readdirSync(app, { recursive: true, withFileTypes: true })) {
|
|
20
|
+
if (/(?:^\.(?:git|DS_Store)$|^node_modules$|^__tests__$|\.(?:map|dSYM|o|a|p12|p8)$|^libclang_rt\..*\.dylib$)/i.test(entry.name) ||
|
|
21
|
+
(!runner && entry.name.endsWith(".debug.dylib"))) {
|
|
22
|
+
throw new Error(`Development artifact in the distribution app: ${path.relative(app, path.join(entry.parentPath, entry.name))}`);
|
|
23
|
+
}
|
|
24
|
+
if (entry.isFile() && /\.(?:mjs|cjs|js)$/.test(entry.name) &&
|
|
25
|
+
/(?:\/\/[#@]|\/\*[#@])\s*sourceMappingURL\s*=/.test(readFileSync(path.join(entry.parentPath, entry.name), "utf8"))) {
|
|
26
|
+
throw new Error(`Source map reference in the distribution app: ${path.relative(app, path.join(entry.parentPath, entry.name))}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function loadCommands(file, output) {
|
|
31
|
+
const images = output.split(/^Mach header$/m).slice(1).map(slice => {
|
|
32
|
+
const header = /^MH_\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s/m.exec(slice);
|
|
33
|
+
if (!header)
|
|
34
|
+
throw new Error(`Cannot read the Mach-O header in ${file}.`);
|
|
35
|
+
const image = { file, arch: header[1], type: header[2], rpaths: [], loads: [] };
|
|
36
|
+
for (const command of slice.split(/^Load command \d+$/m).slice(1)) {
|
|
37
|
+
const kind = /^\s*cmd (LC_\w+)$/m.exec(command)?.[1];
|
|
38
|
+
if (kind === "LC_DYLD_ENVIRONMENT")
|
|
39
|
+
throw new Error(`LC_DYLD_ENVIRONMENT in ${file}.`);
|
|
40
|
+
if (!kind || !/^LC_(?:RPATH|ID_DYLIB|LOAD_DYLINKER|(?:LOAD(?:_WEAK|_UPWARD)?|LAZY_LOAD|REEXPORT)_DYLIB)$/.test(kind))
|
|
41
|
+
continue;
|
|
42
|
+
const value = /^\s*(?:name|path) (.+) \(offset \d+\)$/m.exec(command)?.[1];
|
|
43
|
+
if (!value)
|
|
44
|
+
throw new Error(`Cannot read ${kind} in ${file}.`);
|
|
45
|
+
if (kind === "LC_RPATH")
|
|
46
|
+
image.rpaths.push(value);
|
|
47
|
+
else if (kind === "LC_ID_DYLIB")
|
|
48
|
+
image.id = value;
|
|
49
|
+
else
|
|
50
|
+
image.loads.push(value);
|
|
51
|
+
}
|
|
52
|
+
return image;
|
|
53
|
+
});
|
|
54
|
+
if (!images.length)
|
|
55
|
+
throw new Error(`Cannot read Mach-O load commands in ${file}.`);
|
|
56
|
+
return images;
|
|
57
|
+
}
|
|
58
|
+
const systemPath = (file) => /^\/(?:usr\/lib|System\/Library)(?:\/|$)/.test(file);
|
|
59
|
+
const cleanRpath = (value) => value.startsWith("@rpath/") && !value.split("/").includes("..");
|
|
60
|
+
export async function checkReleaseLoadPaths(root, app, main, files, execute) {
|
|
61
|
+
const byFile = new Map();
|
|
62
|
+
for (const file of files) {
|
|
63
|
+
byFile.set(file, loadCommands(file, await execute(root, ["otool", "-arch", "all", "-hv", "-l", file], { capture: true })));
|
|
64
|
+
}
|
|
65
|
+
const mainImages = byFile.get(realpathSync(main));
|
|
66
|
+
if (!mainImages?.every(image => image.type === "EXECUTE"))
|
|
67
|
+
throw new Error("Distribution app is missing its Mach-O executable.");
|
|
68
|
+
let sdk;
|
|
69
|
+
const visited = new Map();
|
|
70
|
+
const inside = (file) => file === app || file.startsWith(app + path.sep);
|
|
71
|
+
function expand(value, loader, executable) {
|
|
72
|
+
const token = /^@(loader_path|executable_path)(?:\/|$)/.exec(value);
|
|
73
|
+
if (token) {
|
|
74
|
+
const directory = path.dirname(token[1] === "loader_path" ? loader : executable);
|
|
75
|
+
const resolved = path.resolve(directory, value.slice(token[0].length));
|
|
76
|
+
if (inside(resolved))
|
|
77
|
+
return resolved;
|
|
78
|
+
}
|
|
79
|
+
else if (systemPath(value) && systemPath(path.normalize(value)))
|
|
80
|
+
return path.normalize(value);
|
|
81
|
+
}
|
|
82
|
+
async function inspect(image, loader, executable, inherited, ancestors = new Set()) {
|
|
83
|
+
if (ancestors.has(image))
|
|
84
|
+
return;
|
|
85
|
+
const rpaths = [...new Set([...image.rpaths.map(value => {
|
|
86
|
+
const expanded = expand(value, loader, executable);
|
|
87
|
+
if (!expanded)
|
|
88
|
+
throw new Error(`Invalid LC_RPATH ${value} in ${image.file}.`);
|
|
89
|
+
return expanded;
|
|
90
|
+
}), ...inherited])];
|
|
91
|
+
const context = JSON.stringify([loader, executable, rpaths]);
|
|
92
|
+
let contexts = visited.get(image);
|
|
93
|
+
if (contexts?.has(context))
|
|
94
|
+
return;
|
|
95
|
+
if (!contexts)
|
|
96
|
+
visited.set(image, contexts = new Set());
|
|
97
|
+
contexts.add(context);
|
|
98
|
+
if (image.id && !cleanRpath(image.id) && !expand(image.id, loader, executable)?.startsWith(app + path.sep)) {
|
|
99
|
+
throw new Error(`Invalid LC_ID_DYLIB ${image.id} in ${image.file}.`);
|
|
100
|
+
}
|
|
101
|
+
const chain = new Set([...ancestors, image]);
|
|
102
|
+
for (const load of image.loads) {
|
|
103
|
+
const expanded = expand(load, loader, executable);
|
|
104
|
+
if (expanded && systemPath(expanded))
|
|
105
|
+
continue;
|
|
106
|
+
const candidates = cleanRpath(load) ? rpaths.map(dir => path.join(dir, load.slice("@rpath/".length))) : expanded ? [expanded] : [];
|
|
107
|
+
let resolved = false;
|
|
108
|
+
for (const candidate of candidates) {
|
|
109
|
+
if (systemPath(candidate)) {
|
|
110
|
+
// Swift libraries may live in the dyld cache. The SDK stubs also keep this from accepting a missing bundled library.
|
|
111
|
+
sdk ??= (await execute(root, ["xcrun", "--sdk", "macosx", "--show-sdk-path"], { capture: true })).trim();
|
|
112
|
+
if (existsSync(candidate) || existsSync(path.join(sdk, candidate.replace(/\.dylib$/, ".tbd"))))
|
|
113
|
+
resolved = true;
|
|
114
|
+
}
|
|
115
|
+
else if (existsSync(candidate)) {
|
|
116
|
+
const dependency = byFile.get(realpathSync(candidate))?.find(other => other.arch === image.arch && other.type === "DYLIB");
|
|
117
|
+
if (dependency) {
|
|
118
|
+
await inspect(dependency, candidate, executable, rpaths, chain);
|
|
119
|
+
resolved = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (resolved)
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
if (!resolved)
|
|
126
|
+
throw new Error(`Unresolved load path ${load} in ${image.file} (${image.arch}).`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const images = [...byFile.values()].flat();
|
|
130
|
+
for (const image of images.filter(image => image.type === "EXECUTE")) {
|
|
131
|
+
await inspect(image, image.file, image.file, []);
|
|
132
|
+
}
|
|
133
|
+
// Plug-ins and unused universal slices can still load in the main process's context.
|
|
134
|
+
for (const image of images.filter(image => !visited.has(image))) {
|
|
135
|
+
const host = mainImages.find(other => other.arch === image.arch) ?? mainImages[0];
|
|
136
|
+
const rpaths = host.rpaths.map(value => expand(value, main, main));
|
|
137
|
+
await inspect(image, image.file, main, rpaths);
|
|
138
|
+
}
|
|
139
|
+
}
|