ketoy-dev 0.1.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.
- package/LICENSE +17 -0
- package/README.md +101 -0
- package/SECURITY.md +34 -0
- package/dist/ketoy.js +3165 -0
- package/dist/ketoy.js.map +1 -0
- package/package.json +78 -0
- package/skills/ketoy/README.md +50 -0
- package/skills/ketoy/SKILL.md +148 -0
- package/skills/ketoy/examples/capabilities-stubs.kt +60 -0
- package/skills/ketoy/examples/hilt-config.kt +192 -0
- package/skills/ketoy/examples/no-hilt-config.kt +101 -0
- package/skills/ketoy/examples/todo-screen.kt +156 -0
- package/skills/ketoy/guides/build-and-analyze.md +87 -0
- package/skills/ketoy/guides/diagnose-errors.md +129 -0
- package/skills/ketoy/guides/init-project.md +127 -0
- package/skills/ketoy/guides/migrate.md +190 -0
- package/skills/ketoy/guides/publish-deferred.md +46 -0
- package/skills/ketoy/guides/safe-edits.md +141 -0
- package/skills/ketoy/reference/architecture-cheatsheet.md +122 -0
- package/skills/ketoy/reference/capabilities.md +122 -0
- package/skills/ketoy/reference/forbidden-apis.md +149 -0
- package/skills/ketoy/reference/supported-composables.md +80 -0
- package/skills/ketoy/reference/supported-constructors.md +57 -0
- package/skills/ketoy/reference/supported-modifiers.md +76 -0
- package/skills/ketoy/templates/app-build.gradle.kts.tmpl +109 -0
- package/skills/ketoy/templates/ketoy-capabilities.json.tmpl +21 -0
- package/skills/ketoy/templates/manifest-snippet.xml.tmpl +33 -0
- package/templates/HelloKetoyScreen.kt.tmpl +51 -0
- package/templates/MainActivity.kt.tmpl +53 -0
- package/templates/MyApplication.kt.tmpl +88 -0
- package/templates/ketoy-capabilities.json.tmpl +5 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
package {{PACKAGE}}
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import dev.ketoy.adapters.material3.materialDrawableResolver
|
|
5
|
+
import dev.ketoy.adapters.material3.materialFontFamilyResolver
|
|
6
|
+
import dev.ketoy.adapters.material3.materialIconsResolver
|
|
7
|
+
import dev.ketoy.adapters.material3.registerGeneratedAdapters
|
|
8
|
+
import dev.ketoy.adapters.material3.registerGeneratedConstructors
|
|
9
|
+
import dev.ketoy.capabilities.core.registerCoreCapabilities
|
|
10
|
+
import dev.ketoy.runtime.KetoyConfig
|
|
11
|
+
import dev.ketoy.runtime.KetoyRuntime
|
|
12
|
+
import dev.ketoy.runtime.bundle.KetoyBundleLoader
|
|
13
|
+
import dev.ketoy.runtime.capability.CapabilityRegistry
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Ketoy application bootstrap.
|
|
17
|
+
*
|
|
18
|
+
* Owns the [KetoyRuntime] singleton and a [KetoyBundleLoader] keyed to it.
|
|
19
|
+
* Both are exposed to `MainActivity` and published into the composition via
|
|
20
|
+
* `LocalKetoyRuntime` / `LocalKetoyBundleLoader` so `KetoyScreen` can pick
|
|
21
|
+
* them up without manual wiring.
|
|
22
|
+
*
|
|
23
|
+
* Register host-side capabilities (network / storage / app-specific) on the
|
|
24
|
+
* [CapabilityRegistry] returned by `buildCapabilityRegistry()`. Register
|
|
25
|
+
* Compose adapters + constructor adapters on the registries hanging off
|
|
26
|
+
* [KetoyRuntime] — NOT on the capability registry.
|
|
27
|
+
*/
|
|
28
|
+
class MyApplication : Application() {
|
|
29
|
+
|
|
30
|
+
lateinit var ketoyRuntime: KetoyRuntime
|
|
31
|
+
private set
|
|
32
|
+
|
|
33
|
+
lateinit var ketoyBundleLoader: KetoyBundleLoader
|
|
34
|
+
private set
|
|
35
|
+
|
|
36
|
+
override fun onCreate() {
|
|
37
|
+
super.onCreate()
|
|
38
|
+
|
|
39
|
+
val capabilityRegistry =
|
|
40
|
+
CapabilityRegistry().apply {
|
|
41
|
+
registerCoreCapabilities(context = this@MyApplication)
|
|
42
|
+
// App-specific capabilities (0x4000+) go here:
|
|
43
|
+
// registerSuspend(0x4000) { args -> ... }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Resource resolvers — the KBC compiler plugin atomic-collapses
|
|
47
|
+
// `FontFamily(Font(R.font.X))` and `painterResource(R.drawable.X)`
|
|
48
|
+
// into `KBCValue.StringLiteral("X")` at compile time; at render time
|
|
49
|
+
// `KBCParamSet.getFontFamily` / `getPainter` dispatches the bare
|
|
50
|
+
// resource name through these host-supplied resolvers. R8 is safe
|
|
51
|
+
// because we reference the `R.font.X` / `R.drawable.X` fields as
|
|
52
|
+
// compile-time reads here — the shrinker sees them and keeps the
|
|
53
|
+
// resources alive in release builds. No `-keep` rules required.
|
|
54
|
+
val fontResolver = materialFontFamilyResolver {
|
|
55
|
+
// register("courgette_regular", FontFamily(Font(R.font.courgette_regular)))
|
|
56
|
+
}
|
|
57
|
+
val drawableResolver = materialDrawableResolver {
|
|
58
|
+
// register("logo", R.drawable.logo)
|
|
59
|
+
}
|
|
60
|
+
val iconsResolver = materialIconsResolver {
|
|
61
|
+
// registerFilled("Settings", androidx.compose.material.icons.Icons.Filled.Settings)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
val config = KetoyConfig(
|
|
65
|
+
// Production-safe default: signature verification ON. Until you
|
|
66
|
+
// generate a keypair (`openssl genpkey -algorithm Ed25519 ...`)
|
|
67
|
+
// and ship the matching public key at
|
|
68
|
+
// `assets/ketoy/keys/release-public.key`, flip this to false OR
|
|
69
|
+
// pass `publicKey = KetoyKeystore.loadFromAsset(this, "...")`.
|
|
70
|
+
enableSignatureVerification = false,
|
|
71
|
+
fontFamilyResolver = fontResolver,
|
|
72
|
+
drawableResolver = drawableResolver,
|
|
73
|
+
imageVectorResolver = iconsResolver,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
ketoyRuntime = KetoyRuntime(
|
|
77
|
+
capabilityRegistry = capabilityRegistry,
|
|
78
|
+
config = config,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
// Material3 composable + constructor adapters go on the dedicated
|
|
82
|
+
// registries hanging off the runtime — not on CapabilityRegistry.
|
|
83
|
+
registerGeneratedAdapters(ketoyRuntime.adapterRegistry)
|
|
84
|
+
registerGeneratedConstructors(ketoyRuntime.constructorRegistry)
|
|
85
|
+
|
|
86
|
+
ketoyBundleLoader = KetoyBundleLoader(ketoyRuntime, this)
|
|
87
|
+
}
|
|
88
|
+
}
|