@tarve/core 0.4.0 → 0.5.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 +80 -1
- package/README.md +67 -10
- package/dist/npm/build.js +823 -83
- package/dist/npm/cli.js +1087 -116
- package/dist/npm/embedded-assets.js +15 -1
- package/dist/npm/index.js +2468 -181
- package/dist/npm/native-runtime.json +3 -3
- package/dist/npm/node-build.js +865 -0
- package/dist/npm/protocol.js +1 -1
- package/dist/npm/runtime.js +5 -5
- package/dist/types/core/app-metadata.d.ts +49 -0
- package/dist/types/core/build.d.ts +21 -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/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/runtime-select.d.ts +8 -0
- package/dist/types/core/src/app-metadata.d.ts +16 -0
- package/dist/types/core/src/app.d.ts +87 -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/canvas.d.ts +161 -0
- package/dist/types/core/src/components/image.d.ts +7 -3
- package/dist/types/core/src/components/layout.d.ts +4 -3
- package/dist/types/core/src/components/pressable.d.ts +2 -2
- package/dist/types/core/src/extra-controls.d.ts +1 -1
- package/dist/types/core/src/html-elements.d.ts +26 -0
- package/dist/types/core/src/index.d.ts +4 -1
- package/dist/types/core/src/inline-text.d.ts +21 -0
- package/dist/types/core/src/jsx-runtime.d.ts +175 -4
- package/dist/types/core/src/media-element.d.ts +71 -0
- package/dist/types/core/src/memo.d.ts +18 -0
- package/dist/types/core/src/png.d.ts +29 -0
- package/dist/types/core/src/popups.d.ts +3 -2
- package/dist/types/core/src/reconciler.d.ts +27 -3
- package/dist/types/core/src/test-renderer.d.ts +2 -0
- package/dist/types/core/src/theme.d.ts +2 -1
- package/dist/types/core/src/virtual-list.d.ts +5 -1
- package/dist/types/core/windows-executable.d.ts +16 -0
- package/dist/types/protocol/src/index.d.ts +187 -5
- 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 +11 -2
|
@@ -4,13 +4,21 @@ 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
24
|
function materializeAsset(source, filename, digest) {
|
|
@@ -63,6 +71,12 @@ function sizeOf(path) {
|
|
|
63
71
|
return;
|
|
64
72
|
}
|
|
65
73
|
}
|
|
74
|
+
function sourceRoot(source) {
|
|
75
|
+
if (typeof Bun !== "undefined")
|
|
76
|
+
return dirname(Bun.main);
|
|
77
|
+
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);
|
|
78
|
+
return roots.find((root) => existsSync(resolve(root, source))) ?? roots[0];
|
|
79
|
+
}
|
|
66
80
|
export {
|
|
67
81
|
materializeAsset,
|
|
68
82
|
nativeAssetPath
|