bleam 0.0.1 → 0.0.3

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.
Files changed (84) hide show
  1. package/dist/app.cjs +11 -0
  2. package/dist/app.d.cts +7 -0
  3. package/dist/app.d.cts.map +1 -0
  4. package/dist/app.d.ts +7 -0
  5. package/dist/app.d.ts.map +1 -0
  6. package/dist/app.js +10 -0
  7. package/dist/app.js.map +1 -0
  8. package/dist/bundler.cjs +0 -0
  9. package/dist/bundler.d.cts +28 -0
  10. package/dist/bundler.d.cts.map +1 -0
  11. package/dist/bundler.d.ts +28 -0
  12. package/dist/bundler.d.ts.map +1 -0
  13. package/dist/bundler.js +1 -0
  14. package/dist/chunk-CUT6urMc.cjs +30 -0
  15. package/dist/cli.cjs +477 -0
  16. package/dist/cli.d.cts +1 -0
  17. package/dist/cli.d.ts +1 -0
  18. package/dist/cli.js +470 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/config.cjs +26 -0
  21. package/dist/config.d.cts +28 -0
  22. package/dist/config.d.cts.map +1 -0
  23. package/dist/config.d.ts +28 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +25 -0
  26. package/dist/config.js.map +1 -0
  27. package/dist/crypto-BNhWeXMj.cjs +15 -0
  28. package/dist/crypto-Bg8cD8wX.d.cts +8 -0
  29. package/dist/crypto-Bg8cD8wX.d.cts.map +1 -0
  30. package/dist/crypto-CCA_hvao.js +11 -0
  31. package/dist/crypto-CCA_hvao.js.map +1 -0
  32. package/dist/crypto-IOzbNoJD.d.ts +8 -0
  33. package/dist/crypto-IOzbNoJD.d.ts.map +1 -0
  34. package/dist/crypto.cjs +4 -0
  35. package/dist/crypto.d.cts +2 -0
  36. package/dist/crypto.d.ts +2 -0
  37. package/dist/crypto.js +4 -0
  38. package/dist/dev-protocol.cjs +16 -0
  39. package/dist/dev-protocol.d.cts +16 -0
  40. package/dist/dev-protocol.d.cts.map +1 -0
  41. package/dist/dev-protocol.d.ts +16 -0
  42. package/dist/dev-protocol.d.ts.map +1 -0
  43. package/dist/dev-protocol.js +14 -0
  44. package/dist/dev-protocol.js.map +1 -0
  45. package/dist/fs-BK7joD1g.js +13 -0
  46. package/dist/fs-BK7joD1g.js.map +1 -0
  47. package/dist/fs-CEhcjuN6.d.ts +9 -0
  48. package/dist/fs-CEhcjuN6.d.ts.map +1 -0
  49. package/dist/fs-CfE8CHf_.d.cts +9 -0
  50. package/dist/fs-CfE8CHf_.d.cts.map +1 -0
  51. package/dist/fs-DKHYTPua.cjs +18 -0
  52. package/dist/fs.cjs +3 -0
  53. package/dist/fs.d.cts +2 -0
  54. package/dist/fs.d.ts +2 -0
  55. package/dist/fs.js +3 -0
  56. package/dist/index.cjs +6 -0
  57. package/dist/index.d.cts +3 -0
  58. package/dist/index.d.ts +3 -0
  59. package/dist/index.js +5 -0
  60. package/dist/native-runtime-BoqybBBf.js +18 -0
  61. package/dist/native-runtime-BoqybBBf.js.map +1 -0
  62. package/dist/native-runtime-CdeT0JyQ.cjs +30 -0
  63. package/dist/native.cjs +132 -0
  64. package/dist/native.d.cts +64 -0
  65. package/dist/native.d.cts.map +1 -0
  66. package/dist/native.d.ts +64 -0
  67. package/dist/native.d.ts.map +1 -0
  68. package/dist/native.js +133 -0
  69. package/dist/native.js.map +1 -0
  70. package/dist/runtime.cjs +0 -0
  71. package/dist/runtime.d.cts +14 -0
  72. package/dist/runtime.d.cts.map +1 -0
  73. package/dist/runtime.d.ts +14 -0
  74. package/dist/runtime.d.ts.map +1 -0
  75. package/dist/runtime.js +1 -0
  76. package/metro-config.cjs +75 -0
  77. package/package.json +81 -22
  78. package/templates/basic/app.config.ts +3 -0
  79. package/templates/basic/app.tsx +18 -0
  80. package/tsconfig.base.json +7 -0
  81. package/tsconfig.json +3 -0
  82. package/README.md +0 -1
  83. package/dist/index.d.mts +0 -9914
  84. package/dist/index.mjs +0 -1259
@@ -0,0 +1,15 @@
1
+ const require_native_runtime = require('./native-runtime-CdeT0JyQ.cjs');
2
+
3
+ //#region src/crypto.ts
4
+ const crypto = { randomUUID() {
5
+ require_native_runtime.ensureNativeScript();
6
+ return String(require_native_runtime.globals().NSUUID.UUID().UUIDString).toLowerCase();
7
+ } };
8
+
9
+ //#endregion
10
+ Object.defineProperty(exports, 'crypto', {
11
+ enumerable: true,
12
+ get: function () {
13
+ return crypto;
14
+ }
15
+ });
@@ -0,0 +1,8 @@
1
+ //#region src/crypto.d.ts
2
+ interface BleamCrypto {
3
+ randomUUID(): string;
4
+ }
5
+ declare const crypto: BleamCrypto;
6
+ //#endregion
7
+ export { crypto as n, BleamCrypto as t };
8
+ //# sourceMappingURL=crypto-Bg8cD8wX.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-Bg8cD8wX.d.cts","names":[],"sources":["../src/crypto.ts"],"sourcesContent":[],"mappings":";UAEiB,WAAA;EAAA,UAAA,EAAA,EAAW,MAAA;AAI5B;cAAa,QAAQ"}
@@ -0,0 +1,11 @@
1
+ import { n as globals, t as ensureNativeScript } from "./native-runtime-BoqybBBf.js";
2
+
3
+ //#region src/crypto.ts
4
+ const crypto = { randomUUID() {
5
+ ensureNativeScript();
6
+ return String(globals().NSUUID.UUID().UUIDString).toLowerCase();
7
+ } };
8
+
9
+ //#endregion
10
+ export { crypto as t };
11
+ //# sourceMappingURL=crypto-CCA_hvao.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-CCA_hvao.js","names":["crypto: BleamCrypto"],"sources":["../src/crypto.ts"],"sourcesContent":["import { ensureNativeScript, globals } from './native-runtime'\n\nexport interface BleamCrypto {\n randomUUID(): string\n}\n\nexport const crypto: BleamCrypto = {\n randomUUID() {\n ensureNativeScript()\n return String(globals().NSUUID.UUID().UUIDString).toLowerCase()\n },\n}\n"],"mappings":";;;AAMA,MAAaA,SAAsB,EACjC,aAAa;AACX,qBAAoB;AACpB,QAAO,OAAO,SAAS,CAAC,OAAO,MAAM,CAAC,WAAW,CAAC,aAAa;GAElE"}
@@ -0,0 +1,8 @@
1
+ //#region src/crypto.d.ts
2
+ interface BleamCrypto {
3
+ randomUUID(): string;
4
+ }
5
+ declare const crypto: BleamCrypto;
6
+ //#endregion
7
+ export { crypto as n, BleamCrypto as t };
8
+ //# sourceMappingURL=crypto-IOzbNoJD.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-IOzbNoJD.d.ts","names":[],"sources":["../src/crypto.ts"],"sourcesContent":[],"mappings":";UAEiB,WAAA;EAAA,UAAA,EAAA,EAAW,MAAA;AAI5B;cAAa,QAAQ"}
@@ -0,0 +1,4 @@
1
+ require('./native-runtime-CdeT0JyQ.cjs');
2
+ const require_crypto = require('./crypto-BNhWeXMj.cjs');
3
+
4
+ exports.crypto = require_crypto.crypto;
@@ -0,0 +1,2 @@
1
+ import { n as crypto, t as BleamCrypto } from "./crypto-Bg8cD8wX.cjs";
2
+ export { BleamCrypto, crypto };
@@ -0,0 +1,2 @@
1
+ import { n as crypto, t as BleamCrypto } from "./crypto-IOzbNoJD.js";
2
+ export { BleamCrypto, crypto };
package/dist/crypto.js ADDED
@@ -0,0 +1,4 @@
1
+ import "./native-runtime-BoqybBBf.js";
2
+ import { t as crypto } from "./crypto-CCA_hvao.js";
3
+
4
+ export { crypto };
@@ -0,0 +1,16 @@
1
+
2
+ //#region src/dev-protocol.ts
3
+ const BLEAM_MANIFEST_PATH = "/bleam/manifest.json";
4
+ function createBleamDevBundleUrl(origin) {
5
+ return `${origin}/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&minify=false&runModule=true`;
6
+ }
7
+ function isBleamManifest(value) {
8
+ if (!value || typeof value !== "object") return false;
9
+ const manifest = value;
10
+ return typeof manifest.name === "string" && typeof manifest.sdkVersion === "string" && typeof manifest.runtimeVersion === "string" && manifest.platform === "macos" && typeof manifest.bundleUrl === "string" && typeof manifest.dev === "boolean";
11
+ }
12
+
13
+ //#endregion
14
+ exports.BLEAM_MANIFEST_PATH = BLEAM_MANIFEST_PATH;
15
+ exports.createBleamDevBundleUrl = createBleamDevBundleUrl;
16
+ exports.isBleamManifest = isBleamManifest;
@@ -0,0 +1,16 @@
1
+ //#region src/dev-protocol.d.ts
2
+ interface BleamManifest {
3
+ name: string;
4
+ sdkVersion: string;
5
+ runtimeVersion: string;
6
+ platform: 'macos';
7
+ bundleUrl: string;
8
+ assetsUrl?: string;
9
+ dev: boolean;
10
+ }
11
+ declare const BLEAM_MANIFEST_PATH = "/bleam/manifest.json";
12
+ declare function createBleamDevBundleUrl(origin: string): string;
13
+ declare function isBleamManifest(value: unknown): value is BleamManifest;
14
+ //#endregion
15
+ export { BLEAM_MANIFEST_PATH, BleamManifest, createBleamDevBundleUrl, isBleamManifest };
16
+ //# sourceMappingURL=dev-protocol.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-protocol.d.cts","names":[],"sources":["../src/dev-protocol.ts"],"sourcesContent":[],"mappings":";UAAiB,aAAA;EAAA,IAAA,EAAA,MAAA;EAUJ,UAAA,EAAA,MAAA;EAEG,cAAA,EAAA,MAAA;EAIA,QAAA,EAAA,OAAA;;;;;cANH,mBAAA;iBAEG,uBAAA;iBAIA,eAAA,2BAA0C"}
@@ -0,0 +1,16 @@
1
+ //#region src/dev-protocol.d.ts
2
+ interface BleamManifest {
3
+ name: string;
4
+ sdkVersion: string;
5
+ runtimeVersion: string;
6
+ platform: 'macos';
7
+ bundleUrl: string;
8
+ assetsUrl?: string;
9
+ dev: boolean;
10
+ }
11
+ declare const BLEAM_MANIFEST_PATH = "/bleam/manifest.json";
12
+ declare function createBleamDevBundleUrl(origin: string): string;
13
+ declare function isBleamManifest(value: unknown): value is BleamManifest;
14
+ //#endregion
15
+ export { BLEAM_MANIFEST_PATH, BleamManifest, createBleamDevBundleUrl, isBleamManifest };
16
+ //# sourceMappingURL=dev-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-protocol.d.ts","names":[],"sources":["../src/dev-protocol.ts"],"sourcesContent":[],"mappings":";UAAiB,aAAA;EAAA,IAAA,EAAA,MAAA;EAUJ,UAAA,EAAA,MAAA;EAEG,cAAA,EAAA,MAAA;EAIA,QAAA,EAAA,OAAA;;;;;cANH,mBAAA;iBAEG,uBAAA;iBAIA,eAAA,2BAA0C"}
@@ -0,0 +1,14 @@
1
+ //#region src/dev-protocol.ts
2
+ const BLEAM_MANIFEST_PATH = "/bleam/manifest.json";
3
+ function createBleamDevBundleUrl(origin) {
4
+ return `${origin}/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&minify=false&runModule=true`;
5
+ }
6
+ function isBleamManifest(value) {
7
+ if (!value || typeof value !== "object") return false;
8
+ const manifest = value;
9
+ return typeof manifest.name === "string" && typeof manifest.sdkVersion === "string" && typeof manifest.runtimeVersion === "string" && manifest.platform === "macos" && typeof manifest.bundleUrl === "string" && typeof manifest.dev === "boolean";
10
+ }
11
+
12
+ //#endregion
13
+ export { BLEAM_MANIFEST_PATH, createBleamDevBundleUrl, isBleamManifest };
14
+ //# sourceMappingURL=dev-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-protocol.js","names":[],"sources":["../src/dev-protocol.ts"],"sourcesContent":["export interface BleamManifest {\n name: string\n sdkVersion: string\n runtimeVersion: string\n platform: 'macos'\n bundleUrl: string\n assetsUrl?: string\n dev: boolean\n}\n\nexport const BLEAM_MANIFEST_PATH = '/bleam/manifest.json'\n\nexport function createBleamDevBundleUrl(origin: string) {\n return `${origin}/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&minify=false&runModule=true`\n}\n\nexport function isBleamManifest(value: unknown): value is BleamManifest {\n if (!value || typeof value !== 'object') {\n return false\n }\n\n const manifest = value as Partial<BleamManifest>\n\n return (\n typeof manifest.name === 'string' &&\n typeof manifest.sdkVersion === 'string' &&\n typeof manifest.runtimeVersion === 'string' &&\n manifest.platform === 'macos' &&\n typeof manifest.bundleUrl === 'string' &&\n typeof manifest.dev === 'boolean'\n )\n}\n"],"mappings":";AAUA,MAAa,sBAAsB;AAEnC,SAAgB,wBAAwB,QAAgB;AACtD,QAAO,GAAG,OAAO;;AAGnB,SAAgB,gBAAgB,OAAwC;AACtE,KAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO;CAGT,MAAM,WAAW;AAEjB,QACE,OAAO,SAAS,SAAS,YACzB,OAAO,SAAS,eAAe,YAC/B,OAAO,SAAS,mBAAmB,YACnC,SAAS,aAAa,WACtB,OAAO,SAAS,cAAc,YAC9B,OAAO,SAAS,QAAQ"}
@@ -0,0 +1,13 @@
1
+ //#region src/fs.ts
2
+ const fs = {
3
+ readText() {
4
+ throw new Error("bleam/fs is not available in this runtime yet");
5
+ },
6
+ writeText() {
7
+ throw new Error("bleam/fs is not available in this runtime yet");
8
+ }
9
+ };
10
+
11
+ //#endregion
12
+ export { fs as t };
13
+ //# sourceMappingURL=fs-BK7joD1g.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-BK7joD1g.js","names":["fs: BleamFileSystem"],"sources":["../src/fs.ts"],"sourcesContent":["export interface BleamFileSystem {\n readText(path: string): Promise<string>\n writeText(path: string, contents: string): Promise<void>\n}\n\nexport const fs: BleamFileSystem = {\n readText() {\n throw new Error('bleam/fs is not available in this runtime yet')\n },\n writeText() {\n throw new Error('bleam/fs is not available in this runtime yet')\n },\n}\n"],"mappings":";AAKA,MAAaA,KAAsB;CACjC,WAAW;AACT,QAAM,IAAI,MAAM,gDAAgD;;CAElE,YAAY;AACV,QAAM,IAAI,MAAM,gDAAgD;;CAEnE"}
@@ -0,0 +1,9 @@
1
+ //#region src/fs.d.ts
2
+ interface BleamFileSystem {
3
+ readText(path: string): Promise<string>;
4
+ writeText(path: string, contents: string): Promise<void>;
5
+ }
6
+ declare const fs: BleamFileSystem;
7
+ //#endregion
8
+ export { fs as n, BleamFileSystem as t };
9
+ //# sourceMappingURL=fs-CEhcjuN6.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-CEhcjuN6.d.ts","names":[],"sources":["../src/fs.ts"],"sourcesContent":[],"mappings":";UAAiB,eAAA;EAAA,QAAA,CAAA,IAAA,EAAA,MAAe,CAAA,EACN,OAAA,CAAA,MACmB,CAAA;EAGhC,SAOZ,CAAA,IAAA,EAPgB,MAAA,EAAA,QAOhB,EAAA,MAAA,CAAA,EAV4C,OAU5C,CAAA,IAAA,CAAA;;cAPY,IAAI"}
@@ -0,0 +1,9 @@
1
+ //#region src/fs.d.ts
2
+ interface BleamFileSystem {
3
+ readText(path: string): Promise<string>;
4
+ writeText(path: string, contents: string): Promise<void>;
5
+ }
6
+ declare const fs: BleamFileSystem;
7
+ //#endregion
8
+ export { fs as n, BleamFileSystem as t };
9
+ //# sourceMappingURL=fs-CfE8CHf_.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-CfE8CHf_.d.cts","names":[],"sources":["../src/fs.ts"],"sourcesContent":[],"mappings":";UAAiB,eAAA;EAAA,QAAA,CAAA,IAAA,EAAA,MAAe,CAAA,EACN,OAAA,CAAA,MAAA,CACmB;EAGhC,SAOZ,CAAA,IAAA,EAAA,MAPgB,EAAA,QAAA,EAOhB,MAAA,CAAA,EAV4C,OAU5C,CAAA,IAAA,CAAA;;cAPY,IAAI"}
@@ -0,0 +1,18 @@
1
+
2
+ //#region src/fs.ts
3
+ const fs = {
4
+ readText() {
5
+ throw new Error("bleam/fs is not available in this runtime yet");
6
+ },
7
+ writeText() {
8
+ throw new Error("bleam/fs is not available in this runtime yet");
9
+ }
10
+ };
11
+
12
+ //#endregion
13
+ Object.defineProperty(exports, 'fs', {
14
+ enumerable: true,
15
+ get: function () {
16
+ return fs;
17
+ }
18
+ });
package/dist/fs.cjs ADDED
@@ -0,0 +1,3 @@
1
+ const require_fs = require('./fs-DKHYTPua.cjs');
2
+
3
+ exports.fs = require_fs.fs;
package/dist/fs.d.cts ADDED
@@ -0,0 +1,2 @@
1
+ import { n as fs, t as BleamFileSystem } from "./fs-CfE8CHf_.cjs";
2
+ export { BleamFileSystem, fs };
package/dist/fs.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { n as fs, t as BleamFileSystem } from "./fs-CEhcjuN6.js";
2
+ export { BleamFileSystem, fs };
package/dist/fs.js ADDED
@@ -0,0 +1,3 @@
1
+ import { t as fs } from "./fs-BK7joD1g.js";
2
+
3
+ export { fs };
package/dist/index.cjs ADDED
@@ -0,0 +1,6 @@
1
+ require('./native-runtime-CdeT0JyQ.cjs');
2
+ const require_crypto = require('./crypto-BNhWeXMj.cjs');
3
+ const require_fs = require('./fs-DKHYTPua.cjs');
4
+
5
+ exports.crypto = require_crypto.crypto;
6
+ exports.fs = require_fs.fs;
@@ -0,0 +1,3 @@
1
+ import { n as crypto, t as BleamCrypto } from "./crypto-Bg8cD8wX.cjs";
2
+ import { n as fs, t as BleamFileSystem } from "./fs-CfE8CHf_.cjs";
3
+ export { BleamCrypto, BleamFileSystem, crypto, fs };
@@ -0,0 +1,3 @@
1
+ import { n as crypto, t as BleamCrypto } from "./crypto-IOzbNoJD.js";
2
+ import { n as fs, t as BleamFileSystem } from "./fs-CEhcjuN6.js";
3
+ export { BleamCrypto, BleamFileSystem, crypto, fs };
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import "./native-runtime-BoqybBBf.js";
2
+ import { t as crypto } from "./crypto-CCA_hvao.js";
3
+ import { t as fs } from "./fs-BK7joD1g.js";
4
+
5
+ export { crypto, fs };
@@ -0,0 +1,18 @@
1
+ import NativeScript from "@nativescript/react-native";
2
+
3
+ //#region src/native-runtime.ts
4
+ let initialized = false;
5
+ function globals() {
6
+ return globalThis;
7
+ }
8
+ function ensureNativeScript() {
9
+ if (!initialized) {
10
+ NativeScript.init();
11
+ initialized = true;
12
+ }
13
+ return NativeScript;
14
+ }
15
+
16
+ //#endregion
17
+ export { globals as n, ensureNativeScript as t };
18
+ //# sourceMappingURL=native-runtime-BoqybBBf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-runtime-BoqybBBf.js","names":[],"sources":["../src/native-runtime.ts"],"sourcesContent":["import NativeScript from '@nativescript/react-native'\n\nlet initialized = false\n\nexport type NativeGlobals = typeof globalThis & Record<string, any>\n\nexport function globals() {\n return globalThis as NativeGlobals\n}\n\nexport function ensureNativeScript() {\n if (!initialized) {\n NativeScript.init()\n initialized = true\n }\n return NativeScript\n}\n"],"mappings":";;;AAEA,IAAI,cAAc;AAIlB,SAAgB,UAAU;AACxB,QAAO;;AAGT,SAAgB,qBAAqB;AACnC,KAAI,CAAC,aAAa;AAChB,eAAa,MAAM;AACnB,gBAAc;;AAEhB,QAAO"}
@@ -0,0 +1,30 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ let __nativescript_react_native = require("@nativescript/react-native");
3
+ __nativescript_react_native = require_chunk.__toESM(__nativescript_react_native);
4
+
5
+ //#region src/native-runtime.ts
6
+ let initialized = false;
7
+ function globals() {
8
+ return globalThis;
9
+ }
10
+ function ensureNativeScript() {
11
+ if (!initialized) {
12
+ __nativescript_react_native.default.init();
13
+ initialized = true;
14
+ }
15
+ return __nativescript_react_native.default;
16
+ }
17
+
18
+ //#endregion
19
+ Object.defineProperty(exports, 'ensureNativeScript', {
20
+ enumerable: true,
21
+ get: function () {
22
+ return ensureNativeScript;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, 'globals', {
26
+ enumerable: true,
27
+ get: function () {
28
+ return globals;
29
+ }
30
+ });
@@ -0,0 +1,132 @@
1
+ const require_native_runtime = require('./native-runtime-CdeT0JyQ.cjs');
2
+
3
+ //#region src/native.ts
4
+ function colorFromHex(hex) {
5
+ const value = hex.trim().replace(/^#/, "");
6
+ const normalized = value.length === 3 ? value.split("").map((part) => `${part}${part}`).join("") : value;
7
+ if (!/^[\da-f]{6}$/i.test(normalized)) throw new Error(`Invalid native color: ${hex}`);
8
+ const number = Number.parseInt(normalized, 16);
9
+ const red = (number >> 16 & 255) / 255;
10
+ const green = (number >> 8 & 255) / 255;
11
+ const blue = (number & 255) / 255;
12
+ return require_native_runtime.globals().UIColor.colorWithRedGreenBlueAlpha(red, green, blue, 1);
13
+ }
14
+ function forEachNativeObject(collection, callback) {
15
+ const values = collection?.allObjects ?? collection;
16
+ if (Array.isArray(values)) {
17
+ values.forEach(callback);
18
+ return;
19
+ }
20
+ const count = Number(values?.count ?? 0);
21
+ for (let index = 0; index < count; index += 1) callback(values.objectAtIndex(index));
22
+ }
23
+ async function runOnUI(callback) {
24
+ return require_native_runtime.ensureNativeScript().runOnUI(callback);
25
+ }
26
+ async function setTintColor(hex) {
27
+ await runOnUI(() => {
28
+ const api = require_native_runtime.globals();
29
+ const color = colorFromHex(hex);
30
+ const application = api.UIApplication.sharedApplication;
31
+ if (application.keyWindow) application.keyWindow.tintColor = color;
32
+ forEachNativeObject(application.connectedScenes, (scene) => {
33
+ forEachNativeObject(scene.windows, (window) => {
34
+ window.tintColor = color;
35
+ });
36
+ });
37
+ });
38
+ }
39
+ async function setWindowTitle(title) {
40
+ await runOnUI(() => {
41
+ const api = require_native_runtime.globals();
42
+ const application = api.UIApplication.sharedApplication;
43
+ forEachNativeObject(application.connectedScenes, (scene) => {
44
+ if ("title" in scene) scene.title = title;
45
+ });
46
+ const appKit = api.NSApplication?.sharedApplication;
47
+ const window = appKit?.keyWindow ?? appKit?.mainWindow;
48
+ if (window && "title" in window) window.title = title;
49
+ });
50
+ }
51
+ function documentsDirectoryPath() {
52
+ const api = require_native_runtime.globals();
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);
57
+ if (typeof path !== "string") throw new Error("Native FileManager unavailable: Documents directory missing");
58
+ return path;
59
+ }
60
+ function documentPath(name) {
61
+ return require_native_runtime.globals().NSString.stringWithString(documentsDirectoryPath()).stringByAppendingPathComponent(name);
62
+ }
63
+ async function writeDocumentText(name, text) {
64
+ await runOnUI(() => {
65
+ const api = require_native_runtime.globals();
66
+ const path = documentPath(name);
67
+ if (!api.NSString.stringWithString(text).writeToFileAtomicallyEncodingError(path, true, api.NSUTF8StringEncoding, null)) throw new Error(`Failed to write native document at ${path}`);
68
+ });
69
+ }
70
+ async function readDocumentText(name) {
71
+ let text = "";
72
+ await runOnUI(() => {
73
+ const api = require_native_runtime.globals();
74
+ text = String(api.NSString.stringWithContentsOfFileEncodingError(documentPath(name), api.NSUTF8StringEncoding, null));
75
+ });
76
+ return text;
77
+ }
78
+ async function documentExists(name) {
79
+ let exists = false;
80
+ await runOnUI(() => {
81
+ const api = require_native_runtime.globals();
82
+ exists = Boolean(api.NSFileManager.defaultManager.fileExistsAtPath(documentPath(name)));
83
+ });
84
+ return exists;
85
+ }
86
+ async function listDocuments() {
87
+ const names = [];
88
+ await runOnUI(() => {
89
+ forEachNativeObject(require_native_runtime.globals().NSFileManager.defaultManager.contentsOfDirectoryAtPathError(documentsDirectoryPath(), null), (item) => {
90
+ names.push(String(item));
91
+ });
92
+ });
93
+ return names;
94
+ }
95
+ const NativeLabel = require_native_runtime.ensureNativeScript().defineUIKitView({
96
+ name: "NativeLabel",
97
+ layout: {
98
+ sizing: "intrinsic",
99
+ defaultSize: {
100
+ width: 1,
101
+ height: 28
102
+ }
103
+ },
104
+ create() {
105
+ const api = require_native_runtime.globals();
106
+ const label = api.UILabel.new();
107
+ label.textAlignment = api.NSTextAlignment.Center;
108
+ label.font = api.UIFont.boldSystemFontOfSize(18);
109
+ return label;
110
+ },
111
+ update(label, props, previousProps, ctx) {
112
+ label.text = props.text;
113
+ label.textColor = colorFromHex(props.color ?? "#0a84ff");
114
+ ctx?.invalidateLayout();
115
+ }
116
+ });
117
+ const native = {
118
+ init: require_native_runtime.ensureNativeScript,
119
+ NativeLabel,
120
+ runOnUI,
121
+ ui: { setTintColor },
122
+ files: {
123
+ exists: documentExists,
124
+ listDocuments,
125
+ readText: readDocumentText,
126
+ writeText: writeDocumentText
127
+ },
128
+ window: { setTitle: setWindowTitle }
129
+ };
130
+
131
+ //#endregion
132
+ exports.native = native;
@@ -0,0 +1,64 @@
1
+ import * as _nativescript_react_native0 from "@nativescript/react-native";
2
+
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
+ //#region src/native.d.ts
34
+ declare function runOnUI<T>(callback: () => T): Promise<void>;
35
+ declare function setTintColor(hex: string): Promise<void>;
36
+ declare function setWindowTitle(title: string): Promise<void>;
37
+ declare function writeDocumentText(name: string, text: string): Promise<void>;
38
+ declare function readDocumentText(name: string): Promise<string>;
39
+ declare function documentExists(name: string): Promise<boolean>;
40
+ declare function listDocuments(): Promise<string[]>;
41
+ type NativeLabelProps = {
42
+ text: string;
43
+ color?: string;
44
+ };
45
+ declare const native: {
46
+ init: typeof ensureNativeScript;
47
+ NativeLabel: _nativescript_react_native0.UIKitViewComponent<NativeLabelProps, any>;
48
+ runOnUI: typeof runOnUI;
49
+ ui: {
50
+ setTintColor: typeof setTintColor;
51
+ };
52
+ files: {
53
+ exists: typeof documentExists;
54
+ listDocuments: typeof listDocuments;
55
+ readText: typeof readDocumentText;
56
+ writeText: typeof writeDocumentText;
57
+ };
58
+ window: {
59
+ setTitle: typeof setWindowTitle;
60
+ };
61
+ };
62
+ //#endregion
63
+ export { native };
64
+ //# sourceMappingURL=native.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.cts","names":[],"sources":["../src/native-runtime.ts","../src/native.ts"],"sourcesContent":[],"mappings":";;;iBAUgB,kBAAA,CAAA;EAAA,IAAA,EAAA,OAAkB,2BAAA,CAAA,IAAA;EAAA,OAAA,EAAA,0CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCuBnB,2BAA2B,IAAC;iBAI5B,YAAA,eAAwB;AD3BvC,iBC4Ce,cAAA,CD5CmB,KAAA,EAAA,MAAA,CAAA,EC4CS,OD5CT,CAAA,IAAA,CAAA;iBCgGnB,iBAAA,CDhGmB,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,CAAA,ECgGyB,ODhGzB,CAAA,IAAA,CAAA;iBCkHnB,gBAAA,gBAA6B;iBAe7B,cAAA,gBAA2B;iBAW3B,aAAA,CAAA,GAAa;KAevB,gBAAA;;;;cAyBQ"}
@@ -0,0 +1,64 @@
1
+ import * as _nativescript_react_native0 from "@nativescript/react-native";
2
+
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
+ //#region src/native.d.ts
34
+ declare function runOnUI<T>(callback: () => T): Promise<void>;
35
+ declare function setTintColor(hex: string): Promise<void>;
36
+ declare function setWindowTitle(title: string): Promise<void>;
37
+ declare function writeDocumentText(name: string, text: string): Promise<void>;
38
+ declare function readDocumentText(name: string): Promise<string>;
39
+ declare function documentExists(name: string): Promise<boolean>;
40
+ declare function listDocuments(): Promise<string[]>;
41
+ type NativeLabelProps = {
42
+ text: string;
43
+ color?: string;
44
+ };
45
+ declare const native: {
46
+ init: typeof ensureNativeScript;
47
+ NativeLabel: _nativescript_react_native0.UIKitViewComponent<NativeLabelProps, any>;
48
+ runOnUI: typeof runOnUI;
49
+ ui: {
50
+ setTintColor: typeof setTintColor;
51
+ };
52
+ files: {
53
+ exists: typeof documentExists;
54
+ listDocuments: typeof listDocuments;
55
+ readText: typeof readDocumentText;
56
+ writeText: typeof writeDocumentText;
57
+ };
58
+ window: {
59
+ setTitle: typeof setWindowTitle;
60
+ };
61
+ };
62
+ //#endregion
63
+ export { native };
64
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","names":[],"sources":["../src/native-runtime.ts","../src/native.ts"],"sourcesContent":[],"mappings":";;;iBAUgB,kBAAA,CAAA;EAAA,IAAA,EAAA,OAAkB,2BAAA,CAAA,IAAA;EAAA,OAAA,EAAA,0CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCuBnB,2BAA2B,IAAC;iBAI5B,YAAA,eAAwB;AD3BvC,iBC4Ce,cAAA,CD5CmB,KAAA,EAAA,MAAA,CAAA,EC4CS,OD5CT,CAAA,IAAA,CAAA;iBCgGnB,iBAAA,CDhGmB,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,CAAA,ECgGyB,ODhGzB,CAAA,IAAA,CAAA;iBCkHnB,gBAAA,gBAA6B;iBAe7B,cAAA,gBAA2B;iBAW3B,aAAA,CAAA,GAAa;KAevB,gBAAA;;;;cAyBQ"}