UNPKG

11.3 kBMarkdownView Raw
1# SWF Projector
2
3Package for creating Flash Player projectors
4
5[![npm](https://img.shields.io/npm/v/@shockpkg/swf-projector.svg)](https://npmjs.com/package/@shockpkg/swf-projector)
6[![node](https://img.shields.io/node/v/@shockpkg/swf-projector.svg)](https://nodejs.org)
7
8[![size](https://packagephobia.now.sh/badge?p=@shockpkg/swf-projector)](https://packagephobia.now.sh/result?p=@shockpkg/swf-projector)
9[![downloads](https://img.shields.io/npm/dm/@shockpkg/swf-projector.svg)](https://npmcharts.com/compare/@shockpkg/swf-projector?minimal=true)
10
11[![Build Status](https://github.com/shockpkg/swf-projector/workflows/main/badge.svg?branch=master)](https://github.com/shockpkg/swf-projector/actions?query=workflow%3Amain+branch%3Amaster)
12
13# Overview
14
15Creates Flash projectors from a standalone Flash Player.
16
17Takes a standalone Flash Player file, a directory containing a standalone Flash Player, or a shockpkg standalone Flash Player package file.
18
19Can also create bundles that group the projector and resources in a directory beside a single launcher for Windows and Linux or within an application bundle for macOS.
20
21Reading DMG projector packages is only supported on macOS.
22
23# Usage
24
25## Projector
26
27### Sa
28
29#### Windows
30
31```js
32import {ProjectorSaWindows} from '@shockpkg/swf-projector';
33
34const projector = new ProjectorSaWindows('projector-windows/application.exe');
35
36// Required player.
37projector.player = 'player.exe';
38
39// The movie.
40projector.movieFile = 'movie.swf';
41
42// Optional custom icon.
43projector.iconFile = 'icon.ico';
44
45// Optional custom PE resource strings.
46projector.versionStrings = {
47 FileVersion: '1.2.3.4',
48 ProductVersion: '1.2.3.4',
49 CompanyName: 'Custom Company Name',
50 FileDescription: 'Custom File Description',
51 LegalCopyright: 'Custom Legal Copyright',
52 ProductName: 'Custom Product Name',
53 LegalTrademarks: 'Custom Legal Trademarks',
54 OriginalFilename: 'CustomOriginalFilename.exe',
55 InternalName: 'CustomInternalName',
56 Comments: 'Custom Comments'
57};
58
59// Optionally patch window title.
60projector.patchWindowTitle = 'Custom Title';
61
62// Optionally remove now-broken signature.
63projector.removeCodeSignature = true;
64
65// Optionally remove out-of-date check.
66projector.patchOutOfDateDisable = true;
67
68await projector.write();
69```
70
71#### Mac
72
73```js
74import {ProjectorSaMac} from '@shockpkg/swf-projector';
75
76const projector = new ProjectorSaMac('projector-mac/application.app');
77
78// Required player.
79projector.player = 'player.zip';
80
81// The movie.
82projector.movieFile = 'movie.swf';
83
84// Optional custom icon.
85projector.iconFile = 'icon.icns';
86
87// Optionally change main binary name.
88projector.binaryName = 'application';
89
90// Optionally base Info.plist file.
91projector.infoPlistFile = 'Info.plist';
92
93// Optionally custom PkgInfo file.
94projector.pkgInfoFile = 'PkgInfo';
95
96// Optionally update bundle name.
97projector.bundleName = 'application';
98
99// Optionally patch window title (currently requires version 11+).
100projector.patchWindowTitle = 'Custom Title';
101
102// Optionally remove file associations from Info.plist.
103projector.removeFileAssociations = true;
104
105// Optionally exclude InfoPlist.strings files.
106projector.removeInfoPlistStrings = true;
107
108// Optionally remove now-broken signature.
109projector.removeCodeSignature = true;
110
111await projector.write();
112```
113
114#### Linux
115
116```js
117import {ProjectorSaLinux} from '@shockpkg/swf-projector';
118
119const projector = new ProjectorSaLinux('projector-linux/application');
120
121// Required player.
122projector.player = 'player.tar.gz';
123
124// The movie.
125projector.movieFile = 'movie.swf';
126
127// Optionally patch window title.
128projector.patchWindowTitle = 'Custom Title';
129
130// Optionally disable menu entirely.
131// projector.patchMenuRemove = true;
132
133// Necessary to load from relative paths.
134projector.patchProjectorPath = true;
135
136// Only for 64-bit Linux, where this is necessary.
137projector.patchProjectorOffset = true;
138
139await projector.write();
140```
141
142### HTML
143
144```js
145import {ProjectorHtml} from '@shockpkg/swf-projector';
146
147const projector = new ProjectorHtml('projector-html/application.html');
148
149// Required properties.
150projector.src = 'movie.swf';
151projector.width = 600;
152projector.height = 400;
153
154// Optionally configure HTML document.
155p.lang = 'en-US';
156p.title = 'A "special" title with <html> characters';
157p.background = '#000000';
158p.color = '#999999';
159
160// Optionally configure object/param/embed elements.
161p.bgcolor = '#000000';
162p.id = 'element-id';
163p.name = 'element-name';
164p.codebase =
165 'https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=32,0,0,0';
166p.pluginspage = 'https://www.adobe.com/go/getflashplayer';
167p.play = true;
168p.loop = true;
169p.menu = true;
170p.quality = 'high';
171p.scale = 'default';
172p.align = 'l';
173p.salign = 'l';
174p.wmode = 'opaque';
175p.base = '.';
176p.allowFullScreen = true;
177p.allowFullScreenInteractive = true;
178p.allowScriptAccess = 'always';
179p.allowNetworking = 'all';
180p.fullScreenAspectRatio = 'landscape';
181p.flashvars = 'param1=value1&param2=value2';
182p.browserzoom = 'scale';
183p.devicefont = false;
184p.swliveconnect = true;
185p.expressinstall = 'expressinstall.swf';
186p.swfversion = 32;
187
188await projector.write();
189```
190
191## Bundle
192
193### Sa
194
195#### Windows
196
197```js
198import {BundleSaWindows} from '@shockpkg/swf-projector';
199
200const bundle = new BundleSaWindows('bundle-windows/application.exe');
201
202// Use projector property to set options.
203bundle.projector.player = 'player.exe';
204bundle.projector.movie = 'movie.swf';
205bundle.projector.removeCodeSignature = true;
206bundle.projector.patchOutOfDateDisable = true;
207
208await bundle.write(async b => {
209 // Add resources in callback.
210 await b.copyResource('other.swf', 'other.swf');
211});
212```
213
214#### Mac
215
216```js
217import {BundleSaMac} from '@shockpkg/swf-projector';
218
219const bundle = new BundleSaMac('bundle-mac/application.app');
220
221// Use projector property to set options.
222bundle.projector.player = 'player.zip';
223bundle.projector.movie = 'movie.swf';
224bundle.projector.removeCodeSignature = true;
225
226await bundle.write(async b => {
227 // Add resources in callback.
228 await b.copyResource('other.swf', 'other.swf');
229});
230```
231
232#### Linux
233
234```js
235import {BundleSaLinux} from '@shockpkg/swf-projector';
236
237const bundle = new BundleSaLinux('bundle-linux/application');
238
239// Use projector property to set options.
240bundle.projector.player = 'player.tar.gz';
241bundle.projector.movie = 'movie.swf';
242bundle.projector.patchProjectorPath = true;
243bundle.projector.patchProjectorOffset = true;
244
245await bundle.write(async b => {
246 // Add resources in callback.
247 await b.copyResource('other.swf', 'other.swf');
248});
249```
250
251### HTML
252
253```js
254import {BundleHtml} from '@shockpkg/swf-projector';
255
256const bundle = new BundleHtml('bundle-html/application.html');
257
258// Use projector property to set options.
259bundle.projector.src = 'movie.swf';
260bundle.projector.width = 600;
261bundle.projector.height = 400;
262
263await bundle.write(async b => {
264 // Add resources in callback.
265 await b.copyResource('movie.swf', 'movie.swf');
266});
267```
268
269A bundle can also be made "flat" into an empty directory with nesting the resources or adding a launcher stub by passing true as the second argument to the constructor.
270
271## Loader Generator
272
273To make it easier to create a SWF that loads another URL for use in a projector, there's a `loader` utility function which generates an ASVM1 stub which loads another URL into level 0 (effectively replacing the content).
274
275You can also specify a number of frames to delay loading the other movie, to give the player a chance to initialize before loading the other movie. This is especially useful on Linux where the player may take about 0.25s to finish resizing the window and may not finish with the correct size (mainly depending on the desktop environment's use of the menu bar). Loading another movie into level 0 after the initial resize is done will however correct the issue. Waiting 0.5s (or FPS / 2) should offer enough of a buffer.
276
277### SWF8 600x400 30fps white movie that loads `other.swf?param=1`
278
279```js
280import {loader} from '@shockpkg/swf-projector';
281
282const swfData = loader(8, 600, 400, 30, 0xffffff, 'other.swf?param=1');
283```
284
285### SWF8 600x400 30fps red movie that loads `other.swf`, 0.5s delay
286
287```js
288import {loader} from '@shockpkg/swf-projector';
289
290const swfData = loader(8, 600, 400, 30, 0xff0000, 'other.swf', 30 / 2);
291```
292
293# Notes
294
295## Windows
296
297### Option: `patchWindowTitle`
298
299An option to replace the window title stored in the binary (no length limit since library version 3).
300
301### Option: `patchOutOfDateDisable`
302
303An option to disable the out-of-date check present since version 30 and active (with 90 and 180 day defaults) since version 35.
304
305### Option: `removeCodeSignature`
306
307A Windows projector cannot be properly codesigned, so removing the signature makes it smaller.
308
309## Mac
310
311### Option: `patchWindowTitle`
312
313An option to set a custom window title in the binary (no length limit since library version 3).
314
315### Option: `removeCodeSignature`
316
317The code signature will be broken, lightly by adding the movie resource, or heavily by patching the binary. For projectors without an arm64 binary, this can avoid some issues where the code signature is broken.
318
319An application with an arm64 binary however does require a valid code signature to run, even if it's just an ad-hoc one. Currently this library doesn't have a way to ad-hoc codesign, so it must be done after the projector or bundle is produced.
320
321```bash
322codesign --deep -fs - application.app
323```
324
325Alternately the application bundle could be signed with a real code signing certificate.
326
327## Linux
328
329### Option: `patchWindowTitle`
330
331An option to replace the window title stored in the binary (no length limit since library version 3).
332
333### Option: `patchMenuRemove`
334
335An option to completely disable the menu for the projector.
336
337### Option: `patchProjectorPath`
338
339Required in Flash Player 6 and Flash Player 10.1+ to load relative paths (other versions would try the relative path first, before trying resolved path).
340
341Projectors version 9+ create the main URL with: `"file:" + argv[0]` resolving to a bad URL like `file://file|%2Fpath%2Fto%2Fapplication` causing relative paths to load from the root of the drive. For such projectors this patch replaces the string reference to use `"file://" + argv[0]` instead, which resolves to `file:///path/to/application` when run by an absolute path.
342
343Projector version 6 would use the current working directory for the main URL, causing relative paths to start in the directory above the projector binary. For such projectors this patch replaces the directory string reference to use `argv[0]` instead.
344
345Not a perfect patch because it does not resolve the full path first, if run from relative path would get path like `file://./application`, but an improvement. Recommended to use a shell script or binary that resolves itself and runs projector from an absolute path. Using a (non-flat) Bundle does this automatically.
346
347### Option: `patchProjectorOffset`
348
349The Linux projector reading code was never updated for 64-bit ELF compatibility. This patch fixes reading projector data in 64-bit Linux projectors.
350
351# Bugs
352
353If you find a bug or have compatibility issues, please open a ticket under issues section for this repository.
354
355# License
356
357Copyright (c) 2019-2023 JrMasterModelBuilder
358
359Licensed under the Mozilla Public License, v. 2.0.
360
361If this license does not work for you, feel free to contact me.