UNPKG

7.79 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.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
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
210# Notes
211
212## Windows
213
214### Option: `patchWindowTitle`
215
216An 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
222An 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
228An 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
232An 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
236Compatible with Flash Player 9+ (version 6 was correct).
237
238Required since Flash Player 10.1+ to load relative paths (earlier versions would try the relative path first, before trying resolved path).
239
240Projectors 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
242This 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
244Not 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
248The 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
253If you find a bug or have compatibility issues, please open a ticket under issues section for this repository.
254
255
256# License
257
258Copyright (c) 2019-2020 JrMasterModelBuilder
259
260Licensed under the Mozilla Public License, v. 2.0.
261
262If this license does not work for you, feel free to contact me.