cocoapods-lynx-library 4.0.3.pre.alpha.2 → 4.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.
- checksums.yaml +4 -4
- data/lib/lynx/library/autolink.rb +7 -187
- 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: 05d74ec7ee60232cb547dc7c1e1c78be316dca59bde08e7d16cde94333995ef4
|
|
4
|
+
data.tar.gz: d636625c9480f2bdaa8b624e737ae6503b28726c48f6783fbf65d47e7fc6cf45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 458e117fd5822beb0844207198868fb2ee180bf62a10f0b2f252c1a53aa9d2b1dffc8fe8f42db18bba6c298d61e17fe4a275e5a89d1c2a0fe74a6d85301f254a
|
|
7
|
+
data.tar.gz: 1948f8b96eb8bebc9921d8933cc504ae168edb55478d3e41eac1ae500971920c86299b033b8aeaf9ff16a9f9ab9052d61457b11d792688083d9d6f5dae9acfe2
|
|
@@ -4,38 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
require 'json'
|
|
7
|
-
require 'pathname'
|
|
8
7
|
|
|
9
8
|
module Lynx
|
|
10
9
|
module Library
|
|
11
|
-
LibraryInfo = Struct.new(
|
|
12
|
-
:npm_name, :package_dir, :manifest_file, :source_dir, :podspec_path, :node_api_addons)
|
|
10
|
+
LibraryInfo = Struct.new(:npm_name, :package_dir, :manifest_file, :source_dir, :podspec_path)
|
|
13
11
|
ComponentInfo = Struct.new(:kind, :name, :class_name)
|
|
14
|
-
NodeApiAddonInfo = Struct.new(
|
|
15
|
-
:name, :pod_name, :podspec_path, :addon_use_header)
|
|
16
12
|
|
|
17
13
|
class Autolink
|
|
18
14
|
REGISTRY_CLASS_NAME = 'LynxGeneratedLibraryRegistry'
|
|
19
|
-
ADDON_USE_SOURCE_NAME = 'LynxGeneratedNodeAPIAddonUse.mm'
|
|
20
|
-
ADDON_NAME_PATTERN = /\A[A-Za-z_][A-Za-z0-9_]*\z/
|
|
21
15
|
|
|
22
16
|
class << self
|
|
23
17
|
def install!(podfile, options = {})
|
|
24
18
|
start_dir = File.expand_path(options[:root] || Dir.pwd)
|
|
25
19
|
output_dir = File.expand_path(options[:output_dir] || 'generated/lynx-library', start_dir)
|
|
26
20
|
libraries = scan(start_dir)
|
|
27
|
-
added_pods = []
|
|
28
21
|
libraries.each do |library|
|
|
29
22
|
pod_name = pod_name_from_podspec(library.podspec_path)
|
|
30
|
-
|
|
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
|
|
23
|
+
podfile.pod pod_name, :path => File.dirname(library.podspec_path)
|
|
36
24
|
end
|
|
37
25
|
generate_registry(output_dir, libraries)
|
|
38
|
-
podfile.pod 'LynxLibraryRegistry', :path =>
|
|
26
|
+
podfile.pod 'LynxLibraryRegistry', :path => output_dir
|
|
39
27
|
libraries
|
|
40
28
|
end
|
|
41
29
|
|
|
@@ -48,13 +36,10 @@ module Lynx
|
|
|
48
36
|
def generate_registry(output_dir, libraries)
|
|
49
37
|
FileUtils.mkdir_p(output_dir)
|
|
50
38
|
components = libraries.flat_map { |library| scan_components(library.source_dir) }
|
|
51
|
-
node_api_addons = libraries.flat_map(&:node_api_addons)
|
|
52
39
|
File.write(File.join(output_dir, "#{REGISTRY_CLASS_NAME}.h"), header_source)
|
|
53
40
|
File.write(File.join(output_dir, "#{REGISTRY_CLASS_NAME}.m"),
|
|
54
41
|
implementation_source(components))
|
|
55
|
-
File.write(File.join(output_dir,
|
|
56
|
-
File.write(File.join(output_dir, 'LynxLibraryRegistry.podspec'),
|
|
57
|
-
podspec_source(node_api_addons))
|
|
42
|
+
File.write(File.join(output_dir, 'LynxLibraryRegistry.podspec'), podspec_source)
|
|
58
43
|
components
|
|
59
44
|
end
|
|
60
45
|
|
|
@@ -121,89 +106,14 @@ module Lynx
|
|
|
121
106
|
raise "No iOS podspec found for #{manifest_file}" unless
|
|
122
107
|
podspec_path && File.file?(podspec_path)
|
|
123
108
|
|
|
124
|
-
node_api_addons = parse_node_api_addons(ios['nodeApiAddons'], package_realpath,
|
|
125
|
-
podspec_path, manifest_file)
|
|
126
|
-
|
|
127
109
|
npm_name = File.basename(package_dir)
|
|
128
110
|
parent_name = File.basename(File.dirname(package_dir))
|
|
129
111
|
npm_name = "#{parent_name}/#{npm_name}" if parent_name.start_with?('@')
|
|
130
|
-
LibraryInfo.new(npm_name, package_dir, manifest_file, source_dir, podspec_path
|
|
131
|
-
node_api_addons)
|
|
112
|
+
LibraryInfo.new(npm_name, package_dir, manifest_file, source_dir, podspec_path)
|
|
132
113
|
rescue JSON::ParserError => e
|
|
133
114
|
raise "Failed to parse #{manifest_file}: #{e.message}"
|
|
134
115
|
end
|
|
135
116
|
|
|
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
|
-
|
|
207
117
|
def pod_name_from_podspec(podspec_path)
|
|
208
118
|
content = File.read(podspec_path)
|
|
209
119
|
match = content.match(/\.name\s*=\s*['"]([^'"]+)['"]/)
|
|
@@ -313,11 +223,8 @@ module Lynx
|
|
|
313
223
|
#import "#{REGISTRY_CLASS_NAME}.h"
|
|
314
224
|
#import <Lynx/LynxConfig.h>
|
|
315
225
|
|
|
316
|
-
extern void LynxGeneratedNodeAPIAddonUse(void);
|
|
317
|
-
|
|
318
226
|
@implementation #{REGISTRY_CLASS_NAME}
|
|
319
227
|
- (void)setup:(LynxConfig *)config {
|
|
320
|
-
LynxGeneratedNodeAPIAddonUse();
|
|
321
228
|
if (config == nil) {
|
|
322
229
|
return;
|
|
323
230
|
}
|
|
@@ -327,91 +234,7 @@ module Lynx
|
|
|
327
234
|
IMPL
|
|
328
235
|
end
|
|
329
236
|
|
|
330
|
-
def
|
|
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
|
|
237
|
+
def podspec_source
|
|
415
238
|
<<~PODSPEC
|
|
416
239
|
Pod::Spec.new do |s|
|
|
417
240
|
s.name = 'LynxLibraryRegistry'
|
|
@@ -421,11 +244,8 @@ module Lynx
|
|
|
421
244
|
s.license = 'Apache-2.0'
|
|
422
245
|
s.author = 'Lynx'
|
|
423
246
|
s.source = { :path => '.' }
|
|
424
|
-
s.source_files = '#{REGISTRY_CLASS_NAME}.{h,m}'
|
|
247
|
+
s.source_files = '#{REGISTRY_CLASS_NAME}.{h,m}'
|
|
425
248
|
s.dependency 'Lynx'
|
|
426
|
-
#{node_api_dependency_lines}
|
|
427
|
-
#{addon_dependencies}
|
|
428
|
-
#{node_api_xcconfig}
|
|
429
249
|
s.requires_arc = true
|
|
430
250
|
end
|
|
431
251
|
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.3
|
|
4
|
+
version: 4.0.3
|
|
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-09-11 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: '0'
|
|
54
54
|
requirements: []
|
|
55
55
|
rubygems_version: 3.3.27
|
|
56
56
|
signing_key:
|