@lingfan-engine/core 0.0.0-stage → 0.1.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.
- package/LICENSE +201 -0
- package/package.json +36 -3
- package/src/contracts/element.ts +327 -0
- package/src/contracts/extension.ts +144 -0
- package/src/contracts/game.ts +103 -0
- package/src/contracts/guard.ts +86 -0
- package/src/contracts/host.ts +43 -0
- package/src/contracts/identifiers.ts +12 -0
- package/src/contracts/index.ts +20 -0
- package/src/contracts/media/entities.ts +69 -0
- package/src/contracts/media/index.ts +5 -0
- package/src/contracts/media/ports.ts +44 -0
- package/src/contracts/messages.ts +135 -0
- package/src/contracts/minigame.ts +64 -0
- package/src/contracts/platform/entities.ts +57 -0
- package/src/contracts/platform/index.ts +5 -0
- package/src/contracts/platform/ports.ts +81 -0
- package/src/contracts/preferences.ts +68 -0
- package/src/contracts/project.ts +46 -0
- package/src/contracts/runtime/entities.ts +31 -0
- package/src/contracts/runtime/events.ts +161 -0
- package/src/contracts/runtime/index.ts +8 -0
- package/src/contracts/runtime/reader.ts +82 -0
- package/src/contracts/runtime/state-keys.ts +127 -0
- package/src/contracts/runtime/timer.ts +32 -0
- package/src/contracts/save.ts +83 -0
- package/src/contracts/shell.ts +162 -0
- package/src/contracts/story/entities.ts +165 -0
- package/src/contracts/story/index.ts +5 -0
- package/src/contracts/story/ports.ts +21 -0
- package/src/contracts/text.ts +12 -0
- package/src/data/element.ts +215 -0
- package/src/data/format/body.ts +39 -0
- package/src/data/format/column.ts +174 -0
- package/src/data/format/entry.ts +119 -0
- package/src/data/format/error.ts +17 -0
- package/src/data/format/guards.ts +11 -0
- package/src/data/format/index.ts +8 -0
- package/src/data/format/naming.ts +10 -0
- package/src/data/format/validate/blocks.ts +130 -0
- package/src/data/format/validate/collections.ts +64 -0
- package/src/data/format/validate/dialog.ts +68 -0
- package/src/data/format/validate/flow.ts +81 -0
- package/src/data/format/validate/index.ts +13 -0
- package/src/data/format/validate/present.ts +91 -0
- package/src/data/format/validate/save.ts +36 -0
- package/src/data/format/validate/shape.ts +19 -0
- package/src/data/format/validate/variables.ts +31 -0
- package/src/data/format/validate.ts +48 -0
- package/src/data/index.ts +42 -0
- package/src/data/project/assemble.ts +227 -0
- package/src/data/project/conflict.ts +90 -0
- package/src/data/project/diff.ts +61 -0
- package/src/data/project/error.ts +32 -0
- package/src/data/project/index.ts +24 -0
- package/src/data/project/naming.ts +48 -0
- package/src/data/project/serialize.ts +313 -0
- package/src/data/text/entry.ts +245 -0
- package/src/data/text/error.ts +17 -0
- package/src/data/text/generate/body.ts +35 -0
- package/src/data/text/generate/command/blocks.ts +97 -0
- package/src/data/text/generate/command/collections.ts +54 -0
- package/src/data/text/generate/command/dialog.ts +85 -0
- package/src/data/text/generate/command/flow.ts +96 -0
- package/src/data/text/generate/command/index.ts +14 -0
- package/src/data/text/generate/command/media.ts +70 -0
- package/src/data/text/generate/command/present.ts +96 -0
- package/src/data/text/generate/command/save.ts +38 -0
- package/src/data/text/generate/command/variables.ts +33 -0
- package/src/data/text/generate/command.ts +140 -0
- package/src/data/text/generate/context.ts +17 -0
- package/src/data/text/generate/element.ts +48 -0
- package/src/data/text/generate/index.ts +3 -0
- package/src/data/text/generate/projection.ts +23 -0
- package/src/data/text/index.ts +12 -0
- package/src/data/text/lexer.ts +145 -0
- package/src/data/text/literals.ts +214 -0
- package/src/data/text/parse/block.ts +333 -0
- package/src/data/text/parse/element.ts +60 -0
- package/src/data/text/parse/index.ts +4 -0
- package/src/data/text/parse/say.ts +76 -0
- package/src/data/text/parse/state.ts +47 -0
- package/src/data/text/parse/statement/collections.ts +98 -0
- package/src/data/text/parse/statement/dialog.ts +114 -0
- package/src/data/text/parse/statement/flow.ts +124 -0
- package/src/data/text/parse/statement/index.ts +12 -0
- package/src/data/text/parse/statement/media.ts +117 -0
- package/src/data/text/parse/statement/present.ts +229 -0
- package/src/data/text/parse/statement/save.ts +42 -0
- package/src/data/text/parse/statement/variables.ts +39 -0
- package/src/data/text/parse/statement.ts +124 -0
- package/src/data/text/warnings.ts +25 -0
- package/src/index.ts +128 -0
- package/src/runtime/dispatch.ts +315 -0
- package/src/runtime/engine/forwarders.ts +269 -0
- package/src/runtime/engine/index.ts +8 -0
- package/src/runtime/engine/state.ts +196 -0
- package/src/runtime/engine.ts +389 -0
- package/src/runtime/expr/builtins.ts +135 -0
- package/src/runtime/expr/evaluate.ts +19 -0
- package/src/runtime/expr/index.ts +15 -0
- package/src/runtime/expr/interpolate.ts +125 -0
- package/src/runtime/expr/lexer.ts +122 -0
- package/src/runtime/expr/parser/atoms.ts +131 -0
- package/src/runtime/expr/parser/cursor.ts +66 -0
- package/src/runtime/expr/parser/index.ts +7 -0
- package/src/runtime/expr/parser/parse.ts +225 -0
- package/src/runtime/expr/value.ts +58 -0
- package/src/runtime/extensionLoader.ts +97 -0
- package/src/runtime/guardNames.ts +73 -0
- package/src/runtime/history/index.ts +26 -0
- package/src/runtime/history/rollback.ts +196 -0
- package/src/runtime/history/snapshot.ts +177 -0
- package/src/runtime/host.ts +22 -0
- package/src/runtime/i18n/index.ts +8 -0
- package/src/runtime/i18n/overlay.ts +22 -0
- package/src/runtime/i18n/translate.ts +40 -0
- package/src/runtime/index.ts +66 -0
- package/src/runtime/internal/context.ts +271 -0
- package/src/runtime/internal/expression.ts +44 -0
- package/src/runtime/internal/frame-stack.ts +139 -0
- package/src/runtime/internal/frame.ts +83 -0
- package/src/runtime/internal/helpers.ts +75 -0
- package/src/runtime/internal/index.ts +52 -0
- package/src/runtime/internal/media.ts +84 -0
- package/src/runtime/internal/session.ts +340 -0
- package/src/runtime/internal/stage.ts +73 -0
- package/src/runtime/internal/waiting.ts +51 -0
- package/src/runtime/opRegistry.ts +271 -0
- package/src/runtime/ops/call.ts +181 -0
- package/src/runtime/ops/dialog.ts +290 -0
- package/src/runtime/ops/element/animation.ts +197 -0
- package/src/runtime/ops/element/index.ts +13 -0
- package/src/runtime/ops/element/sequence.ts +132 -0
- package/src/runtime/ops/element/visual.ts +233 -0
- package/src/runtime/ops/extension.ts +181 -0
- package/src/runtime/ops/flow.ts +235 -0
- package/src/runtime/ops/index.ts +63 -0
- package/src/runtime/ops/interaction.ts +242 -0
- package/src/runtime/ops/media.ts +274 -0
- package/src/runtime/ops/minigame.ts +237 -0
- package/src/runtime/ops/save.ts +153 -0
- package/src/runtime/ops/variables.ts +270 -0
- package/src/runtime/preferences.ts +352 -0
- package/src/runtime/resolver.ts +4 -0
- package/src/runtime/save/export.ts +107 -0
- package/src/runtime/save/extensions.ts +158 -0
- package/src/runtime/save/import.ts +220 -0
- package/src/runtime/save/index.ts +14 -0
- package/src/runtime/save/minigames.ts +95 -0
- package/src/runtime/scope.ts +106 -0
- package/src/runtime/shell.ts +308 -0
- package/src/runtime/state/evaluate.ts +79 -0
- package/src/runtime/state/index.ts +11 -0
- package/src/runtime/state/instance-z.ts +40 -0
- package/src/runtime/state/notify.ts +44 -0
- package/src/runtime/state/reader.ts +223 -0
- package/src/runtime/state/writer.ts +117 -0
- package/src/runtime/stateContract.ts +108 -0
- package/src/runtime/waitingOps.ts +80 -0
- package/src/shared/guards.ts +77 -0
- package/src/shared/index.ts +6 -0
- package/src/shared/numbers.ts +12 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2026 MoFeng-02
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingfan-engine/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "灵泛叙事引擎核心:框架无关的叙事语义(格式/执行/回溯/作用域/存档编排)",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.ts",
|
|
9
|
+
"./contracts": "./src/contracts/index.ts"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src",
|
|
13
|
+
"!src/**/*.test.ts"
|
|
14
|
+
],
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/MoFeng-02/LingFan.Engine.git",
|
|
19
|
+
"directory": "packages/core"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/MoFeng-02/LingFan.Engine#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/MoFeng-02/LingFan.Engine/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"narrative",
|
|
27
|
+
"visual-novel",
|
|
28
|
+
"game-engine",
|
|
29
|
+
"story",
|
|
30
|
+
"typescript",
|
|
31
|
+
"framework-agnostic"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=22.12.0"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
6
39
|
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 元素系统契约(元素声明 / 舞台层叠)。
|
|
3
|
+
*
|
|
4
|
+
* 类型与属性全集:
|
|
5
|
+
* - 36 类型全集(文本 / 交互 / 图像 / 容器 / 滚动 / 进度 / 间隔七组)
|
|
6
|
+
* - 属性全集 = 通用属性表与元素特定属性的合并
|
|
7
|
+
*
|
|
8
|
+
* 未知类型 / 未知属性一律 fail-closed——「写了也不渲染」的静默容忍是缺陷,不是特性。
|
|
9
|
+
*
|
|
10
|
+
* 元素寻址显式化为契约字段:`id`(唯一,精确寻址)与 `name`(可重复,批量寻址),
|
|
11
|
+
* 不使用隐式魔法键。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 元素动作序列(`ops`)中**不可用**的 op:等待类、位置类、存档类。
|
|
16
|
+
*
|
|
17
|
+
* 理由:`ops` 是「点击时按序执行一串 op」,跑在**当前叙事流的等待画面上**——
|
|
18
|
+
* 这些 op 会打断或替换该流程(进入新等待 / 换列 / 改动存档坐标),与「点一下做点事、
|
|
19
|
+
* 然后继续」的语义冲突。执行期整次拒绝(`element-ops-blocked-op`,状态原样)。
|
|
20
|
+
*
|
|
21
|
+
* 跳列请用元素的 `nav` 属性(那条路走核心 `navigate`,语义明确)。
|
|
22
|
+
* 单一事实源:引擎执行期与编辑器编辑期诊断共用本清单。
|
|
23
|
+
*/
|
|
24
|
+
export const ELEMENT_OPS_BLOCKED: ReadonlySet<string> = new Set([
|
|
25
|
+
// 等待类(进入新等待,替换当前流程)
|
|
26
|
+
"say",
|
|
27
|
+
"menu",
|
|
28
|
+
"input",
|
|
29
|
+
"wait",
|
|
30
|
+
"pause",
|
|
31
|
+
"nvl",
|
|
32
|
+
"cutscene",
|
|
33
|
+
"minigame",
|
|
34
|
+
// 位置类(替换命令流 / 改变叙事坐标)
|
|
35
|
+
"jump",
|
|
36
|
+
"navigate",
|
|
37
|
+
"call",
|
|
38
|
+
"return",
|
|
39
|
+
// 存档类(存档坐标必须是玩家所见的等待点,点击不是)
|
|
40
|
+
"save",
|
|
41
|
+
"load",
|
|
42
|
+
"auto_save",
|
|
43
|
+
"save_delete",
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 舞台元素类型全集(36)。
|
|
48
|
+
* 分组:文本 / 交互 / 图像 / 容器 / 滚动 / 进度 / 间隔七组。
|
|
49
|
+
*/
|
|
50
|
+
export const ELEMENT_TYPES = [
|
|
51
|
+
// 文本
|
|
52
|
+
"text",
|
|
53
|
+
"dialog",
|
|
54
|
+
"narrator",
|
|
55
|
+
"speaker",
|
|
56
|
+
// 交互
|
|
57
|
+
"button",
|
|
58
|
+
"choice",
|
|
59
|
+
"imagebutton",
|
|
60
|
+
// 图像
|
|
61
|
+
"image",
|
|
62
|
+
"background",
|
|
63
|
+
"portrait",
|
|
64
|
+
"video",
|
|
65
|
+
// 容器
|
|
66
|
+
"panel",
|
|
67
|
+
"frame",
|
|
68
|
+
"window",
|
|
69
|
+
"dialogbox",
|
|
70
|
+
"choicebox",
|
|
71
|
+
"infobox",
|
|
72
|
+
"overlay",
|
|
73
|
+
"popup",
|
|
74
|
+
"vbox",
|
|
75
|
+
"hbox",
|
|
76
|
+
"grid",
|
|
77
|
+
"stack",
|
|
78
|
+
"stackpanel",
|
|
79
|
+
"canvas",
|
|
80
|
+
"border",
|
|
81
|
+
// 滚动
|
|
82
|
+
"scroll",
|
|
83
|
+
"scrollviewer",
|
|
84
|
+
"viewport",
|
|
85
|
+
// 进度 / 滑块 / 选择
|
|
86
|
+
"bar",
|
|
87
|
+
"vbar",
|
|
88
|
+
"progressbar",
|
|
89
|
+
"slider",
|
|
90
|
+
"checkbox",
|
|
91
|
+
// 间隔
|
|
92
|
+
"separator",
|
|
93
|
+
"spacer",
|
|
94
|
+
] as const;
|
|
95
|
+
|
|
96
|
+
/** 元素类型名(从 `ELEMENT_TYPES` 派生,是元素表与校验白名单的共同键) */
|
|
97
|
+
export type ElementType = (typeof ELEMENT_TYPES)[number];
|
|
98
|
+
|
|
99
|
+
/** 结构字段(非属性):type 必填,id/name 为寻址标识,children 为容器嵌套 */
|
|
100
|
+
export const ELEMENT_STRUCTURAL_FIELDS: ReadonlySet<string> = new Set([
|
|
101
|
+
"type",
|
|
102
|
+
"id",
|
|
103
|
+
"name",
|
|
104
|
+
"children",
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 属性全集 = 通用属性表与元素特定属性的合并(合并结果即校验白名单)。
|
|
109
|
+
* 分组注释保留来源信息(编辑器表单按 `ELEMENT_SPECIFIC_ATTRS` 分类型提示)。
|
|
110
|
+
*/
|
|
111
|
+
export const ELEMENT_ATTRIBUTES: ReadonlySet<string> = new Set([
|
|
112
|
+
// 内容 / 样式
|
|
113
|
+
"class",
|
|
114
|
+
"style",
|
|
115
|
+
"source",
|
|
116
|
+
"src",
|
|
117
|
+
"path",
|
|
118
|
+
"text",
|
|
119
|
+
// 对齐
|
|
120
|
+
"align",
|
|
121
|
+
"halign",
|
|
122
|
+
"valign",
|
|
123
|
+
"xalign",
|
|
124
|
+
"yalign",
|
|
125
|
+
// 尺寸 / 位置
|
|
126
|
+
"width",
|
|
127
|
+
"height",
|
|
128
|
+
"fontSize",
|
|
129
|
+
"font",
|
|
130
|
+
"order",
|
|
131
|
+
"size",
|
|
132
|
+
"x",
|
|
133
|
+
"y",
|
|
134
|
+
"xoffset",
|
|
135
|
+
"yoffset",
|
|
136
|
+
"xanchor",
|
|
137
|
+
"yanchor",
|
|
138
|
+
"margin",
|
|
139
|
+
"padding",
|
|
140
|
+
"right",
|
|
141
|
+
"bottom",
|
|
142
|
+
"minWidth",
|
|
143
|
+
"minHeight",
|
|
144
|
+
"maxWidth",
|
|
145
|
+
"maxHeight",
|
|
146
|
+
"min",
|
|
147
|
+
"max",
|
|
148
|
+
"orientation",
|
|
149
|
+
"checked",
|
|
150
|
+
// 颜色 / 字体
|
|
151
|
+
"color",
|
|
152
|
+
"fontColor",
|
|
153
|
+
"textColor",
|
|
154
|
+
// 交互(点击优先级:disabled > nav > ops > cmd;视觉态 hover_* / selected_* / disabled_* 与点击正交)
|
|
155
|
+
"disabled",
|
|
156
|
+
"nav",
|
|
157
|
+
"ops",
|
|
158
|
+
"cmd",
|
|
159
|
+
"value",
|
|
160
|
+
"hover_source",
|
|
161
|
+
"hover_color",
|
|
162
|
+
"hover_opacity",
|
|
163
|
+
"selected_source",
|
|
164
|
+
"selected_color",
|
|
165
|
+
"disabled_source",
|
|
166
|
+
"disabled_color",
|
|
167
|
+
"disabled_opacity",
|
|
168
|
+
// Grid 附着
|
|
169
|
+
"col",
|
|
170
|
+
"row",
|
|
171
|
+
"colspan",
|
|
172
|
+
"rowspan",
|
|
173
|
+
// 外观
|
|
174
|
+
"opacity",
|
|
175
|
+
"visible",
|
|
176
|
+
"enabled",
|
|
177
|
+
"zindex",
|
|
178
|
+
"clipToBounds",
|
|
179
|
+
"cursor",
|
|
180
|
+
// 变换
|
|
181
|
+
"rotation",
|
|
182
|
+
"scale",
|
|
183
|
+
"scaleX",
|
|
184
|
+
"scaleY",
|
|
185
|
+
// 边框
|
|
186
|
+
"cornerRadius",
|
|
187
|
+
"borderBrush",
|
|
188
|
+
"borderColor",
|
|
189
|
+
"borderThickness",
|
|
190
|
+
// 容器
|
|
191
|
+
"spacing",
|
|
192
|
+
"direction",
|
|
193
|
+
"columns",
|
|
194
|
+
"rows",
|
|
195
|
+
// 文本
|
|
196
|
+
"textAlign",
|
|
197
|
+
// 图片
|
|
198
|
+
"stretch",
|
|
199
|
+
// 滚动
|
|
200
|
+
"scroll_h",
|
|
201
|
+
"scroll_v",
|
|
202
|
+
]);
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 分类型属性:供编辑器表单按类型提示,
|
|
206
|
+
* 校验仍走 `ELEMENT_ATTRIBUTES` 并集(宽松归属判定)。
|
|
207
|
+
*/
|
|
208
|
+
export const ELEMENT_SPECIFIC_ATTRS: Readonly<
|
|
209
|
+
Record<string, readonly string[]>
|
|
210
|
+
> = {
|
|
211
|
+
text: ["size"],
|
|
212
|
+
dialog: ["size"],
|
|
213
|
+
narrator: ["size"],
|
|
214
|
+
speaker: ["size"],
|
|
215
|
+
grid: ["columns", "rows"],
|
|
216
|
+
panel: ["direction", "spacing"],
|
|
217
|
+
vbox: ["direction", "spacing"],
|
|
218
|
+
hbox: ["direction", "spacing"],
|
|
219
|
+
frame: ["direction", "spacing"],
|
|
220
|
+
window: ["direction", "spacing"],
|
|
221
|
+
dialogbox: ["direction", "spacing"],
|
|
222
|
+
choicebox: ["direction", "spacing"],
|
|
223
|
+
infobox: ["direction", "spacing"],
|
|
224
|
+
overlay: ["direction", "spacing"],
|
|
225
|
+
popup: ["direction", "spacing"],
|
|
226
|
+
stack: ["direction", "spacing"],
|
|
227
|
+
stackpanel: ["direction", "spacing"],
|
|
228
|
+
image: ["stretch"],
|
|
229
|
+
imagebutton: [
|
|
230
|
+
"stretch",
|
|
231
|
+
"hover_source",
|
|
232
|
+
"selected_source",
|
|
233
|
+
"disabled_source",
|
|
234
|
+
],
|
|
235
|
+
portrait: ["stretch"],
|
|
236
|
+
slider: ["min", "max", "orientation"],
|
|
237
|
+
progressbar: ["min", "max"],
|
|
238
|
+
bar: ["min", "max"],
|
|
239
|
+
vbar: ["min", "max"],
|
|
240
|
+
checkbox: ["checked"],
|
|
241
|
+
scroll: ["scroll_h", "scroll_v"],
|
|
242
|
+
scrollviewer: ["scroll_h", "scroll_v"],
|
|
243
|
+
viewport: ["scroll_h", "scroll_v"],
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 舞台元素声明节点(scene 列 `elements[]` 的元素)。
|
|
248
|
+
* JSON 形态为平铺(
|
|
249
|
+
* `{ "type": "image", "source": "Images/bg.png", "x": "0" }`),属性与 type 同级。
|
|
250
|
+
*/
|
|
251
|
+
export interface ElementNode {
|
|
252
|
+
type: string;
|
|
253
|
+
/** 唯一标识(同列内重复 = fail-closed);show/hide/animate 的首选目标 */
|
|
254
|
+
id?: string;
|
|
255
|
+
/** 可重复的分组标识(批量寻址:一次操作一组元素) */
|
|
256
|
+
name?: string;
|
|
257
|
+
/** 容器专有:子元素(投影为缩进子元素行) */
|
|
258
|
+
children?: ElementNode[];
|
|
259
|
+
/** 其余键 = 属性全集(校验白名单) */
|
|
260
|
+
[attr: string]: unknown;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 运行期元素实例:装载进 `SYS.elements`,随快照 / 存档 / 回溯自动随行
|
|
265
|
+
* (整体 state Map 快照,无需重放重建)。
|
|
266
|
+
*/
|
|
267
|
+
export interface ElementInstance {
|
|
268
|
+
/** 稳定标识:显式 id > 派生 `{列id}#{序号}`(派生值仅供内部兜底,不作为稳定契约) */
|
|
269
|
+
id: string;
|
|
270
|
+
type: string;
|
|
271
|
+
/** 分组标识(可重复;未声明则不出现) */
|
|
272
|
+
name?: string;
|
|
273
|
+
/** ELEMENT_ATTRIBUTES 内的属性副本(不含 type/id/name/children) */
|
|
274
|
+
props: Record<string, unknown>;
|
|
275
|
+
/** 舞台内叠放序:显式 `zindex` > 到达序(声明顺序 + 动态追加序) */
|
|
276
|
+
z: number;
|
|
277
|
+
children: ElementInstance[];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 容器类型:支持 `children` 嵌套。
|
|
282
|
+
* 统一口径为「容器 = 支持 children」,取 vbox/hbox 等可嵌套类型的并集。
|
|
283
|
+
*/
|
|
284
|
+
export const ELEMENT_CONTAINER_TYPES: ReadonlySet<string> = new Set([
|
|
285
|
+
"panel",
|
|
286
|
+
"frame",
|
|
287
|
+
"window",
|
|
288
|
+
"dialogbox",
|
|
289
|
+
"choicebox",
|
|
290
|
+
"infobox",
|
|
291
|
+
"overlay",
|
|
292
|
+
"popup",
|
|
293
|
+
"vbox",
|
|
294
|
+
"hbox",
|
|
295
|
+
"grid",
|
|
296
|
+
"stack",
|
|
297
|
+
"stackpanel",
|
|
298
|
+
"canvas",
|
|
299
|
+
"border",
|
|
300
|
+
"scroll",
|
|
301
|
+
"scrollviewer",
|
|
302
|
+
"viewport",
|
|
303
|
+
]);
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 元素动画描述(`animate` / `animate_block` 写入 `SYS.animations`)。
|
|
307
|
+
*
|
|
308
|
+
* 分工:核心层只写「动画描述」(离散、进快照),**UI 每帧插值**应用到 DOM
|
|
309
|
+
* (帧驱动;高频帧级值不进 SSOT/事件流),播毕调 `animationFinished(seq)`
|
|
310
|
+
* 由核心把终值写回元素 `props`——保证快照/存档/回溯都是**终态**语义。
|
|
311
|
+
*
|
|
312
|
+
* 用**队列 + 完成回调**表达动画,避免为每个动画属性铺一串状态键。
|
|
313
|
+
*/
|
|
314
|
+
export interface AnimationSpec {
|
|
315
|
+
/** 动画归属元素 id(写入时由 `target` 寻址解析并**固化**,避免回溯后寻址漂移) */
|
|
316
|
+
target: string;
|
|
317
|
+
/** 动效属性名(元素属性全集内的数值属性) */
|
|
318
|
+
property: string;
|
|
319
|
+
from: number;
|
|
320
|
+
to: number;
|
|
321
|
+
/** 时长(秒) */
|
|
322
|
+
duration: number;
|
|
323
|
+
/** 缓动名(默认 `EaseOutQuad`;UI 侧映射到实际缓动函数) */
|
|
324
|
+
easing: string;
|
|
325
|
+
/** 单调序号:同一目标的连续动画、重放后的同命令可分辨(参考 `__video` 的 seq 去重语义) */
|
|
326
|
+
seq: number;
|
|
327
|
+
}
|