@bake-native/core 0.0.0 → 0.1.0-rc.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/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/close-watcher.js +137 -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-BrSFpaK1.mjs +1 -0
- package/dist/build-tools-Dxyl6XAf.mjs +80 -0
- package/dist/build-vAPG2xQv.mjs +5516 -0
- package/dist/client-Cm7o6dQd.mjs +17544 -0
- package/dist/compiler.mjs +4 -0
- package/dist/config-B1W8gfZY.mjs +12 -0
- package/dist/dev-xZblYmDc.mjs +990 -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-BQ8TtbQj.mjs +8046 -0
- package/dist/octane/package.json +5 -0
- package/dist/package-D2aYD6A4.mjs +2789 -0
- package/dist/react/package.json +13 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/dist/run-BtyJGAQB.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 +521 -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 +166 -0
- package/native-scenarios.d.ts +17 -0
- package/native-scenarios.js +46 -0
- package/native-support.json +366 -0
- package/native.d.ts +52 -0
- package/native.js +237 -0
- package/package.json +143 -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 +176 -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
package/bake-prelude.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// The values a baked first screen cannot know (docs/design/first-screen-locales.md), as the bake
|
|
2
|
+
// traps them: bake build compiles this script to its own bytecode and bake-frame (and bake-snap) run
|
|
3
|
+
// it before the app's app.hbc (`BAKE_FRAME_PRELUDE`, bake-runtime bake.rs), so none of it ships in
|
|
4
|
+
// an app bundle; the app reaches it through first-screen.js (`globalThis.__bakeBake`), which is a
|
|
5
|
+
// no-op on a device. While the build bakes the first commit (`globalThis.__bakeBaking`, set by
|
|
6
|
+
// bake-frame), every read of one is recorded with its stack, and the render goes on with a
|
|
7
|
+
// stand-in value, so one bake finds them all. When the first render ends, `throwIfRead` fails
|
|
8
|
+
// the bake with the list (a FirstScreenReads error whose message is `FirstScreenReads: <JSON>`),
|
|
9
|
+
// which `bake build` turns into one error per place: the app's file, line and column, the line of
|
|
10
|
+
// code, the value, the component path and the fix (first-screen-report.mjs).
|
|
11
|
+
//
|
|
12
|
+
// The fix: draw the first screen with a default and read the value after the first render
|
|
13
|
+
// (a root component parameter default for the host's props, a state's initial value set from an
|
|
14
|
+
// effect for time, randomness and native reads), or `bake: false` in bake.config.ts for an app
|
|
15
|
+
// whose first screen must show it. The device's first render uses the same defaults, so its
|
|
16
|
+
// first commit is the first screen.
|
|
17
|
+
(function () {
|
|
18
|
+
class FirstScreenReads extends Error {
|
|
19
|
+
constructor(reads) {
|
|
20
|
+
super(`FirstScreenReads: ${JSON.stringify(reads)}`);
|
|
21
|
+
this.name = 'FirstScreenReads';
|
|
22
|
+
this.reads = reads;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Reads recorded since the traps went in. */
|
|
27
|
+
const reads = [];
|
|
28
|
+
|
|
29
|
+
/** Records a read of `what` (with the stack that made it) while baking; true when it did. */
|
|
30
|
+
function recordRead(what) {
|
|
31
|
+
if (!globalThis.__bakeBaking) return false;
|
|
32
|
+
reads.push({ what, stack: String(new Error().stack ?? '') });
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A value read can use a parameter default. The presence or enumeration of host keys cannot. */
|
|
37
|
+
const propReads = [];
|
|
38
|
+
function bakeProps(reserved = []) {
|
|
39
|
+
const appKey = key => typeof key === 'string' && !reserved.includes(key);
|
|
40
|
+
function checkPresence(key) {
|
|
41
|
+
if (globalThis.__bakeStrictBake && appKey(key)) recordRead(`props.${key}`);
|
|
42
|
+
}
|
|
43
|
+
return new Proxy({}, {
|
|
44
|
+
get(target, key) {
|
|
45
|
+
if (appKey(key)) propReads.push({ key, stack: String(new Error().stack ?? '') });
|
|
46
|
+
return Reflect.get(target, key);
|
|
47
|
+
},
|
|
48
|
+
has(target, key) {
|
|
49
|
+
checkPresence(key);
|
|
50
|
+
return Reflect.has(target, key);
|
|
51
|
+
},
|
|
52
|
+
getOwnPropertyDescriptor(target, key) {
|
|
53
|
+
checkPresence(key);
|
|
54
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
|
55
|
+
},
|
|
56
|
+
ownKeys(target) {
|
|
57
|
+
if (globalThis.__bakeStrictBake) recordRead('host.props');
|
|
58
|
+
return Reflect.ownKeys(target);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The prop reads recorded so far (emptied). */
|
|
64
|
+
function takePropReads() {
|
|
65
|
+
return propReads.splice(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Fails the bake with every read the first render made (none: returns). */
|
|
69
|
+
function throwIfRead() {
|
|
70
|
+
if (reads.length) throw new FirstScreenReads(reads.splice(0));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Replaces the time, randomness and Intl globals and the locale-dependent string methods with
|
|
75
|
+
* ones that record the read and return a stand-in while the first commit is rendered; returns
|
|
76
|
+
* the function that puts them back.
|
|
77
|
+
*/
|
|
78
|
+
function installBakeTraps(g = globalThis) {
|
|
79
|
+
const undo = [];
|
|
80
|
+
// An own property is replaced and put back; one the object inherits (performance.now,
|
|
81
|
+
// crypto.randomUUID on their prototypes) is shadowed by an own one and the shadow removed.
|
|
82
|
+
const swap = (owner, key, value) => {
|
|
83
|
+
if (!owner || !(key in owner)) return;
|
|
84
|
+
const had = Object.getOwnPropertyDescriptor(owner, key);
|
|
85
|
+
if (had) {
|
|
86
|
+
Object.defineProperty(owner, key, { ...had, value });
|
|
87
|
+
undo.push(() => Object.defineProperty(owner, key, had));
|
|
88
|
+
} else {
|
|
89
|
+
Object.defineProperty(owner, key, { value, writable: true, configurable: true });
|
|
90
|
+
undo.push(() => delete owner[key]);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const standIn = (what, value) => function () {
|
|
94
|
+
recordRead(what);
|
|
95
|
+
return typeof value === 'function' ? value.apply(this, arguments) : value;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const RealDate = g.Date;
|
|
99
|
+
// Only ISO date-only or explicitly zoned ISO timestamps have a portable string parse.
|
|
100
|
+
const portableDate = /^(?:[+-]\d{6}|\d{4})(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[+-]\d{2}:\d{2}))?$/i;
|
|
101
|
+
const strict = g.__bakeStrictBake === true;
|
|
102
|
+
const checkDateText = (text) => {
|
|
103
|
+
if (strict && typeof text === 'string' && !portableDate.test(text)) recordRead('Date parsing without a portable time zone');
|
|
104
|
+
};
|
|
105
|
+
function BakeDate(...args) {
|
|
106
|
+
if (!new.target) {
|
|
107
|
+
recordRead('Date()');
|
|
108
|
+
return strict ? 'Thu, 01 Jan 1970 00:00:00 GMT' : new RealDate(0).toString();
|
|
109
|
+
}
|
|
110
|
+
if (args.length === 0) {
|
|
111
|
+
recordRead('new Date()');
|
|
112
|
+
return Reflect.construct(RealDate, [0], new.target);
|
|
113
|
+
}
|
|
114
|
+
if (strict && args.length > 1) recordRead('new Date() with local calendar fields');
|
|
115
|
+
checkDateText(args[0]);
|
|
116
|
+
return Reflect.construct(RealDate, args, new.target);
|
|
117
|
+
}
|
|
118
|
+
BakeDate.prototype = RealDate.prototype;
|
|
119
|
+
BakeDate.UTC = RealDate.UTC;
|
|
120
|
+
BakeDate.parse = strict ? (s) => { const text = String(s); checkDateText(text); return RealDate.parse(text); } : RealDate.parse;
|
|
121
|
+
if (strict) {
|
|
122
|
+
for (const method of Object.getOwnPropertyNames(RealDate.prototype)) {
|
|
123
|
+
if (/^(?:get|set)(?:Date|Day|FullYear|Hours|Milliseconds|Minutes|Month|Seconds|TimezoneOffset|Year)$|^to(?:Date|Time)?String$/.test(method)) {
|
|
124
|
+
swap(RealDate.prototype, method, standIn(`Date.prototype.${method}()`, RealDate.prototype[method]));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
BakeDate.now = standIn('Date.now()', 0);
|
|
129
|
+
swap(g, 'Date', BakeDate);
|
|
130
|
+
swap(g.performance, 'now', standIn('performance.now()', 0));
|
|
131
|
+
swap(g.Math, 'random', standIn('Math.random()', 0));
|
|
132
|
+
// alert() / confirm() show a dialog on the device; the bake's stand-in resolves as Cancel.
|
|
133
|
+
swap(g, 'alert', standIn('alert()', () => Promise.resolve(undefined)));
|
|
134
|
+
swap(g, 'confirm', standIn('confirm()', () => Promise.resolve(false)));
|
|
135
|
+
if (g.crypto) {
|
|
136
|
+
swap(g.crypto, 'getRandomValues', standIn('crypto.getRandomValues()', (a) => a));
|
|
137
|
+
swap(g.crypto, 'randomUUID', standIn('crypto.randomUUID()', '00000000-0000-4000-8000-000000000000'));
|
|
138
|
+
}
|
|
139
|
+
// A formatter that formats nothing: the read is recorded when it is made.
|
|
140
|
+
const formatter = { format: () => '', formatToParts: () => [], formatRange: () => '', resolvedOptions: () => ({}), select: () => 'other', compare: () => 0, of: () => '', segment: () => [] };
|
|
141
|
+
// Every Intl member a render calls (a constructor, getCanonicalLocales, ...) is a read. An
|
|
142
|
+
// engine without Intl (a Hermes built without it, such as an older runtime) gets a stand-in for the
|
|
143
|
+
// first render, so the read is reported the same way there instead of a ReferenceError.
|
|
144
|
+
const intlRead = (key) => {
|
|
145
|
+
const what = `Intl.${String(key)}`;
|
|
146
|
+
return function () {
|
|
147
|
+
recordRead(what);
|
|
148
|
+
return formatter;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
if (g.Intl) {
|
|
152
|
+
swap(g, 'Intl', new Proxy(g.Intl, {
|
|
153
|
+
get(target, key) {
|
|
154
|
+
const v = Reflect.get(target, key);
|
|
155
|
+
return typeof v === 'function' ? intlRead(key) : v;
|
|
156
|
+
},
|
|
157
|
+
}));
|
|
158
|
+
} else {
|
|
159
|
+
const stub = new Proxy({}, {
|
|
160
|
+
get(target, key) {
|
|
161
|
+
return typeof key === 'symbol' ? Reflect.get(target, key) : intlRead(key);
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(g, 'Intl', { value: stub, writable: true, configurable: true });
|
|
165
|
+
undo.push(() => delete g.Intl);
|
|
166
|
+
}
|
|
167
|
+
swap(g.Number.prototype, 'toLocaleString', standIn('Number.prototype.toLocaleString()', ''));
|
|
168
|
+
swap(g.Array.prototype, 'toLocaleString', standIn('Array.prototype.toLocaleString()', ''));
|
|
169
|
+
for (const m of ['toLocaleString', 'toLocaleDateString', 'toLocaleTimeString']) swap(RealDate.prototype, m, standIn(`Date.prototype.${m}()`, ''));
|
|
170
|
+
// Collation and case mapping follow the device's locale and ICU (Intl on every Hermes target),
|
|
171
|
+
// so a first render that sorts or maps case with them may differ on the device. The stand-ins
|
|
172
|
+
// are the deterministic forms the fix names: code point order, toUpperCase / toLowerCase.
|
|
173
|
+
const S = g.String.prototype;
|
|
174
|
+
swap(S, 'localeCompare', standIn('String.prototype.localeCompare()', function (that) {
|
|
175
|
+
const a = String(this), b = String(that);
|
|
176
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
177
|
+
}));
|
|
178
|
+
swap(S, 'toLocaleUpperCase', standIn('String.prototype.toLocaleUpperCase()', function () { return String(this).toUpperCase(); }));
|
|
179
|
+
swap(S, 'toLocaleLowerCase', standIn('String.prototype.toLocaleLowerCase()', function () { return String(this).toLowerCase(); }));
|
|
180
|
+
return () => {
|
|
181
|
+
for (const u of undo.reverse()) u();
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Strong covers synchronous initialization of modules as well as the root's render. Device
|
|
186
|
+
// VMs never load this script. Reuse the early traps when mount starts, then restore once.
|
|
187
|
+
const early = globalThis.__bakeStrictBake ? installBakeTraps() : null;
|
|
188
|
+
globalThis.__bakeBake = { FirstScreenReads, recordRead, bakeProps, takePropReads, throwIfRead, installBakeTraps: () => early ?? installBakeTraps() };
|
|
189
|
+
})();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Generated by bake-abi-gen from native/rust/schema/batch.oschema. Do not edit.",
|
|
3
|
+
"digest": "0xd4c77b3d54621b67",
|
|
4
|
+
"stream": "ed450a04d5a6a5dd",
|
|
5
|
+
"seed": ["native", "click", "discrete", "default", "continuous", "hidden", "visible", "value", "class", "className", "style", "id", "type", "role", "title", "label", "disabled", "checked", "placeholder", "data-expect", "aria-label", "aria-hidden", "aria-pressed", "modifiers", "$type", "#text", "div", "span", "p", "main", "button", "section", "header", "footer", "img", "input", "svg", "path", "left", "top", "right", "bottom", "width", "height", "position", "backgroundColor", "color", "opacity", "transform", "fill", "stroke", "d"],
|
|
6
|
+
"ops": {
|
|
7
|
+
"create": { "tag": 1, "shape": "ceedecf0869e4cc1" },
|
|
8
|
+
"update": { "tag": 2, "shape": "11ab636af1186798" },
|
|
9
|
+
"recreate": { "tag": 3, "shape": "ceedecf0869e4cc1" },
|
|
10
|
+
"insert": { "tag": 4, "shape": "f0253cbaca3a749f" },
|
|
11
|
+
"move": { "tag": 5, "shape": "f0253cbaca3a749f" },
|
|
12
|
+
"remove": { "tag": 6, "shape": "9fadb466fd5eed28" },
|
|
13
|
+
"destroy": { "tag": 7, "shape": "cdb939bab67bfe62" },
|
|
14
|
+
"event": { "tag": 8, "shape": "dc46c1f636e25100" },
|
|
15
|
+
"visibility": { "tag": 9, "shape": "16408ca043827922" },
|
|
16
|
+
"mount-template-run": { "tag": 10, "shape": "9cd3171437fc3194" },
|
|
17
|
+
"mount-template-range": { "tag": 11, "shape": "de01fc8a5e19f1a7" },
|
|
18
|
+
"mount-template": { "tag": 12, "shape": "317f5d15f465c6fe" },
|
|
19
|
+
"set-transform": { "tag": 13, "shape": "e2a74faf03a213d8" }
|
|
20
|
+
}
|
|
21
|
+
}
|