cocoapods-lynx-library 4.0.2 → 4.0.3.pre.alpha.2
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.
- checksums.yaml +4 -4
- data/lib/lynx/library/autolink.rb +187 -7
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed52e6075baa22a9ae544f58ebd53e9abc411c9c7fc2d6ac94a7e348567eb9be
|
|
4
|
+
data.tar.gz: a6da6f0f03ea3addcd1e87a67a2067d913ffbf16e60743c2cdcae9bbf93e291a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0453a0d1b11191de1d29e4953356105c62799f9c625cd659e910b5966ff09aa23030a9ef1f21209fbcf78ae35b026b78cfdbec2b1b52d348b1fa516684713660
|
|
7
|
+
data.tar.gz: 556232afed56f3edb046b390704243aa56fe2c7d6032a0edfbb6cdb306541ad825b9ebef954df60284f57f124cf15cd0858a5ede52a5a87fca04830700b4592a
|
|
@@ -4,26 +4,38 @@
|
|
|
4
4
|
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
require 'json'
|
|
7
|
+
require 'pathname'
|
|
7
8
|
|
|
8
9
|
module Lynx
|
|
9
10
|
module Library
|
|
10
|
-
LibraryInfo = Struct.new(
|
|
11
|
+
LibraryInfo = Struct.new(
|
|
12
|
+
:npm_name, :package_dir, :manifest_file, :source_dir, :podspec_path, :node_api_addons)
|
|
11
13
|
ComponentInfo = Struct.new(:kind, :name, :class_name)
|
|
14
|
+
NodeApiAddonInfo = Struct.new(
|
|
15
|
+
:name, :pod_name, :podspec_path, :addon_use_header)
|
|
12
16
|
|
|
13
17
|
class Autolink
|
|
14
18
|
REGISTRY_CLASS_NAME = 'LynxGeneratedLibraryRegistry'
|
|
19
|
+
ADDON_USE_SOURCE_NAME = 'LynxGeneratedNodeAPIAddonUse.mm'
|
|
20
|
+
ADDON_NAME_PATTERN = /\A[A-Za-z_][A-Za-z0-9_]*\z/
|
|
15
21
|
|
|
16
22
|
class << self
|
|
17
23
|
def install!(podfile, options = {})
|
|
18
24
|
start_dir = File.expand_path(options[:root] || Dir.pwd)
|
|
19
25
|
output_dir = File.expand_path(options[:output_dir] || 'generated/lynx-library', start_dir)
|
|
20
26
|
libraries = scan(start_dir)
|
|
27
|
+
added_pods = []
|
|
21
28
|
libraries.each do |library|
|
|
22
29
|
pod_name = pod_name_from_podspec(library.podspec_path)
|
|
23
|
-
|
|
30
|
+
pod_path = pod_path_for_podspec(library.package_dir, library.podspec_path)
|
|
31
|
+
add_pod_once(podfile, added_pods, pod_name, pod_path)
|
|
32
|
+
library.node_api_addons.each do |addon|
|
|
33
|
+
addon_path = pod_path_for_podspec(library.package_dir, addon.podspec_path)
|
|
34
|
+
add_pod_once(podfile, added_pods, addon.pod_name, addon_path)
|
|
35
|
+
end
|
|
24
36
|
end
|
|
25
37
|
generate_registry(output_dir, libraries)
|
|
26
|
-
podfile.pod 'LynxLibraryRegistry', :path => output_dir
|
|
38
|
+
podfile.pod 'LynxLibraryRegistry', :path => relative_pod_path(podfile, output_dir)
|
|
27
39
|
libraries
|
|
28
40
|
end
|
|
29
41
|
|
|
@@ -36,10 +48,13 @@ module Lynx
|
|
|
36
48
|
def generate_registry(output_dir, libraries)
|
|
37
49
|
FileUtils.mkdir_p(output_dir)
|
|
38
50
|
components = libraries.flat_map { |library| scan_components(library.source_dir) }
|
|
51
|
+
node_api_addons = libraries.flat_map(&:node_api_addons)
|
|
39
52
|
File.write(File.join(output_dir, "#{REGISTRY_CLASS_NAME}.h"), header_source)
|
|
40
53
|
File.write(File.join(output_dir, "#{REGISTRY_CLASS_NAME}.m"),
|
|
41
54
|
implementation_source(components))
|
|
42
|
-
File.write(File.join(output_dir,
|
|
55
|
+
File.write(File.join(output_dir, ADDON_USE_SOURCE_NAME), addon_use_source(node_api_addons))
|
|
56
|
+
File.write(File.join(output_dir, 'LynxLibraryRegistry.podspec'),
|
|
57
|
+
podspec_source(node_api_addons))
|
|
43
58
|
components
|
|
44
59
|
end
|
|
45
60
|
|
|
@@ -106,14 +121,89 @@ module Lynx
|
|
|
106
121
|
raise "No iOS podspec found for #{manifest_file}" unless
|
|
107
122
|
podspec_path && File.file?(podspec_path)
|
|
108
123
|
|
|
124
|
+
node_api_addons = parse_node_api_addons(ios['nodeApiAddons'], package_realpath,
|
|
125
|
+
podspec_path, manifest_file)
|
|
126
|
+
|
|
109
127
|
npm_name = File.basename(package_dir)
|
|
110
128
|
parent_name = File.basename(File.dirname(package_dir))
|
|
111
129
|
npm_name = "#{parent_name}/#{npm_name}" if parent_name.start_with?('@')
|
|
112
|
-
LibraryInfo.new(npm_name, package_dir, manifest_file, source_dir, podspec_path
|
|
130
|
+
LibraryInfo.new(npm_name, package_dir, manifest_file, source_dir, podspec_path,
|
|
131
|
+
node_api_addons)
|
|
113
132
|
rescue JSON::ParserError => e
|
|
114
133
|
raise "Failed to parse #{manifest_file}: #{e.message}"
|
|
115
134
|
end
|
|
116
135
|
|
|
136
|
+
def add_pod_once(podfile, added_pods, pod_name, pod_path)
|
|
137
|
+
key = [pod_name, File.realpath(pod_path)]
|
|
138
|
+
return if added_pods.include?(key)
|
|
139
|
+
|
|
140
|
+
podfile.pod pod_name, :path => relative_pod_path(podfile, pod_path)
|
|
141
|
+
added_pods << key
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def relative_pod_path(podfile, pod_path)
|
|
145
|
+
podfile_dir = File.expand_path(File.dirname(podfile.defined_in_file.to_s))
|
|
146
|
+
expanded_pod_path = Pathname.new(File.expand_path(pod_path))
|
|
147
|
+
expanded_pod_path.relative_path_from(Pathname.new(podfile_dir)).to_s
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def pod_path_for_podspec(package_dir, podspec_path)
|
|
151
|
+
package_realpath = Pathname.new(File.realpath(package_dir))
|
|
152
|
+
relative_podspec = Pathname.new(podspec_path).relative_path_from(package_realpath)
|
|
153
|
+
File.dirname(File.join(package_dir, relative_podspec.to_s))
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def parse_node_api_addons(addons, package_realpath, default_podspec_path, manifest_file)
|
|
157
|
+
return [] if addons.nil?
|
|
158
|
+
raise "platforms.ios.nodeApiAddons in #{manifest_file} must be an array" unless
|
|
159
|
+
addons.is_a?(Array)
|
|
160
|
+
|
|
161
|
+
addons.each_with_index.map do |addon, index|
|
|
162
|
+
raise "platforms.ios.nodeApiAddons[#{index}] in #{manifest_file} must be an object" unless
|
|
163
|
+
addon.is_a?(Hash)
|
|
164
|
+
|
|
165
|
+
name = addon['name']
|
|
166
|
+
validate_addon_name(name, "platforms.ios.nodeApiAddons[#{index}].name", manifest_file)
|
|
167
|
+
addon_podspec_path = if addon['podspecPath']
|
|
168
|
+
resolve_package_path(package_realpath, addon['podspecPath'],
|
|
169
|
+
manifest_file,
|
|
170
|
+
"nodeApiAddons[#{index}].podspecPath")
|
|
171
|
+
else
|
|
172
|
+
default_podspec_path
|
|
173
|
+
end
|
|
174
|
+
raise "No iOS Node-API addon podspec found for #{manifest_file}" unless
|
|
175
|
+
addon_podspec_path && File.file?(addon_podspec_path)
|
|
176
|
+
|
|
177
|
+
pod_name = addon['podName'] || pod_name_from_podspec(addon_podspec_path)
|
|
178
|
+
addon_use_header = addon['addonUseHeader'] || 'addon_use.h'
|
|
179
|
+
validate_addon_use_header(addon_use_header,
|
|
180
|
+
"platforms.ios.nodeApiAddons[#{index}].addonUseHeader",
|
|
181
|
+
manifest_file)
|
|
182
|
+
NodeApiAddonInfo.new(name.strip, pod_name, addon_podspec_path, addon_use_header)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def validate_addon_name(name, field_name, manifest_file)
|
|
187
|
+
raise "Missing #{field_name} in #{manifest_file}" if name.nil? || name.strip.empty?
|
|
188
|
+
|
|
189
|
+
normalized = name.strip
|
|
190
|
+
return if normalized.length <= 128 && !normalized.include?('..') &&
|
|
191
|
+
normalized.match?(ADDON_NAME_PATTERN)
|
|
192
|
+
|
|
193
|
+
raise "Invalid #{field_name} '#{name}' in #{manifest_file}; " \
|
|
194
|
+
'expected a C identifier matching [A-Za-z_][A-Za-z0-9_]*'
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def validate_addon_use_header(header, field_name, manifest_file)
|
|
198
|
+
raise "Missing #{field_name} in #{manifest_file}" if header.nil? || header.strip.empty?
|
|
199
|
+
|
|
200
|
+
normalized = header.strip
|
|
201
|
+
return if !normalized.start_with?('/') && !normalized.include?('..') &&
|
|
202
|
+
normalized.match?(/\A[A-Za-z0-9_\.\/-]+\z/)
|
|
203
|
+
|
|
204
|
+
raise "Invalid #{field_name} '#{header}' in #{manifest_file}"
|
|
205
|
+
end
|
|
206
|
+
|
|
117
207
|
def pod_name_from_podspec(podspec_path)
|
|
118
208
|
content = File.read(podspec_path)
|
|
119
209
|
match = content.match(/\.name\s*=\s*['"]([^'"]+)['"]/)
|
|
@@ -223,8 +313,11 @@ module Lynx
|
|
|
223
313
|
#import "#{REGISTRY_CLASS_NAME}.h"
|
|
224
314
|
#import <Lynx/LynxConfig.h>
|
|
225
315
|
|
|
316
|
+
extern void LynxGeneratedNodeAPIAddonUse(void);
|
|
317
|
+
|
|
226
318
|
@implementation #{REGISTRY_CLASS_NAME}
|
|
227
319
|
- (void)setup:(LynxConfig *)config {
|
|
320
|
+
LynxGeneratedNodeAPIAddonUse();
|
|
228
321
|
if (config == nil) {
|
|
229
322
|
return;
|
|
230
323
|
}
|
|
@@ -234,7 +327,91 @@ module Lynx
|
|
|
234
327
|
IMPL
|
|
235
328
|
end
|
|
236
329
|
|
|
237
|
-
def
|
|
330
|
+
def addon_use_source(node_api_addons)
|
|
331
|
+
includes = node_api_addons.uniq { |addon| [addon.pod_name, addon.addon_use_header] }
|
|
332
|
+
.map do |addon|
|
|
333
|
+
header = "#{addon.pod_name}/#{addon.addon_use_header}"
|
|
334
|
+
<<~INCLUDE.chomp
|
|
335
|
+
#if __has_include(<#{header}>)
|
|
336
|
+
#include <#{header}>
|
|
337
|
+
#endif
|
|
338
|
+
INCLUDE
|
|
339
|
+
end.join("\n\n")
|
|
340
|
+
addon_register_declarations = node_api_addons.map(&:name).uniq.map do |name|
|
|
341
|
+
"extern void _napi_register_xx_#{name}(void);"
|
|
342
|
+
end.join("\n")
|
|
343
|
+
addon_register_calls = node_api_addons.map(&:name).uniq.map do |name|
|
|
344
|
+
" _napi_register_xx_#{name}();"
|
|
345
|
+
end.join("\n")
|
|
346
|
+
bridge_setup = if node_api_addons.empty?
|
|
347
|
+
''
|
|
348
|
+
else
|
|
349
|
+
<<~SETUP.chomp
|
|
350
|
+
#include <mutex>
|
|
351
|
+
#include <LynxWeakNodeAPI/primjs_weak_node_api_installer.h>
|
|
352
|
+
#include <PrimJS/primjs_weak_node_api_provider.h>
|
|
353
|
+
|
|
354
|
+
namespace {
|
|
355
|
+
extern "C" {
|
|
356
|
+
#{addon_register_declarations}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
void LynxSetupWeakNodeAPI() {
|
|
360
|
+
static std::once_flag once;
|
|
361
|
+
std::call_once(once, []() {
|
|
362
|
+
PrimJSInstallWeakNodeApiRawPtrHostProvider(
|
|
363
|
+
PrimJSGetWeakNodeApiRawPtrHost);
|
|
364
|
+
SetupWeakNodeApiEnv();
|
|
365
|
+
#{addon_register_calls}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
} // namespace
|
|
369
|
+
SETUP
|
|
370
|
+
end
|
|
371
|
+
setup_call = node_api_addons.empty? ? '' : ' LynxSetupWeakNodeAPI();'
|
|
372
|
+
|
|
373
|
+
<<~SOURCE
|
|
374
|
+
// Generated by cocoapods-lynx-library. Do not edit.
|
|
375
|
+
#{bridge_setup}
|
|
376
|
+
|
|
377
|
+
#{includes}
|
|
378
|
+
|
|
379
|
+
#ifdef __cplusplus
|
|
380
|
+
extern "C" {
|
|
381
|
+
#endif
|
|
382
|
+
void LynxGeneratedNodeAPIAddonUse(void) {
|
|
383
|
+
#{setup_call}
|
|
384
|
+
}
|
|
385
|
+
#ifdef __cplusplus
|
|
386
|
+
}
|
|
387
|
+
#endif
|
|
388
|
+
SOURCE
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
def podspec_source(node_api_addons = [])
|
|
392
|
+
addon_pod_names = node_api_addons.map(&:pod_name).uniq
|
|
393
|
+
addon_dependencies = addon_pod_names.map { |pod_name| " s.dependency '#{pod_name}'" }
|
|
394
|
+
.join("\n")
|
|
395
|
+
node_api_dependencies = if node_api_addons.empty?
|
|
396
|
+
[]
|
|
397
|
+
else
|
|
398
|
+
[
|
|
399
|
+
'LynxWeakNodeAPI/primjs_bridge',
|
|
400
|
+
'PrimJS/napi/adapter'
|
|
401
|
+
]
|
|
402
|
+
end
|
|
403
|
+
node_api_dependency_lines = node_api_dependencies.map do |pod_name|
|
|
404
|
+
" s.dependency '#{pod_name}'"
|
|
405
|
+
end.join("\n")
|
|
406
|
+
node_api_xcconfig = if node_api_addons.empty?
|
|
407
|
+
''
|
|
408
|
+
else
|
|
409
|
+
[
|
|
410
|
+
' s.pod_target_xcconfig = {',
|
|
411
|
+
' \'HEADER_SEARCH_PATHS\' => \'$(inherited) "${PODS_ROOT}/LynxWeakNodeAPI/packages/weak-node-api/headers"\'',
|
|
412
|
+
' }'
|
|
413
|
+
].join("\n")
|
|
414
|
+
end
|
|
238
415
|
<<~PODSPEC
|
|
239
416
|
Pod::Spec.new do |s|
|
|
240
417
|
s.name = 'LynxLibraryRegistry'
|
|
@@ -244,8 +421,11 @@ module Lynx
|
|
|
244
421
|
s.license = 'Apache-2.0'
|
|
245
422
|
s.author = 'Lynx'
|
|
246
423
|
s.source = { :path => '.' }
|
|
247
|
-
s.source_files = '#{REGISTRY_CLASS_NAME}.{h,m}'
|
|
424
|
+
s.source_files = '#{REGISTRY_CLASS_NAME}.{h,m}', '#{ADDON_USE_SOURCE_NAME}'
|
|
248
425
|
s.dependency 'Lynx'
|
|
426
|
+
#{node_api_dependency_lines}
|
|
427
|
+
#{addon_dependencies}
|
|
428
|
+
#{node_api_xcconfig}
|
|
249
429
|
s.requires_arc = true
|
|
250
430
|
end
|
|
251
431
|
PODSPEC
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cocoapods-lynx-library
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.2
|
|
4
|
+
version: 4.0.3.pre.alpha.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lynx Authors
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cocoapods
|
|
@@ -48,9 +48,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
48
48
|
version: '0'
|
|
49
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
|
-
- - "
|
|
51
|
+
- - ">"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: 1.3.1
|
|
54
54
|
requirements: []
|
|
55
55
|
rubygems_version: 3.3.27
|
|
56
56
|
signing_key:
|