@lingxia/skill 0.8.0

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 (37) hide show
  1. package/README.md +95 -0
  2. package/bin/install.mjs +247 -0
  3. package/package.json +49 -0
  4. package/scripts/sync.mjs +69 -0
  5. package/skill/SKILL.md +334 -0
  6. package/skill/app/apple-sdk.md +312 -0
  7. package/skill/app/applinks.md +289 -0
  8. package/skill/app/project.md +760 -0
  9. package/skill/cli/lxdev.md +195 -0
  10. package/skill/cli/reference.md +481 -0
  11. package/skill/examples/hello-host-js/README.md +25 -0
  12. package/skill/examples/hello-host-js/home/lxapp.json +12 -0
  13. package/skill/examples/hello-host-js/home/pages/home/index.json +4 -0
  14. package/skill/examples/hello-host-js/home/pages/home/index.ts +14 -0
  15. package/skill/examples/hello-host-js/home/pages/home/index.tsx +15 -0
  16. package/skill/examples/hello-host-js/lingxia.yaml +39 -0
  17. package/skill/examples/hello-host-rust/Cargo.toml +15 -0
  18. package/skill/examples/hello-host-rust/README.md +44 -0
  19. package/skill/examples/hello-host-rust/home/lxapp.json +13 -0
  20. package/skill/examples/hello-host-rust/home/pages/home/index.html +46 -0
  21. package/skill/examples/hello-host-rust/home/pages/home/index.json +4 -0
  22. package/skill/examples/hello-host-rust/lingxia.yaml +32 -0
  23. package/skill/examples/hello-host-rust/src/lib.rs +58 -0
  24. package/skill/examples/hello-lxapp/README.md +29 -0
  25. package/skill/examples/hello-lxapp/lxapp.config.ts +8 -0
  26. package/skill/examples/hello-lxapp/lxapp.json +14 -0
  27. package/skill/examples/hello-lxapp/package.json +14 -0
  28. package/skill/examples/hello-lxapp/pages/home/index.json +4 -0
  29. package/skill/examples/hello-lxapp/pages/home/index.ts +35 -0
  30. package/skill/examples/hello-lxapp/pages/home/index.tsx +34 -0
  31. package/skill/lxapp/bridge.md +654 -0
  32. package/skill/lxapp/components.md +375 -0
  33. package/skill/lxapp/guide.md +675 -0
  34. package/skill/lxapp/lx-api.md +481 -0
  35. package/skill/native/development.md +414 -0
  36. package/skill/reference/file-lifecycle.md +325 -0
  37. package/skill/skill-manifest.json +6 -0
@@ -0,0 +1,289 @@
1
+ # LingXia AppLinks
2
+
3
+ LingXia AppLinks are verified HTTPS URLs that open the host app and route to a
4
+ specific lxapp page. The host app declares which domains it accepts; the URL
5
+ path and query define the action to run.
6
+
7
+ The same URL rule is used everywhere the SDK receives a link:
8
+
9
+ - OS App Links or Universal Links
10
+ - browser handoff into the app
11
+ - push notification links
12
+ - QR code and barcode scan results
13
+
14
+ ## URL Structure
15
+
16
+ A LingXia AppLink is an HTTPS URL split into `scheme`, `host`, `path`, and
17
+ `query`:
18
+
19
+ ```text
20
+ https://<host>/lxapp/open?appId=<appId>&path=<pagePath>&envVersion=<release|preview|develop>&<pageQuery>
21
+ ```
22
+
23
+ | Field | Value | Description |
24
+ |---|---|---|
25
+ | `scheme` | `https` | Required. Platform verified links are HTTPS URLs. |
26
+ | `host` | A host from `lingxia.yaml` `appLinks.hosts` | The OS uses this host to verify and deliver the link to the app. |
27
+ | `path` | `/lxapp/open` | `lxapp` is the LingXia namespace. `open` is the action that opens a target lxapp. |
28
+ | `query` | `appId`, `path`, `envVersion`, plus page params | Routing params select the target. Other params are forwarded to the page. |
29
+
30
+ Examples:
31
+
32
+ ```text
33
+ https://app.example.com/lxapp/open?appId=shop
34
+ https://app.example.com/lxapp/open?appId=shop&path=pages%2Fdetail%2Findex.html&id=42
35
+ https://app.example.com/lxapp/open?appId=shop&path=pages%2Fdetail%2Findex.html&envVersion=preview&id=42
36
+ ```
37
+
38
+ The explicit `open` action keeps the `/lxapp` namespace extensible for future
39
+ actions.
40
+
41
+ ## Routing Parameters
42
+
43
+ | Parameter | Required | Description |
44
+ |---|---:|---|
45
+ | `appId` | Yes | Target lxapp id. |
46
+ | `path` | No | Target page path inside the lxapp. If omitted, the lxapp initial route is used. |
47
+ | `envVersion` | No | Target release channel. Matches `navigateToLxApp`. |
48
+
49
+ All query keys and values should be URL encoded. Routing parameters are consumed
50
+ by the SDK and are not forwarded to the page. Other query parameters are
51
+ forwarded to the target page.
52
+
53
+ Release channel mapping:
54
+
55
+ | Link value | Runtime release type |
56
+ |---|---|
57
+ | `envVersion=release` | `release` |
58
+ | `envVersion=preview` | `preview` |
59
+ | `envVersion=develop` | `developer` |
60
+
61
+ No aliases are accepted. Invalid `envVersion` values are rejected.
62
+
63
+ Example:
64
+
65
+ ```text
66
+ https://app.example.com/lxapp/open?appId=shop&path=pages%2Fdetail%2Findex.html&envVersion=preview&id=42
67
+ ```
68
+
69
+ opens:
70
+
71
+ ```text
72
+ appId: shop
73
+ release: preview
74
+ path: pages/detail/index.html
75
+ page query: id=42
76
+ scene: AppLink
77
+ ```
78
+
79
+ ## Host Configuration
80
+
81
+ The host is configured in `lingxia.yaml`:
82
+
83
+ ```yaml
84
+ appLinks:
85
+ hosts:
86
+ - app.example.com
87
+ ```
88
+
89
+ This config does not define routing rules. It only declares which verified hosts
90
+ the app accepts. If no hosts are configured, AppLinks are ignored.
91
+
92
+ `lingxia build` writes the configured hosts into generated runtime `app.json` and
93
+ syncs the native platform project metadata.
94
+
95
+ `lingxia new -t native-app` does not enable AppLinks by default. Add production
96
+ hosts explicitly after your verification files are ready.
97
+
98
+ ## Well-Known Verification Files
99
+
100
+ Every configured host must serve the platform verification files needed by the
101
+ platforms you ship. For `app.example.com`, serve these from the same HTTPS host:
102
+
103
+ ```text
104
+ https://app.example.com/.well-known/apple-app-site-association
105
+ https://app.example.com/.well-known/assetlinks.json
106
+ https://app.example.com/.well-known/applinking.json
107
+ ```
108
+
109
+ Only serve the files required by your target platforms.
110
+
111
+ ### Apple
112
+
113
+ Entitlement:
114
+
115
+ ```xml
116
+ <key>com.apple.developer.associated-domains</key>
117
+ <array>
118
+ <string>applinks:app.example.com</string>
119
+ </array>
120
+ ```
121
+
122
+ Verification URL:
123
+
124
+ ```text
125
+ https://app.example.com/.well-known/apple-app-site-association
126
+ ```
127
+
128
+ Example response:
129
+
130
+ ```json
131
+ {
132
+ "applinks": {
133
+ "apps": [],
134
+ "details": [
135
+ {
136
+ "appID": "TEAM_ID.com.example.app",
137
+ "paths": ["/lxapp/*"]
138
+ }
139
+ ]
140
+ }
141
+ }
142
+ ```
143
+
144
+ Requirements:
145
+
146
+ - No `.json` suffix in the URL.
147
+ - No redirects.
148
+ - Public HTTPS.
149
+ - `appID` is Apple Team ID plus bundle id.
150
+
151
+ ### Android
152
+
153
+ Intent filter:
154
+
155
+ ```xml
156
+ <intent-filter android:autoVerify="true">
157
+ <action android:name="android.intent.action.VIEW" />
158
+ <category android:name="android.intent.category.DEFAULT" />
159
+ <category android:name="android.intent.category.BROWSABLE" />
160
+ <data android:scheme="https" android:host="app.example.com" />
161
+ </intent-filter>
162
+ ```
163
+
164
+ Verification URL:
165
+
166
+ ```text
167
+ https://app.example.com/.well-known/assetlinks.json
168
+ ```
169
+
170
+ Example response:
171
+
172
+ ```json
173
+ [
174
+ {
175
+ "relation": ["delegate_permission/common.handle_all_urls"],
176
+ "target": {
177
+ "namespace": "android_app",
178
+ "package_name": "com.example.app",
179
+ "sha256_cert_fingerprints": [
180
+ "SHA256_CERT_FINGERPRINT"
181
+ ]
182
+ }
183
+ }
184
+ ]
185
+ ```
186
+
187
+ Include every signing certificate used by debug, internal, and release builds.
188
+
189
+ ### HarmonyOS
190
+
191
+ Browsable skill:
192
+
193
+ ```json5
194
+ {
195
+ "entities": ["entity.system.browsable"],
196
+ "actions": ["ohos.want.action.viewData"],
197
+ "uris": [
198
+ {
199
+ "scheme": "https",
200
+ "host": "app.example.com"
201
+ }
202
+ ]
203
+ }
204
+ ```
205
+
206
+ Verification URL:
207
+
208
+ ```text
209
+ https://app.example.com/.well-known/applinking.json
210
+ ```
211
+
212
+ Example response:
213
+
214
+ ```json
215
+ {
216
+ "applinking": {
217
+ "apps": [
218
+ {
219
+ "appIdentifier": "HARMONY_APP_ID"
220
+ }
221
+ ]
222
+ }
223
+ }
224
+ ```
225
+
226
+ ## Runtime Behavior
227
+
228
+ When the SDK receives a link, it routes the URL through the shared AppLink
229
+ handler.
230
+
231
+ The handler:
232
+
233
+ 1. Accepts only `https://`.
234
+ 2. Checks the host against `appLinks.hosts`.
235
+ 3. Parses `/lxapp/open` and its query parameters.
236
+ 4. Resolves `envVersion`.
237
+ 5. Ensures the requested lxapp release is installed and compatible.
238
+ 6. Opens the target lxapp with `scene: AppLink`.
239
+
240
+ Return codes:
241
+
242
+ | Code | Meaning |
243
+ |---:|---|
244
+ | `1` | Link was accepted and handling was scheduled. |
245
+ | `0` | Link was ignored. |
246
+ | `-1` | Link looked like a LingXia link but was invalid. |
247
+
248
+ Unknown paths are ignored. Invalid LingXia URLs, such as bad percent encoding or
249
+ a missing `appId`, are rejected.
250
+
251
+ When `scanCode` sees a supported AppLink, the SDK forwards it to the shared
252
+ handler and closes the scanner. The scan result is still returned to the caller,
253
+ so existing `scanCode` callers do not hang.
254
+
255
+ ## Testing
256
+
257
+ Android:
258
+
259
+ ```bash
260
+ adb shell am start -a android.intent.action.VIEW \
261
+ -d "https://app.example.com/lxapp/open?appId=shop&path=pages%2Fdetail%2Findex.html&envVersion=preview&id=42" \
262
+ com.example.app
263
+
264
+ adb shell pm get-app-links com.example.app
265
+ ```
266
+
267
+ iOS/macOS:
268
+
269
+ ```bash
270
+ curl https://app.example.com/.well-known/apple-app-site-association
271
+ curl https://app-site-association.cdn-apple.com/a/v1/app.example.com
272
+ ```
273
+
274
+ HarmonyOS:
275
+
276
+ ```bash
277
+ hdc shell aa start -A ohos.want.action.viewData \
278
+ -U "https://app.example.com/lxapp/open?appId=shop&path=pages%2Fdetail%2Findex.html&envVersion=develop&id=42"
279
+ ```
280
+
281
+ ## Checklist
282
+
283
+ - `lingxia.yaml` has every production host under `appLinks.hosts`.
284
+ - Each host serves the required `.well-known` verification files.
285
+ - Apple entitlements use `applinks:<host>`.
286
+ - Android manifest has verified HTTPS intent filters for each host.
287
+ - Harmony module skill has HTTPS URI entries for each host.
288
+ - AppLink URLs use `/lxapp/open` with `appId` and optional `path` query parameters.
289
+ - Page parameters are URL encoded and do not rely on `envVersion` being forwarded.