basalt-appkit 0.1.0 → 0.2.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.
@@ -17,7 +17,10 @@
17
17
  #include "Gradients.h"
18
18
  #include "ExpoImageComponent.h"
19
19
  #include "ImageProgress.h"
20
- #ifdef BASALT_HAS_SKIA
20
+ // Either Skia: the 2.x peer in this package or the 3.x one in basalt-skia,
21
+ // which share this header's two functions and are never both linked. See
22
+ // AppKitSkiaPeer.h.
23
+ #if defined(BASALT_HAS_SKIA) || BASALT_HAS_SKIA_GRAPHITE
21
24
  #include "AppKitSkiaPeer.h"
22
25
  #endif
23
26
  #include "UIManagerAccess.h"
@@ -395,7 +398,7 @@ void AppKitMountingManager::forgetTag(Tag tag) {
395
398
  textInputs_.remove(tag);
396
399
  imageUris_.erase(tag);
397
400
  switchValues_.erase(tag);
398
- #ifdef BASALT_HAS_SKIA
401
+ #if defined(BASALT_HAS_SKIA) || BASALT_HAS_SKIA_GRAPHITE
399
402
  // Unregisters the canvas and takes its layer off the view. This is the one
400
403
  // moment a view is known to be finished with, which matters more here than
401
404
  // elsewhere: a canvas left registered keeps a Metal layer and a GPU surface
@@ -663,7 +666,7 @@ void AppKitMountingManager::updateView(RnAppKitView *view, const ShadowView &sha
663
666
  // needed the same swap for the same reason.
664
667
  applyTextInput(view, shadowView);
665
668
  applyAccessibility(view, shadowView);
666
- #ifdef BASALT_HAS_SKIA
669
+ #if defined(BASALT_HAS_SKIA) || BASALT_HAS_SKIA_GRAPHITE
667
670
  // After applyProps, which is what puts nativeID on the view -- a canvas
668
671
  // registers itself by that id and cannot be attached before it is there. And
669
672
  // before applyLayoutMetrics only incidentally: the size it reads comes from the
@@ -1,5 +1,20 @@
1
1
  // The AppKit half of a `<Canvas>`: a Metal layer inside an ordinary view.
2
2
  //
3
+ // **Two implementations, one at a time.** This header is the contract; which
4
+ // file defines it depends on which Skia the app installed. 2.x is Ganesh over
5
+ // Metal and its half is `AppKitSkiaPeer.mm` beside this, compiled when
6
+ // `BASALT_HAS_SKIA` says core's cmake/Skia.cmake built the Ganesh sources. 3.x
7
+ // is Graphite over Dawn and its half is
8
+ // `basalt-skia/native/appkit/BasaltSkiaCanvasAppKit.mm`, compiled when
9
+ // `BASALT_HAS_SKIA_GRAPHITE` says that package found Dawn. The two cannot both
10
+ // be true -- Skia.cmake refuses a 3.x install by version -- so exactly one
11
+ // definition of each function below is linked, and the mounting manager calls
12
+ // them under a guard that covers either.
13
+ //
14
+ // They differ in the component they answer to as well, which is 3.x's rename:
15
+ // a 2.x `<Canvas>` mounts a `SkiaPictureView` and a 3.x one a `SkiaView`. Both
16
+ // descriptors are registered on all three hosts.
17
+ //
3
18
  // The package's SkiaUIView is an RCTViewComponentView that does three things --
4
19
  // creates a drawing view, adds its layer as a sublayer of its own, and registers
5
20
  // it with RNSkManager under the nativeId. None of the three needs React Native;
@@ -24,6 +24,7 @@
24
24
  #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
25
25
 
26
26
  #include "SkiaPictureViewComponent.h"
27
+ #include "SkiaViewComponent.h"
27
28
  #include <react/renderer/components/FBReactNativeSpec/ComponentDescriptors.h>
28
29
  #include <react/renderer/components/image/ImageComponentDescriptor.h>
29
30
  #include <react/renderer/components/iostextinput/TextInputComponentDescriptor.h>
@@ -81,11 +82,15 @@ ComponentRegistryFactory getDefaultComponentRegistryFactory() {
81
82
  // through a TextLayoutManager, which here is the Core Text one.
82
83
  // Android's needs fbjni. Its component name is "TextInput".
83
84
  registry->add(concreteComponentDescriptorProvider<TextInputComponentDescriptor>());
84
- // @shopify/react-native-skia's <Canvas>. Registered whether or not the
85
- // build has Skia in it, for the reason the Expo one below gives: it costs
86
- // a name in a registry. Without Skia the view mounts and stays empty, and
85
+ // React Native Skia's <Canvas>, under both of its names: 2.x mounts a
86
+ // "SkiaPictureView" and 3.x a "SkiaView", and which one an app mounts is
87
+ // decided by the Skia it installed, which a host binary cannot know
88
+ // until the app's JavaScript runs. Registered whether or not the build
89
+ // has Skia in it, for the reason the Expo one below gives: it costs a
90
+ // name in a registry. Without Skia the view mounts and stays empty, and
87
91
  // an app that draws has already failed at getEnforcing('RNSkiaModule').
88
92
  registry->add(concreteComponentDescriptorProvider<SkiaPictureViewComponentDescriptor>());
93
+ registry->add(concreteComponentDescriptorProvider<SkiaViewComponentDescriptor>());
89
94
  // expo-image's view. Registered whether or not the build has Expo in it:
90
95
  // the descriptor is ordinary Fabric C++, and an app that never renders
91
96
  // one pays a registry entry. See core/ExpoImageComponent.h.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basalt-appkit",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The macOS view layer for basalt-core: an AppKit view layer, a Fabric mounting manager, and a host. Everything behind them is in basalt-core.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,6 +22,6 @@
22
22
  "react-native": "*"
23
23
  },
24
24
  "dependencies": {
25
- "basalt-core": "0.1.0"
25
+ "basalt-core": "0.2.0"
26
26
  }
27
27
  }