@lucent-lang/lucent 0.0.4 → 0.1.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.
- package/README.md +97 -0
- package/app.plugin.js +46 -10
- package/dist/{bench-CR3E7e2e.js → bench-eEez4jhQ.js} +10 -6
- package/dist/{build-CAIrRSYA.js → build-CpUjeHFz.js} +1 -1
- package/dist/{build-check-QozuNJm5.js → build-check-BA1ZEp9s.js} +28 -13
- package/dist/{check-1SCmYlqA.js → check-BZx3FgI6.js} +1 -1
- package/dist/cli.js +62 -13
- package/dist/{codes-CIuwXt1S.js → codes-D-6LxUqD.js} +163 -7
- package/dist/compiler.js +4 -4
- package/dist/{dashboard-B-NzjjaN.js → dashboard-CC-HXhcd.js} +2 -2
- package/dist/{dev-BYWMP7oC.js → dev-DI5yL8zx.js} +62 -23
- package/dist/{diagnostic-BM9sXmwl.js → diagnostic-BvwLZQS1.js} +3 -1
- package/dist/{doctor-C0PrfWT6.js → doctor-CTAX3euc.js} +1 -1
- package/dist/{doctor-DdR4JnVc.js → doctor-CrgOAV5L.js} +1 -1
- package/dist/{explain--vV1oaRl.js → explain-Byit07F-.js} +1 -1
- package/dist/{packages-HyskKIsY.js → packages-CSmKeaAh.js} +2 -33
- package/dist/pipeline-BM_VM2X_.js +700 -0
- package/dist/project-BKNoTEEp.js +342 -0
- package/dist/sdk-coverage-iiv3JqMp.js +113 -0
- package/dist/sdk-diff-ByJ1Gw-F.js +109 -0
- package/dist/sdk-lock-BQn7IyRs.js +38 -0
- package/dist/{sdk-prefetch-mo04JDZV.js → sdk-prefetch-Bv2pNega.js} +2 -2
- package/dist/{sdk-search-Iv4K3-8a.js → sdk-search-CPGJm_Ne.js} +2 -2
- package/dist/{sdk-show-CkrdlqlP.js → sdk-show-BUkLqRnA.js} +5 -4
- package/dist/sdk-usage-0ZFMAYg1.js +95 -0
- package/dist/src-ChnmWLwn.js +40851 -0
- package/dist/trace-Bi4hkmPx.js +139 -0
- package/lib/core.cjs +368 -1
- package/lib/sdk/android.d.ts +54 -1
- package/lib/sdk/compose.d.ts +94 -0
- package/lib/sdk/compose.schemas.json.gz +0 -0
- package/lib/sdk/core.d.ts +201 -0
- package/lib/sdk/ios.d.ts +75 -2
- package/lib/sdk/ui.d.ts +129 -0
- package/metro/transformer.cjs +11 -2
- package/package.json +4 -3
- package/runtime/cpp/lucent/abort.cpp +59 -11
- package/runtime/cpp/lucent/abort.h +22 -6
- package/runtime/cpp/lucent/array.h +12 -2
- package/runtime/cpp/lucent/async.h +101 -21
- package/runtime/cpp/lucent/bigint.cpp +898 -0
- package/runtime/cpp/lucent/bigint.h +302 -0
- package/runtime/cpp/lucent/buffer.cpp +228 -0
- package/runtime/cpp/lucent/buffer.h +328 -0
- package/runtime/cpp/lucent/builtins.cpp +4 -1
- package/runtime/cpp/lucent/bytes.h +21 -2
- package/runtime/cpp/lucent/callback.cpp +29 -0
- package/runtime/cpp/lucent/callback.h +230 -0
- package/runtime/cpp/lucent/compute.cpp +370 -0
- package/runtime/cpp/lucent/compute.h +455 -0
- package/runtime/cpp/lucent/conversions.h +111 -0
- package/runtime/cpp/lucent/core.h +16 -5
- package/runtime/cpp/lucent/equality.h +107 -28
- package/runtime/cpp/lucent/execution.cpp +416 -0
- package/runtime/cpp/lucent/execution.h +270 -0
- package/runtime/cpp/lucent/extension.cpp +97 -0
- package/runtime/cpp/lucent/extension.h +210 -0
- package/runtime/cpp/lucent/helpers.h +12 -5
- package/runtime/cpp/lucent/items.h +52 -0
- package/runtime/cpp/lucent/jserror.cpp +9 -0
- package/runtime/cpp/lucent/jserror.h +11 -0
- package/runtime/cpp/lucent/jsi/convert.cpp +138 -0
- package/runtime/cpp/lucent/jsi/convert.h +128 -59
- package/runtime/cpp/lucent/jsi/host.cpp +213 -35
- package/runtime/cpp/lucent/jsi/host.h +116 -16
- package/runtime/cpp/lucent/json.h +19 -1
- package/runtime/cpp/lucent/lifecycle.cpp +260 -0
- package/runtime/cpp/lucent/lifecycle.h +124 -0
- package/runtime/cpp/lucent/lucent.h +7 -0
- package/runtime/cpp/lucent/map.h +41 -7
- package/runtime/cpp/lucent/native.cpp +35 -47
- package/runtime/cpp/lucent/native.h +116 -26
- package/runtime/cpp/lucent/number.cpp +38 -38
- package/runtime/cpp/lucent/number.h +33 -0
- package/runtime/cpp/lucent/operation.h +65 -0
- package/runtime/cpp/lucent/ops.h +14 -6
- package/runtime/cpp/lucent/platform/android.cpp +223 -10
- package/runtime/cpp/lucent/platform/android.h +227 -4
- package/runtime/cpp/lucent/platform/android_activity.cpp +258 -0
- package/runtime/cpp/lucent/platform/android_requests.h +140 -0
- package/runtime/cpp/lucent/platform/compose.h +256 -0
- package/runtime/cpp/lucent/platform/ios.h +325 -25
- package/runtime/cpp/lucent/platform/ios.mm +1 -14
- package/runtime/cpp/lucent/platform/ios_ui.h +192 -0
- package/runtime/cpp/lucent/platform/ios_ui.mm +454 -0
- package/runtime/cpp/lucent/platform/swiftui.h +190 -0
- package/runtime/cpp/lucent/presentation.cpp +11 -0
- package/runtime/cpp/lucent/presentation.h +109 -0
- package/runtime/cpp/lucent/reactive.cpp +406 -0
- package/runtime/cpp/lucent/reactive.h +566 -0
- package/runtime/cpp/lucent/report.cpp +40 -0
- package/runtime/cpp/lucent/report.h +16 -0
- package/runtime/cpp/lucent/resource.cpp +83 -0
- package/runtime/cpp/lucent/resource.h +75 -0
- package/runtime/cpp/lucent/scheduler.cpp +38 -124
- package/runtime/cpp/lucent/scheduler.h +102 -83
- package/runtime/cpp/lucent/scope.cpp +308 -0
- package/runtime/cpp/lucent/scope.h +452 -0
- package/runtime/cpp/lucent/sizing.h +263 -0
- package/runtime/cpp/lucent/slots.h +231 -0
- package/runtime/cpp/lucent/trace.cpp +539 -0
- package/runtime/cpp/lucent/trace.h +251 -0
- package/runtime/cpp/lucent/transport.cpp +9 -0
- package/runtime/cpp/lucent/transport.h +341 -0
- package/runtime/cpp/lucent/view.cpp +123 -0
- package/runtime/cpp/lucent/view.h +157 -0
- package/runtime/cpp/rn/LucentComponentView.h +121 -0
- package/runtime/cpp/rn/LucentComponentView.mm +479 -0
- package/runtime/cpp/rn/LucentModule.cpp +37 -7
- package/runtime/cpp/rn/LucentModule.h +3 -0
- package/runtime/cpp/rn/LucentViewChildren.h +80 -0
- package/runtime/cpp/rn/LucentViewChildren.mm +211 -0
- package/runtime/cpp/rn/LucentViewRegistry.h +62 -0
- package/runtime/cpp/rn/LucentViewRequests.cpp +91 -0
- package/runtime/cpp/rn/LucentViewRequests.h +104 -0
- package/runtime/cpp/rn/LucentViewSizing.h +345 -0
- package/runtime/cpp/rn/LucentViewSlots.h +242 -0
- package/runtime/cpp/rn/LucentViewValues.h +125 -0
- package/runtime/cpp/rn/LucentViews.h +440 -0
- package/runtime/cpp/rn/LucentViewsAndroid.cpp +439 -0
- package/runtime/cpp/rn/LucentViewsAndroid.h +138 -0
- package/runtime/cpp/third_party/dragonbox/LICENSE-Boost +23 -0
- package/runtime/cpp/third_party/dragonbox/README.md +16 -0
- package/runtime/cpp/third_party/dragonbox/dragonbox.h +4440 -0
- package/runtime/js/index.d.ts +11 -1
- package/runtime/js/index.js +84 -8
- package/runtime/js/views.d.ts +38 -0
- package/runtime/js/views.js +226 -0
- package/runtime/native/android/CMakeLists.txt +4 -1
- package/runtime/native/android/src/compose/java/dev/lucent/compose/CompositionRules.kt +44 -0
- package/runtime/native/android/src/compose/java/dev/lucent/compose/LucentComposition.kt +161 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentActivities.java +292 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentChildren.java +174 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentHostView.java +232 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentInitializer.java +46 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentPackage.java +4 -3
- package/runtime/native/android/src/main/java/dev/lucent/LucentRequestActivity.java +92 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentSlotView.java +102 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentViewManager.java +149 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentViewManagers.java +16 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentViews.java +44 -0
- package/runtime/test/jsi/harness.cpp +9 -0
- package/schemas/build.schema.json +96 -1
- package/schemas/check.schema.json +56 -1
- package/schemas/lucent.schema.json +495 -9
- package/schemas/sdk-diff.schema.json +70 -0
- package/schemas/sdk-lock.schema.json +67 -0
- package/ts-plugin/index.js +85 -4
- package/dist/pipeline-CH7-2cxu.js +0 -232
- package/dist/project-D8tEet0k.js +0 -150
- package/dist/sdk-coverage-BoW_3Efd.js +0 -64
- package/dist/src-BD7f1_aZ.js +0 -11493
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Generated by Lucent. Do not edit.
|
|
2
|
+
package dev.lucent;
|
|
3
|
+
|
|
4
|
+
import android.app.Application;
|
|
5
|
+
import android.content.ContentProvider;
|
|
6
|
+
import android.content.ContentValues;
|
|
7
|
+
import android.database.Cursor;
|
|
8
|
+
import android.net.Uri;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Starts Lucent's Activity tracking with the process, before any Activity
|
|
12
|
+
* or JavaScript: Android creates the providers the app's manifest declares
|
|
13
|
+
* before its first Activity. It provides no data.
|
|
14
|
+
*/
|
|
15
|
+
public final class LucentInitializer extends ContentProvider {
|
|
16
|
+
@Override
|
|
17
|
+
public boolean onCreate() {
|
|
18
|
+
LucentActivities.install((Application) getContext().getApplicationContext());
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Override
|
|
23
|
+
public Cursor query(Uri uri, String[] projection, String selection, String[] args, String order) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public String getType(Uri uri) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Override
|
|
33
|
+
public Uri insert(Uri uri, ContentValues values) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Override
|
|
38
|
+
public int delete(Uri uri, String selection, String[] args) {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Override
|
|
43
|
+
public int update(Uri uri, ContentValues values, String selection, String[] args) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -9,8 +9,9 @@ import java.util.Collections;
|
|
|
9
9
|
import java.util.List;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Lucent's module is C++ (autolinked through CMake). This package
|
|
13
|
-
* autolinking include the Java Lucent's platform code needs (NativeProxy)
|
|
12
|
+
* Lucent's module is C++ (autolinked through CMake). This package lets
|
|
13
|
+
* autolinking include the Java Lucent's platform code needs (NativeProxy),
|
|
14
|
+
* and gives React Native the managers of the app's Lucent components.
|
|
14
15
|
*/
|
|
15
16
|
public final class LucentPackage implements ReactPackage {
|
|
16
17
|
@Override
|
|
@@ -20,6 +21,6 @@ public final class LucentPackage implements ReactPackage {
|
|
|
20
21
|
|
|
21
22
|
@Override
|
|
22
23
|
public List<ViewManager> createViewManagers(ReactApplicationContext context) {
|
|
23
|
-
return
|
|
24
|
+
return LucentViewManagers.create();
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Generated by Lucent. Do not edit.
|
|
2
|
+
package dev.lucent;
|
|
3
|
+
|
|
4
|
+
import android.app.Activity;
|
|
5
|
+
import android.content.ActivityNotFoundException;
|
|
6
|
+
import android.content.Context;
|
|
7
|
+
import android.content.Intent;
|
|
8
|
+
import android.os.Bundle;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Asks for one activity result or one set of permissions on behalf of
|
|
12
|
+
* Lucent code, and hands the answer to LucentActivities. Translucent and
|
|
13
|
+
* short-lived: the app's own Activity stays as it is, and may be recreated
|
|
14
|
+
* while the request is out without losing the answer. Recreated itself (the
|
|
15
|
+
* system reclaimed it while another app's Activity was in front), it waits
|
|
16
|
+
* for the answer instead of asking again.
|
|
17
|
+
*/
|
|
18
|
+
public final class LucentRequestActivity extends Activity {
|
|
19
|
+
private static final String ID = "dev.lucent.request";
|
|
20
|
+
private static final int CODE = 1;
|
|
21
|
+
|
|
22
|
+
private LucentActivities.Request request;
|
|
23
|
+
private boolean done;
|
|
24
|
+
|
|
25
|
+
static Intent intent(Context from, long id) {
|
|
26
|
+
return new Intent(from, LucentRequestActivity.class).putExtra(ID, id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
protected void onCreate(Bundle saved) {
|
|
31
|
+
super.onCreate(saved);
|
|
32
|
+
|
|
33
|
+
request = LucentActivities.attach(getIntent().getLongExtra(ID, 0), this);
|
|
34
|
+
|
|
35
|
+
// Forgotten meanwhile, or a new process after the old one died: nobody waits for the answer.
|
|
36
|
+
if (request == null) {
|
|
37
|
+
done = true;
|
|
38
|
+
finish();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (saved != null) return;
|
|
43
|
+
|
|
44
|
+
if (request.kind == LucentActivities.PERMISSIONS) {
|
|
45
|
+
requestPermissions(request.permissions, CODE);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
startActivityForResult(request.intent, CODE);
|
|
51
|
+
} catch (ActivityNotFoundException | SecurityException e) {
|
|
52
|
+
end();
|
|
53
|
+
LucentActivities.failed(request, "ERR_ACTIVITY_NOT_FOUND", String.valueOf(e.getMessage()));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
protected void onActivityResult(int code, int resultCode, Intent data) {
|
|
59
|
+
super.onActivityResult(code, resultCode, data);
|
|
60
|
+
|
|
61
|
+
end();
|
|
62
|
+
LucentActivities.answered(request, resultCode, data);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Override
|
|
66
|
+
public void onRequestPermissionsResult(int code, String[] permissions, int[] grants) {
|
|
67
|
+
super.onRequestPermissionsResult(code, permissions, grants);
|
|
68
|
+
|
|
69
|
+
end();
|
|
70
|
+
LucentActivities.answered(request, permissions, grants);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The request was forgotten: close what it started, if Android lets the app. */
|
|
74
|
+
void abandon() {
|
|
75
|
+
done = true;
|
|
76
|
+
finishActivity(CODE);
|
|
77
|
+
finish();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private void end() {
|
|
81
|
+
done = true;
|
|
82
|
+
finish();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Override
|
|
86
|
+
protected void onDestroy() {
|
|
87
|
+
super.onDestroy();
|
|
88
|
+
|
|
89
|
+
if (isFinishing() && !done && request != null)
|
|
90
|
+
LucentActivities.failed(request, "ERR_REQUEST_ENDED", "The request ended without an answer");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Generated by Lucent. Do not edit.
|
|
2
|
+
package dev.lucent;
|
|
3
|
+
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.view.ViewGroup;
|
|
7
|
+
import android.view.ViewParent;
|
|
8
|
+
import android.view.ViewTreeObserver;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The view a Lucent component's React children are mounted in: its slot,
|
|
12
|
+
* which the component's setup places in its view ({@link LucentChildren}
|
|
13
|
+
* says who owns what). React Native lays each child out, at the frame Yoga
|
|
14
|
+
* gave it in the component's coordinates; the slot never does. It shows
|
|
15
|
+
* them there wherever it is: it scrolls its content by its own position in
|
|
16
|
+
* the host, at each layout and before each frame, and tells the host where
|
|
17
|
+
* it is then, so that Yoga lays the children out in its rectangle. Like any
|
|
18
|
+
* view group, it clips them to its bounds. It fills the space its parent
|
|
19
|
+
* offers.
|
|
20
|
+
*/
|
|
21
|
+
final class LucentSlotView extends ViewGroup implements ViewTreeObserver.OnPreDrawListener {
|
|
22
|
+
/** Where the slot is in its host, in pixels, as the host hears it. */
|
|
23
|
+
interface Placed {
|
|
24
|
+
void place(int x, int y, int width, int height);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The component's host view, whose coordinates the children's frames are in. */
|
|
28
|
+
private final View host;
|
|
29
|
+
|
|
30
|
+
private final Placed placed;
|
|
31
|
+
|
|
32
|
+
LucentSlotView(Context context, View host, Placed placed) {
|
|
33
|
+
super(context);
|
|
34
|
+
this.host = host;
|
|
35
|
+
this.placed = placed;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
protected void onMeasure(int widthSpec, int heightSpec) {
|
|
40
|
+
setMeasuredDimension(offered(widthSpec), offered(heightSpec));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Override
|
|
44
|
+
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
45
|
+
// React Native lays the children out.
|
|
46
|
+
align();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
protected void onAttachedToWindow() {
|
|
51
|
+
super.onAttachedToWindow();
|
|
52
|
+
getViewTreeObserver().addOnPreDrawListener(this);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
protected void onDetachedFromWindow() {
|
|
57
|
+
getViewTreeObserver().removeOnPreDrawListener(this);
|
|
58
|
+
super.onDetachedFromWindow();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** An ancestor may have moved it within the host without laying it out. */
|
|
62
|
+
@Override
|
|
63
|
+
public boolean onPreDraw() {
|
|
64
|
+
align();
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Scrolls its content by its origin in the host: children show where Yoga
|
|
70
|
+
* put them. Then tells the host where it is.
|
|
71
|
+
*/
|
|
72
|
+
private void align() {
|
|
73
|
+
int x = 0;
|
|
74
|
+
int y = 0;
|
|
75
|
+
|
|
76
|
+
for (View v = this; v != host; ) {
|
|
77
|
+
x += v.getLeft();
|
|
78
|
+
y += v.getTop();
|
|
79
|
+
|
|
80
|
+
ViewParent parent = v.getParent();
|
|
81
|
+
|
|
82
|
+
// Not (or no longer) in the host.
|
|
83
|
+
if (!(parent instanceof View)) return;
|
|
84
|
+
|
|
85
|
+
v = (View) parent;
|
|
86
|
+
|
|
87
|
+
if (v != host) {
|
|
88
|
+
x -= v.getScrollX();
|
|
89
|
+
y -= v.getScrollY();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (getScrollX() != x || getScrollY() != y) scrollTo(x, y);
|
|
94
|
+
|
|
95
|
+
placed.place(x, y, getWidth(), getHeight());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The size a spec offers: all of it, or none when it offers no bound. */
|
|
99
|
+
private static int offered(int spec) {
|
|
100
|
+
return MeasureSpec.getMode(spec) == MeasureSpec.UNSPECIFIED ? 0 : MeasureSpec.getSize(spec);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// Generated by Lucent. Do not edit.
|
|
2
|
+
package dev.lucent;
|
|
3
|
+
|
|
4
|
+
import android.view.View;
|
|
5
|
+
import com.facebook.react.bridge.Arguments;
|
|
6
|
+
import com.facebook.react.bridge.NativeArray;
|
|
7
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
8
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
9
|
+
import com.facebook.react.uimanager.IViewGroupManager;
|
|
10
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
|
11
|
+
import com.facebook.react.uimanager.SimpleViewManager;
|
|
12
|
+
import com.facebook.react.uimanager.StateWrapper;
|
|
13
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The manager of a Lucent component's views. Each component has its own
|
|
17
|
+
* (dev.lucent.generated.<registration>Manager), named as the component is
|
|
18
|
+
* registered; what they do is the C++ host's (LucentViews). React Native
|
|
19
|
+
* mounts a view's children through it (it is an IViewGroupManager): they
|
|
20
|
+
* go in the component's slot, and React Native lays them out.
|
|
21
|
+
*/
|
|
22
|
+
public abstract class LucentViewManager extends SimpleViewManager<LucentHostView>
|
|
23
|
+
implements IViewGroupManager<LucentHostView> {
|
|
24
|
+
private final String name;
|
|
25
|
+
private final boolean takesChildren;
|
|
26
|
+
|
|
27
|
+
protected LucentViewManager(String name) {
|
|
28
|
+
this(name, false);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `takesChildren`: the component takes React children, which its views keep a slot for. */
|
|
32
|
+
protected LucentViewManager(String name, boolean takesChildren) {
|
|
33
|
+
this.name = name;
|
|
34
|
+
this.takesChildren = takesChildren;
|
|
35
|
+
|
|
36
|
+
// Pools dropped views when the app turns enableViewRecycling on: a
|
|
37
|
+
// recycled shell gets a new host, and its next commit a new mount.
|
|
38
|
+
setupViewRecycling();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
public String getName() {
|
|
43
|
+
return name;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
protected LucentHostView createViewInstance(ThemedReactContext context) {
|
|
48
|
+
return new LucentHostView(context, name, takesChildren);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
public void updateProperties(LucentHostView view, ReactStylesDiffMap props) {
|
|
53
|
+
// React Native's view props (style, accessibility…) first, then the component's own.
|
|
54
|
+
super.updateProperties(view, props);
|
|
55
|
+
|
|
56
|
+
// The host consumes what it is given: React Native keeps its map.
|
|
57
|
+
WritableNativeMap own = new WritableNativeMap();
|
|
58
|
+
own.merge(props.internal_backingMap());
|
|
59
|
+
|
|
60
|
+
int surface = ((ThemedReactContext) view.getContext()).getSurfaceId();
|
|
61
|
+
view.host = LucentViews.update(view.host, view, name, view.getId(), surface, own);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Override
|
|
65
|
+
public Object updateState(LucentHostView view, ReactStylesDiffMap props, StateWrapper state) {
|
|
66
|
+
if (view.host != 0 && state != null) LucentViews.state(view.host, state);
|
|
67
|
+
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Yoga's border and padding: the shell lays the content out inside them, as iOS does. */
|
|
72
|
+
@Override
|
|
73
|
+
public void setPadding(LucentHostView view, int left, int top, int right, int bottom) {
|
|
74
|
+
view.setPadding(left, top, right, bottom);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Override
|
|
78
|
+
public void receiveCommand(
|
|
79
|
+
LucentHostView view, String command, ReadableArray args) {
|
|
80
|
+
if (view.host == 0) return;
|
|
81
|
+
|
|
82
|
+
NativeArray list =
|
|
83
|
+
args instanceof NativeArray
|
|
84
|
+
? (NativeArray) args
|
|
85
|
+
: Arguments.makeNativeArray(args == null ? null : args.toArrayList());
|
|
86
|
+
|
|
87
|
+
LucentViews.command(view.host, command, list);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// React Native's children of the component: in its order, whatever the shell holds.
|
|
91
|
+
|
|
92
|
+
@Override
|
|
93
|
+
public void addView(LucentHostView parent, View child, int index) {
|
|
94
|
+
parent.children.add(child, index);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Override
|
|
98
|
+
public View getChildAt(LucentHostView parent, int index) {
|
|
99
|
+
return parent.children.childAt(index);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@Override
|
|
103
|
+
public int getChildCount(LucentHostView parent) {
|
|
104
|
+
return parent.children.count();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Override
|
|
108
|
+
public void removeViewAt(LucentHostView parent, int index) {
|
|
109
|
+
parent.children.remove(index);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Override
|
|
113
|
+
public void removeAllViews(LucentHostView parent) {
|
|
114
|
+
for (int i = parent.children.count() - 1; i >= 0; i--) parent.children.remove(i);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** React Native lays the children out, not the shell or the slot. */
|
|
118
|
+
@Override
|
|
119
|
+
public boolean needsCustomLayoutForChildren() {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@Override
|
|
124
|
+
public void onDropViewInstance(LucentHostView view) {
|
|
125
|
+
super.onDropViewInstance(view);
|
|
126
|
+
|
|
127
|
+
release(view);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Override
|
|
131
|
+
protected LucentHostView prepareToRecycleView(
|
|
132
|
+
ThemedReactContext context, LucentHostView view) {
|
|
133
|
+
LucentHostView shell = super.prepareToRecycleView(context, view);
|
|
134
|
+
|
|
135
|
+
// A recycled shell starts a new mount: none of this one's work (or slot) reaches it.
|
|
136
|
+
release(view);
|
|
137
|
+
view.setContent(null);
|
|
138
|
+
view.children.endMount();
|
|
139
|
+
|
|
140
|
+
return shell;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private static void release(LucentHostView view) {
|
|
144
|
+
if (view.host == 0) return;
|
|
145
|
+
|
|
146
|
+
LucentViews.drop(view.host);
|
|
147
|
+
view.host = 0;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by Lucent. Do not edit.
|
|
2
|
+
package dev.lucent;
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
5
|
+
import java.util.Collections;
|
|
6
|
+
import java.util.List;
|
|
7
|
+
|
|
8
|
+
/** The managers of the app's Lucent components (written by lucent build when it has any). */
|
|
9
|
+
final class LucentViewManagers {
|
|
10
|
+
private LucentViewManagers() {}
|
|
11
|
+
|
|
12
|
+
@SuppressWarnings("rawtypes")
|
|
13
|
+
static List<ViewManager> create() {
|
|
14
|
+
return Collections.emptyList();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generated by Lucent. Do not edit.
|
|
2
|
+
package dev.lucent;
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.bridge.NativeArray;
|
|
5
|
+
import com.facebook.react.bridge.NativeMap;
|
|
6
|
+
import com.facebook.react.uimanager.StateWrapper;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The C++ side of Lucent components' views. Its natives are bound when
|
|
10
|
+
* React Native's renderer registers the components' descriptors, before
|
|
11
|
+
* any of their views exists. `host` is the C++ host of one view; 0 is none.
|
|
12
|
+
*/
|
|
13
|
+
final class LucentViews {
|
|
14
|
+
private LucentViews() {}
|
|
15
|
+
|
|
16
|
+
/** Applies a commit's props (what changed) to `view`'s host, made first if `host` is 0; the host. */
|
|
17
|
+
static native long update(
|
|
18
|
+
long host, LucentHostView view, String component, int tag, int surface, NativeMap props);
|
|
19
|
+
|
|
20
|
+
/** The view is attached: its mount is committed, and the component sets up. */
|
|
21
|
+
static native void attach(long host);
|
|
22
|
+
|
|
23
|
+
/** The size state of the commit being mounted (the renderer's StateWrapperImpl). */
|
|
24
|
+
static native void state(long host, StateWrapper state);
|
|
25
|
+
|
|
26
|
+
/** The content asked for a layout: it may have changed size. */
|
|
27
|
+
static native void contentChanged(long host);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The slot's place: `place` holds its rectangle and the content box's
|
|
31
|
+
* (x, y, width, height each, in the shell's pixels); the shell lays out
|
|
32
|
+
* right to left if `rtl`, its style's left and right swapped if `swapped`.
|
|
33
|
+
*/
|
|
34
|
+
static native void slotPlaced(long host, int[] place, boolean rtl, boolean swapped);
|
|
35
|
+
|
|
36
|
+
/** Runs a command JavaScript sent the component (its ref's method). */
|
|
37
|
+
static native void command(long host, String name, NativeArray args);
|
|
38
|
+
|
|
39
|
+
/** Ends the host's mount and frees it (the view is dropped or recycled). */
|
|
40
|
+
static native void drop(long host);
|
|
41
|
+
|
|
42
|
+
/** Reports what went wrong in a view's Java side, as the rest of Lucent reports errors. */
|
|
43
|
+
static native void report(String message);
|
|
44
|
+
}
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
// Globals available to scripts:
|
|
7
7
|
// __lucent object with every registered Lucent module
|
|
8
8
|
// print(...args) writes a line to stdout
|
|
9
|
+
//
|
|
10
|
+
// Lucent's console.log, warn and error write a line to stdout too, in order
|
|
11
|
+
// with print's, so tests compare what Lucent code logs.
|
|
9
12
|
// __reference undefined unless a reference script defines it
|
|
10
13
|
//
|
|
11
14
|
// The event loop runs JS tasks posted by Lucent, Hermes microtasks and
|
|
@@ -22,6 +25,7 @@
|
|
|
22
25
|
#include <mutex>
|
|
23
26
|
#include <sstream>
|
|
24
27
|
|
|
28
|
+
#include "lucent/console.h"
|
|
25
29
|
#include "lucent/jsi/convert.h"
|
|
26
30
|
#include "lucent/jsi/host.h"
|
|
27
31
|
|
|
@@ -113,6 +117,11 @@ int main(int argc, char** argv) {
|
|
|
113
117
|
std::fprintf(stderr, "usage: harness <script.js>...\n");
|
|
114
118
|
return 2;
|
|
115
119
|
}
|
|
120
|
+
lucent::setConsoleSink([](lucent::ConsoleLevel, const lucent::String& message) {
|
|
121
|
+
std::printf("%s\n", message.toUtf8().c_str());
|
|
122
|
+
std::fflush(stdout);
|
|
123
|
+
});
|
|
124
|
+
|
|
116
125
|
auto config = ::hermes::vm::RuntimeConfig::Builder().withMicrotaskQueue(true).build();
|
|
117
126
|
std::unique_ptr<jsi::Runtime> runtime = facebook::hermes::makeHermesRuntime(config);
|
|
118
127
|
jsi::Runtime& rt = *runtime;
|
|
@@ -2,7 +2,19 @@
|
|
|
2
2
|
"$id": "https://lucent-lang.dev/schemas/build.schema.json",
|
|
3
3
|
"title": "lucent build --json",
|
|
4
4
|
"type": "object",
|
|
5
|
-
"required": [
|
|
5
|
+
"required": [
|
|
6
|
+
"ok",
|
|
7
|
+
"upToDate",
|
|
8
|
+
"out",
|
|
9
|
+
"modules",
|
|
10
|
+
"steps",
|
|
11
|
+
"diagnostics",
|
|
12
|
+
"warnings",
|
|
13
|
+
"notices",
|
|
14
|
+
"next",
|
|
15
|
+
"actions",
|
|
16
|
+
"ms"
|
|
17
|
+
],
|
|
6
18
|
"additionalProperties": false,
|
|
7
19
|
"properties": {
|
|
8
20
|
"ok": {
|
|
@@ -105,10 +117,65 @@
|
|
|
105
117
|
"docs": {
|
|
106
118
|
"type": "string",
|
|
107
119
|
"description": "Where the code is explained"
|
|
120
|
+
},
|
|
121
|
+
"severity": {
|
|
122
|
+
"const": "warning",
|
|
123
|
+
"description": "Present on warnings only"
|
|
108
124
|
}
|
|
109
125
|
}
|
|
110
126
|
}
|
|
111
127
|
},
|
|
128
|
+
"warnings": {
|
|
129
|
+
"type": "array",
|
|
130
|
+
"items": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"required": ["code", "message"],
|
|
133
|
+
"properties": {
|
|
134
|
+
"code": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"pattern": "^LUCENT\\d{4}$",
|
|
137
|
+
"description": "Stable code; lucent explain <code> describes it"
|
|
138
|
+
},
|
|
139
|
+
"message": {
|
|
140
|
+
"type": "string"
|
|
141
|
+
},
|
|
142
|
+
"file": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"description": "Relative to the project root"
|
|
145
|
+
},
|
|
146
|
+
"line": {
|
|
147
|
+
"type": "integer",
|
|
148
|
+
"minimum": 1
|
|
149
|
+
},
|
|
150
|
+
"column": {
|
|
151
|
+
"type": "integer",
|
|
152
|
+
"minimum": 1
|
|
153
|
+
},
|
|
154
|
+
"start": {
|
|
155
|
+
"type": "integer",
|
|
156
|
+
"minimum": 0,
|
|
157
|
+
"description": "Offset of the span in the file"
|
|
158
|
+
},
|
|
159
|
+
"length": {
|
|
160
|
+
"type": "integer",
|
|
161
|
+
"minimum": 0
|
|
162
|
+
},
|
|
163
|
+
"fix": {
|
|
164
|
+
"type": "string",
|
|
165
|
+
"description": "How to fix it, in one line"
|
|
166
|
+
},
|
|
167
|
+
"docs": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"description": "Where the code is explained"
|
|
170
|
+
},
|
|
171
|
+
"severity": {
|
|
172
|
+
"const": "warning",
|
|
173
|
+
"description": "Present on warnings only"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"description": "Warnings: reported, but the build goes on"
|
|
178
|
+
},
|
|
112
179
|
"notices": {
|
|
113
180
|
"type": "array",
|
|
114
181
|
"items": {
|
|
@@ -144,6 +211,34 @@
|
|
|
144
211
|
}
|
|
145
212
|
}
|
|
146
213
|
},
|
|
214
|
+
"actions": {
|
|
215
|
+
"type": "array",
|
|
216
|
+
"description": "Every action the build's changes need, strongest first, each with the targets and the native-package files that need it. Empty when nothing changed.",
|
|
217
|
+
"items": {
|
|
218
|
+
"type": "object",
|
|
219
|
+
"required": ["kind", "targets", "files"],
|
|
220
|
+
"additionalProperties": false,
|
|
221
|
+
"properties": {
|
|
222
|
+
"kind": {
|
|
223
|
+
"enum": ["reinstall", "relink", "compile-native", "repackage", "reload-js"],
|
|
224
|
+
"description": "reinstall: the app's configuration (Info.plist, entitlements, manifest) changed; relink: native dependencies or build files changed; compile-native: native code changed; repackage: resources or assets changed; reload-js: only JavaScript proxies changed"
|
|
225
|
+
},
|
|
226
|
+
"targets": {
|
|
227
|
+
"type": "array",
|
|
228
|
+
"items": {
|
|
229
|
+
"type": "string"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"files": {
|
|
233
|
+
"type": "array",
|
|
234
|
+
"items": {
|
|
235
|
+
"type": "string"
|
|
236
|
+
},
|
|
237
|
+
"description": "Relative to the native package; resolved.json#ios.infoPlist names a part of the resolved manifest"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
},
|
|
147
242
|
"ms": {
|
|
148
243
|
"type": "number",
|
|
149
244
|
"minimum": 0
|