@wix/himalaya-cli 0.1292.0 → 0.1293.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.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/webview/src/index.d.ts +35 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/webview-page/src/capabilities.generated.d.ts +88 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/webview-page/src/index.d.ts +68 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/webview-page.mjs +88 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/webview.mjs +43 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/package.json +4 -0
- package/dist/cli.mjs +164 -60
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/importable-sdks.md +1 -0
- package/guides/index.json +6 -0
- package/guides/sdk-reference.json +79 -0
- package/guides/webview-page-sdk.md +132 -0
- package/package.json +2 -2
|
@@ -11,4 +11,39 @@ export declare function postToPage(msg: unknown): void;
|
|
|
11
11
|
* The latest registered handler wins. Call this once during the bundle's setup.
|
|
12
12
|
*/
|
|
13
13
|
export declare function onPageMessage(cb: (msg: unknown) => void): void;
|
|
14
|
+
export interface PageCapabilityRequest {
|
|
15
|
+
v: 1;
|
|
16
|
+
id: string;
|
|
17
|
+
capability: string;
|
|
18
|
+
method: string;
|
|
19
|
+
args: unknown[];
|
|
20
|
+
}
|
|
21
|
+
export interface PageCapabilityResponse {
|
|
22
|
+
v: 1;
|
|
23
|
+
id: string;
|
|
24
|
+
ok: boolean;
|
|
25
|
+
result?: unknown;
|
|
26
|
+
error?: {
|
|
27
|
+
message: string;
|
|
28
|
+
code?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface ExposedPageCapability {
|
|
32
|
+
module: Record<string, unknown>;
|
|
33
|
+
methods: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Expose selected typed @himalaya/* modules to the hosting page.
|
|
37
|
+
*
|
|
38
|
+
* The worker author must pass both the imported module and its explicit verb allowlist:
|
|
39
|
+
*
|
|
40
|
+
* import * as health from "@wix/himalaya/health";
|
|
41
|
+
* exposeCapabilitiesToPage({
|
|
42
|
+
* health: { module: health, methods: ["availability", "query"] },
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* The bundle still has to declare `webview` plus every exposed capability. Importing only
|
|
46
|
+
* selected modules keeps native permissions and `himi dist` additions opt-in.
|
|
47
|
+
*/
|
|
48
|
+
export declare function exposeCapabilitiesToPage(capabilities: Readonly<Record<string, ExposedPageCapability>>): void;
|
|
14
49
|
export declare const version = 1;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type * as AppInfoSdk from "@wix/himalaya/app-info";
|
|
2
|
+
import type * as AudioRecordSdk from "@wix/himalaya/audio-record";
|
|
3
|
+
import type * as Base44Sdk from "@wix/himalaya/base44";
|
|
4
|
+
import type * as BiometricsSdk from "@wix/himalaya/biometrics";
|
|
5
|
+
import type * as BrowserAuthSdk from "@wix/himalaya/browser-auth";
|
|
6
|
+
import type * as CalendarSdk from "@wix/himalaya/calendar";
|
|
7
|
+
import type * as CallsSdk from "@wix/himalaya/calls";
|
|
8
|
+
import type * as CameraSdk from "@wix/himalaya/camera";
|
|
9
|
+
import type * as ClipboardSdk from "@wix/himalaya/clipboard";
|
|
10
|
+
import type * as ContactsSdk from "@wix/himalaya/contacts";
|
|
11
|
+
import type * as FilePickerSdk from "@wix/himalaya/file-picker";
|
|
12
|
+
import type * as FilesSdk from "@wix/himalaya/files";
|
|
13
|
+
import type * as GodotSdk from "@wix/himalaya/godot";
|
|
14
|
+
import type * as HapticSdk from "@wix/himalaya/haptic";
|
|
15
|
+
import type * as HealthSdk from "@wix/himalaya/health";
|
|
16
|
+
import type * as HimiAppsSdk from "@wix/himalaya/himi-apps";
|
|
17
|
+
import type * as IapSdk from "@wix/himalaya/iap";
|
|
18
|
+
import type * as KeyboardSdk from "@wix/himalaya/keyboard";
|
|
19
|
+
import type * as LiveActivitySdk from "@wix/himalaya/live-activity";
|
|
20
|
+
import type * as LocalDatabaseSdk from "@wix/himalaya/local-db";
|
|
21
|
+
import type * as LocationSdk from "@wix/himalaya/location";
|
|
22
|
+
import type * as MediaPlaybackSdk from "@wix/himalaya/media-playback";
|
|
23
|
+
import type * as MotionSdk from "@wix/himalaya/motion";
|
|
24
|
+
import type * as OnDeviceAiSdk from "@wix/himalaya/on-device-ai";
|
|
25
|
+
import type * as OpenUrlSdk from "@wix/himalaya/open-url";
|
|
26
|
+
import type * as PdfSdk from "@wix/himalaya/pdf";
|
|
27
|
+
import type * as PhotosSdk from "@wix/himalaya/photos";
|
|
28
|
+
import type * as PresignedUploadSdk from "@wix/himalaya/presigned-upload";
|
|
29
|
+
import type * as PushSdk from "@wix/himalaya/push";
|
|
30
|
+
import type * as ReleaseControlSdk from "@wix/himalaya/release-control";
|
|
31
|
+
import type * as SecureStorageSdk from "@wix/himalaya/secure-storage";
|
|
32
|
+
import type * as ShareSdk from "@wix/himalaya/share";
|
|
33
|
+
import type * as SpeakerDiarizationSdk from "@wix/himalaya/speaker-diarization";
|
|
34
|
+
import type * as SpeechSdk from "@wix/himalaya/speech";
|
|
35
|
+
import type * as SystemIntentsSdk from "@wix/himalaya/system-intents";
|
|
36
|
+
import type * as TasksSdk from "@wix/himalaya/tasks";
|
|
37
|
+
import type * as UiSdk from "@wix/himalaya/ui";
|
|
38
|
+
import type * as WixCashierSdk from "@wix/himalaya/wix-cashier";
|
|
39
|
+
type PageModule<T> = {
|
|
40
|
+
readonly [P in keyof T as T[P] extends (...args: any[]) => any ? P : T[P] extends readonly unknown[] ? never : T[P] extends object ? keyof PageModule<T[P]> extends never ? never : P : never]: T[P] extends (...args: infer A) => infer R ? (...args: A) => R : T[P] extends readonly unknown[] ? never : T[P] extends object ? PageModule<T[P]> : never;
|
|
41
|
+
};
|
|
42
|
+
/** Every typed request/response capability a trusted WebView page can ask its companion worker for.
|
|
43
|
+
* Availability is still opt-in: the worker imports a subset and its logic-bundle manifest declares
|
|
44
|
+
* that same subset; every other namespace/method is ignored. */
|
|
45
|
+
export interface HimalayaPageCapabilities {
|
|
46
|
+
readonly "app_info": PageModule<typeof AppInfoSdk>;
|
|
47
|
+
readonly "audio_record": PageModule<typeof AudioRecordSdk>;
|
|
48
|
+
readonly "base44": PageModule<typeof Base44Sdk>;
|
|
49
|
+
readonly "biometrics": PageModule<typeof BiometricsSdk>;
|
|
50
|
+
readonly "browser_auth": PageModule<typeof BrowserAuthSdk>;
|
|
51
|
+
readonly "calendar": PageModule<typeof CalendarSdk>;
|
|
52
|
+
readonly "calls": PageModule<typeof CallsSdk>;
|
|
53
|
+
readonly "camera": PageModule<typeof CameraSdk>;
|
|
54
|
+
readonly "clipboard": PageModule<typeof ClipboardSdk>;
|
|
55
|
+
readonly "contacts": PageModule<typeof ContactsSdk>;
|
|
56
|
+
readonly "file_picker": PageModule<typeof FilePickerSdk>;
|
|
57
|
+
readonly "files": PageModule<typeof FilesSdk>;
|
|
58
|
+
readonly "godot": PageModule<typeof GodotSdk>;
|
|
59
|
+
readonly "haptic": PageModule<typeof HapticSdk>;
|
|
60
|
+
readonly "health": PageModule<typeof HealthSdk>;
|
|
61
|
+
readonly "himi_apps": PageModule<typeof HimiAppsSdk>;
|
|
62
|
+
readonly "iap": PageModule<typeof IapSdk>;
|
|
63
|
+
readonly "keyboard": PageModule<typeof KeyboardSdk>;
|
|
64
|
+
readonly "live_activity": PageModule<typeof LiveActivitySdk>;
|
|
65
|
+
readonly "local_database": PageModule<typeof LocalDatabaseSdk>;
|
|
66
|
+
readonly "location": PageModule<typeof LocationSdk>;
|
|
67
|
+
readonly "media_playback": PageModule<typeof MediaPlaybackSdk>;
|
|
68
|
+
readonly "motion": PageModule<typeof MotionSdk>;
|
|
69
|
+
readonly "on_device_ai": PageModule<typeof OnDeviceAiSdk>;
|
|
70
|
+
readonly "open_url": PageModule<typeof OpenUrlSdk>;
|
|
71
|
+
readonly "pdf": PageModule<typeof PdfSdk>;
|
|
72
|
+
readonly "photos": PageModule<typeof PhotosSdk>;
|
|
73
|
+
readonly "presigned_upload": PageModule<typeof PresignedUploadSdk>;
|
|
74
|
+
readonly "push": PageModule<typeof PushSdk>;
|
|
75
|
+
readonly "release_control": PageModule<typeof ReleaseControlSdk>;
|
|
76
|
+
readonly "secure_storage": PageModule<typeof SecureStorageSdk>;
|
|
77
|
+
readonly "share": PageModule<typeof ShareSdk>;
|
|
78
|
+
readonly "speaker_diarization": PageModule<typeof SpeakerDiarizationSdk>;
|
|
79
|
+
readonly "speech": PageModule<typeof SpeechSdk>;
|
|
80
|
+
readonly "system_intents": PageModule<typeof SystemIntentsSdk>;
|
|
81
|
+
readonly "tasks": PageModule<typeof TasksSdk>;
|
|
82
|
+
readonly "ui": PageModule<typeof UiSdk>;
|
|
83
|
+
readonly "wix_cashier": PageModule<typeof WixCashierSdk>;
|
|
84
|
+
}
|
|
85
|
+
export type HimalayaPageSdk = HimalayaPageCapabilities & {
|
|
86
|
+
readonly version: 1;
|
|
87
|
+
};
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { HimalayaPageSdk } from "./capabilities.generated.js";
|
|
2
|
+
export type { HimalayaPageCapabilities, HimalayaPageSdk } from "./capabilities.generated.js";
|
|
3
|
+
export interface WebViewPageRequest {
|
|
4
|
+
v: 1;
|
|
5
|
+
id: string;
|
|
6
|
+
capability: string;
|
|
7
|
+
method: string;
|
|
8
|
+
args: unknown[];
|
|
9
|
+
}
|
|
10
|
+
export interface WebViewPageError {
|
|
11
|
+
message: string;
|
|
12
|
+
code?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WebViewPageResponse {
|
|
15
|
+
v: 1;
|
|
16
|
+
id: string;
|
|
17
|
+
ok: boolean;
|
|
18
|
+
result?: unknown;
|
|
19
|
+
error?: WebViewPageError;
|
|
20
|
+
}
|
|
21
|
+
/** Invoke one method through the companion worker. Primarily useful to generated bindings. */
|
|
22
|
+
export declare function call<T>(capability: string, method: string, args?: unknown[], timeoutMs?: number): Promise<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Typed SDK proxy for every request/response capability in CAPABILITY_REGISTRY.
|
|
25
|
+
* A namespace is usable only when this screen's companion worker explicitly imported and
|
|
26
|
+
* exposed it and the bundle + host both declared it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const himalaya: HimalayaPageSdk;
|
|
29
|
+
/** Convenience named export; equivalent to `himalaya.health`. */
|
|
30
|
+
export declare const health: {
|
|
31
|
+
readonly healthError: (code: import("@wix/himalaya/health").HealthErrorCode, message: string) => import("@wix/himalaya/health").HealthError;
|
|
32
|
+
readonly isHealthError: (e: unknown) => boolean;
|
|
33
|
+
readonly availability: () => Promise<import("@wix/himalaya/health").HealthAvailability>;
|
|
34
|
+
readonly requestPermission: (p: {
|
|
35
|
+
read: import("@wix/himalaya/health").HealthType[];
|
|
36
|
+
write?: import("@wix/himalaya/health").HealthWriteType[];
|
|
37
|
+
}) => Promise<{
|
|
38
|
+
granted: import("@wix/himalaya/health").HealthType[];
|
|
39
|
+
}>;
|
|
40
|
+
readonly getPermissionStatus: (p: {
|
|
41
|
+
types: import("@wix/himalaya/health").HealthType[];
|
|
42
|
+
}) => Promise<Record<import("@wix/himalaya/health").HealthType, import("@wix/himalaya/health").HealthPermissionState>>;
|
|
43
|
+
readonly query: (p: import("@wix/himalaya/health").HealthQuery) => Promise<{
|
|
44
|
+
samples: import("@wix/himalaya/health").HealthSample[];
|
|
45
|
+
}>;
|
|
46
|
+
readonly saveWorkout: (w: import("@wix/himalaya/health").Workout) => Promise<{
|
|
47
|
+
id: string;
|
|
48
|
+
}>;
|
|
49
|
+
readonly health: {
|
|
50
|
+
readonly availability: () => Promise<import("@wix/himalaya/health").HealthAvailability>;
|
|
51
|
+
readonly requestPermission: (p: {
|
|
52
|
+
read: import("@wix/himalaya/health").HealthType[];
|
|
53
|
+
write?: import("@wix/himalaya/health").HealthWriteType[];
|
|
54
|
+
}) => Promise<{
|
|
55
|
+
granted: import("@wix/himalaya/health").HealthType[];
|
|
56
|
+
}>;
|
|
57
|
+
readonly getPermissionStatus: (p: {
|
|
58
|
+
types: import("@wix/himalaya/health").HealthType[];
|
|
59
|
+
}) => Promise<Record<import("@wix/himalaya/health").HealthType, import("@wix/himalaya/health").HealthPermissionState>>;
|
|
60
|
+
readonly query: (p: import("@wix/himalaya/health").HealthQuery) => Promise<{
|
|
61
|
+
samples: import("@wix/himalaya/health").HealthSample[];
|
|
62
|
+
}>;
|
|
63
|
+
readonly saveWorkout: (w: import("@wix/himalaya/health").Workout) => Promise<{
|
|
64
|
+
id: string;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export declare const version = 1;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// ../../core/sdk/webview-page/src/index.ts
|
|
2
|
+
var pending = /* @__PURE__ */ new Map();
|
|
3
|
+
var installedOn;
|
|
4
|
+
var nextId = 1;
|
|
5
|
+
function workerBridge() {
|
|
6
|
+
const bridge = globalThis.HimalayaWorker;
|
|
7
|
+
if (!bridge || typeof bridge.post !== "function" || typeof bridge.onMessage !== "function") {
|
|
8
|
+
throw new Error(
|
|
9
|
+
"@himalaya/webview-page: this page is not inside a worker-backed Himalaya WebView."
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
if (installedOn !== bridge) {
|
|
13
|
+
bridge.onMessage(receive);
|
|
14
|
+
installedOn = bridge;
|
|
15
|
+
}
|
|
16
|
+
return bridge;
|
|
17
|
+
}
|
|
18
|
+
function isResponse(value) {
|
|
19
|
+
if (!value || typeof value !== "object") return false;
|
|
20
|
+
const r = value;
|
|
21
|
+
return r.v === 1 && typeof r.id === "string" && typeof r.ok === "boolean";
|
|
22
|
+
}
|
|
23
|
+
function receive(message) {
|
|
24
|
+
if (!isResponse(message)) return;
|
|
25
|
+
const call2 = pending.get(message.id);
|
|
26
|
+
if (!call2) return;
|
|
27
|
+
pending.delete(message.id);
|
|
28
|
+
clearTimeout(call2.timeout);
|
|
29
|
+
if (message.ok) {
|
|
30
|
+
call2.resolve(message.result);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const error = new Error(message.error?.message ?? "Himalaya capability call failed");
|
|
34
|
+
if (message.error?.code) Object.assign(error, { code: message.error.code });
|
|
35
|
+
call2.reject(error);
|
|
36
|
+
}
|
|
37
|
+
function call(capability, method, args = [], timeoutMs = 3e4) {
|
|
38
|
+
const bridge = workerBridge();
|
|
39
|
+
const id = `page-${Date.now().toString(36)}-${nextId++}`;
|
|
40
|
+
const request = { v: 1, id, capability, method, args };
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const timeout = setTimeout(() => {
|
|
43
|
+
pending.delete(id);
|
|
44
|
+
reject(new Error(`Himalaya capability call timed out: ${capability}.${method}`));
|
|
45
|
+
}, timeoutMs);
|
|
46
|
+
pending.set(id, { resolve, reject, timeout });
|
|
47
|
+
if (!bridge.post(request)) {
|
|
48
|
+
clearTimeout(timeout);
|
|
49
|
+
pending.delete(id);
|
|
50
|
+
reject(new Error("@himalaya/webview-page: the native page-to-worker bridge refused the request."));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
var members = /* @__PURE__ */ new Map();
|
|
55
|
+
function pageMember(capability, path) {
|
|
56
|
+
const key = `${capability}:${path.join(".")}`;
|
|
57
|
+
let member = members.get(key);
|
|
58
|
+
if (member) return member;
|
|
59
|
+
member = new Proxy(function() {
|
|
60
|
+
}, {
|
|
61
|
+
get(_target, property) {
|
|
62
|
+
if (typeof property !== "string" || property === "then") return void 0;
|
|
63
|
+
return pageMember(capability, [...path, property]);
|
|
64
|
+
},
|
|
65
|
+
apply(_target, _thisArg, args) {
|
|
66
|
+
if (path.length === 0) throw new Error(`Himalaya capability namespace is not callable: ${capability}`);
|
|
67
|
+
return call(capability, path.join("."), args);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
members.set(key, member);
|
|
71
|
+
return member;
|
|
72
|
+
}
|
|
73
|
+
var himalaya = new Proxy({ version: 1 }, {
|
|
74
|
+
get(target, property) {
|
|
75
|
+
if (property === "version") return target.version;
|
|
76
|
+
if (typeof property !== "string" || property === "then") return void 0;
|
|
77
|
+
return pageMember(property, []);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
var health = himalaya.health;
|
|
81
|
+
var version = 1;
|
|
82
|
+
export {
|
|
83
|
+
call,
|
|
84
|
+
health,
|
|
85
|
+
himalaya,
|
|
86
|
+
version
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=webview-page.mjs.map
|
|
@@ -14,8 +14,51 @@ function postToPage(msg) {
|
|
|
14
14
|
function onPageMessage(cb) {
|
|
15
15
|
runtime().onPageMessage(cb);
|
|
16
16
|
}
|
|
17
|
+
function pageRequest(value) {
|
|
18
|
+
if (!value || typeof value !== "object") return null;
|
|
19
|
+
const request = value;
|
|
20
|
+
if (request.v !== 1 || typeof request.id !== "string" || !/^[A-Za-z0-9-]{1,96}$/.test(request.id) || typeof request.capability !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(request.capability) || typeof request.method !== "string" || !/^[A-Za-z][A-Za-z0-9_]{0,63}(?:\.[A-Za-z][A-Za-z0-9_]{0,63}){0,3}$/.test(request.method) || !Array.isArray(request.args) || request.args.length > 12) return null;
|
|
21
|
+
return request;
|
|
22
|
+
}
|
|
23
|
+
function pageError(value) {
|
|
24
|
+
if (!(value instanceof Error)) return { message: "Himalaya capability call failed" };
|
|
25
|
+
const code = value.code;
|
|
26
|
+
return {
|
|
27
|
+
message: value.message,
|
|
28
|
+
...typeof code === "string" && code ? { code } : {}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function exposeCapabilitiesToPage(capabilities) {
|
|
32
|
+
const allowed = new Map(
|
|
33
|
+
Object.entries(capabilities).map(([id, entry]) => [id, {
|
|
34
|
+
module: entry.module,
|
|
35
|
+
methods: new Set(entry.methods)
|
|
36
|
+
}])
|
|
37
|
+
);
|
|
38
|
+
onPageMessage((message) => {
|
|
39
|
+
const request = pageRequest(message);
|
|
40
|
+
if (!request) return;
|
|
41
|
+
const capability = allowed.get(request.capability);
|
|
42
|
+
let candidate = capability?.module;
|
|
43
|
+
let receiver = void 0;
|
|
44
|
+
for (const segment of request.method.split(".")) {
|
|
45
|
+
if (!candidate || typeof candidate !== "object" || !Object.prototype.hasOwnProperty.call(candidate, segment)) {
|
|
46
|
+
candidate = void 0;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
receiver = candidate;
|
|
50
|
+
candidate = candidate[segment];
|
|
51
|
+
}
|
|
52
|
+
if (!capability || !capability.methods.has(request.method) || typeof candidate !== "function") return;
|
|
53
|
+
void Promise.resolve().then(() => candidate.apply(receiver, request.args)).then(
|
|
54
|
+
(result) => postToPage({ v: 1, id: request.id, ok: true, result }),
|
|
55
|
+
(error) => postToPage({ v: 1, id: request.id, ok: false, error: pageError(error) })
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
17
59
|
var version = 1;
|
|
18
60
|
export {
|
|
61
|
+
exposeCapabilitiesToPage,
|
|
19
62
|
onPageMessage,
|
|
20
63
|
postToPage,
|
|
21
64
|
version
|
|
@@ -246,6 +246,10 @@
|
|
|
246
246
|
"types": "./dist/_types/core/sdk/webview/src/index.d.ts",
|
|
247
247
|
"import": "./dist/webview.mjs"
|
|
248
248
|
},
|
|
249
|
+
"./webview-page": {
|
|
250
|
+
"types": "./dist/_types/core/sdk/webview-page/src/index.d.ts",
|
|
251
|
+
"import": "./dist/webview-page.mjs"
|
|
252
|
+
},
|
|
249
253
|
"./widget": {
|
|
250
254
|
"types": "./dist/_types/core/sdk/widget/src/index.d.ts",
|
|
251
255
|
"import": "./dist/widget.mjs"
|