@silkweaver/build 1.3.0 → 1.3.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/dist/build.js +8 -0
- package/dist/object_format.js +23 -7
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -410,6 +410,14 @@ async function _load_sprite(name: string, meta_url: string, img_base: string): P
|
|
|
410
410
|
spr.mask_right = (meta.mask_x || 0) + meta.mask_w
|
|
411
411
|
spr.mask_bottom = (meta.mask_y || 0) + meta.mask_h
|
|
412
412
|
}
|
|
413
|
+
// Scale mode (how the sprite fills a scaled area) + 9-slice border insets (sprite editor).
|
|
414
|
+
if (meta.scale_mode === 'tile' || meta.scale_mode === 'nineslice' || meta.scale_mode === 'stretch') {
|
|
415
|
+
spr.scale_mode = meta.scale_mode
|
|
416
|
+
}
|
|
417
|
+
spr.slice_left = meta.slice_left || 0
|
|
418
|
+
spr.slice_top = meta.slice_top || 0
|
|
419
|
+
spr.slice_right = meta.slice_right || 0
|
|
420
|
+
spr.slice_bottom = meta.slice_bottom || 0
|
|
413
421
|
|
|
414
422
|
// Load all frames specified in meta.json
|
|
415
423
|
const frames = meta.frames || []
|
package/dist/object_format.js
CHANGED
|
@@ -63,6 +63,19 @@ exports.META_ORDER = [
|
|
|
63
63
|
'sprite', 'parent', 'solid', 'visible', 'persistent', 'depth',
|
|
64
64
|
'physics', 'physics_shape', 'physics_density', 'physics_restitution', 'physics_friction', 'physics_sensor',
|
|
65
65
|
];
|
|
66
|
+
/**
|
|
67
|
+
* Explicit type annotations for static fields whose base-class type is narrower than what TypeScript
|
|
68
|
+
* would infer from the literal initializer. Without this, `static physics_shape = 'box'` widens to
|
|
69
|
+
* `string`, which doesn't satisfy the base's `'box' | 'circle'` and the subclass fails to compile.
|
|
70
|
+
*/
|
|
71
|
+
const META_TYPES = {
|
|
72
|
+
physics_shape: `'box' | 'circle'`,
|
|
73
|
+
};
|
|
74
|
+
/** Renders a `static <name>[: <type>] = <expr>;` declaration, adding an annotation where one is needed. */
|
|
75
|
+
function _static_decl(name, expr) {
|
|
76
|
+
const ann = META_TYPES[name];
|
|
77
|
+
return `static ${name}${ann ? `: ${ann}` : ''} = ${expr};`;
|
|
78
|
+
}
|
|
66
79
|
/** Canonical GMS-style order of `on_*` event methods (used to keep events ordered in code). */
|
|
67
80
|
exports.EVENT_ORDER = [
|
|
68
81
|
'on_create', 'on_destroy',
|
|
@@ -226,16 +239,19 @@ function set_static(src, name, expr) {
|
|
|
226
239
|
if (!cls)
|
|
227
240
|
return src;
|
|
228
241
|
const existing = _find_member(cls, m => ts.isPropertyDeclaration(m) && _is_static(m) && _name_of(m) === name);
|
|
229
|
-
if (existing?.initializer) {
|
|
230
|
-
return _apply(src, { start: existing.initializer.getStart(sf), end: existing.initializer.getEnd(), text: expr });
|
|
231
|
-
}
|
|
232
242
|
if (existing) {
|
|
233
|
-
//
|
|
234
|
-
|
|
243
|
+
// For annotated fields (e.g. physics_shape) replace the whole member so the type annotation is
|
|
244
|
+
// always present/correct — updating just the initializer could leave it un-annotated (→ widens
|
|
245
|
+
// to string and fails to compile). For plain fields, the cheaper initializer-only edit is fine.
|
|
246
|
+
if (META_TYPES[name])
|
|
247
|
+
return _apply(src, { start: existing.getStart(sf), end: existing.getEnd(), text: _static_decl(name, expr) });
|
|
248
|
+
if (existing.initializer)
|
|
249
|
+
return _apply(src, { start: existing.initializer.getStart(sf), end: existing.initializer.getEnd(), text: expr });
|
|
250
|
+
return _apply(src, { start: existing.getStart(sf), end: existing.getEnd(), text: _static_decl(name, expr) });
|
|
235
251
|
}
|
|
236
252
|
// New static: metadata lives at the TOP, ordered by META_ORDER. Insert before the first static
|
|
237
253
|
// that sorts after it; else before the first non-static member (so statics stay grouped up top).
|
|
238
|
-
const stub = `
|
|
254
|
+
const stub = ` ${_static_decl(name, expr)}\n`;
|
|
239
255
|
const order = exports.META_ORDER.indexOf(name);
|
|
240
256
|
if (order >= 0) {
|
|
241
257
|
const after = cls.members.find(m => {
|
|
@@ -568,7 +584,7 @@ function scaffold_object(class_name, kind = 'normal') {
|
|
|
568
584
|
if (kind === 'physics') {
|
|
569
585
|
return `export class ${class_name} extends gm_object {
|
|
570
586
|
static physics = true;
|
|
571
|
-
static physics_shape = 'box';
|
|
587
|
+
static physics_shape: 'box' | 'circle' = 'box';
|
|
572
588
|
static physics_density = 0.5;
|
|
573
589
|
static physics_restitution = 0.1;
|
|
574
590
|
static physics_friction = 0.2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silkweaver/build",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Silkweaver toolchain — compiles a project folder into a runnable game (HTML5 / desktop executable). Usable from a CLI or the IDE.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "GPL-3.0",
|