toilscript 0.1.25 → 0.1.26
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/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/importmap.json +2 -2
- package/dist/web.js +3 -3
- package/package.json +1 -1
- package/std/ts-plugin.cjs +17 -2
package/dist/importmap.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"imports": {
|
|
3
|
-
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
4
|
-
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
3
|
+
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.26/dist/toilscript.js",
|
|
4
|
+
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.26/dist/cli.js",
|
|
5
5
|
"binaryen": "https://cdn.jsdelivr.net/npm/binaryen@129.0.0-nightly.20260428/index.js",
|
|
6
6
|
"long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
|
|
7
7
|
}
|
package/dist/web.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var ASSEMBLYSCRIPT_VERSION = "0.1.
|
|
1
|
+
var ASSEMBLYSCRIPT_VERSION = "0.1.26";
|
|
2
2
|
var ASSEMBLYSCRIPT_IMPORTMAP = {
|
|
3
3
|
"imports": {
|
|
4
|
-
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
5
|
-
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
4
|
+
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.26/dist/toilscript.js",
|
|
5
|
+
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.26/dist/cli.js",
|
|
6
6
|
"binaryen": "https://cdn.jsdelivr.net/npm/binaryen@129.0.0-nightly.20260428/index.js",
|
|
7
7
|
"long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
|
|
8
8
|
}
|
package/package.json
CHANGED
package/std/ts-plugin.cjs
CHANGED
|
@@ -125,6 +125,18 @@ function init(modules) {
|
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/** True when a declaration carries an `export` modifier. The appended codec
|
|
129
|
+
* augmentation must match the class's export-ness, else merging the class with
|
|
130
|
+
* the synthesized `interface`/`namespace` trips TS2395 ("must be all exported
|
|
131
|
+
* or all local"). */
|
|
132
|
+
function hasExportModifier(node) {
|
|
133
|
+
const mods =
|
|
134
|
+
(ts.getModifiers && ts.canHaveModifiers && ts.canHaveModifiers(node)
|
|
135
|
+
? ts.getModifiers(node)
|
|
136
|
+
: node.modifiers) || [];
|
|
137
|
+
return mods.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
138
|
+
}
|
|
139
|
+
|
|
128
140
|
/** True when the parsed file is an ES module (has a top-level import/export), so
|
|
129
141
|
* a global augmentation must be wrapped in `declare global { ... }`. */
|
|
130
142
|
function isModuleFile(sf) {
|
|
@@ -164,11 +176,14 @@ function init(modules) {
|
|
|
164
176
|
const isUser = declHasDecorator(node, 'user');
|
|
165
177
|
if (!declHasDecorator(node, 'data') && !isUser) return;
|
|
166
178
|
const n = node.name.text;
|
|
179
|
+
// Match the class's export-ness so the class/interface/namespace merge is all
|
|
180
|
+
// exported or all local (an exported class + local augmentation -> TS2395).
|
|
181
|
+
const exp = hasExportModifier(node) ? 'export ' : '';
|
|
167
182
|
// Both `@data` and `@user` classes get the compiler-injected binary codec.
|
|
168
183
|
out +=
|
|
169
184
|
`\n// toilscript: editor types for the compiler-injected ${isUser ? '@user' : '@data'} ${n} codec\n` +
|
|
170
|
-
|
|
171
|
-
|
|
185
|
+
`${exp}interface ${n} { encode(): Uint8Array; toJSON(): JSON; }\n` +
|
|
186
|
+
`${exp}declare namespace ${n} { function decode(buf: Uint8Array): ${n}; function fromJSON(v: JSON): ${n}; function dataId(): u32; }\n`;
|
|
172
187
|
// The single `@user` class is also the type of `AuthService.getUser()`
|
|
173
188
|
// everywhere: merge it into the global `__ToilAuthUser` interface that the
|
|
174
189
|
// generated env d.ts returns from `getUser()`. `declare global` when the
|