UNPKG

8.95 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[![dependencies](https://img.shields.io/david/shockpkg/swf-projector)](https://david-dm.org/shockpkg/swf-projector)
9[![size](https://packagephobia.now.sh/badge?p=@shockpkg/swf-projector)](https://packagephobia.now.sh/result?p=@shockpkg/swf-projector)
10[![downloads](https://img.shields.io/npm/dm/@shockpkg/swf-projector.svg)](https://npmcharts.com/compare/@shockpkg/swf-projector?minimal=true)
11
12[![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)
13
14
15# Overview
16
17Creates Flash projectors from a standalone Flash Player.
18
19Takes a standalone Flash Player file, a directory containing a standalone Flash Player, or a shockpkg standalone Flash Player package file.
20
21Can 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.
22
23Reading DMG projector packages is only supported on macOS.
24
25
26# Usage
27
28## Projector
29
30### Windows
31
32```js
33import {ProjectorWindows32} from '@shockpkg/swf-projector';
34
35const projector = new ProjectorWindows32('projector-windows32/application.exe');
36
37// Optional custom icon.
38projector.iconFile = 'icon.ico';
39
40// Optional custom PE resource strings.
41projector.versionStrings = {
42 FileVersion: '3.1.4',
43 ProductVersion: '3.1.4',
44 CompanyName: 'Custom Company Name',
45 FileDescription: 'Custom File Description',
46 LegalCopyright: 'Custom Legal Copyright',
47 ProductName: 'Custom Product Name',
48 LegalTrademarks: 'Custom Legal Trademarks',
49 OriginalFilename: 'CustomOriginalFilename.exe',
50 InternalName: 'CustomInternalName',
51 Comments: 'Custom Comments'
52};
53
54// Optionally patch window title.
55projector.patchWindowTitle = 'Custom Title';
56
57// Optionally remove now-broken signature.
58projector.removeCodeSignature = true;
59
60await projector.withFile('player.exe', 'movie.swf');
61```
62
63### Mac App
64
65```js
66import {ProjectorMacApp} from '@shockpkg/swf-projector';
67
68const projector = new ProjectorMacApp('projector-macapp/application.app');
69
70// Optional custom icon.
71projector.iconFile = 'icon.icns';
72
73// Optionally change main binary name.
74projector.binaryName = 'application';
75
76// Optionally base Info.plist file.
77projector.infoPlistFile = 'Info.plist';
78
79// Optionally custom PkgInfo file.
80projector.pkgInfoFile = 'PkgInfo';
81
82// Optionally update bundle name.
83projector.bundleName = 'application';
84
85// Optionally patch window title (currently requires version 11+).
86projector.patchWindowTitle = 'Custom Title';
87
88// Optionally remove file associations from Info.plist.
89projector.removeFileAssociations = true;
90
91// Optionally exclude InfoPlist.strings files.
92projector.removeInfoPlistStrings = true;
93
94// Optionally remove now-broken signature.
95projector.removeCodeSignature = true;
96
97await projector.withFile('player.dmg', 'movie.swf');
98```
99
100### Linux 32-bit
101
102```js
103import {ProjectorLinux32} from '@shockpkg/swf-projector';
104
105const projector = new ProjectorLinux32('projector-linux32/application');
106
107// Optionally patch window title.
108projector.patchWindowTitle = 'Custom Title';
109
110// Optionally disable menu entirely.
111// projector.patchMenuRemove = true;
112
113// Necessary to load from relative paths.
114projector.patchProjectorPath = true;
115
116await projector.withFile('player.tar.gz', 'movie.swf');
117```
118
119### Linux 64-bit
120
121```js
122import {ProjectorLinux64} from '@shockpkg/swf-projector';
123
124const projector = new ProjectorLinux64('projector-linux64/application');
125
126// Optionally patch window title.
127projector.patchWindowTitle = 'Custom Title';
128
129// Optionally disable menu entirely.
130// projector.patchMenuRemove = true;
131
132// Necessary to load from relative paths.
133projector.patchProjectorPath = true;
134
135// Necessary unless the binaries get fixed.
136projector.patchProjectorOffset = true;
137
138await projector.withFile('player.tar.gz', 'movie.swf');
139```
140
141
142## Bundle
143
144### Windows
145
146```js
147import {BundleWindows32} from '@shockpkg/swf-projector';
148
149const bundle = new BundleWindows32('bundle-windows32/application.exe');
150
151// Use projector property to set options.
152bundle.projector.removeCodeSignature = true;
153
154await bundle.withFile('player.exe', 'movie.swf', async b => {
155 // Add resources in callback.
156 await b.copyResource('other.swf', 'other.swf');
157});
158```
159
160### Mac App
161
162```js
163import {BundleMacApp} from '@shockpkg/swf-projector';
164
165const bundle = new BundleMacApp('bundle-macapp/application.app');
166
167// Use projector property to set options.
168bundle.projector.removeCodeSignature = true;
169
170await bundle.withFile('player.dmg', 'movie.swf', async b => {
171 // Add resources in callback.
172 await b.copyResource('other.swf', 'other.swf');
173});
174```
175
176### Linux 32-bit
177
178```js
179import {BundleLinux32} from '@shockpkg/swf-projector';
180
181const bundle = new BundleLinux32('bundle-linux32/application');
182
183// Use projector property to set options.
184bundle.projector.patchProjectorPath = true;
185
186await bundle.withFile('player.tar.gz', 'movie.swf', async b => {
187 // Add resources in callback.
188 await b.copyResource('other.swf', 'other.swf');
189});
190```
191
192### Linux 64-bit
193
194```js
195import {BundleLinux64} from '@shockpkg/swf-projector';
196
197const bundle = new BundleLinux64('bundle-linux64/application');
198
199// Use projector property to set options.
200bundle.projector.patchProjectorPath = true;
201bundle.projector.patchProjectorOffset = true;
202
203await bundle.withFile('player.tar.gz', 'movie.swf', async b => {
204 // Add resources in callback.
205 await b.copyResource('other.swf', 'other.swf');
206});
207```
208
209## Loader Generator
210
211To 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).
212
213You 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.
214
215
216### SWF8 600x400 30fps white movie that loads `other.swf?param=1`
217
218```js
219import {loader} from '@shockpkg/swf-projector';
220
221const swfData = loader(8, 600, 400, 30, 0xFFFFFF, 'other.swf?param=1');
222```
223
224### SWF8 600x400 30fps red movie that loads `other.swf`, 0.5s delay
225
226```js
227import {loader} from '@shockpkg/swf-projector';
228
229const swfData = loader(8, 600, 400, 30, 0xFF0000, 'other.swf', 30 / 2);
230```
231
232
233# Notes
234
235## Windows
236
237### Option: `patchWindowTitle`
238
239An option to replace the window title stored in the binary. Size cannot be larger than the title being replaced in the binary.
240
241## Mac App
242
243### Option: `patchWindowTitle`
244
245An option to set a custom window title in the binary. Size cannot be larger than the string being replaced in the binary.
246
247## Linux
248
249### Option: `patchWindowTitle`
250
251An option to replace the window title stored in the binary. Size cannot be larger than the title being replaced in the binary.
252
253### Option: `patchMenuRemove`
254
255An option to completely disable the menu for the projector. Avoids layout calculation issues when the menu is in the window.
256
257### Option: `patchProjectorPath`
258
259Compatible with Flash Player 9+ (version 6 was correct).
260
261Required since Flash Player 10.1+ to load relative paths (earlier versions would try the relative path first, before trying resolved path).
262
263Projectors 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.
264
265This patch replaces the string reference to use `"file://" + argv[0]` instead, which resolves to `file:///path/to/application` when run by an absolute path.
266
267Not 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 Bundle does this automatically.
268
269### Option: `patchProjectorOffset`
270
271The Linux projector reading code was never updated for 64-bit ELF compatibility. This patch fixes reading projector data in 64-bit Linux projectors.
272
273
274# Bugs
275
276If you find a bug or have compatibility issues, please open a ticket under issues section for this repository.
277
278
279# License
280
281Copyright (c) 2019-2021 JrMasterModelBuilder
282
283Licensed under the Mozilla Public License, v. 2.0.
284
285If this license does not work for you, feel free to contact me.