@publish.os/nextjs 0.0.1-alpha.8 → 0.0.1-alpha.90
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/compiler-assets/nextjs/defaults/app/globals.css +1 -0
- package/compiler-assets/nextjs/defaults/group/index.tsx +50 -0
- package/compiler-assets/nextjs/defaults/group/layout.tsx +7 -3
- package/compiler-assets/nextjs/defaults/group/page.tsx +35 -43
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +22 -11
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +1 -4
- package/compiler-assets/nextjs/defaults/root/css/animation.css +131 -0
- package/compiler-assets/nextjs/defaults/root/css/components/dialog.css +4 -1
- package/compiler-assets/nextjs/defaults/root/css/components/menu.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/components/navigation-menu.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/components/popover.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/components/select.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/components/tooltip.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/shadow.css +6 -25
- package/compiler-assets/nextjs/defaults/root/css/typography.css +51 -68
- package/compiler-assets/nextjs/defaults/root/globals.css +25 -0
- package/compiler-assets/nextjs/defaults/root/{page.tsx → index.tsx} +6 -2
- package/compiler-assets/nextjs/defaults/root/layout.tsx +7 -1
- package/compiler-assets/nextjs/defaults/root/theme.css +22 -22
- package/compiler-assets/nextjs/shims/generated-group-page.tsx +19 -2
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +16 -2
- package/compiler-assets/nextjs/shims/global-layout.tsx +11 -43
- package/compiler-assets/nextjs/shims/proxy.ts +21 -9
- package/compiler-assets/nextjs/shims/publish-os-theme-provider.tsx +76 -15
- package/compiler-assets/nextjs/shims/root-page.tsx +7 -1
- package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +34 -0
- package/compiler-assets/nextjs/shims/site-heading-level.tsx +14 -0
- package/compiler-assets/nextjs/shims/site-mdx-components.tsx +100 -0
- package/compiler-assets/nextjs/shims/site-mdx.tsx +12 -0
- package/compiler-assets/nextjs/shims/theme-defaults.css +41 -25
- package/dist/build-operation-2JAYBSKF.js +83 -0
- package/dist/button-CtzUJB8u.d.ts +11 -0
- package/dist/{button-CFdx-ohV.d.ts → button-c3WGnxIj.d.ts} +3 -3
- package/dist/chunk-535TM4A5.js +1455 -0
- package/dist/chunk-726GV2NF.js +2344 -0
- package/dist/chunk-7OGTPSKI.js +156 -0
- package/dist/chunk-AI2UULNX.js +9 -0
- package/dist/chunk-B2V22WRT.js +297 -0
- package/dist/chunk-DLDFHU7Y.js +191 -0
- package/dist/chunk-DWA3ZRGW.js +142 -0
- package/dist/chunk-GGKFQ3MA.js +621 -0
- package/dist/chunk-H6XILMZX.js +6154 -0
- package/dist/chunk-NECL5IBJ.js +318 -0
- package/dist/chunk-SVYGXXYR.js +36 -0
- package/dist/chunk-UF6ATARM.js +1100 -0
- package/dist/chunk-VO2I7MTM.js +56 -0
- package/dist/chunk-WDY4IK6Z.js +128 -0
- package/dist/chunk-WKTEO6RS.js +586 -0
- package/dist/chunk-YLTOLYWM.js +92 -0
- package/dist/compiler.d.ts +41 -7
- package/dist/compiler.js +48 -13143
- package/dist/compose-NN23UJGC.js +13 -0
- package/dist/config/createNextConfig.js +13 -0
- package/dist/dev-operation-TZDVJCN7.js +1055 -0
- package/dist/framework-selection-X4U6Y6QC.js +10 -0
- package/dist/ide-support-ZNW7ODFY.js +15 -0
- package/dist/index.d.ts +15 -3
- package/dist/kernel/components/blocks/AgentActions.js +71 -61
- package/dist/kernel/components/blocks/design-system-preview.d.ts +1 -1
- package/dist/kernel/components/blocks/design-system-preview.js +32 -13
- package/dist/kernel/components/blocks/link-playground.js +2 -2
- package/dist/kernel/components/blocks/logo-block.js +2 -2
- package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +10 -2
- package/dist/kernel/components/blocks/nav-breadcrumb.js +20 -5
- package/dist/kernel/components/blocks/navbar.d.ts +2 -2
- package/dist/kernel/components/blocks/navbar.js +401 -60
- package/dist/kernel/components/blocks/navigation-progress-playground.js +4 -4
- package/dist/kernel/components/blocks/navigation-progress.js +4 -1
- package/dist/kernel/components/blocks/next-prev.d.ts +1 -1
- package/dist/kernel/components/blocks/next-prev.js +11 -23
- package/dist/kernel/components/blocks/page-list.d.ts +1 -1
- package/dist/kernel/components/blocks/page-list.js +5 -4
- package/dist/kernel/components/blocks/search.d.ts +83 -58
- package/dist/kernel/components/blocks/search.js +553 -426
- package/dist/kernel/components/blocks/sidebar-node.d.ts +2 -2
- package/dist/kernel/components/blocks/sidebar-node.js +11 -9
- package/dist/kernel/components/blocks/sidebar.d.ts +3 -3
- package/dist/kernel/components/blocks/sidebar.js +18 -11
- package/dist/kernel/components/blocks/theme-toggle.d.ts +2 -2
- package/dist/kernel/components/blocks/theme-toggle.js +48 -2
- package/dist/kernel/components/blocks/toc.js +3 -3
- package/dist/kernel/components/mdx/components/blockquote.js +1 -1
- package/dist/kernel/components/mdx/components/callout.d.ts +5 -7
- package/dist/kernel/components/mdx/components/callout.js +66 -35
- package/dist/kernel/components/mdx/components/code-block.d.ts +5 -2
- package/dist/kernel/components/mdx/components/code-block.js +106 -5
- package/dist/kernel/components/mdx/components/copy-code-button.d.ts +8 -0
- package/dist/kernel/components/mdx/components/copy-code-button.js +60 -0
- package/dist/kernel/components/mdx/components/figure-caption.js +1 -1
- package/dist/kernel/components/mdx/components/figure.js +1 -1
- package/dist/kernel/components/mdx/components/heading-copy-link.js +3 -3
- package/dist/kernel/components/mdx/components/image-zoom.d.ts +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.js +1 -1
- package/dist/kernel/components/mdx/components/image.js +77 -56
- package/dist/kernel/components/mdx/components/inline-code.js +1 -1
- package/dist/kernel/components/mdx/components/kbd.d.ts +2 -2
- package/dist/kernel/components/mdx/components/kbd.js +3 -2
- package/dist/kernel/components/mdx/components/link.d.ts +35 -4
- package/dist/kernel/components/mdx/components/link.js +1 -1
- package/dist/kernel/components/mdx/components/paragraph.js +1 -4
- package/dist/kernel/components/mdx/components/task-list.js +1 -1
- package/dist/kernel/components/mdx/components/video-player.js +2 -2
- package/dist/kernel/components/mdx/components/video.js +1 -1
- package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
- package/dist/kernel/components/mdx/mdx.d.ts +12 -8
- package/dist/kernel/components/mdx/mdx.js +115 -39
- package/dist/kernel/components/mdx/rehype-heading-ids.js +1 -1
- package/dist/kernel/components/mdx/types.d.ts +1 -1
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +6 -23
- package/dist/kernel/components/ui/breadcrumb.d.ts +11 -3
- package/dist/kernel/components/ui/breadcrumb.js +6 -4
- package/dist/kernel/components/ui/button-group.d.ts +1 -1
- package/dist/kernel/components/ui/button-group.js +5 -4
- package/dist/kernel/components/ui/button.d.ts +2 -2
- package/dist/kernel/components/ui/button.js +6 -6
- package/dist/kernel/components/ui/card.d.ts +2 -2
- package/dist/kernel/components/ui/drawer.d.ts +3 -1
- package/dist/kernel/components/ui/drawer.js +5 -1
- package/dist/kernel/components/ui/input.d.ts +4 -4
- package/dist/kernel/components/ui/kbd.d.ts +1 -1
- package/dist/kernel/components/ui/kbd.js +9 -16
- package/dist/kernel/components/ui/link.d.ts +5 -3
- package/dist/kernel/components/ui/link.js +10 -9
- package/dist/kernel/components/ui/menu.js +5 -5
- package/dist/kernel/components/ui/mod-key.d.ts +10 -0
- package/dist/kernel/components/ui/mod-key.js +36 -0
- package/dist/kernel/components/ui/navigation-menu.js +2 -2
- package/dist/kernel/components/ui/progress.js +1 -1
- package/dist/kernel/components/ui/scroll-area.d.ts +8 -8
- package/dist/kernel/components/ui/scroll-area.js +4 -4
- package/dist/kernel/components/ui/select.js +7 -10
- package/dist/kernel/components/ui/text.d.ts +2 -2
- package/dist/kernel/components/ui/theme-toggle.d.ts +3 -3
- package/dist/kernel/components/ui/theme-toggle.js +4 -9
- package/dist/kernel/defaults.registry.d.ts +9 -9
- package/dist/kernel/defaults.registry.js +9 -9
- package/dist/kernel/routes/agent/markdown.d.ts +0 -1
- package/dist/kernel/routes/layouts/group.d.ts +1 -1
- package/dist/kernel/routes/metadata/feed.d.ts +1 -1
- package/dist/kernel/routes/metadata/feed.js +13 -9
- package/dist/kernel/routes/metadata/llms.d.ts +2 -1
- package/dist/kernel/routes/metadata/llms.js +4 -4
- package/dist/kernel/routes/metadata/robots.d.ts +1 -1
- package/dist/kernel/routes/metadata/robots.js +2 -2
- package/dist/kernel/routes/metadata/sitemap.d.ts +6 -3
- package/dist/kernel/routes/metadata/sitemap.js +48 -20
- package/dist/kernel/routes/pages/group.d.ts +1 -1
- package/dist/kernel/routes/pages/group.js +20 -12
- package/dist/kernel/routes/pages/leaf.d.ts +2 -2
- package/dist/kernel/routes/pages/leaf.js +20 -12
- package/dist/kernel/routes/pages/root.d.ts +2 -2
- package/dist/kernel/routes/pages/root.js +18 -12
- package/dist/resolvers/manifest-resolver.js +29 -6
- package/dist/search.d.ts +6 -7
- package/dist/search.js +47 -22
- package/dist/{sidebar-types-Bgchdfd6.d.ts → sidebar-types-DKpR27II.d.ts} +1 -1
- package/dist/{types-CIwwieNw.d.ts → types-BzkZty3r.d.ts} +23 -3
- package/dist/{types-DHBm7-j6.d.ts → types-CJWRG05y.d.ts} +20 -1
- package/dist/{types-B_b3C0U6.d.ts → types-CUtrppxt.d.ts} +8 -2
- package/dist/types.d.ts +14 -6
- package/dist/validate-local-source-XRL2Y7XE.js +14 -0
- package/dist/validate-publish-os-source-DAPZ4QGE.js +12 -0
- package/init/seed/minimal/.gitignore +1 -0
- package/init/seed/minimal/publish.os/assets/favicon/favicon.dark.png +0 -0
- package/init/seed/minimal/publish.os/assets/favicon/favicon.png +0 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +6 -10
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +1 -1
- package/init/seed/minimal/publish.os/docs/content/{theme.mdx → themes.mdx} +14 -12
- package/init/seed/minimal/publish.os/publish.os.config.json +3 -7
- package/init/seed/minimal/publish.os/theme.css +52 -24
- package/init/seed/minimal/publish.os/tsconfig.json +3 -0
- package/init/seed/minimal/seed.json +4 -1
- package/init/seed/scratch/publish.os/docs/content/get-started.mdx +6 -0
- package/init/seed/scratch/publish.os/publish.os.config.json +4 -0
- package/init/seed/scratch/seed.json +5 -0
- package/package.json +12 -26
- package/release/app/phosphor/package.json +3 -3
- package/release/app/phosphor/pnpm-lock.yaml.template +523 -360
- package/release/app/phosphor/pnpm-workspace.yaml +3 -0
- package/release/compiler/package.json +1 -1
- package/release/compiler/pnpm-lock.yaml.template +439 -286
- package/release/compiler/pnpm-workspace.yaml +3 -0
- package/release/release.json +7 -36
- package/compiler-assets/nextjs/defaults/group/leaf.tsx +0 -48
- package/dist/icons.d.ts +0 -1
- package/dist/icons.js +0 -2
- package/dist/kernel/components/mdx/components/pre.d.ts +0 -6
- package/dist/kernel/components/mdx/components/pre.js +0 -18
- package/dist/kernel/components/ui/meta-key.d.ts +0 -17
- package/dist/kernel/components/ui/meta-key.js +0 -9
- package/dist/kernel/framework-icons.d.ts +0 -1
- package/dist/kernel/framework-icons.js +0 -39
- package/dist/link-CYaCRDb6.d.ts +0 -35
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +0 -58
- package/dist/types-sM2g9nW0.d.ts +0 -12
- package/release/app/lucide/package.json +0 -30
- package/release/app/lucide/pnpm-lock.yaml.template +0 -2905
- package/release/app/lucide/pnpm-workspace.yaml +0 -11
- package/release/app/tabler/package.json +0 -30
- package/release/app/tabler/pnpm-lock.yaml.template +0 -2911
- package/release/app/tabler/pnpm-workspace.yaml +0 -11
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppError
|
|
3
|
+
} from "./chunk-WDY4IK6Z.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/compiler/lifecycle/local-process.ts
|
|
6
|
+
import { spawn as spawn2 } from "child_process";
|
|
7
|
+
import { delimiter, dirname } from "path";
|
|
8
|
+
|
|
9
|
+
// src/lib/compiler/lifecycle/windows-process.ts
|
|
10
|
+
import { spawn } from "child_process";
|
|
11
|
+
import { randomUUID } from "crypto";
|
|
12
|
+
import {
|
|
13
|
+
closeSync,
|
|
14
|
+
constants,
|
|
15
|
+
fstatSync,
|
|
16
|
+
lstatSync,
|
|
17
|
+
openSync,
|
|
18
|
+
readSync,
|
|
19
|
+
unlinkSync
|
|
20
|
+
} from "fs";
|
|
21
|
+
import { join, win32 } from "path";
|
|
22
|
+
var supervisor = String.raw`
|
|
23
|
+
$ErrorActionPreference = 'Stop'
|
|
24
|
+
[Console]::InputEncoding = [System.Text.UTF8Encoding]::new($false)
|
|
25
|
+
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
|
|
26
|
+
Add-Type -TypeDefinition @'
|
|
27
|
+
using System;
|
|
28
|
+
using System.ComponentModel;
|
|
29
|
+
using System.Diagnostics;
|
|
30
|
+
using System.IO;
|
|
31
|
+
using System.Linq;
|
|
32
|
+
using System.Runtime.InteropServices;
|
|
33
|
+
using System.Text;
|
|
34
|
+
using System.Threading;
|
|
35
|
+
using System.Threading.Tasks;
|
|
36
|
+
|
|
37
|
+
public static class PublishOsOwnedProcess {
|
|
38
|
+
const uint KillOnJobClose = 0x2000, UseStandardHandles = 0x100;
|
|
39
|
+
const uint CreateSuspended = 0x4, CreateUnicodeEnvironment = 0x400, ExtendedStartupInfoPresent = 0x80000;
|
|
40
|
+
const uint WaitTimeout = 258, StillActive = 259, CancelledExitCode = 143;
|
|
41
|
+
const uint GenericRead = 0x80000000, ShareReadWrite = 3, OpenExisting = 3, DuplicateSameAccess = 2;
|
|
42
|
+
const int BasicAccountingInformation = 1, ExtendedLimitInformation = 9;
|
|
43
|
+
const int JobListAttribute = 0x2000D, HandleListAttribute = 0x20002, StandardOutput = -11, StandardError = -12;
|
|
44
|
+
[StructLayout(LayoutKind.Sequential)] struct Limits {
|
|
45
|
+
public long ProcessTime, JobTime;
|
|
46
|
+
public uint Flags;
|
|
47
|
+
public UIntPtr MinWorkingSet, MaxWorkingSet;
|
|
48
|
+
public uint ActiveProcessLimit;
|
|
49
|
+
public UIntPtr Affinity;
|
|
50
|
+
public uint Priority, Scheduling;
|
|
51
|
+
}
|
|
52
|
+
[StructLayout(LayoutKind.Sequential)] struct IoCounters {
|
|
53
|
+
public ulong ReadCount, WriteCount, OtherCount, ReadBytes, WriteBytes, OtherBytes;
|
|
54
|
+
}
|
|
55
|
+
[StructLayout(LayoutKind.Sequential)] struct ExtendedLimits {
|
|
56
|
+
public Limits Basic;
|
|
57
|
+
public IoCounters Io;
|
|
58
|
+
public UIntPtr ProcessMemory, JobMemory, PeakProcessMemory, PeakJobMemory;
|
|
59
|
+
}
|
|
60
|
+
[StructLayout(LayoutKind.Sequential)] struct Accounting {
|
|
61
|
+
public long UserTime, KernelTime, PeriodUserTime, PeriodKernelTime;
|
|
62
|
+
public uint Faults, TotalProcesses, ActiveProcesses, TerminatedProcesses;
|
|
63
|
+
}
|
|
64
|
+
[StructLayout(LayoutKind.Sequential)] struct Startup {
|
|
65
|
+
public int Size;
|
|
66
|
+
public IntPtr Reserved, Desktop, Title;
|
|
67
|
+
public uint X, Y, Width, Height, XChars, YChars, Fill, Flags;
|
|
68
|
+
public ushort Show, ReservedSize;
|
|
69
|
+
public IntPtr ReservedData, Input, Output, Error;
|
|
70
|
+
}
|
|
71
|
+
[StructLayout(LayoutKind.Sequential)] struct ExtendedStartup {
|
|
72
|
+
public Startup Basic;
|
|
73
|
+
public IntPtr Attributes;
|
|
74
|
+
}
|
|
75
|
+
[StructLayout(LayoutKind.Sequential)] struct ProcessInfo {
|
|
76
|
+
public IntPtr Process, Thread;
|
|
77
|
+
public uint ProcessId, ThreadId;
|
|
78
|
+
}
|
|
79
|
+
[StructLayout(LayoutKind.Sequential)] struct Security {
|
|
80
|
+
public int Size;
|
|
81
|
+
public IntPtr Descriptor;
|
|
82
|
+
public int Inherit;
|
|
83
|
+
}
|
|
84
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern IntPtr CreateJobObjectW(IntPtr attributes, IntPtr name);
|
|
85
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool SetInformationJobObject(IntPtr job, int kind, ref ExtendedLimits value, uint size);
|
|
86
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool QueryInformationJobObject(IntPtr job, int kind, out Accounting value, uint size, IntPtr returned);
|
|
87
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateJobObject(IntPtr job, uint code);
|
|
88
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool InitializeProcThreadAttributeList(IntPtr list, int count, uint flags, ref IntPtr size);
|
|
89
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool UpdateProcThreadAttribute(IntPtr list, uint flags, IntPtr key, IntPtr value, IntPtr size, IntPtr previous, IntPtr returned);
|
|
90
|
+
[DllImport("kernel32.dll")] static extern void DeleteProcThreadAttributeList(IntPtr list);
|
|
91
|
+
[DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool CreateProcessW(string application, StringBuilder command, IntPtr processAttributes, IntPtr threadAttributes, bool inherit, uint flags, IntPtr environment, string directory, ref ExtendedStartup startup, out ProcessInfo process);
|
|
92
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern uint ResumeThread(IntPtr thread);
|
|
93
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern uint WaitForSingleObject(IntPtr handle, uint milliseconds);
|
|
94
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool GetExitCodeProcess(IntPtr process, out uint code);
|
|
95
|
+
[DllImport("kernel32.dll")] static extern IntPtr GetStdHandle(int kind);
|
|
96
|
+
[DllImport("kernel32.dll")] static extern IntPtr GetCurrentProcess();
|
|
97
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool DuplicateHandle(IntPtr sourceProcess, IntPtr source, IntPtr targetProcess, out IntPtr target, uint access, bool inherit, uint options);
|
|
98
|
+
[DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern IntPtr CreateFileW(string name, uint access, uint share, ref Security security, uint disposition, uint flags, IntPtr template);
|
|
99
|
+
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
100
|
+
|
|
101
|
+
static void Check(bool success) {
|
|
102
|
+
if (!success) throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
103
|
+
}
|
|
104
|
+
static string Quote(string value) {
|
|
105
|
+
if (value.IndexOf('\0') >= 0) throw new ArgumentException("A process argument contains a null character.");
|
|
106
|
+
var text = new StringBuilder("\"");
|
|
107
|
+
int slashes = 0;
|
|
108
|
+
foreach (char c in value) {
|
|
109
|
+
if (c == '\\') { slashes++; continue; }
|
|
110
|
+
text.Append('\\', c == '"' ? slashes * 2 + 1 : slashes);
|
|
111
|
+
text.Append(c);
|
|
112
|
+
slashes = 0;
|
|
113
|
+
}
|
|
114
|
+
return text.Append('\\', slashes * 2).Append('"').ToString();
|
|
115
|
+
}
|
|
116
|
+
static void StopJob(IntPtr job) {
|
|
117
|
+
Check(TerminateJobObject(job, CancelledExitCode));
|
|
118
|
+
var watch = Stopwatch.StartNew();
|
|
119
|
+
for (;;) {
|
|
120
|
+
Accounting value;
|
|
121
|
+
Check(QueryInformationJobObject(job, BasicAccountingInformation, out value, (uint)Marshal.SizeOf(typeof(Accounting)), IntPtr.Zero));
|
|
122
|
+
if (value.ActiveProcesses == 0) return;
|
|
123
|
+
if (watch.ElapsedMilliseconds >= 4000) throw new TimeoutException("A framework descendant did not stop.");
|
|
124
|
+
Thread.Sleep(20);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
public static int Run(string command, string[] args, string directory, string[] environment, string proof) {
|
|
128
|
+
IntPtr job = IntPtr.Zero, attributes = IntPtr.Zero, jobList = IntPtr.Zero;
|
|
129
|
+
IntPtr handles = IntPtr.Zero, input = IntPtr.Zero, output = IntPtr.Zero, error = IntPtr.Zero, env = IntPtr.Zero;
|
|
130
|
+
ProcessInfo process = new ProcessInfo();
|
|
131
|
+
bool initialized = false, stopAttempted = false;
|
|
132
|
+
try {
|
|
133
|
+
job = CreateJobObjectW(IntPtr.Zero, IntPtr.Zero);
|
|
134
|
+
Check(job != IntPtr.Zero);
|
|
135
|
+
var limits = new ExtendedLimits();
|
|
136
|
+
limits.Basic.Flags = KillOnJobClose; // No breakaway.
|
|
137
|
+
Check(SetInformationJobObject(job, ExtendedLimitInformation, ref limits, (uint)Marshal.SizeOf(typeof(ExtendedLimits))));
|
|
138
|
+
var security = new Security { Size = Marshal.SizeOf(typeof(Security)), Inherit = 1 };
|
|
139
|
+
input = CreateFileW("NUL", GenericRead, ShareReadWrite, ref security, OpenExisting, 0, IntPtr.Zero);
|
|
140
|
+
Check(input != new IntPtr(-1));
|
|
141
|
+
Check(DuplicateHandle(GetCurrentProcess(), GetStdHandle(StandardOutput), GetCurrentProcess(), out output, 0, true, DuplicateSameAccess));
|
|
142
|
+
Check(DuplicateHandle(GetCurrentProcess(), GetStdHandle(StandardError), GetCurrentProcess(), out error, 0, true, DuplicateSameAccess));
|
|
143
|
+
IntPtr size = IntPtr.Zero;
|
|
144
|
+
InitializeProcThreadAttributeList(IntPtr.Zero, 2, 0, ref size);
|
|
145
|
+
Check(size != IntPtr.Zero);
|
|
146
|
+
attributes = Marshal.AllocHGlobal(size);
|
|
147
|
+
Check(InitializeProcThreadAttributeList(attributes, 2, 0, ref size));
|
|
148
|
+
initialized = true;
|
|
149
|
+
jobList = Marshal.AllocHGlobal(IntPtr.Size);
|
|
150
|
+
Marshal.WriteIntPtr(jobList, job);
|
|
151
|
+
Check(UpdateProcThreadAttribute(attributes, 0, new IntPtr(JobListAttribute), jobList, new IntPtr(IntPtr.Size), IntPtr.Zero, IntPtr.Zero));
|
|
152
|
+
handles = Marshal.AllocHGlobal(IntPtr.Size * 3);
|
|
153
|
+
Marshal.WriteIntPtr(handles, 0, input);
|
|
154
|
+
Marshal.WriteIntPtr(handles, IntPtr.Size, output);
|
|
155
|
+
Marshal.WriteIntPtr(handles, IntPtr.Size * 2, error);
|
|
156
|
+
Check(UpdateProcThreadAttribute(attributes, 0, new IntPtr(HandleListAttribute), handles, new IntPtr(IntPtr.Size * 3), IntPtr.Zero, IntPtr.Zero));
|
|
157
|
+
env = Marshal.StringToHGlobalUni(String.Join("\0", environment.OrderBy(value => value, StringComparer.OrdinalIgnoreCase)) + "\0\0");
|
|
158
|
+
var startup = new ExtendedStartup();
|
|
159
|
+
startup.Basic.Size = Marshal.SizeOf(typeof(ExtendedStartup));
|
|
160
|
+
startup.Basic.Flags = UseStandardHandles;
|
|
161
|
+
startup.Basic.Input = input; startup.Basic.Output = output; startup.Basic.Error = error;
|
|
162
|
+
startup.Attributes = attributes;
|
|
163
|
+
var line = new StringBuilder(String.Join(" ", new[] { command }.Concat(args).Select(Quote)));
|
|
164
|
+
// JOB_LIST assigns ownership atomically, including a supervisor crash before ResumeThread.
|
|
165
|
+
Check(CreateProcessW(command, line, IntPtr.Zero, IntPtr.Zero, true, ExtendedStartupInfoPresent | CreateUnicodeEnvironment | CreateSuspended, env, directory, ref startup, out process));
|
|
166
|
+
File.WriteAllText(proof, "running");
|
|
167
|
+
Check(ResumeThread(process.Thread) != UInt32.MaxValue);
|
|
168
|
+
var stop = Task.Factory.StartNew(() => Console.ReadLine()); // A stop line or parent EOF cancels.
|
|
169
|
+
uint wait;
|
|
170
|
+
while ((wait = WaitForSingleObject(process.Process, 20)) == WaitTimeout && !stop.IsCompleted) {}
|
|
171
|
+
Check(wait != UInt32.MaxValue);
|
|
172
|
+
uint code;
|
|
173
|
+
Check(GetExitCodeProcess(process.Process, out code));
|
|
174
|
+
if (code == StillActive) code = CancelledExitCode;
|
|
175
|
+
CloseHandle(process.Thread); process.Thread = IntPtr.Zero;
|
|
176
|
+
CloseHandle(process.Process); process.Process = IntPtr.Zero;
|
|
177
|
+
stopAttempted = true;
|
|
178
|
+
StopJob(job);
|
|
179
|
+
File.WriteAllText(proof, "stopped:" + code);
|
|
180
|
+
return 0;
|
|
181
|
+
} catch (Exception failure) {
|
|
182
|
+
Console.Error.WriteLine("The framework process owner failed: " + failure.Message);
|
|
183
|
+
try {
|
|
184
|
+
if (stopAttempted) return 1;
|
|
185
|
+
if (process.Thread != IntPtr.Zero) { CloseHandle(process.Thread); process.Thread = IntPtr.Zero; }
|
|
186
|
+
if (process.Process != IntPtr.Zero) { CloseHandle(process.Process); process.Process = IntPtr.Zero; }
|
|
187
|
+
if (job != IntPtr.Zero) StopJob(job);
|
|
188
|
+
File.WriteAllText(proof, "stopped:1");
|
|
189
|
+
} catch { /* No completion proof: retain owned output and locks. */ }
|
|
190
|
+
return 1;
|
|
191
|
+
} finally {
|
|
192
|
+
// The job handle is never inherited. Closing the only handle kills all members.
|
|
193
|
+
if (job != IntPtr.Zero) CloseHandle(job);
|
|
194
|
+
if (process.Thread != IntPtr.Zero) CloseHandle(process.Thread);
|
|
195
|
+
if (process.Process != IntPtr.Zero) CloseHandle(process.Process);
|
|
196
|
+
if (input != IntPtr.Zero && input != new IntPtr(-1)) CloseHandle(input);
|
|
197
|
+
if (output != IntPtr.Zero) CloseHandle(output);
|
|
198
|
+
if (error != IntPtr.Zero) CloseHandle(error);
|
|
199
|
+
if (initialized) DeleteProcThreadAttributeList(attributes);
|
|
200
|
+
foreach (var memory in new[] { attributes, jobList, handles, env })
|
|
201
|
+
if (memory != IntPtr.Zero) Marshal.FreeHGlobal(memory);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
'@
|
|
206
|
+
$payload = ConvertFrom-Json ([Console]::ReadLine())
|
|
207
|
+
$environment = [string[]]@($payload.environment.PSObject.Properties | ForEach-Object { $_.Name + '=' + [string]$_.Value })
|
|
208
|
+
exit ([PublishOsOwnedProcess]::Run([string]$payload.command, [string[]]@($payload.args), [string]$payload.cwd, $environment, [string]$payload.proofPath))
|
|
209
|
+
`;
|
|
210
|
+
function startWindowsProcess(options) {
|
|
211
|
+
let systemRoot = Object.entries(options.environment).find(
|
|
212
|
+
([name]) => name.toUpperCase() === "SYSTEMROOT"
|
|
213
|
+
)?.[1];
|
|
214
|
+
if (!systemRoot || !win32.isAbsolute(systemRoot))
|
|
215
|
+
throw new AppError({
|
|
216
|
+
code: "FRAMEWORK_PROCESS_OWNER_UNAVAILABLE",
|
|
217
|
+
message: "Windows process ownership is unavailable. Check the SystemRoot environment variable."
|
|
218
|
+
});
|
|
219
|
+
let proofPath = join(options.cwd, `.publishos-process-${randomUUID()}`), child = spawn(
|
|
220
|
+
win32.join(systemRoot, "System32/WindowsPowerShell/v1.0/powershell.exe"),
|
|
221
|
+
[
|
|
222
|
+
"-NoLogo",
|
|
223
|
+
"-NoProfile",
|
|
224
|
+
"-NonInteractive",
|
|
225
|
+
"-EncodedCommand",
|
|
226
|
+
Buffer.from(supervisor, "utf16le").toString("base64")
|
|
227
|
+
],
|
|
228
|
+
{
|
|
229
|
+
cwd: options.cwd,
|
|
230
|
+
env: options.environment,
|
|
231
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
232
|
+
windowsHide: !0
|
|
233
|
+
}
|
|
234
|
+
), spawnError, isClosed = !1, hasExited = !1, exited = new Promise((resolve) => {
|
|
235
|
+
child.once("exit", () => {
|
|
236
|
+
hasExited = !0, resolve();
|
|
237
|
+
}), child.once("close", () => {
|
|
238
|
+
isClosed = !0, hasExited = !0, resolve();
|
|
239
|
+
}), child.once("error", (error) => {
|
|
240
|
+
spawnError = error, hasExited = !0, resolve();
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
child.stdin.on("error", () => {
|
|
244
|
+
}), child.stdin.write(`${JSON.stringify({ ...options, proofPath })}
|
|
245
|
+
`);
|
|
246
|
+
let readProof = () => {
|
|
247
|
+
try {
|
|
248
|
+
let identity = lstatSync(proofPath);
|
|
249
|
+
if (!identity.isFile() || identity.isSymbolicLink() || identity.size > 64)
|
|
250
|
+
throw failure();
|
|
251
|
+
let file = openSync(
|
|
252
|
+
proofPath,
|
|
253
|
+
constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK
|
|
254
|
+
);
|
|
255
|
+
try {
|
|
256
|
+
let current = fstatSync(file);
|
|
257
|
+
if (!current.isFile() || current.dev !== identity.dev || current.ino !== identity.ino || current.size > 64)
|
|
258
|
+
throw failure();
|
|
259
|
+
let bytes = Buffer.alloc(65), count = readSync(file, bytes, 0, bytes.length, 0);
|
|
260
|
+
if (count > 64) throw failure();
|
|
261
|
+
return bytes.subarray(0, count).toString("utf8");
|
|
262
|
+
} finally {
|
|
263
|
+
closeSync(file);
|
|
264
|
+
}
|
|
265
|
+
} catch (error) {
|
|
266
|
+
if (error.code !== "ENOENT") throw error;
|
|
267
|
+
return "";
|
|
268
|
+
}
|
|
269
|
+
}, failure = () => new AppError({
|
|
270
|
+
code: "FRAMEWORK_PROCESS_SHUTDOWN_FAILED",
|
|
271
|
+
message: "A framework descendant did not stop. Owned staging and locks remain for safe recovery."
|
|
272
|
+
}), stopped, rejectStop = () => {
|
|
273
|
+
}, stopFailure = new Promise((_, reject) => {
|
|
274
|
+
rejectStop = reject;
|
|
275
|
+
}), stop = () => (stopped ??= (async () => {
|
|
276
|
+
let deadline = Date.now() + 4750;
|
|
277
|
+
for (hasExited || child.stdin.end(`stop
|
|
278
|
+
`); !isClosed && !(spawnError && !child.pid); ) {
|
|
279
|
+
if (Date.now() >= deadline)
|
|
280
|
+
throw child.kill("SIGKILL"), failure();
|
|
281
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
282
|
+
}
|
|
283
|
+
if (!(spawnError && !child.pid) && !/^stopped:\d+$/.test(readProof()))
|
|
284
|
+
throw failure();
|
|
285
|
+
})(), stopped.catch(rejectStop), stopped), startupDeadline = Date.now() + 3e4, startup = setInterval(() => {
|
|
286
|
+
try {
|
|
287
|
+
hasExited || readProof() ? clearInterval(startup) : Date.now() >= startupDeadline && (clearInterval(startup), stop().catch(() => {
|
|
288
|
+
}));
|
|
289
|
+
} catch (error) {
|
|
290
|
+
clearInterval(startup), stop().catch(() => {
|
|
291
|
+
}), rejectStop(error);
|
|
292
|
+
}
|
|
293
|
+
}, 20), completion = (async () => {
|
|
294
|
+
try {
|
|
295
|
+
if (await Promise.race([exited, stopFailure]), await stop(), spawnError) throw spawnError;
|
|
296
|
+
let code = Number(readProof().slice(8));
|
|
297
|
+
return unlinkSync(proofPath), code;
|
|
298
|
+
} finally {
|
|
299
|
+
clearInterval(startup);
|
|
300
|
+
}
|
|
301
|
+
})();
|
|
302
|
+
return completion.catch(() => {
|
|
303
|
+
}), { child, completion, stop };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// src/lib/compiler/lifecycle/local-process.ts
|
|
307
|
+
function localProcessEnvironment({
|
|
308
|
+
mode
|
|
309
|
+
}) {
|
|
310
|
+
let environment = Object.fromEntries(
|
|
311
|
+
Object.entries(process.env).filter(
|
|
312
|
+
([name, value]) => value !== void 0 && !/^(?:NODE_(?:OPTIONS|PATH|ENV)|NEXT_TELEMETRY_DISABLED)$/i.test(
|
|
313
|
+
name
|
|
314
|
+
) && // Cache locations do not change the frozen dependency or install policy.
|
|
315
|
+
(!/^(?:npm_config_|PNPM_|COREPACK_|PUBLISH_OS_|PUBLISHOS_)/i.test(
|
|
316
|
+
name
|
|
317
|
+
) || /^PNPM_CONFIG_(?:STORE|CACHE)_DIR$/i.test(name))
|
|
318
|
+
)
|
|
319
|
+
), inheritedPath = environment.PATH;
|
|
320
|
+
if (process.platform === "win32")
|
|
321
|
+
for (let name of Object.keys(environment))
|
|
322
|
+
name.toUpperCase() === "PATH" && (inheritedPath = environment[name], delete environment[name]);
|
|
323
|
+
return environment.PATH = [
|
|
324
|
+
dirname(process.execPath),
|
|
325
|
+
...(inheritedPath ?? "").split(delimiter).filter(
|
|
326
|
+
(path) => path && !/[\\/]node_modules[\\/]\.bin(?:[\\/]|$)/.test(path)
|
|
327
|
+
)
|
|
328
|
+
].join(delimiter), { ...environment, NODE_ENV: mode, NEXT_TELEMETRY_DISABLED: "1" };
|
|
329
|
+
}
|
|
330
|
+
var LocalProcessError = class extends AppError {
|
|
331
|
+
output;
|
|
332
|
+
constructor({ output }) {
|
|
333
|
+
super({
|
|
334
|
+
code: "FRAMEWORK_PROCESS_FAILED",
|
|
335
|
+
message: "A required framework process failed. Review the process output and correct the reported error."
|
|
336
|
+
}), this.output = output;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
function startLocalProcess(options) {
|
|
340
|
+
options.signal.throwIfAborted();
|
|
341
|
+
let grouped = process.platform !== "win32", environment = options.environment ?? localProcessEnvironment({ mode: "production" }), windows = grouped ? void 0 : startWindowsProcess({
|
|
342
|
+
command: options.command,
|
|
343
|
+
args: options.args,
|
|
344
|
+
cwd: options.cwd,
|
|
345
|
+
environment
|
|
346
|
+
}), child = windows?.child ?? spawn2(options.command, options.args, {
|
|
347
|
+
cwd: options.cwd,
|
|
348
|
+
env: environment,
|
|
349
|
+
detached: grouped,
|
|
350
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
351
|
+
}), stdout = "", stderr = "";
|
|
352
|
+
child.stdout.on("data", (chunk) => {
|
|
353
|
+
let value = chunk.toString();
|
|
354
|
+
stdout = (stdout + value).slice(-64e3), options.quiet || process.stdout.write(value), options.onStdout?.(value);
|
|
355
|
+
}), child.stderr.on("data", (chunk) => {
|
|
356
|
+
let value = chunk.toString();
|
|
357
|
+
stderr = (stderr + value).slice(-64e3), options.quiet || process.stderr.write(value), options.onStderr?.(value);
|
|
358
|
+
});
|
|
359
|
+
let spawnError, exited = new Promise((resolve) => {
|
|
360
|
+
child.once("error", (error) => {
|
|
361
|
+
spawnError = error, resolve(null);
|
|
362
|
+
}), child.once("exit", resolve), child.once("close", resolve);
|
|
363
|
+
}), closed = new Promise((resolve) => {
|
|
364
|
+
child.once("close", () => resolve());
|
|
365
|
+
}), stopped, shutdownProved = !1, rejectStop = () => {
|
|
366
|
+
}, stopFailure = new Promise((_, reject) => {
|
|
367
|
+
rejectStop = reject;
|
|
368
|
+
}), signalError, shutdownFailure = (cause = signalError) => new AppError({
|
|
369
|
+
code: "FRAMEWORK_PROCESS_SHUTDOWN_FAILED",
|
|
370
|
+
message: "A framework descendant did not stop. Owned staging and locks remain for safe recovery.",
|
|
371
|
+
details: { cause }
|
|
372
|
+
}), killGroup = (signal) => {
|
|
373
|
+
if (child.pid)
|
|
374
|
+
try {
|
|
375
|
+
process.kill(-child.pid, signal);
|
|
376
|
+
} catch (error) {
|
|
377
|
+
if (error.code === "ESRCH") return;
|
|
378
|
+
if (error.code === "EPERM") {
|
|
379
|
+
signalError = error;
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
throw shutdownFailure(error);
|
|
383
|
+
}
|
|
384
|
+
}, groupExists = () => {
|
|
385
|
+
if (!child.pid) return !1;
|
|
386
|
+
try {
|
|
387
|
+
return process.kill(-child.pid, 0), !0;
|
|
388
|
+
} catch (error) {
|
|
389
|
+
if (error.code === "ESRCH") return !1;
|
|
390
|
+
if (error.code === "EPERM")
|
|
391
|
+
return signalError = error, !0;
|
|
392
|
+
throw shutdownFailure(error);
|
|
393
|
+
}
|
|
394
|
+
}, stop = () => windows ? windows.stop().then(() => {
|
|
395
|
+
shutdownProved = !0;
|
|
396
|
+
}) : (stopped ??= (async () => {
|
|
397
|
+
let deadline = Date.now() + 4e3;
|
|
398
|
+
if (grouped) {
|
|
399
|
+
killGroup("SIGTERM");
|
|
400
|
+
let forced = !1;
|
|
401
|
+
for (; groupExists(); ) {
|
|
402
|
+
if (!forced && Date.now() >= deadline - 750 && (killGroup("SIGKILL"), forced = !0), Date.now() >= deadline) throw shutdownFailure();
|
|
403
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
let timer;
|
|
407
|
+
try {
|
|
408
|
+
await Promise.race([
|
|
409
|
+
closed,
|
|
410
|
+
new Promise((_, reject) => {
|
|
411
|
+
timer = setTimeout(
|
|
412
|
+
() => reject(shutdownFailure()),
|
|
413
|
+
Math.max(0, deadline - Date.now())
|
|
414
|
+
);
|
|
415
|
+
})
|
|
416
|
+
]);
|
|
417
|
+
} finally {
|
|
418
|
+
clearTimeout(timer);
|
|
419
|
+
}
|
|
420
|
+
shutdownProved = !0;
|
|
421
|
+
})(), stopped.catch(rejectStop), stopped), unregister = options.onShutdown(stop), abort = () => {
|
|
422
|
+
stop().catch(() => {
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
options.signal.addEventListener("abort", abort, { once: !0 }), options.signal.aborted && abort();
|
|
426
|
+
let completion = (async () => {
|
|
427
|
+
try {
|
|
428
|
+
let code = await Promise.race([
|
|
429
|
+
windows?.completion ?? exited,
|
|
430
|
+
stopFailure
|
|
431
|
+
]);
|
|
432
|
+
if (await stop(), options.signal.throwIfAborted(), spawnError || code !== 0)
|
|
433
|
+
throw new LocalProcessError({ output: `${stdout}
|
|
434
|
+
${stderr}` });
|
|
435
|
+
return { stdout, stderr };
|
|
436
|
+
} finally {
|
|
437
|
+
options.signal.removeEventListener("abort", abort), shutdownProved && unregister();
|
|
438
|
+
}
|
|
439
|
+
})();
|
|
440
|
+
return completion.catch(() => {
|
|
441
|
+
}), { completion, stop };
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// src/lib/compiler/lifecycle/local-app.ts
|
|
445
|
+
import { lstat, readFile, realpath, symlink, unlink } from "fs/promises";
|
|
446
|
+
import { isAbsolute, join as join2 } from "path";
|
|
447
|
+
import { stripVTControlCharacters } from "util";
|
|
448
|
+
function missingOfflinePackage(error) {
|
|
449
|
+
if (!(error instanceof LocalProcessError)) return;
|
|
450
|
+
let output = stripVTControlCharacters(error.output), uncheckedVersion = output.match(
|
|
451
|
+
/((?:@[a-z0-9._-]+\/)?[a-z0-9._-]+)@[^\s]+ could not be checked against\s+minimumReleaseAge \(version not present in registry manifest\)/iu
|
|
452
|
+
)?.[1];
|
|
453
|
+
if (uncheckedVersion) return `registry metadata for ${uncheckedVersion}`;
|
|
454
|
+
if (/ERR_PNPM_NO_OFFLINE_META\b/.test(output)) {
|
|
455
|
+
let name = output.match(
|
|
456
|
+
/Failed to resolve ((?:@[a-z0-9._-]+\/)?[a-z0-9._-]+)/iu
|
|
457
|
+
)?.[1];
|
|
458
|
+
if (name) return `registry metadata for ${name}`;
|
|
459
|
+
}
|
|
460
|
+
let line = output.split(/\r?\n/u).find(
|
|
461
|
+
(value) => /ERR_PNPM_(?:NO_OFFLINE_TARBALL|NO_OFFLINE_META)\b/.test(value)
|
|
462
|
+
);
|
|
463
|
+
if (!line) return;
|
|
464
|
+
let safeLine = line.slice(0, 1024);
|
|
465
|
+
return output.match(
|
|
466
|
+
/https:\/\/registry\.npmjs\.org\/[A-Za-z0-9@%_./~-]+/
|
|
467
|
+
)?.[0]?.replace(/\.+$/u, "") ?? safeLine;
|
|
468
|
+
}
|
|
469
|
+
async function installLocalApp({
|
|
470
|
+
outputDir,
|
|
471
|
+
framework,
|
|
472
|
+
options,
|
|
473
|
+
lifetime,
|
|
474
|
+
purpose,
|
|
475
|
+
assertInstallGraph
|
|
476
|
+
}) {
|
|
477
|
+
let publicCommand = options.request.operation === "validate" ? "init" : options.request.operation, command = options.request.context?.pnpmExecutable;
|
|
478
|
+
if (typeof command != "string" || !isAbsolute(command))
|
|
479
|
+
throw new AppError({
|
|
480
|
+
code: "FRAMEWORK_PNPM_MISSING",
|
|
481
|
+
message: `Supply the exact pnpm ${framework.release.pnpm} executable from the installed CLI.`
|
|
482
|
+
});
|
|
483
|
+
let environment = localProcessEnvironment({
|
|
484
|
+
mode: options.request.operation === "dev" ? "development" : "production"
|
|
485
|
+
}), run = async ({
|
|
486
|
+
args,
|
|
487
|
+
quiet = !1,
|
|
488
|
+
timeoutMs
|
|
489
|
+
}) => {
|
|
490
|
+
let deadline = new AbortController(), timeout = timeoutMs === void 0 ? void 0 : setTimeout(() => {
|
|
491
|
+
deadline.abort(
|
|
492
|
+
new AppError({
|
|
493
|
+
code: "FRAMEWORK_DEPENDENCY_DOWNLOAD_FAILED",
|
|
494
|
+
message: `Preparing the locked app dependencies for ${framework.packageName}@${framework.version} exceeded ${timeoutMs / 1e3} seconds.`
|
|
495
|
+
})
|
|
496
|
+
);
|
|
497
|
+
}, timeoutMs);
|
|
498
|
+
try {
|
|
499
|
+
return await startLocalProcess({
|
|
500
|
+
command,
|
|
501
|
+
args,
|
|
502
|
+
cwd: outputDir,
|
|
503
|
+
environment,
|
|
504
|
+
signal: timeoutMs === void 0 ? lifetime.signal : AbortSignal.any([lifetime.signal, deadline.signal]),
|
|
505
|
+
onShutdown: lifetime.onShutdown,
|
|
506
|
+
quiet
|
|
507
|
+
}).completion;
|
|
508
|
+
} finally {
|
|
509
|
+
clearTimeout(timeout);
|
|
510
|
+
}
|
|
511
|
+
}, version;
|
|
512
|
+
try {
|
|
513
|
+
version = (await run({ args: ["--version"], quiet: !0, timeoutMs: 1e4 })).stdout.trim();
|
|
514
|
+
} catch (error) {
|
|
515
|
+
throw error instanceof AppError && error.code === "FRAMEWORK_PROCESS_SHUTDOWN_FAILED" ? error : (lifetime.signal.throwIfAborted(), new AppError({
|
|
516
|
+
code: "FRAMEWORK_PNPM_MISSING",
|
|
517
|
+
message: `The required pnpm ${framework.release.pnpm} executable could not run.`
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
if (version !== framework.release.pnpm)
|
|
521
|
+
throw new AppError({
|
|
522
|
+
code: "FRAMEWORK_PNPM_UNSUPPORTED",
|
|
523
|
+
message: `The selected framework requires pnpm ${framework.release.pnpm}; the supplied executable reports ${version || "no version"}.`
|
|
524
|
+
});
|
|
525
|
+
let lockPath = join2(outputDir, "pnpm-lock.yaml"), lock = await readFile(lockPath);
|
|
526
|
+
options.onEvent?.({
|
|
527
|
+
type: "progress",
|
|
528
|
+
message: purpose === "ide" ? "Preparing IDE dependencies" : "Preparing app dependencies"
|
|
529
|
+
});
|
|
530
|
+
try {
|
|
531
|
+
await run({
|
|
532
|
+
args: ["install", "--frozen-lockfile", "--offline"],
|
|
533
|
+
quiet: !0,
|
|
534
|
+
timeoutMs: 12e4
|
|
535
|
+
});
|
|
536
|
+
} catch (error) {
|
|
537
|
+
if (error instanceof AppError && error.code === "FRAMEWORK_PROCESS_SHUTDOWN_FAILED")
|
|
538
|
+
throw error;
|
|
539
|
+
lifetime.signal.throwIfAborted();
|
|
540
|
+
let missing = missingOfflinePackage(error);
|
|
541
|
+
if (!missing)
|
|
542
|
+
throw error instanceof LocalProcessError && error.output.trim() && process.stderr.write(error.output), error;
|
|
543
|
+
options.onEvent?.({
|
|
544
|
+
type: "progress",
|
|
545
|
+
message: `Downloading missing ${purpose === "ide" ? "IDE" : "app"} dependencies`
|
|
546
|
+
}), await assertInstallGraph?.();
|
|
547
|
+
try {
|
|
548
|
+
await run({
|
|
549
|
+
args: ["install", "--frozen-lockfile", "--fetch-timeout=10000"],
|
|
550
|
+
quiet: options.request.operation !== "build",
|
|
551
|
+
timeoutMs: 12e4
|
|
552
|
+
});
|
|
553
|
+
} catch (downloadError) {
|
|
554
|
+
throw downloadError instanceof AppError && downloadError.code === "FRAMEWORK_PROCESS_SHUTDOWN_FAILED" || (lifetime.signal.throwIfAborted(), !(downloadError instanceof LocalProcessError) && !(downloadError instanceof AppError && downloadError.code === "FRAMEWORK_DEPENDENCY_DOWNLOAD_FAILED")) ? downloadError : new AppError({
|
|
555
|
+
code: "FRAMEWORK_DEPENDENCY_DOWNLOAD_FAILED",
|
|
556
|
+
message: `The locked app dependency ${missing} could not be downloaded for ${framework.packageName}@${framework.version}. Connect to the network and run publish.os ${publicCommand} again.`
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (await assertInstallGraph?.(), !(await readFile(lockPath)).equals(lock))
|
|
561
|
+
throw new AppError({
|
|
562
|
+
code: "FRAMEWORK_RELEASE_INVALID",
|
|
563
|
+
message: "App installation changed the released lock. The output was not published."
|
|
564
|
+
});
|
|
565
|
+
if (options.request.context?.framework?.kind === "checkout") {
|
|
566
|
+
let link = join2(outputDir, "node_modules/@publish.os/nextjs");
|
|
567
|
+
if (!(await lstat(link)).isSymbolicLink() || await realpath(link) !== await realpath(framework.packageRoot))
|
|
568
|
+
throw new AppError({
|
|
569
|
+
code: "FRAMEWORK_SELECTION_INVALID",
|
|
570
|
+
message: "The installed checkout link does not match the selected framework."
|
|
571
|
+
});
|
|
572
|
+
await unlink(link), await symlink(
|
|
573
|
+
framework.packageRoot,
|
|
574
|
+
link,
|
|
575
|
+
process.platform === "win32" ? "junction" : "dir"
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
return { run: (args) => run({ args }) };
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export {
|
|
582
|
+
localProcessEnvironment,
|
|
583
|
+
LocalProcessError,
|
|
584
|
+
startLocalProcess,
|
|
585
|
+
installLocalApp
|
|
586
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// src/lib/hosting/framework-paths.ts
|
|
2
|
+
var FRAMEWORK_PREFIX = "/publishos", ASSET_PREFIX = `${FRAMEWORK_PREFIX}/assets`, SITE_API_PREFIX = `${FRAMEWORK_PREFIX}/api`, PAGEFIND_PREFIX = `${ASSET_PREFIX}/pagefind`, PAGEFIND_MODULE_URL = `${PAGEFIND_PREFIX}/pagefind.js`, PAGEFIND_ENTRY_URL = `${PAGEFIND_PREFIX}/pagefind-entry.json`, IMAGE_OPTIMIZER_PATH = `${SITE_API_PREFIX}/image`, NEXT_IMAGE_OPTIMIZER_PATH = "/_next/image", OG_SERVICE_PREFIX = `${SITE_API_PREFIX}/og`, PUBLIC_ASSET_DIRECTORY = "publishos/assets", PUBLIC_FONT_DIRECTORY = `${PUBLIC_ASSET_DIRECTORY}/_publishos/fonts`, PUBLIC_PAGEFIND_DIRECTORY = `public/${PUBLIC_ASSET_DIRECTORY}/pagefind`, FRAMEWORK_PROXY_MATCHER = `/((?!${FRAMEWORK_PREFIX.slice(1)}(?:/|$)|_next/static|_next/image|_next/webpack-hmr).*)`;
|
|
3
|
+
function isFrameworkNamespacePath(pathname) {
|
|
4
|
+
return pathname === FRAMEWORK_PREFIX || pathname.startsWith(`${FRAMEWORK_PREFIX}/`);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// src/lib/compiler/internal/path-containment.ts
|
|
8
|
+
import * as systemPath from "path";
|
|
9
|
+
function relativePath(parent, child, pathImplementation) {
|
|
10
|
+
return pathImplementation.relative(
|
|
11
|
+
pathImplementation.resolve(parent),
|
|
12
|
+
pathImplementation.resolve(child)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
function isContainedRelativePath(path, pathImplementation) {
|
|
16
|
+
return !pathImplementation.isAbsolute(path) && path !== ".." && !path.startsWith(`..${pathImplementation.sep}`);
|
|
17
|
+
}
|
|
18
|
+
function isSameOrDescendant(parent, child, pathImplementation = systemPath) {
|
|
19
|
+
let path = relativePath(parent, child, pathImplementation);
|
|
20
|
+
return path === "" || isContainedRelativePath(path, pathImplementation);
|
|
21
|
+
}
|
|
22
|
+
function isDescendant(parent, child, pathImplementation = systemPath) {
|
|
23
|
+
let path = relativePath(parent, child, pathImplementation);
|
|
24
|
+
return path !== "" && isContainedRelativePath(path, pathImplementation);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/lib/compiler/source/source-paths.ts
|
|
28
|
+
function isExcludedSourcePath(relativePath2) {
|
|
29
|
+
let segments = relativePath2.split(/[\\/]/);
|
|
30
|
+
return relativePath2 === "tsconfig.json" || segments[0] === ".publish.os" || segments.includes("publish.os");
|
|
31
|
+
}
|
|
32
|
+
var ROOT_FILES = /* @__PURE__ */ new Set(["publish.os.config.json", "tsconfig.json"]), RENDERER_FILES = /* @__PURE__ */ new Set([
|
|
33
|
+
"layout.tsx",
|
|
34
|
+
"index.tsx",
|
|
35
|
+
"page.tsx",
|
|
36
|
+
"(index)/layout.tsx",
|
|
37
|
+
"(index)/index.tsx",
|
|
38
|
+
"(page)/layout.tsx",
|
|
39
|
+
"(page)/page.tsx"
|
|
40
|
+
]), ROOT_DIRECTORIES = ["public/", "assets/", "components/", "content/"], RESERVED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
41
|
+
"app",
|
|
42
|
+
"pages",
|
|
43
|
+
"node_modules",
|
|
44
|
+
".publish.os",
|
|
45
|
+
"[...slug]"
|
|
46
|
+
]), RESERVED_FILES = /* @__PURE__ */ new Set([
|
|
47
|
+
"postcss.config.js",
|
|
48
|
+
"postcss.config.mjs",
|
|
49
|
+
"postcss.config.cjs"
|
|
50
|
+
]), FRAMEWORK_BOUNDARY_FILE_PATTERNS = [
|
|
51
|
+
/^middleware\.[cm]?[jt]sx?$/,
|
|
52
|
+
/^route\.[cm]?[jt]sx?$/,
|
|
53
|
+
/^instrumentation(?:\.[\w-]+)?\.[cm]?[jt]sx?$/,
|
|
54
|
+
/^proxy\.[cm]?[jt]sx?$/,
|
|
55
|
+
/^next\.config\./
|
|
56
|
+
];
|
|
57
|
+
function isFrameworkBoundaryFile(name) {
|
|
58
|
+
return FRAMEWORK_BOUNDARY_FILE_PATTERNS.some((pattern) => pattern.test(name));
|
|
59
|
+
}
|
|
60
|
+
function isReservedFrameworkPath(path) {
|
|
61
|
+
let segments = path.split("/"), name = segments.at(-1) ?? path;
|
|
62
|
+
return segments.some((segment) => RESERVED_DIRECTORIES.has(segment)) || RESERVED_FILES.has(name) || isFrameworkBoundaryFile(name) || /^(?:loading|error|not-found)\.[cm]?[jt]sx?$/.test(name);
|
|
63
|
+
}
|
|
64
|
+
function isSourceCssPath(path) {
|
|
65
|
+
return path.endsWith(".css") && (!path.includes("/") || path.startsWith("css/"));
|
|
66
|
+
}
|
|
67
|
+
function isApprovedGroupPath(path, folder) {
|
|
68
|
+
if (!folder || !path.startsWith(`${folder}/`)) return !1;
|
|
69
|
+
let localPath = path.slice(folder.length + 1), groupName = folder.split("/").at(-1)?.replace(/^\((.*)\)$/, "$1");
|
|
70
|
+
return localPath === `${groupName}.config.json` || RENDERER_FILES.has(localPath) || isSourceCssPath(localPath) || localPath.startsWith("content/");
|
|
71
|
+
}
|
|
72
|
+
function isApprovedPublishOsPath(path, groupFolders) {
|
|
73
|
+
return ROOT_FILES.has(path) || RENDERER_FILES.has(path) || isSourceCssPath(path) || ROOT_DIRECTORIES.some((directory) => path.startsWith(directory)) || [...groupFolders].some((folder) => isApprovedGroupPath(path, folder));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
FRAMEWORK_PREFIX,
|
|
78
|
+
ASSET_PREFIX,
|
|
79
|
+
IMAGE_OPTIMIZER_PATH,
|
|
80
|
+
NEXT_IMAGE_OPTIMIZER_PATH,
|
|
81
|
+
OG_SERVICE_PREFIX,
|
|
82
|
+
PUBLIC_ASSET_DIRECTORY,
|
|
83
|
+
PUBLIC_FONT_DIRECTORY,
|
|
84
|
+
PUBLIC_PAGEFIND_DIRECTORY,
|
|
85
|
+
FRAMEWORK_PROXY_MATCHER,
|
|
86
|
+
isFrameworkNamespacePath,
|
|
87
|
+
isSameOrDescendant,
|
|
88
|
+
isDescendant,
|
|
89
|
+
isExcludedSourcePath,
|
|
90
|
+
isReservedFrameworkPath,
|
|
91
|
+
isApprovedPublishOsPath
|
|
92
|
+
};
|