bleam 0.0.5 → 0.0.6
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/ai.cjs +187 -0
- package/dist/ai.d.cts +52 -0
- package/dist/ai.d.ts +52 -0
- package/dist/ai.js +182 -0
- package/dist/animated.cjs +286 -0
- package/dist/animated.d.cts +47 -0
- package/dist/animated.d.ts +47 -0
- package/dist/animated.js +281 -0
- package/dist/app.d.cts +1 -2
- package/dist/app.d.ts +1 -2
- package/dist/app.js +1 -2
- package/dist/bundler.d.cts +1 -2
- package/dist/bundler.d.ts +1 -2
- package/dist/chrome.cjs +265 -0
- package/dist/chrome.d.cts +19 -0
- package/dist/chrome.d.ts +19 -0
- package/dist/chrome.js +262 -0
- package/dist/cli.cjs +768 -31
- package/dist/cli.js +767 -34
- package/dist/config-Bb6SULnR.cjs +46 -0
- package/dist/config-CfWa3q-k.js +28 -0
- package/dist/config-ClDGHNb3.d.ts +39 -0
- package/dist/config-D3gPaVMb.d.cts +39 -0
- package/dist/config.cjs +4 -25
- package/dist/config.d.cts +2 -28
- package/dist/config.d.ts +2 -28
- package/dist/config.js +2 -24
- package/dist/crypto-BB92-Upx.js +7 -0
- package/dist/crypto-CT3VZ7lF.cjs +13 -0
- package/dist/crypto.cjs +2 -2
- package/dist/crypto.d.cts +8 -1
- package/dist/crypto.d.ts +8 -1
- package/dist/crypto.js +2 -2
- package/dist/dev-protocol.d.cts +3 -3
- package/dist/dev-protocol.d.ts +3 -3
- package/dist/dev-protocol.js +1 -2
- package/dist/fs.cjs +12 -2
- package/dist/fs.d.cts +7 -1
- package/dist/fs.d.ts +7 -1
- package/dist/fs.js +10 -1
- package/dist/index.cjs +4 -5
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -4
- package/dist/native-macos-D6p2SmUj.js +20 -0
- package/dist/native-macos-DLwo_ii9.cjs +31 -0
- package/dist/native-runtime-C85Nuc4F.js +10 -0
- package/dist/native-runtime-CbPzrs8j.d.cts +33 -0
- package/dist/{native-runtime-CdeT0JyQ.cjs → native-runtime-CsXnXkQn.cjs} +1 -14
- package/dist/native-runtime-DxHSrsTX.d.ts +33 -0
- package/dist/native.cjs +35 -32
- package/dist/native.d.cts +4 -34
- package/dist/native.d.ts +3 -33
- package/dist/native.js +36 -34
- package/dist/runtime.d.cts +1 -2
- package/dist/runtime.d.ts +1 -2
- package/dist/schema-BOuUHcqo.d.cts +58 -0
- package/dist/schema-DVmoD9JL.js +90 -0
- package/dist/schema-bxeeCyLn.cjs +102 -0
- package/dist/schema-ipsECAso.d.ts +58 -0
- package/dist/schema.cjs +4 -0
- package/dist/schema.d.cts +2 -0
- package/dist/schema.d.ts +2 -0
- package/dist/schema.js +3 -0
- package/dist/state.cjs +765 -0
- package/dist/state.d.cts +129 -0
- package/dist/state.d.ts +129 -0
- package/dist/state.js +747 -0
- package/dist/styles.cjs +742 -0
- package/dist/styles.d.cts +701 -0
- package/dist/styles.d.ts +701 -0
- package/dist/styles.js +739 -0
- package/dist/ui.cjs +113 -0
- package/dist/ui.d.cts +30 -0
- package/dist/ui.d.ts +30 -0
- package/dist/ui.js +110 -0
- package/metro-config.cjs +18 -13
- package/package.json +47 -13
- package/templates/basic/app/index.tsx +130 -12
- package/templates/basic/app.config.ts +4 -2
- package/dist/app.d.cts.map +0 -1
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js.map +0 -1
- package/dist/bundler.d.cts.map +0 -1
- package/dist/bundler.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/crypto-BNhWeXMj.cjs +0 -15
- package/dist/crypto-Bg8cD8wX.d.cts +0 -8
- package/dist/crypto-Bg8cD8wX.d.cts.map +0 -1
- package/dist/crypto-CCA_hvao.js +0 -11
- package/dist/crypto-CCA_hvao.js.map +0 -1
- package/dist/crypto-IOzbNoJD.d.ts +0 -8
- package/dist/crypto-IOzbNoJD.d.ts.map +0 -1
- package/dist/dev-protocol.d.cts.map +0 -1
- package/dist/dev-protocol.d.ts.map +0 -1
- package/dist/dev-protocol.js.map +0 -1
- package/dist/fs-BK7joD1g.js +0 -13
- package/dist/fs-BK7joD1g.js.map +0 -1
- package/dist/fs-CEhcjuN6.d.ts +0 -9
- package/dist/fs-CEhcjuN6.d.ts.map +0 -1
- package/dist/fs-CfE8CHf_.d.cts +0 -9
- package/dist/fs-CfE8CHf_.d.cts.map +0 -1
- package/dist/fs-DKHYTPua.cjs +0 -18
- package/dist/native-runtime-BoqybBBf.js +0 -18
- package/dist/native-runtime-BoqybBBf.js.map +0 -1
- package/dist/native.d.cts.map +0 -1
- package/dist/native.d.ts.map +0 -1
- package/dist/native.js.map +0 -1
- package/dist/runtime.d.cts.map +0 -1
- package/dist/runtime.d.ts.map +0 -1
package/dist/native.cjs
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
const require_native_runtime = require('./native-runtime-
|
|
1
|
+
const require_native_runtime = require('./native-runtime-CsXnXkQn.cjs');
|
|
2
|
+
const require_native_macos = require('./native-macos-DLwo_ii9.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/native.ts
|
|
5
|
+
function objectValue(value, key) {
|
|
6
|
+
if (!value || typeof value !== "object") return;
|
|
7
|
+
return value[key];
|
|
8
|
+
}
|
|
9
|
+
function setObjectValue(value, key, nextValue) {
|
|
10
|
+
if (!value || typeof value !== "object") return false;
|
|
11
|
+
const record = value;
|
|
12
|
+
record[key] = nextValue;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
4
15
|
function colorFromHex(hex) {
|
|
5
16
|
const value = hex.trim().replace(/^#/, "");
|
|
6
17
|
const normalized = value.length === 3 ? value.split("").map((part) => `${part}${part}`).join("") : value;
|
|
@@ -9,7 +20,7 @@ function colorFromHex(hex) {
|
|
|
9
20
|
const red = (number >> 16 & 255) / 255;
|
|
10
21
|
const green = (number >> 8 & 255) / 255;
|
|
11
22
|
const blue = (number & 255) / 255;
|
|
12
|
-
return
|
|
23
|
+
return UIColor.colorWithRedGreenBlueAlpha(red, green, blue, 1);
|
|
13
24
|
}
|
|
14
25
|
function forEachNativeObject(collection, callback) {
|
|
15
26
|
const values = collection?.allObjects ?? collection;
|
|
@@ -17,76 +28,69 @@ function forEachNativeObject(collection, callback) {
|
|
|
17
28
|
values.forEach(callback);
|
|
18
29
|
return;
|
|
19
30
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
31
|
+
const iterableValues = values;
|
|
32
|
+
const count = Number(iterableValues?.count ?? 0);
|
|
33
|
+
for (let index = 0; index < count; index += 1) callback(iterableValues?.objectAtIndex?.(index));
|
|
22
34
|
}
|
|
23
35
|
async function runOnUI(callback) {
|
|
24
36
|
return require_native_runtime.ensureNativeScript().runOnUI(callback);
|
|
25
37
|
}
|
|
26
38
|
async function setTintColor(hex) {
|
|
27
39
|
await runOnUI(() => {
|
|
28
|
-
const api = require_native_runtime.globals();
|
|
29
40
|
const color = colorFromHex(hex);
|
|
30
|
-
const application =
|
|
41
|
+
const application = UIApplication.sharedApplication;
|
|
31
42
|
if (application.keyWindow) application.keyWindow.tintColor = color;
|
|
32
43
|
forEachNativeObject(application.connectedScenes, (scene) => {
|
|
33
|
-
forEachNativeObject(scene
|
|
34
|
-
window.tintColor = color;
|
|
44
|
+
forEachNativeObject(objectValue(scene, "windows"), (window) => {
|
|
45
|
+
if (window && typeof window === "object" && "tintColor" in window) window.tintColor = color;
|
|
35
46
|
});
|
|
36
47
|
});
|
|
37
48
|
});
|
|
38
49
|
}
|
|
39
50
|
async function setWindowTitle(title) {
|
|
40
51
|
await runOnUI(() => {
|
|
41
|
-
const
|
|
42
|
-
const application = api.UIApplication.sharedApplication;
|
|
52
|
+
const application = UIApplication.sharedApplication;
|
|
43
53
|
forEachNativeObject(application.connectedScenes, (scene) => {
|
|
44
|
-
|
|
54
|
+
setObjectValue(scene, "title", title);
|
|
45
55
|
});
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
56
|
+
const appKitApplication = require_native_macos.macOSApplication();
|
|
57
|
+
const appKitWindow = appKitApplication?.keyWindow ?? appKitApplication?.mainWindow;
|
|
58
|
+
if (appKitWindow) setObjectValue(appKitWindow, "title", title);
|
|
49
59
|
});
|
|
50
60
|
}
|
|
51
61
|
function documentsDirectoryPath() {
|
|
52
|
-
const
|
|
53
|
-
if (!api.NSSearchPathForDirectoriesInDomains) throw new Error("Native FileManager unavailable: NSSearchPathForDirectoriesInDomains missing");
|
|
54
|
-
if (typeof api.NSSearchPathDirectory?.Document !== "number") throw new Error("Native FileManager unavailable: NSSearchPathDirectory.Document missing");
|
|
55
|
-
if (typeof api.NSSearchPathDomainMask?.UserDomain !== "number") throw new Error("Native FileManager unavailable: NSSearchPathDomainMask.UserDomain missing");
|
|
56
|
-
const path = api.NSSearchPathForDirectoriesInDomains(api.NSSearchPathDirectory.Document, api.NSSearchPathDomainMask.UserDomain, true)?.objectAtIndex(0);
|
|
62
|
+
const path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.Document, NSSearchPathDomainMask.UserDomain, true)?.objectAtIndex(0);
|
|
57
63
|
if (typeof path !== "string") throw new Error("Native FileManager unavailable: Documents directory missing");
|
|
58
64
|
return path;
|
|
59
65
|
}
|
|
60
66
|
function documentPath(name) {
|
|
61
|
-
return
|
|
67
|
+
return NSString.stringWithString(documentsDirectoryPath()).stringByAppendingPathComponent(name);
|
|
62
68
|
}
|
|
63
69
|
async function writeDocumentText(name, text) {
|
|
64
70
|
await runOnUI(() => {
|
|
65
|
-
const api = require_native_runtime.globals();
|
|
66
71
|
const path = documentPath(name);
|
|
67
|
-
if (!
|
|
72
|
+
if (!NSString.stringWithString(text).writeToFileAtomicallyEncodingError(path, true, NSUTF8StringEncoding, null)) throw new Error(`Failed to write native document at ${path}`);
|
|
68
73
|
});
|
|
69
74
|
}
|
|
70
75
|
async function readDocumentText(name) {
|
|
71
76
|
let text = "";
|
|
72
77
|
await runOnUI(() => {
|
|
73
|
-
|
|
74
|
-
text = String(api.NSString.stringWithContentsOfFileEncodingError(documentPath(name), api.NSUTF8StringEncoding, null));
|
|
78
|
+
text = String(NSString.stringWithContentsOfFileEncodingError(documentPath(name), NSUTF8StringEncoding, null));
|
|
75
79
|
});
|
|
76
80
|
return text;
|
|
77
81
|
}
|
|
78
82
|
async function documentExists(name) {
|
|
79
83
|
let exists = false;
|
|
80
84
|
await runOnUI(() => {
|
|
81
|
-
const
|
|
82
|
-
exists = Boolean(
|
|
85
|
+
const fileManager = NSFileManager.defaultManager;
|
|
86
|
+
exists = Boolean(fileManager.fileExistsAtPath(documentPath(name)));
|
|
83
87
|
});
|
|
84
88
|
return exists;
|
|
85
89
|
}
|
|
86
90
|
async function listDocuments() {
|
|
87
91
|
const names = [];
|
|
88
92
|
await runOnUI(() => {
|
|
89
|
-
forEachNativeObject(
|
|
93
|
+
forEachNativeObject(NSFileManager.defaultManager.contentsOfDirectoryAtPathError(documentsDirectoryPath(), null), (item) => {
|
|
90
94
|
names.push(String(item));
|
|
91
95
|
});
|
|
92
96
|
});
|
|
@@ -102,13 +106,12 @@ const NativeLabel = require_native_runtime.ensureNativeScript().defineUIKitView(
|
|
|
102
106
|
}
|
|
103
107
|
},
|
|
104
108
|
create() {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
label.
|
|
108
|
-
label.font = api.UIFont.boldSystemFontOfSize(18);
|
|
109
|
+
const label = UILabel.new();
|
|
110
|
+
label.textAlignment = NSTextAlignment.Center;
|
|
111
|
+
label.font = UIFont.boldSystemFontOfSize(18);
|
|
109
112
|
return label;
|
|
110
113
|
},
|
|
111
|
-
update(label, props,
|
|
114
|
+
update(label, props, _previousProps, ctx) {
|
|
112
115
|
label.text = props.text;
|
|
113
116
|
label.textColor = colorFromHex(props.color ?? "#0a84ff");
|
|
114
117
|
ctx?.invalidateLayout();
|
package/dist/native.d.cts
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { t as ensureNativeScript } from "./native-runtime-CbPzrs8j.cjs";
|
|
2
|
+
import * as _nativescript_react_native1 from "@nativescript/react-native";
|
|
2
3
|
|
|
3
|
-
//#region src/native-runtime.d.ts
|
|
4
|
-
declare function ensureNativeScript(): {
|
|
5
|
-
init: typeof _nativescript_react_native0.init;
|
|
6
|
-
install: typeof _nativescript_react_native0.install;
|
|
7
|
-
installGlobals: typeof _nativescript_react_native0.installGlobals;
|
|
8
|
-
isInstalled: typeof _nativescript_react_native0.isInstalled;
|
|
9
|
-
defaultMetadataPath: typeof _nativescript_react_native0.defaultMetadataPath;
|
|
10
|
-
defineUIKitContainer: typeof _nativescript_react_native0.defineUIKitContainer;
|
|
11
|
-
defineUIKitView: typeof _nativescript_react_native0.defineUIKitView;
|
|
12
|
-
defineUIViewController: typeof _nativescript_react_native0.defineUIViewController;
|
|
13
|
-
getRuntimeBackend: typeof _nativescript_react_native0.getRuntimeBackend;
|
|
14
|
-
assertUIKitThread: typeof _nativescript_react_native0.assertUIKitThread;
|
|
15
|
-
createDelegate: typeof _nativescript_react_native0.createDelegate;
|
|
16
|
-
createEventBridge: typeof _nativescript_react_native0.createEventBridge;
|
|
17
|
-
createRetainer: typeof _nativescript_react_native0.createRetainer;
|
|
18
|
-
eventBridge: typeof _nativescript_react_native0.eventBridge;
|
|
19
|
-
getClass: typeof _nativescript_react_native0.getClass;
|
|
20
|
-
getProtocol: typeof _nativescript_react_native0.getProtocol;
|
|
21
|
-
isClassAvailable: typeof _nativescript_react_native0.isClassAvailable;
|
|
22
|
-
isFrameworkLoaded: typeof _nativescript_react_native0.isFrameworkLoaded;
|
|
23
|
-
isMainThread: typeof _nativescript_react_native0.isMainThread;
|
|
24
|
-
jsInvoker: typeof _nativescript_react_native0.jsInvoker;
|
|
25
|
-
loadFramework: typeof _nativescript_react_native0.loadFramework;
|
|
26
|
-
release: typeof _nativescript_react_native0.release;
|
|
27
|
-
retain: typeof _nativescript_react_native0.retain;
|
|
28
|
-
runOnUI: typeof _nativescript_react_native0.runOnUI;
|
|
29
|
-
uiInvoker: typeof _nativescript_react_native0.uiInvoker;
|
|
30
|
-
warnIfNotUIKitThread: typeof _nativescript_react_native0.warnIfNotUIKitThread;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
4
|
//#region src/native.d.ts
|
|
34
5
|
declare function runOnUI<T>(callback: () => T): Promise<void>;
|
|
35
6
|
declare function setTintColor(hex: string): Promise<void>;
|
|
@@ -44,7 +15,7 @@ type NativeLabelProps = {
|
|
|
44
15
|
};
|
|
45
16
|
declare const native: {
|
|
46
17
|
init: typeof ensureNativeScript;
|
|
47
|
-
NativeLabel:
|
|
18
|
+
NativeLabel: _nativescript_react_native1.UIKitViewComponent<NativeLabelProps, UILabel>;
|
|
48
19
|
runOnUI: typeof runOnUI;
|
|
49
20
|
ui: {
|
|
50
21
|
setTintColor: typeof setTintColor;
|
|
@@ -60,5 +31,4 @@ declare const native: {
|
|
|
60
31
|
};
|
|
61
32
|
};
|
|
62
33
|
//#endregion
|
|
63
|
-
export { native };
|
|
64
|
-
//# sourceMappingURL=native.d.cts.map
|
|
34
|
+
export { native };
|
package/dist/native.d.ts
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
|
+
import { t as ensureNativeScript } from "./native-runtime-DxHSrsTX.js";
|
|
1
2
|
import * as _nativescript_react_native0 from "@nativescript/react-native";
|
|
2
3
|
|
|
3
|
-
//#region src/native-runtime.d.ts
|
|
4
|
-
declare function ensureNativeScript(): {
|
|
5
|
-
init: typeof _nativescript_react_native0.init;
|
|
6
|
-
install: typeof _nativescript_react_native0.install;
|
|
7
|
-
installGlobals: typeof _nativescript_react_native0.installGlobals;
|
|
8
|
-
isInstalled: typeof _nativescript_react_native0.isInstalled;
|
|
9
|
-
defaultMetadataPath: typeof _nativescript_react_native0.defaultMetadataPath;
|
|
10
|
-
defineUIKitContainer: typeof _nativescript_react_native0.defineUIKitContainer;
|
|
11
|
-
defineUIKitView: typeof _nativescript_react_native0.defineUIKitView;
|
|
12
|
-
defineUIViewController: typeof _nativescript_react_native0.defineUIViewController;
|
|
13
|
-
getRuntimeBackend: typeof _nativescript_react_native0.getRuntimeBackend;
|
|
14
|
-
assertUIKitThread: typeof _nativescript_react_native0.assertUIKitThread;
|
|
15
|
-
createDelegate: typeof _nativescript_react_native0.createDelegate;
|
|
16
|
-
createEventBridge: typeof _nativescript_react_native0.createEventBridge;
|
|
17
|
-
createRetainer: typeof _nativescript_react_native0.createRetainer;
|
|
18
|
-
eventBridge: typeof _nativescript_react_native0.eventBridge;
|
|
19
|
-
getClass: typeof _nativescript_react_native0.getClass;
|
|
20
|
-
getProtocol: typeof _nativescript_react_native0.getProtocol;
|
|
21
|
-
isClassAvailable: typeof _nativescript_react_native0.isClassAvailable;
|
|
22
|
-
isFrameworkLoaded: typeof _nativescript_react_native0.isFrameworkLoaded;
|
|
23
|
-
isMainThread: typeof _nativescript_react_native0.isMainThread;
|
|
24
|
-
jsInvoker: typeof _nativescript_react_native0.jsInvoker;
|
|
25
|
-
loadFramework: typeof _nativescript_react_native0.loadFramework;
|
|
26
|
-
release: typeof _nativescript_react_native0.release;
|
|
27
|
-
retain: typeof _nativescript_react_native0.retain;
|
|
28
|
-
runOnUI: typeof _nativescript_react_native0.runOnUI;
|
|
29
|
-
uiInvoker: typeof _nativescript_react_native0.uiInvoker;
|
|
30
|
-
warnIfNotUIKitThread: typeof _nativescript_react_native0.warnIfNotUIKitThread;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
4
|
//#region src/native.d.ts
|
|
34
5
|
declare function runOnUI<T>(callback: () => T): Promise<void>;
|
|
35
6
|
declare function setTintColor(hex: string): Promise<void>;
|
|
@@ -44,7 +15,7 @@ type NativeLabelProps = {
|
|
|
44
15
|
};
|
|
45
16
|
declare const native: {
|
|
46
17
|
init: typeof ensureNativeScript;
|
|
47
|
-
NativeLabel: _nativescript_react_native0.UIKitViewComponent<NativeLabelProps,
|
|
18
|
+
NativeLabel: _nativescript_react_native0.UIKitViewComponent<NativeLabelProps, UILabel>;
|
|
48
19
|
runOnUI: typeof runOnUI;
|
|
49
20
|
ui: {
|
|
50
21
|
setTintColor: typeof setTintColor;
|
|
@@ -60,5 +31,4 @@ declare const native: {
|
|
|
60
31
|
};
|
|
61
32
|
};
|
|
62
33
|
//#endregion
|
|
63
|
-
export { native };
|
|
64
|
-
//# sourceMappingURL=native.d.ts.map
|
|
34
|
+
export { native };
|
package/dist/native.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as ensureNativeScript } from "./native-runtime-C85Nuc4F.js";
|
|
2
|
+
import { n as macOSApplication } from "./native-macos-D6p2SmUj.js";
|
|
2
3
|
|
|
3
4
|
//#region src/native.ts
|
|
5
|
+
function objectValue(value, key) {
|
|
6
|
+
if (!value || typeof value !== "object") return;
|
|
7
|
+
return value[key];
|
|
8
|
+
}
|
|
9
|
+
function setObjectValue(value, key, nextValue) {
|
|
10
|
+
if (!value || typeof value !== "object") return false;
|
|
11
|
+
const record = value;
|
|
12
|
+
record[key] = nextValue;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
4
15
|
function colorFromHex(hex) {
|
|
5
16
|
const value = hex.trim().replace(/^#/, "");
|
|
6
17
|
const normalized = value.length === 3 ? value.split("").map((part) => `${part}${part}`).join("") : value;
|
|
@@ -9,7 +20,7 @@ function colorFromHex(hex) {
|
|
|
9
20
|
const red = (number >> 16 & 255) / 255;
|
|
10
21
|
const green = (number >> 8 & 255) / 255;
|
|
11
22
|
const blue = (number & 255) / 255;
|
|
12
|
-
return
|
|
23
|
+
return UIColor.colorWithRedGreenBlueAlpha(red, green, blue, 1);
|
|
13
24
|
}
|
|
14
25
|
function forEachNativeObject(collection, callback) {
|
|
15
26
|
const values = collection?.allObjects ?? collection;
|
|
@@ -17,76 +28,69 @@ function forEachNativeObject(collection, callback) {
|
|
|
17
28
|
values.forEach(callback);
|
|
18
29
|
return;
|
|
19
30
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
31
|
+
const iterableValues = values;
|
|
32
|
+
const count = Number(iterableValues?.count ?? 0);
|
|
33
|
+
for (let index = 0; index < count; index += 1) callback(iterableValues?.objectAtIndex?.(index));
|
|
22
34
|
}
|
|
23
35
|
async function runOnUI(callback) {
|
|
24
36
|
return ensureNativeScript().runOnUI(callback);
|
|
25
37
|
}
|
|
26
38
|
async function setTintColor(hex) {
|
|
27
39
|
await runOnUI(() => {
|
|
28
|
-
const api = globals();
|
|
29
40
|
const color = colorFromHex(hex);
|
|
30
|
-
const application =
|
|
41
|
+
const application = UIApplication.sharedApplication;
|
|
31
42
|
if (application.keyWindow) application.keyWindow.tintColor = color;
|
|
32
43
|
forEachNativeObject(application.connectedScenes, (scene) => {
|
|
33
|
-
forEachNativeObject(scene
|
|
34
|
-
window.tintColor = color;
|
|
44
|
+
forEachNativeObject(objectValue(scene, "windows"), (window) => {
|
|
45
|
+
if (window && typeof window === "object" && "tintColor" in window) window.tintColor = color;
|
|
35
46
|
});
|
|
36
47
|
});
|
|
37
48
|
});
|
|
38
49
|
}
|
|
39
50
|
async function setWindowTitle(title) {
|
|
40
51
|
await runOnUI(() => {
|
|
41
|
-
const
|
|
42
|
-
const application = api.UIApplication.sharedApplication;
|
|
52
|
+
const application = UIApplication.sharedApplication;
|
|
43
53
|
forEachNativeObject(application.connectedScenes, (scene) => {
|
|
44
|
-
|
|
54
|
+
setObjectValue(scene, "title", title);
|
|
45
55
|
});
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
56
|
+
const appKitApplication = macOSApplication();
|
|
57
|
+
const appKitWindow = appKitApplication?.keyWindow ?? appKitApplication?.mainWindow;
|
|
58
|
+
if (appKitWindow) setObjectValue(appKitWindow, "title", title);
|
|
49
59
|
});
|
|
50
60
|
}
|
|
51
61
|
function documentsDirectoryPath() {
|
|
52
|
-
const
|
|
53
|
-
if (!api.NSSearchPathForDirectoriesInDomains) throw new Error("Native FileManager unavailable: NSSearchPathForDirectoriesInDomains missing");
|
|
54
|
-
if (typeof api.NSSearchPathDirectory?.Document !== "number") throw new Error("Native FileManager unavailable: NSSearchPathDirectory.Document missing");
|
|
55
|
-
if (typeof api.NSSearchPathDomainMask?.UserDomain !== "number") throw new Error("Native FileManager unavailable: NSSearchPathDomainMask.UserDomain missing");
|
|
56
|
-
const path = api.NSSearchPathForDirectoriesInDomains(api.NSSearchPathDirectory.Document, api.NSSearchPathDomainMask.UserDomain, true)?.objectAtIndex(0);
|
|
62
|
+
const path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.Document, NSSearchPathDomainMask.UserDomain, true)?.objectAtIndex(0);
|
|
57
63
|
if (typeof path !== "string") throw new Error("Native FileManager unavailable: Documents directory missing");
|
|
58
64
|
return path;
|
|
59
65
|
}
|
|
60
66
|
function documentPath(name) {
|
|
61
|
-
return
|
|
67
|
+
return NSString.stringWithString(documentsDirectoryPath()).stringByAppendingPathComponent(name);
|
|
62
68
|
}
|
|
63
69
|
async function writeDocumentText(name, text) {
|
|
64
70
|
await runOnUI(() => {
|
|
65
|
-
const api = globals();
|
|
66
71
|
const path = documentPath(name);
|
|
67
|
-
if (!
|
|
72
|
+
if (!NSString.stringWithString(text).writeToFileAtomicallyEncodingError(path, true, NSUTF8StringEncoding, null)) throw new Error(`Failed to write native document at ${path}`);
|
|
68
73
|
});
|
|
69
74
|
}
|
|
70
75
|
async function readDocumentText(name) {
|
|
71
76
|
let text = "";
|
|
72
77
|
await runOnUI(() => {
|
|
73
|
-
|
|
74
|
-
text = String(api.NSString.stringWithContentsOfFileEncodingError(documentPath(name), api.NSUTF8StringEncoding, null));
|
|
78
|
+
text = String(NSString.stringWithContentsOfFileEncodingError(documentPath(name), NSUTF8StringEncoding, null));
|
|
75
79
|
});
|
|
76
80
|
return text;
|
|
77
81
|
}
|
|
78
82
|
async function documentExists(name) {
|
|
79
83
|
let exists = false;
|
|
80
84
|
await runOnUI(() => {
|
|
81
|
-
const
|
|
82
|
-
exists = Boolean(
|
|
85
|
+
const fileManager = NSFileManager.defaultManager;
|
|
86
|
+
exists = Boolean(fileManager.fileExistsAtPath(documentPath(name)));
|
|
83
87
|
});
|
|
84
88
|
return exists;
|
|
85
89
|
}
|
|
86
90
|
async function listDocuments() {
|
|
87
91
|
const names = [];
|
|
88
92
|
await runOnUI(() => {
|
|
89
|
-
forEachNativeObject(
|
|
93
|
+
forEachNativeObject(NSFileManager.defaultManager.contentsOfDirectoryAtPathError(documentsDirectoryPath(), null), (item) => {
|
|
90
94
|
names.push(String(item));
|
|
91
95
|
});
|
|
92
96
|
});
|
|
@@ -102,13 +106,12 @@ const NativeLabel = ensureNativeScript().defineUIKitView({
|
|
|
102
106
|
}
|
|
103
107
|
},
|
|
104
108
|
create() {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
label.
|
|
108
|
-
label.font = api.UIFont.boldSystemFontOfSize(18);
|
|
109
|
+
const label = UILabel.new();
|
|
110
|
+
label.textAlignment = NSTextAlignment.Center;
|
|
111
|
+
label.font = UIFont.boldSystemFontOfSize(18);
|
|
109
112
|
return label;
|
|
110
113
|
},
|
|
111
|
-
update(label, props,
|
|
114
|
+
update(label, props, _previousProps, ctx) {
|
|
112
115
|
label.text = props.text;
|
|
113
116
|
label.textColor = colorFromHex(props.color ?? "#0a84ff");
|
|
114
117
|
ctx?.invalidateLayout();
|
|
@@ -129,5 +132,4 @@ const native = {
|
|
|
129
132
|
};
|
|
130
133
|
|
|
131
134
|
//#endregion
|
|
132
|
-
export { native };
|
|
133
|
-
//# sourceMappingURL=native.js.map
|
|
135
|
+
export { native };
|
package/dist/runtime.d.cts
CHANGED
package/dist/runtime.d.ts
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/schema.d.ts
|
|
2
|
+
type FieldValue = string | number | boolean;
|
|
3
|
+
type FieldToken = 'string' | 'number' | 'boolean';
|
|
4
|
+
type FieldDefault<T extends FieldValue = FieldValue> = () => T;
|
|
5
|
+
type FieldSchema = FieldToken | FieldDefault;
|
|
6
|
+
type SchemaShape = Record<string, FieldSchema>;
|
|
7
|
+
interface SchemaIssue {
|
|
8
|
+
message: string;
|
|
9
|
+
path?: ReadonlyArray<PropertyKey | {
|
|
10
|
+
key: PropertyKey;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
type SchemaResult<Output> = {
|
|
14
|
+
value: Output;
|
|
15
|
+
issues?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
issues: ReadonlyArray<SchemaIssue>;
|
|
18
|
+
};
|
|
19
|
+
interface StandardSchema<Input = unknown, Output = Input> {
|
|
20
|
+
readonly '~standard': {
|
|
21
|
+
readonly version: 1;
|
|
22
|
+
readonly vendor: 'bleam';
|
|
23
|
+
readonly validate: (value: unknown) => SchemaResult<Output>;
|
|
24
|
+
readonly types?: {
|
|
25
|
+
readonly input: Input;
|
|
26
|
+
readonly output: Output;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
type TokenValue<T extends FieldToken> = T extends 'string' ? string : T extends 'number' ? number : boolean;
|
|
31
|
+
type DefaultValue<T> = T extends (() => infer Value) ? Value extends FieldValue ? Value : never : never;
|
|
32
|
+
type TokenKeys<Shape extends SchemaShape> = { [Key in keyof Shape]: Shape[Key] extends FieldToken ? Key : never }[keyof Shape];
|
|
33
|
+
type DefaultKeys<Shape extends SchemaShape> = { [Key in keyof Shape]: Shape[Key] extends FieldDefault ? Key : never }[keyof Shape];
|
|
34
|
+
type FieldInput<Field extends FieldSchema> = Field extends FieldToken ? TokenValue<Field> : Field extends FieldDefault ? DefaultValue<Field> : never;
|
|
35
|
+
type SchemaInput<Shape extends SchemaShape> = { [Key in keyof Shape]?: FieldInput<Shape[Key]> };
|
|
36
|
+
type SchemaOutput<Shape extends SchemaShape> = { [Key in TokenKeys<Shape>]?: Shape[Key] extends FieldToken ? TokenValue<Shape[Key]> : never } & { [Key in DefaultKeys<Shape>]: Shape[Key] extends FieldDefault ? DefaultValue<Shape[Key]> : never };
|
|
37
|
+
type InferInput<Value$1 extends StandardSchema> = NonNullable<Value$1['~standard']['types']>['input'];
|
|
38
|
+
type InferOutput<Value$1 extends StandardSchema> = NonNullable<Value$1['~standard']['types']>['output'];
|
|
39
|
+
declare class SchemaError extends Error {
|
|
40
|
+
readonly issues: ReadonlyArray<SchemaIssue>;
|
|
41
|
+
constructor(issues: ReadonlyArray<SchemaIssue>);
|
|
42
|
+
}
|
|
43
|
+
interface BleamSchema<Input, Output> extends StandardSchema<Input, Output> {
|
|
44
|
+
parse(value: unknown): Output;
|
|
45
|
+
safeParse(value: unknown): SchemaResult<Output>;
|
|
46
|
+
toJSONSchema(): SchemaJSONSchema;
|
|
47
|
+
transform<NextOutput>(transform: (value: Output) => NextOutput): BleamSchema<Input, NextOutput>;
|
|
48
|
+
}
|
|
49
|
+
type SchemaJSONSchema = {
|
|
50
|
+
type: 'object';
|
|
51
|
+
properties: Record<string, {
|
|
52
|
+
type: FieldToken;
|
|
53
|
+
}>;
|
|
54
|
+
required: string[];
|
|
55
|
+
};
|
|
56
|
+
declare function schema<Shape extends SchemaShape>(shape: Shape): BleamSchema<SchemaInput<Shape>, SchemaOutput<Shape>>;
|
|
57
|
+
//#endregion
|
|
58
|
+
export { FieldValue as a, SchemaError as c, SchemaJSONSchema as d, SchemaOutput as f, schema as g, StandardSchema as h, FieldToken as i, SchemaInput as l, SchemaShape as m, FieldDefault as n, InferInput as o, SchemaResult as p, FieldSchema as r, InferOutput as s, BleamSchema as t, SchemaIssue as u };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//#region src/schema.ts
|
|
2
|
+
var SchemaError = class extends Error {
|
|
3
|
+
constructor(issues) {
|
|
4
|
+
super(issues.map((issue) => issue.message).join("\n"));
|
|
5
|
+
this.issues = issues;
|
|
6
|
+
this.name = "SchemaError";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
function tokenMatches(token, value) {
|
|
10
|
+
return typeof value === token;
|
|
11
|
+
}
|
|
12
|
+
function issueFor(key, expected) {
|
|
13
|
+
return {
|
|
14
|
+
message: `Expected ${key} to be ${expected}`,
|
|
15
|
+
path: [key]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function parseShape(shape, value) {
|
|
19
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return { issues: [{ message: "Expected object" }] };
|
|
20
|
+
const input = value;
|
|
21
|
+
const output = {};
|
|
22
|
+
const issues = [];
|
|
23
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
24
|
+
const inputValue = input[key];
|
|
25
|
+
if (typeof field === "function") {
|
|
26
|
+
const defaultValue = field();
|
|
27
|
+
const expected = typeof defaultValue;
|
|
28
|
+
if (inputValue === void 0) {
|
|
29
|
+
output[key] = defaultValue;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (tokenMatches(expected, inputValue)) {
|
|
33
|
+
output[key] = inputValue;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
issues.push(issueFor(key, expected));
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (inputValue === void 0) continue;
|
|
40
|
+
if (tokenMatches(field, inputValue)) {
|
|
41
|
+
output[key] = inputValue;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
issues.push(issueFor(key, field));
|
|
45
|
+
}
|
|
46
|
+
if (issues.length > 0) return { issues };
|
|
47
|
+
return { value: output };
|
|
48
|
+
}
|
|
49
|
+
function createSchema(validate, jsonSchema) {
|
|
50
|
+
return {
|
|
51
|
+
"~standard": {
|
|
52
|
+
version: 1,
|
|
53
|
+
vendor: "bleam",
|
|
54
|
+
validate
|
|
55
|
+
},
|
|
56
|
+
parse(value) {
|
|
57
|
+
const result = validate(value);
|
|
58
|
+
if (result.issues !== void 0) throw new SchemaError(result.issues);
|
|
59
|
+
return result.value;
|
|
60
|
+
},
|
|
61
|
+
safeParse: validate,
|
|
62
|
+
toJSONSchema: jsonSchema,
|
|
63
|
+
transform(transform) {
|
|
64
|
+
return createSchema((value) => {
|
|
65
|
+
const result = validate(value);
|
|
66
|
+
if (result.issues !== void 0) return result;
|
|
67
|
+
return { value: transform(result.value) };
|
|
68
|
+
}, jsonSchema);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function schema(shape) {
|
|
73
|
+
return createSchema((value) => parseShape(shape, value), () => {
|
|
74
|
+
const properties = {};
|
|
75
|
+
const required = [];
|
|
76
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
77
|
+
if (typeof field === "function") properties[key] = { type: typeof field() };
|
|
78
|
+
else properties[key] = { type: field };
|
|
79
|
+
required.push(key);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
type: "object",
|
|
83
|
+
properties,
|
|
84
|
+
required
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { schema as n, SchemaError as t };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/schema.ts
|
|
3
|
+
var SchemaError = class extends Error {
|
|
4
|
+
constructor(issues) {
|
|
5
|
+
super(issues.map((issue) => issue.message).join("\n"));
|
|
6
|
+
this.issues = issues;
|
|
7
|
+
this.name = "SchemaError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function tokenMatches(token, value) {
|
|
11
|
+
return typeof value === token;
|
|
12
|
+
}
|
|
13
|
+
function issueFor(key, expected) {
|
|
14
|
+
return {
|
|
15
|
+
message: `Expected ${key} to be ${expected}`,
|
|
16
|
+
path: [key]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function parseShape(shape, value) {
|
|
20
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return { issues: [{ message: "Expected object" }] };
|
|
21
|
+
const input = value;
|
|
22
|
+
const output = {};
|
|
23
|
+
const issues = [];
|
|
24
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
25
|
+
const inputValue = input[key];
|
|
26
|
+
if (typeof field === "function") {
|
|
27
|
+
const defaultValue = field();
|
|
28
|
+
const expected = typeof defaultValue;
|
|
29
|
+
if (inputValue === void 0) {
|
|
30
|
+
output[key] = defaultValue;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (tokenMatches(expected, inputValue)) {
|
|
34
|
+
output[key] = inputValue;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
issues.push(issueFor(key, expected));
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (inputValue === void 0) continue;
|
|
41
|
+
if (tokenMatches(field, inputValue)) {
|
|
42
|
+
output[key] = inputValue;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
issues.push(issueFor(key, field));
|
|
46
|
+
}
|
|
47
|
+
if (issues.length > 0) return { issues };
|
|
48
|
+
return { value: output };
|
|
49
|
+
}
|
|
50
|
+
function createSchema(validate, jsonSchema) {
|
|
51
|
+
return {
|
|
52
|
+
"~standard": {
|
|
53
|
+
version: 1,
|
|
54
|
+
vendor: "bleam",
|
|
55
|
+
validate
|
|
56
|
+
},
|
|
57
|
+
parse(value) {
|
|
58
|
+
const result = validate(value);
|
|
59
|
+
if (result.issues !== void 0) throw new SchemaError(result.issues);
|
|
60
|
+
return result.value;
|
|
61
|
+
},
|
|
62
|
+
safeParse: validate,
|
|
63
|
+
toJSONSchema: jsonSchema,
|
|
64
|
+
transform(transform) {
|
|
65
|
+
return createSchema((value) => {
|
|
66
|
+
const result = validate(value);
|
|
67
|
+
if (result.issues !== void 0) return result;
|
|
68
|
+
return { value: transform(result.value) };
|
|
69
|
+
}, jsonSchema);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function schema(shape) {
|
|
74
|
+
return createSchema((value) => parseShape(shape, value), () => {
|
|
75
|
+
const properties = {};
|
|
76
|
+
const required = [];
|
|
77
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
78
|
+
if (typeof field === "function") properties[key] = { type: typeof field() };
|
|
79
|
+
else properties[key] = { type: field };
|
|
80
|
+
required.push(key);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
type: "object",
|
|
84
|
+
properties,
|
|
85
|
+
required
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
Object.defineProperty(exports, 'SchemaError', {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return SchemaError;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, 'schema', {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () {
|
|
100
|
+
return schema;
|
|
101
|
+
}
|
|
102
|
+
});
|