@silkweaver/build 1.3.2 → 1.3.3

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 CHANGED
@@ -218,10 +218,13 @@ async function generate_entry_code(project_folder, proj, asset_mode, engine_path
218
218
  if ((inst.rotation ?? 0) !== 0)
219
219
  lines.push(` ${v}.image_angle = ${inst.rotation}`);
220
220
  lines.push(` ${v}.register_events()`);
221
- lines.push(` game_loop.register(EVENT_TYPE.create, ${v}.on_create.bind(${v}))`);
222
- // Per-instance creation code runs after the object's Create event (bound: this = instance).
221
+ // Queue the Create event (+ optional per-instance creation code) via the engine helper,
222
+ // which runs them under the active-instance context so `sw`/`inst` resolve inside.
223
223
  if (inst.creation_code && inst.creation_code.trim()) {
224
- lines.push(` game_loop.register(EVENT_TYPE.create, (function(this: any){\n${inst.creation_code}\n}).bind(${v}))`);
224
+ lines.push(` instance_queue_create(${v}, (function(this: any){\n${inst.creation_code}\n}).bind(${v}))`);
225
+ }
226
+ else {
227
+ lines.push(` instance_queue_create(${v})`);
225
228
  }
226
229
  return lines.join('\n');
227
230
  }).filter(Boolean).join('\n');
@@ -512,7 +515,7 @@ async function _load_sound(name: string, meta_url: string, base: string): Promis
512
515
  // ── Bootstrap ───────────────────────────────────────────────────────────────
513
516
  export default async function init(canvas: HTMLCanvasElement): Promise<void> {
514
517
  renderer.init(canvas, ${proj.settings.windowWidth ?? 640}, ${proj.settings.windowHeight ?? 480})
515
- // Background clear color: ${proj.settings.displayColor ?? '#000000'}
518
+ renderer.set_clear_color(${JSON.stringify(proj.settings.displayColor ?? '#000000')}) // window/clear color (Game Settings)
516
519
  game_loop.init_input(canvas)
517
520
 
518
521
  // Load sprites
@@ -33,13 +33,14 @@ export interface object_model {
33
33
  /** Extracts the object model from a class-file source. */
34
34
  export declare function parse_object(src: string): object_model;
35
35
  /**
36
- * Collects every instance member reachable through `this.` in a class: declared instance fields
37
- * *plus* members created/assigned at runtime inside any event (e.g. `this.velocity = 0` in on_create,
38
- * read in on_step). This drives `this.` autocomplete, so a variable made in one event surfaces in all
39
- * the others matching the usual split of constants on the object, runtime state in Create. Static
40
- * fields and method/event names are excluded (engine members are merged in separately).
36
+ * Collects the object's OWN variables: declared instance fields *plus* members created/assigned at
37
+ * runtime via the `inst.` namespace inside any event (e.g. `inst.velocity = 0` in on_create, read in
38
+ * on_step). This drives `inst.` autocomplete, so a variable made in one event surfaces in all the
39
+ * others. Static fields (object metadata) and method/event names are excluded. The engine's built-in
40
+ * instance API is NOT collected here — it lives on `sw.` and is typed from the engine directly so
41
+ * `this.x`/`sw.x` style writes never leak into the author's own-variable list.
41
42
  */
42
- export declare function this_members(src: string): string[];
43
+ export declare function object_vars(src: string): string[];
43
44
  /**
44
45
  * Sets (adds or updates) a static metadata field. `expr` is the raw initializer
45
46
  * text (e.g. `'spr_player'`, `true`, `-5`, `obj_base`).
@@ -46,7 +46,7 @@ var __importStar = (this && this.__importStar) || (function () {
46
46
  Object.defineProperty(exports, "__esModule", { value: true });
47
47
  exports.EVENT_ORDER = exports.META_ORDER = void 0;
48
48
  exports.parse_object = parse_object;
49
- exports.this_members = this_members;
49
+ exports.object_vars = object_vars;
50
50
  exports.set_static = set_static;
51
51
  exports.remove_static = remove_static;
52
52
  exports.set_field = set_field;
@@ -151,13 +151,14 @@ function _string_literal(node) {
151
151
  return null;
152
152
  }
153
153
  /**
154
- * Collects every instance member reachable through `this.` in a class: declared instance fields
155
- * *plus* members created/assigned at runtime inside any event (e.g. `this.velocity = 0` in on_create,
156
- * read in on_step). This drives `this.` autocomplete, so a variable made in one event surfaces in all
157
- * the others matching the usual split of constants on the object, runtime state in Create. Static
158
- * fields and method/event names are excluded (engine members are merged in separately).
154
+ * Collects the object's OWN variables: declared instance fields *plus* members created/assigned at
155
+ * runtime via the `inst.` namespace inside any event (e.g. `inst.velocity = 0` in on_create, read in
156
+ * on_step). This drives `inst.` autocomplete, so a variable made in one event surfaces in all the
157
+ * others. Static fields (object metadata) and method/event names are excluded. The engine's built-in
158
+ * instance API is NOT collected here — it lives on `sw.` and is typed from the engine directly so
159
+ * `this.x`/`sw.x` style writes never leak into the author's own-variable list.
159
160
  */
160
- function this_members(src) {
161
+ function object_vars(src) {
161
162
  const sf = _source(src);
162
163
  const cls = _find_class(sf);
163
164
  if (!cls)
@@ -170,14 +171,14 @@ function this_members(src) {
170
171
  names.add(n);
171
172
  }
172
173
  }
173
- // Any `this.<name> = …` (or compound assignment) anywhere in the class body — including nested
174
- // blocks/closures — counts as an instance member the user can reference elsewhere.
174
+ // Any `inst.<name> = …` (or compound assignment) anywhere in the class body — including nested
175
+ // blocks/closures — counts as an author variable the user can reference elsewhere.
175
176
  const visit = (node) => {
176
177
  if (ts.isBinaryExpression(node)
177
178
  && node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment
178
179
  && node.operatorToken.kind <= ts.SyntaxKind.LastAssignment
179
180
  && ts.isPropertyAccessExpression(node.left)
180
- && node.left.expression.kind === ts.SyntaxKind.ThisKeyword
181
+ && ts.isIdentifier(node.left.expression) && node.left.expression.text === 'inst'
181
182
  && ts.isIdentifier(node.left.name)) {
182
183
  names.add(node.left.name.text);
183
184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silkweaver/build",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
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",