@wasm-fmt/mago_fmt 0.4.2 → 0.5.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/jsr.jsonc CHANGED
@@ -1,41 +1,22 @@
1
1
  {
2
+ "$schema": "https://jsr.io/schema/config-file.v1.json",
2
3
  "name": "@fmt/mago-fmt",
3
- "type": "module",
4
- "collaborators": [
5
- "magic-akari <akari.ccino@gmail.com>"
6
- ],
7
- "description": "A WASM based PHP Formatter",
8
- "version": "0.4.2",
9
- "license": "MIT",
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/wasm-fmt/mago_fmt"
13
- },
14
- "homepage": "https://github.com/wasm-fmt/mago_fmt",
15
- "types": "mago_fmt.d.ts",
16
- "sideEffects": [
17
- "./mago_fmt.js",
18
- "./snippets/*"
19
- ],
20
- "keywords": [
21
- "wasm",
22
- "mago",
23
- "PHP",
24
- "formatter"
25
- ],
26
- "publishConfig": {
27
- "access": "public"
28
- },
4
+ "version": "0.5.1",
29
5
  "exports": {
30
- ".": "./mago_fmt_esm.js",
6
+ ".": "./mago_fmt.js",
31
7
  "./esm": "./mago_fmt_esm.js",
32
8
  "./node": "./mago_fmt_node.js",
33
9
  "./bundler": "./mago_fmt.js",
34
- "./web": "./mago_fmt_web.js",
35
- "./wasm": "./mago_fmt_bg.wasm"
10
+ "./web": "./mago_fmt_web.js"
36
11
  },
37
- "exclude": [
38
- "!**",
39
- "*.tgz"
40
- ]
41
- }
12
+ "publish": {
13
+ "include": [
14
+ "mago_fmt_*",
15
+ "mago_fmt.*",
16
+ "README.md"
17
+ ],
18
+ "exclude": [
19
+ "!*"
20
+ ]
21
+ }
22
+ }
package/mago_fmt.d.ts CHANGED
@@ -1,8 +1,31 @@
1
+ /**
2
+ * WASM formatter for PHP using Mago.
3
+ *
4
+ * @example
5
+ * ```javascript
6
+ * import { format } from "@wasm-fmt/mago_fmt";
7
+ *
8
+ * const input = `<?php
9
+ * function hello( \$name ) {
10
+ * echo "Hello, " . \$name;
11
+ * }
12
+ * ?>`;
13
+ *
14
+ * const formatted = format(input, "main.php", {
15
+ * "use-tabs": false,
16
+ * "tab-width": 4,
17
+ * "print-width": 120,
18
+ * });
19
+ * console.log(formatted);
20
+ * ```
21
+ * @module
22
+ */
23
+
1
24
  /* tslint:disable */
2
25
  /* eslint-disable */
3
26
 
4
27
  import type { Settings } from "./mago_fmt_settings.d.ts";
5
- export type { Settings };
28
+ export type * from "./mago_fmt_settings.d.ts";
6
29
 
7
30
 
8
31
 
package/mago_fmt.js CHANGED
@@ -1,4 +1,3 @@
1
- /* @ts-self-types="./mago_fmt.d.ts" */
2
1
  import * as wasm from "./mago_fmt_bg.wasm";
3
2
  export * from "./mago_fmt_bg.js";
4
3
  import { __wbg_set_wasm } from "./mago_fmt_bg.js";
package/mago_fmt_bg.js CHANGED
@@ -111,6 +111,14 @@ function getUint8ArrayMemory0() {
111
111
 
112
112
  function getObject(idx) { return heap[idx]; }
113
113
 
114
+ function handleError(f, args) {
115
+ try {
116
+ return f.apply(this, args);
117
+ } catch (e) {
118
+ wasm.__wbindgen_export3(addHeapObject(e));
119
+ }
120
+ }
121
+
114
122
  let heap = new Array(128).fill(undefined);
115
123
  heap.push(undefined, null, true, false);
116
124
 
@@ -224,7 +232,7 @@ export function format(code, filename, settings) {
224
232
  return getStringFromWasm0(ptr3, len3);
225
233
  } finally {
226
234
  wasm.__wbindgen_add_to_stack_pointer(16);
227
- wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
235
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
228
236
  }
229
237
  }
230
238
 
@@ -263,7 +271,7 @@ export function format_with_version(code, php_version, filename, settings) {
263
271
  return getStringFromWasm0(ptr4, len4);
264
272
  } finally {
265
273
  wasm.__wbindgen_add_to_stack_pointer(16);
266
- wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
274
+ wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
267
275
  }
268
276
  }
269
277
 
@@ -272,11 +280,6 @@ export function __wbg_Error_52673b7de5a0ca89(arg0, arg1) {
272
280
  return addHeapObject(ret);
273
281
  };
274
282
 
275
- export function __wbg_Number_2d1dcfcf4ec51736(arg0) {
276
- const ret = Number(getObject(arg0));
277
- return ret;
278
- };
279
-
280
283
  export function __wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d(arg0, arg1) {
281
284
  const v = getObject(arg1);
282
285
  const ret = typeof(v) === 'bigint' ? v : undefined;
@@ -308,19 +311,14 @@ export function __wbg___wbindgen_is_bigint_0e1a2e3f55cfae27(arg0) {
308
311
  return ret;
309
312
  };
310
313
 
311
- export function __wbg___wbindgen_is_object_ce774f3490692386(arg0) {
312
- const val = getObject(arg0);
313
- const ret = typeof(val) === 'object' && val !== null;
314
+ export function __wbg___wbindgen_is_function_8d400b8b1af978cd(arg0) {
315
+ const ret = typeof(getObject(arg0)) === 'function';
314
316
  return ret;
315
317
  };
316
318
 
317
- export function __wbg___wbindgen_is_string_704ef9c8fc131030(arg0) {
318
- const ret = typeof(getObject(arg0)) === 'string';
319
- return ret;
320
- };
321
-
322
- export function __wbg___wbindgen_is_undefined_f6b95eab589e0269(arg0) {
323
- const ret = getObject(arg0) === undefined;
319
+ export function __wbg___wbindgen_is_object_ce774f3490692386(arg0) {
320
+ const val = getObject(arg0);
321
+ const ret = typeof(val) === 'object' && val !== null;
324
322
  return ret;
325
323
  };
326
324
 
@@ -354,6 +352,16 @@ export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
354
352
  throw new Error(getStringFromWasm0(arg0, arg1));
355
353
  };
356
354
 
355
+ export function __wbg_call_abb4ff46ce38be40() { return handleError(function (arg0, arg1) {
356
+ const ret = getObject(arg0).call(getObject(arg1));
357
+ return addHeapObject(ret);
358
+ }, arguments) };
359
+
360
+ export function __wbg_done_62ea16af4ce34b24(arg0) {
361
+ const ret = getObject(arg0).done;
362
+ return ret;
363
+ };
364
+
357
365
  export function __wbg_entries_83c79938054e065f(arg0) {
358
366
  const ret = Object.entries(getObject(arg0));
359
367
  return addHeapObject(ret);
@@ -364,10 +372,10 @@ export function __wbg_get_6b7bd52aca3f9671(arg0, arg1) {
364
372
  return addHeapObject(ret);
365
373
  };
366
374
 
367
- export function __wbg_get_with_ref_key_1dc361bd10053bfe(arg0, arg1) {
368
- const ret = getObject(arg0)[getObject(arg1)];
375
+ export function __wbg_get_af9dab7e9603ea93() { return handleError(function (arg0, arg1) {
376
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
369
377
  return addHeapObject(ret);
370
- };
378
+ }, arguments) };
371
379
 
372
380
  export function __wbg_instanceof_ArrayBuffer_f3320d2419cd0355(arg0) {
373
381
  let result;
@@ -380,6 +388,17 @@ export function __wbg_instanceof_ArrayBuffer_f3320d2419cd0355(arg0) {
380
388
  return ret;
381
389
  };
382
390
 
391
+ export function __wbg_instanceof_Map_084be8da74364158(arg0) {
392
+ let result;
393
+ try {
394
+ result = getObject(arg0) instanceof Map;
395
+ } catch (_) {
396
+ result = false;
397
+ }
398
+ const ret = result;
399
+ return ret;
400
+ };
401
+
383
402
  export function __wbg_instanceof_Uint8Array_da54ccc9d3e09434(arg0) {
384
403
  let result;
385
404
  try {
@@ -391,11 +410,21 @@ export function __wbg_instanceof_Uint8Array_da54ccc9d3e09434(arg0) {
391
410
  return ret;
392
411
  };
393
412
 
413
+ export function __wbg_isArray_51fd9e6422c0a395(arg0) {
414
+ const ret = Array.isArray(getObject(arg0));
415
+ return ret;
416
+ };
417
+
394
418
  export function __wbg_isSafeInteger_ae7d3f054d55fa16(arg0) {
395
419
  const ret = Number.isSafeInteger(getObject(arg0));
396
420
  return ret;
397
421
  };
398
422
 
423
+ export function __wbg_iterator_27b7c8b35ab3e86b() {
424
+ const ret = Symbol.iterator;
425
+ return addHeapObject(ret);
426
+ };
427
+
399
428
  export function __wbg_length_22ac23eaec9d8053(arg0) {
400
429
  const ret = getObject(arg0).length;
401
430
  return ret;
@@ -411,10 +440,25 @@ export function __wbg_new_6421f6084cc5bc5a(arg0) {
411
440
  return addHeapObject(ret);
412
441
  };
413
442
 
443
+ export function __wbg_next_138a17bbf04e926c(arg0) {
444
+ const ret = getObject(arg0).next;
445
+ return addHeapObject(ret);
446
+ };
447
+
448
+ export function __wbg_next_3cfe5c0fe2a4cc53() { return handleError(function (arg0) {
449
+ const ret = getObject(arg0).next();
450
+ return addHeapObject(ret);
451
+ }, arguments) };
452
+
414
453
  export function __wbg_prototypesetcall_dfe9b766cdc1f1fd(arg0, arg1, arg2) {
415
454
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
416
455
  };
417
456
 
457
+ export function __wbg_value_57b7b035e117f7ee(arg0) {
458
+ const ret = getObject(arg0).value;
459
+ return addHeapObject(ret);
460
+ };
461
+
418
462
  export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
419
463
  // Cast intrinsic for `Ref(String) -> Externref`.
420
464
  const ret = getStringFromWasm0(arg0, arg1);
@@ -427,8 +471,9 @@ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
427
471
  return addHeapObject(ret);
428
472
  };
429
473
 
430
- export function __wbindgen_object_clone_ref(arg0) {
431
- const ret = getObject(arg0);
474
+ export function __wbindgen_cast_9ae0607507abb057(arg0) {
475
+ // Cast intrinsic for `I64 -> Externref`.
476
+ const ret = arg0;
432
477
  return addHeapObject(ret);
433
478
  };
434
479
 
package/mago_fmt_bg.wasm CHANGED
Binary file
@@ -5,5 +5,6 @@ export const format: (a: number, b: number, c: number, d: number, e: number, f:
5
5
  export const format_with_version: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
6
6
  export const __wbindgen_export: (a: number, b: number) => number;
7
7
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
8
+ export const __wbindgen_export3: (a: number) => void;
8
9
  export const __wbindgen_add_to_stack_pointer: (a: number) => number;
9
- export const __wbindgen_export3: (a: number, b: number, c: number) => void;
10
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
@@ -1,7 +1,23 @@
1
1
  /**
2
- * See {@link https://mago.carthage.software/tools/formatter/configuration-reference}
2
+ * Configuration settings for the Mago formatter.
3
+ * See {@link https://mago.carthage.software/tools/formatter/configuration-reference}
3
4
  */
4
5
  export interface Settings {
6
+ /**
7
+ * Formatter preset to use as base configuration.
8
+ *
9
+ * Individual settings can override the preset values.
10
+ * @default "default"
11
+ *
12
+ * @remarks Available presets:
13
+ * - `default` - Default preset (PER-CS compatible)
14
+ * - `psr-12` - PSR-12 preset
15
+ * - `pint` - Pint preset (Laravel Pint compatible)
16
+ * - `tempest` - Tempest preset (Tempest framework compatible)
17
+ * - `hack` - Hack preset (`hackfmt` compatible)
18
+ */
19
+ preset?: "default" | "psr-12" | "pint" | "tempest" | "hack";
20
+
5
21
  /**
6
22
  * Maximum line length that the printer will wrap on.
7
23
  * @default 120
@@ -76,6 +92,12 @@ export interface Settings {
76
92
  */
77
93
  "control-brace-style"?: "same-line" | "next-line";
78
94
 
95
+ /**
96
+ * Whether to place `else`, `elseif`, `catch` and `finally` on a new line.
97
+ * @default false
98
+ */
99
+ "following-clause-on-newline"?: boolean;
100
+
79
101
  /**
80
102
  * Brace placement for closures.
81
103
  * @default "same-line"
@@ -961,7 +983,23 @@ export interface Settings {
961
983
  *
962
984
  * @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
963
985
  */
964
- "empty-line-after-classlike-constant"?: boolean;
986
+ "empty-line-after-class-like-constant"?: boolean;
987
+
988
+ /**
989
+ * Whether to add an empty line immediately after a class-like opening brace.
990
+ * @default false
991
+ *
992
+ * @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
993
+ */
994
+ "empty-line-after-class-like-open"?: boolean;
995
+
996
+ /**
997
+ * Whether to insert an empty line before the closing brace of class-like structures when the class body is not empty.
998
+ * @default false
999
+ *
1000
+ * When enabled, a blank line will be inserted immediately before the `}` that closes a class, trait, interface or enum, but only if the body contains at least one member.
1001
+ */
1002
+ "empty-line-before-class-like-close"?: boolean;
965
1003
 
966
1004
  /**
967
1005
  * Whether to add an empty line after enum case.
@@ -1011,5 +1049,24 @@ export interface Settings {
1011
1049
  * Whether to separate class-like members of different kinds with a blank line.
1012
1050
  * @default true
1013
1051
  */
1014
- "separate-classlike-members"?: boolean;
1052
+ "separate-class-like-members"?: boolean;
1053
+
1054
+ /**
1055
+ * Whether to indent heredoc/nowdoc content.
1056
+ * @default true
1057
+ */
1058
+ "indent-heredoc"?: boolean;
1059
+
1060
+ /**
1061
+ * Whether to print boolean and null literals in upper-case (e.g. `TRUE`, `FALSE`, `NULL`).
1062
+ * @default false
1063
+ *
1064
+ * When enabled these literals are printed in uppercase; when disabled they are printed in lowercase.
1065
+ */
1066
+ "uppercase-literal-keyword"?: boolean;
1067
+
1068
+ /**
1069
+ * See {@link https://mago.carthage.software/tools/formatter/configuration-reference}
1070
+ */
1071
+ [key: string]: unknown;
1015
1072
  }
package/mago_fmt_web.d.ts CHANGED
@@ -1,7 +1,42 @@
1
+ /**
2
+ * WASM formatter for PHP using Mago.
3
+ * Import this module and call init function before using.
4
+ *
5
+ * @example
6
+ * ```javascript
7
+ * import init, { format } from "@wasm-fmt/mago_fmt";
8
+ *
9
+ * await init();
10
+ *
11
+ * const input = `<?php
12
+ * function hello( \$name ) {
13
+ * echo "Hello, " . \$name;
14
+ * }
15
+ * ?>`;
16
+ *
17
+ * const formatted = format(input, "main.php", {
18
+ * "use-tabs": false,
19
+ * "tab-width": 4,
20
+ * "print-width": 120,
21
+ * });
22
+ * console.log(formatted);
23
+ * ```
24
+ * @module
25
+ */
26
+
1
27
  import type * as InitOutput from "./mago_fmt_bg.wasm.d.ts";
2
28
  declare type InitOutput = typeof InitOutput;
3
29
 
30
+ /**
31
+ * Input types for asynchronous WASM initialization.
32
+ * Can be a URL/path to fetch, a Response object, raw bytes, or a pre-compiled WebAssembly.Module.
33
+ */
4
34
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
35
+
36
+ /**
37
+ * Input types for synchronous WASM initialization.
38
+ * Must be raw bytes (BufferSource) or a pre-compiled WebAssembly.Module.
39
+ */
5
40
  export type SyncInitInput = BufferSource | WebAssembly.Module;
6
41
 
7
42
  /**
package/package.json CHANGED
@@ -5,17 +5,17 @@
5
5
  "magic-akari <akari.ccino@gmail.com>"
6
6
  ],
7
7
  "description": "A WASM based PHP Formatter",
8
- "version": "0.4.2",
8
+ "version": "0.5.1",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/wasm-fmt/mago_fmt"
12
+ "url": "git+https://github.com/wasm-fmt/mago_fmt.git"
13
13
  },
14
14
  "homepage": "https://github.com/wasm-fmt/mago_fmt",
15
- "types": "mago_fmt.d.ts",
16
15
  "sideEffects": [
17
16
  "./mago_fmt.js",
18
- "./snippets/*"
17
+ "./mago_fmt_node.js",
18
+ "./mago_fmt_esm.js"
19
19
  ],
20
20
  "keywords": [
21
21
  "wasm",
@@ -23,14 +23,14 @@
23
23
  "PHP",
24
24
  "formatter"
25
25
  ],
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
26
  "exports": {
30
27
  ".": {
31
28
  "types": "./mago_fmt.d.ts",
32
- "node": "./mago_fmt_node.js",
33
29
  "webpack": "./mago_fmt.js",
30
+ "deno": "./mago_fmt.js",
31
+ "bun": "./mago_fmt_node.js",
32
+ "module-sync": "./mago_fmt_node.js",
33
+ "node": "./mago_fmt_node.js",
34
34
  "default": "./mago_fmt_esm.js"
35
35
  },
36
36
  "./esm": {
@@ -56,5 +56,8 @@
56
56
  "./wasm": "./mago_fmt_bg.wasm",
57
57
  "./package.json": "./package.json",
58
58
  "./*": "./*"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
59
62
  }
60
- }
63
+ }