craft-native 0.0.276 → 0.0.278
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/android/src/index.js +1 -1
- package/dist/android/templates/CraftNativeMutation.kt.template +35 -0
- package/dist/api/index.d.ts +2 -2
- package/dist/api/mobile.d.ts +25 -0
- package/dist/cli.js +29 -6
- package/dist/index.cjs +78 -5
- package/dist/index.js +79 -6
- package/dist/ios/src/index.js +7 -3
- package/dist/ios/templates/CraftNativeActions.swift +6 -0
- package/dist/ios/templates/CraftNativeFiles.swift +136 -0
- package/dist/ios/templates/CraftNativeMutation.swift +51 -0
- package/dist/ios/templates/CraftWatchApp.swift.template +303 -9
- package/dist/ios/templates/WatchExtension.Info.plist.template +1 -0
- package/dist/macos/templates/CraftNativeMutation.swift +51 -0
- package/dist/mobile.js +50 -0
- package/dist/package.d.ts +19 -3
- package/dist/types.d.ts +19 -0
- package/package.json +1 -1
package/dist/mobile.js
CHANGED
|
@@ -223,6 +223,55 @@ var permissions = {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
|
+
var files = {
|
|
227
|
+
async pickFile(options = {}) {
|
|
228
|
+
const craft = getCraftMobile();
|
|
229
|
+
if (typeof window !== "undefined" && craft?.files) {
|
|
230
|
+
return craft.files.pickFile(options);
|
|
231
|
+
}
|
|
232
|
+
if (typeof document === "undefined") {
|
|
233
|
+
throw new Error("File picker not available. Must run in Craft or a browser.");
|
|
234
|
+
}
|
|
235
|
+
return new Promise((resolve, reject) => {
|
|
236
|
+
const input = document.createElement("input");
|
|
237
|
+
input.type = "file";
|
|
238
|
+
if (options.contentTypes?.length)
|
|
239
|
+
input.accept = options.contentTypes.join(",");
|
|
240
|
+
const requested = Number(options.maxSelections);
|
|
241
|
+
const maxSelections = Number.isFinite(requested) && requested > 0 ? Math.min(20, Math.floor(requested)) : 1;
|
|
242
|
+
input.multiple = maxSelections > 1;
|
|
243
|
+
input.style.display = "none";
|
|
244
|
+
let settled = false;
|
|
245
|
+
const finish = (result) => {
|
|
246
|
+
if (settled)
|
|
247
|
+
return;
|
|
248
|
+
settled = true;
|
|
249
|
+
input.remove();
|
|
250
|
+
result();
|
|
251
|
+
};
|
|
252
|
+
input.addEventListener("cancel", () => finish(() => resolve([])), { once: true });
|
|
253
|
+
input.onchange = () => {
|
|
254
|
+
const chosen = Array.from(input.files ?? []).slice(0, maxSelections);
|
|
255
|
+
const limit = Number(options.maxBytes);
|
|
256
|
+
if (Number.isFinite(limit) && limit > 0) {
|
|
257
|
+
const oversized = chosen.find((file) => file.size > limit);
|
|
258
|
+
if (oversized) {
|
|
259
|
+
finish(() => reject(Object.assign(new Error("The selected file is too large"), { code: "FILE_TOO_LARGE" })));
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
finish(() => resolve(chosen.map((file) => ({
|
|
264
|
+
path: URL.createObjectURL(file),
|
|
265
|
+
name: file.name,
|
|
266
|
+
type: file.type || "application/octet-stream",
|
|
267
|
+
size: file.size
|
|
268
|
+
}))));
|
|
269
|
+
};
|
|
270
|
+
document.body.append(input);
|
|
271
|
+
input.click();
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
};
|
|
226
275
|
var camera = {
|
|
227
276
|
async takePicture(options = {}) {
|
|
228
277
|
const craft = getCraftMobile();
|
|
@@ -1877,6 +1926,7 @@ export {
|
|
|
1877
1926
|
deepLinks,
|
|
1878
1927
|
device,
|
|
1879
1928
|
dialog,
|
|
1929
|
+
files,
|
|
1880
1930
|
haptics,
|
|
1881
1931
|
health,
|
|
1882
1932
|
heartRate,
|
package/dist/package.d.ts
CHANGED
|
@@ -29,6 +29,16 @@ export interface PackageConfig {
|
|
|
29
29
|
platforms?: Array<'macos' | 'windows' | 'linux'>;
|
|
30
30
|
/** macOS-specific options */
|
|
31
31
|
macos?: {
|
|
32
|
+
/** Preserve a prebuilt .app, including its resources and Info.plist. */
|
|
33
|
+
appBundlePath?: string;
|
|
34
|
+
/** Use existing notarytool credentials stored in the macOS keychain. */
|
|
35
|
+
notaryKeychainProfile?: string;
|
|
36
|
+
/** App Store Connect API-key authentication for notarization. */
|
|
37
|
+
notaryApiKey?: {
|
|
38
|
+
path: string;
|
|
39
|
+
keyId: string;
|
|
40
|
+
issuer: string;
|
|
41
|
+
};
|
|
32
42
|
/** Create DMG installer */
|
|
33
43
|
dmg?: boolean;
|
|
34
44
|
/** Create PKG installer */
|
|
@@ -208,9 +218,15 @@ export declare function productbuildArguments(opts: {
|
|
|
208
218
|
/** Build the `xcrun notarytool submit` argument list for a DMG or PKG. */
|
|
209
219
|
export declare function notarytoolArguments(opts: {
|
|
210
220
|
artifactPath: string;
|
|
211
|
-
appleId
|
|
212
|
-
applePassword
|
|
213
|
-
teamId
|
|
221
|
+
appleId?: string;
|
|
222
|
+
applePassword?: string;
|
|
223
|
+
teamId?: string;
|
|
224
|
+
keychainProfile?: string;
|
|
225
|
+
apiKey?: {
|
|
226
|
+
path: string;
|
|
227
|
+
keyId: string;
|
|
228
|
+
issuer: string;
|
|
229
|
+
};
|
|
214
230
|
}): string[];
|
|
215
231
|
export declare function dmgCapacityMegabytes(contentBytes: number): number;
|
|
216
232
|
export declare function dmgCreateArguments(opts: {
|
package/dist/types.d.ts
CHANGED
|
@@ -569,6 +569,8 @@ export interface AppConfig {
|
|
|
569
569
|
* Craft System Tray API (available as window.craft.tray in WebView)
|
|
570
570
|
*/
|
|
571
571
|
export interface CraftTrayAPI {
|
|
572
|
+
/** SF Symbol name, image path, or base64 image data URL. */
|
|
573
|
+
setIcon(icon: string): Promise<void>;
|
|
572
574
|
/**
|
|
573
575
|
* Update the system tray title/text
|
|
574
576
|
* Updates in real-time (60fps max)
|
|
@@ -1163,6 +1165,23 @@ export interface CraftBridgeAPI {
|
|
|
1163
1165
|
* System tray control (desktop only)
|
|
1164
1166
|
*/
|
|
1165
1167
|
tray?: CraftTrayAPI;
|
|
1168
|
+
/** Native status-item arrangement and collapse controls (macOS). */
|
|
1169
|
+
menubar?: {
|
|
1170
|
+
init(): Promise<void>;
|
|
1171
|
+
collapse(): Promise<void>;
|
|
1172
|
+
expand(): Promise<void>;
|
|
1173
|
+
toggle(): Promise<void>;
|
|
1174
|
+
getState(): Promise<{
|
|
1175
|
+
collapsed: boolean;
|
|
1176
|
+
initialized: boolean;
|
|
1177
|
+
separatorHidden: boolean;
|
|
1178
|
+
}>;
|
|
1179
|
+
setAutoCollapse(seconds: number): Promise<void>;
|
|
1180
|
+
setSeparatorHidden(hidden: boolean): Promise<void>;
|
|
1181
|
+
onStateChange(callback: (state: {
|
|
1182
|
+
collapsed: boolean;
|
|
1183
|
+
}) => void): () => void;
|
|
1184
|
+
};
|
|
1166
1185
|
/**
|
|
1167
1186
|
* Window control (desktop)
|
|
1168
1187
|
*/
|