@lucent-lang/lucent 0.0.4 → 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.
Files changed (152) hide show
  1. package/README.md +97 -0
  2. package/app.plugin.js +46 -10
  3. package/dist/{bench-CR3E7e2e.js → bench-B555m0wU.js} +10 -6
  4. package/dist/{build-CAIrRSYA.js → build-UZ5Zm5m6.js} +1 -1
  5. package/dist/{build-check-QozuNJm5.js → build-check-Dmf8_yiw.js} +28 -13
  6. package/dist/{check-1SCmYlqA.js → check-D-H9WLG4.js} +1 -1
  7. package/dist/cli.js +62 -13
  8. package/dist/{codes-CIuwXt1S.js → codes-D-6LxUqD.js} +163 -7
  9. package/dist/compiler.js +4 -4
  10. package/dist/{dashboard-B-NzjjaN.js → dashboard-C8iF5-6T.js} +2 -2
  11. package/dist/{dev-BYWMP7oC.js → dev-B3lSx5CF.js} +62 -23
  12. package/dist/{diagnostic-BM9sXmwl.js → diagnostic-BvwLZQS1.js} +3 -1
  13. package/dist/{doctor-C0PrfWT6.js → doctor-CTAX3euc.js} +1 -1
  14. package/dist/{doctor-DdR4JnVc.js → doctor-CrgOAV5L.js} +1 -1
  15. package/dist/{explain--vV1oaRl.js → explain-Byit07F-.js} +1 -1
  16. package/dist/{packages-HyskKIsY.js → packages-CSmKeaAh.js} +2 -33
  17. package/dist/pipeline-BBY0df_2.js +700 -0
  18. package/dist/project-BLhWwnns.js +342 -0
  19. package/dist/sdk-coverage-DFGiDOzR.js +113 -0
  20. package/dist/sdk-diff-DpPYWzrl.js +109 -0
  21. package/dist/sdk-lock-QOxEFD1o.js +38 -0
  22. package/dist/{sdk-prefetch-mo04JDZV.js → sdk-prefetch-DX6ztlPN.js} +2 -2
  23. package/dist/{sdk-search-Iv4K3-8a.js → sdk-search-BShBL1LL.js} +2 -2
  24. package/dist/{sdk-show-CkrdlqlP.js → sdk-show-B3bI-0M7.js} +5 -4
  25. package/dist/sdk-usage-ljX5bTuZ.js +95 -0
  26. package/dist/src-DlICbK91.js +39682 -0
  27. package/dist/trace-Bi4hkmPx.js +139 -0
  28. package/lib/core.cjs +368 -1
  29. package/lib/sdk/android.d.ts +54 -1
  30. package/lib/sdk/compose.d.ts +94 -0
  31. package/lib/sdk/compose.schemas.json.gz +0 -0
  32. package/lib/sdk/core.d.ts +201 -0
  33. package/lib/sdk/ios.d.ts +75 -2
  34. package/lib/sdk/ui.d.ts +129 -0
  35. package/metro/transformer.cjs +11 -2
  36. package/package.json +2 -1
  37. package/runtime/cpp/lucent/abort.cpp +59 -11
  38. package/runtime/cpp/lucent/abort.h +22 -6
  39. package/runtime/cpp/lucent/array.h +12 -2
  40. package/runtime/cpp/lucent/async.h +101 -21
  41. package/runtime/cpp/lucent/bigint.cpp +898 -0
  42. package/runtime/cpp/lucent/bigint.h +302 -0
  43. package/runtime/cpp/lucent/buffer.cpp +228 -0
  44. package/runtime/cpp/lucent/buffer.h +328 -0
  45. package/runtime/cpp/lucent/builtins.cpp +4 -1
  46. package/runtime/cpp/lucent/bytes.h +21 -2
  47. package/runtime/cpp/lucent/callback.cpp +29 -0
  48. package/runtime/cpp/lucent/callback.h +230 -0
  49. package/runtime/cpp/lucent/compute.cpp +370 -0
  50. package/runtime/cpp/lucent/compute.h +455 -0
  51. package/runtime/cpp/lucent/conversions.h +111 -0
  52. package/runtime/cpp/lucent/core.h +16 -5
  53. package/runtime/cpp/lucent/equality.h +107 -28
  54. package/runtime/cpp/lucent/execution.cpp +416 -0
  55. package/runtime/cpp/lucent/execution.h +270 -0
  56. package/runtime/cpp/lucent/extension.cpp +97 -0
  57. package/runtime/cpp/lucent/extension.h +210 -0
  58. package/runtime/cpp/lucent/helpers.h +12 -5
  59. package/runtime/cpp/lucent/items.h +52 -0
  60. package/runtime/cpp/lucent/jserror.cpp +9 -0
  61. package/runtime/cpp/lucent/jserror.h +11 -0
  62. package/runtime/cpp/lucent/jsi/convert.cpp +138 -0
  63. package/runtime/cpp/lucent/jsi/convert.h +128 -59
  64. package/runtime/cpp/lucent/jsi/host.cpp +213 -35
  65. package/runtime/cpp/lucent/jsi/host.h +116 -16
  66. package/runtime/cpp/lucent/json.h +19 -1
  67. package/runtime/cpp/lucent/lifecycle.cpp +260 -0
  68. package/runtime/cpp/lucent/lifecycle.h +124 -0
  69. package/runtime/cpp/lucent/lucent.h +7 -0
  70. package/runtime/cpp/lucent/map.h +41 -7
  71. package/runtime/cpp/lucent/native.cpp +35 -47
  72. package/runtime/cpp/lucent/native.h +116 -26
  73. package/runtime/cpp/lucent/number.cpp +38 -38
  74. package/runtime/cpp/lucent/number.h +33 -0
  75. package/runtime/cpp/lucent/operation.h +65 -0
  76. package/runtime/cpp/lucent/ops.h +14 -6
  77. package/runtime/cpp/lucent/platform/android.cpp +223 -10
  78. package/runtime/cpp/lucent/platform/android.h +227 -4
  79. package/runtime/cpp/lucent/platform/android_activity.cpp +258 -0
  80. package/runtime/cpp/lucent/platform/android_requests.h +140 -0
  81. package/runtime/cpp/lucent/platform/compose.h +256 -0
  82. package/runtime/cpp/lucent/platform/ios.h +325 -25
  83. package/runtime/cpp/lucent/platform/ios.mm +1 -14
  84. package/runtime/cpp/lucent/platform/ios_ui.h +192 -0
  85. package/runtime/cpp/lucent/platform/ios_ui.mm +454 -0
  86. package/runtime/cpp/lucent/platform/swiftui.h +190 -0
  87. package/runtime/cpp/lucent/presentation.cpp +11 -0
  88. package/runtime/cpp/lucent/presentation.h +109 -0
  89. package/runtime/cpp/lucent/reactive.cpp +406 -0
  90. package/runtime/cpp/lucent/reactive.h +566 -0
  91. package/runtime/cpp/lucent/report.cpp +40 -0
  92. package/runtime/cpp/lucent/report.h +16 -0
  93. package/runtime/cpp/lucent/resource.cpp +83 -0
  94. package/runtime/cpp/lucent/resource.h +75 -0
  95. package/runtime/cpp/lucent/scheduler.cpp +38 -124
  96. package/runtime/cpp/lucent/scheduler.h +102 -83
  97. package/runtime/cpp/lucent/scope.cpp +308 -0
  98. package/runtime/cpp/lucent/scope.h +452 -0
  99. package/runtime/cpp/lucent/sizing.h +263 -0
  100. package/runtime/cpp/lucent/slots.h +231 -0
  101. package/runtime/cpp/lucent/trace.cpp +539 -0
  102. package/runtime/cpp/lucent/trace.h +251 -0
  103. package/runtime/cpp/lucent/transport.cpp +9 -0
  104. package/runtime/cpp/lucent/transport.h +341 -0
  105. package/runtime/cpp/lucent/view.cpp +123 -0
  106. package/runtime/cpp/lucent/view.h +157 -0
  107. package/runtime/cpp/rn/LucentComponentView.h +121 -0
  108. package/runtime/cpp/rn/LucentComponentView.mm +479 -0
  109. package/runtime/cpp/rn/LucentModule.cpp +37 -7
  110. package/runtime/cpp/rn/LucentModule.h +3 -0
  111. package/runtime/cpp/rn/LucentViewChildren.h +80 -0
  112. package/runtime/cpp/rn/LucentViewChildren.mm +211 -0
  113. package/runtime/cpp/rn/LucentViewRegistry.h +62 -0
  114. package/runtime/cpp/rn/LucentViewRequests.cpp +91 -0
  115. package/runtime/cpp/rn/LucentViewRequests.h +104 -0
  116. package/runtime/cpp/rn/LucentViewSizing.h +345 -0
  117. package/runtime/cpp/rn/LucentViewSlots.h +242 -0
  118. package/runtime/cpp/rn/LucentViewValues.h +125 -0
  119. package/runtime/cpp/rn/LucentViews.h +440 -0
  120. package/runtime/cpp/rn/LucentViewsAndroid.cpp +439 -0
  121. package/runtime/cpp/rn/LucentViewsAndroid.h +138 -0
  122. package/runtime/cpp/third_party/dragonbox/LICENSE-Boost +23 -0
  123. package/runtime/cpp/third_party/dragonbox/README.md +16 -0
  124. package/runtime/cpp/third_party/dragonbox/dragonbox.h +4440 -0
  125. package/runtime/js/index.d.ts +11 -1
  126. package/runtime/js/index.js +84 -8
  127. package/runtime/js/views.d.ts +38 -0
  128. package/runtime/js/views.js +226 -0
  129. package/runtime/native/android/CMakeLists.txt +4 -1
  130. package/runtime/native/android/src/compose/java/dev/lucent/compose/CompositionRules.kt +44 -0
  131. package/runtime/native/android/src/compose/java/dev/lucent/compose/LucentComposition.kt +161 -0
  132. package/runtime/native/android/src/main/java/dev/lucent/LucentActivities.java +292 -0
  133. package/runtime/native/android/src/main/java/dev/lucent/LucentChildren.java +174 -0
  134. package/runtime/native/android/src/main/java/dev/lucent/LucentHostView.java +232 -0
  135. package/runtime/native/android/src/main/java/dev/lucent/LucentInitializer.java +46 -0
  136. package/runtime/native/android/src/main/java/dev/lucent/LucentPackage.java +4 -3
  137. package/runtime/native/android/src/main/java/dev/lucent/LucentRequestActivity.java +92 -0
  138. package/runtime/native/android/src/main/java/dev/lucent/LucentSlotView.java +102 -0
  139. package/runtime/native/android/src/main/java/dev/lucent/LucentViewManager.java +149 -0
  140. package/runtime/native/android/src/main/java/dev/lucent/LucentViewManagers.java +16 -0
  141. package/runtime/native/android/src/main/java/dev/lucent/LucentViews.java +44 -0
  142. package/runtime/test/jsi/harness.cpp +9 -0
  143. package/schemas/build.schema.json +96 -1
  144. package/schemas/check.schema.json +56 -1
  145. package/schemas/lucent.schema.json +495 -9
  146. package/schemas/sdk-diff.schema.json +70 -0
  147. package/schemas/sdk-lock.schema.json +67 -0
  148. package/ts-plugin/index.js +77 -4
  149. package/dist/pipeline-CH7-2cxu.js +0 -232
  150. package/dist/project-D8tEet0k.js +0 -150
  151. package/dist/sdk-coverage-BoW_3Efd.js +0 -64
  152. package/dist/src-BD7f1_aZ.js +0 -11493
@@ -0,0 +1,95 @@
1
+ import { $ as sdkSchemaEntry, H as displayName, U as symbolKey, X as sdkAvailable, Z as sdkModuleArtifacts, s as sdkModule, z as compareArtifacts } from "./src-DlICbK91.js";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ //#region src/cli/sdk-usage.ts
5
+ const PLATFORMS = ["ios", "android"];
6
+ function sdkUnavailable(platform, sdk) {
7
+ if (sdkAvailable(platform, sdk)) return void 0;
8
+ const why = sdkModule(platform, platform === "ios" ? "Foundation" : "android.os", sdk);
9
+ return "missing" in why ? why.missing : `no ${platform} SDK`;
10
+ }
11
+ const LOCK_FILE = "lucent-sdk.lock.json";
12
+ const USAGE_FILE = ".lucent/sdk-usage.json";
13
+ function usedModule(platform, module, sdk) {
14
+ const artifacts = sdkModuleArtifacts(platform, module, sdk);
15
+ if (!artifacts.length) return void 0;
16
+ const schema = sdkSchemaEntry(platform, module, sdk);
17
+ return {
18
+ artifacts: artifacts.map((a) => `${a.id}#${a.contentHash}`).sort(),
19
+ ...schema ? { schema } : {}
20
+ };
21
+ }
22
+ function usedModules(modules, sdk) {
23
+ const out = {};
24
+ for (const key of [...new Set(modules)].sort()) {
25
+ const [platform, module] = key.split("/");
26
+ const used = usedModule(platform, module, sdk);
27
+ if (used) out[key] = used;
28
+ }
29
+ return out;
30
+ }
31
+ function sdkUsage(symbols, targets, imports, sdk) {
32
+ return {
33
+ format: 1,
34
+ targets: [...targets].sort(),
35
+ modules: usedModules([...imports, ...symbols.map((s) => `${s.platform}/${s.module}`)], sdk),
36
+ symbols
37
+ };
38
+ }
39
+ function readUsage(file) {
40
+ if (!fs.existsSync(file)) return void 0;
41
+ let value;
42
+ try {
43
+ value = JSON.parse(fs.readFileSync(file, "utf8"));
44
+ } catch (e) {
45
+ throw new Error(`${path.basename(file)} is not valid JSON: ${e.message}`, { cause: e });
46
+ }
47
+ if (value.format !== 1) throw new Error(`${path.basename(file)} has format ${value.format ?? "none"}; this Lucent reads format 1: run lucent sdk lock again`);
48
+ if (!Array.isArray(value.targets) || !value.modules || !Array.isArray(value.symbols)) throw new Error(`${path.basename(file)} is incomplete: run lucent sdk lock again`);
49
+ const unknown = [
50
+ ...value.targets,
51
+ ...Object.keys(value.modules).map((k) => k.split("/")[0]),
52
+ ...value.symbols.map((s) => s.platform)
53
+ ].filter((p) => !PLATFORMS.includes(p));
54
+ if (unknown.length) throw new Error(`${path.basename(file)}: unknown target ${[...new Set(unknown)].join(", ")}`);
55
+ return value;
56
+ }
57
+ function usageReadable(file) {
58
+ try {
59
+ return readUsage(file) !== void 0;
60
+ } catch {
61
+ return false;
62
+ }
63
+ }
64
+ function writeUsage(file, usage) {
65
+ const tmp = `${file}.${process.pid}.tmp`;
66
+ fs.mkdirSync(path.dirname(file), { recursive: true });
67
+ fs.writeFileSync(tmp, `${JSON.stringify(usage, null, 2)}\n`);
68
+ fs.renameSync(tmp, file);
69
+ }
70
+ function artifactText(c) {
71
+ if (!c.locked) return "not in the lock";
72
+ const gone = c.locked.filter((a) => !c.found.includes(a));
73
+ const added = c.found.filter((a) => !c.locked.includes(a));
74
+ return `${gone.join(", ") || "-"} → ${added.join(", ") || "-"}`;
75
+ }
76
+ function lockProblems(lock, found, symbols = []) {
77
+ const problems = compareArtifacts(lock.modules, found).map((c) => `lucent:${c.module}: ${artifactText(c)}`);
78
+ const locked = new Set(lock.symbols.map(symbolKey));
79
+ const unlocked = symbols.filter((s) => !locked.has(symbolKey(s)));
80
+ if (unlocked.length) {
81
+ const names = unlocked.slice(0, 3).map(displayName).join(", ");
82
+ const more = unlocked.length > 3 ? ` and ${unlocked.length - 3} more` : "";
83
+ problems.push(`${unlocked.length} SDK symbol${unlocked.length === 1 ? " the code uses is" : "s the code uses are"} not in ${LOCK_FILE}: ${names}${more}`);
84
+ }
85
+ return problems;
86
+ }
87
+ function frozenFailure(problems) {
88
+ return [
89
+ `the SDKs or SDK symbols differ from ${LOCK_FILE}:`,
90
+ ...problems.map((p) => ` ${p}`),
91
+ "lucent sdk diff shows what the installed SDKs change for the app; lucent sdk lock records them"
92
+ ].join("\n");
93
+ }
94
+ //#endregion
95
+ export { lockProblems as a, sdkUsage as c, writeUsage as d, frozenFailure as i, usageReadable as l, USAGE_FILE as n, readUsage as o, artifactText as r, sdkUnavailable as s, LOCK_FILE as t, usedModules as u };