react-native-impeller-platform 0.0.0-stage → 0.3.1

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 (39) hide show
  1. package/README.md +165 -2
  2. package/package.json +52 -4
  3. package/react-native.config.js +24 -0
  4. package/src/bin/engine-path.js +12 -0
  5. package/src/cli/index.js +20 -0
  6. package/src/cli/init.js +112 -0
  7. package/src/cli/run.js +73 -0
  8. package/src/externaltexture/index.js +58 -0
  9. package/src/index.js +12 -0
  10. package/src/metro-shims/index.js +382 -0
  11. package/src/metro-shims/shims/Alert.impeller.js +89 -0
  12. package/src/metro-shims/shims/BaseViewConfig.impeller.js +81 -0
  13. package/src/metro-shims/shims/Button.impeller.js +100 -0
  14. package/src/metro-shims/shims/Image.impeller.js +97 -0
  15. package/src/metro-shims/shims/Platform.impeller-as-ios.js +44 -0
  16. package/src/metro-shims/shims/Platform.impeller.js +53 -0
  17. package/src/metro-shims/shims/ReactNativeFeatureFlags.impeller.js +40 -0
  18. package/src/metro-shims/shims/ReactNativeStyleAttributes.impeller.js +20 -0
  19. package/src/metro-shims/shims/TextInputState.impeller.js +100 -0
  20. package/src/metro-shims/shims/ViewConfigIgnore.impeller.js +55 -0
  21. package/src/metro-shims/shims/reanimated/clock.js +41 -0
  22. package/src/metro-shims/shims/reanimated/component.js +83 -0
  23. package/src/metro-shims/shims/reanimated/css.js +193 -0
  24. package/src/metro-shims/shims/reanimated/easing.js +47 -0
  25. package/src/metro-shims/shims/reanimated/hooks.js +191 -0
  26. package/src/metro-shims/shims/reanimated/interpolate.js +133 -0
  27. package/src/metro-shims/shims/reanimated/values.js +264 -0
  28. package/src/metro-shims/shims/reanimated.impeller.js +90 -0
  29. package/src/notifications/index.d.ts +44 -0
  30. package/src/notifications/index.js +95 -0
  31. package/src/platformview/index.js +23 -0
  32. package/src/resolve.js +238 -0
  33. package/src/selftest.js +123 -0
  34. package/src/storage/index.js +161 -0
  35. package/src/viewshot/index.js +98 -0
  36. package/src/worldraster/index.js +75 -0
  37. package/templates/app/README.md.tmpl +18 -0
  38. package/templates/app/_gitignore +1 -0
  39. package/templates/app/impeller.config.json.tmpl +11 -0
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+ // ENG-09 — WorldRaster JS shim.
3
+ //
4
+ // The engine vends ONE primitive: WorldRaster.setPixels(id, rgba, w, h),
5
+ // synchronous, throwing on a mismatched buffer. This file is a thin,
6
+ // defensive wrapper -- same `get` (not `getEnforcing`) pattern as
7
+ // package/src/storage/index.js, so an engine built before ENG-09 fails the
8
+ // one call site that needs WorldRaster rather than taking the whole bundle
9
+ // down at import.
10
+
11
+ const {TurboModuleRegistry} = require('react-native');
12
+
13
+ const Native = TurboModuleRegistry.get('WorldRaster');
14
+
15
+ function mod() {
16
+ if (Native == null) {
17
+ throw new Error(
18
+ 'WorldRaster native module is unavailable. The engine binary predates ' +
19
+ 'ENG-09 — world raster calls cannot work until the engine is updated.',
20
+ );
21
+ }
22
+ return Native;
23
+ }
24
+
25
+ function isSupported() {
26
+ return Native != null && mod().isSupported();
27
+ }
28
+
29
+ // id: string — must match the `name` prop set on the <world> host component
30
+ // this buffer is meant for. rgba: ArrayBuffer of exactly w*h*4 bytes,
31
+ // tightly packed RGBA8, row-major, top-to-bottom (the engine performs the
32
+ // Y-flip at paint time; callers never flip).
33
+ function setPixels(id, rgba, w, h) {
34
+ mod().setPixels(id, rgba, w, h);
35
+ }
36
+
37
+ // ENG-10 — GPU sprite compositing.
38
+ //
39
+ // registerSprite(textureId, rgba, w, h): upload ONE atlas entry, once.
40
+ // rgba: ArrayBuffer of exactly w*h*4 bytes, STRAIGHT (non-premultiplied)
41
+ // RGBA8, top-to-bottom — canvas ImageData layout. Re-registering the same
42
+ // textureId replaces it.
43
+ function registerSprite(textureId, rgba, w, h) {
44
+ mod().registerSprite(textureId, rgba, w, h);
45
+ }
46
+
47
+ // drawSprites(id, sprites): per frame. `id` is the <world name> to composite
48
+ // over; sprites is an Array<{textureId, x, y, w, h, alpha?}> in layout points,
49
+ // BACK-TO-FRONT (list order is paint order). Throws on an unregistered
50
+ // textureId. Pass [] to clear.
51
+ function drawSprites(id, sprites) {
52
+ mod().drawSprites(id, sprites);
53
+ }
54
+
55
+ // ENG-21 — setSampling(id, mode): how <world name=id> samples its setPixels
56
+ // terrain and every sprite drawn on it. mode 'nearest' keeps pixel-art edges
57
+ // hard at an integer scale; 'linear' (the default) blends neighbouring texels.
58
+ // Throws on any other mode. Engines built before ENG-21 lack the method; call
59
+ // isSamplingSupported() first if the app must run on them.
60
+ function setSampling(id, mode) {
61
+ mod().setSampling(id, mode);
62
+ }
63
+
64
+ function isSamplingSupported() {
65
+ return Native != null && typeof Native.setSampling === 'function';
66
+ }
67
+
68
+ module.exports = {
69
+ isSupported,
70
+ isSamplingSupported,
71
+ setPixels,
72
+ registerSprite,
73
+ drawSprites,
74
+ setSampling,
75
+ };
@@ -0,0 +1,18 @@
1
+ # impeller/
2
+
3
+ Scaffolded by `npx react-native init-impeller` for **{{displayName}}**.
4
+
5
+ - `impeller.config.json` — window + app identity. The app name registered by the
6
+ engine is `{{appName}}`, taken from your `app.json`; the engine runs the same
7
+ name it registers.
8
+ - `build/` — Metro output for `--platform impeller`. Safe to delete; regenerated
9
+ by `run-impeller`. Add it to `.gitignore`.
10
+
11
+ The engine binary is **not** here. It is installed from npm as
12
+ `@blbaker/react-native-impeller-platform-engine-<platform>-<arch>` (an optional dependency of
13
+ `react-native-impeller-platform`) and located at runtime by the resolver. Set
14
+ `IMPELLER_ENGINE_BINARY` to point at a locally built engine instead.
15
+
16
+ Run it:
17
+
18
+ npx react-native run-impeller
@@ -0,0 +1 @@
1
+ build/
@@ -0,0 +1,11 @@
1
+ {
2
+ "//": "Scaffolded by init-impeller. App identity is derived from your app.json --",
3
+ "//2": "nothing here is hardcoded to a sample app, and no path is CWD-relative.",
4
+ "appName": "{{appName}}",
5
+ "displayName": "{{displayName}}",
6
+ "window": {
7
+ "width": 1024,
8
+ "height": 768,
9
+ "title": "{{displayName}}"
10
+ }
11
+ }