objcjs-types 0.2.1 → 0.4.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.
Files changed (106) hide show
  1. package/bin/objcjs-types.ts +31 -0
  2. package/dist/AVFoundation/functions.d.ts +21 -0
  3. package/dist/AVFoundation/functions.js +32 -0
  4. package/dist/Accessibility/functions.d.ts +16 -0
  5. package/dist/Accessibility/functions.js +35 -0
  6. package/dist/AddressBook/functions.d.ts +98 -0
  7. package/dist/AddressBook/functions.js +290 -0
  8. package/dist/AppKit/functions.d.ts +112 -0
  9. package/dist/AppKit/functions.js +272 -0
  10. package/dist/AudioToolbox/functions.d.ts +377 -0
  11. package/dist/AudioToolbox/functions.js +1124 -0
  12. package/dist/AuthenticationServices/functions.d.ts +2 -0
  13. package/dist/AuthenticationServices/functions.js +5 -0
  14. package/dist/BrowserEngineCore/functions.d.ts +3 -0
  15. package/dist/BrowserEngineCore/functions.js +11 -0
  16. package/dist/CoreAudio/functions.d.ts +60 -0
  17. package/dist/CoreAudio/functions.js +173 -0
  18. package/dist/CoreMIDI/functions.d.ts +96 -0
  19. package/dist/CoreMIDI/functions.js +287 -0
  20. package/dist/CoreML/functions.d.ts +2 -0
  21. package/dist/CoreML/functions.js +5 -0
  22. package/dist/CoreMediaIO/functions.d.ts +38 -0
  23. package/dist/CoreMediaIO/functions.js +107 -0
  24. package/dist/CoreText/functions.d.ts +209 -0
  25. package/dist/CoreText/functions.js +611 -0
  26. package/dist/CoreWLAN/functions.d.ts +23 -0
  27. package/dist/CoreWLAN/functions.js +56 -0
  28. package/dist/DeviceDiscoveryExtension/functions.d.ts +11 -0
  29. package/dist/DeviceDiscoveryExtension/functions.js +17 -0
  30. package/dist/DiscRecording/functions.d.ts +97 -0
  31. package/dist/DiscRecording/functions.js +290 -0
  32. package/dist/DiscRecordingUI/functions.d.ts +13 -0
  33. package/dist/DiscRecordingUI/functions.js +38 -0
  34. package/dist/ExceptionHandling/functions.d.ts +1 -0
  35. package/dist/ExceptionHandling/functions.js +5 -0
  36. package/dist/FSKit/functions.d.ts +4 -0
  37. package/dist/FSKit/functions.js +11 -0
  38. package/dist/Foundation/functions.d.ts +145 -0
  39. package/dist/Foundation/functions.js +386 -0
  40. package/dist/GLKit/functions.d.ts +51 -0
  41. package/dist/GLKit/functions.js +146 -0
  42. package/dist/GameController/functions.d.ts +18 -0
  43. package/dist/GameController/functions.js +44 -0
  44. package/dist/HealthKit/functions.d.ts +19 -0
  45. package/dist/HealthKit/functions.js +35 -0
  46. package/dist/IOSurface/functions.d.ts +53 -0
  47. package/dist/IOSurface/functions.js +155 -0
  48. package/dist/IOUSBHost/functions.d.ts +44 -0
  49. package/dist/IOUSBHost/functions.js +131 -0
  50. package/dist/InstantMessage/functions.d.ts +1 -0
  51. package/dist/InstantMessage/functions.js +5 -0
  52. package/dist/JavaRuntimeSupport/functions.d.ts +40 -0
  53. package/dist/JavaRuntimeSupport/functions.js +113 -0
  54. package/dist/JavaScriptCore/functions.d.ts +120 -0
  55. package/dist/JavaScriptCore/functions.js +359 -0
  56. package/dist/MLCompute/functions.d.ts +27 -0
  57. package/dist/MLCompute/functions.js +41 -0
  58. package/dist/MapKit/functions.d.ts +23 -0
  59. package/dist/MapKit/functions.js +56 -0
  60. package/dist/Matter/functions.d.ts +17 -0
  61. package/dist/Matter/functions.js +26 -0
  62. package/dist/MediaAccessibility/functions.d.ts +28 -0
  63. package/dist/MediaAccessibility/functions.js +83 -0
  64. package/dist/MediaPlayer/functions.d.ts +3 -0
  65. package/dist/MediaPlayer/functions.js +11 -0
  66. package/dist/Metal/functions.d.ts +14 -0
  67. package/dist/Metal/functions.js +26 -0
  68. package/dist/MetalKit/functions.d.ts +11 -0
  69. package/dist/MetalKit/functions.js +20 -0
  70. package/dist/MetalPerformanceShaders/functions.d.ts +7 -0
  71. package/dist/MetalPerformanceShaders/functions.js +14 -0
  72. package/dist/NearbyInteraction/functions.d.ts +3 -0
  73. package/dist/NearbyInteraction/functions.js +5 -0
  74. package/dist/ParavirtualizedGraphics/functions.d.ts +7 -0
  75. package/dist/ParavirtualizedGraphics/functions.js +14 -0
  76. package/dist/QuartzCore/functions.d.ts +19 -0
  77. package/dist/QuartzCore/functions.js +50 -0
  78. package/dist/SceneKit/functions.d.ts +17 -0
  79. package/dist/SceneKit/functions.js +38 -0
  80. package/dist/SensorKit/functions.d.ts +4 -0
  81. package/dist/SensorKit/functions.js +14 -0
  82. package/dist/ServiceManagement/functions.d.ts +7 -0
  83. package/dist/ServiceManagement/functions.js +20 -0
  84. package/dist/StoreKit/functions.d.ts +1 -0
  85. package/dist/StoreKit/functions.js +5 -0
  86. package/dist/VideoToolbox/functions.d.ts +81 -0
  87. package/dist/VideoToolbox/functions.js +236 -0
  88. package/dist/Vision/functions.d.ts +16 -0
  89. package/dist/Vision/functions.js +38 -0
  90. package/generator/ast-parser.ts +1368 -0
  91. package/generator/clang.ts +167 -0
  92. package/generator/custom.ts +936 -0
  93. package/generator/discover.ts +111 -0
  94. package/generator/emitter.ts +2020 -0
  95. package/generator/frameworks.ts +135 -0
  96. package/generator/index.ts +1334 -0
  97. package/generator/parse-worker.ts +263 -0
  98. package/generator/resolve-strings.ts +121 -0
  99. package/generator/struct-fields.ts +46 -0
  100. package/generator/templates/bind.ts +100 -0
  101. package/generator/templates/helpers.ts +70 -0
  102. package/generator/templates/nsdata.ts +97 -0
  103. package/generator/templates/osversion.ts +91 -0
  104. package/generator/type-mapper.ts +615 -0
  105. package/generator/worker-pool.ts +309 -0
  106. package/package.json +17 -4
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Framework configuration and auto-discovery.
3
+ * Scans the macOS SDK to find all ObjC frameworks with headers,
4
+ * then builds configuration objects for each.
5
+ */
6
+
7
+ import { readdir } from "fs/promises";
8
+ import { existsSync } from "fs";
9
+
10
+ /** Static framework configuration — just paths and optional overrides. */
11
+ export interface FrameworkBase {
12
+ /** Framework name (e.g., "Foundation") */
13
+ name: string;
14
+ /** Path to the framework binary (for NobjcLibrary) */
15
+ libraryPath: string;
16
+ /** Path to the framework headers directory */
17
+ headersPath: string;
18
+ /** Optional pre-includes for fallback clang mode (without -fmodules) */
19
+ preIncludes?: string[];
20
+ /** Extra headers to parse for additional class members (class name → absolute path) */
21
+ extraHeaders?: Record<string, string>;
22
+ }
23
+
24
+ /** Resolved framework config with discovered classes and protocols. */
25
+ export interface FrameworkConfig extends FrameworkBase {
26
+ /** All discovered class names */
27
+ classes: string[];
28
+ /** All discovered protocol names */
29
+ protocols: string[];
30
+ /** All discovered integer enum names (NS_ENUM / NS_OPTIONS) */
31
+ integerEnums: string[];
32
+ /** All discovered string enum names (NS_TYPED_EXTENSIBLE_ENUM etc.) */
33
+ stringEnums: string[];
34
+ /** Maps class name → header file name (without .h) */
35
+ classHeaders: Map<string, string>;
36
+ /** Maps protocol name → header file name (without .h) */
37
+ protocolHeaders: Map<string, string>;
38
+ /** Maps integer enum name → header file name (without .h) */
39
+ integerEnumHeaders: Map<string, string>;
40
+ /** Maps string enum name → header file name (without .h) */
41
+ stringEnumHeaders: Map<string, string>;
42
+ }
43
+
44
+ export const SDK_PATH =
45
+ "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk";
46
+
47
+ const FRAMEWORKS_DIR = `${SDK_PATH}/System/Library/Frameworks`;
48
+
49
+ // --- Edge-case overrides for specific frameworks ---
50
+
51
+ /** Extra headers to parse for additional class members (class name → path). */
52
+ const EXTRA_HEADERS: Record<string, Record<string, string>> = {
53
+ Foundation: {
54
+ // alloc, init, new, copy, isKindOfClass:, respondsToSelector:, etc.
55
+ // are defined in the ObjC runtime header, not the Foundation NSObject.h
56
+ NSObject: `${SDK_PATH}/usr/include/objc/NSObject.h`
57
+ }
58
+ };
59
+
60
+ /** Additional pre-includes for fallback clang mode (without -fmodules). */
61
+ const PRE_INCLUDES: Record<string, string[]> = {
62
+ WebKit: ["WebKit/WKFoundation.h"],
63
+ AuthenticationServices: ["AuthenticationServices/ASFoundation.h"]
64
+ };
65
+
66
+ /**
67
+ * Discover all ObjC frameworks in the macOS SDK.
68
+ * Scans the Frameworks directory for .framework bundles that have
69
+ * a Headers/ directory with .h files. Returns FrameworkBase configs
70
+ * with paths derived from the standard bundle structure.
71
+ *
72
+ * Foundation is always sorted first (it's the universal base framework).
73
+ */
74
+ export async function discoverAllFrameworks(): Promise<FrameworkBase[]> {
75
+ const entries = await readdir(FRAMEWORKS_DIR);
76
+ const frameworks: FrameworkBase[] = [];
77
+
78
+ for (const entry of entries) {
79
+ if (!entry.endsWith(".framework")) continue;
80
+ // Skip private/internal frameworks (underscore-prefixed)
81
+ if (entry.startsWith("_")) continue;
82
+
83
+ const name = entry.slice(0, -".framework".length);
84
+ const headersPath = `${FRAMEWORKS_DIR}/${entry}/Headers`;
85
+
86
+ // Must have a Headers directory with .h files
87
+ if (!existsSync(headersPath)) continue;
88
+ const headers = await readdir(headersPath);
89
+ if (!headers.some((h) => h.endsWith(".h"))) continue;
90
+
91
+ const fw: FrameworkBase = {
92
+ name,
93
+ libraryPath: `/System/Library/Frameworks/${entry}/${name}`,
94
+ headersPath,
95
+ ...(EXTRA_HEADERS[name] ? { extraHeaders: EXTRA_HEADERS[name] } : {}),
96
+ ...(PRE_INCLUDES[name] ? { preIncludes: PRE_INCLUDES[name] } : {})
97
+ };
98
+
99
+ frameworks.push(fw);
100
+ }
101
+
102
+ // Foundation first (universal base), then alphabetical
103
+ frameworks.sort((a, b) => {
104
+ if (a.name === "Foundation") return -1;
105
+ if (b.name === "Foundation") return 1;
106
+ return a.name.localeCompare(b.name);
107
+ });
108
+
109
+ return frameworks;
110
+ }
111
+
112
+ /**
113
+ * Get the header file path for a class using discovered header mapping.
114
+ */
115
+ export function getHeaderPath(framework: FrameworkConfig, className: string): string {
116
+ const headerName = framework.classHeaders.get(className) ?? className;
117
+ return `${framework.headersPath}/${headerName}.h`;
118
+ }
119
+
120
+ /**
121
+ * Get the header file path for a protocol using discovered header mapping.
122
+ */
123
+ export function getProtocolHeaderPath(framework: FrameworkConfig, protocolName: string): string {
124
+ const headerName = framework.protocolHeaders.get(protocolName) ?? protocolName;
125
+ return `${framework.headersPath}/${headerName}.h`;
126
+ }
127
+
128
+ /**
129
+ * Get the header file path for an enum using discovered header mapping.
130
+ */
131
+ export function getEnumHeaderPath(framework: FrameworkConfig, enumName: string, kind: "integer" | "string"): string {
132
+ const headers = kind === "integer" ? framework.integerEnumHeaders : framework.stringEnumHeaders;
133
+ const headerName = headers.get(enumName) ?? enumName;
134
+ return `${framework.headersPath}/${headerName}.h`;
135
+ }