@momoyu-ink/kit 0.4.2 → 0.5.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 (181) hide show
  1. package/dist/jsx-dev-runtime--ZXLAgUi.d.mts +600 -0
  2. package/dist/jsx-dev-runtime--ZXLAgUi.d.ts +600 -0
  3. package/dist/jsx-dev-runtime.cjs +27 -0
  4. package/dist/jsx-dev-runtime.d.mts +4 -0
  5. package/dist/jsx-dev-runtime.d.ts +4 -0
  6. package/dist/jsx-dev-runtime.mjs +6 -0
  7. package/dist/jsx-runtime.cjs +28 -0
  8. package/dist/jsx-runtime.d.mts +4 -0
  9. package/dist/jsx-runtime.d.ts +4 -0
  10. package/dist/jsx-runtime.mjs +7 -0
  11. package/dist/lib.cjs +1610 -0
  12. package/dist/lib.d.mts +668 -0
  13. package/dist/lib.d.ts +668 -15
  14. package/dist/lib.mjs +1641 -0
  15. package/package.json +29 -8
  16. package/dist/bindings/AnimationFormat.d.ts +0 -1
  17. package/dist/bindings/AnimationFormat.js +0 -3
  18. package/dist/bindings/AnimationFrameCallbackEvent.d.ts +0 -3
  19. package/dist/bindings/AnimationFrameCallbackEvent.js +0 -3
  20. package/dist/bindings/AnimationProps.d.ts +0 -6
  21. package/dist/bindings/AnimationProps.js +0 -2
  22. package/dist/bindings/AudioCommand.d.ts +0 -54
  23. package/dist/bindings/AudioCommand.js +0 -2
  24. package/dist/bindings/AudioSettings.d.ts +0 -42
  25. package/dist/bindings/AudioSettings.js +0 -3
  26. package/dist/bindings/BackdropProps.d.ts +0 -6
  27. package/dist/bindings/BackdropProps.js +0 -2
  28. package/dist/bindings/BeforeUnloadEvent.d.ts +0 -1
  29. package/dist/bindings/BeforeUnloadEvent.js +0 -3
  30. package/dist/bindings/ClipProps.d.ts +0 -4
  31. package/dist/bindings/ClipProps.js +0 -3
  32. package/dist/bindings/CustomEvent.d.ts +0 -18
  33. package/dist/bindings/CustomEvent.js +0 -3
  34. package/dist/bindings/EffectParams.d.ts +0 -6
  35. package/dist/bindings/EffectParams.js +0 -3
  36. package/dist/bindings/FilterKind.d.ts +0 -34
  37. package/dist/bindings/FilterKind.js +0 -3
  38. package/dist/bindings/FilterProps.d.ts +0 -4
  39. package/dist/bindings/FilterProps.js +0 -2
  40. package/dist/bindings/FocusEvent.d.ts +0 -5
  41. package/dist/bindings/FocusEvent.js +0 -2
  42. package/dist/bindings/FocusEventKind.d.ts +0 -1
  43. package/dist/bindings/FocusEventKind.js +0 -3
  44. package/dist/bindings/FullScreenEvent.d.ts +0 -4
  45. package/dist/bindings/FullScreenEvent.js +0 -2
  46. package/dist/bindings/FullscreenEventKind.d.ts +0 -1
  47. package/dist/bindings/FullscreenEventKind.js +0 -3
  48. package/dist/bindings/GameEvent.d.ts +0 -1
  49. package/dist/bindings/GameEvent.js +0 -3
  50. package/dist/bindings/Gamepad.d.ts +0 -44
  51. package/dist/bindings/Gamepad.js +0 -2
  52. package/dist/bindings/GamepadButton.d.ts +0 -20
  53. package/dist/bindings/GamepadButton.js +0 -3
  54. package/dist/bindings/GamepadCommand.d.ts +0 -9
  55. package/dist/bindings/GamepadCommand.js +0 -2
  56. package/dist/bindings/GamepadEvent.d.ts +0 -12
  57. package/dist/bindings/GamepadEvent.js +0 -2
  58. package/dist/bindings/GamepadHapticActuator.d.ts +0 -11
  59. package/dist/bindings/GamepadHapticActuator.js +0 -3
  60. package/dist/bindings/KeyboardEventKind.d.ts +0 -1
  61. package/dist/bindings/KeyboardEventKind.js +0 -3
  62. package/dist/bindings/KeyboardLocation.d.ts +0 -1
  63. package/dist/bindings/KeyboardLocation.js +0 -3
  64. package/dist/bindings/Literal.d.ts +0 -3
  65. package/dist/bindings/Literal.js +0 -3
  66. package/dist/bindings/MouseEventKind.d.ts +0 -1
  67. package/dist/bindings/MouseEventKind.js +0 -3
  68. package/dist/bindings/MoyuCursor.d.ts +0 -1
  69. package/dist/bindings/MoyuCursor.js +0 -3
  70. package/dist/bindings/NineSliceMode.d.ts +0 -1
  71. package/dist/bindings/NineSliceMode.js +0 -3
  72. package/dist/bindings/NodeEvent.d.ts +0 -4
  73. package/dist/bindings/NodeEvent.js +0 -3
  74. package/dist/bindings/NodeProps.d.ts +0 -20
  75. package/dist/bindings/NodeProps.js +0 -2
  76. package/dist/bindings/RawKeyboardEvent.d.ts +0 -16
  77. package/dist/bindings/RawKeyboardEvent.js +0 -2
  78. package/dist/bindings/RawMouseEvent.d.ts +0 -12
  79. package/dist/bindings/RawMouseEvent.js +0 -2
  80. package/dist/bindings/RawTouchEvent.d.ts +0 -13
  81. package/dist/bindings/RawTouchEvent.js +0 -2
  82. package/dist/bindings/RawWheelEvent.d.ts +0 -10
  83. package/dist/bindings/RawWheelEvent.js +0 -2
  84. package/dist/bindings/ResizeEvent.d.ts +0 -4
  85. package/dist/bindings/ResizeEvent.js +0 -3
  86. package/dist/bindings/ResolvedArgument.d.ts +0 -5
  87. package/dist/bindings/ResolvedArgument.js +0 -2
  88. package/dist/bindings/ResolvedCommandLine.d.ts +0 -5
  89. package/dist/bindings/ResolvedCommandLine.js +0 -2
  90. package/dist/bindings/ResolvedSystemCallLine.d.ts +0 -5
  91. package/dist/bindings/ResolvedSystemCallLine.js +0 -2
  92. package/dist/bindings/ScenarioCommand.d.ts +0 -103
  93. package/dist/bindings/ScenarioCommand.js +0 -2
  94. package/dist/bindings/ScenarioEvent.d.ts +0 -4
  95. package/dist/bindings/ScenarioEvent.js +0 -2
  96. package/dist/bindings/SpriteMode.d.ts +0 -1
  97. package/dist/bindings/SpriteMode.js +0 -3
  98. package/dist/bindings/SpriteProps.d.ts +0 -11
  99. package/dist/bindings/SpriteProps.js +0 -2
  100. package/dist/bindings/SystemCommand.d.ts +0 -30
  101. package/dist/bindings/SystemCommand.js +0 -2
  102. package/dist/bindings/TextCommand.d.ts +0 -9
  103. package/dist/bindings/TextCommand.js +0 -3
  104. package/dist/bindings/TextEvent.d.ts +0 -1
  105. package/dist/bindings/TextEvent.js +0 -3
  106. package/dist/bindings/TextLine.d.ts +0 -5
  107. package/dist/bindings/TextLine.js +0 -3
  108. package/dist/bindings/TextPrintMode.d.ts +0 -4
  109. package/dist/bindings/TextPrintMode.js +0 -3
  110. package/dist/bindings/TextProps.d.ts +0 -41
  111. package/dist/bindings/TextProps.js +0 -2
  112. package/dist/bindings/TouchEventKind.d.ts +0 -1
  113. package/dist/bindings/TouchEventKind.js +0 -3
  114. package/dist/bindings/VideoCommand.d.ts +0 -21
  115. package/dist/bindings/VideoCommand.js +0 -3
  116. package/dist/bindings/VideoEvent.d.ts +0 -1
  117. package/dist/bindings/VideoEvent.js +0 -3
  118. package/dist/bindings/VideoProps.d.ts +0 -7
  119. package/dist/bindings/VideoProps.js +0 -3
  120. package/dist/bindings/WheelEventDeltaMode.d.ts +0 -1
  121. package/dist/bindings/WheelEventDeltaMode.js +0 -3
  122. package/dist/bindings/WindowState.d.ts +0 -1
  123. package/dist/bindings/WindowState.js +0 -3
  124. package/dist/bindings/serde_json/JsonValue.d.ts +0 -3
  125. package/dist/bindings/serde_json/JsonValue.js +0 -3
  126. package/dist/commands.d.ts +0 -17
  127. package/dist/commands.js +0 -24
  128. package/dist/components/navigation.d.ts +0 -154
  129. package/dist/components/navigation.js +0 -252
  130. package/dist/declaration.d.ts +0 -80
  131. package/dist/declaration.js +0 -2
  132. package/dist/events/base.d.ts +0 -16
  133. package/dist/events/base.js +0 -19
  134. package/dist/events/globals.d.ts +0 -2
  135. package/dist/events/globals.js +0 -122
  136. package/dist/events/keyboard.d.ts +0 -37
  137. package/dist/events/keyboard.js +0 -2
  138. package/dist/events/listener.d.ts +0 -1
  139. package/dist/events/listener.js +0 -13
  140. package/dist/events/mouse.d.ts +0 -15
  141. package/dist/events/mouse.js +0 -2
  142. package/dist/events/touch.d.ts +0 -16
  143. package/dist/events/touch.js +0 -2
  144. package/dist/events/wheel.d.ts +0 -9
  145. package/dist/events/wheel.js +0 -2
  146. package/dist/events.d.ts +0 -33
  147. package/dist/events.js +0 -49
  148. package/dist/hooks/useFadeInOut.d.ts +0 -16
  149. package/dist/hooks/useFadeInOut.js +0 -62
  150. package/dist/hooks/useScenario.d.ts +0 -13
  151. package/dist/hooks/useScenario.js +0 -64
  152. package/dist/hooks/useSoundEffect.d.ts +0 -4
  153. package/dist/hooks/useSoundEffect.js +0 -63
  154. package/dist/hooks/useStage.d.ts +0 -126
  155. package/dist/hooks/useStage.js +0 -706
  156. package/dist/hooks.d.ts +0 -4
  157. package/dist/hooks.js +0 -20
  158. package/dist/lib.js +0 -54
  159. package/dist/moyu.d.ts +0 -19
  160. package/dist/moyu.js +0 -49
  161. package/dist/node.d.ts +0 -16
  162. package/dist/node.js +0 -105
  163. package/dist/react.d.ts +0 -20
  164. package/dist/react.js +0 -222
  165. package/dist/runtime-globals.d.ts +0 -65
  166. package/dist/runtime-globals.js +0 -2
  167. package/dist/sandbox.d.ts +0 -1
  168. package/dist/sandbox.js +0 -88
  169. package/dist/spring/animated.d.ts +0 -27
  170. package/dist/spring/animated.js +0 -2
  171. package/dist/spring/index.d.ts +0 -5
  172. package/dist/spring/index.js +0 -35
  173. package/dist/spring/primitives.d.ts +0 -3
  174. package/dist/spring/primitives.js +0 -13
  175. package/dist/state.d.ts +0 -6
  176. package/dist/state.js +0 -8
  177. package/dist/utils.d.ts +0 -10
  178. package/dist/utils.js +0 -10
  179. package/dist/zod-patch.d.ts +0 -10
  180. package/dist/zod-patch.js +0 -2
  181. package/jsx-runtime.d.ts +0 -1
package/dist/hooks.js DELETED
@@ -1,20 +0,0 @@
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
- __exportStar(require("./hooks/useFadeInOut"), exports);
18
- __exportStar(require("./hooks/useScenario"), exports);
19
- __exportStar(require("./hooks/useSoundEffect"), exports);
20
- __exportStar(require("./hooks/useStage"), exports);
package/dist/lib.js DELETED
@@ -1,54 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
- var __importStar = (this && this.__importStar) || (function () {
22
- var ownKeys = function(o) {
23
- ownKeys = Object.getOwnPropertyNames || function (o) {
24
- var ar = [];
25
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
- return ar;
27
- };
28
- return ownKeys(o);
29
- };
30
- return function (mod) {
31
- if (mod && mod.__esModule) return mod;
32
- var result = {};
33
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
- __setModuleDefault(result, mod);
35
- return result;
36
- };
37
- })();
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.moyu = exports.executePluginCommand = exports.executeNodeCommand = void 0;
40
- __exportStar(require("./react"), exports);
41
- const moyu = __importStar(require("./moyu"));
42
- exports.moyu = moyu;
43
- require("./sandbox");
44
- var moyu_1 = require("./moyu");
45
- Object.defineProperty(exports, "executeNodeCommand", { enumerable: true, get: function () { return moyu_1.executeNodeCommand; } });
46
- Object.defineProperty(exports, "executePluginCommand", { enumerable: true, get: function () { return moyu_1.executePluginCommand; } });
47
- __exportStar(require("./spring"), exports);
48
- __exportStar(require("./events"), exports);
49
- __exportStar(require("./utils"), exports);
50
- __exportStar(require("./commands"), exports);
51
- __exportStar(require("./runtime-globals"), exports);
52
- __exportStar(require("./components/navigation"), exports);
53
- __exportStar(require("./hooks"), exports);
54
- __exportStar(require("./zod-patch"), exports);
package/dist/moyu.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import type { Command, MaybePromise } from './commands';
2
- import type { MoyuEvent } from './events';
3
- declare global {
4
- interface Window {
5
- moyu: any;
6
- }
7
- var __moyu_receive_event: (event: MoyuEvent) => void;
8
- var __moyu_eval_sandbox: (code: string) => any;
9
- }
10
- export declare function createInstance(nodeType: string, label: string | undefined, props: Record<string, any>): number;
11
- export declare function destroyInstance(nodeId: number): void;
12
- export declare function addChild(nodeId: number, childNodeId: number): void;
13
- export declare function insertChild(nodeId: number, index: number, childNodeId: number): void;
14
- export declare function insertChildBefore(nodeId: number, beforeChildNodeId: number, childNodeId: number): void;
15
- export declare function removeChildAt(nodeId: number, index: number): void;
16
- export declare function removeChild(nodeId: number, childNodeId: number): void;
17
- export declare function updateProps(nodeId: number, props: Record<string, any>): void;
18
- export declare function executeNodeCommand(nodeId: number, payload: Command): MaybePromise;
19
- export declare function executePluginCommand(pluginName: string, payload: Command): MaybePromise;
package/dist/moyu.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createInstance = createInstance;
4
- exports.destroyInstance = destroyInstance;
5
- exports.addChild = addChild;
6
- exports.insertChild = insertChild;
7
- exports.insertChildBefore = insertChildBefore;
8
- exports.removeChildAt = removeChildAt;
9
- exports.removeChild = removeChild;
10
- exports.updateProps = updateProps;
11
- exports.executeNodeCommand = executeNodeCommand;
12
- exports.executePluginCommand = executePluginCommand;
13
- function createInstance(nodeType, label, props) {
14
- let node_id = 0;
15
- const ret = moyu.pushCommand('create_instance', [nodeType, label, props], (id) => {
16
- node_id = id;
17
- });
18
- if (ret) {
19
- return ret;
20
- }
21
- return node_id;
22
- }
23
- function destroyInstance(nodeId) {
24
- moyu.pushCommand('destroy_instance', [nodeId]);
25
- }
26
- function addChild(nodeId, childNodeId) {
27
- moyu.pushCommand('add_child', [nodeId, childNodeId]);
28
- }
29
- function insertChild(nodeId, index, childNodeId) {
30
- moyu.pushCommand('insert_child', [nodeId, index, childNodeId]);
31
- }
32
- function insertChildBefore(nodeId, beforeChildNodeId, childNodeId) {
33
- moyu.pushCommand('insert_child_before', [nodeId, beforeChildNodeId, childNodeId]);
34
- }
35
- function removeChildAt(nodeId, index) {
36
- moyu.pushCommand('remove_child_at', [nodeId, index]);
37
- }
38
- function removeChild(nodeId, childNodeId) {
39
- moyu.pushCommand('remove_child', [nodeId, childNodeId]);
40
- }
41
- function updateProps(nodeId, props) {
42
- moyu.pushCommand('update_props', [nodeId, props]);
43
- }
44
- function executeNodeCommand(nodeId, payload) {
45
- return moyu.executeNodeCommand(nodeId, payload);
46
- }
47
- function executePluginCommand(pluginName, payload) {
48
- return moyu.executePluginCommand(pluginName, payload);
49
- }
package/dist/node.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import { Command } from './commands';
2
- import type { BubbleEvent } from './events/base';
3
- export declare class Node {
4
- nodeId: number;
5
- label?: string;
6
- props: Record<string, any>;
7
- listeners: Record<string, (evt?: BubbleEvent | Record<string, any>) => any>;
8
- static create(label: string, type: string, props: Record<string, any>): Node;
9
- static rootNode(): Node;
10
- addChild(child: Node): void;
11
- insertChild(index: number, child: Node): void;
12
- insertChildBefore(beforeChild: Node, child: Node): void;
13
- removeChild(child: Node): void;
14
- updateProps(props: Record<string, any>): void;
15
- executeCommand(payload: Command): any;
16
- }
package/dist/node.js DELETED
@@ -1,105 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Node = void 0;
37
- const moyu = __importStar(require("./moyu"));
38
- const state_1 = require("./state");
39
- class Node {
40
- nodeId;
41
- label;
42
- props = {};
43
- listeners = {};
44
- static create(label, type, props) {
45
- const { children: _, ...rest } = props;
46
- const node = new Node();
47
- node.label = label;
48
- const [restProps, listeners] = filterProps(rest);
49
- node.props = restProps;
50
- node.listeners = listeners;
51
- node.nodeId = moyu.createInstance(type, label, restProps);
52
- state_1.STATE.nodeMap[node.nodeId] = node;
53
- return node;
54
- }
55
- static rootNode() {
56
- const node = new Node();
57
- node.label = 'rootNode';
58
- node.nodeId = 0;
59
- return node;
60
- }
61
- addChild(child) {
62
- moyu.addChild(this.nodeId, child.nodeId);
63
- }
64
- insertChild(index, child) {
65
- moyu.insertChild(this.nodeId, 0, child.nodeId);
66
- }
67
- insertChildBefore(beforeChild, child) {
68
- moyu.insertChildBefore(this.nodeId, beforeChild.nodeId, child.nodeId);
69
- }
70
- // removeChildAt(index: number): Node | undefined {
71
- // return this.children.splice(index, 1)[0];
72
- // }
73
- removeChild(child) {
74
- moyu.removeChild(this.nodeId, child.nodeId);
75
- moyu.destroyInstance(child.nodeId);
76
- }
77
- updateProps(props) {
78
- const [restProps, listeners] = filterProps(props);
79
- Object.assign(this.props, restProps);
80
- Object.assign(this.listeners, listeners);
81
- // skip empty props
82
- if (Object.keys(restProps).length > 0) {
83
- moyu.updateProps(this.nodeId, restProps);
84
- }
85
- }
86
- executeCommand(payload) {
87
- return moyu.executeNodeCommand(this.nodeId, payload);
88
- }
89
- }
90
- exports.Node = Node;
91
- /// filter props to props and listeners
92
- function filterProps(props) {
93
- const ret = {};
94
- const listeners = {};
95
- for (const key in props) {
96
- // FIXME: it is not quite right to check if a key starts with 'on'
97
- if (key.startsWith('on')) {
98
- listeners[key] = props[key];
99
- }
100
- else {
101
- ret[key] = props[key];
102
- }
103
- }
104
- return [ret, listeners];
105
- }
package/dist/react.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import type { Component, ReactElement } from 'react';
2
- import Reconciler from 'react-reconciler';
3
- import type { BaseErrorInfo } from 'react-reconciler';
4
- import { Node } from './node';
5
- export declare const MoyuRenderer: Reconciler.Reconciler<Node, Node, never, never, never, any>;
6
- export interface RootOptions {
7
- /**
8
- * Prefix for `useId`.
9
- */
10
- identifierPrefix?: string;
11
- onUncaughtError: (error: Error, info: BaseErrorInfo & {
12
- errorBoundary?: Component;
13
- }) => void;
14
- onCaughtError: (error: Error, info: BaseErrorInfo) => void;
15
- onRecoverableError: (error: Error, info: BaseErrorInfo) => void;
16
- onDefaultTransitionIndicator: () => void;
17
- }
18
- export declare function createRoot(options?: RootOptions): {
19
- render: (reactElement: ReactElement, callback?: (() => void) | null) => Reconciler.Lane;
20
- };
package/dist/react.js DELETED
@@ -1,222 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MoyuRenderer = void 0;
7
- exports.createRoot = createRoot;
8
- const react_1 = __importDefault(require("react"));
9
- const react_reconciler_1 = __importDefault(require("react-reconciler"));
10
- const constants_1 = require("react-reconciler/constants");
11
- const node_1 = require("./node");
12
- let currentUpdatePriority = constants_1.NoEventPriority;
13
- const hostConfig = {
14
- isPrimaryRenderer: true,
15
- supportsHydration: false,
16
- supportsMutation: true,
17
- supportsPersistence: false,
18
- /**
19
- * @required
20
- */
21
- createInstance(type, props, _root, _hostContext, _internalInstanceHandle) {
22
- // console.debug('createInstance', type);
23
- const node = node_1.Node.create(props.label ?? '', type, props);
24
- return node;
25
- },
26
- /**
27
- * throw if not supported
28
- * @required
29
- */
30
- createTextInstance(_text, _rootContainerInstance, _hostContext, _internalInstanceHandle) {
31
- // console.debug('createTextInstance');
32
- // return SpanNode({}, text) as SkNode;
33
- throw new Error('Text nodes are not supported yet');
34
- },
35
- /**
36
- * @required
37
- */
38
- appendInitialChild(parentInstance, child) {
39
- // console.debug('appendInitialChild');
40
- parentInstance.addChild(child);
41
- },
42
- /**
43
- * return true if needs `commitMount`
44
- * @required
45
- */
46
- finalizeInitialChildren(parentInstance, _type, _props, _rootContainerInstance, _hostContext) {
47
- // console.debug('finalizeInitialChildren', parentInstance);
48
- return true;
49
- },
50
- shouldSetTextContent(_type, _props) {
51
- return false;
52
- },
53
- getRootHostContext: (_rootContainerInstance) => {
54
- // console.debug('getRootHostContext');
55
- return {};
56
- },
57
- getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {
58
- // console.debug('getChildHostContext');
59
- return _parentHostContext;
60
- },
61
- getPublicInstance(node) {
62
- // console.debug('getPublicInstance');
63
- return node;
64
- },
65
- prepareForCommit(_containerInfo) {
66
- // console.debug('prepareForCommit');
67
- return null;
68
- },
69
- resetAfterCommit(container) {
70
- // console.debug('resetAfterCommit');
71
- // TODO: this is not necessary in continuous rendering
72
- // container.redraw();
73
- },
74
- preparePortalMount: () => {
75
- // console.debug('preparePortalMount');
76
- },
77
- scheduleTimeout: setTimeout,
78
- cancelTimeout: clearTimeout,
79
- noTimeout: -1,
80
- // optional
81
- appendChild(parent, child) {
82
- // console.debug('appendChild', parent, child);
83
- parent.addChild(child);
84
- },
85
- appendChildToContainer(container, child) {
86
- // console.debug('appendChildToContainer', container, child);
87
- container.addChild(child);
88
- },
89
- insertBefore: (parent, child, before) => {
90
- // console.debug('insertBefore', parent, child, before);
91
- parent.insertChildBefore(before, child);
92
- },
93
- insertInContainerBefore: (parent, child, before) => {
94
- parent.insertChildBefore(before, child);
95
- },
96
- removeChild: (parent, child) => {
97
- // console.debug('removeChild', parent, child);
98
- parent.removeChild(child);
99
- },
100
- removeChildFromContainer: (parent, child) => {
101
- // console.debug('removeChildFromContainer', parent, child);
102
- parent.removeChild(child);
103
- },
104
- finalizeContainerChildren: () => {
105
- // console.debug('finalizeContainerChildren');
106
- },
107
- commitMount(instance, type, props, internalInstanceHandle) {
108
- // if finalizeInitialChildren = true
109
- // console.debug('commitMount');
110
- },
111
- commitUpdate(instance, type, prevProps, nextProps, _internalHandle) {
112
- // console.debug('commitUpdate: ', type, JSON.stringify(_updatePayload));
113
- const { label: _oldLabel, children: _oldChildren, ...oldProps } = prevProps;
114
- const { label, children, ...newProps } = nextProps;
115
- const changedProps = {};
116
- // Check for changed or new props
117
- for (const key in newProps) {
118
- if (newProps[key] !== oldProps[key]) {
119
- changedProps[key] = newProps[key];
120
- }
121
- }
122
- // Check for removed props
123
- for (const key in oldProps) {
124
- if (!(key in newProps)) {
125
- changedProps[key] = null;
126
- }
127
- }
128
- // Handle label especially if it's reactive
129
- if (label !== _oldLabel) {
130
- changedProps.label = label ?? null;
131
- }
132
- if (Object.keys(changedProps).length) {
133
- instance.updateProps(changedProps);
134
- }
135
- },
136
- commitTextUpdate: (_textInstance, _oldText, _newText) => {
137
- // textInstance.instance = newText;
138
- },
139
- clearContainer: (container) => {
140
- // console.error('clearContainer not implement');
141
- // container.children.splice(0);
142
- },
143
- getInstanceFromNode(node) {
144
- console.error('getInstanceFromNode not implement');
145
- throw new Error('Function not implemented.');
146
- },
147
- beforeActiveInstanceBlur: () => {
148
- console.error('beforeActiveInstanceBlur not implement');
149
- // throw new Error('Function not implemented.');
150
- },
151
- afterActiveInstanceBlur: () => {
152
- console.error('afterActiveInstanceBlur not implement');
153
- // throw new Error('Function not implemented.');
154
- },
155
- prepareScopeUpdate: (scopeInstance, instance) => {
156
- console.error('prepareScopeUpdate not implement');
157
- // throw new Error('Function not implemented.');
158
- },
159
- getInstanceFromScope: (scopeInstance) => {
160
- console.error('getInstanceFromScope not implement');
161
- // throw new Error('Function not implemented.');
162
- return null;
163
- },
164
- detachDeletedInstance: (node) => {
165
- // node will be destroyed by the engine
166
- // just do nothing here
167
- },
168
- NotPendingTransition: undefined,
169
- // see https://github.com/pmndrs/react-three-fiber/blob/2541e81fb6ddc22d0869b9eb5cdbedcbbc62324c/packages/fiber/src/core/reconciler.tsx#L570
170
- HostTransitionContext: /* @__PURE__ */ react_1.default.createContext(null),
171
- setCurrentUpdatePriority(newPriority) {
172
- currentUpdatePriority = newPriority;
173
- },
174
- getCurrentUpdatePriority() {
175
- return currentUpdatePriority;
176
- },
177
- resolveUpdatePriority() {
178
- if (currentUpdatePriority !== constants_1.NoEventPriority)
179
- return currentUpdatePriority;
180
- return constants_1.DefaultEventPriority;
181
- },
182
- resetFormInstance() { },
183
- requestPostPaintCallback() { },
184
- shouldAttemptEagerTransition: () => false,
185
- trackSchedulerEvent: () => { },
186
- resolveEventType: () => null,
187
- resolveEventTimeStamp: () => -1.1,
188
- maySuspendCommit: () => false,
189
- preloadInstance: () => true,
190
- startSuspendingCommit() { },
191
- suspendInstance() { },
192
- waitForCommitToBeReady: () => null,
193
- };
194
- exports.MoyuRenderer = (0, react_reconciler_1.default)(hostConfig);
195
- function createRoot(options) {
196
- const rootNode = node_1.Node.rootNode();
197
- const rootElement = exports.MoyuRenderer.createContainer(rootNode, 0, null, false, false, options?.identifierPrefix ?? 'moyu', options?.onUncaughtError ??
198
- ((err) => {
199
- console.error('uncaught error: ', err);
200
- }), options?.onCaughtError ??
201
- ((err) => {
202
- console.error('caught error: ', err);
203
- }), options?.onRecoverableError ??
204
- ((err) => {
205
- console.error('unrecoverable error: ', err);
206
- }), options?.onDefaultTransitionIndicator ?? (() => { }));
207
- exports.MoyuRenderer.injectIntoDevTools({
208
- bundleType: process.env.NODE_ENV === 'production' ? 0 : 1,
209
- version: '0.1.0',
210
- rendererPackageName: '@momoyu-ink/kit',
211
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
212
- findFiberByHostInstance: (instance) => {
213
- return instance;
214
- },
215
- });
216
- return {
217
- render: (reactElement, callback) => {
218
- // update the root Container
219
- return exports.MoyuRenderer.updateContainer(reactElement, rootElement, null, callback);
220
- },
221
- };
222
- }
@@ -1,65 +0,0 @@
1
- export {};
2
- declare global {
3
- /**
4
- * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).
5
- *
6
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)
7
- */
8
- interface Console {
9
- /**
10
- * The **`console.debug()`** static method outputs a message to the console at the 'debug' log level.
11
- *
12
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)
13
- */
14
- debug(...data: any[]): void;
15
- /**
16
- * The **`console.error()`** static method outputs a message to the console at the 'error' log level.
17
- *
18
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
19
- */
20
- error(...data: any[]): void;
21
- /**
22
- * The **`console.info()`** static method outputs a message to the console at the 'info' log level.
23
- *
24
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)
25
- */
26
- info(...data: any[]): void;
27
- /**
28
- * The **`console.log()`** static method outputs a message to the console.
29
- *
30
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
31
- */
32
- log(...data: any[]): void;
33
- /**
34
- * The **`console.trace()`** static method outputs a stack trace to the console.
35
- *
36
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
37
- */
38
- trace(...data: any[]): void;
39
- /**
40
- * The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level.
41
- *
42
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)
43
- */
44
- warn(...data: any[]): void;
45
- }
46
- var console: Console;
47
- type TimerHandler = string | Function;
48
- function clearInterval(id: number | undefined): void;
49
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
50
- function clearTimeout(id: number | undefined): void;
51
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
52
- function setInterval(handler: TimerHandler, timeout?: number, ...args: any[]): number;
53
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
54
- function setTimeout(handler: TimerHandler, timeout?: number, ...args: any[]): number;
55
- type DOMHighResTimeStamp = number;
56
- interface FrameRequestCallback {
57
- (time: DOMHighResTimeStamp): void;
58
- }
59
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/cancelAnimationFrame) */
60
- function cancelAnimationFrame(handle: number): void;
61
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame) */
62
- function requestAnimationFrame(callback: FrameRequestCallback): number;
63
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/queueMicrotask) */
64
- function queueMicrotask(callback: () => void): void;
65
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/sandbox.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/sandbox.js DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const moyu_1 = require("./moyu");
4
- // Snapshot of JS built-in globals captured at init time, used to let them bypass the sandbox proxy
5
- const JS_GLOBAL_KEYS = new Set(Object.getOwnPropertyNames(globalThis));
6
- const JS_GLOBAL_KEYS_EXCLUDED = new Set(['window', 'globalThis', 'ARCHIVE', 'GLOBAL']);
7
- JS_GLOBAL_KEYS_EXCLUDED.forEach((key) => JS_GLOBAL_KEYS.delete(key));
8
- const archiveVariables = new Proxy({}, {
9
- get(_, key) {
10
- if (typeof key === 'string') {
11
- return (0, moyu_1.executePluginCommand)('scenario', {
12
- subCommand: 'getVariable',
13
- name: key,
14
- });
15
- }
16
- return undefined;
17
- },
18
- set(_, key, value) {
19
- if (typeof key === 'string') {
20
- (0, moyu_1.executePluginCommand)('scenario', {
21
- subCommand: 'setVariable',
22
- name: key,
23
- value,
24
- });
25
- return true;
26
- }
27
- return false;
28
- },
29
- });
30
- const globalVariables = new Proxy({}, {
31
- get(_, key) {
32
- if (typeof key === 'string') {
33
- return (0, moyu_1.executePluginCommand)('scenario', {
34
- subCommand: 'getPermanentVariable',
35
- key,
36
- });
37
- }
38
- return undefined;
39
- },
40
- set(_, key, value) {
41
- if (typeof key === 'string') {
42
- (0, moyu_1.executePluginCommand)('scenario', {
43
- subCommand: 'setPermanentVariable',
44
- key,
45
- value,
46
- });
47
- return true;
48
- }
49
- return false;
50
- },
51
- });
52
- function safeEval(code, sandbox) {
53
- const proxy = new Proxy(sandbox, {
54
- has(target, key) {
55
- // Let JS built-ins fall through to the actual global scope, intercept everything else
56
- if (typeof key === 'string' && JS_GLOBAL_KEYS.has(key)) {
57
- return false;
58
- }
59
- return key in target || key === 'ARCHIVE' || key === 'GLOBAL' || key === 'window' || key === 'globalThis';
60
- },
61
- get(target, key) {
62
- if (key === 'window' || key === 'globalThis')
63
- return proxy; // Make window/globalThis refer to the sandbox itself
64
- if (key === 'ARCHIVE')
65
- return archiveVariables;
66
- if (key === 'GLOBAL')
67
- return globalVariables;
68
- if (key === Symbol.unscopables)
69
- return undefined;
70
- return target[key];
71
- },
72
- set(target, key, value) {
73
- target[key] = value;
74
- return true;
75
- },
76
- });
77
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
78
- return new Function('sandbox', `with(sandbox) { return (${code}) }`).bind(proxy)(proxy);
79
- }
80
- globalThis.__moyu_eval_sandbox = (code) => {
81
- try {
82
- return safeEval(code, {});
83
- }
84
- catch (err) {
85
- console.error('Error evaluating code in sandbox:', err);
86
- throw err;
87
- }
88
- };