-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.mjs
264 lines (252 loc) · 7.99 KB
/
make.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import {readdir, rm} from 'node:fs/promises';
import {Manager} from '@shockpkg/core';
import {
Plist,
ValueDict,
ValueString,
ValueBoolean
} from '@shockpkg/plist-dom';
import {
BundleHtml,
BundleSaWindows,
BundleSaMac,
BundleSaLinux,
loader
} from '@shockpkg/swf-projector';
import {
appName,
appDomain,
version,
author,
copyright,
appFile,
appDmgTitle,
versionShort,
distName
} from './util/meta.mjs';
import {docs} from './util/doc.mjs';
import {zip, tgz} from './util/archive.mjs';
import {isMac, codesign, dmg} from './util/mac/index.mjs';
import {exe} from './util/windows/index.mjs';
async function * resources() {
for (const [dir, base] of [
['original/files/2006/ep1', 'ep1'],
['original/files/2006/ep2', 'ep2'],
['original/files/2006/ep3', 'ep3'],
['original/files/2006/ep4', 'ep4'],
['original/files/2006/ep5', 'ep5'],
['original/files/2006/ep6', 'ep6'],
['original/files/2006/ep6/scenes', 'ep6/scenes'],
['src/shared', '']
]) {
for (const f of (await readdir(dir)).sort()) {
if (/[^.].*(swf|xml|txt)$/i.test(f) && f !== 'detect.swf') {
yield [base ? `${base}/${f}` : f, `${dir}/${f}`];
}
}
}
}
function projected(delay) {
const swfv = 8;
const [w, h] = [760, 389];
const fps = 25;
const bg = 0xFFFFFF;
const url = 'voyanuianimations.swf';
return loader(swfv, w, h, fps, bg, url, delay ? Math.round(fps / 2) : 0);
}
const task = {'': _ => Object.keys(task).map(t => t && console.error(t)) && 1};
task['clean'] = async () => {
await rm('dist', {force: true, recursive: true});
await rm('build', {force: true, recursive: true});
};
for (const [type, flat] of Object.entries({
'pages': true,
'browser': false
})) {
const build = `build/${type}`;
task[`build:${type}`] = async () => {
await rm(build, {force: true, recursive: true});
const file = flat ? 'index.html' : `${appFile}.html`;
const b = new BundleHtml(`${build}/${file}`, flat);
b.projector.lang = 'en-US';
b.projector.title = appName;
b.projector.background = '#000000';
b.projector.color = '#999999';
b.projector.src = 'voyanuianimations.swf';
b.projector.width = 760;
b.projector.height = 389;
await b.write(async b => {
for await (const [file, data] of resources()) {
await b.copyResourceFile(file, data);
}
});
await docs('docs', build);
};
}
for (const [type, make] of Object.entries({
'zip': zip,
'tgz': tgz
})) {
task[`dist:browser:${type}`] = async () => {
await make(`dist/${distName}-Browser.${type}`, 'build/browser');
};
}
for (const [type, pkg] of Object.entries({
'i386': 'flash-player-35.0.0.204-windows-i386-sa-2022-08-13',
'x86_64': 'flash-player-35.0.0.204-windows-x86_64-sa-2022-08-13',
'x86_64-debug': 'flash-player-35.0.0.204-windows-x86_64-sa-debug-2022-08-13'
})) {
const build = `build/windows-${type}`;
task[`build:windows-${type}`] = async () => {
await rm(build, {force: true, recursive: true});
const file = `${appFile}.exe`;
const b = new BundleSaWindows(`${build}/${file}`);
b.projector.player = await new Manager().file(pkg);
b.projector.movieData = projected(false);
b.projector.versionStrings = {
FileVersion: version,
ProductVersion: versionShort,
CompanyName: author,
FileDescription: appName,
LegalCopyright: copyright,
ProductName: appName,
LegalTrademarks: '',
OriginalFilename: file,
InternalName: appFile,
Comments: ''
};
b.projector.iconFile = 'res/app-icon-windows.ico';
b.projector.patchWindowTitle = appName;
b.projector.patchOutOfDateDisable = true;
b.projector.removeCodeSignature = true;
await b.write(async b => {
for await (const [file, data] of resources()) {
await b.copyResourceFile(file, data);
}
});
await docs('docs', build);
};
task[`dist:windows-${type}:zip`] = async () => {
await zip(`dist/${distName}-Windows-${type}.zip`, build);
};
task[`dist:windows-${type}:exe`] = async () => {
await exe(
`dist/${distName}-Windows-${type}.exe`,
/x86_64/.test(type) ? 'x64 arm64' : '',
appDomain,
appName,
appFile,
version,
author,
copyright,
'LICENSE.txt',
'res/inno-icon.ico',
'res/inno-header/*.bmp',
'res/inno-sidebar/*.bmp',
`${build}/*`,
[
[`${appFile}.exe`, appFile, true, true],
['README.html', `${appFile} - README`]
]
);
};
}
for (const [type, pkg] of Object.entries({
'x86_64-arm64': 'flash-player-35.0.0.60-mac-x86_64-arm64-sa-2023-09-23',
'x86_64-arm64-debug': 'flash-player-35.0.0.60-mac-x86_64-arm64-sa-debug-2023-09-23'
})) {
const build = `build/mac-${type}`;
task[`build:mac-${type}`] = async () => {
await rm(build, {force: true, recursive: true});
const pkgInfo = 'APPL????';
const b = new BundleSaMac(`${build}/${appFile}.app`);
b.projector.player = await new Manager().file(pkg);
b.projector.movieData = projected(false);
b.projector.binaryName = appFile;
b.projector.pkgInfoData = pkgInfo;
b.projector.infoPlistData = (new Plist(new ValueDict(new Map([
['CFBundleInfoDictionaryVersion', new ValueString('6.0')],
['CFBundleDevelopmentRegion', new ValueString('en-US')],
['CFBundleExecutable', new ValueString('')],
['CFBundleIconFile', new ValueString('')],
['CFBundleName', new ValueString(appName)],
['NSHumanReadableCopyright', new ValueString(copyright)],
['CFBundleGetInfoString', new ValueString(copyright)],
['CFBundleIdentifier', new ValueString(appDomain)],
['CFBundleVersion', new ValueString(version)],
['CFBundleLongVersionString', new ValueString(version)],
['CFBundleShortVersionString', new ValueString(versionShort)],
['CFBundlePackageType', new ValueString(pkgInfo.substring(0, 4))],
['CFBundleSignature', new ValueString(pkgInfo.substring(4))],
['NSAppTransportSecurity', new ValueDict(new Map([
['NSAllowsArbitraryLoads', new ValueBoolean(true)]
]))],
['NSSupportsAutomaticGraphicsSwitching', new ValueBoolean(true)],
['NSHighResolutionCapable', new ValueBoolean(true)],
['CSResourcesFileMapped', new ValueBoolean(true)],
['LSPrefersCarbon', new ValueString('YES')],
['NSAppleScriptEnabled', new ValueString('YES')],
['NSMainNibFile', new ValueString('MainMenu')],
['NSPrincipalClass', new ValueString('NSApplication')]
])))).toXml();
b.projector.iconFile = 'res/app-icon-mac.icns';
b.projector.patchWindowTitle = appName;
b.projector.removeInfoPlistStrings = true;
b.projector.removeCodeSignature = true;
await b.write(async b => {
for await (const [file, data] of resources()) {
await b.copyResourceFile(file, data);
}
});
if (isMac) {
await codesign(b.projector.path);
await codesign(b.path);
}
await docs('docs', build);
};
task[`dist:mac-${type}:tgz`] = async () => {
await tgz(`dist/${distName}-Mac-${type}.tgz`, build);
};
task[`dist:mac-${type}:dmg`] = async () => {
await dmg(
`dist/${distName}-Mac-${type}.dmg`,
appDmgTitle,
'res/dmg-icon.icns',
'res/dmg-background/dmg-background.png',
[640, 512],
128,
[
[-160, -148, 'file', `${build}/${appFile}.app`],
[160, -148, 'link', '/Applications'],
[0, 100, 'file', `${build}/README.html`]
]
);
};
}
for (const [type, pkg] of Object.entries({
'i386': 'flash-player-11.2.202.644-linux-i386-sa',
'i386-debug': 'flash-player-11.2.202.644-linux-i386-sa-debug',
'x86_64': 'flash-player-32.0.0.465-linux-x86_64-sa',
'x86_64-debug': 'flash-player-32.0.0.465-linux-x86_64-sa-debug'
})) {
const build = `build/linux-${type}`;
task[`build:linux-${type}`] = async () => {
await rm(build, {force: true, recursive: true});
const b = new BundleSaLinux(`${build}/${appFile}`);
b.projector.player = await new Manager().file(pkg);
b.projector.movieData = projected(true);
b.projector.patchProjectorOffset = /x86_64/.test(type);
b.projector.patchProjectorPath = true;
b.projector.patchWindowTitle = appName;
await b.write(async b => {
for await (const [file, data] of resources()) {
await b.copyResourceFile(file, data);
}
});
await docs('docs', build);
};
task[`dist:linux-${type}:tgz`] = async () => {
await tgz(`dist/${distName}-Linux-${type}.tgz`, build);
};
}
process.exitCode = await task[process.argv[2] || '']();