@lucent-lang/lucent 0.0.4
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/app.plugin.js +92 -0
- package/bin/lucent.cjs +16 -0
- package/core/index.cjs +11 -0
- package/dist/bench-CR3E7e2e.js +304 -0
- package/dist/build-CAIrRSYA.js +7 -0
- package/dist/build-check-QozuNJm5.js +92 -0
- package/dist/check-1SCmYlqA.js +7 -0
- package/dist/clean-BVwpbJ5K.js +35 -0
- package/dist/cli.js +406 -0
- package/dist/codes-CIuwXt1S.js +260 -0
- package/dist/compiler.js +4 -0
- package/dist/confirm-BYF5eY3q.js +34 -0
- package/dist/dashboard-B-NzjjaN.js +91 -0
- package/dist/dev-BYWMP7oC.js +221 -0
- package/dist/diagnostic-BM9sXmwl.js +30 -0
- package/dist/diff-BTDo3Sro.js +44 -0
- package/dist/doctor-C0PrfWT6.js +230 -0
- package/dist/doctor-DdR4JnVc.js +30 -0
- package/dist/explain--vV1oaRl.js +35 -0
- package/dist/format-D9fnIMEx.js +53 -0
- package/dist/init-gIabu1S_.js +207 -0
- package/dist/live-steps-BGcWFM9M.js +79 -0
- package/dist/new-module-C2mtb0op.js +66 -0
- package/dist/package-manager-BnxwCySi.js +30 -0
- package/dist/package.json +3 -0
- package/dist/packages-HyskKIsY.js +150 -0
- package/dist/pipeline-CH7-2cxu.js +232 -0
- package/dist/project-D8tEet0k.js +150 -0
- package/dist/sdk-coverage-BoW_3Efd.js +64 -0
- package/dist/sdk-prefetch-mo04JDZV.js +89 -0
- package/dist/sdk-search-Iv4K3-8a.js +124 -0
- package/dist/sdk-show-CkrdlqlP.js +74 -0
- package/dist/sdks-Xoyiy2E4.js +28 -0
- package/dist/src-BD7f1_aZ.js +11493 -0
- package/dist/steps--_h-FFS7.js +24 -0
- package/dist/theme-uv5bc0aK.js +134 -0
- package/dist/tsconfig-S4uyLNzf.js +59 -0
- package/dist/version-bqpIO5sP.js +26 -0
- package/gradle/lucent-classpath.gradle +38 -0
- package/gradle/lucent-classpath.init.gradle +6 -0
- package/gradle/lucent.gradle +24 -0
- package/lib/core.cjs +106 -0
- package/lib/globals.d.ts +36 -0
- package/lib/sdk/android.d.ts +8 -0
- package/lib/sdk/core.d.ts +23 -0
- package/lib/sdk/ios.d.ts +33 -0
- package/lib/sdk/platform.d.ts +8 -0
- package/lib/sdk/thread.d.ts +8 -0
- package/metro/index.cjs +72 -0
- package/metro/index.d.ts +6 -0
- package/metro/transformer.cjs +70 -0
- package/package.json +61 -0
- package/runtime/cpp/lucent/abort.cpp +61 -0
- package/runtime/cpp/lucent/abort.h +54 -0
- package/runtime/cpp/lucent/array.h +442 -0
- package/runtime/cpp/lucent/async.h +236 -0
- package/runtime/cpp/lucent/builtins.cpp +163 -0
- package/runtime/cpp/lucent/bytes.h +129 -0
- package/runtime/cpp/lucent/console.h +17 -0
- package/runtime/cpp/lucent/core.h +129 -0
- package/runtime/cpp/lucent/date.cpp +441 -0
- package/runtime/cpp/lucent/date.h +82 -0
- package/runtime/cpp/lucent/equality.h +87 -0
- package/runtime/cpp/lucent/function.h +61 -0
- package/runtime/cpp/lucent/generator.h +244 -0
- package/runtime/cpp/lucent/helpers.h +226 -0
- package/runtime/cpp/lucent/jserror.cpp +51 -0
- package/runtime/cpp/lucent/jserror.h +66 -0
- package/runtime/cpp/lucent/jsi/convert.cpp +202 -0
- package/runtime/cpp/lucent/jsi/convert.h +612 -0
- package/runtime/cpp/lucent/jsi/host.cpp +322 -0
- package/runtime/cpp/lucent/jsi/host.h +166 -0
- package/runtime/cpp/lucent/json.cpp +243 -0
- package/runtime/cpp/lucent/json.h +164 -0
- package/runtime/cpp/lucent/json_parse.h +138 -0
- package/runtime/cpp/lucent/jsstring.cpp +874 -0
- package/runtime/cpp/lucent/jsstring.h +152 -0
- package/runtime/cpp/lucent/lucent.h +24 -0
- package/runtime/cpp/lucent/map.h +344 -0
- package/runtime/cpp/lucent/native.cpp +76 -0
- package/runtime/cpp/lucent/native.h +116 -0
- package/runtime/cpp/lucent/number.cpp +545 -0
- package/runtime/cpp/lucent/number.h +190 -0
- package/runtime/cpp/lucent/ops.h +165 -0
- package/runtime/cpp/lucent/platform/android.cpp +437 -0
- package/runtime/cpp/lucent/platform/android.h +117 -0
- package/runtime/cpp/lucent/platform/ios.h +297 -0
- package/runtime/cpp/lucent/platform/ios.mm +31 -0
- package/runtime/cpp/lucent/regexp.cpp +440 -0
- package/runtime/cpp/lucent/regexp.h +107 -0
- package/runtime/cpp/lucent/scheduler.cpp +153 -0
- package/runtime/cpp/lucent/scheduler.h +160 -0
- package/runtime/cpp/lucent/unicode_data.inc +4051 -0
- package/runtime/cpp/rn/LucentModule.cpp +35 -0
- package/runtime/cpp/rn/LucentModule.h +37 -0
- package/runtime/cpp/third_party/quickjs/LICENSE +22 -0
- package/runtime/cpp/third_party/quickjs/README.md +11 -0
- package/runtime/cpp/third_party/quickjs/cutils.c +641 -0
- package/runtime/cpp/third_party/quickjs/cutils.h +457 -0
- package/runtime/cpp/third_party/quickjs/libregexp-opcode.h +73 -0
- package/runtime/cpp/third_party/quickjs/libregexp.c +3448 -0
- package/runtime/cpp/third_party/quickjs/libregexp.h +65 -0
- package/runtime/cpp/third_party/quickjs/libunicode-table.h +5206 -0
- package/runtime/cpp/third_party/quickjs/libunicode.c +2124 -0
- package/runtime/cpp/third_party/quickjs/libunicode.h +196 -0
- package/runtime/js/index.d.ts +7 -0
- package/runtime/js/index.js +60 -0
- package/runtime/native/LucentNative.podspec +28 -0
- package/runtime/native/android/CMakeLists.txt +51 -0
- package/runtime/native/android/build.gradle +22 -0
- package/runtime/native/android/include/lucentnative.h +16 -0
- package/runtime/native/android/src/main/java/dev/lucent/LucentPackage.java +25 -0
- package/runtime/native/android/src/main/java/dev/lucent/NativeProxy.java +132 -0
- package/runtime/native/ios/LucentRegistration.mm +23 -0
- package/runtime/native/package.json +6 -0
- package/runtime/native/react-native.config.js +19 -0
- package/runtime/test/jsi/harness.cpp +181 -0
- package/schemas/build.schema.json +152 -0
- package/schemas/check.schema.json +74 -0
- package/schemas/doctor.schema.json +40 -0
- package/schemas/lucent.schema.json +43 -0
- package/schemas/sdk-prefetch.schema.json +37 -0
- package/schemas/sdk-search.schema.json +54 -0
- package/ts-plugin/index.d.ts +4 -0
- package/ts-plugin/index.js +99 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { D as sdkModule, E as sdkAvailable, O as sdkModules, y as sdkDts } from "./src-BD7f1_aZ.js";
|
|
2
|
+
import { i as projectSdk } from "./project-D8tEet0k.js";
|
|
3
|
+
//#region src/cli/commands/sdk-show.ts
|
|
4
|
+
function run({ root, positionals, out }) {
|
|
5
|
+
const t = out.theme;
|
|
6
|
+
const [symbol] = positionals;
|
|
7
|
+
if (!symbol) {
|
|
8
|
+
out.error(`${t.error(t.symbols.fail)} name a symbol: lucent sdk show <module>.<Type>[.<member>], e.g. android.os.Vibrator`);
|
|
9
|
+
return 2;
|
|
10
|
+
}
|
|
11
|
+
const sdk = projectSdk(root);
|
|
12
|
+
const parts = symbol.split(".");
|
|
13
|
+
for (const platform of ["android", "ios"]) {
|
|
14
|
+
if (!sdkAvailable(platform, sdk)) continue;
|
|
15
|
+
const known = sdkModules(platform, sdk);
|
|
16
|
+
for (let n = parts.length - 1; n >= 1; n--) {
|
|
17
|
+
const module = parts.slice(0, n).join(".");
|
|
18
|
+
if (Array.isArray(known) && !known.includes(module)) continue;
|
|
19
|
+
const r = sdkModule(platform, module, sdk);
|
|
20
|
+
if ("missing" in r) continue;
|
|
21
|
+
const [type, member] = parts.slice(n);
|
|
22
|
+
const block = declaration(sdkDts(r.schema), type);
|
|
23
|
+
if (!block) {
|
|
24
|
+
out.error(`${t.error(t.symbols.fail)} no ${type} in lucent:${platform}/${module}: lucent sdk search ${type} finds similar names`);
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
const shown = member ? memberLines(block, member) : block;
|
|
28
|
+
if (!shown) {
|
|
29
|
+
out.error(`${t.error(t.symbols.fail)} ${type} has no member ${member}`);
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
if (out.json) out.data({
|
|
33
|
+
platform,
|
|
34
|
+
module,
|
|
35
|
+
symbol,
|
|
36
|
+
declaration: shown
|
|
37
|
+
});
|
|
38
|
+
else out.print(`${t.dim(`// lucent:${platform}/${module}`)}\n${highlight(shown, t)}`);
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
out.error(`${t.error(t.symbols.fail)} no SDK module in ${symbol}: write <module>.<Type>, e.g. android.os.Vibrator or UIKit.UIDevice`);
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
function declaration(dts, name) {
|
|
46
|
+
const lines = dts.split("\n");
|
|
47
|
+
const start = lines.findIndex((l) => new RegExp(`^export (declare )?(abstract )?(class|interface|enum|const enum|type|function|const) ${name}\\b`).test(l));
|
|
48
|
+
if (start < 0) return void 0;
|
|
49
|
+
let from = start;
|
|
50
|
+
while (from > 0 && /^\s*(\/\*\*|\*)/.test(lines[from - 1])) from--;
|
|
51
|
+
if (!lines[start].trimEnd().endsWith("{")) return lines.slice(from, start + 1).join("\n");
|
|
52
|
+
let depth = 0;
|
|
53
|
+
for (let i = start; i < lines.length; i++) {
|
|
54
|
+
depth += (lines[i].match(/\{/g) ?? []).length - (lines[i].match(/\}/g) ?? []).length;
|
|
55
|
+
if (depth === 0) return lines.slice(from, i + 1).join("\n");
|
|
56
|
+
}
|
|
57
|
+
return lines.slice(from).join("\n");
|
|
58
|
+
}
|
|
59
|
+
function memberLines(block, member) {
|
|
60
|
+
const lines = block.split("\n");
|
|
61
|
+
const head = lines.find((l) => l.startsWith("export "));
|
|
62
|
+
const found = lines.filter((l) => new RegExp(`^\\s+(static |readonly |get |set |protected |private )*${member}\\b[?(<:]`).test(l));
|
|
63
|
+
return found.length ? [
|
|
64
|
+
head,
|
|
65
|
+
...found,
|
|
66
|
+
"}"
|
|
67
|
+
].join("\n") : void 0;
|
|
68
|
+
}
|
|
69
|
+
function highlight(code, t) {
|
|
70
|
+
if (!t.terminal.color) return code;
|
|
71
|
+
return code.split("\n").map((line) => /^\s*(\/\/|\/\*\*|\*)/.test(line) ? t.dim(line) : line.replace(/\b(export|declare|class|interface|enum|static|readonly|abstract|extends|implements|function|const|type|protected|private|new)\b/g, (k) => t.brand(k)).replace(/\b(string|number|boolean|void|undefined|null|Promise|Uint8Array)\b/g, (k) => t.progress(k))).join("\n");
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { run };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
//#region src/cli/sdks.ts
|
|
6
|
+
function installedSdks() {
|
|
7
|
+
const out = {};
|
|
8
|
+
if (process.platform === "darwin") {
|
|
9
|
+
const r = spawnSync("xcrun", [
|
|
10
|
+
"--sdk",
|
|
11
|
+
"iphonesimulator",
|
|
12
|
+
"--show-sdk-version"
|
|
13
|
+
], {
|
|
14
|
+
encoding: "utf8",
|
|
15
|
+
timeout: 5e3
|
|
16
|
+
});
|
|
17
|
+
if (r.status === 0 && r.stdout.trim()) out.ios = r.stdout.trim();
|
|
18
|
+
}
|
|
19
|
+
const home = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || path.join(os.homedir(), process.platform === "darwin" ? "Library/Android/sdk" : "Android/Sdk");
|
|
20
|
+
const platforms = path.join(home, "platforms");
|
|
21
|
+
if (fs.existsSync(platforms)) {
|
|
22
|
+
const newest = fs.readdirSync(platforms).filter((p) => /^android-\d+/.test(p)).sort((a, b) => Number(b.slice(8)) - Number(a.slice(8)))[0];
|
|
23
|
+
if (newest) out.android = newest;
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { installedSdks };
|