@bake-native/core 0.0.0 → 0.1.0-rc.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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/THIRD_PARTY_NOTICES.txt +548 -0
  3. package/bake-prelude.js +189 -0
  4. package/batch-contract.json +21 -0
  5. package/batch-wire.js +674 -0
  6. package/compat.json +64 -0
  7. package/controls.css +108 -0
  8. package/determinism.js +175 -0
  9. package/devtools.d.ts +13 -0
  10. package/devtools.js +73 -0
  11. package/dialogs.js +59 -0
  12. package/direct-style.js +105 -0
  13. package/direct-table.js +261 -0
  14. package/dist/bake.mjs +2211 -0
  15. package/dist/build-CMsvCcZ0.mjs +1 -0
  16. package/dist/build-CkLSZw06.mjs +5514 -0
  17. package/dist/build-tools-Dxyl6XAf.mjs +80 -0
  18. package/dist/client-Cm7o6dQd.mjs +17544 -0
  19. package/dist/compiler.mjs +4 -0
  20. package/dist/config-B1W8gfZY.mjs +12 -0
  21. package/dist/dev-Cskd8Hl4.mjs +986 -0
  22. package/dist/direct-report-Bdda-k_Y.mjs +153 -0
  23. package/dist/direct-report-Du44nNWl.mjs +1 -0
  24. package/dist/index.d.mts +176 -0
  25. package/dist/index.mjs +1 -0
  26. package/dist/intl-ROnAp2qO.mjs +75 -0
  27. package/dist/jiti-stub-CKcaShwE.mjs +5 -0
  28. package/dist/native-views-BuzB9x5H.mjs +7849 -0
  29. package/dist/octane/package.json +5 -0
  30. package/dist/package-KkUSMoji.mjs +2784 -0
  31. package/dist/react/package.json +13 -0
  32. package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
  33. package/dist/run-D2aPm54a.mjs +6632 -0
  34. package/dist/scope-8W2aIuQ9.mjs +262 -0
  35. package/dist/screens/BakeNativeScreen.native.ts +9 -0
  36. package/dist/screens/package.json +5 -0
  37. package/dom-exception.js +31 -0
  38. package/element-api.js +158 -0
  39. package/first-screen.js +30 -0
  40. package/fonts/Geist-Italic-Variable.ttf +0 -0
  41. package/fonts/Geist-Variable.ttf +0 -0
  42. package/fonts/GeistMono-Italic-Variable.ttf +0 -0
  43. package/fonts/GeistMono-Variable.ttf +0 -0
  44. package/fonts/OFL.txt +93 -0
  45. package/fonts/README.md +27 -0
  46. package/fonts/geist-italic.css +8 -0
  47. package/fonts/geist-mono-italic.css +8 -0
  48. package/fonts/geist-mono.css +8 -0
  49. package/fonts/geist.css +8 -0
  50. package/header-icons.json +53 -0
  51. package/host-runtime.js +508 -0
  52. package/image-props.js +17 -0
  53. package/index.d.ts +8 -0
  54. package/index.js +7 -0
  55. package/licenses/Apache-2.0.txt +73 -0
  56. package/locale-entry.d.ts +1 -0
  57. package/locale-entry.js +1 -0
  58. package/locale.d.ts +28 -0
  59. package/locale.js +124 -0
  60. package/markup-support.js +87 -0
  61. package/media-element.js +115 -0
  62. package/native-args-entry.js +2 -0
  63. package/native-args.d.ts +7 -0
  64. package/native-args.js +155 -0
  65. package/native-entry.js +1 -0
  66. package/native-globals.d.ts +156 -0
  67. package/native-scenarios.d.ts +17 -0
  68. package/native-scenarios.js +46 -0
  69. package/native-support.json +349 -0
  70. package/native.d.ts +52 -0
  71. package/native.js +237 -0
  72. package/package.json +142 -4
  73. package/page-elements.js +123 -0
  74. package/runtime-provides.json +412 -0
  75. package/safe-area.d.ts +1 -0
  76. package/safe-area.js +44 -0
  77. package/swift-ui/modifiers.js +164 -0
  78. package/tab-icons.js +62 -0
  79. package/templates/create/tabs/AGENTS.md +22 -0
  80. package/templates/create/tabs/README.md +43 -0
  81. package/templates/create/tabs/_gitignore +13 -0
  82. package/templates/create/tabs/android/app/build.gradle.kts +79 -0
  83. package/templates/create/tabs/android/app/src/main/AndroidManifest.xml +39 -0
  84. package/templates/create/tabs/android/app/src/main/kotlin/MainActivity.kt +35 -0
  85. package/templates/create/tabs/android/app/src/main/res/values/themes.xml +8 -0
  86. package/templates/create/tabs/android/build.gradle.kts +5 -0
  87. package/templates/create/tabs/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  88. package/templates/create/tabs/android/gradle/wrapper/gradle-wrapper.properties +9 -0
  89. package/templates/create/tabs/android/gradle.properties +3 -0
  90. package/templates/create/tabs/android/gradlew +248 -0
  91. package/templates/create/tabs/android/settings.gradle.kts +47 -0
  92. package/templates/create/tabs/bake.config.ts +10 -0
  93. package/templates/create/tabs/ios/App/App.swift +30 -0
  94. package/templates/create/tabs/ios/build.sh +23 -0
  95. package/templates/create/tabs/ios/project.yml +57 -0
  96. package/templates/create/tabs/macos/Package.swift +24 -0
  97. package/templates/create/tabs/macos/Sources/__SWIFT_NAME__/App.swift +146 -0
  98. package/templates/create/tabs/macos/build.sh +4 -0
  99. package/templates/create/tabs/package.json +23 -0
  100. package/templates/create/tabs/pnpm-workspace.yaml +6 -0
  101. package/templates/create/tabs/src/App.tsrx +92 -0
  102. package/templates/create/tabs/src/App.tsx +67 -0
  103. package/templates/create/tabs/src/styles.css +32 -0
  104. package/templates/create/tabs/tsconfig.json +5 -0
  105. package/templates/create/tabs/windows/Cargo.toml +29 -0
  106. package/templates/create/tabs/windows/build.rs +9 -0
  107. package/templates/create/tabs/windows/src/main.rs +52 -0
  108. package/templates/create/tabs/windows/src/shell.rs +316 -0
  109. package/templates/module/__NAME__.kt +20 -0
  110. package/templates/module/__NAME__.native.ts +24 -0
  111. package/templates/module/__NAME__.swift +25 -0
  112. package/templates/module/__NAME__.web.ts +13 -0
  113. package/templates/module/__NAME__Test.kt +26 -0
  114. package/templates/module/__NAME__Tests.swift +25 -0
  115. package/templates/module/__SNAKE__.rs +43 -0
  116. package/text.d.ts +20 -0
  117. package/text.js +100 -0
  118. package/transform-entry.js +1 -0
  119. package/transform.d.ts +15 -0
  120. package/transform.js +98 -0
  121. package/tsconfig.native.json +16 -0
  122. package/ui/scope.js +103 -0
  123. package/ui/swift.js +106 -0
  124. package/ui/ui.css +272 -0
  125. package/view-ref-writer.js +268 -0
  126. package/view-ref.d.ts +26 -0
  127. package/view-ref.js +85 -0
  128. package/views/Video.native.ts +68 -0
  129. package/views/generated/VideoViewAndroid.h +68 -0
  130. package/views/generated/VideoViewJSI.h +94 -0
  131. package/views/generated/VideoViewSpec.kt +113 -0
  132. package/views/generated/apple/VideoViewJSI/VideoViewJSIApple.cpp +40 -0
  133. package/views/generated/apple/VideoViewJSI/include/VideoViewJSIApple.h +28 -0
  134. package/views/generated/apple/VideoViewSpec/VideoViewInterop.swift +39 -0
  135. package/views/generated/apple/VideoViewSpec/VideoViewSpec.swift +186 -0
  136. package/views/generated/video_view_spec.rs +189 -0
  137. package/views.d.ts +24 -0
  138. package/views.js +45 -0
  139. package/virtual-window.js +35 -0
  140. package/visibility.js +75 -0
  141. package/web-crypto.js +84 -0
  142. package/web-fetch.js +1071 -0
  143. package/README.md +0 -3
@@ -0,0 +1,153 @@
1
+ import { readFileSync, readdirSync } from "node:fs";
2
+ import { join, relative, sep } from "node:path";
3
+ import { parseSync } from "@tsrx/oxc/parser";
4
+ // direct-report.mjs
5
+ const PROPS = /* @__PURE__ */ new Set(["transform", "opacity"]);
6
+ function unwrap(n) {
7
+ while (n && (n.type === "ParenthesizedExpression" || n.type === "TSAsExpression" || n.type === "TSNonNullExpression" || n.type === "TSSatisfiesExpression")) n = n.expression;
8
+ return n;
9
+ }
10
+ /** The handle naming convention (`count$`, `row.t$`): the last identifier of the path ends in `$`. */
11
+ function isHandle(n) {
12
+ n = unwrap(n);
13
+ if (n?.type === "Identifier") return n.name.endsWith("$");
14
+ if (n?.type === "MemberExpression" && !n.computed) return n.property?.name?.endsWith("$") === true;
15
+ return false;
16
+ }
17
+ function isLiteral(n) {
18
+ n = unwrap(n);
19
+ if (!n) return false;
20
+ if (n.type === "Literal") return true;
21
+ if (n.type === "TemplateLiteral") return n.expressions.length === 0;
22
+ if (n.type === "UnaryExpression") return isLiteral(n.argument);
23
+ return false;
24
+ }
25
+ function keyName(p) {
26
+ if (p.type !== "Property" || p.computed) return null;
27
+ const k = unwrap(p.key);
28
+ return k?.type === "Identifier" ? k.name : k?.type === "Literal" ? String(k.value) : null;
29
+ }
30
+ const BUILT_IN_VIEWS = /* @__PURE__ */ new Set([
31
+ "View",
32
+ "Text",
33
+ "Image"
34
+ ]);
35
+ /** Whether a JSX opening element of `program` renders a host element: an intrinsic element or a
36
+ * built-in view imported from @bake-native/octane. */
37
+ function hostElementTest(program) {
38
+ const named = /* @__PURE__ */ new Set();
39
+ const namespaces = /* @__PURE__ */ new Set();
40
+ for (const s of program.body) {
41
+ if (s.type !== "ImportDeclaration" || s.source.value !== "@bake-native/octane" || s.importKind === "type") continue;
42
+ for (const sp of s.specifiers) if (sp.type === "ImportNamespaceSpecifier") namespaces.add(sp.local.name);
43
+ else if (sp.type === "ImportSpecifier" && sp.importKind !== "type" && BUILT_IN_VIEWS.has(sp.imported.name)) named.add(sp.local.name);
44
+ }
45
+ return (opening) => {
46
+ const n = opening?.name;
47
+ if (n?.type === "JSXIdentifier") return /^[a-z]/.test(n.name) || named.has(n.name);
48
+ return n?.type === "JSXMemberExpression" && n.object?.type === "JSXIdentifier" && namespaces.has(n.object.name) && BUILT_IN_VIEWS.has(n.property?.name);
49
+ };
50
+ }
51
+ function tagName(el) {
52
+ const n = el.openingElement?.name;
53
+ if (n?.type === "JSXIdentifier") return n.name;
54
+ return n?.type === "JSXMemberExpression" ? n.object.name + "." + n.property.name : "?";
55
+ }
56
+ /**
57
+ * The `transform` / `opacity` style values of one .tsrx source:
58
+ * `{ file, line, column, element, prop, value, kind: 'bound' | 'dynamic' }`.
59
+ */
60
+ function directSites(code, file = "App.tsrx") {
61
+ const parsed = parseSync(file, code, { lang: "tsrx" });
62
+ if (parsed.errors?.length) return [];
63
+ const lineStarts = [0];
64
+ for (let i = 0; i < code.length; i++) if (code.charCodeAt(i) === 10) lineStarts.push(i + 1);
65
+ const pos = (offset) => {
66
+ let lo = 0, hi = lineStarts.length - 1;
67
+ while (lo < hi) {
68
+ const mid = lo + hi + 1 >> 1;
69
+ if (lineStarts[mid] <= offset) lo = mid;
70
+ else hi = mid - 1;
71
+ }
72
+ return {
73
+ line: lo + 1,
74
+ column: offset - lineStarts[lo] + 1
75
+ };
76
+ };
77
+ const text = (n) => code.slice(n.start, n.end).replace(/\s+/g, " ");
78
+ const out = [];
79
+ const isHost = hostElementTest(parsed.program);
80
+ const visit = (n) => {
81
+ if (!n || typeof n !== "object") return;
82
+ if (Array.isArray(n)) {
83
+ for (const c of n) visit(c);
84
+ return;
85
+ }
86
+ if (n.type === "JSXElement" && isHost(n.openingElement)) for (const a of n.openingElement?.attributes ?? []) {
87
+ if (a.type !== "JSXAttribute" || a.name?.name !== "style" || a.value?.type !== "JSXExpressionContainer") continue;
88
+ const v = unwrap(a.value.expression);
89
+ if (v?.type !== "ObjectExpression") continue;
90
+ for (const p of v.properties) {
91
+ const k = keyName(p);
92
+ if (!k || !PROPS.has(k) || isLiteral(p.value)) continue;
93
+ const at = pos(p.start);
94
+ const value = text(p.value);
95
+ out.push({
96
+ file,
97
+ line: at.line,
98
+ column: at.column,
99
+ element: tagName(n),
100
+ prop: k,
101
+ value: value.length > 60 ? value.slice(0, 59) + "…" : value,
102
+ kind: isHandle(p.value) ? "bound" : "dynamic"
103
+ });
104
+ }
105
+ }
106
+ for (const key in n) {
107
+ if (key === "parent" || key === "start" || key === "end" || key === "loc" || key === "range") continue;
108
+ const c = n[key];
109
+ if (c && typeof c === "object") visit(c);
110
+ }
111
+ };
112
+ visit(parsed.program);
113
+ return out;
114
+ }
115
+ function tsrxFiles(dir, out = []) {
116
+ let entries = [];
117
+ try {
118
+ entries = readdirSync(dir, { withFileTypes: true });
119
+ } catch {
120
+ return out;
121
+ }
122
+ for (const e of entries) {
123
+ if (e.name.startsWith(".") || e.name === "node_modules") continue;
124
+ const p = join(dir, e.name);
125
+ if (e.isDirectory()) tsrxFiles(p, out);
126
+ else if (e.name.endsWith(".tsrx")) out.push(p);
127
+ }
128
+ return out;
129
+ }
130
+ /** Every site under `root/src`. */
131
+ function directReport(root, { dirs = ["src"] } = {}) {
132
+ const files = dirs.flatMap((d) => tsrxFiles(join(root, d)));
133
+ const sites = [];
134
+ for (const f of files) sites.push(...directSites(readFileSync(f, "utf8"), relative(root, f).split(sep).join("/")));
135
+ return {
136
+ files: files.length,
137
+ sites
138
+ };
139
+ }
140
+ /** Human-readable form. */
141
+ function formatDirectReport(result) {
142
+ const out = [];
143
+ const bound = result.sites.filter((s) => s.kind === "bound");
144
+ const dynamic = result.sites.filter((s) => s.kind === "dynamic");
145
+ for (const s of bound) out.push(`direct ${s.file}:${s.line}:${s.column} <${s.element}> ${s.prop}: ${s.value} (a signal binding: its changes can take the direct path)`);
146
+ for (const s of dynamic) {
147
+ out.push(`batch ${s.file}:${s.line}:${s.column} <${s.element}> ${s.prop}: ${s.value}`);
148
+ out.push(s.prop === "transform" ? " each change re-renders and goes through the batch; bind a signal holding a numeric transform instead (`transform: t$`, `t$.set(transform().translate(x, y))` from @bake-native/octane, where the value changes) and the change can take the direct path" : " each change re-renders and goes through the batch; bind a signal holding the number instead (`opacity: o$`, `o$.set(v)` where the value changes) and the change can take the direct path");
149
+ }
150
+ out.push(`${bound.length} direct, ${dynamic.length} through the batch, in ${result.files} .tsrx ${result.files === 1 ? "file" : "files"}`);
151
+ return out.join("\n");
152
+ }
153
+ export { hostElementTest as i, directSites as n, formatDirectReport as r, directReport as t };
@@ -0,0 +1 @@
1
+ export { t as directReport, r as formatDirectReport } from "./direct-report-Bdda-k_Y.mjs";
@@ -0,0 +1,176 @@
1
+ /** A platform a BakeNative app builds for. */
2
+ type BakeTarget = 'web' | 'ios' | 'android' | 'mac' | 'windows';
3
+ declare const bundledFonts: readonly ["geist", "geist-italic", "geist-mono", "geist-mono-italic"];
4
+ /**
5
+ * The app's `bake.config.ts` (also .mts, .cts, .js, .mjs), at the app root:
6
+ *
7
+ * import { defineConfig } from '@bake-native/core';
8
+ * export default defineConfig({ targets: ['web', 'ios', 'android'] });
9
+ *
10
+ * The bake CLI reads it (docs: reference/config). Unknown keys are errors.
11
+ */
12
+ interface BakeConfig {
13
+ /** Select the app entry when both src/App.tsx and src/App.tsrx exist. */
14
+ renderer?: 'react' | 'octane';
15
+ /** Octane compiler options for .tsrx components. */
16
+ compiler?: {
17
+ strong?: boolean;
18
+ strongDependencies?: {
19
+ require?: boolean;
20
+ allow?: readonly string[];
21
+ };
22
+ };
23
+ /**
24
+ * The platforms the app ships on. `bake build`, `bake dev`, `bake package` and `bake check` use
25
+ * them when `--target` is not given, and refuse a `--target` outside them. Default: `['web']`.
26
+ */
27
+ targets?: BakeTarget[];
28
+ /** Fonts registered before the first frame. Local files are relative to the app root. */
29
+ fonts?: readonly ((typeof bundledFonts)[number] | {
30
+ family: string;
31
+ src: string;
32
+ weight?: number | readonly [number, number];
33
+ style?: 'normal' | 'italic';
34
+ })[];
35
+ /**
36
+ * Settings for a standalone native host generated by bake create.
37
+ * Embedded bundles omit app and inherit their native host's shell.
38
+ */
39
+ app?: BakeAppConfig;
40
+ /** The Android target's settings. */
41
+ android?: BakeAndroidConfig;
42
+ /**
43
+ * The languages the app ships, as BCP 47 tags (`['en', 'ko']`); the first is the default.
44
+ * `bake build --bake` bakes a first screen per locale (`app.<tag>.baked`), each host opens the
45
+ * one matching the user's preferred languages, and the bundle reads it with `locale()` from
46
+ * `@bake-native/core`. Without it the app has one locale, `en`. Right-to-left locales are
47
+ * refused until the layout supports them.
48
+ */
49
+ locales?: string[];
50
+ /**
51
+ * Whether `bake build --bake` bakes this app's first screen (default true). The first screen is
52
+ * the root's first render, so the switch is the whole bundle: `false` for an app whose first
53
+ * render must read runtime values (the host's props, the clock, native state). Such an app has
54
+ * no baked first screen, and its first render gets the host's props. App-wide Strong mode
55
+ * always requires a verified first screen for native builds and conflicts with false.
56
+ */
57
+ bake?: boolean;
58
+ /**
59
+ * Native module registries besides the official one, by alias: `bake add <alias>/<name>` copies
60
+ * from them. A value is an https URL or a directory holding the registry's index.json
61
+ * (docs: guides/bake-add). Setting `bakenative` replaces the official registry. A private registry
62
+ * takes `{ url, headers }`; `${NAME}` in a header is read from the environment when bake sends
63
+ * the request, so tokens stay out of the config and the lock:
64
+ * `acme: { url: 'https://acme.dev/r', headers: { Authorization: 'Bearer ${ACME_TOKEN}' } }`.
65
+ */
66
+ registries?: Record<string, string | BakeRegistry>;
67
+ /**
68
+ * Direct updates: a signal bound to an element's inline `transform` or `opacity` moves the native
69
+ * view without a batch or a commit wherever nothing else owns that property (docs: guides/direct
70
+ * updates). On by default. `false` turns it off for the app; `{ exclude: ['src/legacy/**'] }`
71
+ * for the files matching those globs (relative to the app root).
72
+ */
73
+ direct?: boolean | {
74
+ exclude?: string[];
75
+ };
76
+ /**
77
+ * CSS a build step generates (Tailwind's utilities, a component library's classes) that the app
78
+ * keeps web-only where a native target cannot draw it. A native build fails on such CSS; each
79
+ * entry here leaves that CSS out on the targets that reject it, and the build lists what it
80
+ * left out. An entry is a property (`'background-clip'`), a declaration (`'appearance: button'`),
81
+ * a pseudo-class or pseudo-element (`':has()'`, `'::placeholder'`, `'::-webkit-*'`) or an
82
+ * at-rule (`'@container'`). For CSS you write, use `@supports not (-bake-native: true)`.
83
+ */
84
+ css?: {
85
+ webOnly?: readonly string[];
86
+ };
87
+ /**
88
+ * Third-party code the app adds itself (a library vendored into its native host, an icon set,
89
+ * a font it ships outside `fonts`): `bake build` lists each entry in the THIRD_PARTY_NOTICES.txt
90
+ * / .json it writes into the app's outputs, with the license text in `file` (relative to
91
+ * bake.config.ts). Packages the bundle contains and the BakeNative runtime are listed without
92
+ * an entry (docs: guides/packaging#third-party-notices).
93
+ */
94
+ notices?: readonly BakeNoticeEntry[];
95
+ }
96
+ /** One `notices` entry of bake.config.ts. */
97
+ interface BakeNoticeEntry {
98
+ name: string;
99
+ version?: string;
100
+ /** An SPDX expression, such as `MIT` or `Apache-2.0`. */
101
+ license: string;
102
+ url?: string;
103
+ /** The license text, relative to bake.config.ts. */
104
+ file: string;
105
+ }
106
+ /** A registry in bake.config.ts `registries` that needs request headers. */
107
+ interface BakeRegistry {
108
+ url: string;
109
+ headers?: Record<string, string>;
110
+ }
111
+ interface BakeMobileBranding {
112
+ /** Native application identifier. Use a platform override to preserve an existing store listing. */
113
+ appId?: string;
114
+ /** PNG relative to the app root. iOS requires 1024 × 1024. */
115
+ icon?: string;
116
+ splash?: {
117
+ /** Centered PNG relative to the app root. */
118
+ image?: string;
119
+ /** Opaque #RRGGBB. */
120
+ backgroundColor?: string;
121
+ };
122
+ }
123
+ interface BakeAppConfig extends BakeMobileBranding {
124
+ mac?: {
125
+ appId?: string;
126
+ icon?: string;
127
+ };
128
+ windows?: {
129
+ appId?: string;
130
+ icon?: string;
131
+ };
132
+ desktop?: BakeDesktopShell;
133
+ name?: string;
134
+ ios?: BakeMobileBranding;
135
+ android?: BakeMobileBranding & {
136
+ /** Foreground PNG and opaque #RRGGBB background for Android's masked launcher icon. */
137
+ adaptiveIcon?: {
138
+ foregroundImage: string;
139
+ backgroundColor: string;
140
+ };
141
+ };
142
+ }
143
+ /** Window and tray settings shared by the standalone macOS and Windows hosts. */
144
+ interface BakeDesktopShell {
145
+ window?: {
146
+ startVisible?: boolean;
147
+ titleBar?: 'system' | 'hidden';
148
+ showInTaskbar?: boolean;
149
+ alwaysOnTop?: boolean;
150
+ };
151
+ tray?: {
152
+ click?: 'menu' | 'toggle';
153
+ menu?: ({
154
+ label: string;
155
+ action: 'show' | 'hide' | 'toggle' | 'quit';
156
+ } | {
157
+ label: string;
158
+ action: 'app';
159
+ id: string;
160
+ })[];
161
+ };
162
+ }
163
+ /** `android` in bake.config.ts. */
164
+ interface BakeAndroidConfig {
165
+ /**
166
+ * The lowest Android API level the app runs on: 29 (the BakeNative host's own minimum) through 37.
167
+ * `bake build --target android` writes it into the generated `.bake/native/android` module, whose
168
+ * `min-sdk` file the app's Gradle build reads for `minSdk`, and the CSS check follows it:
169
+ * `filter: blur()` / `drop-shadow()` (RenderEffect, API 31) are a build error below 31.
170
+ * Default: 29.
171
+ */
172
+ minSdk?: number;
173
+ }
174
+ /** Types the config; returns it unchanged. */
175
+ export declare function defineConfig(config: BakeConfig): BakeConfig;
176
+ export type { BakeAndroidConfig, BakeConfig, BakeTarget };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { n as defineConfig } from "./config-B1W8gfZY.mjs";
@@ -0,0 +1,75 @@
1
+ // src/intl.mjs
2
+ const HERMES_TARGETS = /* @__PURE__ */ new Set([
3
+ "ios",
4
+ "mac",
5
+ "android",
6
+ "windows"
7
+ ]);
8
+ const HERMES_INTL = /* @__PURE__ */ new Set([
9
+ "Collator",
10
+ "DateTimeFormat",
11
+ "NumberFormat",
12
+ "getCanonicalLocales"
13
+ ]);
14
+ /** What to write instead of an Intl member Hermes does not have. */
15
+ const INTL_INSTEAD = {
16
+ PluralRules: "choose the plural form in the app's translations (`n === 1 ? one : other`, or the translation library's plural rules)",
17
+ RelativeTimeFormat: "a number from `Intl.NumberFormat` and a translated unit (`${n} days ago`), or an absolute date from `Intl.DateTimeFormat`",
18
+ ListFormat: "join the items with the separators of the app's translations (`items.join(', ')`)",
19
+ DisplayNames: "a table of language, region or currency names in the app's translations",
20
+ Segmenter: "`Array.from(text)` for code points, or `String.prototype.split` for words",
21
+ Locale: "the tag string from `locale()` (or `Intl.getCanonicalLocales(tag)[0]`)",
22
+ supportedValuesOf: "a fixed list of the calendars, currencies or units the app uses",
23
+ DurationFormat: "format each part with `Intl.NumberFormat` and join them with translated units"
24
+ };
25
+ const INSTEAD_DEFAULT = "`Intl.DateTimeFormat`, `Intl.NumberFormat`, `Intl.Collator` or `Intl.getCanonicalLocales`";
26
+ /** The diagnostic text for `Intl.<name>` on `target`. */
27
+ function intlMessage(name, target) {
28
+ return `\`Intl.${name}\` is not supported on ${target}: Hermes has no Intl.${name} on any native target (only ${[...HERMES_INTL].map((m) => `Intl.${m}`).join(", ")}). Instead: ${INTL_INSTEAD[name] ?? INSTEAD_DEFAULT}, or guard with \`typeof Intl.${name} !== 'undefined'\` and keep that fallback (intl-unsupported).`;
29
+ }
30
+ const GLOBALS = /* @__PURE__ */ new Set([
31
+ "globalThis",
32
+ "global",
33
+ "self",
34
+ "window"
35
+ ]);
36
+ const literalKey = (node) => node?.type === "Literal" && typeof node.value === "string" ? node.value : null;
37
+ /**
38
+ * Finds the Intl members Hermes does not have in one module's (transformed) program:
39
+ * `Intl.PluralRules`, `Intl['Segmenter']` and `const { ListFormat } = Intl`. Feature detection
40
+ * (`typeof Intl.PluralRules`, `'Segmenter' in Intl`) is not a use. Returns { name, start } per
41
+ * finding, `name` being the member.
42
+ * @param {{ type: 'Program', body: readonly object[] }} program
43
+ * @returns {{ name: string, start: number }[]}
44
+ */
45
+ function intlUses(program) {
46
+ const found = [];
47
+ const isIntl = (node) => node?.type === "Identifier" && node.name === "Intl" || node?.type === "MemberExpression" && !node.computed && node.property?.name === "Intl" && node.object?.type === "Identifier" && GLOBALS.has(node.object.name);
48
+ const visit = (node, parent) => {
49
+ if (!node || typeof node.type !== "string") return;
50
+ if (node.type === "MemberExpression" && isIntl(node.object)) {
51
+ const name = node.computed ? literalKey(node.property) : node.property?.name;
52
+ const guarded = parent?.type === "UnaryExpression" && parent.operator === "typeof";
53
+ if (name && !HERMES_INTL.has(name) && !guarded) found.push({
54
+ name,
55
+ start: node.property.start
56
+ });
57
+ }
58
+ if (node.type === "VariableDeclarator" && isIntl(node.init) && node.id?.type === "ObjectPattern") for (const p of node.id.properties) {
59
+ const name = p.type === "Property" ? p.computed ? literalKey(p.key) : p.key?.name : null;
60
+ if (name && !HERMES_INTL.has(name)) found.push({
61
+ name,
62
+ start: p.key.start
63
+ });
64
+ }
65
+ for (const k in node) {
66
+ if (k === "type" || k === "start" || k === "end" || k === "loc") continue;
67
+ const v = node[k];
68
+ if (Array.isArray(v)) for (const c of v) visit(c, node);
69
+ else if (v && typeof v === "object" && typeof v.type === "string") visit(v, node);
70
+ }
71
+ };
72
+ visit(program, null);
73
+ return found;
74
+ }
75
+ export { intlUses as i, HERMES_TARGETS as n, intlMessage as r, HERMES_INTL as t };
@@ -0,0 +1,5 @@
1
+ // cli/jiti-stub.ts
2
+ function createJiti() {
3
+ throw new Error("bake loads bake.config.ts with Node, not jiti");
4
+ }
5
+ export { createJiti };