@swf2es/web 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +43 -2
- package/dist/air-files.d.ts +40 -0
- package/dist/air-files.d.ts.map +1 -0
- package/dist/air-files.js +304 -0
- package/dist/air-files.js.map +1 -0
- package/dist/air-items.d.ts +28 -0
- package/dist/air-items.d.ts.map +1 -0
- package/dist/air-items.js +186 -0
- package/dist/air-items.js.map +1 -0
- package/dist/air.d.ts +81 -0
- package/dist/air.d.ts.map +1 -0
- package/dist/air.js +409 -0
- package/dist/air.js.map +1 -0
- package/dist/config.d.ts +123 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +127 -0
- package/dist/config.js.map +1 -0
- package/dist/element.d.ts +80 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +725 -0
- package/dist/element.js.map +1 -0
- package/dist/external.d.ts +49 -0
- package/dist/external.d.ts.map +1 -0
- package/dist/external.js +268 -0
- package/dist/external.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.d.ts +47 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +75 -0
- package/dist/layout.js.map +1 -0
- package/dist/playback.d.ts +107 -0
- package/dist/playback.d.ts.map +1 -0
- package/dist/playback.js +308 -0
- package/dist/playback.js.map +1 -0
- package/dist/replace.d.ts +22 -0
- package/dist/replace.d.ts.map +1 -0
- package/dist/replace.js +141 -0
- package/dist/replace.js.map +1 -0
- package/dist/stage3d.d.ts +25 -0
- package/dist/stage3d.d.ts.map +1 -0
- package/dist/stage3d.js +90 -0
- package/dist/stage3d.js.map +1 -0
- package/package.json +38 -3
- package/src/air-files.ts +371 -0
- package/src/air-items.ts +217 -0
- package/src/air.ts +497 -0
- package/src/config.ts +244 -0
- package/src/element.ts +902 -0
- package/src/external.ts +338 -0
- package/src/index.ts +33 -0
- package/src/layout.ts +127 -0
- package/src/playback.ts +388 -0
- package/src/replace.ts +166 -0
- package/src/stage3d.ts +112 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
const DATABASE = "swf2es-air-items";
|
|
2
|
+
const VERSION = 1;
|
|
3
|
+
const ITEMS = "items";
|
|
4
|
+
const BY_ID = "id";
|
|
5
|
+
/** The items of one application; `ready` once what IndexedDB kept is read. */
|
|
6
|
+
export class AirItems {
|
|
7
|
+
#items = new Map();
|
|
8
|
+
/** The names changed since IndexedDB last had them. */
|
|
9
|
+
#dirty = new Set();
|
|
10
|
+
#database;
|
|
11
|
+
#id;
|
|
12
|
+
#saving = Promise.resolve();
|
|
13
|
+
#scheduled = false;
|
|
14
|
+
ready;
|
|
15
|
+
/**
|
|
16
|
+
* The items of the application `id`, kept in `indexedDB` where given, in
|
|
17
|
+
* memory alone otherwise, read from it once `after` settles.
|
|
18
|
+
*/
|
|
19
|
+
constructor(id, indexedDB, after = Promise.resolve()) {
|
|
20
|
+
this.#id = id;
|
|
21
|
+
this.#database = indexedDB
|
|
22
|
+
? after.then(() => open(indexedDB)).catch(() => null)
|
|
23
|
+
: Promise.resolve(null);
|
|
24
|
+
this.ready = this.#database.then(async (db) => {
|
|
25
|
+
if (!db) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const index = db.transaction(ITEMS).objectStore(ITEMS).index(BY_ID);
|
|
30
|
+
for (const stored of await request(index.getAll(id))) {
|
|
31
|
+
this.#items.set(stored.name, stored.bytes);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// What could not be read is not there.
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getItem(name) {
|
|
40
|
+
return this.#items.get(name) ?? null;
|
|
41
|
+
}
|
|
42
|
+
setItem(name, bytes) {
|
|
43
|
+
this.#items.set(name, bytes.slice());
|
|
44
|
+
this.#changed(name);
|
|
45
|
+
}
|
|
46
|
+
removeItem(name) {
|
|
47
|
+
if (this.#items.delete(name)) {
|
|
48
|
+
this.#changed(name);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
reset() {
|
|
52
|
+
for (const name of this.#items.keys()) {
|
|
53
|
+
this.#changed(name);
|
|
54
|
+
}
|
|
55
|
+
this.#items.clear();
|
|
56
|
+
}
|
|
57
|
+
/** Lets go of the database once what was changed is saved: resolves then. */
|
|
58
|
+
close() {
|
|
59
|
+
// After the turn's changes join the saves.
|
|
60
|
+
return new Promise((resolve) => setTimeout(resolve, 0))
|
|
61
|
+
.then(() => this.#saving)
|
|
62
|
+
.then(() => this.#database)
|
|
63
|
+
.then((db) => db?.close());
|
|
64
|
+
}
|
|
65
|
+
/** Marks `name` for IndexedDB, which gets the changes of a turn together. */
|
|
66
|
+
#changed(name) {
|
|
67
|
+
this.#dirty.add(name);
|
|
68
|
+
if (this.#scheduled) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.#scheduled = true;
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
this.#scheduled = false;
|
|
74
|
+
const names = [...this.#dirty];
|
|
75
|
+
this.#dirty.clear();
|
|
76
|
+
this.#saving = this.#saving.then(() => this.#save(names));
|
|
77
|
+
}, 0);
|
|
78
|
+
}
|
|
79
|
+
async #save(names) {
|
|
80
|
+
const db = await this.#database;
|
|
81
|
+
if (!db) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const tx = db.transaction(ITEMS, "readwrite");
|
|
86
|
+
const store = tx.objectStore(ITEMS);
|
|
87
|
+
for (const name of names) {
|
|
88
|
+
const bytes = this.#items.get(name);
|
|
89
|
+
if (bytes) {
|
|
90
|
+
store.put({ id: this.#id, name, bytes });
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
store.delete([this.#id, name]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
await done(tx);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
// A quota, say: the items are still in memory while the page plays.
|
|
100
|
+
console.warn(`swf2es: the AIR application's EncryptedLocalStore could not be kept: ${e}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Each application's items, by its id, with how many elements play it. */
|
|
105
|
+
const shared = new Map();
|
|
106
|
+
/** By application id, the last items let go of, until what they changed is saved. */
|
|
107
|
+
const closing = new Map();
|
|
108
|
+
/**
|
|
109
|
+
* The items of the application `id` for an element to play it with,
|
|
110
|
+
* shared with other elements playing it, kept in IndexedDB where the page
|
|
111
|
+
* has it; `release` when the element is done with them. One that plays it
|
|
112
|
+
* next waits for the last to save.
|
|
113
|
+
*/
|
|
114
|
+
export function airItems(id) {
|
|
115
|
+
let entry = shared.get(id);
|
|
116
|
+
if (!entry) {
|
|
117
|
+
entry = { items: new AirItems(id, globalThis.indexedDB ?? null, closing.get(id)), users: 0 };
|
|
118
|
+
shared.set(id, entry);
|
|
119
|
+
}
|
|
120
|
+
entry.users++;
|
|
121
|
+
const held = entry;
|
|
122
|
+
let released = false;
|
|
123
|
+
return {
|
|
124
|
+
items: held.items,
|
|
125
|
+
release: () => {
|
|
126
|
+
if (released) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
released = true;
|
|
130
|
+
held.users--;
|
|
131
|
+
if (held.users === 0 && shared.get(id) === held) {
|
|
132
|
+
shared.delete(id);
|
|
133
|
+
const closed = held.items.close();
|
|
134
|
+
closing.set(id, closed);
|
|
135
|
+
void closed.then(() => {
|
|
136
|
+
if (closing.get(id) === closed) {
|
|
137
|
+
closing.delete(id);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function open(factory) {
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
// Another tab holding an older version open blocks it: done without.
|
|
147
|
+
let late = false;
|
|
148
|
+
const timer = setTimeout(() => {
|
|
149
|
+
late = true;
|
|
150
|
+
reject(new Error(`IndexedDB ${DATABASE} did not open`));
|
|
151
|
+
}, 2000);
|
|
152
|
+
const opening = factory.open(DATABASE, VERSION);
|
|
153
|
+
opening.onupgradeneeded = () => {
|
|
154
|
+
opening.result
|
|
155
|
+
.createObjectStore(ITEMS, { keyPath: ["id", "name"] })
|
|
156
|
+
.createIndex(BY_ID, BY_ID);
|
|
157
|
+
};
|
|
158
|
+
opening.onsuccess = () => {
|
|
159
|
+
clearTimeout(timer);
|
|
160
|
+
if (late) {
|
|
161
|
+
opening.result.close();
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
resolve(opening.result);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
opening.onerror = () => {
|
|
168
|
+
clearTimeout(timer);
|
|
169
|
+
reject(opening.error);
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function request(r) {
|
|
174
|
+
return new Promise((resolve, reject) => {
|
|
175
|
+
r.onsuccess = () => resolve(r.result);
|
|
176
|
+
r.onerror = () => reject(r.error);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function done(tx) {
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
tx.oncomplete = () => resolve();
|
|
182
|
+
tx.onerror = () => reject(tx.error);
|
|
183
|
+
tx.onabort = () => reject(tx.error ?? new Error("IndexedDB transaction aborted"));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=air-items.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"air-items.js","sourceRoot":"","sources":["../src/air-items.ts"],"names":[],"mappings":"AAQA,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AACpC,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,KAAK,GAAG,OAAO,CAAC;AACtB,MAAM,KAAK,GAAG,IAAI,CAAC;A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K,CAAC,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAI,CAAa;IAC/B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAW,CAAC,CAAC;QAC3C,CAAC,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,IAAI,CAAC,EAAkB;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,EAAE,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QAChC,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QACpC,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/air.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type AirDescriptor, type Swf } from "@swf2es/format";
|
|
2
|
+
import { type AirApplication, type AirWindow, type FetchRequest, type FetchResult, type FileSystemHost } from "@swf2es/player";
|
|
3
|
+
import { AirFiles } from "./air-files.js";
|
|
4
|
+
/** One of an application's files, its path relative to the folder it came in, "/"-separated. */
|
|
5
|
+
export interface AirAppFile {
|
|
6
|
+
path: string;
|
|
7
|
+
bytes: Uint8Array;
|
|
8
|
+
/** When it was last changed, in ms since 1970; when it was opened if not given. */
|
|
9
|
+
modified?: number;
|
|
10
|
+
}
|
|
11
|
+
/** AIR's directories but the application's, there before it writes, as paths from the root. */
|
|
12
|
+
export declare const AIR_DIRECTORIES: readonly string[];
|
|
13
|
+
interface Entry {
|
|
14
|
+
size: number;
|
|
15
|
+
modified: number;
|
|
16
|
+
bytes(): Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
/** An AIR application opened from its files; `Swf2esPlayerElement.loadAir` plays it. */
|
|
19
|
+
export declare class AirApp {
|
|
20
|
+
#private;
|
|
21
|
+
/** The descriptor as written, which NativeApplication.applicationDescriptor gives. */
|
|
22
|
+
readonly xml: string;
|
|
23
|
+
readonly descriptor: AirDescriptor;
|
|
24
|
+
/**
|
|
25
|
+
* Where the files not in memory are on the network, the directory a SWF
|
|
26
|
+
* played alone came from (`airAppForSwf`): an app: URL loads from there
|
|
27
|
+
* what the application does not hold, as its folder on a server is.
|
|
28
|
+
*/
|
|
29
|
+
readonly base: string | null;
|
|
30
|
+
constructor(xml: string, files: Map<string, Entry>, base?: string | null);
|
|
31
|
+
/** The bytes of the file at `path` under the application's directory; null where none is. */
|
|
32
|
+
read(path: string): Uint8Array | null;
|
|
33
|
+
/**
|
|
34
|
+
* The file system File sees: the application's files under its
|
|
35
|
+
* directory, which it does not write, and `files` for the rest, by
|
|
36
|
+
* default its own, in memory.
|
|
37
|
+
*/
|
|
38
|
+
fileSystem(files?: AirFiles): FileSystemHost;
|
|
39
|
+
/**
|
|
40
|
+
* NativeApplication's view: the descriptor, `args` as the launch's
|
|
41
|
+
* arguments, and `window`, the element playing it. Its exit is `exit`.
|
|
42
|
+
*/
|
|
43
|
+
application(window: AirWindow, args: readonly string[], exit: (code: number) => void): AirApplication;
|
|
44
|
+
/**
|
|
45
|
+
* What the application's SWFs load from it: an app: URL, or a file: URL
|
|
46
|
+
* under its directory, from memory, and an app-storage: URL or a file:
|
|
47
|
+
* URL elsewhere from `files`, if given, a missing one as a 404 is. Null
|
|
48
|
+
* for any other URL, which the page's fetch loads.
|
|
49
|
+
*/
|
|
50
|
+
fetch(request: FetchRequest, files?: AirFiles): FetchResult | null;
|
|
51
|
+
/** Where on the network `url`, an app: URL of a file not in memory, is under `base`; null for none. */
|
|
52
|
+
remote(url: string): string | null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The application in `source`: an AIR package's or a ZIP's bytes, or the
|
|
56
|
+
* files of its folder. Its descriptor is the package's, or else the
|
|
57
|
+
* shallowest `*-app.xml` or `application.xml`, whose folder is the
|
|
58
|
+
* application's directory. An Error says what it lacks.
|
|
59
|
+
*/
|
|
60
|
+
export declare function openAirApp(source: Uint8Array | ArrayBuffer | Iterable<AirAppFile>): AirApp;
|
|
61
|
+
/**
|
|
62
|
+
* Whether `swf` is an AIR application's, though it came alone: its
|
|
63
|
+
* ActionScript names a definition only AIR has (AIR_DEFINITIONS), which a
|
|
64
|
+
* browser's Flash Player would refuse it for.
|
|
65
|
+
*/
|
|
66
|
+
export declare function namesAir(swf: Swf): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The AIR application of `bytes`, a SWF played alone from `url`, as adl
|
|
69
|
+
* runs one from a descriptor that names only it: its id and title from
|
|
70
|
+
* its file's name, its directory holding it alone, and the directory it
|
|
71
|
+
* came from, if from a server, where its app: URLs load what else it has.
|
|
72
|
+
*/
|
|
73
|
+
export declare function airAppForSwf(bytes: Uint8Array, url: string): AirApp;
|
|
74
|
+
/**
|
|
75
|
+
* The window an application sees, the element playing it: where it is on
|
|
76
|
+
* the page, the descriptor's title until the application sets another, in
|
|
77
|
+
* the normal state and shown, active while it has the focus.
|
|
78
|
+
*/
|
|
79
|
+
export declare function elementWindow(element: HTMLElement, title: string | null): AirWindow;
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=air.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"air.d.ts","sourceRoot":"","sources":["../src/air.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,aAAa,EAKlB,KAAK,GAAG,EAET,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,cAA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