@akashic/headless-driver 1.11.37 → 2.0.1

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 (139) hide show
  1. package/CHANGELOG.md +1728 -0
  2. package/README.md +30 -0
  3. package/lib/ExecuteVmScriptV1.d.ts +2 -2
  4. package/lib/ExecuteVmScriptV1.js +2 -2
  5. package/lib/ExecuteVmScriptV2.d.ts +2 -2
  6. package/lib/ExecuteVmScriptV2.js +2 -2
  7. package/lib/ExecuteVmScriptV3.d.ts +2 -2
  8. package/lib/ExecuteVmScriptV3.js +2 -2
  9. package/lib/Looper.d.ts +24 -0
  10. package/lib/Looper.js +79 -0
  11. package/lib/index.d.ts +3 -11
  12. package/lib/index.js +8 -12
  13. package/lib/play/AMFlowClientManager.d.ts +1 -1
  14. package/lib/play/Play.d.ts +1 -1
  15. package/lib/play/PlayManager.d.ts +5 -5
  16. package/lib/play/amflow/AMFlowClient.d.ts +4 -4
  17. package/lib/play/amflow/AMFlowStore.d.ts +3 -3
  18. package/lib/play/amflow/index.d.ts +4 -0
  19. package/lib/play/amflow/index.js +20 -0
  20. package/lib/play/amflow/types.d.ts +2 -2
  21. package/lib/play/index.d.ts +5 -0
  22. package/lib/play/index.js +21 -0
  23. package/lib/runner/Platform.d.ts +25 -0
  24. package/lib/runner/Platform.js +34 -0
  25. package/lib/runner/Runner.d.ts +110 -0
  26. package/lib/runner/Runner.js +101 -0
  27. package/lib/runner/RunnerManager.d.ts +6 -6
  28. package/lib/runner/RunnerManager.js +2 -2
  29. package/lib/runner/index.d.ts +7 -0
  30. package/lib/runner/index.js +23 -0
  31. package/lib/runner/types.d.ts +15 -0
  32. package/lib/runner/types.js +2 -0
  33. package/lib/runner/v1/RunnerV1.d.ts +26 -0
  34. package/lib/runner/v1/RunnerV1.js +230 -0
  35. package/lib/runner/v1/index.d.ts +3 -0
  36. package/lib/runner/v1/index.js +23 -0
  37. package/lib/runner/v1/platform/NullAudioPlayer.d.ts +3 -0
  38. package/lib/runner/v1/platform/NullAudioPlayer.js +7 -0
  39. package/lib/runner/v1/platform/NullGlyphFactory.d.ts +6 -0
  40. package/lib/runner/v1/platform/NullGlyphFactory.js +18 -0
  41. package/lib/runner/v1/platform/NullRenderer.d.ts +16 -0
  42. package/lib/runner/v1/platform/NullRenderer.js +46 -0
  43. package/lib/runner/v1/platform/NullSurface.d.ts +7 -0
  44. package/lib/runner/v1/platform/NullSurface.js +18 -0
  45. package/lib/runner/v1/platform/NullVideoPlayer.d.ts +4 -0
  46. package/lib/runner/v1/platform/NullVideoPlayer.js +10 -0
  47. package/lib/runner/v1/platform/PlatformV1.d.ts +22 -0
  48. package/lib/runner/v1/platform/PlatformV1.js +67 -0
  49. package/lib/runner/v1/platform/ResourceFactory.d.ts +18 -0
  50. package/lib/runner/v1/platform/ResourceFactory.js +53 -0
  51. package/lib/runner/v1/platform/assets/NodeScriptAsset.d.ts +16 -0
  52. package/lib/runner/v1/platform/assets/NodeScriptAsset.js +36 -0
  53. package/lib/runner/v1/platform/assets/NodeTextAsset.d.ts +11 -0
  54. package/lib/runner/v1/platform/assets/NodeTextAsset.js +23 -0
  55. package/lib/runner/v1/platform/assets/NullAudioAsset.d.ts +4 -0
  56. package/lib/runner/v1/platform/assets/NullAudioAsset.js +10 -0
  57. package/lib/runner/v1/platform/assets/NullImageAsset.d.ts +6 -0
  58. package/lib/runner/v1/platform/assets/NullImageAsset.js +18 -0
  59. package/lib/runner/v1/platform/assets/NullVideoAsset.d.ts +10 -0
  60. package/lib/runner/v1/platform/assets/NullVideoAsset.js +25 -0
  61. package/lib/runner/v2/RunnerV2.d.ts +26 -0
  62. package/lib/runner/v2/RunnerV2.js +229 -0
  63. package/lib/runner/v2/index.d.ts +3 -0
  64. package/lib/runner/v2/index.js +23 -0
  65. package/lib/runner/v2/platform/NullAudioPlayer.d.ts +3 -0
  66. package/lib/runner/v2/platform/NullAudioPlayer.js +7 -0
  67. package/lib/runner/v2/platform/NullGlyphFactory.d.ts +6 -0
  68. package/lib/runner/v2/platform/NullGlyphFactory.js +18 -0
  69. package/lib/runner/v2/platform/NullRenderer.d.ts +20 -0
  70. package/lib/runner/v2/platform/NullRenderer.js +58 -0
  71. package/lib/runner/v2/platform/NullSurface.d.ts +7 -0
  72. package/lib/runner/v2/platform/NullSurface.js +18 -0
  73. package/lib/runner/v2/platform/NullVideoPlayer.d.ts +4 -0
  74. package/lib/runner/v2/platform/NullVideoPlayer.js +10 -0
  75. package/lib/runner/v2/platform/PlatformV2.d.ts +23 -0
  76. package/lib/runner/v2/platform/PlatformV2.js +70 -0
  77. package/lib/runner/v2/platform/ResourceFactory.d.ts +18 -0
  78. package/lib/runner/v2/platform/ResourceFactory.js +53 -0
  79. package/lib/runner/v2/platform/assets/NodeScriptAsset.d.ts +16 -0
  80. package/lib/runner/v2/platform/assets/NodeScriptAsset.js +36 -0
  81. package/lib/runner/v2/platform/assets/NodeTextAsset.d.ts +11 -0
  82. package/lib/runner/v2/platform/assets/NodeTextAsset.js +23 -0
  83. package/lib/runner/v2/platform/assets/NullAudioAsset.d.ts +4 -0
  84. package/lib/runner/v2/platform/assets/NullAudioAsset.js +10 -0
  85. package/lib/runner/v2/platform/assets/NullImageAsset.d.ts +6 -0
  86. package/lib/runner/v2/platform/assets/NullImageAsset.js +18 -0
  87. package/lib/runner/v2/platform/assets/NullVideoAsset.d.ts +10 -0
  88. package/lib/runner/v2/platform/assets/NullVideoAsset.js +25 -0
  89. package/lib/runner/v3/RunnerV3.d.ts +38 -0
  90. package/lib/runner/v3/RunnerV3.js +245 -0
  91. package/lib/runner/v3/engineFiles.d.ts +2 -0
  92. package/lib/runner/v3/engineFiles.js +31 -0
  93. package/lib/runner/v3/index.d.ts +5 -0
  94. package/lib/runner/v3/index.js +25 -0
  95. package/lib/runner/v3/platform/NodeCanvasResourceFactory.d.ts +22 -0
  96. package/lib/runner/v3/platform/NodeCanvasResourceFactory.js +57 -0
  97. package/lib/runner/v3/platform/NullResourceFactory.d.ts +21 -0
  98. package/lib/runner/v3/platform/NullResourceFactory.js +54 -0
  99. package/lib/runner/v3/platform/PlatformV3.d.ts +23 -0
  100. package/lib/runner/v3/platform/PlatformV3.js +94 -0
  101. package/lib/runner/v3/platform/assets/Asset.d.ts +14 -0
  102. package/lib/runner/v3/platform/assets/Asset.js +30 -0
  103. package/lib/runner/v3/platform/assets/NodeScriptAsset.d.ts +19 -0
  104. package/lib/runner/v3/platform/assets/NodeScriptAsset.js +48 -0
  105. package/lib/runner/v3/platform/assets/NodeTextAsset.d.ts +14 -0
  106. package/lib/runner/v3/platform/assets/NodeTextAsset.js +35 -0
  107. package/lib/runner/v3/platform/audios/NullAudioAsset.d.ts +15 -0
  108. package/lib/runner/v3/platform/audios/NullAudioAsset.js +28 -0
  109. package/lib/runner/v3/platform/audios/NullAudioPlayer.d.ts +17 -0
  110. package/lib/runner/v3/platform/audios/NullAudioPlayer.js +34 -0
  111. package/lib/runner/v3/platform/graphics/canvas/CompositeOperationConverter.d.ts +6 -0
  112. package/lib/runner/v3/platform/graphics/canvas/CompositeOperationConverter.js +78 -0
  113. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasGlyph.d.ts +16 -0
  114. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasGlyph.js +25 -0
  115. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasGlyphFactory.d.ts +24 -0
  116. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasGlyphFactory.js +204 -0
  117. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasImageAsset.d.ts +16 -0
  118. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasImageAsset.js +78 -0
  119. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasRenderer.d.ts +26 -0
  120. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasRenderer.js +72 -0
  121. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasSurface.d.ts +14 -0
  122. package/lib/runner/v3/platform/graphics/canvas/NodeCanvasSurface.js +25 -0
  123. package/lib/runner/v3/platform/graphics/null/NullGlyph.d.ts +16 -0
  124. package/lib/runner/v3/platform/graphics/null/NullGlyph.js +25 -0
  125. package/lib/runner/v3/platform/graphics/null/NullGlyphFactory.d.ts +14 -0
  126. package/lib/runner/v3/platform/graphics/null/NullGlyphFactory.js +22 -0
  127. package/lib/runner/v3/platform/graphics/null/NullImageAsset.d.ts +13 -0
  128. package/lib/runner/v3/platform/graphics/null/NullImageAsset.js +24 -0
  129. package/lib/runner/v3/platform/graphics/null/NullRenderer.d.ts +21 -0
  130. package/lib/runner/v3/platform/graphics/null/NullRenderer.js +60 -0
  131. package/lib/runner/v3/platform/graphics/null/NullSurface.d.ts +14 -0
  132. package/lib/runner/v3/platform/graphics/null/NullSurface.js +26 -0
  133. package/lib/runner/v3/platform/videos/NullVideoAsset.d.ts +20 -0
  134. package/lib/runner/v3/platform/videos/NullVideoAsset.js +37 -0
  135. package/lib/runner/v3/platform/videos/NullVideoPlayer.d.ts +14 -0
  136. package/lib/runner/v3/platform/videos/NullVideoPlayer.js +25 -0
  137. package/lib/runner/v3/requireEngineFiles.d.ts +5 -0
  138. package/lib/runner/v3/requireEngineFiles.js +21 -0
  139. package/package.json +33 -25
@@ -0,0 +1,5 @@
1
+ export * from "./RunnerV3";
2
+ export * from "./platform/PlatformV3";
3
+ export { akashicEngine as RunnerV3_g } from "./engineFiles";
4
+ export { gameDriver as RunnerV3_gdr } from "./engineFiles";
5
+ export { pdi as RunnerV3_pdi } from "./engineFiles";
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.RunnerV3_pdi = exports.RunnerV3_gdr = exports.RunnerV3_g = void 0;
18
+ __exportStar(require("./RunnerV3"), exports);
19
+ __exportStar(require("./platform/PlatformV3"), exports);
20
+ var engineFiles_1 = require("./engineFiles");
21
+ Object.defineProperty(exports, "RunnerV3_g", { enumerable: true, get: function () { return engineFiles_1.akashicEngine; } });
22
+ var engineFiles_2 = require("./engineFiles");
23
+ Object.defineProperty(exports, "RunnerV3_gdr", { enumerable: true, get: function () { return engineFiles_2.gameDriver; } });
24
+ var engineFiles_3 = require("./engineFiles");
25
+ Object.defineProperty(exports, "RunnerV3_pdi", { enumerable: true, get: function () { return engineFiles_3.pdi; } });
@@ -0,0 +1,22 @@
1
+ import type { akashicEngine as g } from "../engineFiles";
2
+ export interface NodeCanvasResourceFactoryParameters {
3
+ loadFileHandler: (url: string, callback: (err: Error | null, data?: string) => void) => void;
4
+ errorHandler: (err: Error) => void;
5
+ }
6
+ /**
7
+ * node-canvas への描画出力機能を持つ ResourceFactory の実装。
8
+ * 音声再生には未対応。
9
+ */
10
+ export declare class NodeCanvasResourceFactory implements g.ResourceFactory {
11
+ private loadFileHandler;
12
+ private errorHandler;
13
+ constructor({ loadFileHandler, errorHandler }: NodeCanvasResourceFactoryParameters);
14
+ createImageAsset(id: string, assetPath: string, width: number, height: number): g.ImageAsset;
15
+ createVideoAsset(id: string, assetPath: string, width: number, height: number, system: g.VideoSystem, loop: boolean, useRealSize: boolean): g.VideoAsset;
16
+ createAudioAsset(id: string, assetPath: string, duration: number, system: g.AudioSystem, loop: boolean, hint: g.AudioAssetHint): g.AudioAsset;
17
+ createAudioPlayer(system: g.AudioSystem): g.AudioPlayer;
18
+ createTextAsset(id: string, assetPath: string): g.TextAsset;
19
+ createScriptAsset(id: string, assetPath: string): g.ScriptAsset;
20
+ createSurface(width: number, height: number): g.Surface;
21
+ createGlyphFactory(fontFamily: string | string[], fontSize: number, baselineHeight?: number, fontColor?: string, strokeWidth?: number, strokeColor?: string, strokeOnly?: boolean, fontWeight?: g.FontWeightString): g.GlyphFactory;
22
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeCanvasResourceFactory = void 0;
4
+ const canvas_1 = require("canvas");
5
+ const NodeScriptAsset_1 = require("./assets/NodeScriptAsset");
6
+ const NodeTextAsset_1 = require("./assets/NodeTextAsset");
7
+ const NullAudioAsset_1 = require("./audios/NullAudioAsset");
8
+ const NullAudioPlayer_1 = require("./audios/NullAudioPlayer");
9
+ const NodeCanvasGlyphFactory_1 = require("./graphics/canvas/NodeCanvasGlyphFactory");
10
+ const NodeCanvasImageAsset_1 = require("./graphics/canvas/NodeCanvasImageAsset");
11
+ const NodeCanvasSurface_1 = require("./graphics/canvas/NodeCanvasSurface");
12
+ const NullVideoAsset_1 = require("./videos/NullVideoAsset");
13
+ /**
14
+ * node-canvas への描画出力機能を持つ ResourceFactory の実装。
15
+ * 音声再生には未対応。
16
+ */
17
+ class NodeCanvasResourceFactory {
18
+ constructor({ loadFileHandler, errorHandler }) {
19
+ this.loadFileHandler = loadFileHandler;
20
+ this.errorHandler = errorHandler;
21
+ }
22
+ createImageAsset(id, assetPath, width, height) {
23
+ return new NodeCanvasImageAsset_1.NodeCanvasImageAsset(id, assetPath, width, height);
24
+ }
25
+ createVideoAsset(id, assetPath, width, height, system, loop, useRealSize) {
26
+ return new NullVideoAsset_1.NullVideoAsset(id, assetPath, width, height, system, loop, useRealSize);
27
+ }
28
+ createAudioAsset(id, assetPath, duration, system, loop, hint) {
29
+ return new NullAudioAsset_1.NullAudioAsset(id, assetPath, duration, system, loop, hint);
30
+ }
31
+ createAudioPlayer(system) {
32
+ return new NullAudioPlayer_1.NullAudioPlayer(system);
33
+ }
34
+ createTextAsset(id, assetPath) {
35
+ return new NodeTextAsset_1.NodeTextAsset({
36
+ id,
37
+ path: assetPath,
38
+ loadFileHandler: this.loadFileHandler
39
+ });
40
+ }
41
+ createScriptAsset(id, assetPath) {
42
+ return new NodeScriptAsset_1.NodeScriptAsset({
43
+ id,
44
+ path: assetPath,
45
+ errorHandler: this.errorHandler,
46
+ loadFileHandler: this.loadFileHandler
47
+ });
48
+ }
49
+ createSurface(width, height) {
50
+ const canvas = new canvas_1.Canvas(width, height);
51
+ return new NodeCanvasSurface_1.NodeCanvasSurface(canvas);
52
+ }
53
+ createGlyphFactory(fontFamily, fontSize, baselineHeight, fontColor, strokeWidth, strokeColor, strokeOnly, fontWeight) {
54
+ return new NodeCanvasGlyphFactory_1.NodeCanvasGlyphFactory(fontFamily, fontSize, baselineHeight, fontColor, strokeWidth, strokeColor, strokeOnly, fontWeight);
55
+ }
56
+ }
57
+ exports.NodeCanvasResourceFactory = NodeCanvasResourceFactory;
@@ -0,0 +1,21 @@
1
+ import type { akashicEngine as g } from "../engineFiles";
2
+ export interface NullResourceFactoryParameters {
3
+ loadFileHandler: (url: string, callback: (err: Error | null, data?: string) => void) => void;
4
+ errorHandler: (err: Error) => void;
5
+ }
6
+ /**
7
+ * 描画出力や音声再生機能を持たない最小限の ResourceFactory の実装。
8
+ */
9
+ export declare class NullResourceFactory implements g.ResourceFactory {
10
+ private loadFileHandler;
11
+ private errorHandler;
12
+ constructor({ loadFileHandler, errorHandler }: NullResourceFactoryParameters);
13
+ createImageAsset(id: string, assetPath: string, width: number, height: number): g.ImageAsset;
14
+ createVideoAsset(id: string, assetPath: string, width: number, height: number, system: g.VideoSystem, loop: boolean, useRealSize: boolean): g.VideoAsset;
15
+ createAudioAsset(id: string, assetPath: string, duration: number, system: g.AudioSystem, loop: boolean, hint: g.AudioAssetHint): g.AudioAsset;
16
+ createAudioPlayer(system: g.AudioSystem): g.AudioPlayer;
17
+ createTextAsset(id: string, assetPath: string): g.TextAsset;
18
+ createScriptAsset(id: string, assetPath: string): g.ScriptAsset;
19
+ createSurface(width: number, height: number): g.Surface;
20
+ createGlyphFactory(fontFamily: string | string[], fontSize: number, baselineHeight?: number, fontColor?: string, strokeWidth?: number, strokeColor?: string, strokeOnly?: boolean, fontWeight?: g.FontWeightString): g.GlyphFactory;
21
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NullResourceFactory = void 0;
4
+ const NodeScriptAsset_1 = require("./assets/NodeScriptAsset");
5
+ const NodeTextAsset_1 = require("./assets/NodeTextAsset");
6
+ const NullAudioAsset_1 = require("./audios/NullAudioAsset");
7
+ const NullAudioPlayer_1 = require("./audios/NullAudioPlayer");
8
+ const NullGlyphFactory_1 = require("./graphics/null/NullGlyphFactory");
9
+ const NullImageAsset_1 = require("./graphics/null/NullImageAsset");
10
+ const NullSurface_1 = require("./graphics/null/NullSurface");
11
+ const NullVideoAsset_1 = require("./videos/NullVideoAsset");
12
+ /**
13
+ * 描画出力や音声再生機能を持たない最小限の ResourceFactory の実装。
14
+ */
15
+ class NullResourceFactory {
16
+ constructor({ loadFileHandler, errorHandler }) {
17
+ this.loadFileHandler = loadFileHandler;
18
+ this.errorHandler = errorHandler;
19
+ }
20
+ createImageAsset(id, assetPath, width, height) {
21
+ return new NullImageAsset_1.NullImageAsset(id, assetPath, width, height);
22
+ }
23
+ createVideoAsset(id, assetPath, width, height, system, loop, useRealSize) {
24
+ return new NullVideoAsset_1.NullVideoAsset(id, assetPath, width, height, system, loop, useRealSize);
25
+ }
26
+ createAudioAsset(id, assetPath, duration, system, loop, hint) {
27
+ return new NullAudioAsset_1.NullAudioAsset(id, assetPath, duration, system, loop, hint);
28
+ }
29
+ createAudioPlayer(system) {
30
+ return new NullAudioPlayer_1.NullAudioPlayer(system);
31
+ }
32
+ createTextAsset(id, assetPath) {
33
+ return new NodeTextAsset_1.NodeTextAsset({
34
+ id,
35
+ path: assetPath,
36
+ loadFileHandler: this.loadFileHandler
37
+ });
38
+ }
39
+ createScriptAsset(id, assetPath) {
40
+ return new NodeScriptAsset_1.NodeScriptAsset({
41
+ id,
42
+ path: assetPath,
43
+ errorHandler: this.errorHandler,
44
+ loadFileHandler: this.loadFileHandler
45
+ });
46
+ }
47
+ createSurface(width, height) {
48
+ return new NullSurface_1.NullSurface(width, height);
49
+ }
50
+ createGlyphFactory(fontFamily, fontSize, baselineHeight, fontColor, strokeWidth, strokeColor, strokeOnly, fontWeight) {
51
+ return new NullGlyphFactory_1.NullGlyphFactory(fontFamily, fontSize, baselineHeight, fontColor, strokeWidth, strokeColor, strokeOnly, fontWeight);
52
+ }
53
+ }
54
+ exports.NullResourceFactory = NullResourceFactory;
@@ -0,0 +1,23 @@
1
+ import { Looper } from "../../../Looper";
2
+ import type { PlatformParameters } from "../../Platform";
3
+ import { Platform } from "../../Platform";
4
+ import type { akashicEngine as g, pdi } from "../engineFiles";
5
+ export declare class PlatformV3 extends Platform implements pdi.Platform {
6
+ private resFac;
7
+ private rendererReq;
8
+ private primarySurface;
9
+ private eventHandler;
10
+ private loopers;
11
+ private isLooperPaused;
12
+ constructor(param: PlatformParameters);
13
+ getResourceFactory(): g.ResourceFactory;
14
+ setRendererRequirement(requirement: pdi.RendererRequirement): void;
15
+ setPlatformEventHandler(handler: pdi.PlatformEventHandler): void;
16
+ getPrimarySurface(): g.Surface;
17
+ createLooper(fun: (deltaTime: number) => number): Looper;
18
+ advanceLoopers(ms: number): void;
19
+ pauseLoopers(): void;
20
+ resumeLoopers(): void;
21
+ stepLoopers(): void;
22
+ firePointEvent(event: pdi.PlatformPointEvent): void;
23
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlatformV3 = void 0;
4
+ const Looper_1 = require("../../../Looper");
5
+ const Platform_1 = require("../../Platform");
6
+ const NullSurface_1 = require("./graphics/null/NullSurface");
7
+ class PlatformV3 extends Platform_1.Platform {
8
+ constructor(param) {
9
+ super(param);
10
+ this.rendererReq = null;
11
+ this.primarySurface = null;
12
+ this.eventHandler = null;
13
+ this.loopers = [];
14
+ this.isLooperPaused = false;
15
+ // NOTE: このファイルの require() 時点で ResourceFactory 側の依存モジュールを読み込ませないよう、動的に require() する。
16
+ // (このモジュールの利用元である headless-driver が NodeVM 上で起動する仕様上の制限のための苦肉の策)
17
+ /* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-var-requires */
18
+ const ResourceFactory = this.renderingMode === "canvas" && this.trusted
19
+ ? require("./NodeCanvasResourceFactory").NodeCanvasResourceFactory
20
+ : require("./NullResourceFactory").NullResourceFactory;
21
+ /* eslint-enable */
22
+ this.resFac = new ResourceFactory({
23
+ errorHandler: (e) => this.errorHandler(e),
24
+ loadFileHandler: param.loadFileHandler
25
+ });
26
+ }
27
+ getResourceFactory() {
28
+ return this.resFac;
29
+ }
30
+ setRendererRequirement(requirement) {
31
+ this.rendererReq = requirement;
32
+ if (this.renderingMode === "canvas") {
33
+ if (this.trusted) {
34
+ /* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-var-requires */
35
+ const Canvas = require("canvas").Canvas;
36
+ const NodeCanvasSurface = require("./graphics/canvas/NodeCanvasSurface").NodeCanvasSurface;
37
+ /* eslint-enable */
38
+ const canvas = new Canvas(this.rendererReq.primarySurfaceWidth, this.rendererReq.primarySurfaceHeight);
39
+ this.primarySurface = new NodeCanvasSurface(canvas);
40
+ }
41
+ else {
42
+ throw Error("PlatformV3#setRendererRequirement(): Must given trusted === `true` if set renderingMode === 'canvas'");
43
+ }
44
+ }
45
+ else {
46
+ this.primarySurface = new NullSurface_1.NullSurface(this.rendererReq.primarySurfaceWidth, this.rendererReq.primarySurfaceHeight);
47
+ }
48
+ }
49
+ setPlatformEventHandler(handler) {
50
+ this.eventHandler = handler;
51
+ }
52
+ getPrimarySurface() {
53
+ if (this.primarySurface == null) {
54
+ throw new Error("PlatformV3#getPrimarySurface(): Primary surface has not been initialized yet");
55
+ }
56
+ return this.primarySurface;
57
+ }
58
+ createLooper(fun) {
59
+ const looper = new Looper_1.Looper(fun, (e) => this.errorHandler(e));
60
+ if (this.isLooperPaused) {
61
+ looper.debugStop();
62
+ }
63
+ this.loopers.push(looper);
64
+ return looper;
65
+ }
66
+ advanceLoopers(ms) {
67
+ for (let i = 0; i < this.loopers.length; i++) {
68
+ this.loopers[i].debugStep(ms);
69
+ }
70
+ }
71
+ pauseLoopers() {
72
+ this.isLooperPaused = true;
73
+ for (let i = 0; i < this.loopers.length; i++) {
74
+ this.loopers[i].debugStop();
75
+ }
76
+ }
77
+ resumeLoopers() {
78
+ this.isLooperPaused = false;
79
+ for (let i = 0; i < this.loopers.length; i++) {
80
+ this.loopers[i].debugStart();
81
+ }
82
+ }
83
+ stepLoopers() {
84
+ for (let i = 0; i < this.loopers.length; i++) {
85
+ // v3 のみ対応。game-driver 側の実装により NaN を渡すと次のフレームまで進む。
86
+ this.loopers[i].debugStep(NaN);
87
+ }
88
+ }
89
+ firePointEvent(event) {
90
+ var _a;
91
+ (_a = this.eventHandler) === null || _a === void 0 ? void 0 : _a.onPointEvent(event);
92
+ }
93
+ }
94
+ exports.PlatformV3 = PlatformV3;
@@ -0,0 +1,14 @@
1
+ import { akashicEngine as g } from "../../engineFiles";
2
+ export declare abstract class Asset implements g.Asset {
3
+ abstract type: string;
4
+ id: string;
5
+ path: string;
6
+ originalPath: string;
7
+ onDestroyed: g.Trigger<g.Asset>;
8
+ constructor(id: string, path: string);
9
+ destroy(): void;
10
+ destroyed(): boolean;
11
+ inUse(): boolean;
12
+ abstract _load(loader: g.AssetLoadHandler): void;
13
+ _assetPathFilter(path: string): string;
14
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Asset = void 0;
4
+ const engineFiles_1 = require("../../engineFiles");
5
+ class Asset {
6
+ constructor(id, path) {
7
+ this.id = id;
8
+ this.originalPath = path;
9
+ this.path = this._assetPathFilter(path);
10
+ this.onDestroyed = new engineFiles_1.akashicEngine.Trigger();
11
+ }
12
+ destroy() {
13
+ this.onDestroyed.fire(this);
14
+ this.id = undefined;
15
+ this.originalPath = undefined;
16
+ this.path = undefined;
17
+ this.onDestroyed.destroy();
18
+ this.onDestroyed = undefined;
19
+ }
20
+ destroyed() {
21
+ return this.id === undefined;
22
+ }
23
+ inUse() {
24
+ return false;
25
+ }
26
+ _assetPathFilter(path) {
27
+ return path;
28
+ }
29
+ }
30
+ exports.Asset = Asset;
@@ -0,0 +1,19 @@
1
+ import type { akashicEngine as g } from "../../engineFiles";
2
+ import { Asset } from "./Asset";
3
+ export interface NodeScriptAssetParameters {
4
+ id: string;
5
+ path: string;
6
+ errorHandler: (err: any) => void;
7
+ loadFileHandler: (url: string, callback: (err: Error | null, data?: string) => void) => void;
8
+ }
9
+ export declare class NodeScriptAsset extends Asset implements g.ScriptAsset {
10
+ static PRE_SCRIPT: string;
11
+ static POST_SCRIPT: string;
12
+ type: "script";
13
+ script: string;
14
+ private errorHandler;
15
+ private loadFileHandler;
16
+ constructor(param: NodeScriptAssetParameters);
17
+ _load(loader: g.AssetLoadHandler): void;
18
+ execute(execEnv: g.ScriptAssetRuntimeValue): any;
19
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeScriptAsset = void 0;
4
+ const Asset_1 = require("./Asset");
5
+ class NodeScriptAsset extends Asset_1.Asset {
6
+ constructor(param) {
7
+ super(param.id, param.path);
8
+ this.type = "script";
9
+ this.script = "";
10
+ this.errorHandler = param.errorHandler;
11
+ this.loadFileHandler = param.loadFileHandler;
12
+ }
13
+ _load(loader) {
14
+ this.loadFileHandler(this.path, (err, text) => {
15
+ if (err) {
16
+ loader._onAssetError(this, {
17
+ name: "AssetLoadError",
18
+ message: err.message,
19
+ retriable: false
20
+ });
21
+ }
22
+ else if (text == null) {
23
+ loader._onAssetError(this, {
24
+ name: "AssetLoadError",
25
+ message: "NoteScriptAsset#_load(): No data received",
26
+ retriable: false
27
+ });
28
+ }
29
+ else {
30
+ this.script = text;
31
+ loader._onAssetLoad(this);
32
+ }
33
+ });
34
+ }
35
+ execute(execEnv) {
36
+ const func = new Function("g", NodeScriptAsset.PRE_SCRIPT + this.script + NodeScriptAsset.POST_SCRIPT);
37
+ try {
38
+ func(execEnv);
39
+ }
40
+ catch (e) {
41
+ this.errorHandler(e);
42
+ }
43
+ return execEnv.module.exports;
44
+ }
45
+ }
46
+ exports.NodeScriptAsset = NodeScriptAsset;
47
+ NodeScriptAsset.PRE_SCRIPT = "(function(exports, require, module, __filename, __dirname) {\n";
48
+ NodeScriptAsset.POST_SCRIPT = "\n})(g.module.exports, g.module.require, g.module, g.filename, g.dirname);";
@@ -0,0 +1,14 @@
1
+ import type { akashicEngine as g } from "../../engineFiles";
2
+ import { Asset } from "./Asset";
3
+ export interface NodeTextAssetParameters {
4
+ id: string;
5
+ path: string;
6
+ loadFileHandler: (url: string, callback: (err: Error | null, data?: string) => void) => void;
7
+ }
8
+ export declare class NodeTextAsset extends Asset implements g.TextAsset {
9
+ type: "text";
10
+ data: string;
11
+ private loadFileHandler;
12
+ constructor(param: NodeTextAssetParameters);
13
+ _load(loader: g.AssetLoadHandler): void;
14
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeTextAsset = void 0;
4
+ const Asset_1 = require("./Asset");
5
+ class NodeTextAsset extends Asset_1.Asset {
6
+ constructor(param) {
7
+ super(param.id, param.path);
8
+ this.type = "text";
9
+ this.data = "";
10
+ this.loadFileHandler = param.loadFileHandler;
11
+ }
12
+ _load(loader) {
13
+ this.loadFileHandler(this.path, (err, text) => {
14
+ if (err) {
15
+ loader._onAssetError(this, {
16
+ name: "AssetLoadError",
17
+ message: err.message,
18
+ retriable: false
19
+ });
20
+ }
21
+ else if (text == null) {
22
+ loader._onAssetError(this, {
23
+ name: "AssetLoadError",
24
+ message: "NodeTextAsset#_load(): No data received",
25
+ retriable: false
26
+ });
27
+ }
28
+ else {
29
+ this.data = text;
30
+ loader._onAssetLoad(this);
31
+ }
32
+ });
33
+ }
34
+ }
35
+ exports.NodeTextAsset = NodeTextAsset;
@@ -0,0 +1,15 @@
1
+ import type { akashicEngine as g } from "../../engineFiles";
2
+ import { Asset } from "../assets/Asset";
3
+ export declare class NullAudioAsset extends Asset implements g.AudioAsset {
4
+ type: "audio";
5
+ data: any;
6
+ duration: number;
7
+ loop: boolean;
8
+ hint: g.AudioAssetHint;
9
+ _system: g.AudioSystem;
10
+ constructor(id: string, assetPath: string, duration: number, system: g.AudioSystem, loop: boolean, hint: g.AudioAssetHint);
11
+ _load(loader: g.AssetLoadHandler): void;
12
+ play(): g.AudioPlayer;
13
+ stop(): void;
14
+ inUse(): boolean;
15
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NullAudioAsset = void 0;
4
+ const Asset_1 = require("../assets/Asset");
5
+ class NullAudioAsset extends Asset_1.Asset {
6
+ constructor(id, assetPath, duration, system, loop, hint) {
7
+ super(id, assetPath);
8
+ this.type = "audio";
9
+ this.duration = duration;
10
+ this.loop = loop;
11
+ this.hint = hint;
12
+ this._system = system;
13
+ this.data = undefined;
14
+ }
15
+ _load(loader) {
16
+ loader._onAssetLoad(this);
17
+ }
18
+ play() {
19
+ return this._system.createPlayer();
20
+ }
21
+ stop() {
22
+ //
23
+ }
24
+ inUse() {
25
+ return this._system.findPlayers(this).length > 0;
26
+ }
27
+ }
28
+ exports.NullAudioAsset = NullAudioAsset;
@@ -0,0 +1,17 @@
1
+ import { akashicEngine as g } from "../../engineFiles";
2
+ export declare class NullAudioPlayer implements g.AudioPlayer {
3
+ currentAudio: g.AudioAsset | undefined;
4
+ onPlay: g.Trigger<g.AudioPlayerEvent>;
5
+ onStop: g.Trigger<g.AudioPlayerEvent>;
6
+ played: g.Trigger<g.AudioPlayerEvent>;
7
+ stopped: g.Trigger<g.AudioPlayerEvent>;
8
+ volume: number;
9
+ _muted: boolean;
10
+ constructor(system: g.AudioSystem);
11
+ play(audio: g.AudioAsset): void;
12
+ stop(): void;
13
+ canHandleStopped(): boolean;
14
+ changeVolume(volume: number): void;
15
+ _changeMuted(muted: boolean): void;
16
+ _notifyVolumeChanged(): void;
17
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NullAudioPlayer = void 0;
4
+ const engineFiles_1 = require("../../engineFiles");
5
+ class NullAudioPlayer {
6
+ constructor(system) {
7
+ this.onPlay = new engineFiles_1.akashicEngine.Trigger();
8
+ this.onStop = new engineFiles_1.akashicEngine.Trigger();
9
+ this.played = this.onPlay;
10
+ this.stopped = this.onStop;
11
+ this.currentAudio = undefined;
12
+ this.volume = system.volume;
13
+ this._muted = system._muted;
14
+ }
15
+ play(audio) {
16
+ this.currentAudio = audio;
17
+ }
18
+ stop() {
19
+ //
20
+ }
21
+ canHandleStopped() {
22
+ return true;
23
+ }
24
+ changeVolume(volume) {
25
+ this.volume = volume;
26
+ }
27
+ _changeMuted(muted) {
28
+ this._muted = muted;
29
+ }
30
+ _notifyVolumeChanged() {
31
+ //
32
+ }
33
+ }
34
+ exports.NullAudioPlayer = NullAudioPlayer;
@@ -0,0 +1,6 @@
1
+ import type { akashicEngine as g } from "../../../engineFiles";
2
+ export declare type CompositeOperation = "source-atop" | "lighter" | "copy" | "source-in" | "source-out" | "destination-atop" | "destination-in" | "destination-out" | "destination-over" | "xor" | "source-over";
3
+ export declare class CompositeOperationConverter {
4
+ static toEngine(operation: CompositeOperation): g.CompositeOperationString;
5
+ static toContext2D(operation: g.CompositeOperationString): CompositeOperation;
6
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompositeOperationConverter = void 0;
4
+ class CompositeOperationConverter {
5
+ static toEngine(operation) {
6
+ if (operation === "source-over") {
7
+ return "source-over";
8
+ }
9
+ else if (operation === "source-atop") {
10
+ return "source-atop";
11
+ }
12
+ else if (operation === "lighter") {
13
+ return "lighter";
14
+ }
15
+ else if (operation === "copy") {
16
+ return "copy";
17
+ }
18
+ else if (operation === "destination-out") {
19
+ return "destination-out";
20
+ }
21
+ else if (operation === "destination-over") {
22
+ return "destination-over";
23
+ }
24
+ else if (operation === "xor") {
25
+ return "xor";
26
+ }
27
+ else if (operation === "source-in") {
28
+ return "experimental-source-in";
29
+ }
30
+ else if (operation === "source-out") {
31
+ return "experimental-source-out";
32
+ }
33
+ else if (operation === "destination-in") {
34
+ return "experimental-destination-in";
35
+ }
36
+ else if (operation === "destination-atop") {
37
+ return "experimental-destination-atop";
38
+ }
39
+ throw new Error(`unknown composite operation: ${operation}`);
40
+ }
41
+ static toContext2D(operation) {
42
+ if (operation === "source-over") {
43
+ return "source-over";
44
+ }
45
+ else if (operation === "source-atop") {
46
+ return "source-atop";
47
+ }
48
+ else if (operation === "lighter") {
49
+ return "lighter";
50
+ }
51
+ else if (operation === "copy") {
52
+ return "copy";
53
+ }
54
+ else if (operation === "destination-out") {
55
+ return "destination-out";
56
+ }
57
+ else if (operation === "destination-over") {
58
+ return "destination-over";
59
+ }
60
+ else if (operation === "xor") {
61
+ return "xor";
62
+ }
63
+ else if (operation === "experimental-source-in") {
64
+ return "source-in";
65
+ }
66
+ else if (operation === "experimental-source-out") {
67
+ return "source-out";
68
+ }
69
+ else if (operation === "experimental-destination-in") {
70
+ return "destination-in";
71
+ }
72
+ else if (operation === "experimental-destination-atop") {
73
+ return "destination-atop";
74
+ }
75
+ throw new Error(`unknown composite operation: ${operation}`);
76
+ }
77
+ }
78
+ exports.CompositeOperationConverter = CompositeOperationConverter;