bleam 0.0.8 → 0.0.10

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 (96) hide show
  1. package/dist/cli.cjs +269 -22
  2. package/dist/cli.d.cts +32 -2
  3. package/dist/cli.d.ts +32 -2
  4. package/dist/cli.js +270 -23
  5. package/dist/platform.d.cts +2 -0
  6. package/dist/platform.d.ts +2 -0
  7. package/dist/{ui-1WepaMS4.d.cts → ui-Bg11tvlc.d.ts} +1 -1
  8. package/dist/{ui-Ce-pnUUA.d.ts → ui-Dd7SXdbg.d.cts} +7 -7
  9. package/dist/ui.d.cts +1 -1
  10. package/dist/ui.d.ts +1 -1
  11. package/dist/window.d.cts +1 -1
  12. package/dist/window.d.ts +1 -1
  13. package/package.json +5 -1
  14. package/templates/image-generation/app/index.tsx +1 -1
  15. package/templates/native/.gitattributes +1 -0
  16. package/templates/native/App.tsx +26 -0
  17. package/templates/native/app.json +12 -0
  18. package/templates/native/index.ts +8 -0
  19. package/templates/native/ios/.xcode.env +11 -0
  20. package/templates/native/ios/Bleam/AI/Flux2/Configuration/Flux2Config.swift +288 -0
  21. package/templates/native/ios/Bleam/AI/Flux2/Configuration/MemoryConfig.swift +233 -0
  22. package/templates/native/ios/Bleam/AI/Flux2/Configuration/MemoryOptimizationConfig.swift +157 -0
  23. package/templates/native/ios/Bleam/AI/Flux2/Configuration/ModelRegistry.swift +425 -0
  24. package/templates/native/ios/Bleam/AI/Flux2/Configuration/QuantizationConfig.swift +138 -0
  25. package/templates/native/ios/Bleam/AI/Flux2/Configuration/TransformerRepoProfile.swift +59 -0
  26. package/templates/native/ios/Bleam/AI/Flux2/Configuration/VAEConfig.swift +134 -0
  27. package/templates/native/ios/Bleam/AI/Flux2/Flux2Core.swift +55 -0
  28. package/templates/native/ios/Bleam/AI/Flux2/Loading/WeightLoader.swift +1192 -0
  29. package/templates/native/ios/Bleam/AI/Flux2/Pipeline/FluxImageRunner.swift +1282 -0
  30. package/templates/native/ios/Bleam/AI/Flux2/Pipeline/LatentUtils.swift +191 -0
  31. package/templates/native/ios/Bleam/AI/Flux2/Scheduler/FlowMatchEulerScheduler.swift +279 -0
  32. package/templates/native/ios/Bleam/AI/Flux2/Text/KleinTextEncoder.swift +380 -0
  33. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2Attention.swift +379 -0
  34. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2Embeddings.swift +159 -0
  35. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2FeedForward.swift +154 -0
  36. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2FusedKernels.swift +198 -0
  37. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2KVCache.swift +36 -0
  38. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2Modulation.swift +193 -0
  39. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2ParallelAttention.swift +389 -0
  40. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2RoPE.swift +304 -0
  41. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2SingleBlock.swift +290 -0
  42. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2Transformer.swift +530 -0
  43. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2TransformerBlock.swift +362 -0
  44. package/templates/native/ios/Bleam/AI/Flux2/Utils/Flux2Debug.swift +101 -0
  45. package/templates/native/ios/Bleam/AI/Flux2/Utils/MLXCheckpoint.swift +118 -0
  46. package/templates/native/ios/Bleam/AI/Flux2/Utils/MemoryManager.swift +201 -0
  47. package/templates/native/ios/Bleam/AI/Flux2/VAE/AutoencoderKL.swift +476 -0
  48. package/templates/native/ios/Bleam/AI/Flux2/VAE/ResnetBlock.swift +316 -0
  49. package/templates/native/ios/Bleam/AI/Flux2/VAE/VAEDecoder.swift +120 -0
  50. package/templates/native/ios/Bleam/AI/Flux2/VAE/VAEEncoder.swift +136 -0
  51. package/templates/native/ios/Bleam/AppDelegate.swift +482 -0
  52. package/templates/native/ios/Bleam/Appearance.swift +62 -0
  53. package/templates/native/ios/Bleam/Bridging-Header.h +3 -0
  54. package/templates/native/ios/Bleam/Images.xcassets/AppIcon.appiconset/Contents.json +13 -0
  55. package/templates/native/ios/Bleam/Images.xcassets/Contents.json +6 -0
  56. package/templates/native/ios/Bleam/Info.plist +76 -0
  57. package/templates/native/ios/Bleam/PrivacyInfo.xcprivacy +48 -0
  58. package/templates/native/ios/Bleam/SceneDelegate.swift +58 -0
  59. package/templates/native/ios/Bleam/SplashScreen.storyboard +47 -0
  60. package/templates/native/ios/Bleam/Supporting/Expo.plist +6 -0
  61. package/templates/native/ios/Bleam/bleam.entitlements +10 -0
  62. package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +1147 -0
  63. package/templates/native/ios/Bleam.xcodeproj/xcshareddata/xcschemes/Bleam.xcscheme +88 -0
  64. package/templates/native/ios/GenerationService/GenerationService.entitlements +10 -0
  65. package/templates/native/ios/GenerationService/ImageGenerationRunner.swift +591 -0
  66. package/templates/native/ios/GenerationService/Info.plist +31 -0
  67. package/templates/native/ios/GenerationService/main.swift +165 -0
  68. package/templates/native/ios/PlatformHelper/main.swift +726 -0
  69. package/templates/native/ios/Podfile +198 -0
  70. package/templates/native/ios/Podfile.lock +2284 -0
  71. package/templates/native/ios/Podfile.properties.json +5 -0
  72. package/templates/native/ios/Shared/Generation/GenerationServiceProtocol.swift +12 -0
  73. package/templates/native/ios/Shared/Generation/GenerationWorkerProtocol.swift +124 -0
  74. package/templates/native/metro.config.js +6 -0
  75. package/templates/native/modules/bleam-runtime/BleamRuntime.podspec +14 -0
  76. package/templates/native/modules/bleam-runtime/expo-module.config.json +8 -0
  77. package/templates/native/modules/bleam-runtime/ios/AIModule.swift +1258 -0
  78. package/templates/native/modules/bleam-runtime/ios/GenerationContracts.swift +135 -0
  79. package/templates/native/modules/bleam-runtime/ios/PlatformModule.swift +329 -0
  80. package/templates/native/modules/bleam-runtime/package.json +5 -0
  81. package/templates/native/package.json +39 -0
  82. package/templates/native/scripts/build/mlx-frameworks.ts +421 -0
  83. package/templates/native/scripts/start/index.ts +474 -0
  84. package/templates/native/scripts/start/known-failures.ts +20 -0
  85. package/templates/native/scripts/start/loader.ts +76 -0
  86. package/templates/native/scripts/start/native-state.ts +242 -0
  87. package/templates/native/scripts/start/package.json +4 -0
  88. package/templates/native/scripts/start/swift-packages.ts +414 -0
  89. package/templates/native/scripts/start/xcode-formatter.ts +106 -0
  90. package/templates/native/tsconfig.json +14 -0
  91. package/templates/native/yarn.lock +3749 -0
  92. package/templates/updates/README.md +272 -0
  93. package/templates/updates/src/index.ts +385 -0
  94. package/templates/updates/src/schema.ts +385 -0
  95. package/templates/updates/tsconfig.json +12 -0
  96. package/templates/updates/wrangler.jsonc +19 -0
@@ -0,0 +1,198 @@
1
+ # Expo's bundled precompiled modules do not currently include Mac Catalyst slices.
2
+ ENV['EXPO_USE_PRECOMPILED_MODULES'] = '0'
3
+
4
+ unless ::Enumerable.method_defined?(:filter_map)
5
+ module ::Enumerable
6
+ def filter_map
7
+ return enum_for(:filter_map) unless block_given?
8
+
9
+ each_with_object([]) do |element, result|
10
+ value = yield(element)
11
+ result << value if value
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
18
+ require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
19
+
20
+ require 'json'
21
+ podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
22
+
23
+ def ccache_enabled?(podfile_properties)
24
+ # Environment variable takes precedence
25
+ return ENV['USE_CCACHE'] == '1' if ENV['USE_CCACHE']
26
+
27
+ # Fall back to Podfile properties
28
+ podfile_properties['apple.ccacheEnabled'] == 'true'
29
+ end
30
+
31
+ ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] ||= podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']
32
+ ENV['RCT_USE_RN_DEP'] ||= podfile_properties['ios.buildReactNativeFromSource'] == 'true' ? '0' : '1'
33
+ ENV['RCT_USE_PREBUILT_RNCORE'] ||= podfile_properties['ios.buildReactNativeFromSource'] == 'true' ? '0' : '1'
34
+ ENV['RCT_HERMES_V1_ENABLED'] ||= '0' if podfile_properties['expo.useHermesV1'] == 'false'
35
+ platform :ios, podfile_properties['ios.deploymentTarget'] || '16.4'
36
+
37
+ prepare_react_native_project!
38
+
39
+ def install_bleam_catalyst_prebuilt_framework_normalizer(installer)
40
+ # RN's Catalyst prebuilt frameworks currently mix flat and versioned macOS layouts.
41
+ # Normalize them before CocoaPods embeds and codesigns the selected XCFramework slices.
42
+ phase_name = '[bleam] Normalize Catalyst prebuilt frameworks'
43
+ script = <<~'SCRIPT'
44
+ set -euo pipefail
45
+
46
+ if [[ "${EFFECTIVE_PLATFORM_NAME:-}" != "-maccatalyst" ]]; then
47
+ exit 0
48
+ fi
49
+
50
+ normalize_framework() {
51
+ # Codesign rejects embedded macOS frameworks with root-level payload files.
52
+ local framework="$1"
53
+ local binary_name="$2"
54
+ local versions_dir="${framework}/Versions"
55
+ local current_dir="${versions_dir}/Current"
56
+ local version_a_dir="${versions_dir}/A"
57
+
58
+ if [[ ! -d "${version_a_dir}" ]]; then
59
+ return 0
60
+ fi
61
+
62
+ if [[ ! -e "${version_a_dir}/${binary_name}" && -e "${framework}/${binary_name}" ]]; then
63
+ mv "${framework}/${binary_name}" "${version_a_dir}/${binary_name}"
64
+ fi
65
+
66
+ if [[ -e "${framework}/${binary_name}" || -L "${framework}/${binary_name}" ]]; then
67
+ rm -f "${framework}/${binary_name}"
68
+ fi
69
+ ln -sfn "Versions/Current/${binary_name}" "${framework}/${binary_name}"
70
+
71
+ if [[ -e "${current_dir}" || -L "${current_dir}" ]]; then
72
+ rm -rf "${current_dir}"
73
+ fi
74
+ ln -sfn "A" "${current_dir}"
75
+
76
+ if [[ -e "${framework}/Resources" || -L "${framework}/Resources" ]]; then
77
+ rm -rf "${framework}/Resources"
78
+ fi
79
+ mkdir -p "${version_a_dir}/Resources"
80
+
81
+ shopt -s nullglob
82
+ for bundle in "${framework}"/*.bundle; do
83
+ mv "${bundle}" "${version_a_dir}/Resources/"
84
+ done
85
+ shopt -u nullglob
86
+
87
+ if [[ -d "${version_a_dir}/Resources" ]]; then
88
+ ln -sfn "Versions/Current/Resources" "${framework}/Resources"
89
+ fi
90
+ }
91
+
92
+ normalize_framework "${BUILT_PRODUCTS_DIR}/XCFrameworkIntermediates/React-Core-prebuilt/React.framework" "React"
93
+ normalize_framework "${BUILT_PRODUCTS_DIR}/XCFrameworkIntermediates/ReactNativeDependencies/ReactNativeDependencies.framework" "ReactNativeDependencies"
94
+ SCRIPT
95
+
96
+ installer.aggregate_targets.each do |aggregate_target|
97
+ user_project = aggregate_target.user_project
98
+ native_target = user_project.native_targets.find { |target| target.name == 'bleam' }
99
+ next unless native_target
100
+
101
+ phase = native_target.shell_script_build_phases.find { |build_phase| build_phase.name == phase_name }
102
+ phase ||= native_target.new_shell_script_build_phase(phase_name)
103
+ phase.shell_script = script
104
+ phase.show_env_vars_in_log = '0'
105
+
106
+ build_phases = native_target.build_phases
107
+ build_phases.delete(phase)
108
+ embed_index = build_phases.index { |build_phase| build_phase.respond_to?(:name) && build_phase.name == '[CP] Embed Pods Frameworks' }
109
+ build_phases.insert(embed_index || build_phases.length, phase)
110
+ user_project.save
111
+ end
112
+ end
113
+
114
+ target 'bleam' do
115
+ use_expo_modules!(searchPaths: [File.expand_path('../modules', __dir__)])
116
+
117
+ if ENV['EXPO_USE_COMMUNITY_AUTOLINKING'] == '1'
118
+ config_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
119
+ else
120
+ config_command = [
121
+ 'node',
122
+ '--no-warnings',
123
+ '--eval',
124
+ 'require(\'expo/bin/autolinking\')',
125
+ 'expo-modules-autolinking',
126
+ 'react-native-config',
127
+ '--json',
128
+ '--platform',
129
+ 'ios'
130
+ ]
131
+ end
132
+
133
+ config = use_native_modules!(config_command)
134
+
135
+ use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
136
+ use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']
137
+
138
+ use_react_native!(
139
+ :path => config[:reactNativePath],
140
+ :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
141
+ # An absolute path to your application root.
142
+ :app_path => "#{Pod::Config.instance.installation_root}/..",
143
+ :privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',
144
+ )
145
+
146
+ post_install do |installer|
147
+ react_native_post_install(
148
+ installer,
149
+ config[:reactNativePath],
150
+ :mac_catalyst_enabled => true,
151
+ :ccache_enabled => ccache_enabled?(podfile_properties),
152
+ )
153
+ # [bleam] Disable fmt consteval for Mac Catalyst pod builds
154
+ installer.pods_project.build_configurations.each do |build_configuration|
155
+ current_ios_target = build_configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f
156
+ if current_ios_target < 17.0
157
+ build_configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '17.0'
158
+ end
159
+ current_macos_target = build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET'].to_f
160
+ if current_macos_target < 14.0
161
+ build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '14.0'
162
+ end
163
+ build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET[sdk=macosx*]'] = '14.0'
164
+ build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET[sdk=macosx*][variant=Mac Catalyst]'] = '14.0'
165
+ end
166
+
167
+ installer.pods_project.targets.each do |target|
168
+ target.build_configurations.each do |build_configuration|
169
+ current_ios_target = build_configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f
170
+ if current_ios_target < 17.0
171
+ build_configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '17.0'
172
+ end
173
+ current_macos_target = build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET'].to_f
174
+ if current_macos_target < 14.0
175
+ build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '14.0'
176
+ end
177
+ build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET[sdk=macosx*]'] = '14.0'
178
+ build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET[sdk=macosx*][variant=Mac Catalyst]'] = '14.0'
179
+ build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'x86_64'
180
+
181
+ next unless target.name.match?(/^(fmt|RCT-Folly|React(?:-.+)?|ReactCommon(?:-.+)?|ReactCodegen|ReactAppDependencyProvider|hermes-engine)$/)
182
+
183
+ definitions = build_configuration.build_settings['GCC_PREPROCESSOR_DEFINITIONS']
184
+ definitions = ['$(inherited)'] if definitions.nil?
185
+ definitions = [definitions] unless definitions.is_a?(Array)
186
+ definitions.unshift('$(inherited)') unless definitions.include?('$(inherited)')
187
+ definitions << 'FMT_USE_CONSTEVAL=0' unless definitions.include?('FMT_USE_CONSTEVAL=0')
188
+ build_configuration.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = definitions
189
+ build_configuration.build_settings['GCC_PREPROCESSOR_DEFINITIONS[sdk=macosx*]'] = definitions
190
+ if target.name == 'fmt'
191
+ build_configuration.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'gnu++17'
192
+ build_configuration.build_settings['CLANG_CXX_LANGUAGE_STANDARD[sdk=macosx*]'] = 'gnu++17'
193
+ end
194
+ end
195
+ end
196
+ install_bleam_catalyst_prebuilt_framework_normalizer(installer)
197
+ end
198
+ end