@invarn/cli 0.9.364 → 0.9.368

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 (37) hide show
  1. package/dist/capture/android/VERSION +1 -1
  2. package/dist/capture/android/capture-build.cjs +1 -1
  3. package/dist/capture/android/controller.cjs +1 -1
  4. package/dist/capture/android/index.cjs +1 -1
  5. package/dist/capture/android/invarn-agent-0.138.0.aar +0 -0
  6. package/dist/capture/android/verify-apk.cjs +1 -1
  7. package/dist/capture/ios/InvarnAgent-0.95.0.dylib +0 -0
  8. package/dist/capture/ios/InvarnComposeReader-0.95.0/VERSION +1 -0
  9. package/dist/capture/ios/InvarnComposeReader-0.95.0/invarn-compose.gradle +168 -0
  10. package/dist/capture/ios/{InvarnComposeReader-0.90.0.tar → InvarnComposeReader-0.95.0.tar} +0 -0
  11. package/dist/capture/ios/{InvarnFold-0.90.0 → InvarnFold-0.95.0} +0 -0
  12. package/dist/capture/ios/{InvarnHinge-0.90.0 → InvarnHinge-0.95.0} +0 -0
  13. package/dist/capture/ios/{InvarnQuit-0.90.0 → InvarnQuit-0.95.0} +0 -0
  14. package/dist/capture/ios/{InvarnReencode-0.90.0 → InvarnReencode-0.95.0} +0 -0
  15. package/dist/capture/ios/{InvarnSystemRunner-0.90.0.dylib → InvarnSystemRunner-0.95.0.dylib} +0 -0
  16. package/dist/capture/ios/VERSION +1 -1
  17. package/dist/capture/ios/capture-build.cjs +1 -1
  18. package/dist/capture/ios/controller.cjs +1 -1
  19. package/dist/capture/ios/index.cjs +1 -1
  20. package/dist/invarn.cjs +25 -24
  21. package/dist/local-run-worker.mjs +1 -1
  22. package/dist/sdk.mjs +36 -39
  23. package/package.json +1 -1
  24. package/dist/capture/android/invarn-agent-0.136.0.aar +0 -0
  25. package/dist/capture/ios/InvarnAgent-0.90.0.dylib +0 -0
  26. package/dist/capture/ios/InvarnComposeReader-0.90.0/VERSION +0 -1
  27. package/dist/capture/ios/InvarnComposeReader-0.90.0/invarn-compose.gradle +0 -90
  28. /package/dist/capture/android/{invarn-init-0.136.0.gradle → invarn-init-0.138.0.gradle} +0 -0
  29. /package/dist/capture/android/{invarn-instrument-0.136.0.jar → invarn-instrument-0.138.0.jar} +0 -0
  30. /package/dist/capture/android/{invarn-reader-0.136.0.jar → invarn-reader-0.138.0.jar} +0 -0
  31. /package/dist/capture/ios/{InvarnComposeReader-0.90.0 → InvarnComposeReader-0.95.0}/scan.groovy +0 -0
  32. /package/dist/capture/ios/{InvarnComposeReader-0.90.0 → InvarnComposeReader-0.95.0}/src/Ivx.kt +0 -0
  33. /package/dist/capture/ios/{InvarnComposeReader-0.90.0 → InvarnComposeReader-0.95.0}/src/Zmn0.kt +0 -0
  34. /package/dist/capture/ios/{InvarnComposeReader-0.90.0 → InvarnComposeReader-0.95.0}/src/Znn0.kt +0 -0
  35. /package/dist/capture/ios/{InvarnComposeReader-0.90.0 → InvarnComposeReader-0.95.0}/src/Zpn0.kt +0 -0
  36. /package/dist/capture/ios/{InvarnComposeReader-0.90.0 → InvarnComposeReader-0.95.0}/src/Zqn0.kt +0 -0
  37. /package/dist/capture/ios/{InvarnComposeReader-0.90.0 → InvarnComposeReader-0.95.0}/src/Zsn0.kt +0 -0
@@ -0,0 +1,168 @@
1
+ def readerHome = System.getenv('INVARN_COMPOSE_READER') ?: buildscript.sourceFile?.parentFile?.absolutePath
2
+ def READER = (new File(readerHome, 'VERSION').with { it.exists() ? it.text.trim() : 'dev' })
3
+
4
+ @org.gradle.api.tasks.UntrackedTask(because = 'reads every Kotlin file of the build')
5
+ abstract class InvarnReaderSources extends DefaultTask {
6
+ static final List<Integer> FLOOR = [1, 10, 0]
7
+
8
+ @Input abstract Property<String> getReaderHome()
9
+ @Input abstract Property<String> getReaderVersion()
10
+ @Input abstract Property<String> getRootPath()
11
+ @Input abstract Property<String> getGradleHomePath()
12
+ @Input abstract Property<String> getLabel()
13
+ @Internal abstract ConfigurableFileCollection getLibraries()
14
+ @OutputDirectory abstract DirectoryProperty getOutputDir()
15
+
16
+ static List<Integer> versionOf(String v) {
17
+ def m = (v =~ /^(\d+)\.(\d+)(?:\.(\d+))?/)
18
+ m.find() ? [m.group(1) as int, m.group(2) as int, (m.group(3) ?: '0') as int] : null
19
+ }
20
+
21
+ static boolean atLeast(List a, List b) {
22
+ for (int i = 0; i < 3; i++) { if (a[i] != b[i]) return a[i] > b[i] }
23
+ true
24
+ }
25
+
26
+ static FileCollection external(Configuration c) {
27
+ c.incoming.artifactView { v -> v.componentFilter { id -> id instanceof org.gradle.api.artifacts.component.ModuleComponentIdentifier } }.files
28
+ }
29
+
30
+ @TaskAction
31
+ void write() {
32
+ def dir = outputDir.get().asFile
33
+ dir.deleteDir(); dir.mkdirs()
34
+ def found = []
35
+ libraries.files.each { f ->
36
+ def m = (f.absolutePath =~ /compose[\/.]runtime[\/.]runtime-(?:ios|uikit)[a-z0-9]*[\/.](\d[^\/]*)[\/]/)
37
+ if (m.find()) { def v = versionOf(m.group(1)); if (v) found << v }
38
+ }
39
+ def runtime = found.max { a, b -> atLeast(a, b) ? (a == b ? 0 : 1) : -1 }
40
+ if (runtime == null || !atLeast(runtime, FLOOR)) {
41
+ logger.lifecycle("[invarn-compose] ${label.get()}: no reader (Compose runtime ${runtime ? runtime.join('.') : 'not found'}, reader needs ${FLOOR.join('.')} or later)")
42
+ return
43
+ }
44
+ def readerHome = readerHome.get()
45
+ ['src'].each { sub -> new File(readerHome, sub).eachFileRecurse { f -> if (f.name.endsWith('.kt')) new File(dir, f.name).text = f.text } }
46
+ def zvg0 = new TreeSet<String>()
47
+ def zhk0 = new TreeMap<String, String>()
48
+ def scanFile = new File(readerHome, 'scan.groovy')
49
+ def scanner = scanFile.exists() ? new GroovyShell(InvarnReaderSources.classLoader).evaluate(scanFile) : null
50
+ def ztm0 = new TreeSet<String>()
51
+ def root = new File(rootPath.get())
52
+ def buildSrc = new File(root, 'buildSrc').canonicalPath
53
+ def home = new File(gradleHomePath.get()).canonicalPath
54
+ def walk
55
+ walk = { File d ->
56
+ d.listFiles()?.each { f ->
57
+ if (f.isDirectory()) {
58
+ if (f.name == 'build' || f.name.startsWith('.') || f.canonicalPath == home) return
59
+ walk(f)
60
+ } else if (f.name.endsWith('.kt')) {
61
+ def pm = (f.text =~ /(?m)^\s*package\s+([A-Za-z_`][\w.`]*)/)
62
+ def pkg = pm.find() ? pm.group(1).replace('`', '') : ''
63
+ def key = f.name + '#' + Integer.toString(Math.abs(pkg.hashCode()), 36)
64
+ zvg0 << key
65
+ zhk0[key] = pkg
66
+ if (scanner != null && !scanner.inTestSources(f) && !f.canonicalPath.startsWith(buildSrc + File.separator))
67
+ scanner.scan(f.text, { String l -> ztm0 << String.format('%016x', scanner.hash(l)) } as java.util.function.Consumer)
68
+ }
69
+ }
70
+ }
71
+ walk(root)
72
+ def literal = { String joined ->
73
+ def chunks = []
74
+ for (int i = 0; i < joined.length(); i += 20000) chunks << joined.substring(i, Math.min(joined.length(), i + 20000))
75
+ chunks.collect { '"' + it.replace('\\', '\\\\').replace('"', '\\"').replace('$', '\\$').replace('\n', '\\n') + '"' }.join(' +\n ')
76
+ }
77
+ def lit = literal(zvg0.join('\n'))
78
+ def pkgs = literal(zhk0.collect { k, v -> k + '=' + v }.join('\n'))
79
+ def hashes = literal(ztm0.join('\n'))
80
+ new File(dir, 'zmb0.kt').text = """package zp6
81
+
82
+ internal object zmb0 {
83
+ val zvg0: Set<String>? = (${lit ?: '""'}).split('\\n').filter { it.isNotEmpty() }.toSet().takeIf { it.isNotEmpty() }
84
+ val zhk0: Map<String, String>? = (${pkgs ?: '""'}).split('\\n').filter { it.contains('=') }
85
+ .associate { it.substringBefore('=') to it.substringAfter('=') }.takeIf { it.isNotEmpty() }
86
+ val ztm0: LongArray? = (${hashes ?: '""'}).split('\\n').filter { it.isNotEmpty() }.map { it.toULong(16).toLong() }
87
+ .toLongArray().also { it.sort() }.takeIf { it.isNotEmpty() }
88
+ }
89
+ """
90
+ logger.lifecycle("[invarn-compose] ${label.get()}: reader ${readerVersion.get()} added (Compose runtime ${runtime.join('.')}, ${zvg0.size()} Kotlin files, ${ztm0.size()} literals)")
91
+ }
92
+ }
93
+
94
+ def FRAMEWORK_TASK = ~/^(embedAndSign\w*|link\w*Framework\w*|syncFramework)$/
95
+ def requested = [] as Set
96
+ gradle.startParameter.taskNames.each { String n ->
97
+ def name = n.contains(':') ? n.substring(n.lastIndexOf(':') + 1) : n
98
+ if (!(name ==~ FRAMEWORK_TASK)) return
99
+ if (n.contains(':')) {
100
+ def path = n.substring(0, n.lastIndexOf(':'))
101
+ requested << (path.startsWith(':') ? (path ?: ':') : ':' + path)
102
+ } else {
103
+ requested << gradle.startParameter.currentDir.canonicalPath
104
+ }
105
+ }
106
+
107
+ def frameworks = []
108
+
109
+ gradle.beforeProject { p ->
110
+ p.pluginManager.withPlugin('org.jetbrains.kotlin.plugin.compose') {
111
+ def ext = p.extensions.findByName('composeCompiler')
112
+ if (ext != null && ext.hasProperty('includeSourceInformation')) ext.includeSourceInformation.set(true)
113
+ }
114
+ p.pluginManager.withPlugin('org.jetbrains.kotlin.multiplatform') {
115
+ p.afterEvaluate {
116
+ def kotlin = p.extensions.getByName('kotlin')
117
+ def targets = kotlin.targets.findAll { t ->
118
+ t.hasProperty('konanTarget') && t.konanTarget.family.name() == 'IOS' && t.binaries.any { it.getClass().name.contains('Framework') }
119
+ }
120
+ if (targets) frameworks << [p, targets]
121
+ }
122
+ }
123
+ }
124
+
125
+ gradle.projectsEvaluated {
126
+ if (frameworks.isEmpty()) return
127
+ def chosen = frameworks.findAll { e -> e[0].path in requested || e[0].projectDir.canonicalPath in requested }
128
+ def why = 'the framework task asked for'
129
+ if (chosen.isEmpty()) {
130
+ def edges = [:].withDefault { [] as Set }
131
+ gradle.rootProject.allprojects.each { q ->
132
+ q.configurations.each { c ->
133
+ try {
134
+ c.dependencies.withType(ProjectDependency).each { d ->
135
+ def path = d.metaClass.respondsTo(d, 'getPath') ? d.path : d.dependencyProject.path
136
+ if (path != q.path) edges[q.path] << path
137
+ }
138
+ } catch (Exception ignored) { }
139
+ }
140
+ }
141
+ def linked = [] as Set
142
+ frameworks.each { e ->
143
+ def seen = [] as Set
144
+ def next = new ArrayDeque<String>(edges[e[0].path])
145
+ while (!next.isEmpty()) { def n = next.poll(); if (seen.add(n)) next.addAll(edges[n]) }
146
+ linked.addAll(seen)
147
+ }
148
+ chosen = frameworks.findAll { e -> !(e[0].path in linked) }
149
+ why = 'no other framework links it'
150
+ }
151
+ chosen.each { e ->
152
+ def p = e[0]
153
+ p.logger.lifecycle("[invarn-compose] ${p.path}: the reader goes into this framework (${why})")
154
+ e[1].each { t ->
155
+ def main = t.compilations.getByName('main')
156
+ def gen = p.tasks.register("invarnComposeReader${t.name.capitalize()}", InvarnReaderSources) { task ->
157
+ task.readerHome.set(readerHome)
158
+ task.readerVersion.set(READER)
159
+ task.rootPath.set(p.rootDir.absolutePath)
160
+ task.gradleHomePath.set(p.gradle.gradleUserHomeDir.absolutePath)
161
+ task.label.set("${p.path} ${t.name}".toString())
162
+ task.libraries.from(InvarnReaderSources.external(p.configurations.getByName(main.compileDependencyConfigurationName)))
163
+ task.outputDir.set(p.layout.buildDirectory.dir("generated/invarn-compose/${t.name}"))
164
+ }
165
+ main.defaultSourceSet.kotlin.srcDir(gen)
166
+ }
167
+ }
168
+ }
@@ -1 +1 @@
1
- 0.90.0
1
+ 0.95.0