@stacksjs/mobile 0.75.155 → 0.75.157
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 +48 -0
- package/dist/testing.d.ts +18 -0
- package/dist/testing.js +24 -0
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -266,3 +266,51 @@ 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
|
+
## Bun-only test tooling
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
import { prepareIosSimulatorDriver, serializeSimulatorSteps } from '@stacksjs/mobile/testing'
|
|
292
|
+
import mobile from './config/mobile'
|
|
293
|
+
|
|
294
|
+
const { output, projectName } = prepareIosSimulatorDriver(mobile.ios)
|
|
295
|
+
const script = serializeSimulatorSteps([
|
|
296
|
+
{ command: 'launch' },
|
|
297
|
+
{ command: 'expect', text: 'Today', seconds: 10 },
|
|
298
|
+
])
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
The generated test host defaults to `storage/framework/mobile/ios-driver`, targets
|
|
302
|
+
`ios.bundleId`, and derives tab labels from `ios.tabs`. Customize its output,
|
|
303
|
+
project name, bundle prefix, iOS deployment target (17+), and control URL through
|
|
304
|
+
`ios.simulator`. Generate with xcodegen and run with xcodebuild against an installed
|
|
305
|
+
app. Serve the serialized journey at `/script` and accept `/note` and `/save` on
|
|
306
|
+
the control server. `TEST_RUNNER_CRAFT_TEST_CONTROL` overrides the URL per run.
|
|
307
|
+
Legacy line-based scripts remain supported; failed checks also fail XCTest.
|
|
308
|
+
|
|
309
|
+
`createNativeMutationValidator()` validates captured STX messages against the
|
|
310
|
+
package's real Swift mutation host on macOS. It returns a disposable validator
|
|
311
|
+
whose `validate(messages)` reports `exitCode`, `stdout` and `stderr`.
|
|
312
|
+
|
|
313
|
+
The `/testing` entrypoint is for Bun build/test tools and is excluded from browser
|
|
314
|
+
exports. The ordinary `@stacksjs/mobile` entrypoint stays browser-safe. Extend
|
|
315
|
+
Craft's shared host and typed APIs for new platform features instead of editing
|
|
316
|
+
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';
|
package/dist/testing.js
ADDED
|
@@ -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.
|
|
5
|
+
"version": "0.75.157",
|
|
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
|
-
"
|
|
41
|
+
"@stacksjs/types": "0.75.157",
|
|
42
|
+
"craft-native": ">=0.0.155"
|
|
36
43
|
},
|
|
37
44
|
"devDependencies": {
|
|
38
|
-
"@stacksjs/build": "0.75.
|
|
45
|
+
"@stacksjs/build": "0.75.157",
|
|
39
46
|
"better-dx": "^0.2.24"
|
|
40
47
|
}
|
|
41
48
|
}
|