gs2-studio-dsl 0.0.0-stage → 2026.11.13
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 +63 -0
- package/LLM.md +395 -0
- package/README.md +80 -2
- package/REFERENCE.md +1599 -0
- package/gs2.d.ts +1 -0
- package/index.d.ts +9016 -0
- package/package.json +34 -4
- package/raw.d.ts +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
|
|
4
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
5
|
+
|
|
6
|
+
1. Definitions.
|
|
7
|
+
|
|
8
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
9
|
+
|
|
10
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
11
|
+
|
|
12
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
13
|
+
|
|
14
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
15
|
+
|
|
16
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
17
|
+
|
|
18
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
19
|
+
|
|
20
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
21
|
+
|
|
22
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
23
|
+
|
|
24
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
25
|
+
|
|
26
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
27
|
+
|
|
28
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
29
|
+
|
|
30
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
31
|
+
|
|
32
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
33
|
+
|
|
34
|
+
1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
35
|
+
2. You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
36
|
+
3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
37
|
+
4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
38
|
+
|
|
39
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
40
|
+
|
|
41
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
42
|
+
|
|
43
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
44
|
+
|
|
45
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
46
|
+
|
|
47
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
48
|
+
|
|
49
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
50
|
+
|
|
51
|
+
END OF TERMS AND CONDITIONS
|
|
52
|
+
|
|
53
|
+
Note: Other license terms may apply to certain, identified software files contained within or distributed with the accompanying software if such terms are included in the directory containing the accompanying software. Such other license terms will then apply in lieu of the terms of the software license above.
|
|
54
|
+
|
|
55
|
+
JSON processing code subject to the JSON License from JSON.org:
|
|
56
|
+
|
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
58
|
+
|
|
59
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
60
|
+
|
|
61
|
+
The Software shall be used for Good, not Evil.
|
|
62
|
+
|
|
63
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/LLM.md
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
# gs2-studio-dsl for LLM coding agents
|
|
2
|
+
|
|
3
|
+
Instructions for an agent that writes or edits a GS2 Studio package DSL. Follow them literally. Section names in
|
|
4
|
+
[REFERENCE.md](REFERENCE.md) are linked where an API is involved.
|
|
5
|
+
|
|
6
|
+
## 1. What the DSL is
|
|
7
|
+
|
|
8
|
+
- A package DSL is a TypeScript module that calls `definePackage({ ... })` and exports the package definition (or the
|
|
9
|
+
result of `.build()`). GS2 Studio's `dsl build` command evaluates it, validates the package, and saves it into a GS2
|
|
10
|
+
Studio project.
|
|
11
|
+
- This npm package (`gs2-studio-dsl`) contains type declarations only. It has no runtime; never try to run a DSL with
|
|
12
|
+
Node, `ts-node`, a bundler or a test runner. Only `dsl build` evaluates it.
|
|
13
|
+
- `dsl build` does not type-check. It removes types with Node's type stripping and runs the result. Type errors you do
|
|
14
|
+
not catch with `tsc --noEmit` become run-time failures or wrong packages.
|
|
15
|
+
- The generated package files in the project (`packages/<id>/**`, `project.json`) are output. Never edit them; change
|
|
16
|
+
the DSL and rebuild.
|
|
17
|
+
|
|
18
|
+
## 2. Project layout
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
<project>/ GS2 Studio project (project.json, packages/)
|
|
22
|
+
<dsl>/
|
|
23
|
+
index.ts the entry: exports exactly one definePackage({...}) or .build() result
|
|
24
|
+
id-ledger.json ids of the package; created by dsl build --write-ledger; commit it
|
|
25
|
+
dependency-surface.json written by dsl build: what this package publishes to packages that depend on it
|
|
26
|
+
surfaces/<packageId>.json written by dsl surfaces: what each package of the project publishes
|
|
27
|
+
tsconfig.json the tsconfig from the README
|
|
28
|
+
package.json devDependencies: gs2-studio-dsl, typescript
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Besides `gs2-studio-dsl` and `gs2-studio-dsl/gs2`, a module may import only by relative path (`./...` or `../...`,
|
|
32
|
+
anywhere on disk): `.ts` files (the extension may be left out), `.json` files, and any file as text with `?raw`. Nothing
|
|
33
|
+
else (see [Modules and imports](REFERENCE.md#modules-and-imports)).
|
|
34
|
+
|
|
35
|
+
## 3. Workflow
|
|
36
|
+
|
|
37
|
+
`<GS2 Studio>` is the GS2 Studio executable (the README gives its path per platform).
|
|
38
|
+
|
|
39
|
+
To start a new `<dsl>`, run `"<GS2 Studio>" dsl init --dir <project> --out <dsl> --package-id <id>`, then
|
|
40
|
+
`npm install` in `<dsl>` (without `--package-id`, the package id is the name of `<dsl>`). It writes `package.json`,
|
|
41
|
+
`tsconfig.json`, a starter `index.ts`, `surfaces/`, these documents under `docs/`, and an `AGENTS.md` that lists the
|
|
42
|
+
commands below with the executable's path; the first build writes the ledger. It refuses when one of its files exists.
|
|
43
|
+
|
|
44
|
+
1. Put every dependency in the project first: install it in GS2 Studio ("Add dependency", under any package of the
|
|
45
|
+
project), or, for a package you author too, build it into the project with `dsl build`. The DSL cannot install
|
|
46
|
+
packages.
|
|
47
|
+
2. If the package depends on other packages, write their surfaces (one file per package of the project):
|
|
48
|
+
`"<GS2 Studio>" dsl surfaces --dir <project> --out <dsl>/surfaces`
|
|
49
|
+
3. Write or edit `<dsl>/index.ts`. When the package depends on other packages, declare the dependencies first and build
|
|
50
|
+
(steps 4 to 7): the build then names the types of the dependencies that need rows from this package.
|
|
51
|
+
4. Type-check: `npx tsc --noEmit -p <dsl>`. Fix every error before building.
|
|
52
|
+
5. First build of a new package:
|
|
53
|
+
`"<GS2 Studio>" dsl build --dir <project> --entry <dsl>/index.ts --write-ledger`
|
|
54
|
+
6. Later builds: the same command without `--write-ledger`. Add `--write-ledger` only when the build reports missing
|
|
55
|
+
ledger tokens for things you added (a type, property, row or transform) and reports no token as "not current".
|
|
56
|
+
A "not current" token means a rename or removal: handle it as in section 4 first.
|
|
57
|
+
7. Read what a build that saved the package prints on stderr: the `[error]` and `[warning]` lines `project check`
|
|
58
|
+
reports for the project. The build exits with 0 because it saved the package, but each line says what deploy or code
|
|
59
|
+
generation will do wrong or leave out. Fix each one the DSL can fix (section 6) and build again; tell the user about a
|
|
60
|
+
line on another package that the DSL does not change. Then open the project in GS2 Studio and fix what it reports:
|
|
61
|
+
what Unity code generation alone refuses is not printed (see
|
|
62
|
+
[Building with dsl build](REFERENCE.md#building-with-dsl-build)).
|
|
63
|
+
8. Keep `id-ledger.json` and `dependency-surface.json` with `index.ts`; commit them together.
|
|
64
|
+
|
|
65
|
+
A build that fails a check writes nothing. On failure, read every listed problem, fix the DSL, and rerun.
|
|
66
|
+
|
|
67
|
+
## 4. Hard rules
|
|
68
|
+
|
|
69
|
+
MUST:
|
|
70
|
+
|
|
71
|
+
- Export exactly one `definePackage({ ... })` (or `.build()`) result from the entry.
|
|
72
|
+
- Register every domain type definition you reference in `definePackage({ domainTypes: [...] })`. Refer to types,
|
|
73
|
+
resources and action transforms by their definition handles (never by raw type name strings).
|
|
74
|
+
- Use thunks (`() => Type` or `() => resource`) when two definitions refer to each other or when a definition refers to
|
|
75
|
+
one declared later in the file.
|
|
76
|
+
- Import types with `import type` or `type` specifiers (`import { type LocalizedDisplay, PT } from "gs2-studio-dsl"`).
|
|
77
|
+
- Name domain types in PascalCase and properties in camelCase. Never declare a property named `id`.
|
|
78
|
+
- Bind every `.masterData()` property in some master data resource and every `.userData()` property in some user data
|
|
79
|
+
resource, or remove the hint.
|
|
80
|
+
- Make sure some resource, of this package or of a dependency, mounts the target type of every `defineUiComponent`.
|
|
81
|
+
- Before adding UI to a dependency's type, read `types.<Type>.uiComponents` of its surface. Reuse a listed item instead
|
|
82
|
+
of adding one that shows the same, and give new items unlisted class names: a listed one replaces that item.
|
|
83
|
+
- Give a single-entry type's row the type name in lower case as its id (`GameSettings` → `gamesettings`).
|
|
84
|
+
- Refer to anything of another package only through `dependencyPackage(surface)` built from a surface file that
|
|
85
|
+
`dsl surfaces` wrote (or, for a package you build yourself, the `dependency-surface.json` beside its ledger, which
|
|
86
|
+
has the same content): `dep.type(...)`, `dep.overlay(...)`, `dep.typeId(...)`, `dep.propertyId(...)`,
|
|
87
|
+
`dep.transformId(...)`, `dep.transformCall(...)`, `dep.transformProgram(...)`, `dep.resourceId(...)`. Declare the
|
|
88
|
+
dependency in `definePackage({ dependencies: { [dep.packageId]: spec } })`. The spec of a package authored in the same
|
|
89
|
+
project is `"*"`. An installed package has the spec of its source, as the `dependencies` of
|
|
90
|
+
`<project>/packages/<packageId>/package.json` of the package that installed it declare it: a package installed from
|
|
91
|
+
GitHub is `github:<owner>/<repo>[@<range>]` without its subdirectory, and every package of the GS2 Studio package
|
|
92
|
+
repository is `github:gs2io/gs2-studio-package`. Never give an installed package `"*"`; `dsl build` refuses it and
|
|
93
|
+
prints the spec to declare (see [Dependencies](REFERENCE.md#dependencies)).
|
|
94
|
+
- Learn what a dependency needs from its surface file, not from its package files: `types.<Type>.propertyDetails`
|
|
95
|
+
gives each property's `type`, `requirement`, `bindingHint` and, when it has one, its `display` (label and description
|
|
96
|
+
per locale); `actionTransformSignatures.<Name>` gives each transform's category and parameters (name, type,
|
|
97
|
+
required and, when it has one, description); `types.<Type>.delegatedActions.<Method>.parameters` gives what a
|
|
98
|
+
`UiItem.buttonAction` on that method takes as `args`; `types.<Type>.sort` gives the order of its rows, which an overlay of
|
|
99
|
+
the type keeps unless it sets a `sort` other than id ascending. A `ref<T>` parameter or property takes a row id of `T`.
|
|
100
|
+
- Call a dependency's transform with `dep.transformCall(name, { <parameter>: source })` (spread into an
|
|
101
|
+
`actionPropertyTransforms` entry) or `dep.transformProgram(name, { <parameter>: source })` (in `actionProgram`),
|
|
102
|
+
not with `dep.transformId(...)` and hand-written arguments, so `tsc` and `dsl build` check the parameter names. The
|
|
103
|
+
two name a property differently: `transformCall` takes `{ kind: "domainProperty", propertyName: "<property of the
|
|
104
|
+
row>" }`, `transformProgram` takes `{ kind: "domainProperty", source: Source.direct(...) }`. See the examples in
|
|
105
|
+
[Overlay types](REFERENCE.md#overlay-types) and [Action programs](REFERENCE.md#action-programs-and-arguments).
|
|
106
|
+
- Add the rows a dependency's type needs from the project with `instance(dep.type("<Type>"), id, values)` in
|
|
107
|
+
`definePackage({ instances: [...] })`: every type a build names in `No master data is registered for domain model
|
|
108
|
+
"<Type>"`. Never author a row whose id a surface lists for the same type (`shippedRowIds`,
|
|
109
|
+
`shippedRowsOfDependencyTypes`): a package ships it, and a row with its id replaces it (use `overlayInstance`). Take
|
|
110
|
+
the values from `types.<Type>.propertyDetails` of the surface. Give a value to every `requirement: "always"` property
|
|
111
|
+
except `id` (the row id), `userData` properties and action lists
|
|
112
|
+
(`list<consumeAction>` and the other action kinds): a missing one fails the build. An action list you leave out
|
|
113
|
+
deploys as what `actionPropertyTransforms` add to it, or empty.
|
|
114
|
+
- Choose each property's binding hint by what reads its value, also for a property an overlay adds: the client, from
|
|
115
|
+
the rows you author (a UI component shows it) → `.assetDelivery()`; only an `actionPropertyTransforms` argument → no
|
|
116
|
+
hint; a field a master data resource of this package binds → `.masterData()`. See the table in
|
|
117
|
+
[Property modifiers](REFERENCE.md#property-modifiers).
|
|
118
|
+
- Check the value keys of rows written with a dependency type (`instance(dep.type("Energy"), ...)`) against the
|
|
119
|
+
published property names yourself: `tsc` does not check them, and `dsl build` refuses an unknown one
|
|
120
|
+
(`unresolvedPropertySlot`).
|
|
121
|
+
- Regenerate surface files after a dependency changes. Never edit them by hand.
|
|
122
|
+
- In master data, use `Bind.domainProperty` only in a resource mounted on a domain type, and never use
|
|
123
|
+
`Bind.domainProperties` (user data only). `dsl build` accepts both mistakes; the editor and code generation refuse
|
|
124
|
+
them.
|
|
125
|
+
- When you edit `id-ledger.json`, keep the key order `schemaVersion`, `retired`, `random`, `deterministicOverrides` and
|
|
126
|
+
keep the entries of each section sorted by token.
|
|
127
|
+
|
|
128
|
+
MUST NOT:
|
|
129
|
+
|
|
130
|
+
- Edit generated package JSON in the project.
|
|
131
|
+
- Change, swap or reuse an existing id in `id-ledger.json`. Other packages and projects refer to these ids.
|
|
132
|
+
- Delete ledger entries. Move the entry of a removed thing from `random` to `retired`; move the id of a renamed thing to
|
|
133
|
+
its new token.
|
|
134
|
+
- Hand-write ids (`dt_...`, `prop_...`, `at_...`, `mdr_...`) in the DSL. Take them from a surface or let the build
|
|
135
|
+
generate them.
|
|
136
|
+
- Use `enum`, `namespace` with values, parameter properties, top-level `await`, dynamic `import()` of the DSL modules,
|
|
137
|
+
`node:*` modules or npm packages other than `gs2-studio-dsl`.
|
|
138
|
+
- Attach one `defineMasterDataResource` / `defineUserDataResource` definition in two places.
|
|
139
|
+
- Use one `defineInlineElement` schema for two list properties.
|
|
140
|
+
|
|
141
|
+
Names and ids:
|
|
142
|
+
|
|
143
|
+
- You write names; GS2 Studio stores ids. The ledger maps names (tokens such as `property:Item.count`) to ids.
|
|
144
|
+
- Renaming a type, property, row or transform: the build reports the old token as "not current" and the new one as
|
|
145
|
+
missing. In `id-ledger.json`, move the old token's id to the new token in `random`, then build without
|
|
146
|
+
`--write-ledger`. Never let `--write-ledger` record a new id for a renamed thing. Renaming a type also renames its
|
|
147
|
+
`property:<Type>.<name>` and row tokens; move each of them. It also changes, without a message, the ids of the
|
|
148
|
+
type's UI component and its items and of user data resources mounted on the type; keep them with
|
|
149
|
+
`deterministicOverrides`. See [The id ledger](REFERENCE.md#the-id-ledger).
|
|
150
|
+
- A row id is letters, digits, `_`, `.` and `-`, at most 128 characters; a resource that binds `id` to a GS2 name sends
|
|
151
|
+
it as that name (a `micro-economy-quest` `Quest` row id is the quest model name), and some GS2 fields take fewer.
|
|
152
|
+
- A row token contains the row id. Before you treat a "not current" + "missing" row token pair as a rename of a
|
|
153
|
+
composite-key row, check the new row id against the composite key rule below; a wrong id must be fixed in the DSL,
|
|
154
|
+
not moved in the ledger.
|
|
155
|
+
- A composite-key row id is its key values joined with `.` in ascending order of the key members' property ids in the
|
|
156
|
+
ledger, not in the order passed to `compositeKey`. Build the type with `--write-ledger` before adding its rows,
|
|
157
|
+
read the ids, then add the rows. See [Keys and identity](REFERENCE.md#keys-and-identity).
|
|
158
|
+
|
|
159
|
+
## 5. API cheat sheet
|
|
160
|
+
|
|
161
|
+
| Task | API | Reference |
|
|
162
|
+
| --- | --- | --- |
|
|
163
|
+
| Declare a package | `definePackage({ id, version, display?, dependencies?, domainTypes?, instances?, ... }).build()` | [Packages](REFERENCE.md#packages) |
|
|
164
|
+
| Label a package or type | `display` on `definePackage`; `localizedDisplay` on `defineDomainType` / `defineOverlayDomainType` / `defineInlineElement` | [Packages](REFERENCE.md#packages), [Domain types](REFERENCE.md#domain-types) |
|
|
165
|
+
| Declare a type | `defineDomainType(name, { properties, localizedDisplay?, localizedProperties?, singleEntry?, compositeKey?, sort?, delegatedActions? })` | [Domain types](REFERENCE.md#domain-types) |
|
|
166
|
+
| Declare a property | `PT.int32().masterData().required()`, `PT.ref(Item)`, `PT.enum("a", "b")` in `properties: { name: ... }` | [Properties](REFERENCE.md#properties) |
|
|
167
|
+
| Choose a binding hint | `.assetDelivery()` (the client shows it), none (only a transform argument), `.masterData()` (a resource binds it) | [Property modifiers](REFERENCE.md#property-modifiers) |
|
|
168
|
+
| Text shown in the player's language (a display name) | One `displayName: PT.localizedString().assetDelivery()`, rows `{ ja: "...", en: "..." }`, a `UiItem.label` on it; not one property per language | [Localized text](REFERENCE.md#localized-text) |
|
|
169
|
+
| Localized text in a template or a condition | `templateLabel` placeholder and `UiCond.truthy` / `eq` / `neq` read the player's locale's translation; never `gt`/`lt`, never against a number | [Localized text](REFERENCE.md#localized-text) |
|
|
170
|
+
| Conditional requirement | `.requiredWhen(Cond.eq("limited", true))` | [Conditions](REFERENCE.md#conditions) |
|
|
171
|
+
| Identity and order | `singleEntry: true`, `compositeKey: [...]`, `sort: { key, direction? }` | [Keys and identity](REFERENCE.md#keys-and-identity) |
|
|
172
|
+
| Author rows | `instance(definition, id, values)` in `instances: [...]` | [Instances](REFERENCE.md#instances) |
|
|
173
|
+
| Rows a dependency's type needs from the project | `instance(dep.type("Energy"), id, values)` in `instances: [...]` | [Instances](REFERENCE.md#instances) |
|
|
174
|
+
| Change a row a dependency ships | `overlayInstance(type, sourceInstanceId, { overrides?, suppressed? })` in `overlayInstances: [...]` | [Instances](REFERENCE.md#instances) |
|
|
175
|
+
| Extend a dependency's type | `defineOverlayDomainType(name, dep.overlay(name), { properties?, actionPropertyTransforms?, ... })` | [Overlay types](REFERENCE.md#overlay-types) |
|
|
176
|
+
| List of structured elements | `defineInlineElement(name, { properties, elementKey?, ... })`, `PT.listOf(PT.inlineElement(schema))`, `inlineElementOf(Host, "listProp")` | [Inline elements](REFERENCE.md#inline-elements) |
|
|
177
|
+
| Configure a GS2 master data model | `defineMasterDataResource({ model: GS2.svc.Model, mount: T, bindings: {...}, children?, arrayChildren? })` | [Master data resources](REFERENCE.md#master-data-resources) |
|
|
178
|
+
| Map GS2 user data to properties | `defineUserDataResource({ model: GS2.svc.Model, linkedMaster?, mount?, bindings: {...}, children? })` | [User data resources](REFERENCE.md#user-data-resources) |
|
|
179
|
+
| Field values | `Bind.*`, `Source.direct(T, "prop")`, `Source.parent(...)`, `transactionSettingV2()` | [Bindings](REFERENCE.md#bindings) |
|
|
180
|
+
| Actions of an action entry | `ActionProgram.transform(transform, [Arg...])`; a dependency's: `dep.transformProgram(name, { count: { kind: "domainProperty", source: Source.parent(Source.direct(T, "count")) } })` | [Action programs and arguments](REFERENCE.md#action-programs-and-arguments) |
|
|
181
|
+
| Add a dependency's transform to an inherited action property | `actionPropertyTransforms: [{ targetProperty, mode: "append", ...dep.transformCall(name, { count: { kind: "domainProperty", propertyName: "price" } }) }]` | [Overlay types](REFERENCE.md#overlay-types) |
|
|
182
|
+
| Produce GS2 actions from parameters | `defineActionTransform(name, { category, parameters, outputs })` + `OutputMap.*` | [Action transforms](REFERENCE.md#action-transforms) |
|
|
183
|
+
| A method that runs a GS2 action | `delegatedActions: { Method: { targetActionKey, targetResource } }` on the type, or `definePackage({ delegatedActions: [{ target, methodName, action: { targetActionKey, targetResource } }] })` | [Delegated actions](REFERENCE.md#delegated-actions) |
|
|
184
|
+
| Generated UI | `defineUiComponent(T, { items: [UiItem.label(...), UiItem.buttonAction(...)] })`, `UiSource.*`, `UiCond.*` | [UI components](REFERENCE.md#ui-components) |
|
|
185
|
+
| Enable a button by another type's row (stamina, coins) | `UiItem.interactable("StartInteractable", UiCond.gte(UiSource.rowProp(energy.type("Energy"), "stamina", "currentValue"), UiSource.prop("staminaCost")))` | [Another type's row](REFERENCE.md#another-types-row) |
|
|
186
|
+
| Choose a UI item and its options | `label` shows text, `templateLabel` text around values, `value` sends a typed value the game formats; a button never disables itself (add `interactable`). `{ name, description }` only label the item in GS2 Studio's editor; leave them out | [UI components](REFERENCE.md#ui-components), [Item options](REFERENCE.md#item-options) |
|
|
187
|
+
| Show every row in the game, in order | A UI component describes one row; the generated `<T>ListHandler` makes one instance of a prefab per row, in the order of `sort` (an overlay: the dependency's order unless it sets a `sort` other than id ascending) | [Rows in the game](REFERENCE.md#rows-in-the-game) |
|
|
188
|
+
| A button on a dependency's delegated action | `UiItem.buttonAction("StartButton", "Start", args, options)`; `args` takes only the names under `types.<T>.delegatedActions.Start.parameters` of the surface and needs each `required: true` one; with none required it may be `undefined` | [Dependencies](REFERENCE.md#dependencies) |
|
|
189
|
+
| Code template | `codeTemplates: [{ outputFileName: "File.cs", templateSource: text }]` with a `?raw` import | [Code templates](REFERENCE.md#code-templates) |
|
|
190
|
+
| Use another package of the project | `dependencyPackage(surface)`, `dependencies: { [dep.packageId]: spec }`; spec `"*"` (authored in the project), or for an installed package the spec the package that installed it declares (`"github:gs2io/gs2-studio-package"` for an official package) | [Dependencies](REFERENCE.md#dependencies) |
|
|
191
|
+
|
|
192
|
+
## 6. Common mistakes
|
|
193
|
+
|
|
194
|
+
| Symptom | Cause | Fix |
|
|
195
|
+
| --- | --- | --- |
|
|
196
|
+
| `CLI_DSL_LOAD_FAILED` ... `imports X from "gs2-studio-dsl", which exports no value with that name` | A type imported as a value. | Use `import type` / `type X`. |
|
|
197
|
+
| `CLI_DSL_LOAD_FAILED` ... `which a DSL cannot import` | An import other than the published modules, relative `.ts`, `.json` or `?raw` files. | Remove it; inline the code or copy the file into the DSL directory. |
|
|
198
|
+
| `CLI_DSL_LOAD_FAILED` ... `dependency surface: no type named "X"` (or `no property`, `no ActionTransform`) | The name is not in the surface file, or the surface is stale. | Rerun `dsl surfaces`; use a published name. |
|
|
199
|
+
| `tsc`: `... is not assignable to parameter of type 'never'` on `dep.transformCall` / `dep.transformProgram`, or `CLI_DSL_LOAD_FAILED` ... `publishes no parameters of ActionTransform` | The surface file was written by a GS2 Studio that did not publish transform signatures. | Rerun `dsl surfaces` (and `dsl build` of a dependency you author). |
|
|
200
|
+
| `tsc`: `Object literal may only specify known properties` in a `transformCall` argument, or `ActionTransform "X" has no parameter "y"` / `needs the required parameter "z"` | A wrong or missing parameter name. The message lists the parameters. | Use the names under `actionTransformSignatures.X.parameters` of the surface. |
|
|
201
|
+
| `CLI_DSL_EXPORT_INVALID` | Zero or several built packages exported. | Export exactly one `definePackage({...})` or `.build()` result. |
|
|
202
|
+
| `{"kind":"domainTypeDefinitionNotRegistered",...}`, `{"kind":"invalidInstanceType",...}`, `{"kind":"uiComponentTargetTypeUnknown",...}` | A definition used (in a mount or binding, a row, a UI component) without being listed in `domainTypes: [...]`. | Include it in `definePackage({ domainTypes: [...] })`. |
|
|
203
|
+
| `{"kind":"reservedPropertyName",...}` | A property named `id`. | Rename it; `id` exists already. |
|
|
204
|
+
| `{"kind":"unresolvedPropertySlot",...}` | A misspelled or undeclared property name in values, overlay options or UI. | Use a declared or published name; the error lists both. |
|
|
205
|
+
| `{"kind":"uiComponentUnknownProperty",...}` / `{"kind":"uiComponentUnknownDelegatedAction",...}` | `UiSource.prop` or `UiItem.buttonAction` names something the target lacks. | Declare the property or register the delegated action on that type. |
|
|
206
|
+
| `{"kind":"duplicateUiComponentClassName",...}` | Two items of the same type share a class name. | Make class names unique per type. |
|
|
207
|
+
| `{"kind":"uiComponentTemplateLabelKeyMismatch",...}` | `{key}` placeholders and `sources` keys differ. | Make them match one to one. |
|
|
208
|
+
| `{"kind":"singleEntryInstanceIdMismatch",...,"expectedId":"..."}` | Wrong row id on a single-entry type. | Use `expectedId`. |
|
|
209
|
+
| `{"kind":"invalidCompositeKey","reason":"unsupportedMemberBindingHint",...}` | A key member without `masterData` / `assetDelivery`. | Add the hint. |
|
|
210
|
+
| `{"kind":"invalidSortKey","reason":"notRequired",...}` | Sorting by an optional property. | Make it `.required()` or sort by `"id"`. |
|
|
211
|
+
| `{"kind":"invalidBindingValue",...}` | A binding kind the resource does not accept (for example `Bind.resourceKey()` on user data), a malformed directive, or an inline schema used twice. | Read `context`; use an accepted kind. |
|
|
212
|
+
| `{"kind":"unresolvedResourceRef",...}` | A `resource`, `linkedMaster`, `resourceLink` or `mountedResource` handle names a resource never included in the package's `masterDataResources` / `userDataResources` trees. | Include the resource in `masterDataResources`, `userDataResources`, `children`, or `arrayChildren`. |
|
|
213
|
+
| `{"kind":"resourceDefinitionAttachedTwice",...}` | One resource definition included in two places (two `children` lists, or a root and a child). | Make a second definition with its own `defineMasterDataResource` / `defineUserDataResource`. |
|
|
214
|
+
| `{"kind":"unresolvedParentBinding",...}` | `Source.parent(...)` on a root resource. | Use `Source.direct(...)`, or move the resource under a parent. |
|
|
215
|
+
| `CLI_DSL_LEDGER_MISSING` | First build without `--write-ledger`. | Add `--write-ledger`. |
|
|
216
|
+
| `CLI_DSL_LEDGER_MISMATCH` ... `random token ... is missing from the ledger`, and no token is "not current" | You added something. | Check the tokens, then rebuild with `--write-ledger`. |
|
|
217
|
+
| `CLI_DSL_LEDGER_MISMATCH` ... `is not current; move it to retired` | You renamed or removed something, or changed a row id. | A changed composite-key row id: first check it against the composite key rule. Renamed: move the old token's id to the new token. Removed: move token and id to `retired`. Then rebuild without `--write-ledger`. |
|
|
218
|
+
| `CLI_DSL_LEDGER_INVALID` ... `not canonical` | The ledger's key order, entry order, indentation or final newline differs from what GS2 Studio writes. | Restore that form (section 4). |
|
|
219
|
+
| `CLI_DSL_VALIDATION_FAILED` ... `No master data resource binds this property.` | A `.masterData()` property no resource binds. | Bind it with `Bind.domainProperty(Source.direct(T, "prop"))` in a resource mounted on `T`, or remove the hint. |
|
|
220
|
+
| `CLI_DSL_VALIDATION_FAILED` ... `No user data resource binds this property.` | A `.userData()` property no resource binds. | Bind it in a user data resource (`Bind.domainProperty` / `Bind.domainProperties` with `Source.direct(T, "prop")`), or remove the hint. |
|
|
221
|
+
| `CLI_DSL_VALIDATION_FAILED` ... `is not mounted by any resource` | A UI component on a type no resource mounts. | Mount the type with a resource, or remove the component. |
|
|
222
|
+
| `CLI_DSL_VALIDATION_FAILED` ... `instance ids that no longer match their composite-key values` | Row ids not composed from key values in property-id order. | Recompose ids per [Keys and identity](REFERENCE.md#keys-and-identity). |
|
|
223
|
+
| `CLI_DSL_DEPENDENCY_NOT_INSTALLED` | `dependencies` names a package the project lacks. | A package authored in the project: build it with `dsl build` first. Another package: add it in GS2 Studio. |
|
|
224
|
+
| `CLI_DSL_PACKAGE_INVALID` ... `Invalid GitHub dependency spec: github:<owner>/<repo>/<dir>` | A subdirectory in a GitHub spec. | Use `github:<owner>/<repo>`; the project's lock records the directory. |
|
|
225
|
+
| `CLI_DSL_DEPENDENCY_SPEC_MISMATCH` | `dependencies` gives an installed package a spec that names another source than the one the project installed it from, such as `"*"`. | Declare it with the spec the message prints, then build again. |
|
|
226
|
+
| `CLI_DSL_VALIDATION_FAILED` ... `the parent <resource> resource has no row` ... `Add a row of "T"` | Rows of a dependency's type sit under a GS2 resource made from rows of `T`, which nobody authored. | Add a row of `T` with `instance(dep.type("T"), id, values)` and point your rows at it (for example the `collection` of a quest row). |
|
|
227
|
+
| `... is a dependency the DSL cannot change, so these are fixed through the dependency that brings it in: ...` | A defect of the dependency itself, not of this DSL. | If the message says to remove the dependency `"X"` from the DSL and the package does not need X, remove it and what refers to it. Otherwise tell the user: the project's owner updates or removes the dependency in GS2 Studio, as the message says. |
|
|
228
|
+
| A successful build prints `[warning] ... No master data is registered for domain model "T"` | A dependency's GS2 resource needs rows of `T` from the project; it is not deployed without them. | Add the row the message names, `instance(dep.type("T"), id, values)`, with the values it names, and build again. `dep.type("<Type>")` means the message names no type `dep.type()` takes: for an inline schema, add elements to the host type's list property with `dep.inlineElements(...)`; for an unresolved type, find it in the surfaces. |
|
|
229
|
+
| A successful build prints `[error] ... the required arguments (...) of action transform ... have no value for row "r"` | An `actionPropertyTransforms` argument reads a property row `r` has no value for. | Give the row the value; for a row a dependency ships, use `overlayInstance(type, "r", { overrides })`. |
|
|
230
|
+
| A UI item of a property you added shows nothing (or `0`) in the game | The property has no binding hint, so the client never gets its value. | Give it `.assetDelivery()`. |
|
|
231
|
+
|
|
232
|
+
## 7. Minimal complete example
|
|
233
|
+
|
|
234
|
+
A package with one type, a master data resource tree, a user data resource, a UI component and two action transforms.
|
|
235
|
+
It builds with `dsl build` as shown in the workflow.
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
import {
|
|
239
|
+
Bind,
|
|
240
|
+
defineActionTransform,
|
|
241
|
+
defineDomainType,
|
|
242
|
+
defineMasterDataResource,
|
|
243
|
+
definePackage,
|
|
244
|
+
defineUiComponent,
|
|
245
|
+
defineUserDataResource,
|
|
246
|
+
type LocalizedDisplay,
|
|
247
|
+
OutputMap,
|
|
248
|
+
PT,
|
|
249
|
+
Source,
|
|
250
|
+
UiCond,
|
|
251
|
+
UiItem,
|
|
252
|
+
UiSource,
|
|
253
|
+
} from "gs2-studio-dsl";
|
|
254
|
+
import { GS2 } from "gs2-studio-dsl/gs2";
|
|
255
|
+
|
|
256
|
+
function text(label: string, description: string): LocalizedDisplay {
|
|
257
|
+
return { en: { label, description } };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const Item = defineDomainType("Item", {
|
|
261
|
+
properties: {
|
|
262
|
+
count: PT.int64().userData().required(),
|
|
263
|
+
},
|
|
264
|
+
localizedDisplay: text("Item", "An item a player can own."),
|
|
265
|
+
localizedProperties: {
|
|
266
|
+
id: text("ID", "Identifies the item."),
|
|
267
|
+
count: text("Owned quantity", "How many of the item the player owns."),
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const SimpleItemModel = defineMasterDataResource({
|
|
272
|
+
model: GS2.inventory.SimpleItemModel,
|
|
273
|
+
mount: Item,
|
|
274
|
+
bindings: {
|
|
275
|
+
name: Bind.domainProperty(Source.direct(Item, "id")),
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
const AcquireItem = defineActionTransform("AcquireItem", {
|
|
280
|
+
category: "acquire",
|
|
281
|
+
parameters: {
|
|
282
|
+
itemName: { type: PT.ref(Item) },
|
|
283
|
+
count: { type: PT.int32() },
|
|
284
|
+
},
|
|
285
|
+
outputs: [
|
|
286
|
+
{
|
|
287
|
+
kind: "direct",
|
|
288
|
+
actionName: "Gs2Inventory:AcquireSimpleItemsByUserId",
|
|
289
|
+
resource: SimpleItemModel,
|
|
290
|
+
parameterMappings: {
|
|
291
|
+
namespaceName: OutputMap.resourceKey(),
|
|
292
|
+
inventoryName: OutputMap.resourceKey(),
|
|
293
|
+
userId: OutputMap.placeholder("#{userId}"),
|
|
294
|
+
"acquireCounts[0].itemName": OutputMap.parameter("itemName"),
|
|
295
|
+
"acquireCounts[0].count": OutputMap.parameter("count"),
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
const ConsumeItem = defineActionTransform("ConsumeItem", {
|
|
302
|
+
category: "consume",
|
|
303
|
+
parameters: {
|
|
304
|
+
itemName: { type: PT.ref(Item) },
|
|
305
|
+
count: { type: PT.int32() },
|
|
306
|
+
},
|
|
307
|
+
outputs: [
|
|
308
|
+
{
|
|
309
|
+
kind: "direct",
|
|
310
|
+
actionName: "Gs2Inventory:ConsumeSimpleItemsByUserId",
|
|
311
|
+
resource: SimpleItemModel,
|
|
312
|
+
parameterMappings: {
|
|
313
|
+
namespaceName: OutputMap.resourceKey(),
|
|
314
|
+
inventoryName: OutputMap.resourceKey(),
|
|
315
|
+
userId: OutputMap.placeholder("#{userId}"),
|
|
316
|
+
"consumeCounts[0].itemName": OutputMap.parameter("itemName"),
|
|
317
|
+
"consumeCounts[0].count": OutputMap.parameter("count"),
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
export const exampleInventory = definePackage({
|
|
324
|
+
id: "example-inventory",
|
|
325
|
+
version: "0.0.1",
|
|
326
|
+
display: text("Items", "Tracks the items a player owns."),
|
|
327
|
+
domainTypes: [Item],
|
|
328
|
+
masterDataResources: [
|
|
329
|
+
defineMasterDataResource({
|
|
330
|
+
model: GS2.inventory.Namespace,
|
|
331
|
+
bindings: {
|
|
332
|
+
name: Bind.static("Inventory"),
|
|
333
|
+
},
|
|
334
|
+
children: [
|
|
335
|
+
defineMasterDataResource({
|
|
336
|
+
model: GS2.inventory.SimpleInventoryModel,
|
|
337
|
+
bindings: {
|
|
338
|
+
name: Bind.static("Inventory"),
|
|
339
|
+
},
|
|
340
|
+
arrayChildren: {
|
|
341
|
+
simpleItemModels: [SimpleItemModel],
|
|
342
|
+
},
|
|
343
|
+
}),
|
|
344
|
+
],
|
|
345
|
+
}),
|
|
346
|
+
],
|
|
347
|
+
userDataResources: [
|
|
348
|
+
defineUserDataResource({
|
|
349
|
+
model: GS2.inventory.SimpleItem,
|
|
350
|
+
linkedMaster: SimpleItemModel,
|
|
351
|
+
bindings: {
|
|
352
|
+
count: Bind.domainProperties([Source.direct(Item, "count")]),
|
|
353
|
+
itemName: Bind.skip(),
|
|
354
|
+
userId: Bind.skip(),
|
|
355
|
+
},
|
|
356
|
+
}),
|
|
357
|
+
],
|
|
358
|
+
uiComponents: [
|
|
359
|
+
defineUiComponent(Item, {
|
|
360
|
+
items: [
|
|
361
|
+
UiItem.templateLabel("StockLabel", "{id} x{count}", {
|
|
362
|
+
id: UiSource.prop("id"),
|
|
363
|
+
count: UiSource.prop("count"),
|
|
364
|
+
}),
|
|
365
|
+
UiItem.value("CountValue", UiSource.prop("count")),
|
|
366
|
+
UiItem.interactable(
|
|
367
|
+
"OwnedInteractable",
|
|
368
|
+
UiCond.gt(UiSource.prop("count"), UiSource.lit(0))
|
|
369
|
+
),
|
|
370
|
+
],
|
|
371
|
+
}),
|
|
372
|
+
],
|
|
373
|
+
actionTransforms: [AcquireItem, ConsumeItem],
|
|
374
|
+
});
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Its `id-ledger.json` after the first `dsl build --write-ledger`:
|
|
378
|
+
|
|
379
|
+
```json
|
|
380
|
+
{
|
|
381
|
+
"schemaVersion": 1,
|
|
382
|
+
"retired": {},
|
|
383
|
+
"random": {
|
|
384
|
+
"property:Item.count": "prop_1DQWSQS8AC837BT0EWF1439PFW",
|
|
385
|
+
"transform:AcquireItem": "at_0XAMJJD9WX8S0TR71Z8KMQ8V80",
|
|
386
|
+
"transform:ConsumeItem": "at_1YA7MG1XJH88XT3P4Z6JF09ZVW",
|
|
387
|
+
"type:Item": "dt_20QRK0BTMW89TAWPHGNYFXNYJ5"
|
|
388
|
+
},
|
|
389
|
+
"deterministicOverrides": {}
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
For dependencies, overlays, delegated actions and code templates, read the `example-gift-shop` sections of
|
|
394
|
+
[REFERENCE.md](REFERENCE.md#dependencies). For an overlay that appends a dependency's transform to an inherited action
|
|
395
|
+
property with `dep.transformCall`, read `example-gift-sale` in [Overlay types](REFERENCE.md#overlay-types).
|
package/README.md
CHANGED
|
@@ -1,3 +1,81 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gs2-studio-dsl
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Type definitions for the GS2 Studio package DSL. This package contains declarations only.
|
|
4
|
+
GS2 Studio evaluates the DSL itself: it strips the TypeScript types with Node's built-in type
|
|
5
|
+
stripping and runs the result against the DSL runtime bundled in the app. The app does not
|
|
6
|
+
type-check; use these declarations in your editor and with `tsc --noEmit`.
|
|
7
|
+
|
|
8
|
+
- Syntax reference: [REFERENCE.md](REFERENCE.md)
|
|
9
|
+
- For LLM coding agents: [LLM.md](LLM.md)
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install --save-dev gs2-studio-dsl@2026.11.13
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The version is the GS2 Studio version whose DSL these declarations describe: a DSL written
|
|
16
|
+
against gs2-studio-dsl 2026.11.13 builds with GS2 Studio 2026.11.13 and later. Install the version that
|
|
17
|
+
matches the oldest GS2 Studio you build with.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { definePackage, defineDomainType, PT, Bind, Source } from "gs2-studio-dsl";
|
|
21
|
+
import { GS2 } from "gs2-studio-dsl/gs2";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
GS2 Studio also loads a file's text through a `?raw` import (for example a script passed to an
|
|
25
|
+
action). Its declaration is opt-in, because projects that also use Vite already get the same
|
|
26
|
+
`*?raw` module from `vite/client`. Enable it with `"types": ["gs2-studio-dsl/raw"]` in
|
|
27
|
+
tsconfig, or with `/// <reference types="gs2-studio-dsl/raw" />` in one source file:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import updateScript from "./scripts/update.lua?raw";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## tsconfig
|
|
34
|
+
|
|
35
|
+
Only syntax that Node can strip is supported (no `enum`, `namespace` with values, or
|
|
36
|
+
parameter properties), and type-only imports must be marked with `import type`:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"compilerOptions": {
|
|
41
|
+
"target": "ES2022",
|
|
42
|
+
"module": "ESNext",
|
|
43
|
+
"moduleResolution": "bundler",
|
|
44
|
+
"strict": true,
|
|
45
|
+
"noEmit": true,
|
|
46
|
+
"verbatimModuleSyntax": true,
|
|
47
|
+
"erasableSyntaxOnly": true,
|
|
48
|
+
"resolveJsonModule": true,
|
|
49
|
+
"allowImportingTsExtensions": true,
|
|
50
|
+
"types": [
|
|
51
|
+
"gs2-studio-dsl/raw"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`resolveJsonModule` lets a package read a dependency's `dependency-surface.json` and pass it to
|
|
58
|
+
`dependencyPackage(...)`.
|
|
59
|
+
|
|
60
|
+
## Building with GS2 Studio
|
|
61
|
+
|
|
62
|
+
The GS2 Studio executable runs the `dsl` commands headless and exits with their exit code:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
# start a DSL directory for the project: package.json, this tsconfig, a starter index.ts, docs/LLM.md,
|
|
66
|
+
# docs/REFERENCE.md, AGENTS.md (CLAUDE.md) with these commands, and surfaces/; then run npm install in it
|
|
67
|
+
"<GS2 Studio>" dsl init --dir <project> --out <dsl> --package-id <id>
|
|
68
|
+
# write <out>/<packageId>.json for each package of the project (installed or authored in it)
|
|
69
|
+
"<GS2 Studio>" dsl surfaces --dir <project> --out <out>
|
|
70
|
+
# evaluate the DSL, check it, and save the package into the project (--write-ledger the first time);
|
|
71
|
+
# after saving it prints the [error] and [warning] lines project check reports, and exits with 0
|
|
72
|
+
"<GS2 Studio>" dsl build --dir <project> --entry <dsl/index.ts> --write-ledger
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`<GS2 Studio>` is `/Applications/GS2 Studio.app/Contents/MacOS/GS2 Studio` on macOS and the
|
|
76
|
+
`GS2-Studio-<version>-linux-<arch>.AppImage` file on Linux. On Windows the executable does not write to the console, so the commands cannot
|
|
77
|
+
be run from a terminal yet. `--help` after `dsl` lists every option.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
Apache-2.0
|