@adea-ai/app-framework 0.27.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +177 -15
- package/dist/app/create-application.d.ts +2 -0
- package/dist/app/create-application.js +6 -0
- package/dist/app/service-registry.js +4 -0
- package/dist/appearance/custom-theme-import.js +43 -7
- package/dist/appearance/custom-theme-library.d.ts +2 -0
- package/dist/appearance/custom-theme-library.js +5 -1
- package/dist/appearance/theme-record-adapter.js +4 -2
- package/dist/appearance/theme-registry.js +7 -1
- package/dist/cli/cli-runner.d.ts +4 -0
- package/dist/cli/cli-runner.js +14 -1
- package/dist/cli/create-application-cli.js +4 -2
- package/dist/cli/release-cut-cli.js +2 -2
- package/dist/cli/update-helper-cli.js +28 -6
- package/dist/desktop/client-asset-manifest.d.ts +47 -0
- package/dist/desktop/client-asset-manifest.js +114 -0
- package/dist/desktop/client-asset-stream.d.ts +10 -0
- package/dist/desktop/client-asset-stream.js +138 -33
- package/dist/desktop/client-assets.d.ts +20 -0
- package/dist/desktop/client-assets.js +132 -22
- package/dist/desktop/client-response-lifecycle.d.ts +22 -0
- package/dist/desktop/client-response-lifecycle.js +233 -0
- package/dist/desktop/desktop-host.d.ts +40 -2
- package/dist/desktop/desktop-host.js +159 -9
- package/dist/framework-source.json +1 -1
- package/dist/installer/command-artifact.d.ts +4 -2
- package/dist/installer/command-artifact.js +119 -19
- package/dist/installer/linux-process-group.d.ts +13 -0
- package/dist/installer/linux-process-group.js +58 -0
- package/dist/native/darwin-sync.d.ts +7 -0
- package/dist/native/darwin-sync.js +43 -0
- package/dist/native/desktop-build-hook.js +7 -0
- package/dist/native/directory-exchange.d.ts +10 -0
- package/dist/native/directory-exchange.js +90 -0
- package/dist/native/electrobun-source-patch.d.ts +5 -0
- package/dist/native/electrobun-source-patch.js +19 -1
- package/dist/native/posix-launcher-build.d.ts +24 -0
- package/dist/native/posix-launcher-build.js +232 -0
- package/dist/native/posix-tree-removal.d.ts +36 -0
- package/dist/native/posix-tree-removal.js +425 -0
- package/dist/release/feed-release-cut.js +30 -10
- package/dist/release/github-release-cut.js +16 -0
- package/dist/release/release-cut.d.ts +8 -1
- package/dist/release/release-cut.js +9 -1
- package/dist/update-helper.bundle.js +1483 -105
- package/dist/updates/channel-update-manager.d.ts +5 -0
- package/dist/updates/channel-update-manager.js +13 -1
- package/dist/updates/desktop-updater.d.ts +78 -2
- package/dist/updates/desktop-updater.js +320 -37
- package/dist/updates/launch-environment.d.ts +2 -0
- package/dist/updates/launch-environment.js +4 -0
- package/dist/updates/native-file-lock.d.ts +15 -0
- package/dist/updates/native-file-lock.js +189 -0
- package/dist/updates/packaged-launch-admission.d.ts +13 -0
- package/dist/updates/packaged-launch-admission.js +45 -0
- package/dist/updates/packaged-release-config.d.ts +18 -0
- package/dist/updates/packaged-release-config.js +60 -0
- package/dist/updates/packaged-update-startup.d.ts +44 -0
- package/dist/updates/packaged-update-startup.js +81 -0
- package/dist/updates/update-arm.d.ts +9 -8
- package/dist/updates/update-arm.js +227 -62
- package/dist/updates/update-cleanup-error.d.ts +23 -0
- package/dist/updates/update-cleanup-error.js +65 -0
- package/dist/updates/update-download-cleanup.d.ts +11 -0
- package/dist/updates/update-download-cleanup.js +112 -2
- package/dist/updates/update-download-lock.d.ts +20 -0
- package/dist/updates/update-download-lock.js +73 -0
- package/dist/updates/update-download.d.ts +2 -0
- package/dist/updates/update-download.js +7 -3
- package/dist/updates/update-generation-lease.d.ts +6 -0
- package/dist/updates/update-generation-lease.js +14 -0
- package/dist/updates/update-helper.d.ts +11 -2
- package/dist/updates/update-helper.js +322 -13
- package/dist/updates/update-inherited-launch-lease.d.ts +22 -0
- package/dist/updates/update-inherited-launch-lease.js +58 -0
- package/dist/updates/update-instance-lease.d.ts +15 -0
- package/dist/updates/update-instance-lease.js +25 -0
- package/dist/updates/update-launch-gate.d.ts +137 -0
- package/dist/updates/update-launch-gate.js +617 -0
- package/dist/updates/update-launch.js +3 -1
- package/dist/updates/update-lock.d.ts +12 -0
- package/dist/updates/update-lock.js +18 -0
- package/dist/updates/update-manager.d.ts +2 -0
- package/dist/updates/update-manager.js +9 -2
- package/dist/updates/update-marker.d.ts +7 -0
- package/dist/updates/update-marker.js +62 -0
- package/dist/updates/update-preflight-error.d.ts +7 -0
- package/dist/updates/update-preflight-error.js +11 -0
- package/dist/updates/update-process-fence.d.ts +4 -0
- package/dist/updates/update-process-fence.js +85 -73
- package/dist/updates/update-process-liveness.d.ts +2 -0
- package/dist/updates/update-process-liveness.js +11 -0
- package/dist/updates/update-resume.d.ts +37 -3
- package/dist/updates/update-resume.js +839 -23
- package/dist/updates/update-retention-marker.d.ts +67 -0
- package/dist/updates/update-retention-marker.js +165 -0
- package/dist/updates/update-retention-plan.d.ts +25 -0
- package/dist/updates/update-retention-plan.js +54 -0
- package/dist/updates/update-retention-sync.d.ts +34 -0
- package/dist/updates/update-retention-sync.js +83 -0
- package/dist/updates/update-retirement.d.ts +205 -0
- package/dist/updates/update-retirement.js +1485 -0
- package/dist/updates/update-shutdown.d.ts +16 -4
- package/dist/updates/update-shutdown.js +133 -8
- package/dist/updates/update-state-store.d.ts +58 -0
- package/dist/updates/update-state-store.js +139 -0
- package/dist/updates/update-swap-stage.d.ts +1 -1
- package/dist/updates/update-swap-stage.js +85 -14
- package/dist/updates/update-swap.d.ts +45 -2
- package/dist/updates/update-swap.js +207 -17
- package/package.json +31 -1
- package/src/appearance/custom-theme-import.ts +96 -14
- package/src/appearance/custom-theme-library.ts +5 -0
- package/src/appearance/theme-record-adapter.ts +15 -6
- package/src/appearance/theme-registry.ts +8 -1
- package/src/desktop/client-asset-manifest.ts +207 -0
- package/src/desktop/client-asset-stream.ts +193 -32
- package/src/desktop/client-assets.ts +210 -19
- package/src/desktop/client-response-lifecycle.ts +305 -0
- package/src/native/electrobun-posix-launch-lease.patch +398 -0
- package/templates/application/README.md +50 -0
- package/templates/application/electrobun.config.ts +5 -1
- package/templates/application/scripts/build-desktop.ts +4 -0
- package/templates/application/src/bun/index.ts +173 -16
- package/templates/application/vite.config.ts +112 -6
|
@@ -1,21 +1,81 @@
|
|
|
1
1
|
import { ApplicationMenu, BrowserWindow, Utils } from 'electrobun/bun'
|
|
2
2
|
import { mkdirSync } from 'node:fs'
|
|
3
3
|
import { join } from 'node:path'
|
|
4
|
+
import {
|
|
5
|
+
CLIENT_ASSET_MANIFEST_FILE,
|
|
6
|
+
loadClientAssetManifest,
|
|
7
|
+
} from '@adea-ai/app-framework/client-assets'
|
|
4
8
|
import {
|
|
5
9
|
createApplicationCommandBroadcaster,
|
|
6
10
|
createApplicationMenu,
|
|
7
11
|
createApplicationMenuHandler,
|
|
8
12
|
} from '@adea-ai/app-framework/application-menu'
|
|
9
13
|
import { readPackagedVersion } from '@adea-ai/app-framework/app-bundle'
|
|
10
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
createDesktopUpdater,
|
|
16
|
+
registerUpdateServices,
|
|
17
|
+
type UpdateShutdownTiming,
|
|
18
|
+
} from '@adea-ai/app-framework/desktop-updater'
|
|
19
|
+
import {
|
|
20
|
+
acquirePackagedLaunchAdmission,
|
|
21
|
+
INHERITED_LAUNCH_LEASE_ENV,
|
|
22
|
+
} from '@adea-ai/app-framework/packaged-launch-admission'
|
|
23
|
+
import {
|
|
24
|
+
preparePackagedUpdateStartup,
|
|
25
|
+
recoverPackagedUpdateLaunchGate,
|
|
26
|
+
} from '@adea-ai/app-framework/packaged-update-startup'
|
|
27
|
+
import {
|
|
28
|
+
startDesktopHostWithRetainedLease,
|
|
29
|
+
startDesktopHostWithRetry,
|
|
30
|
+
} from '@adea-ai/app-framework/desktop-host'
|
|
11
31
|
import { createServiceRegistry } from '@adea-ai/app-framework/service-registry'
|
|
12
32
|
import { registerNativeUtilities } from '@adea-ai/app-framework/native-utilities'
|
|
13
33
|
import { appConfig } from '../app-config'
|
|
14
34
|
|
|
35
|
+
const HOST_DRAIN_TIMEOUT_MS = 5000
|
|
36
|
+
// The helper's process fence is 30 seconds; once terminal close starts, the
|
|
37
|
+
// process must exit before that fence instead of reopening a stopped window.
|
|
38
|
+
const HOST_TERMINAL_CLOSE_FENCE_MS = 25000
|
|
39
|
+
const inheritedLaunchDescriptor = process.env[INHERITED_LAUNCH_LEASE_ENV]
|
|
40
|
+
delete process.env[INHERITED_LAUNCH_LEASE_ENV]
|
|
15
41
|
const dataDirectory = Utils.paths.userData
|
|
16
42
|
mkdirSync(dataDirectory, { recursive: true, mode: 0o700 })
|
|
17
|
-
const
|
|
43
|
+
const packagedIdentity = {
|
|
44
|
+
slug: appConfig.slug,
|
|
45
|
+
identifier: appConfig.identifier,
|
|
46
|
+
name: appConfig.name,
|
|
47
|
+
}
|
|
48
|
+
if (inheritedLaunchDescriptor === undefined) {
|
|
49
|
+
// Without a launcher lease this process holds no instance lease yet, so it
|
|
50
|
+
// can reconcile a gate left by a crashed update helper before app services
|
|
51
|
+
// start. A managed launcher refuses to start while a gate exists.
|
|
52
|
+
const gateRecovery = await recoverPackagedUpdateLaunchGate({
|
|
53
|
+
entryDirectory: import.meta.dir,
|
|
54
|
+
dataDirectory,
|
|
55
|
+
identity: packagedIdentity,
|
|
56
|
+
}).catch((error: unknown) => `failed: ${String(error)}`)
|
|
57
|
+
if (gateRecovery !== 'absent') console.error(`update launch gate recovery: ${gateRecovery}`)
|
|
58
|
+
}
|
|
59
|
+
const launchAdmission = await acquirePackagedLaunchAdmission({
|
|
60
|
+
entryDirectory: import.meta.dir,
|
|
61
|
+
descriptor: inheritedLaunchDescriptor,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const clientRoot = join(import.meta.dir, '..', 'client')
|
|
65
|
+
const immutableClientAssets = await loadClientAssetManifest(
|
|
66
|
+
join(clientRoot, CLIENT_ASSET_MANIFEST_FILE)
|
|
67
|
+
)
|
|
18
68
|
const { version } = readPackagedVersion(import.meta.dir)
|
|
69
|
+
let preparedUpdateStartup =
|
|
70
|
+
launchAdmission === 'acquired'
|
|
71
|
+
? await preparePackagedUpdateStartup({
|
|
72
|
+
entryDirectory: import.meta.dir,
|
|
73
|
+
dataDirectory,
|
|
74
|
+
identity: packagedIdentity,
|
|
75
|
+
loadManifest: (root) => loadClientAssetManifest(join(root, CLIENT_ASSET_MANIFEST_FILE)),
|
|
76
|
+
})
|
|
77
|
+
: undefined
|
|
78
|
+
const services = createServiceRegistry<string>()
|
|
19
79
|
registerNativeUtilities({
|
|
20
80
|
services,
|
|
21
81
|
info: { name: appConfig.name, version, platform: process.platform },
|
|
@@ -66,17 +126,114 @@ if (process.platform !== 'linux') {
|
|
|
66
126
|
})
|
|
67
127
|
)
|
|
68
128
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
129
|
+
|
|
130
|
+
let closeManagedHost: (() => Promise<void>) | undefined
|
|
131
|
+
let quiesceManagedHost: ((timeoutMs: number) => Promise<void>) | undefined
|
|
132
|
+
let resumeManagedHost: (() => void) | undefined
|
|
133
|
+
const quitManagedApp = async (timing: UpdateShutdownTiming) => {
|
|
134
|
+
if (!closeManagedHost) throw new Error('Managed desktop host is not ready to quit')
|
|
135
|
+
const closeTimeoutMs = Math.min(HOST_TERMINAL_CLOSE_FENCE_MS, timing.remainingMs())
|
|
136
|
+
if (closeTimeoutMs < 1) {
|
|
137
|
+
// The host has not started terminal shutdown yet. Reject so the updater
|
|
138
|
+
// cancels the helper and resumes this still-live host after gate cleanup.
|
|
139
|
+
throw new Error('Insufficient helper time remains to close desktop host safely')
|
|
140
|
+
}
|
|
141
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
142
|
+
try {
|
|
143
|
+
await Promise.race([
|
|
144
|
+
closeManagedHost(),
|
|
145
|
+
new Promise<never>((_, reject) => {
|
|
146
|
+
timer = setTimeout(
|
|
147
|
+
() => reject(new Error('Managed desktop host did not finish terminal shutdown')),
|
|
148
|
+
closeTimeoutMs
|
|
149
|
+
)
|
|
150
|
+
}),
|
|
151
|
+
])
|
|
152
|
+
} catch (error) {
|
|
153
|
+
// Once terminal host shutdown starts there is no safe way to reopen its
|
|
154
|
+
// native window. End this process so the armed helper can finish the handoff.
|
|
155
|
+
console.error('managed desktop host shutdown failed; exiting for update handoff', error)
|
|
156
|
+
process.exit(1)
|
|
157
|
+
return
|
|
158
|
+
} finally {
|
|
159
|
+
if (timer) clearTimeout(timer)
|
|
160
|
+
}
|
|
161
|
+
process.exit(0)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
if (preparedUpdateStartup) {
|
|
166
|
+
const updater = await createDesktopUpdater({
|
|
167
|
+
release: preparedUpdateStartup.release,
|
|
168
|
+
repository: preparedUpdateStartup.release.repository,
|
|
169
|
+
renderer: appConfig.renderer,
|
|
170
|
+
entryDirectory: import.meta.dir,
|
|
171
|
+
dataDirectory,
|
|
172
|
+
currentVersion: preparedUpdateStartup.currentVersion,
|
|
173
|
+
helperScript: 'update-helper.js',
|
|
174
|
+
startup: {
|
|
175
|
+
savedChannel: preparedUpdateStartup.savedChannel,
|
|
176
|
+
resume: preparedUpdateStartup.resume,
|
|
177
|
+
},
|
|
178
|
+
prepareQuit: async (timing) => {
|
|
179
|
+
if (!quiesceManagedHost) throw new Error('Managed desktop host is not ready to quiesce')
|
|
180
|
+
const drainTimeoutMs = Math.min(HOST_DRAIN_TIMEOUT_MS, timing.remainingMs() - 1000)
|
|
181
|
+
if (drainTimeoutMs < 1)
|
|
182
|
+
throw new Error('Insufficient helper time remains to quiesce desktop assets')
|
|
183
|
+
await quiesceManagedHost(drainTimeoutMs)
|
|
184
|
+
},
|
|
185
|
+
abortPreparedQuit: () => resumeManagedHost?.(),
|
|
186
|
+
quit: quitManagedApp,
|
|
187
|
+
log: (line) => console.error(line),
|
|
188
|
+
})
|
|
189
|
+
registerUpdateServices({
|
|
190
|
+
services,
|
|
191
|
+
updater,
|
|
192
|
+
authorize: (principal) => principal === 'app-window',
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const hostOptions = {
|
|
197
|
+
clientRoot,
|
|
198
|
+
// Electrobun copies the build output into the running app bundle.
|
|
199
|
+
streamClientAssets: true,
|
|
200
|
+
immutableClientAssets,
|
|
201
|
+
portFile: join(dataDirectory, 'desktop-origin-port'),
|
|
202
|
+
initialPort: appConfig.initialPort ?? undefined,
|
|
203
|
+
title: appConfig.name,
|
|
204
|
+
renderer: appConfig.renderer,
|
|
205
|
+
platform: process.platform,
|
|
206
|
+
principal: 'app-window',
|
|
207
|
+
services,
|
|
208
|
+
configureStreams: (streams) => commands.register(streams),
|
|
209
|
+
construct: (options) => new BrowserWindow(options),
|
|
210
|
+
} satisfies Parameters<typeof startDesktopHostWithRetry<string, BrowserWindow>>[0]
|
|
211
|
+
if (preparedUpdateStartup) {
|
|
212
|
+
const startup = preparedUpdateStartup
|
|
213
|
+
preparedUpdateStartup = undefined
|
|
214
|
+
const host = await startDesktopHostWithRetainedLease(
|
|
215
|
+
{ ...hostOptions, retainedClientAssets: startup.retainedClientAssets },
|
|
216
|
+
startup.releaseLease
|
|
217
|
+
)
|
|
218
|
+
closeManagedHost = () => host.close()
|
|
219
|
+
quiesceManagedHost = (timeoutMs) => host.quiesceClientAssets(timeoutMs)
|
|
220
|
+
resumeManagedHost = () => host.resumeClientAssetsAfterCancelledShutdown()
|
|
221
|
+
} else {
|
|
222
|
+
await startDesktopHostWithRetry(hostOptions)
|
|
223
|
+
}
|
|
224
|
+
} catch (error) {
|
|
225
|
+
if (preparedUpdateStartup) {
|
|
226
|
+
const release = preparedUpdateStartup.releaseLease.release.bind(
|
|
227
|
+
preparedUpdateStartup.releaseLease
|
|
228
|
+
)
|
|
229
|
+
preparedUpdateStartup = undefined
|
|
230
|
+
try {
|
|
231
|
+
await release()
|
|
232
|
+
} catch (releaseError) {
|
|
233
|
+
throw new AggregateError([error, releaseError], 'Packaged startup and lease release failed', {
|
|
234
|
+
cause: releaseError,
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
throw error
|
|
239
|
+
}
|
|
@@ -1,10 +1,116 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
3
|
+
import { readFile, writeFile } from 'node:fs/promises'
|
|
4
|
+
import { join, resolve } from 'node:path'
|
|
5
|
+
import { defineConfig, type Plugin } from 'vite'
|
|
2
6
|
import solid from 'vite-plugin-solid'
|
|
3
7
|
import tailwind from '@tailwindcss/vite'
|
|
4
8
|
import { applicationVersion } from './scripts/app-version'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
import {
|
|
10
|
+
CLIENT_ASSET_ASSET_PATTERN,
|
|
11
|
+
CLIENT_ASSET_CHUNK_PATTERN,
|
|
12
|
+
CLIENT_ASSET_MANIFEST_FILE,
|
|
13
|
+
clientAssetAssetEvidenceKey,
|
|
14
|
+
clientAssetChunkEvidenceKey,
|
|
15
|
+
createClientAssetManifest,
|
|
16
|
+
} from '@adea-ai/app-framework/client-asset-manifest'
|
|
17
|
+
|
|
18
|
+
export default defineConfig(() => {
|
|
19
|
+
// Keep evidence local to this resolved build config; concurrent builds never share it.
|
|
20
|
+
const namingEvidence = new Map<string, number>()
|
|
21
|
+
let configuredOutputDirectory: string | undefined
|
|
22
|
+
const recordNamingEvidence = (key: string) => {
|
|
23
|
+
namingEvidence.set(key, (namingEvidence.get(key) ?? 0) + 1)
|
|
24
|
+
}
|
|
25
|
+
const hashedOutput = {
|
|
26
|
+
assetFileNames(asset: { name?: string | null; source: string | Uint8Array }) {
|
|
27
|
+
recordNamingEvidence(clientAssetAssetEvidenceKey(asset))
|
|
28
|
+
return CLIENT_ASSET_ASSET_PATTERN
|
|
29
|
+
},
|
|
30
|
+
chunkFileNames(chunk: {
|
|
31
|
+
name: string
|
|
32
|
+
isEntry: boolean
|
|
33
|
+
facadeModuleId?: string | null
|
|
34
|
+
moduleIds?: readonly string[]
|
|
35
|
+
}) {
|
|
36
|
+
recordNamingEvidence(clientAssetChunkEvidenceKey(chunk))
|
|
37
|
+
return CLIENT_ASSET_CHUNK_PATTERN
|
|
38
|
+
},
|
|
39
|
+
entryFileNames(chunk: {
|
|
40
|
+
name: string
|
|
41
|
+
isEntry: boolean
|
|
42
|
+
facadeModuleId?: string | null
|
|
43
|
+
moduleIds?: readonly string[]
|
|
44
|
+
}) {
|
|
45
|
+
recordNamingEvidence(clientAssetChunkEvidenceKey(chunk))
|
|
46
|
+
return CLIENT_ASSET_CHUNK_PATTERN
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
const clientAssetManifest: Plugin = {
|
|
50
|
+
name: 'framework-client-asset-manifest',
|
|
51
|
+
apply: 'build',
|
|
52
|
+
enforce: 'post',
|
|
53
|
+
configResolved(config) {
|
|
54
|
+
const output = config.build.rollupOptions.output
|
|
55
|
+
configuredOutputDirectory = resolve(config.root, config.build.outDir)
|
|
56
|
+
if (
|
|
57
|
+
!output ||
|
|
58
|
+
Array.isArray(output) ||
|
|
59
|
+
output.assetFileNames !== hashedOutput.assetFileNames ||
|
|
60
|
+
output.chunkFileNames !== hashedOutput.chunkFileNames ||
|
|
61
|
+
output.entryFileNames !== hashedOutput.entryFileNames
|
|
62
|
+
)
|
|
63
|
+
throw new Error('Client asset caching requires the configured hashed Vite output names')
|
|
64
|
+
if (config.publicDir && existsSync(join(config.publicDir, CLIENT_ASSET_MANIFEST_FILE)))
|
|
65
|
+
throw new Error('The client asset manifest path is reserved for generated build output')
|
|
66
|
+
},
|
|
67
|
+
buildStart() {
|
|
68
|
+
namingEvidence.clear()
|
|
69
|
+
},
|
|
70
|
+
generateBundle(_output, bundle) {
|
|
71
|
+
if (Object.values(bundle).some((item) => item.fileName === CLIENT_ASSET_MANIFEST_FILE))
|
|
72
|
+
throw new Error('The client asset manifest output path is already in use')
|
|
73
|
+
this.emitFile({
|
|
74
|
+
type: 'asset',
|
|
75
|
+
fileName: CLIENT_ASSET_MANIFEST_FILE,
|
|
76
|
+
source: JSON.stringify({ format: 'adea-client-assets-v1', assets: [] }),
|
|
77
|
+
})
|
|
78
|
+
},
|
|
79
|
+
async writeBundle(output, bundle) {
|
|
80
|
+
const candidate = createClientAssetManifest(
|
|
81
|
+
bundle,
|
|
82
|
+
{
|
|
83
|
+
assetFileNames: CLIENT_ASSET_ASSET_PATTERN,
|
|
84
|
+
chunkFileNames: CLIENT_ASSET_CHUNK_PATTERN,
|
|
85
|
+
entryFileNames: CLIENT_ASSET_CHUNK_PATTERN,
|
|
86
|
+
},
|
|
87
|
+
namingEvidence
|
|
88
|
+
)
|
|
89
|
+
const outputDirectory = output.dir ? resolve(output.dir) : configuredOutputDirectory
|
|
90
|
+
if (!outputDirectory) throw new Error('The client asset output directory is unavailable')
|
|
91
|
+
const assets = await Promise.all(
|
|
92
|
+
candidate.assets.map(async ({ path }) => ({
|
|
93
|
+
path,
|
|
94
|
+
sha256: createHash('sha256')
|
|
95
|
+
.update(await readFile(join(outputDirectory, path.slice(1))))
|
|
96
|
+
.digest('hex'),
|
|
97
|
+
}))
|
|
98
|
+
)
|
|
99
|
+
await writeFile(
|
|
100
|
+
join(outputDirectory, CLIENT_ASSET_MANIFEST_FILE),
|
|
101
|
+
JSON.stringify({ ...candidate, assets })
|
|
102
|
+
)
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
define: { __APP_VERSION__: JSON.stringify(applicationVersion()) },
|
|
108
|
+
root: 'src/web',
|
|
109
|
+
plugins: [solid(), tailwind(), clientAssetManifest],
|
|
110
|
+
build: {
|
|
111
|
+
outDir: '../../build/client',
|
|
112
|
+
emptyOutDir: true,
|
|
113
|
+
rollupOptions: { output: hashedOutput },
|
|
114
|
+
},
|
|
115
|
+
}
|
|
10
116
|
})
|