@swf2es/runtime 0.1.20 → 0.1.21

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.
Files changed (64) hide show
  1. package/dist/avm2/amf.d.ts +1 -1
  2. package/dist/avm2/amf.d.ts.map +1 -1
  3. package/dist/avm2/amf.js +1 -1
  4. package/dist/avm2/amf.js.map +1 -1
  5. package/dist/avm2/enumeration.d.ts +1 -19
  6. package/dist/avm2/enumeration.d.ts.map +1 -1
  7. package/dist/avm2/enumeration.js +1 -51
  8. package/dist/avm2/enumeration.js.map +1 -1
  9. package/dist/avm2/errors.d.ts +2 -0
  10. package/dist/avm2/errors.d.ts.map +1 -1
  11. package/dist/avm2/errors.js +40 -2
  12. package/dist/avm2/errors.js.map +1 -1
  13. package/dist/avm2/index.d.ts +3 -1
  14. package/dist/avm2/index.d.ts.map +1 -1
  15. package/dist/avm2/index.js +3 -1
  16. package/dist/avm2/index.js.map +1 -1
  17. package/dist/avm2/natives/aliases.js +1 -1
  18. package/dist/avm2/natives/aliases.js.map +1 -1
  19. package/dist/avm2/natives/bytearray.d.ts +0 -160
  20. package/dist/avm2/natives/bytearray.d.ts.map +1 -1
  21. package/dist/avm2/natives/bytearray.js +1 -506
  22. package/dist/avm2/natives/bytearray.js.map +1 -1
  23. package/dist/avm2/natives/bytes.d.ts +141 -0
  24. package/dist/avm2/natives/bytes.d.ts.map +1 -0
  25. package/dist/avm2/natives/bytes.js +458 -0
  26. package/dist/avm2/natives/bytes.js.map +1 -0
  27. package/dist/avm2/natives/concurrent.js +1 -1
  28. package/dist/avm2/natives/concurrent.js.map +1 -1
  29. package/dist/avm2/natives/shared-bytes.d.ts +45 -0
  30. package/dist/avm2/natives/shared-bytes.d.ts.map +1 -0
  31. package/dist/avm2/natives/shared-bytes.js +52 -0
  32. package/dist/avm2/natives/shared-bytes.js.map +1 -0
  33. package/dist/avm2/natives/shell.d.ts.map +1 -1
  34. package/dist/avm2/natives/shell.js +3 -1
  35. package/dist/avm2/natives/shell.js.map +1 -1
  36. package/dist/avm2/options.d.ts +1 -1
  37. package/dist/avm2/options.d.ts.map +1 -1
  38. package/dist/avm2/runtime-xml.d.ts +11 -0
  39. package/dist/avm2/runtime-xml.d.ts.map +1 -0
  40. package/dist/avm2/runtime-xml.js +44 -0
  41. package/dist/avm2/runtime-xml.js.map +1 -0
  42. package/dist/avm2/runtime.d.ts +5 -13
  43. package/dist/avm2/runtime.d.ts.map +1 -1
  44. package/dist/avm2/runtime.js +17 -67
  45. package/dist/avm2/runtime.js.map +1 -1
  46. package/dist/avm2/sparse-indices.d.ts +34 -0
  47. package/dist/avm2/sparse-indices.d.ts.map +1 -0
  48. package/dist/avm2/sparse-indices.js +54 -0
  49. package/dist/avm2/sparse-indices.js.map +1 -0
  50. package/package.json +2 -2
  51. package/src/avm2/amf.ts +1 -1
  52. package/src/avm2/enumeration.ts +1 -76
  53. package/src/avm2/errors.ts +48 -3
  54. package/src/avm2/index.ts +9 -12
  55. package/src/avm2/natives/aliases.ts +1 -1
  56. package/src/avm2/natives/bytearray.ts +1 -616
  57. package/src/avm2/natives/bytes.ts +543 -0
  58. package/src/avm2/natives/concurrent.ts +1 -1
  59. package/src/avm2/natives/shared-bytes.ts +99 -0
  60. package/src/avm2/natives/shell.ts +3 -8
  61. package/src/avm2/options.ts +1 -1
  62. package/src/avm2/runtime-xml.ts +54 -0
  63. package/src/avm2/runtime.ts +31 -78
  64. package/src/avm2/sparse-indices.ts +80 -0
@@ -3,170 +3,10 @@ import type { IndexHook } from "../hooks.js";
3
3
  import type { Runtime } from "../runtime.js";
4
4
  import type { Traits } from "../traits.js";
5
5
  import { type Natives } from "./define.js";
6
- /** DomainEnv::GLOBAL_MEMORY_MIN_SIZE: domain memory's least length. */
7
- export declare const GLOBAL_MEMORY_MIN_SIZE = 1024;
8
- /**
9
- * A shareable ByteArray's memory once it has crossed to another worker,
10
- * which every worker's ByteArray for it uses, as avmplus' ByteArrays share
11
- * one Buffer: its bytes grow in place, and its length is one for all.
12
- * Plain data, which a structured clone carries to another thread.
13
- */
14
- export interface SharedBytesMemory {
15
- /** The same in every worker, by which each VM keeps one ByteArray for it, as avmplus interns it. */
16
- id: number;
17
- /** Its words: the length, as a uint32. */
18
- meta: SharedArrayBuffer;
19
- /** Its bytes, as long as its capacity: growable, up to the most a ByteArray holds where it can. */
20
- data: SharedArrayBuffer;
21
- }
22
- /**
23
- * Whether this thread can share memory with others: SharedArrayBuffer is
24
- * there, as node always has it, and a browser only for a page that is
25
- * cross-origin isolated.
26
- */
27
- export declare function canShareMemory(): boolean;
28
- /** What a page that is not cross-origin isolated gets for sharing `what` with another worker. */
29
- export declare function notIsolated(what: string): Error;
30
- /** The capacity of `rt`'s ByteArrays, which avmshell's System counts in its memory. */
31
- export declare function byteArrayCapacity(rt: Runtime): number;
32
- /**
33
- * A ByteArray's state: its buffer, as long as its capacity, and its length
34
- * and position. A read or write takes its offset first: growing replaces
35
- * the buffer and its view.
36
- *
37
- * A length or position is stored through `>>> 0`, as a uint32: an int32
38
- * while below 2^31, and a double only from there.
39
- * JavaScriptCore keeps a number its JIT once made a double a double, and
40
- * an addition that has seen one makes doubles from then on: a double
41
- * offset fails the int32 check of a DataView or typed array access, and
42
- * after enough failures JavaScriptCore calls DataView's methods instead
43
- * of inlining them, a quarter slower on every read and write. V8 makes
44
- * small integers of them itself.
45
- */
46
- export declare class Bytes {
47
- readonly rt: Runtime;
48
- readonly owner: AsObject;
49
- buffer: Uint8Array;
50
- view: DataView<ArrayBufferLike>;
51
- length: number;
52
- position: number;
53
- littleEndian: boolean;
54
- /** As ByteArray's constructor: ByteArray.defaultObjectEncoding when it is made. */
55
- objectEncoding: number;
56
- /** Whether it is the domain memory, which it then tells when its buffer or length changes. */
57
- subscribed: boolean;
58
- /**
59
- * Whether `shareable` was set true, which cannot be undone: the
60
- * ByteArray then crosses to another worker as its memory, not a copy.
61
- */
62
- shareable: boolean;
63
- /**
64
- * Its memory once it has crossed to another worker (share), which its
65
- * buffer and view are then over, tracking its length as it grows; null
66
- * until then, when it is a ByteArray like any other.
67
- */
68
- shared: SharedBytesMemory | null;
69
- /** The shared memory's words, the length first, and its bytes as words for the atomics. */
70
- private sharedWords;
71
- private sharedInts;
72
- /** Its runtime's capacity count, and its own part of it. */
73
- private readonly capacity;
74
- constructor(rt: Runtime, owner: AsObject);
75
- /** Its buffer replaced by `next`, its runtime's capacity count with it. */
76
- setBuffer(next: Uint8Array<ArrayBuffer>): void;
77
- get available(): number;
78
- /** As Grower::ReallocBackingStore: a new buffer, the old length's bytes copied and the rest zero. */
79
- private realloc;
80
- /** As Grower::EnsureWritableCapacity: double, at least `minimum`, and 4096 unless the setter sizes an empty one. */
81
- private ensure;
82
- /** As ByteArray::SetLengthCommon. */
83
- setLength(length: number, fromSetter?: boolean): void;
84
- /**
85
- * The length made at least `length`, as a write past the end makes it:
86
- * shared, by a compare and swap that only ever raises it, so that
87
- * workers appending at once never lower what another made it.
88
- */
89
- extend(length: number): void;
90
- /** A shared length raised to `length` unless another worker made it as long. */
91
- private raise;
92
- /** As Grower::SetLengthCommon, before the length is set: the capacity for `length`. */
93
- private reserve;
94
- /** Tell the domain memory, if this is it, where the bytes are now: a new view only if they moved or their length changed. */
95
- notify(): void;
96
- /** As ByteArray::Clear: no buffer at all; shared, every worker's ByteArray for it empty. */
97
- clear(): void;
98
- /**
99
- * Its memory, shared from now on: a growable SharedArrayBuffer its bytes
100
- * move to once, and that this ByteArray, and every worker's ByteArray for
101
- * it, uses from then on. Where memory cannot be shared, the error that
102
- * names cross-origin isolation.
103
- */
104
- share(): SharedBytesMemory;
105
- /**
106
- * Use `memory`, shared, as its bytes and length from now on. Its length
107
- * becomes an accessor of the memory's word on this object alone, so that
108
- * every read sees another worker's change and every write is seen, and
109
- * a ByteArray that shares nothing reads a plain field as before.
110
- */
111
- adopt(memory: SharedBytesMemory): void;
112
- /**
113
- * A shared memory's capacity made at least `capacity`: it grows in place,
114
- * which every worker sees, and never shrinks, as another worker may have
115
- * grown it past what this one asks for since. Nor is what a smaller
116
- * buffer would drop zeroed: without avmplus' safepoint, another worker
117
- * may have grown the length again and written there meanwhile, so bytes
118
- * past a lowered length may come back when it grows again.
119
- */
120
- private reshare;
121
- /** As ByteArray::CAS, once the index is checked: atomic where the memory is shared. */
122
- compareAndSwapInt(at: number, expected: number, next: number): number;
123
- /**
124
- * As UnprotectedAtomicCompareAndSwapLength: the length set to `next`, as
125
- * its setter sets it, if it is `expected`; the length before. Shared,
126
- * the capacity is made first and the length swapped atomically, so that
127
- * of workers growing it at once one wins.
128
- */
129
- compareAndSwapLength(expected: number, next: number): number;
130
- /** As requestBytesForShortRead: the offset of `n` bytes to read, or EOFError. */
131
- shortRead(n: number): number;
132
- /** As requestBytesForShortWrite: the offset of `n` bytes to write, the length grown to hold them. */
133
- shortWrite(n: number): number;
134
- /** As DataInput::CheckEOF. */
135
- checkEOF(count: number): void;
136
- /** As ByteArray::Read: `count` bytes from the position. */
137
- read(count: number): Uint8Array;
138
- /** As read, but the bytes themselves, not a copy: for a caller that only reads them, at once. */
139
- readView(count: number): Uint8Array;
140
- /**
141
- * As ByteArray::Write: `count` bytes of `source` from `offset`, all of
142
- * it by default, at the position; the length grows to the position after.
143
- */
144
- write(source: Uint8Array, offset?: number, count?: number): void;
145
- /**
146
- * As ByteArray::Write but for the bytes, which the caller writes itself:
147
- * room for `count` at the position, which moves past them, the length
148
- * growing to it. Where in the buffer they start.
149
- */
150
- claim(count: number): number;
151
- /** As ByteArray's operator[] for a write: the length grows to hold `index`. */
152
- setByte(index: number, value: number): void;
153
- }
154
6
  /** How a ByteArray's elements are indexed: its bytes; past its length undefined, and a write grows it. */
155
7
  export declare const byteArrayHook: IndexHook & {
156
8
  create: (traits: Traits, rt: Runtime) => AsObject;
157
9
  };
158
- /** A ByteArray's state, made the first time a native needs it. */
159
- export declare function bytesOf(rt: Runtime, o: AsObject): Bytes;
160
- /**
161
- * A shareable ByteArray's memory, shared from now on, as it crosses to
162
- * another worker; where memory cannot be shared, the error that names
163
- * cross-origin isolation.
164
- */
165
- export declare function shareBytes(rt: Runtime, o: AsObject): SharedBytesMemory;
166
- /** This VM's one ByteArray for a shared memory, as avmplus interns one for its Buffer: shareable, at position 0. */
167
- export declare function sharedByteArray(rt: Runtime, memory: SharedBytesMemory): AsObject;
168
- /** This VM's ByteArray for the shared memory `id`, if it has one. */
169
- export declare function knownSharedByteArray(rt: Runtime, id: number): AsObject | undefined;
170
10
  /** ByteArray's natives, by the names the compiler gives them. */
171
11
  /** ByteArray's natives, for `rt`: written as a class, each running with the ByteArray object as `this`. */
172
12
  export declare function byteArrayNatives(rt: Runtime): Natives;
@@ -1 +1 @@
1
- {"version":3,"file":"bytearray.d.ts","sourceRoot":"","sources":["../../../src/avm2/natives/bytearray.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,QAAQ,EAAU,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,KAAK,OAAO,EAAuB,MAAM,aAAa,CAAC;AAWhE,uEAAuE;AACvE,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAI3C;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,oGAAoG;IACpG,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,IAAI,EAAE,iBAAiB,CAAC;IACxB,mGAAmG;IACnG,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAmBD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAGxC;AAED,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAI/C;AA2BD,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,OAAO,GAAG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