@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.
- package/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.txt +548 -0
- package/bake-prelude.js +189 -0
- package/batch-contract.json +21 -0
- package/batch-wire.js +674 -0
- package/compat.json +64 -0
- package/controls.css +108 -0
- package/determinism.js +175 -0
- package/devtools.d.ts +13 -0
- package/devtools.js +73 -0
- package/dialogs.js +59 -0
- package/direct-style.js +105 -0
- package/direct-table.js +261 -0
- package/dist/bake.mjs +2211 -0
- package/dist/build-CMsvCcZ0.mjs +1 -0
- package/dist/build-CkLSZw06.mjs +5514 -0
- package/dist/build-tools-Dxyl6XAf.mjs +80 -0
- package/dist/client-Cm7o6dQd.mjs +17544 -0
- package/dist/compiler.mjs +4 -0
- package/dist/config-B1W8gfZY.mjs +12 -0
- package/dist/dev-Cskd8Hl4.mjs +986 -0
- package/dist/direct-report-Bdda-k_Y.mjs +153 -0
- package/dist/direct-report-Du44nNWl.mjs +1 -0
- package/dist/index.d.mts +176 -0
- package/dist/index.mjs +1 -0
- package/dist/intl-ROnAp2qO.mjs +75 -0
- package/dist/jiti-stub-CKcaShwE.mjs +5 -0
- package/dist/native-views-BuzB9x5H.mjs +7849 -0
- package/dist/octane/package.json +5 -0
- package/dist/package-KkUSMoji.mjs +2784 -0
- package/dist/react/package.json +13 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/dist/run-D2aPm54a.mjs +6632 -0
- package/dist/scope-8W2aIuQ9.mjs +262 -0
- package/dist/screens/BakeNativeScreen.native.ts +9 -0
- package/dist/screens/package.json +5 -0
- package/dom-exception.js +31 -0
- package/element-api.js +158 -0
- package/first-screen.js +30 -0
- package/fonts/Geist-Italic-Variable.ttf +0 -0
- package/fonts/Geist-Variable.ttf +0 -0
- package/fonts/GeistMono-Italic-Variable.ttf +0 -0
- package/fonts/GeistMono-Variable.ttf +0 -0
- package/fonts/OFL.txt +93 -0
- package/fonts/README.md +27 -0
- package/fonts/geist-italic.css +8 -0
- package/fonts/geist-mono-italic.css +8 -0
- package/fonts/geist-mono.css +8 -0
- package/fonts/geist.css +8 -0
- package/header-icons.json +53 -0
- package/host-runtime.js +508 -0
- package/image-props.js +17 -0
- package/index.d.ts +8 -0
- package/index.js +7 -0
- package/licenses/Apache-2.0.txt +73 -0
- package/locale-entry.d.ts +1 -0
- package/locale-entry.js +1 -0
- package/locale.d.ts +28 -0
- package/locale.js +124 -0
- package/markup-support.js +87 -0
- package/media-element.js +115 -0
- package/native-args-entry.js +2 -0
- package/native-args.d.ts +7 -0
- package/native-args.js +155 -0
- package/native-entry.js +1 -0
- package/native-globals.d.ts +156 -0
- package/native-scenarios.d.ts +17 -0
- package/native-scenarios.js +46 -0
- package/native-support.json +349 -0
- package/native.d.ts +52 -0
- package/native.js +237 -0
- package/package.json +142 -4
- package/page-elements.js +123 -0
- package/runtime-provides.json +412 -0
- package/safe-area.d.ts +1 -0
- package/safe-area.js +44 -0
- package/swift-ui/modifiers.js +164 -0
- package/tab-icons.js +62 -0
- package/templates/create/tabs/AGENTS.md +22 -0
- package/templates/create/tabs/README.md +43 -0
- package/templates/create/tabs/_gitignore +13 -0
- package/templates/create/tabs/android/app/build.gradle.kts +79 -0
- package/templates/create/tabs/android/app/src/main/AndroidManifest.xml +39 -0
- package/templates/create/tabs/android/app/src/main/kotlin/MainActivity.kt +35 -0
- package/templates/create/tabs/android/app/src/main/res/values/themes.xml +8 -0
- package/templates/create/tabs/android/build.gradle.kts +5 -0
- package/templates/create/tabs/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/create/tabs/android/gradle/wrapper/gradle-wrapper.properties +9 -0
- package/templates/create/tabs/android/gradle.properties +3 -0
- package/templates/create/tabs/android/gradlew +248 -0
- package/templates/create/tabs/android/settings.gradle.kts +47 -0
- package/templates/create/tabs/bake.config.ts +10 -0
- package/templates/create/tabs/ios/App/App.swift +30 -0
- package/templates/create/tabs/ios/build.sh +23 -0
- package/templates/create/tabs/ios/project.yml +57 -0
- package/templates/create/tabs/macos/Package.swift +24 -0
- package/templates/create/tabs/macos/Sources/__SWIFT_NAME__/App.swift +146 -0
- package/templates/create/tabs/macos/build.sh +4 -0
- package/templates/create/tabs/package.json +23 -0
- package/templates/create/tabs/pnpm-workspace.yaml +6 -0
- package/templates/create/tabs/src/App.tsrx +92 -0
- package/templates/create/tabs/src/App.tsx +67 -0
- package/templates/create/tabs/src/styles.css +32 -0
- package/templates/create/tabs/tsconfig.json +5 -0
- package/templates/create/tabs/windows/Cargo.toml +29 -0
- package/templates/create/tabs/windows/build.rs +9 -0
- package/templates/create/tabs/windows/src/main.rs +52 -0
- package/templates/create/tabs/windows/src/shell.rs +316 -0
- package/templates/module/__NAME__.kt +20 -0
- package/templates/module/__NAME__.native.ts +24 -0
- package/templates/module/__NAME__.swift +25 -0
- package/templates/module/__NAME__.web.ts +13 -0
- package/templates/module/__NAME__Test.kt +26 -0
- package/templates/module/__NAME__Tests.swift +25 -0
- package/templates/module/__SNAKE__.rs +43 -0
- package/text.d.ts +20 -0
- package/text.js +100 -0
- package/transform-entry.js +1 -0
- package/transform.d.ts +15 -0
- package/transform.js +98 -0
- package/tsconfig.native.json +16 -0
- package/ui/scope.js +103 -0
- package/ui/swift.js +106 -0
- package/ui/ui.css +272 -0
- package/view-ref-writer.js +268 -0
- package/view-ref.d.ts +26 -0
- package/view-ref.js +85 -0
- package/views/Video.native.ts +68 -0
- package/views/generated/VideoViewAndroid.h +68 -0
- package/views/generated/VideoViewJSI.h +94 -0
- package/views/generated/VideoViewSpec.kt +113 -0
- package/views/generated/apple/VideoViewJSI/VideoViewJSIApple.cpp +40 -0
- package/views/generated/apple/VideoViewJSI/include/VideoViewJSIApple.h +28 -0
- package/views/generated/apple/VideoViewSpec/VideoViewInterop.swift +39 -0
- package/views/generated/apple/VideoViewSpec/VideoViewSpec.swift +186 -0
- package/views/generated/video_view_spec.rs +189 -0
- package/views.d.ts +24 -0
- package/views.js +45 -0
- package/virtual-window.js +35 -0
- package/visibility.js +75 -0
- package/web-crypto.js +84 -0
- package/web-fetch.js +1071 -0
- package/README.md +0 -3
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
// ui/scope.js
|
|
3
|
+
var scope_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
SWIFT_UI_INSTEAD: () => SWIFT_UI_INSTEAD,
|
|
5
|
+
SWIFT_UI_MODULES: () => SWIFT_UI_MODULES,
|
|
6
|
+
SWIFT_UI_PROPS_LATER: () => SWIFT_UI_PROPS_LATER,
|
|
7
|
+
SWIFT_UI_TARGETS: () => SWIFT_UI_TARGETS,
|
|
8
|
+
UI_COMPONENTS: () => UI_COMPONENTS,
|
|
9
|
+
UI_EXPORTS: () => UI_EXPORTS,
|
|
10
|
+
UI_LATER: () => UI_LATER,
|
|
11
|
+
UI_PROPS_LATER: () => UI_PROPS_LATER,
|
|
12
|
+
UI_SWIFT_STYLE_KEYS: () => UI_SWIFT_STYLE_KEYS
|
|
13
|
+
});
|
|
14
|
+
const COMMON = [
|
|
15
|
+
"testID",
|
|
16
|
+
"style",
|
|
17
|
+
"hidden"
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* component -> { props: [names], values?: { prop: [allowed string literals] }, expo?: note }.
|
|
21
|
+
* `children` is listed where the component takes children.
|
|
22
|
+
*/
|
|
23
|
+
const UI_COMPONENTS = {
|
|
24
|
+
Host: {
|
|
25
|
+
props: [
|
|
26
|
+
"children",
|
|
27
|
+
"matchContents",
|
|
28
|
+
"colorScheme",
|
|
29
|
+
...COMMON
|
|
30
|
+
],
|
|
31
|
+
values: { colorScheme: ["light", "dark"] }
|
|
32
|
+
},
|
|
33
|
+
Column: {
|
|
34
|
+
props: [
|
|
35
|
+
"children",
|
|
36
|
+
"spacing",
|
|
37
|
+
"alignment",
|
|
38
|
+
...COMMON
|
|
39
|
+
],
|
|
40
|
+
values: { alignment: [
|
|
41
|
+
"start",
|
|
42
|
+
"center",
|
|
43
|
+
"end"
|
|
44
|
+
] }
|
|
45
|
+
},
|
|
46
|
+
Row: {
|
|
47
|
+
props: [
|
|
48
|
+
"children",
|
|
49
|
+
"spacing",
|
|
50
|
+
"alignment",
|
|
51
|
+
...COMMON
|
|
52
|
+
],
|
|
53
|
+
values: { alignment: [
|
|
54
|
+
"start",
|
|
55
|
+
"center",
|
|
56
|
+
"end"
|
|
57
|
+
] }
|
|
58
|
+
},
|
|
59
|
+
Spacer: { props: [
|
|
60
|
+
"size",
|
|
61
|
+
"flexible",
|
|
62
|
+
"testID"
|
|
63
|
+
] },
|
|
64
|
+
Text: { props: [
|
|
65
|
+
"children",
|
|
66
|
+
"textStyle",
|
|
67
|
+
"numberOfLines",
|
|
68
|
+
...COMMON
|
|
69
|
+
] },
|
|
70
|
+
Button: {
|
|
71
|
+
props: [
|
|
72
|
+
"children",
|
|
73
|
+
"label",
|
|
74
|
+
"onPress",
|
|
75
|
+
"variant",
|
|
76
|
+
"disabled",
|
|
77
|
+
...COMMON
|
|
78
|
+
],
|
|
79
|
+
values: { variant: [
|
|
80
|
+
"filled",
|
|
81
|
+
"outlined",
|
|
82
|
+
"text"
|
|
83
|
+
] }
|
|
84
|
+
},
|
|
85
|
+
Switch: { props: [
|
|
86
|
+
"value",
|
|
87
|
+
"onValueChange",
|
|
88
|
+
"label",
|
|
89
|
+
"disabled",
|
|
90
|
+
"testID"
|
|
91
|
+
] },
|
|
92
|
+
Checkbox: { props: [
|
|
93
|
+
"value",
|
|
94
|
+
"onValueChange",
|
|
95
|
+
"label",
|
|
96
|
+
"disabled",
|
|
97
|
+
"testID"
|
|
98
|
+
] },
|
|
99
|
+
Slider: { props: [
|
|
100
|
+
"value",
|
|
101
|
+
"onValueChange",
|
|
102
|
+
"min",
|
|
103
|
+
"max",
|
|
104
|
+
"step",
|
|
105
|
+
"disabled",
|
|
106
|
+
"testID"
|
|
107
|
+
] },
|
|
108
|
+
Picker: {
|
|
109
|
+
props: [
|
|
110
|
+
"children",
|
|
111
|
+
"selectedValue",
|
|
112
|
+
"onValueChange",
|
|
113
|
+
"appearance",
|
|
114
|
+
"enabled",
|
|
115
|
+
"accessibilityLabel",
|
|
116
|
+
"testID"
|
|
117
|
+
],
|
|
118
|
+
values: { appearance: ["menu", "wheel"] }
|
|
119
|
+
},
|
|
120
|
+
"Picker.Item": { props: ["label", "value"] },
|
|
121
|
+
TextInput: {
|
|
122
|
+
props: [
|
|
123
|
+
"value",
|
|
124
|
+
"defaultValue",
|
|
125
|
+
"onChangeText",
|
|
126
|
+
"placeholder",
|
|
127
|
+
"secureTextEntry",
|
|
128
|
+
"multiline",
|
|
129
|
+
"rows",
|
|
130
|
+
"maxLength",
|
|
131
|
+
"autoCapitalize",
|
|
132
|
+
"autoCorrect",
|
|
133
|
+
"inputMode",
|
|
134
|
+
"enterKeyHint",
|
|
135
|
+
"autoComplete",
|
|
136
|
+
"onSubmitEditing",
|
|
137
|
+
"onFocus",
|
|
138
|
+
"onBlur",
|
|
139
|
+
"accessibilityLabel",
|
|
140
|
+
...COMMON
|
|
141
|
+
],
|
|
142
|
+
values: {
|
|
143
|
+
autoCapitalize: [
|
|
144
|
+
"none",
|
|
145
|
+
"characters",
|
|
146
|
+
"words",
|
|
147
|
+
"sentences"
|
|
148
|
+
],
|
|
149
|
+
inputMode: [
|
|
150
|
+
"none",
|
|
151
|
+
"text",
|
|
152
|
+
"decimal",
|
|
153
|
+
"numeric",
|
|
154
|
+
"tel",
|
|
155
|
+
"search",
|
|
156
|
+
"email",
|
|
157
|
+
"url"
|
|
158
|
+
],
|
|
159
|
+
enterKeyHint: [
|
|
160
|
+
"enter",
|
|
161
|
+
"done",
|
|
162
|
+
"go",
|
|
163
|
+
"next",
|
|
164
|
+
"previous",
|
|
165
|
+
"search",
|
|
166
|
+
"send"
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
Header: { props: [
|
|
171
|
+
"title",
|
|
172
|
+
"subtitle",
|
|
173
|
+
"largeTitle",
|
|
174
|
+
"transparent",
|
|
175
|
+
"blurEffect",
|
|
176
|
+
"backgroundColor",
|
|
177
|
+
"tintColor",
|
|
178
|
+
"titleColor",
|
|
179
|
+
"shadowVisible",
|
|
180
|
+
"backTitle",
|
|
181
|
+
"hidden",
|
|
182
|
+
"leftItems",
|
|
183
|
+
"rightItems",
|
|
184
|
+
"onItemPress"
|
|
185
|
+
] },
|
|
186
|
+
TabBar: {
|
|
187
|
+
props: [
|
|
188
|
+
"tabs",
|
|
189
|
+
"selected",
|
|
190
|
+
"onSelect",
|
|
191
|
+
"tintColor",
|
|
192
|
+
"inactiveTintColor",
|
|
193
|
+
"backgroundColor",
|
|
194
|
+
"labeled",
|
|
195
|
+
"hidden",
|
|
196
|
+
"minimizeBehavior"
|
|
197
|
+
],
|
|
198
|
+
values: { minimizeBehavior: [
|
|
199
|
+
"automatic",
|
|
200
|
+
"never",
|
|
201
|
+
"onScrollDown",
|
|
202
|
+
"onScrollUp"
|
|
203
|
+
] }
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
/** `style` keys a component inside a Host takes on iOS and macOS, where SwiftUI draws the Host's
|
|
207
|
+
* tree (ui/swift.js maps them to modifiers): padding, size, opacity, background and corner
|
|
208
|
+
* radius, lengths in px. Another key, or a style that is not an object literal, is a build error
|
|
209
|
+
* on ios / mac (ui-style). The Host's own `style` is CSS (it places the Host). */
|
|
210
|
+
const UI_SWIFT_STYLE_KEYS = [
|
|
211
|
+
"padding",
|
|
212
|
+
"paddingTop",
|
|
213
|
+
"paddingRight",
|
|
214
|
+
"paddingBottom",
|
|
215
|
+
"paddingLeft",
|
|
216
|
+
"width",
|
|
217
|
+
"height",
|
|
218
|
+
"minWidth",
|
|
219
|
+
"maxWidth",
|
|
220
|
+
"minHeight",
|
|
221
|
+
"maxHeight",
|
|
222
|
+
"opacity",
|
|
223
|
+
"backgroundColor",
|
|
224
|
+
"borderRadius"
|
|
225
|
+
];
|
|
226
|
+
/** Other exports of @bake-native/octane/ui (not components). */
|
|
227
|
+
const UI_EXPORTS = ["TAB_ICONS"];
|
|
228
|
+
/** @expo/ui Universal exports that @bake-native/octane/ui does not have yet (a later release): a clear
|
|
229
|
+
* build error instead of a missing export. */
|
|
230
|
+
const UI_LATER = {
|
|
231
|
+
BottomSheet: "a <dialog open> (an open dialog is a platform sheet), or @bake-native/octane/swift-ui BottomSheet on iOS / macOS",
|
|
232
|
+
Collapsible: "a <details> element",
|
|
233
|
+
FieldGroup: "Column with your own section styles",
|
|
234
|
+
Icon: "an inline <svg>",
|
|
235
|
+
List: "Column, or VirtualList from @bake-native/octane",
|
|
236
|
+
ListItem: "Row",
|
|
237
|
+
RNHostView: "plain elements next to the Host (Universal components are elements on web and Windows)",
|
|
238
|
+
OctaneView: "plain elements next to the Host",
|
|
239
|
+
ScrollView: "a <div> with overflow: auto",
|
|
240
|
+
useNativeState: "useState from octane (state is controlled from JS: value + onChangeText)"
|
|
241
|
+
};
|
|
242
|
+
/** Props @expo/ui has that @bake-native/octane/ui does not (yet), with what to use instead. */
|
|
243
|
+
const UI_PROPS_LATER = {
|
|
244
|
+
modifiers: "style (platform modifiers are in @bake-native/octane/swift-ui)",
|
|
245
|
+
onAppear: "useEffect in the component that renders it",
|
|
246
|
+
onDisappear: "the cleanup of a useEffect",
|
|
247
|
+
editable: "render the value as Text (TextInput has no read-only state in v0.1; Button, Switch, Checkbox and Slider take `disabled`, Picker takes `enabled`)",
|
|
248
|
+
readOnly: "render the value as Text",
|
|
249
|
+
autoFocus: "nothing yet (focus is not moved on mount on native targets)",
|
|
250
|
+
snapPoints: "nothing yet (BottomSheet is a later release)"
|
|
251
|
+
};
|
|
252
|
+
/** The import paths of the SwiftUI components (one module). */
|
|
253
|
+
const SWIFT_UI_MODULES = ["@bake-native/octane/ui/swift-ui"];
|
|
254
|
+
/** Targets SwiftUI draws on. On the web the components render HTML approximations; on every
|
|
255
|
+
* other target a SwiftUI component left in the bundle is a build error (ui-swift-ui-target). */
|
|
256
|
+
const SWIFT_UI_TARGETS = ["ios", "mac"];
|
|
257
|
+
/** What to use instead of @bake-native/octane/swift-ui on a target SwiftUI does not draw on. */
|
|
258
|
+
const SWIFT_UI_INSTEAD = "the Universal components of `@bake-native/octane/ui` (every target), or render the SwiftUI screen only in a branch on import.meta.env.BAKE_TARGET ('ios' / 'mac') and something else on the other targets";
|
|
259
|
+
/** Props of @bake-native/octane/swift-ui components that are not drawn on iOS / macOS (@expo/ui has
|
|
260
|
+
* them), with what to use instead: a build error (ui-swift-ui-prop) on every target. */
|
|
261
|
+
const SWIFT_UI_PROPS_LATER = { Host: { ignoreSafeArea: "the ignoresSafeArea() modifier on the Host's content (`modifiers={[ignoresSafeArea()]}`); the Host itself is laid out by CSS, so give it the size you want" } };
|
|
262
|
+
export { UI_SWIFT_STYLE_KEYS as n, scope_exports as r, UI_COMPONENTS as t };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NativeModule } from '@bake-native/core';
|
|
2
|
+
|
|
3
|
+
/** The screen's service defines its routes and performs navigation on the main thread. */
|
|
4
|
+
export interface BakeNativeScreen extends NativeModule {
|
|
5
|
+
push(route: string, template: string, screenArguments: Record<string, Record<string, unknown>>): void;
|
|
6
|
+
pop(): void;
|
|
7
|
+
postponeEnterTransition(): void;
|
|
8
|
+
startPostponedEnterTransition(): void;
|
|
9
|
+
}
|
package/dom-exception.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// DOMException for the native targets (Hermes has none): web-fetch.js (AbortError, TimeoutError,
|
|
2
|
+
// NetworkError) and web-crypto.js (TypeMismatchError, QuotaExceededError) install the same class,
|
|
3
|
+
// whichever runs first. Plain module, no imports.
|
|
4
|
+
|
|
5
|
+
const DOM_CODES = {
|
|
6
|
+
IndexSizeError: 1, HierarchyRequestError: 3, WrongDocumentError: 4, InvalidCharacterError: 5, NoModificationAllowedError: 7,
|
|
7
|
+
NotFoundError: 8, NotSupportedError: 9, InvalidStateError: 11, SyntaxError: 12, InvalidModificationError: 13, NamespaceError: 14,
|
|
8
|
+
InvalidAccessError: 15, TypeMismatchError: 17, SecurityError: 18, NetworkError: 19, AbortError: 20, URLMismatchError: 21,
|
|
9
|
+
QuotaExceededError: 22, TimeoutError: 23, InvalidNodeTypeError: 24, DataCloneError: 25,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export class DOMExceptionPolyfill extends Error {
|
|
13
|
+
constructor(message = '', name = 'Error') {
|
|
14
|
+
super(String(message));
|
|
15
|
+
Object.defineProperty(this, 'name', { value: String(name), configurable: true, writable: true });
|
|
16
|
+
}
|
|
17
|
+
get code() { return DOM_CODES[this.name] || 0; }
|
|
18
|
+
}
|
|
19
|
+
DOMExceptionPolyfill.ABORT_ERR = 20;
|
|
20
|
+
DOMExceptionPolyfill.TIMEOUT_ERR = 23;
|
|
21
|
+
DOMExceptionPolyfill.NETWORK_ERR = 19;
|
|
22
|
+
DOMExceptionPolyfill.TYPE_MISMATCH_ERR = 17;
|
|
23
|
+
DOMExceptionPolyfill.QUOTA_EXCEEDED_ERR = 22;
|
|
24
|
+
|
|
25
|
+
/** `g.DOMException` (installed when the engine has none). */
|
|
26
|
+
export function installDOMException(g) {
|
|
27
|
+
if (typeof g.DOMException === 'undefined') {
|
|
28
|
+
Object.defineProperty(g, 'DOMException', { value: DOMExceptionPolyfill, writable: true, configurable: true, enumerable: false });
|
|
29
|
+
}
|
|
30
|
+
return g.DOMException;
|
|
31
|
+
}
|
package/element-api.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Element handles of native targets (refs, event targets): synchronous reads of the core's layout
|
|
2
|
+
// and focus on the JS thread through __bakeElement (element.rs in the runtime). Batches JS sent in
|
|
3
|
+
// the same entry are applied and laid out first, as the web's forced layout. Errors carry a code
|
|
4
|
+
// (E_NO_LAYOUT for a read before the first commit, E_UNSUPPORTED for what native targets do not
|
|
5
|
+
// have). addEventListener works from the first render's mount effects: the runtime queues it.
|
|
6
|
+
//
|
|
7
|
+
// host-runtime.js installs this only in bundles that name an element API (`bake build`:
|
|
8
|
+
// __BAKE_ELEMENT_API__, fail-closed.mjs usesElementApi): the rest pay nothing for it.
|
|
9
|
+
|
|
10
|
+
/** Installs getComputedStyle and document.activeElement's backing on `global`; `element(id)` is
|
|
11
|
+
* the runtime's handle cache. Returns the handles' prototype and the addEventListener table. */
|
|
12
|
+
export function installElementApi(global, element) {
|
|
13
|
+
const elementOp = global.__bakeElement;
|
|
14
|
+
function elementCall(op, id, a, b) {
|
|
15
|
+
if (typeof elementOp !== 'function') {
|
|
16
|
+
const err = new Error('element APIs are not available in this runtime (a host whose core predates them, or the snapshot bake)');
|
|
17
|
+
err.code = 'E_UNAVAILABLE';
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
return elementOp(op, id, a, b);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
const message = String(e?.message ?? e);
|
|
24
|
+
const m = /^(E_[A-Z_]+): ([\s\S]*)$/.exec(message);
|
|
25
|
+
if (!m) throw e;
|
|
26
|
+
const err = new Error(m[2]);
|
|
27
|
+
err.code = m[1];
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function rectOf(g, i) {
|
|
32
|
+
const x = g[i], y = g[i + 1], width = g[i + 2], height = g[i + 3];
|
|
33
|
+
return { x, y, width, height, top: y, left: x, right: x + width, bottom: y + height,
|
|
34
|
+
toJSON() { return { x, y, width, height, top: y, left: x, right: x + width, bottom: y + height }; } };
|
|
35
|
+
}
|
|
36
|
+
// Listeners added with addEventListener: id -> key ('click' / 'clickcapture') -> functions.
|
|
37
|
+
const refListeners = new Map();
|
|
38
|
+
function runRefListeners(id, key, event) {
|
|
39
|
+
const set = refListeners.get(id)?.get(key);
|
|
40
|
+
if (!set) return;
|
|
41
|
+
for (const fn of [...set]) {
|
|
42
|
+
if (event.__immediate) break;
|
|
43
|
+
if (typeof fn === 'function') fn.call(event.currentTarget, event);
|
|
44
|
+
else fn.handleEvent(event);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const elementProto = {
|
|
48
|
+
getBoundingClientRect() {
|
|
49
|
+
return rectOf(elementCall(0, this.id), 0);
|
|
50
|
+
},
|
|
51
|
+
getClientRects() {
|
|
52
|
+
const r = rectOf(elementCall(0, this.id), 0);
|
|
53
|
+
return r.width || r.height ? [r] : [];
|
|
54
|
+
},
|
|
55
|
+
get offsetLeft() { return elementCall(0, this.id)[4]; },
|
|
56
|
+
get offsetTop() { return elementCall(0, this.id)[5]; },
|
|
57
|
+
get offsetWidth() { return elementCall(0, this.id)[6]; },
|
|
58
|
+
get offsetHeight() { return elementCall(0, this.id)[7]; },
|
|
59
|
+
get offsetParent() {
|
|
60
|
+
const p = elementCall(0, this.id)[16];
|
|
61
|
+
return Number.isNaN(p) ? null : element(p);
|
|
62
|
+
},
|
|
63
|
+
get clientLeft() { return elementCall(0, this.id)[8]; },
|
|
64
|
+
get clientTop() { return elementCall(0, this.id)[9]; },
|
|
65
|
+
get clientWidth() { return elementCall(0, this.id)[10]; },
|
|
66
|
+
get clientHeight() { return elementCall(0, this.id)[11]; },
|
|
67
|
+
get scrollLeft() { return elementCall(0, this.id)[12]; },
|
|
68
|
+
get scrollTop() { return elementCall(0, this.id)[13]; },
|
|
69
|
+
get scrollWidth() { return elementCall(0, this.id)[14]; },
|
|
70
|
+
get scrollHeight() { return elementCall(0, this.id)[15]; },
|
|
71
|
+
focus() {
|
|
72
|
+
elementCall(1, this.id);
|
|
73
|
+
},
|
|
74
|
+
blur() {
|
|
75
|
+
elementCall(2, this.id);
|
|
76
|
+
},
|
|
77
|
+
contains(other) {
|
|
78
|
+
return other != null && typeof other.id === 'number' && elementCall(4, this.id, other.id);
|
|
79
|
+
},
|
|
80
|
+
addEventListener(type, fn, options) {
|
|
81
|
+
if (fn == null) return;
|
|
82
|
+
const capture = typeof options === 'boolean' ? options : !!options?.capture;
|
|
83
|
+
const key = String(type).toLowerCase() + (capture ? 'capture' : '');
|
|
84
|
+
let byKey = refListeners.get(this.id);
|
|
85
|
+
let set = byKey?.get(key);
|
|
86
|
+
if (!set) {
|
|
87
|
+
// The core checks the event name (E_UNSUPPORTED for one it does not deliver) before the
|
|
88
|
+
// table takes anything. Before the first commit (a mount effect of the first render) it
|
|
89
|
+
// queues the registration behind the batch that creates the element.
|
|
90
|
+
elementCall(6, this.id, key, 1);
|
|
91
|
+
if (!byKey) refListeners.set(this.id, (byKey = new Map()));
|
|
92
|
+
byKey.set(key, (set = new Set()));
|
|
93
|
+
}
|
|
94
|
+
if (options?.once) {
|
|
95
|
+
const self = this;
|
|
96
|
+
const once = function (event) {
|
|
97
|
+
self.removeEventListener(type, once, options);
|
|
98
|
+
return typeof fn === 'function' ? fn.call(this, event) : fn.handleEvent(event);
|
|
99
|
+
};
|
|
100
|
+
once.__bakeOnceOf = fn;
|
|
101
|
+
set.add(once);
|
|
102
|
+
} else {
|
|
103
|
+
set.add(fn);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
removeEventListener(type, fn, options) {
|
|
107
|
+
const capture = typeof options === 'boolean' ? options : !!options?.capture;
|
|
108
|
+
const key = String(type).toLowerCase() + (capture ? 'capture' : '');
|
|
109
|
+
const byKey = refListeners.get(this.id);
|
|
110
|
+
const set = byKey?.get(key);
|
|
111
|
+
if (!set) return;
|
|
112
|
+
if (!set.delete(fn)) for (const f of set) if (f.__bakeOnceOf === fn) { set.delete(f); break; }
|
|
113
|
+
if (set.size === 0) {
|
|
114
|
+
byKey.delete(key);
|
|
115
|
+
if (byKey.size === 0) refListeners.delete(this.id);
|
|
116
|
+
try {
|
|
117
|
+
elementCall(6, this.id, key, 0);
|
|
118
|
+
} catch {}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
get ownerDocument() {
|
|
122
|
+
return nativeDocument;
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
// The subset of `document` native targets have (`bake build` rewrites document.activeElement).
|
|
126
|
+
const nativeDocument = {
|
|
127
|
+
get activeElement() {
|
|
128
|
+
const id = elementCall(3, 0);
|
|
129
|
+
return id == null ? null : element(id);
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
global.__bakeActiveElement = () => nativeDocument.activeElement;
|
|
133
|
+
// getComputedStyle(element): a live view (each read asks the core). Properties outside the
|
|
134
|
+
// supported list throw (fail-closed); getPropertyValue takes kebab-case names, and custom
|
|
135
|
+
// properties (`--name`, case-sensitive, with env() substituted) as written.
|
|
136
|
+
const camel = (name) => name.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
137
|
+
global.getComputedStyle = function getComputedStyle(el) {
|
|
138
|
+
if (el != null && (el.tagName === 'HTML' || el.tagName === 'BODY') && typeof el.id !== 'number') {
|
|
139
|
+
throw new TypeError(`getComputedStyle(document.${el.tagName === 'HTML' ? 'documentElement' : 'body'}) is not supported on native targets: pass an element from a ref (custom properties set on :root inherit to it)`);
|
|
140
|
+
}
|
|
141
|
+
if (el == null || typeof el.id !== 'number') throw new TypeError('getComputedStyle: the argument is not an element');
|
|
142
|
+
const id = el.id;
|
|
143
|
+
const read = (name) => elementCall(5, id, name);
|
|
144
|
+
return new Proxy(
|
|
145
|
+
{ getPropertyValue: (name) => { const n = String(name); return read(n.startsWith('--') ? n : camel(n)); } },
|
|
146
|
+
{
|
|
147
|
+
get(target, key) {
|
|
148
|
+
if (typeof key !== 'string' || key in target) return target[key];
|
|
149
|
+
// As on the web, custom properties are read only through getPropertyValue.
|
|
150
|
+
if (key.startsWith('--')) return undefined;
|
|
151
|
+
return read(key);
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
return { proto: elementProto, refListeners, runRefListeners };
|
|
158
|
+
}
|
package/first-screen.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The app's side of the bake's traps for values a baked first screen cannot know
|
|
2
|
+
// (docs/design/first-screen-locales.md). The traps themselves are bake-prelude.js, which bake-frame
|
|
3
|
+
// runs before app.hbc (`globalThis.__bakeBake`): they are not part of an app bundle, and outside a
|
|
4
|
+
// bake these do nothing.
|
|
5
|
+
|
|
6
|
+
const bake = () => globalThis.__bakeBake;
|
|
7
|
+
|
|
8
|
+
/** Records a read of `what` while baking; true when it did. */
|
|
9
|
+
export function recordRead(what) {
|
|
10
|
+
return globalThis.__bakeBaking ? (bake()?.recordRead(what) ?? false) : false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Puts the bake's traps in (time, randomness, Intl); returns the function that takes them out.
|
|
14
|
+
* A bake without the prelude fails: its first screen would not be checked. */
|
|
15
|
+
export function installBakeTraps() {
|
|
16
|
+
const b = bake();
|
|
17
|
+
if (!b) throw new Error('the bake prelude is not loaded (bake-prelude.js, BAKE_FRAME_PRELUDE): bake-frame runs it before app.hbc');
|
|
18
|
+
return b.installBakeTraps();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The root's props while baking (every key read recorded). */
|
|
22
|
+
export const bakeProps = (reserved) => bake().bakeProps(reserved);
|
|
23
|
+
|
|
24
|
+
/** The prop reads recorded so far (emptied). */
|
|
25
|
+
export const takePropReads = () => bake()?.takePropReads() ?? [];
|
|
26
|
+
|
|
27
|
+
/** Fails the bake with every read the first render made (none: returns). */
|
|
28
|
+
export function throwIfRead() {
|
|
29
|
+
bake()?.throwIfRead();
|
|
30
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/fonts/OFL.txt
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2026 The Geist Project Authors (https://github.com/vercel/geist-font)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://openfontlicense.org
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
package/fonts/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Bundled fonts
|
|
2
|
+
|
|
3
|
+
Choose the faces the app uses in its `bake.config.ts`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineConfig } from '@bake-native/react';
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
fonts: [
|
|
10
|
+
'geist',
|
|
11
|
+
'geist-mono',
|
|
12
|
+
{ family: 'Brand', src: './assets/Brand.ttf', weight: [100, 900] },
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Use `font-family: "Geist"`, `"Geist Mono"` or `"Brand"` in app CSS.
|
|
18
|
+
Each preset supplies one variable face with weights 100–900. Select `geist-italic`
|
|
19
|
+
or `geist-mono-italic` for the corresponding italic face. The build packages the selected files
|
|
20
|
+
and native hosts register them before the first frame.
|
|
21
|
+
|
|
22
|
+
## Source and license
|
|
23
|
+
|
|
24
|
+
Geist and Geist Mono by Vercel and the Geist Project Authors, version 1.9.2
|
|
25
|
+
(https://github.com/vercel/geist-font, release `v1.9.2`, the `variable/*[wght].ttf` files,
|
|
26
|
+
renamed and otherwise unmodified). Licensed under the SIL Open Font License, Version 1.1:
|
|
27
|
+
[OFL.txt](./OFL.txt).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* Geist Sans italic (Vercel Geist v1.9.2, variable, weights 100-900). SIL Open Font License 1.1: see OFL.txt.
|
|
2
|
+
Select 'geist-italic' in bake.config.ts fonts; then font-family: "Geist". */
|
|
3
|
+
@font-face {
|
|
4
|
+
font-family: "Geist";
|
|
5
|
+
src: url("./Geist-Italic-Variable.ttf") format("truetype");
|
|
6
|
+
font-weight: 100 900;
|
|
7
|
+
font-style: italic;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* Geist Mono italic (Vercel Geist v1.9.2, variable, weights 100-900). SIL Open Font License 1.1: see OFL.txt.
|
|
2
|
+
Select 'geist-mono-italic' in bake.config.ts fonts; then font-family: "Geist Mono". */
|
|
3
|
+
@font-face {
|
|
4
|
+
font-family: "Geist Mono";
|
|
5
|
+
src: url("./GeistMono-Italic-Variable.ttf") format("truetype");
|
|
6
|
+
font-weight: 100 900;
|
|
7
|
+
font-style: italic;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* Geist Mono (Vercel Geist v1.9.2, variable, weights 100-900). SIL Open Font License 1.1: see OFL.txt.
|
|
2
|
+
Select 'geist-mono' in bake.config.ts fonts; then font-family: "Geist Mono". */
|
|
3
|
+
@font-face {
|
|
4
|
+
font-family: "Geist Mono";
|
|
5
|
+
src: url("./GeistMono-Variable.ttf") format("truetype");
|
|
6
|
+
font-weight: 100 900;
|
|
7
|
+
font-style: normal;
|
|
8
|
+
}
|
package/fonts/geist.css
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* Geist Sans (Vercel Geist v1.9.2, variable, weights 100-900). SIL Open Font License 1.1: see OFL.txt.
|
|
2
|
+
Select 'geist' in bake.config.ts fonts; then font-family: "Geist". */
|
|
3
|
+
@font-face {
|
|
4
|
+
font-family: "Geist";
|
|
5
|
+
src: url("./Geist-Variable.ttf") format("truetype");
|
|
6
|
+
font-weight: 100 900;
|
|
7
|
+
font-style: normal;
|
|
8
|
+
}
|