1 | # swf-projector
|
2 |
|
3 | Package 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.svg)](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 |
|
17 | Creates Flash projectors from a standalone Flash Player.
|
18 |
|
19 | Takes a standalone Flash Player file, a directory containing a standalone Flash Player, or a shockpkg standalone Flash Player package file.
|
20 |
|
21 | Can 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 |
|
23 | Reading DMG projector packages is only supported on macOS.
|
24 |
|
25 |
|
26 | # Usage
|
27 |
|
28 | ## Projector
|
29 |
|
30 | ### Windows
|
31 |
|
32 | ```js
|
33 | import {ProjectorWindows32} from '@shockpkg/swf-projector';
|
34 |
|
35 | const projector = new ProjectorWindows32('projector-windows32/application.exe');
|
36 |
|
37 | // Optional custom icon.
|
38 | projector.iconFile = 'icon.ico';
|
39 |
|
40 | // Optional custom PE resource strings.
|
41 | projector.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.
|
55 | projector.patchWindowTitle = 'Custom Title';
|
56 |
|
57 | // Optionally remove now-broken signature.
|
58 | projector.removeCodeSignature = true;
|
59 |
|
60 | await projector.withFile('player.exe', 'movie.swf');
|
61 | ```
|
62 |
|
63 | ### Mac App
|
64 |
|
65 | ```js
|
66 | import {ProjectorMacApp} from '@shockpkg/swf-projector';
|
67 |
|
68 | const projector = new ProjectorMacApp('projector-macapp/application.app');
|
69 |
|
70 | // Optional custom icon.
|
71 | projector.iconFile = 'icon.icns';
|
72 |
|
73 | // Optionally change main binary name.
|
74 | projector.binaryName = 'application';
|
75 |
|
76 | // Optionally base Info.plist file.
|
77 | projector.infoPlistFile = 'Info.plist';
|
78 |
|
79 | // Optionally custom PkgInfo file.
|
80 | projector.pkgInfoFile = 'PkgInfo';
|
81 |
|
82 | // Optionally update bundle name.
|
83 | projector.bundleName = 'application';
|
84 |
|
85 | // Optionally patch window title (currently requires version 11+).
|
86 | projector.patchWindowTitle = 'Custom Title';
|
87 |
|
88 | // Optionally remove file associations from Info.plist.
|
89 | projector.removeFileAssociations = true;
|
90 |
|
91 | // Optionally exclude InfoPlist.strings files.
|
92 | projector.removeInfoPlistStrings = true;
|
93 |
|
94 | // Optionally remove now-broken signature.
|
95 | projector.removeCodeSignature = true;
|
96 |
|
97 | await projector.withFile('player.dmg', 'movie.swf');
|
98 | ```
|
99 |
|
100 | ### Linux 32-bit
|
101 |
|
102 | ```js
|
103 | import {ProjectorLinux32} from '@shockpkg/swf-projector';
|
104 |
|
105 | const projector = new ProjectorLinux32('projector-linux32/application');
|
106 |
|
107 | // Optionally patch window title.
|
108 | projector.patchWindowTitle = 'Custom Title';
|
109 |
|
110 | // Optionally disable menu entirely.
|
111 | // projector.patchMenuRemove = true;
|
112 |
|
113 | // Necessary to load from relative paths.
|
114 | projector.patchProjectorPath = true;
|
115 |
|
116 | await projector.withFile('player.tar.gz', 'movie.swf');
|
117 | ```
|
118 |
|
119 | ### Linux 64-bit
|
120 |
|
121 | ```js
|
122 | import {ProjectorLinux64} from '@shockpkg/swf-projector';
|
123 |
|
124 | const projector = new ProjectorLinux64('projector-linux64/application');
|
125 |
|
126 | // Optionally patch window title.
|
127 | projector.patchWindowTitle = 'Custom Title';
|
128 |
|
129 | // Optionally disable menu entirely.
|
130 | // projector.patchMenuRemove = true;
|
131 |
|
132 | // Necessary to load from relative paths.
|
133 | projector.patchProjectorPath = true;
|
134 |
|
135 | // Necessary unless the binaries get fixed.
|
136 | projector.patchProjectorOffset = true;
|
137 |
|
138 | await projector.withFile('player.tar.gz', 'movie.swf');
|
139 | ```
|
140 |
|
141 |
|
142 | ## Bundle
|
143 |
|
144 | ### Windows
|
145 |
|
146 | ```js
|
147 | import {BundleWindows32} from '@shockpkg/swf-projector';
|
148 |
|
149 | const bundle = new BundleWindows32('bundle-windows32/application.exe');
|
150 |
|
151 | // Use projector property to set options.
|
152 | bundle.projector.removeCodeSignature = true;
|
153 |
|
154 | await 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
|
163 | import {BundleMacApp} from '@shockpkg/swf-projector';
|
164 |
|
165 | const bundle = new BundleMacApp('bundle-macapp/application.app');
|
166 |
|
167 | // Use projector property to set options.
|
168 | bundle.projector.removeCodeSignature = true;
|
169 |
|
170 | await 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
|
179 | import {BundleLinux32} from '@shockpkg/swf-projector';
|
180 |
|
181 | const bundle = new BundleLinux32('bundle-linux32/application');
|
182 |
|
183 | // Use projector property to set options.
|
184 | bundle.projector.patchProjectorPath = true;
|
185 |
|
186 | await 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
|
195 | import {BundleLinux64} from '@shockpkg/swf-projector';
|
196 |
|
197 | const bundle = new BundleLinux64('bundle-linux64/application');
|
198 |
|
199 | // Use projector property to set options.
|
200 | bundle.projector.patchProjectorPath = true;
|
201 | bundle.projector.patchProjectorOffset = true;
|
202 |
|
203 | await 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 |
|
210 | # Notes
|
211 |
|
212 | ## Windows
|
213 |
|
214 | ### Option: `patchWindowTitle`
|
215 |
|
216 | An option to replace the window title stored in the binary. Size cannot be larger than the title being replaced in the binary.
|
217 |
|
218 | ## Mac App
|
219 |
|
220 | ### Option: `patchWindowTitle`
|
221 |
|
222 | An option to set a custom window title in the binary. Size cannot be larger than the string being replaced in the binary.
|
223 |
|
224 | ## Linux
|
225 |
|
226 | ### Option: `patchWindowTitle`
|
227 |
|
228 | An option to replace the window title stored in the binary. Size cannot be larger than the title being replaced in the binary.
|
229 |
|
230 | ### Option: `patchMenuRemove`
|
231 |
|
232 | An option to completely disable the menu for the projector. Avoids layout calculation issues when the menu is in the window.
|
233 |
|
234 | ### Option: `patchProjectorPath`
|
235 |
|
236 | Compatible with Flash Player 9+ (version 6 was correct).
|
237 |
|
238 | Required since Flash Player 10.1+ to load relative paths (earlier versions would try the relative path first, before trying resolved path).
|
239 |
|
240 | Projectors 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.
|
241 |
|
242 | 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.
|
243 |
|
244 | Not 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.
|
245 |
|
246 | ### Option: `patchProjectorOffset`
|
247 |
|
248 | The Linux projector reading code was never updated for 64-bit ELF compatibility. This patch fixes reading projector data in 64-bit Linux projectors.
|
249 |
|
250 |
|
251 | # Bugs
|
252 |
|
253 | If you find a bug or have compatibility issues, please open a ticket under issues section for this repository.
|
254 |
|
255 |
|
256 | # License
|
257 |
|
258 | Copyright (c) 2019-2020 JrMasterModelBuilder
|
259 |
|
260 | Licensed under the Mozilla Public License, v. 2.0.
|
261 |
|
262 | If this license does not work for you, feel free to contact me.
|