@skillbuilder/miniapp-simulator 0.2.1 → 0.2.2

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.
@@ -90,9 +90,10 @@ JSAPI 配置。`businessLine` 缺失或为空时薄 SDK 会拒绝创建实例。
90
90
  远端配置的作用规则:
91
91
 
92
92
  - `unsupported` 只调整明确不支持或没有 handler 的 JSAPI 提示,不影响已有实现。
93
- - API 名称可精确覆盖对应实现,例如 `postNote`;支持 `{ toast: "文案" }` 或
94
- `{ alert: "文案" }`,两者同时存在时 Alert 优先。
95
- - 精确配置只展示提示并成功返回 `{}`,不会生成 API 专属返回字段。
93
+ - API 名称可精确覆盖对应实现,例如 `postNote`;支持 `{ data: {...} }`、
94
+ `{ toast: "文案" }` 或 `{ alert: "文案" }`,同时存在时依次按 data、Alert、Toast 优先。
95
+ - `data` 必须是 JSON 对象,允许 `{}`;直接作为成功业务数据返回,Bridge 包装为 `{ code: 0, data }`。
96
+ 配置 data 时不展示提示;仅配置 Alert/Toast 时成功返回 `{}`。`unsupported` 只支持提示配置。
96
97
  - 优先级为:宿主 `hostApi` → 单 API 远端配置 → `unsupported` → Runtime 默认行为。
97
98
  - 配置在实例连接 Runtime 时读取;配置更新后需要新建模拟器实例才能取得新值。
98
99
 
@@ -101,6 +102,10 @@ JSAPI 配置。`businessLine` 缺失或为空时薄 SDK 会拒绝创建实例。
101
102
  短震动缺少 `type` 或取值非法时返回 `10001`。两个 API 均在触发后立即返回成功,不等待动画结束;
102
103
  同一模拟器 100ms 内的重复震动请求合并处理,仍正常回调。未支持 API 的统一提示不影响这两个内置实现。
103
104
 
105
+ 模拟器内置 `startGyroscope()`、`stopGyroscope()` 空实现,成功返回 `{}`,不采集或推送陀螺仪数据。
106
+ `getFollowStatus()` 默认成功返回 `{ follow_status: 0 }`(未关注)。这三个 API 不进入 unsupported
107
+ 兜底,可通过单 API Apollo 配置或宿主 `hostApi` 覆盖返回值。
108
+
104
109
  ## 3. 加载小应用
105
110
 
106
111
  ### 加载 ZIP
@@ -1,4 +1,4 @@
1
- import { c as he, r as ye, v as we, o as ve, e as ge } from "./index-DI2oETZ_.mjs";
1
+ import { c as he, r as ye, v as we, o as ve, e as ge } from "./index-D5AYVv8s.mjs";
2
2
  const K = {
3
3
  report() {
4
4
  },
@@ -1,4 +1,4 @@
1
- const E = "0.2.1", _ = /* @__PURE__ */ new Set();
1
+ const E = "0.2.2", _ = /* @__PURE__ */ new Set();
2
2
  function M(e, n) {
3
3
  const t = () => {
4
4
  let s = !document.hidden && e.isConnected;
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ var tr = (r) => {
3
3
  };
4
4
  var dt = (r, e, t) => e.has(r) || tr("Cannot " + t);
5
5
  var A = (r, e, t) => (dt(r, e, "read from private field"), t ? t.call(r) : e.get(r)), S = (r, e, t) => e.has(r) ? tr("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), V = (r, e, t, n) => (dt(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t), T = (r, e, t) => (dt(r, e, "access private method"), t);
6
- import { a as rr, M as v, b as E, i as Gn, d as Hn, e as Qn, f as zn, g as Jn, v as jn } from "./index-DI2oETZ_.mjs";
6
+ import { a as rr, M as v, b as E, i as Gn, d as Hn, e as Qn, f as zn, g as Jn, v as jn } from "./index-D5AYVv8s.mjs";
7
7
  import { B as _n, M as he } from "./options-B34ipLmF.mjs";
8
8
  const $n = "minitool-worker-runtime", es = "0.1.0", ts = 1, rs = "default-src 'none'; script-src 'none'; connect-src 'none'; worker-src 'none'; child-src 'none'", Mt = {
9
9
  name: $n,
@@ -7806,6 +7806,10 @@ function ol(r) {
7806
7806
  return {};
7807
7807
  }
7808
7808
  },
7809
+ getFollowStatus: {
7810
+ // 契约:0 表示未关注;允许 Apollo 或宿主覆盖 mock 结果。
7811
+ handler: () => ({ follow_status: 0 })
7812
+ },
7809
7813
  vibrateLong: {
7810
7814
  handler: () => (r.vibrate("long"), {})
7811
7815
  },
@@ -8150,6 +8154,13 @@ function Rl(r) {
8150
8154
  getWindowInfo: {
8151
8155
  handler: () => Tl(r.viewport),
8152
8156
  hostOverride: "forbid"
8157
+ },
8158
+ // PC 预览仅确认调用成功,不采集或推送陀螺仪数据。
8159
+ startGyroscope: {
8160
+ handler: () => ({})
8161
+ },
8162
+ stopGyroscope: {
8163
+ handler: () => ({})
8153
8164
  }
8154
8165
  }
8155
8166
  };
@@ -1,6 +1,6 @@
1
- import { R as r, a as O, c as e } from "./client-BlQ9j4FW.mjs";
1
+ import { R as r, a as O, c as e } from "./client-_vNHVHSm.mjs";
2
2
  import { B as s, M as _ } from "./options-B34ipLmF.mjs";
3
- import { M } from "./index-DI2oETZ_.mjs";
3
+ import { M } from "./index-D5AYVv8s.mjs";
4
4
  export {
5
5
  s as BusinessLine,
6
6
  _ as MINIAPP_SCREENSHOT_ERROR_CODE,
@@ -1,7 +1,11 @@
1
1
  import type { MiniAppHostApiEntry, MiniAppUnsupportedJsApiBehavior } from "../types";
2
2
  type RemoteJsApiNotice = MiniAppUnsupportedJsApiBehavior;
3
- export type RemoteJsApiConfig = Record<string, RemoteJsApiNotice>;
4
- /** Server 透传通用 JSON;具体 JSAPI 提示语义只在 Runtime 解析。 */
3
+ type RemoteJsApiEntry = RemoteJsApiNotice | {
4
+ type: "mock";
5
+ data: Record<string, unknown>;
6
+ };
7
+ export type RemoteJsApiConfig = Record<string, RemoteJsApiEntry>;
8
+ /** Server 透传通用 JSON;具体 JSAPI 提示和 mock 语义只在 Runtime 解析。 */
5
9
  export declare function parseRemoteJsApiConfig(input: unknown): RemoteJsApiConfig | undefined;
6
10
  export declare function getUnsupportedJsApiBehavior(config?: RemoteJsApiConfig): MiniAppUnsupportedJsApiBehavior | undefined;
7
11
  /** `unsupported` 是统一兜底,其余 key 是可覆盖任意 API 的精确配置。 */
package/lib/workbench.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as Mn } from "./client-BlQ9j4FW.mjs";
1
+ import { c as Mn } from "./client-_vNHVHSm.mjs";
2
2
  function Sn(a, i) {
3
3
  const e = /* @__PURE__ */ new Map();
4
4
  let v = 0, l = !1, w, b, L, m, u;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillbuilder/miniapp-simulator",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Designable Miniapp Simulator - 技术栈无关的小应用 PC 预览与审核模拟器 SDK",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",