@craft-native/ios 0.0.91 → 0.0.94

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.
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Craft iOS Builder
3
+ *
4
+ * Generates native iOS apps from web content using WKWebView.
5
+ */
6
+ export interface CraftConfig {
7
+ appName: string;
8
+ bundleId: string;
9
+ version?: string;
10
+ buildNumber?: string;
11
+ darkMode?: boolean;
12
+ backgroundColor?: string;
13
+ enableSpeechRecognition?: boolean;
14
+ enableHaptics?: boolean;
15
+ enableShare?: boolean;
16
+ enableCamera?: boolean;
17
+ enableBiometric?: boolean;
18
+ enablePushNotifications?: boolean;
19
+ enableSecureStorage?: boolean;
20
+ enableGeolocation?: boolean;
21
+ enableClipboard?: boolean;
22
+ enableContacts?: boolean;
23
+ enableCalendar?: boolean;
24
+ enableLocalNotifications?: boolean;
25
+ enableInAppPurchase?: boolean;
26
+ enableKeepAwake?: boolean;
27
+ enableOrientationLock?: boolean;
28
+ enableDeepLinks?: boolean;
29
+ enableQRScanner?: boolean;
30
+ enableFilePicker?: boolean;
31
+ enableFileDownload?: boolean;
32
+ enableSocialAuth?: boolean;
33
+ enableAudioRecording?: boolean;
34
+ enableVideoRecording?: boolean;
35
+ enableMotionSensors?: boolean;
36
+ enableLocalDatabase?: boolean;
37
+ enableBluetooth?: boolean;
38
+ enableNFC?: boolean;
39
+ enableHealthKit?: boolean;
40
+ enableLiveActivities?: boolean;
41
+ enableWatchApp?: boolean;
42
+ enableBackgroundLocation?: boolean;
43
+ enableBackgroundTasks?: boolean;
44
+ enableScreenCapture?: boolean;
45
+ enablePDFViewer?: boolean;
46
+ enableAR?: boolean;
47
+ enableMLKit?: boolean;
48
+ devServerURL?: string;
49
+ iosVersion?: string;
50
+ watchosVersion?: string;
51
+ teamId?: string;
52
+ urlSchemes?: string[];
53
+ trustedOrigins?: string[];
54
+ associatedDomains?: string[];
55
+ appGroups?: string[];
56
+ appIconPath?: string;
57
+ privacy?: CraftPrivacyManifest;
58
+ orientations?: Array<'portrait' | 'landscape-left' | 'landscape-right' | 'portrait-upside-down'>;
59
+ deviceFamilies?: Array<'iphone' | 'ipad'>;
60
+ }
61
+ export interface CraftPrivacyDataType {
62
+ type: string;
63
+ linked?: boolean;
64
+ tracking?: boolean;
65
+ purposes: string[];
66
+ }
67
+ export interface CraftPrivacyAccessedApiType {
68
+ type: string;
69
+ reasons: string[];
70
+ }
71
+ export interface CraftPrivacyManifest {
72
+ tracking?: boolean;
73
+ trackingDomains?: string[];
74
+ collectedDataTypes?: CraftPrivacyDataType[];
75
+ accessedApiTypes?: CraftPrivacyAccessedApiType[];
76
+ }
77
+ export interface InitOptions {
78
+ name: string;
79
+ bundleId?: string;
80
+ teamId?: string;
81
+ output: string;
82
+ config?: Partial<CraftConfig>;
83
+ /**
84
+ * Where the Zig runtime archives live, overriding `CRAFT_IOS_RUNTIME`.
85
+ *
86
+ * `null` means "no runtime, whatever the environment says" — the shape
87
+ * `AppConfig.craftPath` has for `CRAFT_BIN`, and the reason it exists here
88
+ * is the same: a caller that does not opt in should not be steered by an
89
+ * ambient variable. Without it this package's own tests inherited whatever
90
+ * the developer's shell exported, and went from 12 passing to 8 passing and
91
+ * 4 failing when `CRAFT_IOS_RUNTIME` happened to be set.
92
+ *
93
+ * Omitted (`undefined`) keeps the environment lookup, which is what the
94
+ * monorepo dev loop uses.
95
+ */
96
+ runtimeDir?: string | null;
97
+ }
98
+ export interface BuildOptions {
99
+ htmlPath?: string;
100
+ devServer?: string;
101
+ output: string;
102
+ generateProject?: boolean;
103
+ /**
104
+ * Where to re-read the Zig runtime archives from, overriding
105
+ * `CRAFT_IOS_RUNTIME`. Same meaning as `InitOptions.runtimeDir`; `null`
106
+ * leaves whatever `init` installed exactly as it is.
107
+ */
108
+ runtimeDir?: string | null;
109
+ }
110
+ export interface OpenOptions {
111
+ output: string;
112
+ }
113
+ export interface RunOptions {
114
+ simulator: boolean;
115
+ output: string;
116
+ }
117
+ export declare function renderDeviceFamilies(config: CraftConfig): string;
118
+ export declare function renderUsageDescriptions(config: CraftConfig): string;
119
+ export declare function renderOrientations(config: CraftConfig): string;
120
+ export declare function renderUrlTypes(config: CraftConfig): string;
121
+ export declare function renderBackgroundModes(config: CraftConfig): string;
122
+ export declare function renderEntitlements(config: CraftConfig): string;
123
+ export declare function renderWatchEntitlements(config: CraftConfig): string;
124
+ /**
125
+ * The build settings that link the Zig runtime into the app target.
126
+ *
127
+ * Two things are load-bearing here:
128
+ *
129
+ * `LIBRARY_SEARCH_PATHS` is written twice, once per SDK, so `-lcraft-ios`
130
+ * resolves to the device archive for a device build and the simulator archive
131
+ * for a simulator one without the flag itself changing. Xcode applies the
132
+ * `[sdk=...]` condition; xcodegen passes these keys through verbatim.
133
+ *
134
+ * The four `-u` flags are the reason anything works at all. Nothing in the
135
+ * Swift source *references* these symbols — `CraftZigRuntime` and
136
+ * `CraftSwiftShim` both find them with `dlsym` at runtime — so a static
137
+ * archive contributes no objects for them and the linker drops the entire
138
+ * runtime as unreachable. `-u` names them as undefined so the objects are
139
+ * pulled in and the symbols end up in the binary for `dlsym` to find.
140
+ *
141
+ * `-u` rather than `-force_load`: forcing the whole archive would pull in
142
+ * every object whether reachable or not, and these four entry points already
143
+ * reach everything the bridge actually uses.
144
+ */
145
+ export declare function renderRuntimeSettings(): string;
146
+ export declare function renderPrivacyManifest(config: CraftConfig): string;
147
+ /** Replace the bundled web application atomically so removed assets cannot linger. */
148
+ export declare function syncWebAssets(source: string, output: string): void;
149
+ /**
150
+ * Initialize a new iOS project
151
+ */
152
+ /**
153
+ * Where the Zig runtime archives live, or null when this build has none.
154
+ *
155
+ * `CRAFT_IOS_RUNTIME` points at a directory holding the archives `zig build
156
+ * build-ios-all` produces. It is opt-in and there is deliberately no fallback
157
+ * search: a generated project with no runtime is the shipping default today,
158
+ * and it works — `CraftZigRuntime.offer` is a `dlsym` miss, every action
159
+ * answers false, and the Swift switch serves the whole surface exactly as it
160
+ * always has. Guessing at a path would turn "no runtime" into "some runtime,
161
+ * from somewhere", which is the failure mode the pantry contract exists to
162
+ * rule out.
163
+ *
164
+ * This is the same shape as `CRAFT_BIN`: an explicit override for the monorepo
165
+ * dev loop, not a lookup path. Shipping the runtime to real apps means putting
166
+ * these archives in the pantry package beside the `craft` binary, which is a
167
+ * distribution decision this function does not make.
168
+ *
169
+ * `override` is what `InitOptions.runtimeDir` passes: a path to use instead of
170
+ * the variable, or `null` to declare there is no runtime regardless of what the
171
+ * environment says. `undefined` falls through to `CRAFT_IOS_RUNTIME`.
172
+ */
173
+ export declare function resolveRuntimeDir(override?: string | null): string | null;
174
+ /**
175
+ * Copy the Zig archives into the generated project as `Runtime/<sdk>/libcraft-ios.a`.
176
+ *
177
+ * One name for both SDKs, in two directories, because that is what lets a
178
+ * single `-lcraft-ios` in OTHER_LDFLAGS work for device and simulator builds:
179
+ * Xcode picks the directory by SDK and the flag never changes.
180
+ *
181
+ * Returns true when a runtime was installed.
182
+ */
183
+ export declare function installRuntime(output: string, runtimeDir: string): Promise<boolean>;
184
+ export declare function init(options: InitOptions): Promise<void>;
185
+ /**
186
+ * Build web assets and generate Xcode project
187
+ */
188
+ export declare function build(options: BuildOptions): Promise<void>;
189
+ /**
190
+ * Open Xcode project
191
+ */
192
+ export declare function open(options: OpenOptions): Promise<void>;
193
+ /**
194
+ * Build and run on simulator or device
195
+ */
196
+ /** One bootable simulator, as `simctl list` describes it. */
197
+ export interface SimulatorDevice {
198
+ name: string;
199
+ udid: string;
200
+ state: string;
201
+ runtime: string;
202
+ }
203
+ /**
204
+ * Every available *iOS* simulator, newest runtime first, iPhones before iPads.
205
+ *
206
+ * Exported because the choice is worth testing without a simulator present -
207
+ * `pickSimulator` is the policy and this is the data it reads.
208
+ */
209
+ export declare function orderSimulators(devices: SimulatorDevice[]): SimulatorDevice[];
210
+ /**
211
+ * The device to run on.
212
+ *
213
+ * A booted one first - if the developer already has a simulator open, that is
214
+ * the one they are looking at - then the newest iPhone.
215
+ *
216
+ * This used to be the string `iPhone 15`, hard-coded into the `-destination`
217
+ * argument. On a machine whose Xcode ships iPhone 17 and no iPhone 15, that is
218
+ * not a fallback, it is `xcodebuild: error: Unable to find a device named
219
+ * 'iPhone 15'` - the command fails for a reason that has nothing to do with the
220
+ * app being built, and the fix is invisible from the error.
221
+ */
222
+ export declare function pickSimulator(): Promise<SimulatorDevice | null>;
223
+ /**
224
+ * Boot it, and wait until it can actually do something.
225
+ *
226
+ * `simctl boot` returns as soon as the device starts booting, and a device
227
+ * that reports `Booted` is minutes away from being able to install anything on
228
+ * a cold runtime. `bootstatus` is the wait, and skipping it is why a first run
229
+ * on a fresh machine fails where the second succeeds.
230
+ */
231
+ export declare function bootSimulator(device: SimulatorDevice): Promise<void>;
232
+ /**
233
+ * Bring the Simulator window to the front, if it can be found.
234
+ *
235
+ * `open -a Simulator` resolves through LaunchServices, and LaunchServices only
236
+ * knows the name if a Simulator.app has been registered under it - which is not
237
+ * true on a machine running Xcode-beta, where the answer is `Unable to find
238
+ * application named 'Simulator'`. The app is always at a known path under the
239
+ * *selected* developer directory, so that is tried first.
240
+ *
241
+ * Never throws. The window is a convenience: the app is installed and launched
242
+ * either way, and failing the whole run because a window did not come to the
243
+ * front would be reporting a cosmetic problem as a build failure.
244
+ */
245
+ export declare function showSimulator(): Promise<void>;
246
+ export declare function run(options: RunOptions): Promise<void>;