@patodo/localapp 0.2.1 → 0.2.6
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/.localapp-artifact.json +109 -109
- package/README.md +12 -2
- package/bin/localapp.mjs +645 -184
- package/package.json +1 -1
- package/runtime/native/adapter-manifest.json +10 -10
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +57 -5
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +2 -2
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +57 -5
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +2 -2
- package/runtime/native/linux-x64/localapp-native-ipc-client.mjs +57 -5
- package/runtime/native/linux-x64/localapp-notifications +0 -0
- package/runtime/native/win32-x64/localapp-native-ipc-client.mjs +57 -5
- package/runtime/native/win32-x64/localapp-native.exe +0 -0
- package/runtime/server/.localapp-server-runtime.json +59 -59
- package/runtime/server/bin/worker.cjs +110 -2
- package/runtime/server/web/404.html +1 -1
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/page-3252f21360e42fa1.js +1 -0
- package/runtime/server/web/_next/static/css/b8973d29c0d3fd9b.css +3 -0
- package/runtime/server/web/inbox.html +1 -1
- package/runtime/server/web/inbox.txt +2 -2
- package/runtime/server/web/index.html +1 -1
- package/runtime/server/web/index.txt +3 -3
- package/runtime/server/web/my/analytics.html +1 -1
- package/runtime/server/web/my/analytics.txt +2 -2
- package/runtime/server/web/my/apps/placeholder/settings.html +1 -1
- package/runtime/server/web/my/apps/placeholder/settings.txt +2 -2
- package/runtime/server/web/my/apps.html +1 -1
- package/runtime/server/web/my/apps.txt +2 -2
- package/runtime/server/web/my/dashboard.html +1 -1
- package/runtime/server/web/my/dashboard.txt +2 -2
- package/runtime/server/web/my/device-actions.html +1 -1
- package/runtime/server/web/my/device-actions.txt +2 -2
- package/runtime/server/web/my/device-notifications.html +1 -1
- package/runtime/server/web/my/device-notifications.txt +2 -2
- package/runtime/server/web/my/favorites.html +1 -1
- package/runtime/server/web/my/favorites.txt +2 -2
- package/runtime/server/web/my/groups.html +1 -1
- package/runtime/server/web/my/groups.txt +2 -2
- package/runtime/server/web/my/info.html +1 -1
- package/runtime/server/web/my/info.txt +2 -2
- package/runtime/server/web/my/keys.html +1 -1
- package/runtime/server/web/my/keys.txt +2 -2
- package/runtime/server/web/my/orgs.html +1 -1
- package/runtime/server/web/my/orgs.txt +2 -2
- package/runtime/server/web/my/pages.html +1 -1
- package/runtime/server/web/my/pages.txt +2 -2
- package/runtime/server/web/my/peers.html +1 -1
- package/runtime/server/web/my/peers.txt +2 -2
- package/runtime/server/web/my/recent.html +1 -1
- package/runtime/server/web/my/recent.txt +2 -2
- package/runtime/server/web/my/settings.html +1 -1
- package/runtime/server/web/my/settings.txt +2 -2
- package/runtime/server/web/my/studio.html +1 -1
- package/runtime/server/web/my/studio.txt +2 -2
- package/runtime/server/web/my/subscriptions.html +1 -1
- package/runtime/server/web/my/subscriptions.txt +2 -2
- package/runtime/server/web/my/system.html +1 -1
- package/runtime/server/web/my/system.txt +2 -2
- package/runtime/server/web/my/tasks.html +1 -1
- package/runtime/server/web/my/tasks.txt +2 -2
- package/runtime/server/web/my/users.html +1 -1
- package/runtime/server/web/my/users.txt +2 -2
- package/runtime/server/web/my.html +1 -1
- package/runtime/server/web/my.txt +2 -2
- package/runtime/server/web/platform-shell/placeholder/placeholder.html +1 -1
- package/runtime/server/web/platform-shell/placeholder/placeholder.txt +2 -2
- package/runtime/server/web/platform-shell-preview.html +1 -1
- package/runtime/server/web/platform-shell-preview.txt +2 -2
- package/runtime/server/web/setup.html +1 -1
- package/runtime/server/web/setup.txt +2 -2
- package/template/runtime/version.json +1 -1
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/page-f4641be7b88818a2.js +0 -1
- package/runtime/server/web/_next/static/css/7618766dbe836b27.css +0 -3
- /package/runtime/server/web/_next/static/{GyUKT-hZbRN2iexOBXTTr → qBns-ZRUDtxsd4XX5SLLK}/_buildManifest.js +0 -0
- /package/runtime/server/web/_next/static/{GyUKT-hZbRN2iexOBXTTr → qBns-ZRUDtxsd4XX5SLLK}/_ssgManifest.js +0 -0
package/bin/localapp.mjs
CHANGED
|
@@ -552,9 +552,9 @@ var require_yauzl = __commonJS({
|
|
|
552
552
|
exports.Entry = Entry;
|
|
553
553
|
exports.LocalFileHeader = LocalFileHeader;
|
|
554
554
|
exports.RandomAccessReader = RandomAccessReader;
|
|
555
|
-
function openPromise(
|
|
555
|
+
function openPromise(path35, options2) {
|
|
556
556
|
return new Promise((resolve2, reject) => {
|
|
557
|
-
open2(
|
|
557
|
+
open2(path35, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
558
558
|
if (err) return reject(err);
|
|
559
559
|
resolve2(zipfile);
|
|
560
560
|
});
|
|
@@ -584,7 +584,7 @@ var require_yauzl = __commonJS({
|
|
|
584
584
|
});
|
|
585
585
|
});
|
|
586
586
|
}
|
|
587
|
-
function open2(
|
|
587
|
+
function open2(path35, options2, callback) {
|
|
588
588
|
if (typeof options2 === "function") {
|
|
589
589
|
callback = options2;
|
|
590
590
|
options2 = null;
|
|
@@ -596,7 +596,7 @@ var require_yauzl = __commonJS({
|
|
|
596
596
|
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
597
597
|
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
598
598
|
if (callback == null) callback = defaultCallback;
|
|
599
|
-
fs30.open(
|
|
599
|
+
fs30.open(path35, "r", function(err, fd) {
|
|
600
600
|
if (err) return callback(err);
|
|
601
601
|
fromFd(fd, options2, function(err2, zipfile) {
|
|
602
602
|
if (err2) fs30.close(fd, defaultCallback);
|
|
@@ -3288,13 +3288,13 @@ function getStat(file, followSymlinks) {
|
|
|
3288
3288
|
});
|
|
3289
3289
|
});
|
|
3290
3290
|
}
|
|
3291
|
-
async function* exploreWalkAsync(dir,
|
|
3292
|
-
let files = await readdir2(
|
|
3291
|
+
async function* exploreWalkAsync(dir, path35, followSymlinks, useStat, shouldSkip, strict) {
|
|
3292
|
+
let files = await readdir2(path35 + dir, strict);
|
|
3293
3293
|
for (const file of files) {
|
|
3294
3294
|
let name = file.name;
|
|
3295
3295
|
const filename = dir + "/" + name;
|
|
3296
3296
|
const relative = filename.slice(1);
|
|
3297
|
-
const absolute =
|
|
3297
|
+
const absolute = path35 + "/" + relative;
|
|
3298
3298
|
let stat2 = file;
|
|
3299
3299
|
if (useStat || followSymlinks) stat2 = await getStat(absolute, followSymlinks) ?? stat2;
|
|
3300
3300
|
if (stat2.isDirectory()) {
|
|
@@ -3304,7 +3304,7 @@ async function* exploreWalkAsync(dir, path34, followSymlinks, useStat, shouldSki
|
|
|
3304
3304
|
absolute,
|
|
3305
3305
|
stat: stat2
|
|
3306
3306
|
};
|
|
3307
|
-
yield* exploreWalkAsync(filename,
|
|
3307
|
+
yield* exploreWalkAsync(filename, path35, followSymlinks, useStat, shouldSkip, false);
|
|
3308
3308
|
}
|
|
3309
3309
|
} else yield {
|
|
3310
3310
|
relative,
|
|
@@ -3313,8 +3313,8 @@ async function* exploreWalkAsync(dir, path34, followSymlinks, useStat, shouldSki
|
|
|
3313
3313
|
};
|
|
3314
3314
|
}
|
|
3315
3315
|
}
|
|
3316
|
-
async function* explore(
|
|
3317
|
-
yield* exploreWalkAsync("",
|
|
3316
|
+
async function* explore(path35, followSymlinks, useStat, shouldSkip) {
|
|
3317
|
+
yield* exploreWalkAsync("", path35, followSymlinks, useStat, shouldSkip, true);
|
|
3318
3318
|
}
|
|
3319
3319
|
function readOptions(options2) {
|
|
3320
3320
|
return {
|
|
@@ -13799,22 +13799,22 @@ var require_ours = __commonJS({
|
|
|
13799
13799
|
// node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js
|
|
13800
13800
|
var require_normalize_path = __commonJS({
|
|
13801
13801
|
"node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js"(exports, module) {
|
|
13802
|
-
module.exports = function(
|
|
13803
|
-
if (typeof
|
|
13802
|
+
module.exports = function(path35, stripTrailing) {
|
|
13803
|
+
if (typeof path35 !== "string") {
|
|
13804
13804
|
throw new TypeError("expected path to be a string");
|
|
13805
13805
|
}
|
|
13806
|
-
if (
|
|
13807
|
-
var len =
|
|
13808
|
-
if (len <= 1) return
|
|
13806
|
+
if (path35 === "\\" || path35 === "/") return "/";
|
|
13807
|
+
var len = path35.length;
|
|
13808
|
+
if (len <= 1) return path35;
|
|
13809
13809
|
var prefix = "";
|
|
13810
|
-
if (len > 4 &&
|
|
13811
|
-
var ch =
|
|
13812
|
-
if ((ch === "?" || ch === ".") &&
|
|
13813
|
-
|
|
13810
|
+
if (len > 4 && path35[3] === "\\") {
|
|
13811
|
+
var ch = path35[2];
|
|
13812
|
+
if ((ch === "?" || ch === ".") && path35.slice(0, 2) === "\\\\") {
|
|
13813
|
+
path35 = path35.slice(2);
|
|
13814
13814
|
prefix = "//";
|
|
13815
13815
|
}
|
|
13816
13816
|
}
|
|
13817
|
-
var segs =
|
|
13817
|
+
var segs = path35.split(/[/\\]+/);
|
|
13818
13818
|
if (stripTrailing !== false && segs[segs.length - 1] === "") {
|
|
13819
13819
|
segs.pop();
|
|
13820
13820
|
}
|
|
@@ -24809,6 +24809,309 @@ var require_websocket_server = __commonJS({
|
|
|
24809
24809
|
}
|
|
24810
24810
|
});
|
|
24811
24811
|
|
|
24812
|
+
// packages/localapp/src/cli/help.ts
|
|
24813
|
+
var TOPICS = /* @__PURE__ */ new Map([
|
|
24814
|
+
["", "root"],
|
|
24815
|
+
["server", "server"],
|
|
24816
|
+
["server start", "server-start"],
|
|
24817
|
+
["server run", "server-run"],
|
|
24818
|
+
["server stop", "server-stop"],
|
|
24819
|
+
["server restart", "server-restart"],
|
|
24820
|
+
["server status", "server-status"],
|
|
24821
|
+
["server logs", "server-logs"],
|
|
24822
|
+
["server uninstall", "server-uninstall"],
|
|
24823
|
+
["init", "init"],
|
|
24824
|
+
["check", "check"],
|
|
24825
|
+
["build", "build"],
|
|
24826
|
+
["login", "login"],
|
|
24827
|
+
["logout", "logout"],
|
|
24828
|
+
["whoami", "whoami"],
|
|
24829
|
+
["app", "app"],
|
|
24830
|
+
["app install", "app-install"],
|
|
24831
|
+
["app sync", "app-sync"],
|
|
24832
|
+
["dev", "dev"],
|
|
24833
|
+
["sync-template", "sync-template"],
|
|
24834
|
+
["eject-template", "eject-template"],
|
|
24835
|
+
["version", "version"]
|
|
24836
|
+
]);
|
|
24837
|
+
var HELP = /* @__PURE__ */ new Map([
|
|
24838
|
+
["root", `LocalApp \u2014 run, develop, install, and synchronize LocalApp applications.
|
|
24839
|
+
|
|
24840
|
+
Usage:
|
|
24841
|
+
localapp <command> [options]
|
|
24842
|
+
localapp help [command [subcommand]]
|
|
24843
|
+
|
|
24844
|
+
Commands:
|
|
24845
|
+
server [start] Install system integration and start the user daemon
|
|
24846
|
+
server run Run the same Server in the foreground
|
|
24847
|
+
server <action> stop, restart, status, logs, or uninstall the daemon
|
|
24848
|
+
init [name] Create an application from the built-in template
|
|
24849
|
+
dev Start the application development environment
|
|
24850
|
+
check Validate the current application before installation
|
|
24851
|
+
build --package Build a distributable .localapp package
|
|
24852
|
+
app install Install the current application on a target Server
|
|
24853
|
+
app sync Synchronize an application to a configured peer
|
|
24854
|
+
login [url] Save credentials for a Server profile
|
|
24855
|
+
logout Remove credentials for a Server profile
|
|
24856
|
+
whoami Show the authenticated user for a Server profile
|
|
24857
|
+
sync-template Update the CLI-managed application runtime and skills
|
|
24858
|
+
eject-template Stop CLI management of the application template
|
|
24859
|
+
version Print the installed LocalApp version
|
|
24860
|
+
|
|
24861
|
+
Global options:
|
|
24862
|
+
-h, --help Show help for a command
|
|
24863
|
+
-V, --version Print the installed LocalApp version
|
|
24864
|
+
|
|
24865
|
+
Examples:
|
|
24866
|
+
localapp server
|
|
24867
|
+
localapp init interview-app
|
|
24868
|
+
localapp dev
|
|
24869
|
+
localapp app install --target local
|
|
24870
|
+
localapp help app sync
|
|
24871
|
+
|
|
24872
|
+
Run 'localapp help <command>' or 'localapp <command> --help' for details.
|
|
24873
|
+
`],
|
|
24874
|
+
["server", `Manage the current user's unified LocalApp Server daemon.
|
|
24875
|
+
|
|
24876
|
+
Usage:
|
|
24877
|
+
localapp server [start]
|
|
24878
|
+
localapp server <action>
|
|
24879
|
+
|
|
24880
|
+
Actions:
|
|
24881
|
+
start Install localapp:// integration and start the daemon (default)
|
|
24882
|
+
run Run the same Server in the foreground
|
|
24883
|
+
stop Stop the daemon
|
|
24884
|
+
restart Restart the daemon
|
|
24885
|
+
status Print daemon and Server health information
|
|
24886
|
+
logs Print daemon logs
|
|
24887
|
+
uninstall Stop and unregister the current-user service
|
|
24888
|
+
|
|
24889
|
+
Options:
|
|
24890
|
+
-h, --help Show this help
|
|
24891
|
+
|
|
24892
|
+
Examples:
|
|
24893
|
+
localapp server
|
|
24894
|
+
localapp server status
|
|
24895
|
+
localapp server logs
|
|
24896
|
+
localapp server run --host 0.0.0.0 --port 3000
|
|
24897
|
+
|
|
24898
|
+
Run 'localapp help server <action>' for action-specific help.
|
|
24899
|
+
`],
|
|
24900
|
+
["server-start", noOptionsHelp(
|
|
24901
|
+
"Install localapp:// integration and start the current-user daemon.",
|
|
24902
|
+
"localapp server [start]",
|
|
24903
|
+
["localapp server", "localapp server start"]
|
|
24904
|
+
)],
|
|
24905
|
+
["server-run", `Run the unified LocalApp Server in the foreground.
|
|
24906
|
+
|
|
24907
|
+
Usage:
|
|
24908
|
+
localapp server run [options]
|
|
24909
|
+
|
|
24910
|
+
Options:
|
|
24911
|
+
--data-dir <path> Server database, files, and configuration directory
|
|
24912
|
+
--host <address> Listen address (default: 127.0.0.1)
|
|
24913
|
+
--port <number> Listen port, 0 selects an available port (default: 0)
|
|
24914
|
+
-h, --help Show this help
|
|
24915
|
+
|
|
24916
|
+
Examples:
|
|
24917
|
+
localapp server run
|
|
24918
|
+
localapp server run --data-dir ./localapp-data --port 3000
|
|
24919
|
+
localapp server run --host 0.0.0.0 --port 3000
|
|
24920
|
+
`],
|
|
24921
|
+
["server-stop", noOptionsHelp("Stop the current-user LocalApp daemon.", "localapp server stop", ["localapp server stop"])],
|
|
24922
|
+
["server-restart", noOptionsHelp("Restart the current-user LocalApp daemon.", "localapp server restart", ["localapp server restart"])],
|
|
24923
|
+
["server-status", noOptionsHelp("Print daemon status and Server health information as JSON.", "localapp server status", ["localapp server status"])],
|
|
24924
|
+
["server-logs", noOptionsHelp("Print logs from the current-user LocalApp daemon.", "localapp server logs", ["localapp server logs"])],
|
|
24925
|
+
["server-uninstall", noOptionsHelp("Stop and unregister the current-user LocalApp service.", "localapp server uninstall", ["localapp server uninstall"])],
|
|
24926
|
+
["init", `Create or initialize an application from the built-in template.
|
|
24927
|
+
|
|
24928
|
+
Usage:
|
|
24929
|
+
localapp init [name] [options]
|
|
24930
|
+
|
|
24931
|
+
Arguments:
|
|
24932
|
+
name Project name (default: current directory name)
|
|
24933
|
+
|
|
24934
|
+
Options:
|
|
24935
|
+
--skip-install Do not install template dependencies
|
|
24936
|
+
--skip-deploy Do not install the new application on a Server
|
|
24937
|
+
-h, --help Show this help
|
|
24938
|
+
|
|
24939
|
+
Examples:
|
|
24940
|
+
localapp init interview-app
|
|
24941
|
+
localapp init --skip-install --skip-deploy
|
|
24942
|
+
`],
|
|
24943
|
+
["check", `Validate the current application, contracts, migrations, and package metadata.
|
|
24944
|
+
|
|
24945
|
+
Usage:
|
|
24946
|
+
localapp check [options]
|
|
24947
|
+
|
|
24948
|
+
Options:
|
|
24949
|
+
--json Emit machine-readable JSON
|
|
24950
|
+
--profile <name> Use the named Server profile
|
|
24951
|
+
-h, --help Show this help
|
|
24952
|
+
|
|
24953
|
+
Examples:
|
|
24954
|
+
localapp check
|
|
24955
|
+
localapp check --json
|
|
24956
|
+
`],
|
|
24957
|
+
["build", `Build the current application as a distributable .localapp package.
|
|
24958
|
+
|
|
24959
|
+
Usage:
|
|
24960
|
+
localapp build --package [options]
|
|
24961
|
+
|
|
24962
|
+
Options:
|
|
24963
|
+
--package Required package-build mode
|
|
24964
|
+
--output <path> Output file or directory
|
|
24965
|
+
-h, --help Show this help
|
|
24966
|
+
|
|
24967
|
+
Examples:
|
|
24968
|
+
localapp build --package
|
|
24969
|
+
localapp build --package --output ./dist
|
|
24970
|
+
`],
|
|
24971
|
+
["login", `Save an API key for a LocalApp Server profile.
|
|
24972
|
+
|
|
24973
|
+
Usage:
|
|
24974
|
+
localapp login [server-url] [options]
|
|
24975
|
+
|
|
24976
|
+
Arguments:
|
|
24977
|
+
server-url Target LocalApp Server URL
|
|
24978
|
+
|
|
24979
|
+
Options:
|
|
24980
|
+
--api-key <key> API key issued by the target Server
|
|
24981
|
+
--profile <name> Save under the named profile
|
|
24982
|
+
-h, --help Show this help
|
|
24983
|
+
|
|
24984
|
+
Example:
|
|
24985
|
+
localapp login http://192.168.2.9:3000 --profile office --api-key <key>
|
|
24986
|
+
`],
|
|
24987
|
+
["logout", profileHelp("Remove saved credentials for a LocalApp Server profile.", "logout")],
|
|
24988
|
+
["whoami", profileHelp("Show the authenticated identity for a LocalApp Server profile.", "whoami")],
|
|
24989
|
+
["app", `Install or synchronize LocalApp applications.
|
|
24990
|
+
|
|
24991
|
+
Usage:
|
|
24992
|
+
localapp app <command> [options]
|
|
24993
|
+
|
|
24994
|
+
Commands:
|
|
24995
|
+
install Build or read a .localapp package and install it on a Server
|
|
24996
|
+
sync Synchronize an installed application to a configured peer
|
|
24997
|
+
|
|
24998
|
+
Options:
|
|
24999
|
+
-h, --help Show this help
|
|
25000
|
+
|
|
25001
|
+
Examples:
|
|
25002
|
+
localapp app install --target local
|
|
25003
|
+
localapp app sync --peer office
|
|
25004
|
+
|
|
25005
|
+
Run 'localapp help app <command>' for command-specific help.
|
|
25006
|
+
`],
|
|
25007
|
+
["app-install", `Install the current project or an existing .localapp package.
|
|
25008
|
+
|
|
25009
|
+
Usage:
|
|
25010
|
+
localapp app install [options]
|
|
25011
|
+
|
|
25012
|
+
Options:
|
|
25013
|
+
--target <name> Server profile or explicit target (default: project target)
|
|
25014
|
+
--package <path> Install an existing .localapp package instead of building
|
|
25015
|
+
-h, --help Show this help
|
|
25016
|
+
|
|
25017
|
+
Examples:
|
|
25018
|
+
localapp app install --target local
|
|
25019
|
+
localapp app install --target office --package ./dist/notes.localapp
|
|
25020
|
+
`],
|
|
25021
|
+
["app-sync", `Synchronize an installed application to a configured peer Server.
|
|
25022
|
+
|
|
25023
|
+
Usage:
|
|
25024
|
+
localapp app sync --peer <name> [options]
|
|
25025
|
+
|
|
25026
|
+
Options:
|
|
25027
|
+
--peer <name> Required destination peer configured on the source Server
|
|
25028
|
+
--target <name> Source Server profile (default: project target)
|
|
25029
|
+
--with-data Also replace the destination application data and files
|
|
25030
|
+
--confirm-app <name> Exact application name required with --with-data
|
|
25031
|
+
-h, --help Show this help
|
|
25032
|
+
|
|
25033
|
+
By default only the application package, manifest, migrations, and backend
|
|
25034
|
+
contract are synchronized. --with-data first backs up the destination, then
|
|
25035
|
+
atomically replaces that application's database and files.
|
|
25036
|
+
|
|
25037
|
+
Examples:
|
|
25038
|
+
localapp app sync --peer office
|
|
25039
|
+
localapp app sync --peer office --with-data --confirm-app notes
|
|
25040
|
+
`],
|
|
25041
|
+
["dev", noOptionsHelp(
|
|
25042
|
+
"Start the local application development environment and Dev Shell.",
|
|
25043
|
+
"localapp dev",
|
|
25044
|
+
["localapp dev"]
|
|
25045
|
+
)],
|
|
25046
|
+
["sync-template", `Update CLI-managed runtime files and Agent skills in the current project.
|
|
25047
|
+
|
|
25048
|
+
Usage:
|
|
25049
|
+
localapp sync-template [options]
|
|
25050
|
+
|
|
25051
|
+
Options:
|
|
25052
|
+
--quiet Suppress the success result
|
|
25053
|
+
-h, --help Show this help
|
|
25054
|
+
|
|
25055
|
+
Example:
|
|
25056
|
+
localapp sync-template
|
|
25057
|
+
`],
|
|
25058
|
+
["eject-template", noOptionsHelp(
|
|
25059
|
+
"Stop CLI management of the current project's template files. This is irreversible.",
|
|
25060
|
+
"localapp eject-template",
|
|
25061
|
+
["localapp eject-template"]
|
|
25062
|
+
)],
|
|
25063
|
+
["version", `Print the installed LocalApp version.
|
|
25064
|
+
|
|
25065
|
+
Usage:
|
|
25066
|
+
localapp version
|
|
25067
|
+
localapp --version
|
|
25068
|
+
localapp -V
|
|
25069
|
+
`]
|
|
25070
|
+
]);
|
|
25071
|
+
function resolveHelpTopic(path35) {
|
|
25072
|
+
return TOPICS.get(path35.join(" "));
|
|
25073
|
+
}
|
|
25074
|
+
function renderHelp(topic) {
|
|
25075
|
+
const help2 = HELP.get(topic);
|
|
25076
|
+
if (help2 === void 0) throw new Error(`Missing LocalApp help topic: ${topic}`);
|
|
25077
|
+
return help2;
|
|
25078
|
+
}
|
|
25079
|
+
function helpHint(argv) {
|
|
25080
|
+
const parent = argv[0] === "server" || argv[0] === "app" ? argv[0] : void 0;
|
|
25081
|
+
const commandPath = parent !== void 0 ? argv.slice(0, 2).filter((value2) => value2 !== void 0 && !value2.startsWith("-")) : argv.slice(0, 1).filter((value2) => !value2.startsWith("-"));
|
|
25082
|
+
const topic = resolveHelpTopic(commandPath);
|
|
25083
|
+
if (topic === void 0 && parent !== void 0) return `Run 'localapp ${parent} --help' for usage.`;
|
|
25084
|
+
if (topic === void 0 || topic === "root") return "Run 'localapp --help' for usage.";
|
|
25085
|
+
return `Run 'localapp ${commandPath.join(" ")} --help' for usage.`;
|
|
25086
|
+
}
|
|
25087
|
+
function noOptionsHelp(description, usage, examples) {
|
|
25088
|
+
return `${description}
|
|
25089
|
+
|
|
25090
|
+
Usage:
|
|
25091
|
+
${usage}
|
|
25092
|
+
|
|
25093
|
+
Options:
|
|
25094
|
+
-h, --help Show this help
|
|
25095
|
+
|
|
25096
|
+
${examples.length === 1 ? "Example" : "Examples"}:
|
|
25097
|
+
${examples.map((example) => ` ${example}`).join("\n")}
|
|
25098
|
+
`;
|
|
25099
|
+
}
|
|
25100
|
+
function profileHelp(description, command) {
|
|
25101
|
+
return `${description}
|
|
25102
|
+
|
|
25103
|
+
Usage:
|
|
25104
|
+
localapp ${command} [options]
|
|
25105
|
+
|
|
25106
|
+
Options:
|
|
25107
|
+
--profile <name> Use the named Server profile
|
|
25108
|
+
-h, --help Show this help
|
|
25109
|
+
|
|
25110
|
+
Example:
|
|
25111
|
+
localapp ${command} --profile office
|
|
25112
|
+
`;
|
|
25113
|
+
}
|
|
25114
|
+
|
|
24812
25115
|
// packages/localapp/src/cli/args.ts
|
|
24813
25116
|
var LocalAppArgumentError = class extends Error {
|
|
24814
25117
|
constructor(message, option) {
|
|
@@ -24822,11 +25125,14 @@ var LocalAppArgumentError = class extends Error {
|
|
|
24822
25125
|
function parseLocalAppArgs(argv) {
|
|
24823
25126
|
const args = [...argv];
|
|
24824
25127
|
const command = args.shift();
|
|
24825
|
-
if (command === void 0
|
|
25128
|
+
if (command === void 0) return help("root");
|
|
25129
|
+
if (command === "help") return parseHelp(args);
|
|
25130
|
+
if (command === "--help" || command === "-h") {
|
|
24826
25131
|
requireNoArguments(args);
|
|
24827
|
-
return
|
|
25132
|
+
return help("root");
|
|
24828
25133
|
}
|
|
24829
25134
|
if (command === "version" || command === "--version" || command === "-V") {
|
|
25135
|
+
if (hasHelp(args)) return help("version");
|
|
24830
25136
|
requireNoArguments(args);
|
|
24831
25137
|
return { kind: "version" };
|
|
24832
25138
|
}
|
|
@@ -24834,25 +25140,27 @@ function parseLocalAppArgs(argv) {
|
|
|
24834
25140
|
case "server":
|
|
24835
25141
|
return parseServer(args);
|
|
24836
25142
|
case "init":
|
|
24837
|
-
return parseInit(args);
|
|
25143
|
+
return hasHelp(args) ? help("init") : parseInit(args);
|
|
24838
25144
|
case "check":
|
|
24839
|
-
return parseCheck(args);
|
|
25145
|
+
return hasHelp(args) ? help("check") : parseCheck(args);
|
|
24840
25146
|
case "build":
|
|
24841
|
-
return parseBuild(args);
|
|
25147
|
+
return hasHelp(args) ? help("build") : parseBuild(args);
|
|
24842
25148
|
case "login":
|
|
24843
|
-
return parseLogin(args);
|
|
25149
|
+
return hasHelp(args) ? help("login") : parseLogin(args);
|
|
24844
25150
|
case "logout":
|
|
24845
|
-
return parseProfileCommand(args, "logout");
|
|
25151
|
+
return hasHelp(args) ? help("logout") : parseProfileCommand(args, "logout");
|
|
24846
25152
|
case "whoami":
|
|
24847
|
-
return parseProfileCommand(args, "whoami");
|
|
25153
|
+
return hasHelp(args) ? help("whoami") : parseProfileCommand(args, "whoami");
|
|
24848
25154
|
case "app":
|
|
24849
25155
|
return parseApp(args);
|
|
24850
25156
|
case "dev":
|
|
25157
|
+
if (hasHelp(args)) return help("dev");
|
|
24851
25158
|
requireNoArguments(args);
|
|
24852
25159
|
return { kind: "dev" };
|
|
24853
25160
|
case "sync-template":
|
|
24854
|
-
return parseSyncTemplate(args);
|
|
25161
|
+
return hasHelp(args) ? help("sync-template") : parseSyncTemplate(args);
|
|
24855
25162
|
case "eject-template":
|
|
25163
|
+
if (hasHelp(args)) return help("eject-template");
|
|
24856
25164
|
requireNoArguments(args);
|
|
24857
25165
|
return { kind: "eject-template" };
|
|
24858
25166
|
case "_daemon":
|
|
@@ -24864,11 +25172,14 @@ function parseLocalAppArgs(argv) {
|
|
|
24864
25172
|
}
|
|
24865
25173
|
function parseServer(args) {
|
|
24866
25174
|
const action = args.shift();
|
|
25175
|
+
if (isHelpFlag(action)) return help("server");
|
|
24867
25176
|
if (action === void 0 || action === "start") {
|
|
25177
|
+
if (hasHelp(args)) return help("server-start");
|
|
24868
25178
|
requireNoArguments(args);
|
|
24869
25179
|
return { kind: "server-start" };
|
|
24870
25180
|
}
|
|
24871
25181
|
if (action === "run") {
|
|
25182
|
+
if (hasHelp(args)) return help("server-run");
|
|
24872
25183
|
const options2 = consumeOptions(args, /* @__PURE__ */ new Set(["--data-dir", "--host", "--port"]));
|
|
24873
25184
|
requireNoPositionals(options2);
|
|
24874
25185
|
const port = value(options2, "--port");
|
|
@@ -24880,6 +25191,7 @@ function parseServer(args) {
|
|
|
24880
25191
|
};
|
|
24881
25192
|
}
|
|
24882
25193
|
if (["stop", "restart", "status", "logs", "uninstall"].includes(action)) {
|
|
25194
|
+
if (hasHelp(args)) return help(`server-${action}`);
|
|
24883
25195
|
requireNoArguments(args);
|
|
24884
25196
|
return { kind: "server-control", action };
|
|
24885
25197
|
}
|
|
@@ -24930,7 +25242,9 @@ function parseProfileCommand(args, command) {
|
|
|
24930
25242
|
}
|
|
24931
25243
|
function parseApp(args) {
|
|
24932
25244
|
const command = args.shift();
|
|
25245
|
+
if (isHelpFlag(command)) return help("app");
|
|
24933
25246
|
if (command === "install") {
|
|
25247
|
+
if (hasHelp(args)) return help("app-install");
|
|
24934
25248
|
const options2 = consumeOptions(args, /* @__PURE__ */ new Set(["--target", "--package"]));
|
|
24935
25249
|
requireNoPositionals(options2);
|
|
24936
25250
|
const target = value(options2, "--target");
|
|
@@ -24938,6 +25252,7 @@ function parseApp(args) {
|
|
|
24938
25252
|
return { kind: "app-install", ...target === void 0 ? {} : { target }, ...packagePath === void 0 ? {} : { packagePath } };
|
|
24939
25253
|
}
|
|
24940
25254
|
if (command === "sync") {
|
|
25255
|
+
if (hasHelp(args)) return help("app-sync");
|
|
24941
25256
|
const options2 = consumeOptions(args, /* @__PURE__ */ new Set(["--peer", "--target", "--with-data", "--confirm-app"]), /* @__PURE__ */ new Set(["--with-data"]));
|
|
24942
25257
|
requireNoPositionals(options2);
|
|
24943
25258
|
const peer = value(options2, "--peer");
|
|
@@ -24954,6 +25269,24 @@ function parseApp(args) {
|
|
|
24954
25269
|
}
|
|
24955
25270
|
throw new LocalAppArgumentError(`Unknown app command: ${command ?? ""}`, command);
|
|
24956
25271
|
}
|
|
25272
|
+
function parseHelp(args) {
|
|
25273
|
+
const topicPath = args.filter((argument) => !isHelpFlag(argument));
|
|
25274
|
+
const topic = resolveHelpTopic(topicPath);
|
|
25275
|
+
if (topic === void 0) {
|
|
25276
|
+
const requested = topicPath.join(" ");
|
|
25277
|
+
throw new LocalAppArgumentError(`Unknown help topic: ${requested}`, topicPath[0]);
|
|
25278
|
+
}
|
|
25279
|
+
return help(topic);
|
|
25280
|
+
}
|
|
25281
|
+
function help(topic) {
|
|
25282
|
+
return { kind: "help", topic };
|
|
25283
|
+
}
|
|
25284
|
+
function hasHelp(args) {
|
|
25285
|
+
return args.some(isHelpFlag);
|
|
25286
|
+
}
|
|
25287
|
+
function isHelpFlag(argument) {
|
|
25288
|
+
return argument === "--help" || argument === "-h";
|
|
25289
|
+
}
|
|
24957
25290
|
function parseSyncTemplate(args) {
|
|
24958
25291
|
const options2 = consumeOptions(args, /* @__PURE__ */ new Set(["--quiet"]), /* @__PURE__ */ new Set(["--quiet"]));
|
|
24959
25292
|
requireNoPositionals(options2);
|
|
@@ -25236,9 +25569,9 @@ var LocalAppClient = class {
|
|
|
25236
25569
|
this.setTimeout = dependencies.setTimeout ?? globalThis.setTimeout;
|
|
25237
25570
|
this.clearTimeout = dependencies.clearTimeout ?? globalThis.clearTimeout;
|
|
25238
25571
|
}
|
|
25239
|
-
async requestJson(
|
|
25572
|
+
async requestJson(path35, options2 = {}) {
|
|
25240
25573
|
const body = options2.body === void 0 ? void 0 : JSON.stringify(options2.body);
|
|
25241
|
-
return this.request(
|
|
25574
|
+
return this.request(path35, {
|
|
25242
25575
|
method: options2.method ?? "GET",
|
|
25243
25576
|
body,
|
|
25244
25577
|
timeoutMs: options2.timeoutMs ?? 3e4,
|
|
@@ -25246,11 +25579,11 @@ var LocalAppClient = class {
|
|
|
25246
25579
|
signal: options2.signal
|
|
25247
25580
|
});
|
|
25248
25581
|
}
|
|
25249
|
-
async getJson(
|
|
25250
|
-
return this.requestJson(
|
|
25582
|
+
async getJson(path35, timeoutMs = 3e4) {
|
|
25583
|
+
return this.requestJson(path35, { method: "GET", timeoutMs });
|
|
25251
25584
|
}
|
|
25252
|
-
async postJson(
|
|
25253
|
-
return this.requestJson(
|
|
25585
|
+
async postJson(path35, body, timeoutMs = 3e4) {
|
|
25586
|
+
return this.requestJson(path35, { method: "POST", body, timeoutMs });
|
|
25254
25587
|
}
|
|
25255
25588
|
async installPackage(packagePath, signal) {
|
|
25256
25589
|
const form = new FormData();
|
|
@@ -25263,8 +25596,8 @@ var LocalAppClient = class {
|
|
|
25263
25596
|
async getSyncJob(id) {
|
|
25264
25597
|
return this.getJson(`/api/sync-jobs/${encodeURIComponent(id)}`);
|
|
25265
25598
|
}
|
|
25266
|
-
async request(
|
|
25267
|
-
if (!
|
|
25599
|
+
async request(path35, options2) {
|
|
25600
|
+
if (!path35.startsWith("/") || path35.startsWith("//")) return { ok: false, error: "Request path must be relative to the LocalApp Server" };
|
|
25268
25601
|
const controller = new AbortController();
|
|
25269
25602
|
let timedOut = false;
|
|
25270
25603
|
const timeout2 = this.setTimeout(() => {
|
|
@@ -25276,7 +25609,7 @@ var LocalAppClient = class {
|
|
|
25276
25609
|
if (options2.signal?.aborted) onExternalAbort();
|
|
25277
25610
|
try {
|
|
25278
25611
|
const version = await loadPackageVersion();
|
|
25279
|
-
const response = await fetch(`${this.serverUrl}${
|
|
25612
|
+
const response = await fetch(`${this.serverUrl}${path35}`, {
|
|
25280
25613
|
method: options2.method,
|
|
25281
25614
|
body: options2.body,
|
|
25282
25615
|
headers: { "X-API-Key": this.apiKey, "X-CLI-Version": version, ...options2.headers },
|
|
@@ -26285,9 +26618,9 @@ var MAX_APP_PACKAGE_BYTES = 512 * 1024 * 1024;
|
|
|
26285
26618
|
var METADATA_PATHS = /* @__PURE__ */ new Set(["package.json", "checksums.json"]);
|
|
26286
26619
|
var FIXED_ARCHIVE_DATE = /* @__PURE__ */ new Date("1980-01-01T00:00:00.000Z");
|
|
26287
26620
|
var AppPackageValidationError = class extends Error {
|
|
26288
|
-
constructor(message,
|
|
26621
|
+
constructor(message, path35) {
|
|
26289
26622
|
super(message);
|
|
26290
|
-
this.path =
|
|
26623
|
+
this.path = path35;
|
|
26291
26624
|
this.name = "AppPackageValidationError";
|
|
26292
26625
|
}
|
|
26293
26626
|
path;
|
|
@@ -28160,11 +28493,12 @@ async function detectPackageManager(projectDir, packageJson) {
|
|
|
28160
28493
|
return "npm";
|
|
28161
28494
|
}
|
|
28162
28495
|
async function runProjectCommand(invocation) {
|
|
28163
|
-
const
|
|
28496
|
+
const isWindows = process.platform === "win32";
|
|
28497
|
+
const command = isWindows ? `${invocation.command}.cmd` : invocation.command;
|
|
28164
28498
|
return new Promise((resolve2, reject) => {
|
|
28165
28499
|
const child = spawn2(command, invocation.args, {
|
|
28166
28500
|
cwd: invocation.cwd,
|
|
28167
|
-
shell:
|
|
28501
|
+
shell: isWindows,
|
|
28168
28502
|
stdio: "ignore",
|
|
28169
28503
|
windowsHide: true,
|
|
28170
28504
|
signal: invocation.signal
|
|
@@ -28970,8 +29304,8 @@ import { randomBytes as randomBytes2 } from "node:crypto";
|
|
|
28970
29304
|
import { chmodSync, renameSync } from "node:fs";
|
|
28971
29305
|
import fs18 from "node:fs/promises";
|
|
28972
29306
|
import net from "node:net";
|
|
28973
|
-
import
|
|
28974
|
-
import { fileURLToPath as
|
|
29307
|
+
import path23 from "node:path";
|
|
29308
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
28975
29309
|
|
|
28976
29310
|
// packages/localapp/src/dev/credentials.ts
|
|
28977
29311
|
import { randomBytes } from "node:crypto";
|
|
@@ -29044,9 +29378,28 @@ import { spawn as spawn5 } from "node:child_process";
|
|
|
29044
29378
|
|
|
29045
29379
|
// packages/localapp/src/native/native-adapter.ts
|
|
29046
29380
|
import { spawn as spawn4 } from "node:child_process";
|
|
29381
|
+
import { existsSync } from "node:fs";
|
|
29047
29382
|
import fs17 from "node:fs/promises";
|
|
29048
29383
|
import { homedir as homedir2 } from "node:os";
|
|
29049
|
-
import
|
|
29384
|
+
import path22 from "node:path";
|
|
29385
|
+
|
|
29386
|
+
// packages/localapp/src/artifact-directory.ts
|
|
29387
|
+
import { realpathSync } from "node:fs";
|
|
29388
|
+
import path20 from "node:path";
|
|
29389
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
29390
|
+
function artifactDirectoryFromEntrypoint(entrypoint) {
|
|
29391
|
+
const canonical = realpathSync(entrypoint);
|
|
29392
|
+
return path20.resolve(path20.dirname(canonical), "..");
|
|
29393
|
+
}
|
|
29394
|
+
function localAppArtifactDirectory(entrypoint = process.argv[1]) {
|
|
29395
|
+
if (entrypoint !== void 0 && entrypoint.length > 0) {
|
|
29396
|
+
try {
|
|
29397
|
+
return artifactDirectoryFromEntrypoint(entrypoint);
|
|
29398
|
+
} catch {
|
|
29399
|
+
}
|
|
29400
|
+
}
|
|
29401
|
+
return path20.resolve(path20.dirname(fileURLToPath3(import.meta.url)), "..");
|
|
29402
|
+
}
|
|
29050
29403
|
|
|
29051
29404
|
// packages/server/src/lib/device-action-types.ts
|
|
29052
29405
|
var DEVICE_ACTION_PROTOCOL_VERSION = 2;
|
|
@@ -29172,21 +29525,21 @@ function invalid2() {
|
|
|
29172
29525
|
// packages/localapp/src/native/adapter-selection.ts
|
|
29173
29526
|
import crypto5 from "node:crypto";
|
|
29174
29527
|
import fs16 from "node:fs/promises";
|
|
29175
|
-
import
|
|
29528
|
+
import path21 from "node:path";
|
|
29176
29529
|
async function selectNativeAdapter(options2) {
|
|
29177
29530
|
const platform = options2.platform ?? process.platform;
|
|
29178
29531
|
const arch = options2.arch ?? process.arch;
|
|
29179
29532
|
const target = targetFor(platform, arch);
|
|
29180
|
-
const root =
|
|
29533
|
+
const root = path21.resolve(options2.root);
|
|
29181
29534
|
let value2;
|
|
29182
29535
|
try {
|
|
29183
|
-
value2 = JSON.parse(await fs16.readFile(
|
|
29536
|
+
value2 = JSON.parse(await fs16.readFile(path21.join(root, "adapter-manifest.json"), "utf8"));
|
|
29184
29537
|
} catch {
|
|
29185
29538
|
throw unsupported(platform, arch);
|
|
29186
29539
|
}
|
|
29187
29540
|
const manifest = parseManifest(value2, target, root, platform, arch);
|
|
29188
29541
|
for (const asset of manifest.assets) {
|
|
29189
|
-
const absolute =
|
|
29542
|
+
const absolute = path21.join(root, ...asset.path.split("/"));
|
|
29190
29543
|
let bytes;
|
|
29191
29544
|
try {
|
|
29192
29545
|
const stat2 = await fs16.lstat(absolute);
|
|
@@ -29207,8 +29560,8 @@ async function selectNativeAdapter(options2) {
|
|
|
29207
29560
|
return {
|
|
29208
29561
|
target,
|
|
29209
29562
|
root,
|
|
29210
|
-
executable:
|
|
29211
|
-
ipcClient:
|
|
29563
|
+
executable: path21.join(root, ...executable.split("/")),
|
|
29564
|
+
ipcClient: path21.join(root, ...ipcClient.split("/")),
|
|
29212
29565
|
signing: manifest.signing,
|
|
29213
29566
|
assets: manifest.assets
|
|
29214
29567
|
};
|
|
@@ -29241,7 +29594,7 @@ function parseSingleManifest(value2, target, root, platform, arch) {
|
|
|
29241
29594
|
throw unsupported(platform, arch);
|
|
29242
29595
|
}
|
|
29243
29596
|
const assets = value2.assets.map((asset) => {
|
|
29244
|
-
if (!record(asset) || !exactKeys(asset, ["path", "sha256"]) || typeof asset.path !== "string" || typeof asset.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(asset.sha256) || !safeRelativeAsset(asset.path) || !asset.path.startsWith(`${target}/`) ||
|
|
29597
|
+
if (!record(asset) || !exactKeys(asset, ["path", "sha256"]) || typeof asset.path !== "string" || typeof asset.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(asset.sha256) || !safeRelativeAsset(asset.path) || !asset.path.startsWith(`${target}/`) || path21.resolve(root, ...asset.path.split("/")).startsWith(`${root}${path21.sep}`) === false) {
|
|
29245
29598
|
throw unsupported(platform, arch);
|
|
29246
29599
|
}
|
|
29247
29600
|
return { path: asset.path, sha256: asset.sha256 };
|
|
@@ -29250,7 +29603,7 @@ function parseSingleManifest(value2, target, root, platform, arch) {
|
|
|
29250
29603
|
return { signing: { mode: value2.signing.mode }, assets };
|
|
29251
29604
|
}
|
|
29252
29605
|
function safeRelativeAsset(value2) {
|
|
29253
|
-
return value2.length > 0 && value2.length <= 512 && !value2.includes("\\") && !value2.startsWith("/") && !value2.endsWith("/") &&
|
|
29606
|
+
return value2.length > 0 && value2.length <= 512 && !value2.includes("\\") && !value2.startsWith("/") && !value2.endsWith("/") && path21.posix.normalize(value2) === value2 && value2.split("/").every((part) => part && part !== "." && part !== "..");
|
|
29254
29607
|
}
|
|
29255
29608
|
function record(value2) {
|
|
29256
29609
|
return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
|
|
@@ -29367,9 +29720,9 @@ function validateNativeNotificationEnvelope(value2, platform = process.platform)
|
|
|
29367
29720
|
async function installLinuxScheme(options2) {
|
|
29368
29721
|
if (!safeAbsoluteLocalPath(options2.dataHome, "linux")) throw lifecycleError("native_adapter_invalid", "The Linux data directory is invalid");
|
|
29369
29722
|
const desktop = buildLinuxDesktopEntry(options2.nodePath, options2.ipcClientPath);
|
|
29370
|
-
const applications =
|
|
29723
|
+
const applications = path22.posix.join(options2.dataHome, "applications");
|
|
29371
29724
|
const filename = "localapp.desktop";
|
|
29372
|
-
const destination =
|
|
29725
|
+
const destination = path22.posix.join(applications, filename);
|
|
29373
29726
|
await fs17.mkdir(applications, { recursive: true, mode: 448 });
|
|
29374
29727
|
const current = await fs17.readFile(destination, "utf8").catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
|
|
29375
29728
|
if (current !== desktop) await fs17.writeFile(destination, desktop, { mode: 420 });
|
|
@@ -29401,7 +29754,7 @@ async function writeBridgeConfiguration(options2) {
|
|
|
29401
29754
|
if (options2.environment !== void 0) configuration.environment = options2.environment;
|
|
29402
29755
|
const content = `${JSON.stringify(configuration)}
|
|
29403
29756
|
`;
|
|
29404
|
-
await fs17.mkdir(
|
|
29757
|
+
await fs17.mkdir(path22.dirname(options2.configPath), { recursive: true, mode: 448 });
|
|
29405
29758
|
const current = await fs17.readFile(options2.configPath, "utf8").catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
|
|
29406
29759
|
if (current !== content) await fs17.writeFile(options2.configPath, content, { mode: 384 });
|
|
29407
29760
|
}
|
|
@@ -29417,20 +29770,20 @@ function bridgeRuntimeEnvironment(env, platform) {
|
|
|
29417
29770
|
return Object.keys(environment).length === 0 ? void 0 : environment;
|
|
29418
29771
|
}
|
|
29419
29772
|
function nativeBridgeConfigPath(platform, supportDir, env) {
|
|
29420
|
-
if (supportDir !== void 0) return platform === "win32" ?
|
|
29421
|
-
if (platform === "darwin") return
|
|
29422
|
-
if (platform === "win32") return
|
|
29423
|
-
return
|
|
29773
|
+
if (supportDir !== void 0) return platform === "win32" ? path22.win32.join(supportDir, "native-bridge.json") : path22.join(supportDir, "native-bridge.json");
|
|
29774
|
+
if (platform === "darwin") return path22.join(homedir2(), "Library", "Application Support", "LocalApp", "native-bridge.json");
|
|
29775
|
+
if (platform === "win32") return path22.win32.join(env.LOCALAPPDATA ?? path22.win32.join(homedir2(), "AppData", "Local"), "LocalApp", "native-bridge.json");
|
|
29776
|
+
return path22.join(env.XDG_DATA_HOME ?? path22.join(homedir2(), ".local", "share"), "localapp", "native-bridge.json");
|
|
29424
29777
|
}
|
|
29425
29778
|
function linuxDataHome(env) {
|
|
29426
|
-
return env.XDG_DATA_HOME ??
|
|
29779
|
+
return env.XDG_DATA_HOME ?? path22.join(homedir2(), ".local", "share");
|
|
29427
29780
|
}
|
|
29428
29781
|
function createWindowsProcessTreeAdapter(helper) {
|
|
29429
29782
|
return { spawnOwned: (command, args, options2) => helper.spawn(command, args, options2) };
|
|
29430
29783
|
}
|
|
29431
29784
|
function createWindowsProcessTreeAdapterFromEnvironment() {
|
|
29432
29785
|
if (process.platform !== "win32") return void 0;
|
|
29433
|
-
const executable =
|
|
29786
|
+
const executable = resolveWindowsNativeExecutable();
|
|
29434
29787
|
if (executable === void 0) return void 0;
|
|
29435
29788
|
return createWindowsProcessTreeAdapter({
|
|
29436
29789
|
spawn(command, args, options2) {
|
|
@@ -29445,6 +29798,17 @@ function createWindowsProcessTreeAdapterFromEnvironment() {
|
|
|
29445
29798
|
}
|
|
29446
29799
|
});
|
|
29447
29800
|
}
|
|
29801
|
+
function resolveWindowsNativeExecutable(options2 = {}) {
|
|
29802
|
+
const env = options2.env ?? process.env;
|
|
29803
|
+
const arch = options2.arch ?? process.arch;
|
|
29804
|
+
const roots = [env.LOCALAPP_RELEASE_PATH, options2.artifactDirectory ?? localAppArtifactDirectory()];
|
|
29805
|
+
for (const root of roots) {
|
|
29806
|
+
if (root === void 0 || root.length === 0) continue;
|
|
29807
|
+
const candidate = path22.join(root, "runtime", "native", `win32-${arch}`, "localapp-native.exe");
|
|
29808
|
+
if (existsSync(candidate)) return candidate;
|
|
29809
|
+
}
|
|
29810
|
+
return void 0;
|
|
29811
|
+
}
|
|
29448
29812
|
async function openValidatedExternalUrl(url) {
|
|
29449
29813
|
let parsed;
|
|
29450
29814
|
try {
|
|
@@ -29458,18 +29822,13 @@ async function openValidatedExternalUrl(url) {
|
|
|
29458
29822
|
if (process.platform === "darwin") return waitForChild(spawn4("/usr/bin/open", [url], { shell: false, stdio: "ignore" }));
|
|
29459
29823
|
if (process.platform === "linux") return waitForChild(spawn4("xdg-open", [url], { shell: false, stdio: "ignore" }));
|
|
29460
29824
|
if (process.platform === "win32") {
|
|
29461
|
-
const executable =
|
|
29825
|
+
const executable = resolveWindowsNativeExecutable();
|
|
29462
29826
|
if (executable === void 0) throw lifecycleError("native_adapter_unsupported", "NATIVE_ADAPTER_UNSUPPORTED: the Windows opener is unavailable");
|
|
29463
29827
|
await waitForChild(spawn4(executable, ["--open-url", url], { shell: false, stdio: "ignore", windowsHide: true }));
|
|
29464
29828
|
return;
|
|
29465
29829
|
}
|
|
29466
29830
|
throw unsupported2(process.platform);
|
|
29467
29831
|
}
|
|
29468
|
-
function windowsNativeExecutableFromEnvironment() {
|
|
29469
|
-
const release = process.env.LOCALAPP_RELEASE_PATH;
|
|
29470
|
-
if (!release) return void 0;
|
|
29471
|
-
return path21.join(release, "runtime", "native", `win32-${process.arch}`, "localapp-native.exe");
|
|
29472
|
-
}
|
|
29473
29832
|
async function runCommand(command, args, timeoutMs, environment = process.env) {
|
|
29474
29833
|
const child = spawn4(command, [...args], { shell: false, windowsHide: true, stdio: ["ignore", "pipe", "pipe"], env: environment });
|
|
29475
29834
|
let stdout = "";
|
|
@@ -29605,7 +29964,7 @@ var PackagedLinuxNotificationSession = class {
|
|
|
29605
29964
|
function createPackagedLinuxNotificationSession(selected, nodePath, environment, timeoutMs) {
|
|
29606
29965
|
const relative = `${selected.target}/localapp-notifications`;
|
|
29607
29966
|
if (!selected.assets.some((asset) => asset.path === relative)) return unsupportedLinuxNotificationSession();
|
|
29608
|
-
return new PackagedLinuxNotificationSession(
|
|
29967
|
+
return new PackagedLinuxNotificationSession(path22.join(selected.root, ...relative.split("/")), nodePath, selected.ipcClient, environment, timeoutMs);
|
|
29609
29968
|
}
|
|
29610
29969
|
function readLinuxAccepted(child, timeoutMs) {
|
|
29611
29970
|
return new Promise((resolve2, reject) => {
|
|
@@ -29682,7 +30041,7 @@ function desktopExecQuote(value2) {
|
|
|
29682
30041
|
}
|
|
29683
30042
|
function safeAbsoluteLocalPath(value2, platform) {
|
|
29684
30043
|
if (typeof value2 !== "string" || value2.length === 0 || value2.includes("\0") || /[\r\n]/.test(value2) || /^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(value2)) return false;
|
|
29685
|
-
const pathApi = platform === "win32" ?
|
|
30044
|
+
const pathApi = platform === "win32" ? path22.win32 : path22.posix;
|
|
29686
30045
|
if (!pathApi.isAbsolute(value2) || pathApi.normalize(value2) !== value2) return false;
|
|
29687
30046
|
return !value2.split(/[\\/]/).some((part) => part === "." || part === "..");
|
|
29688
30047
|
}
|
|
@@ -29719,7 +30078,7 @@ function spawnOwnedProcess(command, args, options2 = {}) {
|
|
|
29719
30078
|
if (platform === "win32") {
|
|
29720
30079
|
const windowsAdapter = options2.windowsAdapter ?? createWindowsProcessTreeAdapterFromEnvironment();
|
|
29721
30080
|
if (windowsAdapter === void 0) {
|
|
29722
|
-
throw
|
|
30081
|
+
throw lifecycleError("native_adapter_unsupported", "NATIVE_ADAPTER_UNSUPPORTED: the Windows process-tree adapter is unavailable without the packaged LocalApp native helper");
|
|
29723
30082
|
}
|
|
29724
30083
|
return ownedWindowsProcess(windowsAdapter.spawnOwned(command, args, spawnOptions), options2);
|
|
29725
30084
|
}
|
|
@@ -30212,10 +30571,10 @@ function isRecord9(value2) {
|
|
|
30212
30571
|
// packages/localapp/src/commands/dev.ts
|
|
30213
30572
|
var DEV_USER_ID = "dev-user";
|
|
30214
30573
|
async function runDev(options2, dependencies = {}) {
|
|
30215
|
-
const projectDir =
|
|
30216
|
-
const stateRoot =
|
|
30217
|
-
const dataDir =
|
|
30218
|
-
const packagesDir =
|
|
30574
|
+
const projectDir = path23.resolve(options2.projectDir);
|
|
30575
|
+
const stateRoot = path23.join(projectDir, "tmp/localapp-dev");
|
|
30576
|
+
const dataDir = path23.join(stateRoot, "server");
|
|
30577
|
+
const packagesDir = path23.join(stateRoot, "packages");
|
|
30219
30578
|
const spawnProcess = dependencies.spawnOwnedProcess ?? spawnOwnedProcess;
|
|
30220
30579
|
const lifecycle = new DevLifecycle();
|
|
30221
30580
|
const abort = () => lifecycle.abort();
|
|
@@ -30267,7 +30626,7 @@ async function runDev(options2, dependencies = {}) {
|
|
|
30267
30626
|
const initialize = dependencies.initializeServer ?? initializeServer;
|
|
30268
30627
|
await lifecycle.runPhase((signal) => initialize(ready.listenUrl, ready.setupUrl, credentials.password, signal));
|
|
30269
30628
|
const version = uniqueDevVersion();
|
|
30270
|
-
const packagePath =
|
|
30629
|
+
const packagePath = path23.join(packagesDir, `${manifest.name}-${version}.localapp`);
|
|
30271
30630
|
const build = dependencies.buildApplicationPackage ?? buildApplicationPackage;
|
|
30272
30631
|
const runBuildCommand = createOwnedProjectCommandRunner(lifecycle, spawnProcess, dependencies.windowsAdapter);
|
|
30273
30632
|
const applicationPackage = await lifecycle.runPhase((signal) => build({
|
|
@@ -30525,15 +30884,15 @@ function isErrorCode(value2, code) {
|
|
|
30525
30884
|
}
|
|
30526
30885
|
async function writeDevConfig(options2) {
|
|
30527
30886
|
throwIfAborted(options2.signal);
|
|
30528
|
-
const projectDir =
|
|
30529
|
-
const localAppDir =
|
|
30530
|
-
const stateRoot =
|
|
30887
|
+
const projectDir = path23.resolve(options2.projectDir);
|
|
30888
|
+
const localAppDir = path23.join(projectDir, ".localapp");
|
|
30889
|
+
const stateRoot = path23.join(projectDir, "tmp/localapp-dev");
|
|
30531
30890
|
await Promise.all([
|
|
30532
30891
|
fs18.mkdir(localAppDir, { recursive: true }),
|
|
30533
30892
|
fs18.mkdir(stateRoot, { recursive: true, mode: 448 })
|
|
30534
30893
|
]);
|
|
30535
|
-
const temporary =
|
|
30536
|
-
const destination =
|
|
30894
|
+
const temporary = path23.join(stateRoot, `dev-config.${process.pid}.${randomBytes2(8).toString("hex")}.next`);
|
|
30895
|
+
const destination = path23.join(localAppDir, "dev-config.json");
|
|
30537
30896
|
const value2 = {
|
|
30538
30897
|
serverUrl: options2.serverUrl,
|
|
30539
30898
|
userId: DEV_USER_ID,
|
|
@@ -30555,12 +30914,12 @@ async function writeDevConfig(options2) {
|
|
|
30555
30914
|
}
|
|
30556
30915
|
}
|
|
30557
30916
|
function embeddedServerLauncher() {
|
|
30558
|
-
return
|
|
30917
|
+
return path23.resolve(path23.dirname(fileURLToPath4(import.meta.url)), "../runtime/server/bin/server.mjs");
|
|
30559
30918
|
}
|
|
30560
30919
|
async function readManifest(projectDir) {
|
|
30561
30920
|
let value2;
|
|
30562
30921
|
try {
|
|
30563
|
-
value2 = JSON.parse(await fs18.readFile(
|
|
30922
|
+
value2 = JSON.parse(await fs18.readFile(path23.join(projectDir, "manifest.json"), "utf8"));
|
|
30564
30923
|
} catch {
|
|
30565
30924
|
throw lifecycleError("project_manifest_missing", "No valid manifest.json found. Run 'localapp init' first.");
|
|
30566
30925
|
}
|
|
@@ -30668,9 +31027,7 @@ function isRecord10(value2) {
|
|
|
30668
31027
|
|
|
30669
31028
|
// packages/localapp/src/commands/server.ts
|
|
30670
31029
|
import fs25 from "node:fs/promises";
|
|
30671
|
-
import
|
|
30672
|
-
import path29 from "node:path";
|
|
30673
|
-
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
31030
|
+
import path30 from "node:path";
|
|
30674
31031
|
|
|
30675
31032
|
// packages/localapp/src/daemon/ipc-client.ts
|
|
30676
31033
|
import net2 from "node:net";
|
|
@@ -30936,19 +31293,19 @@ function transportError(error) {
|
|
|
30936
31293
|
import crypto6 from "node:crypto";
|
|
30937
31294
|
import fs19 from "node:fs/promises";
|
|
30938
31295
|
import { constants as fsConstants } from "node:fs";
|
|
30939
|
-
import
|
|
31296
|
+
import path24 from "node:path";
|
|
30940
31297
|
var DIGEST = /^[0-9a-f]{64}$/;
|
|
30941
31298
|
var VERSION = /^[0-9A-Za-z][0-9A-Za-z.+_-]{0,127}$/;
|
|
30942
31299
|
async function verifyReleaseArtifact(directory) {
|
|
30943
|
-
return (await inspectReleaseArtifact(
|
|
31300
|
+
return (await inspectReleaseArtifact(path24.resolve(directory))).manifest;
|
|
30944
31301
|
}
|
|
30945
31302
|
async function publishRelease(options2) {
|
|
30946
|
-
const sourceDirectory =
|
|
31303
|
+
const sourceDirectory = path24.resolve(options2.sourceDirectory);
|
|
30947
31304
|
const inspected = await inspectReleaseArtifact(sourceDirectory);
|
|
30948
31305
|
await ensurePrivateDirectories(options2.layout);
|
|
30949
31306
|
return withReleaseLock(options2.layout, options2.lockTimeoutMs ?? 5e3, async () => {
|
|
30950
31307
|
const releaseName = `${inspected.manifest.version}-${inspected.manifest.artifactDigest}`;
|
|
30951
|
-
const releasePath =
|
|
31308
|
+
const releasePath = path24.join(options2.layout.releasesDir, releaseName);
|
|
30952
31309
|
const existing = await lstatOptional2(releasePath);
|
|
30953
31310
|
if (existing === void 0) {
|
|
30954
31311
|
await publishImmutableDirectory(releasePath, inspected, options2.layout.releasesDir);
|
|
@@ -30964,7 +31321,7 @@ async function publishRelease(options2) {
|
|
|
30964
31321
|
entrypoint: inspected.manifest.entrypoint,
|
|
30965
31322
|
bootstrapEntrypoint: inspected.manifest.bootstrapEntrypoint
|
|
30966
31323
|
};
|
|
30967
|
-
const launcherBytes = await readRegularFile(
|
|
31324
|
+
const launcherBytes = await readRegularFile(path24.join(releasePath, ...inspected.manifest.bootstrapEntrypoint.split("/")));
|
|
30968
31325
|
await ensureStableLauncher(options2.layout.launcherPath, launcherBytes);
|
|
30969
31326
|
await writeAtomic(options2.layout.currentManifestPath, Buffer.from(`${JSON.stringify(current, null, 2)}
|
|
30970
31327
|
`), 384);
|
|
@@ -30981,8 +31338,8 @@ async function readCurrentRelease(layout) {
|
|
|
30981
31338
|
if (!isRecord12(value2) || !hasExactKeys2(value2, ["version", "artifactDigest", "releasePath", "entrypoint", "bootstrapEntrypoint"]) || typeof value2.version !== "string" || !VERSION.test(value2.version) || typeof value2.artifactDigest !== "string" || !DIGEST.test(value2.artifactDigest) || typeof value2.releasePath !== "string" || typeof value2.entrypoint !== "string" || typeof value2.bootstrapEntrypoint !== "string") {
|
|
30982
31339
|
throw lifecycleError("release_current_invalid", "The current LocalApp release manifest is missing or invalid");
|
|
30983
31340
|
}
|
|
30984
|
-
const expectedPath =
|
|
30985
|
-
if (
|
|
31341
|
+
const expectedPath = path24.join(layout.releasesDir, `${value2.version}-${value2.artifactDigest}`);
|
|
31342
|
+
if (path24.resolve(value2.releasePath) !== path24.resolve(expectedPath) || !isSafeRelativeFile(value2.entrypoint) || !isSafeRelativeFile(value2.bootstrapEntrypoint)) {
|
|
30986
31343
|
throw lifecycleError("release_current_invalid", "The current LocalApp release manifest is missing or invalid");
|
|
30987
31344
|
}
|
|
30988
31345
|
return {
|
|
@@ -30997,7 +31354,7 @@ async function inspectReleaseArtifact(directory) {
|
|
|
30997
31354
|
try {
|
|
30998
31355
|
const root = await fs19.lstat(directory);
|
|
30999
31356
|
if (!root.isDirectory() || root.isSymbolicLink()) throw invalidArtifact();
|
|
31000
|
-
const manifestPath =
|
|
31357
|
+
const manifestPath = path24.join(directory, ".localapp-artifact.json");
|
|
31001
31358
|
const manifestBytes = await readRegularFile(manifestPath);
|
|
31002
31359
|
const manifest = parseArtifactManifest(JSON.parse(manifestBytes.toString("utf8")));
|
|
31003
31360
|
const observed = await listArtifactFiles(directory);
|
|
@@ -31007,7 +31364,7 @@ async function inspectReleaseArtifact(directory) {
|
|
|
31007
31364
|
}
|
|
31008
31365
|
const files = /* @__PURE__ */ new Map();
|
|
31009
31366
|
for (const entry of manifest.files) {
|
|
31010
|
-
const bytes = await readRegularFile(
|
|
31367
|
+
const bytes = await readRegularFile(path24.join(directory, ...entry.path.split("/")));
|
|
31011
31368
|
if (bytes.byteLength !== entry.size || sha2563(bytes) !== entry.sha256) throw invalidArtifact();
|
|
31012
31369
|
files.set(entry.path, bytes);
|
|
31013
31370
|
}
|
|
@@ -31140,7 +31497,7 @@ async function listArtifactFiles(root) {
|
|
|
31140
31497
|
if (relativePath2 === ".localapp-artifact.json") continue;
|
|
31141
31498
|
if (!isSafeRelativeFile(relativePath2)) throw invalidArtifact();
|
|
31142
31499
|
if (entry.isSymbolicLink()) throw invalidArtifact();
|
|
31143
|
-
if (entry.isDirectory()) await visit(
|
|
31500
|
+
if (entry.isDirectory()) await visit(path24.join(directory, entry.name), relativePath2);
|
|
31144
31501
|
else if (entry.isFile()) files.add(relativePath2);
|
|
31145
31502
|
else throw invalidArtifact();
|
|
31146
31503
|
}
|
|
@@ -31149,15 +31506,15 @@ async function listArtifactFiles(root) {
|
|
|
31149
31506
|
return files;
|
|
31150
31507
|
}
|
|
31151
31508
|
async function publishImmutableDirectory(releasePath, inspected, releasesDirectory) {
|
|
31152
|
-
const staging = await fs19.mkdtemp(
|
|
31509
|
+
const staging = await fs19.mkdtemp(path24.join(releasesDirectory, ".release-stage-"));
|
|
31153
31510
|
if (process.platform !== "win32") await fs19.chmod(staging, 448);
|
|
31154
31511
|
try {
|
|
31155
31512
|
for (const [relativePath2, bytes] of inspected.files) {
|
|
31156
|
-
const destination =
|
|
31157
|
-
await fs19.mkdir(
|
|
31513
|
+
const destination = path24.join(staging, ...relativePath2.split("/"));
|
|
31514
|
+
await fs19.mkdir(path24.dirname(destination), { recursive: true, mode: 448 });
|
|
31158
31515
|
await fs19.writeFile(destination, bytes, { flag: "wx", mode: isExecutableReleaseFile(relativePath2, inspected.manifest) ? 448 : 384 });
|
|
31159
31516
|
}
|
|
31160
|
-
await fs19.writeFile(
|
|
31517
|
+
await fs19.writeFile(path24.join(staging, ".localapp-artifact.json"), inspected.manifestBytes, { flag: "wx", mode: 384 });
|
|
31161
31518
|
await inspectReleaseArtifact(staging);
|
|
31162
31519
|
try {
|
|
31163
31520
|
await fs19.rename(staging, releasePath);
|
|
@@ -31177,7 +31534,7 @@ function isExecutableReleaseFile(relativePath2, manifest) {
|
|
|
31177
31534
|
async function ensurePrivateDirectories(layout) {
|
|
31178
31535
|
validateRuntimeLayout(layout);
|
|
31179
31536
|
await ensurePrivateDirectory(layout.supportDir);
|
|
31180
|
-
for (const directory of [layout.releasesDir, layout.logsDir,
|
|
31537
|
+
for (const directory of [layout.releasesDir, layout.logsDir, path24.dirname(layout.launcherPath), layout.runtimeDir]) {
|
|
31181
31538
|
await ensurePrivateDirectory(directory);
|
|
31182
31539
|
}
|
|
31183
31540
|
}
|
|
@@ -31200,7 +31557,7 @@ async function withReleaseLock(layout, timeoutMs, operation) {
|
|
|
31200
31557
|
}
|
|
31201
31558
|
}
|
|
31202
31559
|
async function tryCreateReleaseLock(layout) {
|
|
31203
|
-
const temporary =
|
|
31560
|
+
const temporary = path24.join(layout.runtimeDir, `.release-lock.${process.pid}.${crypto6.randomUUID()}.next`);
|
|
31204
31561
|
let handle;
|
|
31205
31562
|
let identity;
|
|
31206
31563
|
let linked = false;
|
|
@@ -31286,14 +31643,14 @@ async function ensurePrivateDirectory(directory) {
|
|
|
31286
31643
|
}
|
|
31287
31644
|
}
|
|
31288
31645
|
function validateRuntimeLayout(layout) {
|
|
31289
|
-
const support =
|
|
31646
|
+
const support = path24.resolve(layout.supportDir);
|
|
31290
31647
|
const expected = [
|
|
31291
|
-
[layout.releasesDir,
|
|
31292
|
-
[layout.currentManifestPath,
|
|
31293
|
-
[layout.launcherPath,
|
|
31294
|
-
[layout.logsDir,
|
|
31648
|
+
[layout.releasesDir, path24.join(support, "releases")],
|
|
31649
|
+
[layout.currentManifestPath, path24.join(support, "current.json")],
|
|
31650
|
+
[layout.launcherPath, path24.join(support, "bin", "localapp-daemon-bootstrap.mjs")],
|
|
31651
|
+
[layout.logsDir, path24.join(support, "logs")]
|
|
31295
31652
|
];
|
|
31296
|
-
if (expected.some(([actual, canonical]) =>
|
|
31653
|
+
if (expected.some(([actual, canonical]) => path24.resolve(actual) !== path24.resolve(canonical)) || path24.resolve(layout.releaseLockPath) !== path24.resolve(layout.runtimeDir, "release.lock")) {
|
|
31297
31654
|
throw lifecycleError("release_path_unsafe", "The LocalApp release layout is invalid");
|
|
31298
31655
|
}
|
|
31299
31656
|
}
|
|
@@ -31316,8 +31673,8 @@ async function ensureStableLauncher(filePath, bytes) {
|
|
|
31316
31673
|
if (process.platform !== "win32") await fs19.chmod(filePath, 448);
|
|
31317
31674
|
}
|
|
31318
31675
|
async function writeAtomic(filePath, bytes, mode) {
|
|
31319
|
-
await fs19.mkdir(
|
|
31320
|
-
const temporary =
|
|
31676
|
+
await fs19.mkdir(path24.dirname(filePath), { recursive: true, mode: 448 });
|
|
31677
|
+
const temporary = path24.join(path24.dirname(filePath), `.${path24.basename(filePath)}.${process.pid}.${crypto6.randomUUID()}.next`);
|
|
31321
31678
|
let handle;
|
|
31322
31679
|
try {
|
|
31323
31680
|
handle = await fs19.open(temporary, "wx", mode);
|
|
@@ -31349,7 +31706,7 @@ async function readRegularFile(filePath) {
|
|
|
31349
31706
|
}
|
|
31350
31707
|
}
|
|
31351
31708
|
function isSafeRelativeFile(value2) {
|
|
31352
|
-
return value2.length > 0 && value2.length <= 512 && !value2.includes("\\") && !value2.startsWith("/") &&
|
|
31709
|
+
return value2.length > 0 && value2.length <= 512 && !value2.includes("\\") && !value2.startsWith("/") && path24.posix.normalize(value2) === value2 && !value2.endsWith("/") && value2.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
31353
31710
|
}
|
|
31354
31711
|
function compareArtifactFiles(left, right) {
|
|
31355
31712
|
return left.path < right.path ? -1 : left.path > right.path ? 1 : 0;
|
|
@@ -31378,12 +31735,12 @@ async function lstatOptional2(filePath) {
|
|
|
31378
31735
|
// packages/localapp/src/daemon/runtime-layout.ts
|
|
31379
31736
|
import crypto7 from "node:crypto";
|
|
31380
31737
|
import { homedir as homedir3 } from "node:os";
|
|
31381
|
-
import
|
|
31738
|
+
import path25 from "node:path";
|
|
31382
31739
|
function createRuntimeLayout(options2 = {}) {
|
|
31383
31740
|
const platform = options2.platform ?? process.platform;
|
|
31384
31741
|
const env = options2.env ?? process.env;
|
|
31385
31742
|
const homeDirectory = options2.homeDir ?? homedir3();
|
|
31386
|
-
const pathApi = platform === "win32" ?
|
|
31743
|
+
const pathApi = platform === "win32" ? path25.win32 : path25.posix;
|
|
31387
31744
|
const supportDir = options2.supportDir ?? defaultSupportDirectory(platform, env, homeDirectory, pathApi);
|
|
31388
31745
|
const runtimeDir = options2.runtimeDir ?? defaultRuntimeDirectory(platform, env, homeDirectory, supportDir, options2.uid, pathApi);
|
|
31389
31746
|
const dataDir = options2.dataDir ?? pathApi.join(supportDir, "data");
|
|
@@ -31426,20 +31783,20 @@ import { spawn as spawn6 } from "node:child_process";
|
|
|
31426
31783
|
|
|
31427
31784
|
// packages/localapp/src/service/linux-systemd-user.ts
|
|
31428
31785
|
import fs21 from "node:fs/promises";
|
|
31429
|
-
import
|
|
31786
|
+
import path27 from "node:path";
|
|
31430
31787
|
|
|
31431
31788
|
// packages/localapp/src/service/service-files.ts
|
|
31432
31789
|
import crypto8 from "node:crypto";
|
|
31433
31790
|
import fs20 from "node:fs/promises";
|
|
31434
|
-
import
|
|
31791
|
+
import path26 from "node:path";
|
|
31435
31792
|
async function writeServiceFile(filePath, value2) {
|
|
31436
31793
|
const existing = await fs20.readFile(filePath, "utf8").catch((error) => {
|
|
31437
31794
|
if (error.code === "ENOENT") return void 0;
|
|
31438
31795
|
throw error;
|
|
31439
31796
|
});
|
|
31440
31797
|
if (existing === value2) return false;
|
|
31441
|
-
await fs20.mkdir(
|
|
31442
|
-
const temporary =
|
|
31798
|
+
await fs20.mkdir(path26.dirname(filePath), { recursive: true, mode: 448 });
|
|
31799
|
+
const temporary = path26.join(path26.dirname(filePath), `.${path26.basename(filePath)}.${process.pid}.${crypto8.randomUUID()}.next`);
|
|
31443
31800
|
let handle;
|
|
31444
31801
|
try {
|
|
31445
31802
|
handle = await fs20.open(temporary, "wx", 384);
|
|
@@ -31462,8 +31819,8 @@ function xmlEscape(value2) {
|
|
|
31462
31819
|
// packages/localapp/src/service/linux-systemd-user.ts
|
|
31463
31820
|
var UNIT_NAME = "localapp.service";
|
|
31464
31821
|
function createLinuxSystemdUserService(options2) {
|
|
31465
|
-
const configHome = options2.env?.XDG_CONFIG_HOME ??
|
|
31466
|
-
const registrationPath =
|
|
31822
|
+
const configHome = options2.env?.XDG_CONFIG_HOME ?? path27.join(options2.homeDir, ".config");
|
|
31823
|
+
const registrationPath = path27.join(configHome, "systemd", "user", UNIT_NAME);
|
|
31467
31824
|
const unit = buildUnit(options2);
|
|
31468
31825
|
const systemctl = options2.env?.SYSTEMCTL_PATH ?? "systemctl";
|
|
31469
31826
|
return {
|
|
@@ -31479,7 +31836,7 @@ function createLinuxSystemdUserService(options2) {
|
|
|
31479
31836
|
return { mode: "service", installed };
|
|
31480
31837
|
},
|
|
31481
31838
|
async start(signal) {
|
|
31482
|
-
await runServiceCommand(options2.run, withAbortSignal({ command: systemctl, args: ["--user", "
|
|
31839
|
+
await runServiceCommand(options2.run, withAbortSignal({ command: systemctl, args: ["--user", "restart", UNIT_NAME] }, signal));
|
|
31483
31840
|
},
|
|
31484
31841
|
async stop() {
|
|
31485
31842
|
const result = await options2.run({ command: systemctl, args: ["--user", "stop", UNIT_NAME] });
|
|
@@ -31520,8 +31877,8 @@ Type=simple
|
|
|
31520
31877
|
ExecStart=${systemdQuote(options2.nodePath)} ${systemdQuote(options2.layout.launcherPath)}
|
|
31521
31878
|
Restart=on-failure
|
|
31522
31879
|
RestartSec=2
|
|
31523
|
-
StandardOutput=append:${
|
|
31524
|
-
StandardError=append:${
|
|
31880
|
+
StandardOutput=append:${options2.layout.daemonLogPath}
|
|
31881
|
+
StandardError=append:${options2.layout.daemonLogPath}
|
|
31525
31882
|
${environment ? `${environment}
|
|
31526
31883
|
` : ""}
|
|
31527
31884
|
[Install]
|
|
@@ -31538,14 +31895,14 @@ function systemdQuote(value2) {
|
|
|
31538
31895
|
// packages/localapp/src/service/macos-launch-agent.ts
|
|
31539
31896
|
import crypto9 from "node:crypto";
|
|
31540
31897
|
import fs22 from "node:fs/promises";
|
|
31541
|
-
import
|
|
31898
|
+
import path28 from "node:path";
|
|
31542
31899
|
var LABEL = "com.localapp.daemon";
|
|
31543
31900
|
function createMacosLaunchAgent(options2) {
|
|
31544
31901
|
const uid = options2.uid ?? (typeof process.getuid === "function" ? process.getuid() : void 0);
|
|
31545
31902
|
if (!Number.isSafeInteger(uid) || (uid ?? -1) < 0) {
|
|
31546
31903
|
throw lifecycleError("user_service_configuration_invalid", "The current macOS user identity is unavailable");
|
|
31547
31904
|
}
|
|
31548
|
-
const registrationPath =
|
|
31905
|
+
const registrationPath = path28.join(options2.homeDir, "Library", "LaunchAgents", `${LABEL}.plist`);
|
|
31549
31906
|
const domain = `gui/${uid}`;
|
|
31550
31907
|
const target = `${domain}/${LABEL}`;
|
|
31551
31908
|
const plist = buildPlist(options2);
|
|
@@ -31638,12 +31995,12 @@ ${environment}
|
|
|
31638
31995
|
|
|
31639
31996
|
// packages/localapp/src/service/windows-user-task.ts
|
|
31640
31997
|
import fs23 from "node:fs/promises";
|
|
31641
|
-
import
|
|
31998
|
+
import path29 from "node:path";
|
|
31642
31999
|
var TASK_NAME = "LocalApp User Daemon";
|
|
31643
32000
|
function createWindowsUserTask(options2) {
|
|
31644
|
-
const registrationPath =
|
|
32001
|
+
const registrationPath = path29.join(options2.layout.supportDir, "service", "windows-user-task.json");
|
|
31645
32002
|
const systemRoot = options2.env?.SystemRoot ?? options2.env?.SYSTEMROOT ?? "C:\\Windows";
|
|
31646
|
-
const scheduler =
|
|
32003
|
+
const scheduler = path29.win32.join(systemRoot, "System32", "schtasks.exe");
|
|
31647
32004
|
const taskCommand = `${quoteWindowsArgument(options2.nodePath)} ${quoteWindowsArgument(options2.layout.launcherPath)}`;
|
|
31648
32005
|
const metadata = `${JSON.stringify({
|
|
31649
32006
|
schemaVersion: 1,
|
|
@@ -31656,18 +32013,25 @@ function createWindowsUserTask(options2) {
|
|
|
31656
32013
|
registrationPath,
|
|
31657
32014
|
async install() {
|
|
31658
32015
|
const installed = await writeServiceFile(registrationPath, metadata);
|
|
32016
|
+
const definitionPath = path29.join(path29.dirname(registrationPath), "windows-user-task.xml");
|
|
32017
|
+
await fs23.mkdir(path29.dirname(definitionPath), { recursive: true });
|
|
32018
|
+
await fs23.writeFile(definitionPath, taskDefinition(options2.nodePath, options2.layout.launcherPath));
|
|
31659
32019
|
await runServiceCommand(options2.run, {
|
|
31660
32020
|
command: scheduler,
|
|
31661
|
-
args: ["/Create", "/TN", TASK_NAME, "/
|
|
32021
|
+
args: ["/Create", "/TN", TASK_NAME, "/XML", definitionPath, "/F"]
|
|
31662
32022
|
});
|
|
31663
32023
|
return { mode: "service", installed };
|
|
31664
32024
|
},
|
|
31665
32025
|
async start(signal) {
|
|
32026
|
+
const ended = await options2.run(withAbortSignal({ command: scheduler, args: ["/End", "/TN", TASK_NAME] }, signal));
|
|
32027
|
+
if (ended.code !== 0 && !isNotRunningTask(ended.stderr)) {
|
|
32028
|
+
throw lifecycleError("user_service_command_failed", "The Windows user task could not be stopped");
|
|
32029
|
+
}
|
|
31666
32030
|
await runServiceCommand(options2.run, withAbortSignal({ command: scheduler, args: ["/Run", "/TN", TASK_NAME] }, signal));
|
|
31667
32031
|
},
|
|
31668
32032
|
async stop() {
|
|
31669
32033
|
const result = await options2.run({ command: scheduler, args: ["/End", "/TN", TASK_NAME] });
|
|
31670
|
-
if (result.code !== 0 &&
|
|
32034
|
+
if (result.code !== 0 && !isNotRunningTask(result.stderr)) {
|
|
31671
32035
|
throw lifecycleError("user_service_command_failed", "The Windows user task could not be stopped");
|
|
31672
32036
|
}
|
|
31673
32037
|
},
|
|
@@ -31688,6 +32052,51 @@ function createWindowsUserTask(options2) {
|
|
|
31688
32052
|
}
|
|
31689
32053
|
};
|
|
31690
32054
|
}
|
|
32055
|
+
function isNotRunningTask(stderr) {
|
|
32056
|
+
return /cannot find|does not exist|not currently running/i.test(stderr);
|
|
32057
|
+
}
|
|
32058
|
+
function taskDefinition(nodePath, launcherPath) {
|
|
32059
|
+
const xml = `<?xml version="1.0" encoding="UTF-16"?>
|
|
32060
|
+
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
32061
|
+
<RegistrationInfo>
|
|
32062
|
+
<Description>LocalApp per-user daemon</Description>
|
|
32063
|
+
</RegistrationInfo>
|
|
32064
|
+
<Triggers>
|
|
32065
|
+
<LogonTrigger>
|
|
32066
|
+
<Enabled>true</Enabled>
|
|
32067
|
+
</LogonTrigger>
|
|
32068
|
+
</Triggers>
|
|
32069
|
+
<Principals>
|
|
32070
|
+
<Principal id="Author">
|
|
32071
|
+
<LogonType>InteractiveToken</LogonType>
|
|
32072
|
+
<RunLevel>LeastPrivilege</RunLevel>
|
|
32073
|
+
</Principal>
|
|
32074
|
+
</Principals>
|
|
32075
|
+
<Settings>
|
|
32076
|
+
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
|
|
32077
|
+
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
32078
|
+
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
32079
|
+
<AllowStartOnDemand>true</AllowStartOnDemand>
|
|
32080
|
+
<Enabled>true</Enabled>
|
|
32081
|
+
<Hidden>false</Hidden>
|
|
32082
|
+
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
|
32083
|
+
<WakeToRun>false</WakeToRun>
|
|
32084
|
+
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
|
|
32085
|
+
<Priority>7</Priority>
|
|
32086
|
+
</Settings>
|
|
32087
|
+
<Actions Context="Author">
|
|
32088
|
+
<Exec>
|
|
32089
|
+
<Command>${xmlEscape2(nodePath)}</Command>
|
|
32090
|
+
<Arguments>${xmlEscape2(launcherPath)}</Arguments>
|
|
32091
|
+
</Exec>
|
|
32092
|
+
</Actions>
|
|
32093
|
+
</Task>
|
|
32094
|
+
`;
|
|
32095
|
+
return Buffer.concat([Buffer.from([255, 254]), Buffer.from(xml, "utf16le")]);
|
|
32096
|
+
}
|
|
32097
|
+
function xmlEscape2(value2) {
|
|
32098
|
+
return value2.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
32099
|
+
}
|
|
31691
32100
|
function quoteWindowsArgument(value2) {
|
|
31692
32101
|
if (value2.includes("\0") || /[\r\n]/.test(value2)) {
|
|
31693
32102
|
throw lifecycleError("user_service_configuration_invalid", "The Windows service command path is invalid");
|
|
@@ -31820,7 +32229,7 @@ async function runServerCommand(options2, dependencies = {}) {
|
|
|
31820
32229
|
const artifactDirectory = dependencies.artifactDirectory ?? defaultArtifactDirectory();
|
|
31821
32230
|
await (dependencies.verifyReleaseArtifact ?? verifyReleaseArtifact)(artifactDirectory);
|
|
31822
32231
|
const release = await (dependencies.publishRelease ?? publishRelease)({ sourceDirectory: artifactDirectory, layout });
|
|
31823
|
-
const native = await (dependencies.createNativeAdapter ?? createNativeAdapter)(
|
|
32232
|
+
const native = await (dependencies.createNativeAdapter ?? createNativeAdapter)(path30.join(release.releasePath, "runtime", "native"), { supportDir: layout.supportDir });
|
|
31824
32233
|
await native.installScheme();
|
|
31825
32234
|
const manager = service();
|
|
31826
32235
|
const installed = await manager.install();
|
|
@@ -31860,7 +32269,7 @@ async function runServerForeground(options2, dependencies = {}) {
|
|
|
31860
32269
|
const artifact = dependencies.artifactDirectory ?? defaultArtifactDirectory();
|
|
31861
32270
|
const manifest = await verifyReleaseArtifact(artifact);
|
|
31862
32271
|
if (typeof manifest.serverEntrypoint !== "string") throw lifecycleError("canonical_server_unavailable", "The packed canonical LocalApp Server runtime is unavailable");
|
|
31863
|
-
const entrypoint =
|
|
32272
|
+
const entrypoint = path30.join(artifact, ...manifest.serverEntrypoint.split("/"));
|
|
31864
32273
|
const child = (dependencies.spawnOwnedProcess ?? spawnOwnedProcess)(process.execPath, [
|
|
31865
32274
|
entrypoint,
|
|
31866
32275
|
"start",
|
|
@@ -31972,13 +32381,7 @@ function defaultServiceManager(layout) {
|
|
|
31972
32381
|
return createCurrentUserServiceManager(layout);
|
|
31973
32382
|
}
|
|
31974
32383
|
function defaultArtifactDirectory() {
|
|
31975
|
-
|
|
31976
|
-
if (fromEntry !== void 0) return fromEntry;
|
|
31977
|
-
return path29.resolve(path29.dirname(fileURLToPath4(import.meta.url)), "../..");
|
|
31978
|
-
}
|
|
31979
|
-
function artifactDirectoryFromEntrypoint(entrypoint) {
|
|
31980
|
-
const canonical = realpathSync(entrypoint);
|
|
31981
|
-
return path29.resolve(path29.dirname(canonical), "..");
|
|
32384
|
+
return localAppArtifactDirectory();
|
|
31982
32385
|
}
|
|
31983
32386
|
function runtimeLayoutFromEnvironment(environment = process.env) {
|
|
31984
32387
|
return createRuntimeLayout({
|
|
@@ -32004,7 +32407,7 @@ function delay2(ms) {
|
|
|
32004
32407
|
// packages/localapp/src/daemon/daemon.ts
|
|
32005
32408
|
import crypto11 from "node:crypto";
|
|
32006
32409
|
import fs28 from "node:fs/promises";
|
|
32007
|
-
import
|
|
32410
|
+
import path33 from "node:path";
|
|
32008
32411
|
|
|
32009
32412
|
// packages/localapp/src/activation/activation-broker.ts
|
|
32010
32413
|
var DEVICE_ACTION_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -32114,7 +32517,7 @@ import crypto10 from "node:crypto";
|
|
|
32114
32517
|
import { execFile } from "node:child_process";
|
|
32115
32518
|
import { constants as constants4 } from "node:fs";
|
|
32116
32519
|
import fs26 from "node:fs/promises";
|
|
32117
|
-
import
|
|
32520
|
+
import path31 from "node:path";
|
|
32118
32521
|
import { promisify } from "node:util";
|
|
32119
32522
|
var EMPTY_STATE = { version: 1, sources: [] };
|
|
32120
32523
|
var SOURCE_ID = /^[A-Za-z0-9](?:[A-Za-z0-9_-]{0,127})$/;
|
|
@@ -32138,7 +32541,7 @@ var DeliveryStore = class {
|
|
|
32138
32541
|
tail = Promise.resolve();
|
|
32139
32542
|
poisoned = false;
|
|
32140
32543
|
constructor(options2) {
|
|
32141
|
-
this.statePath =
|
|
32544
|
+
this.statePath = path31.resolve(options2.statePath);
|
|
32142
32545
|
this.now = options2.now ?? (() => /* @__PURE__ */ new Date());
|
|
32143
32546
|
this.randomBytes = options2.randomBytes ?? crypto10.randomBytes;
|
|
32144
32547
|
this.fault = options2.fault;
|
|
@@ -32171,7 +32574,7 @@ var DeliveryStore = class {
|
|
|
32171
32574
|
return snapshot(source);
|
|
32172
32575
|
});
|
|
32173
32576
|
}
|
|
32174
|
-
async preparePending(sourceId, value2, expiresAt, sourceLabel = sourceId, iconPath =
|
|
32577
|
+
async preparePending(sourceId, value2, expiresAt, sourceLabel = sourceId, iconPath = path31.resolve(process.cwd(), "localapp-notification.png")) {
|
|
32175
32578
|
return this.mutate((state) => {
|
|
32176
32579
|
const source = requiredSource(state, sourceId);
|
|
32177
32580
|
const delivery = validateDelivery(value2);
|
|
@@ -32314,9 +32717,9 @@ var DeliveryStore = class {
|
|
|
32314
32717
|
});
|
|
32315
32718
|
}
|
|
32316
32719
|
async withFileLock(operation) {
|
|
32317
|
-
const parent =
|
|
32720
|
+
const parent = path31.dirname(this.statePath);
|
|
32318
32721
|
await ensurePrivateParent(parent);
|
|
32319
|
-
const lockPath =
|
|
32722
|
+
const lockPath = path31.join(parent, `.${path31.basename(this.statePath)}.lock`);
|
|
32320
32723
|
const deadline = Date.now() + this.lockTimeoutMs;
|
|
32321
32724
|
let lock;
|
|
32322
32725
|
while (lock === void 0) {
|
|
@@ -32327,7 +32730,7 @@ var DeliveryStore = class {
|
|
|
32327
32730
|
await new Promise((resolve2) => setTimeout(resolve2, 10));
|
|
32328
32731
|
}
|
|
32329
32732
|
try {
|
|
32330
|
-
await removeOwnedStaleTemps(parent,
|
|
32733
|
+
await removeOwnedStaleTemps(parent, path31.basename(this.statePath));
|
|
32331
32734
|
return await operation();
|
|
32332
32735
|
} finally {
|
|
32333
32736
|
await lock.handle.close().catch(() => void 0);
|
|
@@ -32343,7 +32746,7 @@ var DeliveryStore = class {
|
|
|
32343
32746
|
return run;
|
|
32344
32747
|
}
|
|
32345
32748
|
async read() {
|
|
32346
|
-
await ensurePrivateParent(
|
|
32749
|
+
await ensurePrivateParent(path31.dirname(this.statePath));
|
|
32347
32750
|
let handle;
|
|
32348
32751
|
try {
|
|
32349
32752
|
const before = await fs26.lstat(this.statePath, { bigint: true });
|
|
@@ -32365,11 +32768,11 @@ var DeliveryStore = class {
|
|
|
32365
32768
|
}
|
|
32366
32769
|
}
|
|
32367
32770
|
async publish(state) {
|
|
32368
|
-
const parent =
|
|
32771
|
+
const parent = path31.dirname(this.statePath);
|
|
32369
32772
|
const parentBefore = await privateDirectoryIdentity(parent);
|
|
32370
32773
|
const parentHandle = await fs26.open(parent, "r");
|
|
32371
32774
|
let existing;
|
|
32372
|
-
const temporary =
|
|
32775
|
+
const temporary = path31.join(parent, `.${path31.basename(this.statePath)}.${process.pid}.${this.token(12)}.tmp`);
|
|
32373
32776
|
let handle;
|
|
32374
32777
|
let tempIdentity;
|
|
32375
32778
|
let renamed = false;
|
|
@@ -32396,7 +32799,7 @@ var DeliveryStore = class {
|
|
|
32396
32799
|
if (!optionalSameIdentity(existing, current)) throw unsafe("Notification delivery state was replaced");
|
|
32397
32800
|
await this.fault?.("before-rename");
|
|
32398
32801
|
try {
|
|
32399
|
-
await renameInPinnedParent(parent,
|
|
32802
|
+
await renameInPinnedParent(parent, path31.basename(temporary), path31.basename(this.statePath), parentBefore, tempIdentity);
|
|
32400
32803
|
renamed = true;
|
|
32401
32804
|
} catch (error) {
|
|
32402
32805
|
if (error instanceof PinnedRenamePreconditionError) throw error;
|
|
@@ -32541,7 +32944,7 @@ function validateDisplaySourceLabel(value2) {
|
|
|
32541
32944
|
return value2;
|
|
32542
32945
|
}
|
|
32543
32946
|
function validateIconPath(value2) {
|
|
32544
|
-
if (typeof value2 !== "string" || value2.length > 2048 || !
|
|
32947
|
+
if (typeof value2 !== "string" || value2.length > 2048 || !path31.isAbsolute(value2) || path31.resolve(value2) !== value2 || /[\u0000-\u001f\u007f]/.test(value2)) throw new Error("Notification icon path is invalid");
|
|
32545
32948
|
return value2;
|
|
32546
32949
|
}
|
|
32547
32950
|
function validateSourceId(value2) {
|
|
@@ -32610,11 +33013,11 @@ async function ensurePrivateParent(directory) {
|
|
|
32610
33013
|
await privateDirectoryIdentity(directory);
|
|
32611
33014
|
}
|
|
32612
33015
|
async function assertNoSymlinkAncestors(target, allowMissingTail) {
|
|
32613
|
-
const absolute =
|
|
32614
|
-
const parsed =
|
|
33016
|
+
const absolute = path31.resolve(target);
|
|
33017
|
+
const parsed = path31.parse(absolute);
|
|
32615
33018
|
let current = parsed.root;
|
|
32616
|
-
for (const segment of absolute.slice(parsed.root.length).split(
|
|
32617
|
-
current =
|
|
33019
|
+
for (const segment of absolute.slice(parsed.root.length).split(path31.sep).filter(Boolean)) {
|
|
33020
|
+
current = path31.join(current, segment);
|
|
32618
33021
|
const stat2 = await optionalLstat(current);
|
|
32619
33022
|
if (stat2 === void 0) {
|
|
32620
33023
|
if (allowMissingTail) return;
|
|
@@ -32681,7 +33084,7 @@ async function removeOwnedStaleTemps(parent, basename2) {
|
|
|
32681
33084
|
const names = (await fs26.readdir(parent)).filter((name) => name.startsWith(prefix) && name.endsWith(".tmp"));
|
|
32682
33085
|
if (names.length === 0) return;
|
|
32683
33086
|
for (const name of names) {
|
|
32684
|
-
const target =
|
|
33087
|
+
const target = path31.join(parent, name);
|
|
32685
33088
|
const stat2 = await fs26.lstat(target, { bigint: true });
|
|
32686
33089
|
assertPrivateRegular(stat2, "Notification delivery stale temporary file");
|
|
32687
33090
|
await unlinkOwned(target, { dev: BigInt(stat2.dev), ino: BigInt(stat2.ino) });
|
|
@@ -32779,7 +33182,7 @@ function strictJsonParse(input) {
|
|
|
32779
33182
|
return result;
|
|
32780
33183
|
}
|
|
32781
33184
|
async function tryAcquireLock(lockPath) {
|
|
32782
|
-
const temporary =
|
|
33185
|
+
const temporary = path31.join(path31.dirname(lockPath), `.${path31.basename(lockPath)}.${process.pid}.${crypto10.randomUUID()}.next`);
|
|
32783
33186
|
let handle;
|
|
32784
33187
|
let identity;
|
|
32785
33188
|
let linked = false;
|
|
@@ -32853,11 +33256,11 @@ async function validateVisibleLock(stat2, lockPath) {
|
|
|
32853
33256
|
throw unsafe("Notification delivery lock path is unsafe");
|
|
32854
33257
|
}
|
|
32855
33258
|
if (stat2.nlink === 1n) return { stable: true, linkedTemporary: void 0 };
|
|
32856
|
-
const prefix = `.${
|
|
32857
|
-
const candidates = (await fs26.readdir(
|
|
33259
|
+
const prefix = `.${path31.basename(lockPath)}.`;
|
|
33260
|
+
const candidates = (await fs26.readdir(path31.dirname(lockPath))).filter((name) => name.startsWith(prefix) && name.endsWith(".next"));
|
|
32858
33261
|
const same = [];
|
|
32859
33262
|
for (const name of candidates) {
|
|
32860
|
-
const candidate =
|
|
33263
|
+
const candidate = path31.join(path31.dirname(lockPath), name);
|
|
32861
33264
|
const metadata = await optionalLstat(candidate);
|
|
32862
33265
|
if (metadata !== void 0 && sameIdentity(stat2, metadata)) same.push(candidate);
|
|
32863
33266
|
}
|
|
@@ -33596,7 +33999,7 @@ function delay3(ms, signal) {
|
|
|
33596
33999
|
// packages/localapp/src/daemon/ipc-server.ts
|
|
33597
34000
|
import fs27 from "node:fs/promises";
|
|
33598
34001
|
import net3 from "node:net";
|
|
33599
|
-
import
|
|
34002
|
+
import path32 from "node:path";
|
|
33600
34003
|
var DEFAULT_TIMEOUT_MS2 = 5e3;
|
|
33601
34004
|
async function createIpcServer(options2) {
|
|
33602
34005
|
const platform = options2.platform ?? process.platform;
|
|
@@ -33606,7 +34009,7 @@ async function createIpcServer(options2) {
|
|
|
33606
34009
|
const sockets = /* @__PURE__ */ new Set();
|
|
33607
34010
|
const server = net3.createServer({ allowHalfOpen: true }, (socket) => {
|
|
33608
34011
|
sockets.add(socket);
|
|
33609
|
-
void serveConnection(socket, options2.handle, options2.afterResponse, options2.timeoutMs ?? DEFAULT_TIMEOUT_MS2).finally(() => sockets.delete(socket));
|
|
34012
|
+
void serveConnection(socket, options2.handle, options2.afterResponse, options2.timeoutMs ?? DEFAULT_TIMEOUT_MS2, platform).finally(() => sockets.delete(socket));
|
|
33610
34013
|
});
|
|
33611
34014
|
await new Promise((resolve2, reject) => {
|
|
33612
34015
|
server.once("error", reject);
|
|
@@ -33627,7 +34030,7 @@ async function createIpcServer(options2) {
|
|
|
33627
34030
|
let closing;
|
|
33628
34031
|
return { close: () => closing ??= closeServer(server, sockets, options2.endpoint, identity, options2.timeoutMs ?? DEFAULT_TIMEOUT_MS2) };
|
|
33629
34032
|
}
|
|
33630
|
-
function serveConnection(socket, handle, afterResponse, timeoutMs) {
|
|
34033
|
+
function serveConnection(socket, handle, afterResponse, timeoutMs, platform) {
|
|
33631
34034
|
return new Promise((resolve2) => {
|
|
33632
34035
|
socket.setNoDelay(true);
|
|
33633
34036
|
let bytes = Buffer.alloc(0);
|
|
@@ -33672,14 +34075,7 @@ function serveConnection(socket, handle, afterResponse, timeoutMs) {
|
|
|
33672
34075
|
timer.unref?.();
|
|
33673
34076
|
socket.once("error", close);
|
|
33674
34077
|
socket.once("close", close);
|
|
33675
|
-
|
|
33676
|
-
if (settled || requestEnded || bytes.byteLength + chunk.byteLength > CONTROL_FRAME_LIMIT_BYTES) {
|
|
33677
|
-
if (!settled) fail2("IPC_MESSAGE_TOO_LARGE");
|
|
33678
|
-
return;
|
|
33679
|
-
}
|
|
33680
|
-
bytes = Buffer.concat([bytes, chunk]);
|
|
33681
|
-
});
|
|
33682
|
-
socket.once("end", () => {
|
|
34078
|
+
const dispatch = () => {
|
|
33683
34079
|
requestEnded = true;
|
|
33684
34080
|
if (settled) return;
|
|
33685
34081
|
try {
|
|
@@ -33688,11 +34084,23 @@ function serveConnection(socket, handle, afterResponse, timeoutMs) {
|
|
|
33688
34084
|
} catch (error) {
|
|
33689
34085
|
fail2(typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : "IPC_REQUEST_INVALID");
|
|
33690
34086
|
}
|
|
34087
|
+
};
|
|
34088
|
+
socket.on("data", (chunk) => {
|
|
34089
|
+
if (settled || requestEnded || bytes.byteLength + chunk.byteLength > CONTROL_FRAME_LIMIT_BYTES) {
|
|
34090
|
+
if (!settled) fail2("IPC_MESSAGE_TOO_LARGE");
|
|
34091
|
+
return;
|
|
34092
|
+
}
|
|
34093
|
+
bytes = Buffer.concat([bytes, chunk]);
|
|
34094
|
+
if (platform === "win32" && bytes.indexOf(10) >= 0) dispatch();
|
|
34095
|
+
});
|
|
34096
|
+
socket.once("end", () => {
|
|
34097
|
+
if (requestEnded || settled) return;
|
|
34098
|
+
dispatch();
|
|
33691
34099
|
});
|
|
33692
34100
|
});
|
|
33693
34101
|
}
|
|
33694
34102
|
async function prepareUnixEndpoint(endpoint, reclaim) {
|
|
33695
|
-
const parent =
|
|
34103
|
+
const parent = path32.dirname(endpoint);
|
|
33696
34104
|
const parentStat = await fs27.lstat(parent).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
|
|
33697
34105
|
if (parentStat === void 0 || !parentStat.isDirectory() || parentStat.isSymbolicLink() || (Number(parentStat.mode) & 63) !== 0) throw lifecycleError("ipc_path_unsafe", "The LocalApp control directory is not private");
|
|
33698
34106
|
const existing = await fs27.lstat(endpoint, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
|
|
@@ -33883,9 +34291,9 @@ var LocalAppDaemon = class {
|
|
|
33883
34291
|
const current = await readCurrentRelease(this.options.layout);
|
|
33884
34292
|
const manifest = await verifyReleaseArtifact(current.releasePath);
|
|
33885
34293
|
if (typeof manifest.serverEntrypoint !== "string") throw lifecycleError("canonical_server_unavailable", "The packed canonical LocalApp Server runtime is unavailable");
|
|
33886
|
-
const entrypoint =
|
|
33887
|
-
const
|
|
33888
|
-
const server =
|
|
34294
|
+
const entrypoint = path33.join(current.releasePath, ...manifest.serverEntrypoint.split("/"));
|
|
34295
|
+
const spawn8 = this.options.spawnOwnedProcess ?? spawnOwnedProcess;
|
|
34296
|
+
const server = spawn8(process.execPath, [entrypoint, "start", "--data-dir", this.options.layout.dataDir, "--host", "127.0.0.1", "--port", "0"], {
|
|
33889
34297
|
cwd: current.releasePath,
|
|
33890
34298
|
env: { ...process.env, LOCALAPP_DEVICE_CONTROL_TOKEN: this.deviceControlToken, LOCALAPP_NOTIFICATION_CONTROL_TOKEN: this.notificationControlToken, LOCALAPP_DEV_TOOLS: void 0 },
|
|
33891
34299
|
stdio: ["ignore", "pipe", "inherit"]
|
|
@@ -33953,12 +34361,12 @@ var LocalAppDaemon = class {
|
|
|
33953
34361
|
if (failure !== void 0) throw failure;
|
|
33954
34362
|
}
|
|
33955
34363
|
async createDefaultNotificationRuntime(options2) {
|
|
33956
|
-
const store = new DeliveryStore({ statePath:
|
|
33957
|
-
const native = await createNativeAdapter(
|
|
34364
|
+
const store = new DeliveryStore({ statePath: path33.join(this.options.layout.supportDir, "notifications", "delivery-state.json") });
|
|
34365
|
+
const native = await createNativeAdapter(path33.join(options2.releasePath, "runtime", "native"), { supportDir: this.options.layout.supportDir });
|
|
33958
34366
|
const dispatcher = new NotificationDispatcher({
|
|
33959
34367
|
store,
|
|
33960
34368
|
adapter: native,
|
|
33961
|
-
iconPath:
|
|
34369
|
+
iconPath: path33.join(options2.releasePath, "runtime", "server", "web", "home", "redline-launch-hero.png")
|
|
33962
34370
|
});
|
|
33963
34371
|
const manager = new NotificationConnectionManager({
|
|
33964
34372
|
localServerOrigin: options2.listenUrl,
|
|
@@ -34049,7 +34457,7 @@ async function verifyHealth2(listenUrl, timeoutMs) {
|
|
|
34049
34457
|
}
|
|
34050
34458
|
async function readLock(lockPath) {
|
|
34051
34459
|
const before = await fs28.lstat(lockPath, { bigint: true });
|
|
34052
|
-
if (!before.isFile() || before.isSymbolicLink() || (Number(before.mode) & 63) !== 0) {
|
|
34460
|
+
if (!before.isFile() || before.isSymbolicLink() || process.platform !== "win32" && (Number(before.mode) & 63) !== 0) {
|
|
34053
34461
|
throw lifecycleError("daemon_lock_invalid", "The LocalApp daemon lock is unsafe");
|
|
34054
34462
|
}
|
|
34055
34463
|
let value2;
|
|
@@ -34102,7 +34510,7 @@ async function unlinkOwned2(filePath, identity) {
|
|
|
34102
34510
|
return true;
|
|
34103
34511
|
}
|
|
34104
34512
|
function digestDataRoot(dataDir) {
|
|
34105
|
-
return crypto11.createHash("sha256").update(
|
|
34513
|
+
return crypto11.createHash("sha256").update(path33.resolve(dataDir)).digest("hex");
|
|
34106
34514
|
}
|
|
34107
34515
|
async function withCleanupTimeout(operation, timeoutMs) {
|
|
34108
34516
|
let timer;
|
|
@@ -34116,8 +34524,57 @@ async function withCleanupTimeout(operation, timeoutMs) {
|
|
|
34116
34524
|
}
|
|
34117
34525
|
}
|
|
34118
34526
|
|
|
34527
|
+
// packages/localapp/src/daemon/windows-identity.ts
|
|
34528
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
34529
|
+
var VERIFY_TIMEOUT_MS = 8e3;
|
|
34530
|
+
async function verifyWindowsRuntimeOwnership(layout) {
|
|
34531
|
+
const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT ?? "C:\\Windows";
|
|
34532
|
+
const powershell = `${systemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
34533
|
+
const script = [
|
|
34534
|
+
"$errorActionPreference='Stop'",
|
|
34535
|
+
"try {",
|
|
34536
|
+
" $dir = $env:LOCALAPP_VERIFY_DIR",
|
|
34537
|
+
" if (-not $dir) { 'false'; exit }",
|
|
34538
|
+
" $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()",
|
|
34539
|
+
" $current = [string]$identity.User.Value",
|
|
34540
|
+
" $owner = (Get-Acl -LiteralPath $dir).Owner",
|
|
34541
|
+
" $ownerSid = ([System.Security.Principal.NTAccount]$owner).Translate([System.Security.Principal.SecurityIdentifier]).Value",
|
|
34542
|
+
" if ($current -eq [string]$ownerSid) { 'true'; exit }",
|
|
34543
|
+
" $isAdmin = @($identity.Groups | ForEach-Object { [string]$_.Value }) -contains 'S-1-5-32-544'",
|
|
34544
|
+
" if ([string]$ownerSid -eq 'S-1-5-32-544' -and $isAdmin) { 'true'; exit }",
|
|
34545
|
+
" 'false'",
|
|
34546
|
+
"} catch { 'false' }"
|
|
34547
|
+
].join("\n");
|
|
34548
|
+
return await new Promise((resolve2) => {
|
|
34549
|
+
let stdout = "";
|
|
34550
|
+
let settled = false;
|
|
34551
|
+
const settle = (value2) => {
|
|
34552
|
+
if (settled) return;
|
|
34553
|
+
settled = true;
|
|
34554
|
+
clearTimeout(timer);
|
|
34555
|
+
resolve2(value2);
|
|
34556
|
+
};
|
|
34557
|
+
const child = spawn7(powershell, ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
34558
|
+
windowsHide: true,
|
|
34559
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
34560
|
+
env: { ...process.env, LOCALAPP_VERIFY_DIR: layout.runtimeDir }
|
|
34561
|
+
});
|
|
34562
|
+
const timer = setTimeout(() => {
|
|
34563
|
+
child.kill();
|
|
34564
|
+
settle(false);
|
|
34565
|
+
}, VERIFY_TIMEOUT_MS);
|
|
34566
|
+
timer.unref?.();
|
|
34567
|
+
child.stdout?.setEncoding("utf8");
|
|
34568
|
+
child.stdout?.on("data", (chunk) => {
|
|
34569
|
+
stdout += chunk;
|
|
34570
|
+
});
|
|
34571
|
+
child.once("error", () => settle(false));
|
|
34572
|
+
child.once("close", () => settle(stdout.trim() === "true"));
|
|
34573
|
+
});
|
|
34574
|
+
}
|
|
34575
|
+
|
|
34119
34576
|
// packages/localapp/src/main.ts
|
|
34120
|
-
import
|
|
34577
|
+
import path34 from "node:path";
|
|
34121
34578
|
import fs29 from "node:fs";
|
|
34122
34579
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
34123
34580
|
async function runLocalApp(argv, io = defaultCliIo()) {
|
|
@@ -34127,7 +34584,7 @@ async function runLocalApp(argv, io = defaultCliIo()) {
|
|
|
34127
34584
|
io.stdout(`localapp ${await loadPackageVersion()}
|
|
34128
34585
|
`);
|
|
34129
34586
|
} else if (command.kind === "help") {
|
|
34130
|
-
io.stdout(
|
|
34587
|
+
io.stdout(renderHelp(command.topic));
|
|
34131
34588
|
} else if (command.kind === "login") {
|
|
34132
34589
|
return login(command, io);
|
|
34133
34590
|
} else if (command.kind === "logout") {
|
|
@@ -34135,7 +34592,7 @@ async function runLocalApp(argv, io = defaultCliIo()) {
|
|
|
34135
34592
|
} else if (command.kind === "whoami") {
|
|
34136
34593
|
return whoami(command, io);
|
|
34137
34594
|
} else if (command.kind === "init") {
|
|
34138
|
-
const name = command.name ??
|
|
34595
|
+
const name = command.name ?? path34.basename(process.cwd());
|
|
34139
34596
|
await initializeProject({ cwd: process.cwd(), name, skipInstall: command.skipInstall, skipDeploy: command.skipDeploy, io });
|
|
34140
34597
|
} else if (command.kind === "sync-template") {
|
|
34141
34598
|
const result = await syncManagedTemplate(process.cwd(), command);
|
|
@@ -34188,7 +34645,10 @@ async function runLocalApp(argv, io = defaultCliIo()) {
|
|
|
34188
34645
|
runtimeDir: process.env.LOCALAPP_RUNTIME_DIR,
|
|
34189
34646
|
dataDir: process.env.LOCALAPP_DATA_DIR
|
|
34190
34647
|
});
|
|
34191
|
-
const daemon = new LocalAppDaemon({
|
|
34648
|
+
const daemon = new LocalAppDaemon({
|
|
34649
|
+
layout,
|
|
34650
|
+
...layout.platform === "win32" ? { verifyWindowsCurrentUser: () => verifyWindowsRuntimeOwnership(layout) } : {}
|
|
34651
|
+
});
|
|
34192
34652
|
const stop = () => {
|
|
34193
34653
|
void daemon.stop().catch(() => void 0);
|
|
34194
34654
|
};
|
|
@@ -34203,6 +34663,7 @@ async function runLocalApp(argv, io = defaultCliIo()) {
|
|
|
34203
34663
|
writeStructuredError(io, {
|
|
34204
34664
|
code: error.code,
|
|
34205
34665
|
message: error.message,
|
|
34666
|
+
...error instanceof LocalAppArgumentError ? { hint: helpHint(argv) } : {},
|
|
34206
34667
|
...error instanceof LocalAppArgumentError && error.option !== void 0 ? { option: error.option } : {}
|
|
34207
34668
|
});
|
|
34208
34669
|
return 1;
|
|
@@ -34220,7 +34681,7 @@ function isMainModule(modulePath, invokedPath) {
|
|
|
34220
34681
|
try {
|
|
34221
34682
|
return fs29.realpathSync(modulePath) === fs29.realpathSync(invokedPath);
|
|
34222
34683
|
} catch {
|
|
34223
|
-
return
|
|
34684
|
+
return path34.resolve(modulePath) === path34.resolve(invokedPath);
|
|
34224
34685
|
}
|
|
34225
34686
|
}
|
|
34226
34687
|
export {
|