@ateam-ai-mobile/plugin-runtime 0.1.7 → 0.1.8

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/dist/index.mjs CHANGED
@@ -41,6 +41,7 @@ import {
41
41
  ensureDeviceToolsLoaded,
42
42
  gateDeviceState,
43
43
  gatePluginNative,
44
+ gateVoice,
44
45
  getCameraPreviewProvider,
45
46
  getHaptics,
46
47
  getNativeBundleHash,
@@ -50,6 +51,7 @@ import {
50
51
  getPluginNative,
51
52
  hasDeviceTool,
52
53
  implementedStateDomains,
54
+ implementedVoice,
53
55
  isInlineSurface,
54
56
  isMountSurface,
55
57
  listDeviceTools,
@@ -62,6 +64,8 @@ import {
62
64
  registerService,
63
65
  registerTools,
64
66
  resetDeviceToolLoader,
67
+ resolvePluginGrants,
68
+ resolvePluginRuntimeProps,
65
69
  resolvePluginUrl,
66
70
  setBundleStorage,
67
71
  setCameraPreviewProvider,
@@ -70,6 +74,7 @@ import {
70
74
  setHapticsProvider,
71
75
  setPluginNativeProvider,
72
76
  setPluginThemeColors,
77
+ setVoiceProvider,
73
78
  supportsNative,
74
79
  supportsWebView,
75
80
  unregisterDeviceTools,
@@ -78,7 +83,7 @@ import {
78
83
  useNativeBridge,
79
84
  usePluginTheme,
80
85
  useSurfaceStore
81
- } from "./chunk-PKDQLNBL.mjs";
86
+ } from "./chunk-RXR6M623.mjs";
82
87
 
83
88
  // src/sdk/device-state.ts
84
89
  var device_state_exports = {};
@@ -134,102 +139,6 @@ function explainCapability(status) {
134
139
  return null;
135
140
  }
136
141
 
137
- // src/voiceHost.ts
138
- var _provider = null;
139
- function setVoiceProvider(provider) {
140
- _provider = provider || null;
141
- }
142
- function implementedVoice() {
143
- return !!_provider;
144
- }
145
- function voiceDenial(why) {
146
- const err = new Error(`voice: ${why}`);
147
- err.code = "RESTRICTED";
148
- return err;
149
- }
150
- function deniedVoice(why) {
151
- const fail = () => {
152
- throw voiceDenial(why);
153
- };
154
- return {
155
- async start() {
156
- return fail();
157
- },
158
- stop() {
159
- fail();
160
- },
161
- setMuted() {
162
- fail();
163
- },
164
- prompt() {
165
- fail();
166
- },
167
- observe() {
168
- fail();
169
- },
170
- getSnapshot() {
171
- return {
172
- state: "error",
173
- sessionId: null,
174
- muted: false,
175
- speaking: false,
176
- listening: false,
177
- userSpeaking: false,
178
- lastUserSpeechEndedAt: null,
179
- lastError: why
180
- };
181
- },
182
- subscribe() {
183
- return fail();
184
- },
185
- transcript() {
186
- return [];
187
- }
188
- };
189
- }
190
- function scopedVoice(provider, pluginId) {
191
- return {
192
- start: (opts) => provider.start(opts, pluginId),
193
- stop: () => provider.stop(pluginId),
194
- setMuted: (muted) => provider.setMuted(muted, pluginId),
195
- prompt: (input) => provider.prompt(input, pluginId),
196
- observe: (text) => provider.observe(text, pluginId),
197
- getSnapshot: () => provider.getSnapshot(pluginId),
198
- subscribe: (cb) => provider.subscribe(cb, pluginId),
199
- transcript: () => provider.transcript(pluginId)
200
- };
201
- }
202
- function gateVoice(declared, pluginId) {
203
- if (!declared) {
204
- return deniedVoice(
205
- "not declared in this plugin's capabilities. Add `capabilities: { voice: true }` to use it."
206
- );
207
- }
208
- if (!pluginId) {
209
- return deniedVoice(
210
- "no plugin identity \u2014 voice fails closed without a caller to scope the session to."
211
- );
212
- }
213
- return _provider ? scopedVoice(_provider, pluginId) : deniedVoice(
214
- "no voice session in this build \u2014 the app has not mounted a VoiceSessionHost / called setVoiceProvider."
215
- );
216
- }
217
-
218
- // src/pluginRuntime.ts
219
- function mergeCaps(decl) {
220
- if (!decl) return void 0;
221
- return { ...decl.native, ...decl.capabilities };
222
- }
223
- function resolvePluginRuntimeProps(src) {
224
- const trusted = src.manifest ?? src.plugin ?? null;
225
- const capabilities = mergeCaps(trusted);
226
- const stateDomains = trusted?.stateDomains;
227
- const native = gatePluginNative(getPluginNative(), capabilities, src.pluginId);
228
- const deviceState = gateDeviceState(stateDomains);
229
- const voice = gateVoice(!!capabilities?.voice, src.pluginId);
230
- return { device: native, native, deviceState, voice };
231
- }
232
-
233
142
  // src/tools/platformTools.ts
234
143
  var PLATFORM_PLUGIN_ID = "platform:device-tools";
235
144
  function registerPlatformDeviceTools() {
@@ -271,10 +180,10 @@ var REAL_DEPS = {
271
180
  // `./loader` reaches react-native via the bundle manager; import it only when
272
181
  // an effect actually fires (real app), never at module load (tests).
273
182
  resetLoader: () => {
274
- void import("./loader-5LUVXUY2.mjs").then((m) => m.resetDeviceToolLoader());
183
+ void import("./loader-UUOPZQSI.mjs").then((m) => m.resetDeviceToolLoader());
275
184
  },
276
185
  load: () => {
277
- void import("./loader-5LUVXUY2.mjs").then((m) => {
186
+ void import("./loader-UUOPZQSI.mjs").then((m) => {
278
187
  m.resetDeviceToolLoader();
279
188
  return m.ensureDeviceToolsLoaded({ force: true });
280
189
  });
@@ -370,6 +279,8 @@ function usePlugin(pluginId, manifest) {
370
279
  const bundleHash = extractBundleHash(manifest);
371
280
  const componentId = extractComponentId(manifest);
372
281
  const lookupId = componentId || pluginId;
282
+ const grants = resolvePluginGrants({ pluginId, manifest });
283
+ const grantsKey = JSON.stringify(grants);
373
284
  if (ignoredUrl) {
374
285
  console.warn(`[usePlugin] ${pluginId}: IGNORED connector-injected bundleUrl="${ignoredUrl}". The host derives bundle URLs from pluginId via the canonical route.`);
375
286
  }
@@ -392,7 +303,7 @@ function usePlugin(pluginId, manifest) {
392
303
  }
393
304
  if (bundleUrl) {
394
305
  try {
395
- const component = await bundleManager.load(pluginId, bundleUrl, version, bundleHash);
306
+ const component = await bundleManager.load(pluginId, bundleUrl, version, bundleHash, grants);
396
307
  if (cancelled) return;
397
308
  setPlugin(component);
398
309
  setLoading(false);
@@ -429,7 +340,7 @@ function usePlugin(pluginId, manifest) {
429
340
  return () => {
430
341
  cancelled = true;
431
342
  };
432
- }, [pluginId, lookupId, bundleUrl, bundleHash, version]);
343
+ }, [pluginId, lookupId, bundleUrl, bundleHash, version, grantsKey]);
433
344
  return { plugin, loading, error, bundleMissing };
434
345
  }
435
346
 
@@ -576,6 +487,7 @@ export {
576
487
  registerService,
577
488
  registerTools,
578
489
  resetDeviceToolLoader,
490
+ resolvePluginGrants,
579
491
  resolvePluginRuntimeProps,
580
492
  resolvePluginUrl,
581
493
  setBundleStorage,