@tarve/core 0.4.0 → 0.6.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/CHANGELOG.md +126 -1
- package/README.md +121 -12
- package/dist/npm/build.js +1401 -85
- package/dist/npm/cli.js +1940 -117
- package/dist/npm/embedded-assets.js +22 -3
- package/dist/npm/index.js +5274 -975
- package/dist/npm/jsx-dev-runtime.js +1268 -0
- package/dist/npm/jsx-runtime.js +1268 -0
- package/dist/npm/native-runtime.json +3 -3
- package/dist/npm/node-build.js +1159 -0
- package/dist/npm/protocol.js +1 -1
- package/dist/npm/runtime.js +5 -5
- package/dist/npm/txiki/fetch.ts +228 -0
- package/dist/npm/txiki/intl-data.ts +7 -0
- package/dist/npm/txiki/intl.test.ts +53 -0
- package/dist/npm/txiki/intl.ts +249 -0
- package/dist/npm/txiki/prelude.ts +132 -0
- package/dist/npm/txiki/runtime.ts +6 -0
- package/dist/npm/txiki/shims/buffer.ts +112 -0
- package/dist/npm/txiki/shims/child-process.ts +151 -0
- package/dist/npm/txiki/shims/crypto.ts +30 -0
- package/dist/npm/txiki/shims/events.ts +75 -0
- package/dist/npm/txiki/shims/fs-promises.ts +77 -0
- package/dist/npm/txiki/shims/fs.ts +231 -0
- package/dist/npm/txiki/shims/module.ts +8 -0
- package/dist/npm/txiki/shims/net.ts +69 -0
- package/dist/npm/txiki/shims/os.ts +72 -0
- package/dist/npm/txiki/shims/path.ts +4 -0
- package/dist/npm/txiki/shims/timers-promises.ts +9 -0
- package/dist/npm/txiki/shims/zlib.ts +9 -0
- package/dist/npm/txiki/tjs.d.ts +58 -0
- package/dist/npm/txiki/unavailable.ts +10 -0
- package/dist/types/core/build.d.ts +24 -0
- package/dist/types/core/cli.d.ts +1 -1
- package/dist/types/core/esbuild-file-imports.d.ts +8 -0
- package/dist/types/core/jsx-compile.d.ts +7 -0
- package/dist/types/core/node-build.d.ts +7 -0
- package/dist/types/core/node-dev.d.ts +4 -0
- package/dist/types/core/node-target.d.ts +10 -0
- package/dist/types/core/package-metadata.d.ts +49 -0
- package/dist/types/core/runtime-select.d.ts +8 -0
- package/dist/types/core/src/advanced-controls.d.ts +1 -1
- package/dist/types/core/src/app/element-events.d.ts +18 -0
- package/dist/types/core/src/app/media.d.ts +15 -0
- package/dist/types/core/src/app/requests.d.ts +25 -0
- package/dist/types/core/src/app/shadow.d.ts +7 -0
- package/dist/types/core/src/app/stats.d.ts +12 -0
- package/dist/types/core/src/app/tray.d.ts +40 -0
- package/dist/types/core/src/app-metadata.d.ts +18 -0
- package/dist/types/core/src/app.d.ts +89 -2
- package/dist/types/core/src/assets.d.ts +4 -0
- package/dist/types/core/src/bridge/binding.d.ts +10 -34
- package/dist/types/core/src/bridge/index.d.ts +1 -1
- package/dist/types/core/src/canvas.d.ts +161 -0
- package/dist/types/core/src/chat-controls.d.ts +2 -1
- package/dist/types/core/src/components/button.d.ts +1 -1
- package/dist/types/core/src/components/glass.d.ts +52 -0
- package/dist/types/core/src/components/icon.d.ts +1 -1
- package/dist/types/core/src/components/image.d.ts +8 -4
- package/dist/types/core/src/components/layout.d.ts +5 -4
- package/dist/types/core/src/components/pressable.d.ts +3 -3
- package/dist/types/core/src/components/rich-content.d.ts +1 -1
- package/dist/types/core/src/components/scroll.d.ts +2 -2
- package/dist/types/core/src/components/svg.d.ts +1 -1
- package/dist/types/core/src/components/titlebar.d.ts +15 -1
- package/dist/types/core/src/components/window.d.ts +21 -1
- package/dist/types/core/src/components.d.ts +2 -0
- package/dist/types/core/src/css-shadow.d.ts +1 -1
- package/dist/types/core/src/desktop-controls.d.ts +2 -2
- package/dist/types/core/src/embedded-assets.d.ts +3 -2
- package/dist/types/core/src/extra-controls.d.ts +2 -2
- package/dist/types/core/src/form-controls.d.ts +1 -1
- package/dist/types/core/src/html-elements.d.ts +26 -0
- package/dist/types/core/src/index.d.ts +23 -11
- package/dist/types/core/src/inline-text.d.ts +25 -0
- package/dist/types/core/src/intrinsic-style.d.ts +1 -1
- package/dist/types/core/src/jsx-runtime.d.ts +182 -5
- package/dist/types/core/src/media-element.d.ts +70 -0
- package/dist/types/core/src/memo.d.ts +28 -0
- package/dist/types/core/src/motion.d.ts +1 -1
- package/dist/types/core/src/png.d.ts +29 -0
- package/dist/types/core/src/popups.d.ts +4 -3
- package/dist/types/core/src/protocol.d.ts +6 -0
- package/dist/types/core/src/reconciler/diff.d.ts +11 -0
- package/dist/types/core/src/reconciler/intrinsics.d.ts +24 -0
- package/dist/types/core/src/reconciler.d.ts +33 -10
- package/dist/types/core/src/render-scope.d.ts +8 -0
- package/dist/types/core/src/style.d.ts +1 -1
- package/dist/types/core/src/tailwind-palette.d.ts +1 -0
- package/dist/types/core/src/tailwind.d.ts +8 -0
- package/dist/types/core/src/test-renderer.d.ts +3 -1
- package/dist/types/core/src/text-search.d.ts +1 -1
- package/dist/types/core/src/theme.d.ts +10 -2
- package/dist/types/core/src/updates.d.ts +87 -0
- package/dist/types/core/src/virtual-list.d.ts +8 -2
- package/dist/types/core/txiki/fetch.d.ts +1 -0
- package/dist/types/core/txiki/intl-data.d.ts +6 -0
- package/dist/types/core/txiki/intl.d.ts +92 -0
- package/dist/types/core/txiki/prelude.d.ts +1 -0
- package/dist/types/core/txiki/runtime.d.ts +2 -0
- package/dist/types/core/txiki/shims/buffer.d.ts +37 -0
- package/dist/types/core/txiki/shims/child-process.d.ts +46 -0
- package/dist/types/core/txiki/shims/crypto.d.ts +16 -0
- package/dist/types/core/txiki/shims/events.d.ts +21 -0
- package/dist/types/core/txiki/shims/fs-promises.d.ts +41 -0
- package/dist/types/core/txiki/shims/fs.d.ts +44 -0
- package/dist/types/core/txiki/shims/module.d.ts +5 -0
- package/dist/types/core/txiki/shims/net.d.ts +22 -0
- package/dist/types/core/txiki/shims/os.d.ts +52 -0
- package/dist/types/core/txiki/shims/path.d.ts +3 -0
- package/dist/types/core/txiki/shims/timers-promises.d.ts +7 -0
- package/dist/types/core/txiki/shims/zlib.d.ts +11 -0
- package/dist/types/core/txiki/unavailable.d.ts +5 -0
- package/dist/types/core/txiki-build.d.ts +23 -0
- package/dist/types/core/updates-build.d.ts +35 -0
- package/dist/types/core/windows-executable.d.ts +16 -0
- package/dist/types/protocol/src/index.d.ts +344 -11
- package/native/linux-x64/libtarve_native.so +0 -0
- package/native/linux-x64/runtime.json +4 -4
- package/native/win32-x64/runtime.json +4 -4
- package/native/win32-x64/tarve_native.dll +0 -0
- package/package.json +13 -3
|
@@ -4,16 +4,24 @@ import { createHash, randomUUID } from "crypto";
|
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
5
5
|
import { tmpdir } from "os";
|
|
6
6
|
import { basename, dirname, isAbsolute, join, resolve } from "path";
|
|
7
|
+
import { createRequire } from "module";
|
|
7
8
|
var materialized = new Map;
|
|
8
9
|
function nativeAssetPath(source) {
|
|
9
|
-
|
|
10
|
+
if (/^https?:\/\//i.test(source))
|
|
11
|
+
return source;
|
|
12
|
+
const path = isAbsolute(source) ? source : resolve(sourceRoot(source), source);
|
|
10
13
|
const normalized = path.replaceAll("\\", "/");
|
|
11
14
|
if (normalized.startsWith("/$bunfs/") || /^[a-z]:\/~BUN\//i.test(normalized)) {
|
|
12
15
|
return materializeAsset(path, basename(path));
|
|
13
16
|
}
|
|
17
|
+
if (typeof Bun === "undefined" && path.startsWith(import.meta.dirname + (process.platform === "win32" ? "\\" : "/"))) {
|
|
18
|
+
const { isSea } = createRequire(import.meta.url)("node:sea");
|
|
19
|
+
if (isSea())
|
|
20
|
+
return materializeAsset(path, basename(path));
|
|
21
|
+
}
|
|
14
22
|
return path;
|
|
15
23
|
}
|
|
16
|
-
function materializeAsset(source, filename, digest) {
|
|
24
|
+
function materializeAsset(source, filename, digest, encoding) {
|
|
17
25
|
if (!filename || filename === "." || filename === ".." || basename(filename) !== filename) {
|
|
18
26
|
throw new Error("An embedded asset filename must be a simple filename");
|
|
19
27
|
}
|
|
@@ -28,7 +36,7 @@ function materializeAsset(source, filename, digest) {
|
|
|
28
36
|
return path;
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
|
-
const bytes = readFileSync(source);
|
|
39
|
+
const bytes = encoding === "zstd" ? zstdDecompress(readFileSync(source)) : readFileSync(source);
|
|
32
40
|
const hash = createHash("sha256").update(bytes).digest("hex");
|
|
33
41
|
if (digest && hash !== digest.sha256) {
|
|
34
42
|
throw new Error(`Embedded asset ${filename} does not match its build-time digest; rebuild the executable.`);
|
|
@@ -56,6 +64,11 @@ function materializeAsset(source, filename, digest) {
|
|
|
56
64
|
materialized.set(key, path);
|
|
57
65
|
return path;
|
|
58
66
|
}
|
|
67
|
+
function zstdDecompress(bytes) {
|
|
68
|
+
if (typeof Bun === "undefined")
|
|
69
|
+
throw new Error("A zstd-compressed embedded asset needs the Bun runtime.");
|
|
70
|
+
return Bun.zstdDecompressSync(bytes);
|
|
71
|
+
}
|
|
59
72
|
function sizeOf(path) {
|
|
60
73
|
try {
|
|
61
74
|
return statSync(path).size;
|
|
@@ -63,6 +76,12 @@ function sizeOf(path) {
|
|
|
63
76
|
return;
|
|
64
77
|
}
|
|
65
78
|
}
|
|
79
|
+
function sourceRoot(source) {
|
|
80
|
+
if (typeof Bun !== "undefined")
|
|
81
|
+
return dirname(Bun.main);
|
|
82
|
+
const roots = [import.meta.dirname, process.env.TARVE_ENTRY && dirname(process.env.TARVE_ENTRY), process.argv[1] && dirname(resolve(process.argv[1]))].filter((root) => !!root);
|
|
83
|
+
return roots.find((root) => existsSync(resolve(root, source))) ?? roots[0];
|
|
84
|
+
}
|
|
66
85
|
export {
|
|
67
86
|
materializeAsset,
|
|
68
87
|
nativeAssetPath
|