@lucent-lang/lucent 0.1.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucent-lang/lucent",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Write native React Native modules in TypeScript: the Lucent compiler, CLI, Metro integration, Expo config plugin and editor plugin",
5
5
  "homepage": "https://lucent-lang.dev",
6
6
  "bugs": "https://github.com/Fausto95/lucent/issues",
@@ -55,8 +55,8 @@
55
55
  "ink-testing-library": "^4.0.0",
56
56
  "@lucent-lang/bindgen": "0.0.3",
57
57
  "@lucent-lang/codegen": "0.0.3",
58
- "@lucent-lang/compiler": "0.0.3",
59
- "@lucent-lang/runtime": "0.0.3"
58
+ "@lucent-lang/runtime": "0.0.3",
59
+ "@lucent-lang/compiler": "0.0.3"
60
60
  },
61
61
  "scripts": {}
62
62
  }
@@ -11,8 +11,12 @@ const TYPESCRIPT_PASSTHROUGH = "LUCENT9001";
11
11
 
12
12
  // A platform's Lucent files write JSX with its toolkit (the compiler's TOOLKITS,
13
13
  // ui/toolkits.ts; a test keeps them equal): their implicit JSX runtime import
14
- // resolves to lucent:<toolkit>, whose module declares the JSX namespace.
14
+ // resolves to lucent:<toolkit>, whose module declares the JSX namespace. A
15
+ // shared Lucent file writes either toolkit's, each in its platform's code:
16
+ // its runtime is lucent:jsx, which `lucent build` writes beside them.
15
17
  const TOOLKIT_JSX = { ios: "swiftui", android: "compose" };
18
+ const SHARED_JSX = "jsx";
19
+ const LUCENT_JSX_FILE = /\.lucent\.tsx$/;
16
20
  const PLATFORM_FILE = /\.(ios|android)\.lucent\.tsx$/;
17
21
  const JSX_RUNTIME = /\/jsx-(dev-)?runtime$/;
18
22
 
@@ -22,7 +26,7 @@ const JSX_RUNTIME = /\/jsx-(dev-)?runtime$/;
22
26
  * file, and the host resolves that import. An app whose JSX has no runtime
23
27
  * import (React Native's `jsx: react-native`) gets React's as its import
24
28
  * source, which types React's JSX alike (react/jsx-runtime's JSX is
25
- * React.JSX), once it has platform Lucent files.
29
+ * React.JSX), once it has Lucent files with JSX.
26
30
  */
27
31
  function withToolkitJsx(ts, host) {
28
32
  const settings = host.getCompilationSettings.bind(host);
@@ -33,7 +37,7 @@ function withToolkitJsx(ts, host) {
33
37
  options.jsx === ts.JsxEmit.ReactJSXDev ||
34
38
  options.jsx === ts.JsxEmit.React ||
35
39
  options.jsxImportSource;
36
- if (imported || !host.getScriptFileNames().some((f) => PLATFORM_FILE.test(f))) return options;
40
+ if (imported || !host.getScriptFileNames().some((f) => LUCENT_JSX_FILE.test(f))) return options;
37
41
  return { ...options, jsxImportSource: "react" };
38
42
  };
39
43
 
@@ -42,7 +46,11 @@ function withToolkitJsx(ts, host) {
42
46
  : defaultResolution(ts, host);
43
47
  host.resolveModuleNameLiterals = (literals, containing, redirected, options, sf, reused) => {
44
48
  const platform = PLATFORM_FILE.exec(containing);
45
- const toolkit = platform && TOOLKIT_JSX[platform[1]];
49
+ const toolkit = platform
50
+ ? TOOLKIT_JSX[platform[1]]
51
+ : LUCENT_JSX_FILE.test(containing)
52
+ ? SHARED_JSX
53
+ : undefined;
46
54
  // The implicit import is synthesized: it has no place in the file's text.
47
55
  const runtime = (l) => toolkit && l.pos < 0 && JSX_RUNTIME.test(l.text);
48
56
  const own = literals.map((l) =>