@stacksjs/mobile 0.75.156 → 0.75.158

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/README.md CHANGED
@@ -266,3 +266,57 @@ The phone-native behaviour a screen expects, kept out of STX templates:
266
266
 
267
267
  The framework's `NativeNavBar`, `NativePullToRefresh`, `NativeSegmentedControl`
268
268
  and `NativeSheet` components are built on these.
269
+
270
+ ## Native source ownership
271
+
272
+ Stacks applications author TypeScript and STX. Craft distributes reusable Swift
273
+ shells inside its package, and `buddy build:ios` generates them under
274
+ `storage/framework/mobile/ios`. Generated Swift is ignored by the project's
275
+ generated `.gitignore`, including optional watch and widget sources. Application
276
+ configuration belongs in typed `config/mobile.ts`, rather than generated Swift.
277
+
278
+ The build also generates executable `ci_scripts/ci_post_clone.sh`. Keep that hook,
279
+ Xcode metadata, `craft.config.json`, assets, compiled native bundles and `bun.lock`
280
+ in Git when using Xcode Cloud. The hook installs frozen dependencies and restores
281
+ Swift from the installed Craft package without changing project metadata. It
282
+ installs Bun when unavailable, using `ios.shell.bunVersion` or the Bun version
283
+ that generated the project. Another CI can call `restoreIosShell(output)` after
284
+ installing dependencies. Rebuild metadata and bundles when config or Craft changes.
285
+ Existing apps must remove previously tracked Swift with `git rm --cached`; ignore
286
+ rules do not untrack files already committed.
287
+
288
+ When the app's root `.gitignore` excludes the whole mobile directory, unignore
289
+ `/storage/framework/mobile/`, ignore its children with
290
+ `/storage/framework/mobile/*`, then unignore `/storage/framework/mobile/ios/`.
291
+ Keep build products and `xcuserdata` ignored. This admits cloud metadata while
292
+ the generated iOS `.gitignore` excludes Swift.
293
+
294
+ ## Bun-only test tooling
295
+
296
+ ```ts
297
+ import { prepareIosSimulatorDriver, serializeSimulatorSteps } from '@stacksjs/mobile/testing'
298
+ import mobile from './config/mobile'
299
+
300
+ const { output, projectName } = prepareIosSimulatorDriver(mobile.ios)
301
+ const script = serializeSimulatorSteps([
302
+ { command: 'launch' },
303
+ { command: 'expect', text: 'Today', seconds: 10 },
304
+ ])
305
+ ```
306
+
307
+ The generated test host defaults to `storage/framework/mobile/ios-driver`, targets
308
+ `ios.bundleId`, and derives tab labels from `ios.tabs`. Customize its output,
309
+ project name, bundle prefix, iOS deployment target (17+), and control URL through
310
+ `ios.simulator`. Generate with xcodegen and run with xcodebuild against an installed
311
+ app. Serve the serialized journey at `/script` and accept `/note` and `/save` on
312
+ the control server. `TEST_RUNNER_CRAFT_TEST_CONTROL` overrides the URL per run.
313
+ Legacy line-based scripts remain supported; failed checks also fail XCTest.
314
+
315
+ `createNativeMutationValidator()` validates captured STX messages against the
316
+ package's real Swift mutation host on macOS. It returns a disposable validator
317
+ whose `validate(messages)` reports `exitCode`, `stdout` and `stderr`.
318
+
319
+ The `/testing` entrypoint is for Bun build/test tools and is excluded from browser
320
+ exports. The ordinary `@stacksjs/mobile` entrypoint stays browser-safe. Extend
321
+ Craft's shared host and typed APIs for new platform features instead of editing
322
+ generated sources.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Bundled TypeScript declarations
3
+ * Generated from 1 source files
4
+ */
5
+
6
+ import { IosMobileConfig } from '@stacksjs/types';
7
+
8
+ // From: src/testing.ts
9
+ /** Bun-only build/test entrypoint. The browser runtime never imports the iOS builder. */
10
+ declare function prepareIosSimulatorDriver(config: IosMobileConfig, root?: string): { output: string, projectName: string };
11
+
12
+ export { prepareIosSimulatorDriver };
13
+ export { NativeMutationValidator } from 'craft-native/ios';
14
+ export { NativeValidationResult } from 'craft-native/ios';
15
+ export { SimulatorStep } from 'craft-native/ios';
16
+ export { createNativeMutationValidator } from 'craft-native/ios';
17
+ export { restoreShell as restoreIosShell } from 'craft-native/ios';
18
+ export { serializeSimulatorSteps } from 'craft-native/ios';
@@ -0,0 +1,24 @@
1
+ // @bun
2
+ // src/testing.ts
3
+ import { resolve } from "path";
4
+ import { initSimulatorDriver } from "craft-native/ios";
5
+ import { createNativeMutationValidator, restoreShell, serializeSimulatorSteps } from "craft-native/ios";
6
+ function prepareIosSimulatorDriver(config, root = process.cwd()) {
7
+ const simulator = config.simulator ?? {};
8
+ const output = resolve(root, simulator.output ?? "storage/framework/mobile/ios-driver");
9
+ const projectName = simulator.projectName ?? "CraftDriver";
10
+ initSimulatorDriver({
11
+ ...simulator,
12
+ output,
13
+ projectName,
14
+ bundleId: config.bundleId,
15
+ tabs: config.tabs?.map((tab) => tab.title)
16
+ });
17
+ return { output, projectName };
18
+ }
19
+ export {
20
+ createNativeMutationValidator,
21
+ prepareIosSimulatorDriver,
22
+ restoreShell as restoreIosShell,
23
+ serializeSimulatorSteps
24
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/mobile",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.156",
5
+ "version": "0.75.158",
6
6
  "description": "Craft-powered native mobile runtime for Stacks and STX applications",
7
7
  "author": "Chris Breuer",
8
8
  "license": "MIT",
@@ -18,6 +18,12 @@
18
18
  "bun": "./dist/index.js",
19
19
  "import": "./dist/index.js",
20
20
  "default": "./dist/index.js"
21
+ },
22
+ "./testing": {
23
+ "browser": null,
24
+ "types": "./dist/testing.d.ts",
25
+ "bun": "./dist/testing.js",
26
+ "import": "./dist/testing.js"
21
27
  }
22
28
  },
23
29
  "module": "dist/index.js",
@@ -32,10 +38,11 @@
32
38
  "test": "bun test"
33
39
  },
34
40
  "dependencies": {
35
- "craft-native": ">=0.0.152"
41
+ "@stacksjs/types": "0.75.158",
42
+ "craft-native": ">=0.0.158"
36
43
  },
37
44
  "devDependencies": {
38
- "@stacksjs/build": "0.75.156",
45
+ "@stacksjs/build": "0.75.158",
39
46
  "better-dx": "^0.2.24"
40
47
  }
41
48
  }