@yabgu_gm/tensionscript 0.0.0-stage → 0.11.0

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.
Files changed (117) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +97 -0
  3. package/README.md +156 -2
  4. package/bin/tensionscript.js +35 -0
  5. package/dist/asc.d.ts +4 -0
  6. package/dist/asc.generated.d.ts +12007 -0
  7. package/dist/asc.js +23474 -0
  8. package/dist/asc.js.map +7 -0
  9. package/dist/assemblyscript.d.ts +4 -0
  10. package/dist/assemblyscript.generated.d.ts +13221 -0
  11. package/dist/assemblyscript.js +337 -0
  12. package/dist/assemblyscript.js.map +7 -0
  13. package/dist/importmap.json +9 -0
  14. package/dist/transform.cjs +1 -0
  15. package/dist/transform.d.ts +1 -0
  16. package/dist/transform.js +1 -0
  17. package/dist/web.js +22 -0
  18. package/lib/binaryen.d.ts +2 -0
  19. package/lib/binaryen.js +2 -0
  20. package/package.json +116 -4
  21. package/std/README.md +6 -0
  22. package/std/assembly/array.ts +526 -0
  23. package/std/assembly/arraybuffer.ts +77 -0
  24. package/std/assembly/atomics.ts +127 -0
  25. package/std/assembly/bindings/asyncify.ts +16 -0
  26. package/std/assembly/bindings/dom.ts +291 -0
  27. package/std/assembly/bindings/node.ts +6 -0
  28. package/std/assembly/builtins.ts +2642 -0
  29. package/std/assembly/closures.ts +22 -0
  30. package/std/assembly/compat.ts +2 -0
  31. package/std/assembly/console.ts +42 -0
  32. package/std/assembly/crypto.ts +9 -0
  33. package/std/assembly/dataview.ts +181 -0
  34. package/std/assembly/date.ts +373 -0
  35. package/std/assembly/diagnostics.ts +11 -0
  36. package/std/assembly/error.ts +44 -0
  37. package/std/assembly/function.ts +38 -0
  38. package/std/assembly/index.d.ts +2721 -0
  39. package/std/assembly/iterator.ts +35 -0
  40. package/std/assembly/map.ts +260 -0
  41. package/std/assembly/math.ts +3289 -0
  42. package/std/assembly/memory.ts +123 -0
  43. package/std/assembly/number.ts +388 -0
  44. package/std/assembly/object.ts +36 -0
  45. package/std/assembly/performance.ts +9 -0
  46. package/std/assembly/polyfills.ts +27 -0
  47. package/std/assembly/process.ts +50 -0
  48. package/std/assembly/reference.ts +48 -0
  49. package/std/assembly/regexp.ts +12 -0
  50. package/std/assembly/rt/README.md +81 -0
  51. package/std/assembly/rt/common.ts +81 -0
  52. package/std/assembly/rt/index-incremental.ts +2 -0
  53. package/std/assembly/rt/index-minimal.ts +2 -0
  54. package/std/assembly/rt/index-stub.ts +1 -0
  55. package/std/assembly/rt/index.d.ts +37 -0
  56. package/std/assembly/rt/itcms.ts +419 -0
  57. package/std/assembly/rt/rtrace.ts +15 -0
  58. package/std/assembly/rt/stub.ts +133 -0
  59. package/std/assembly/rt/tcms.ts +254 -0
  60. package/std/assembly/rt/tlsf.ts +592 -0
  61. package/std/assembly/rt.ts +87 -0
  62. package/std/assembly/set.ts +220 -0
  63. package/std/assembly/shared/feature.ts +65 -0
  64. package/std/assembly/shared/runtime.ts +11 -0
  65. package/std/assembly/shared/target.ts +11 -0
  66. package/std/assembly/shared/tsconfig.json +11 -0
  67. package/std/assembly/shared/typeinfo.ts +72 -0
  68. package/std/assembly/staticarray.ts +401 -0
  69. package/std/assembly/string.ts +847 -0
  70. package/std/assembly/symbol.ts +114 -0
  71. package/std/assembly/table.ts +16 -0
  72. package/std/assembly/task-rt.ts +609 -0
  73. package/std/assembly/task.ts +90 -0
  74. package/std/assembly/tsconfig.json +6 -0
  75. package/std/assembly/typedarray.ts +1945 -0
  76. package/std/assembly/uri.ts +17 -0
  77. package/std/assembly/util/bytes.ts +135 -0
  78. package/std/assembly/util/casemap.ts +497 -0
  79. package/std/assembly/util/error.ts +54 -0
  80. package/std/assembly/util/hash.ts +117 -0
  81. package/std/assembly/util/math.ts +1922 -0
  82. package/std/assembly/util/memory.ts +290 -0
  83. package/std/assembly/util/number.ts +873 -0
  84. package/std/assembly/util/sort.ts +313 -0
  85. package/std/assembly/util/string.ts +1202 -0
  86. package/std/assembly/util/uri.ts +275 -0
  87. package/std/assembly/vector.ts +4 -0
  88. package/std/assembly.json +16 -0
  89. package/std/portable/index.d.ts +462 -0
  90. package/std/portable/index.js +416 -0
  91. package/std/portable.json +11 -0
  92. package/std/types/assembly/index.d.ts +1 -0
  93. package/std/types/assembly/package.json +3 -0
  94. package/std/types/portable/index.d.ts +1 -0
  95. package/std/types/portable/package.json +3 -0
  96. package/tsconfig-base.json +13 -0
  97. package/util/README.md +23 -0
  98. package/util/browser/fs.js +1 -0
  99. package/util/browser/module.js +5 -0
  100. package/util/browser/path.js +520 -0
  101. package/util/browser/process.js +59 -0
  102. package/util/browser/url.js +23 -0
  103. package/util/cpu.d.ts +9 -0
  104. package/util/cpu.js +42 -0
  105. package/util/find.d.ts +6 -0
  106. package/util/find.js +20 -0
  107. package/util/node.d.ts +21 -0
  108. package/util/node.js +34 -0
  109. package/util/options.d.ts +70 -0
  110. package/util/options.js +262 -0
  111. package/util/terminal.d.ts +52 -0
  112. package/util/terminal.js +35 -0
  113. package/util/text.d.ts +26 -0
  114. package/util/text.js +114 -0
  115. package/util/tsconfig.json +9 -0
  116. package/util/web.d.ts +11 -0
  117. package/util/web.js +33 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,97 @@
1
+ This package is TensionScript, a fork of AssemblyScript maintained at
2
+ https://github.com/Yabgu/TensionScript for the Tension engine. The attribution
3
+ notices below are retained from the original project, as its license requires.
4
+
5
+ The following authors have all licensed their contributions to AssemblyScript
6
+ under the licensing terms detailed in LICENSE:
7
+
8
+ * Daniel Wirtz <dcode@dcode.io>
9
+ * Max Graey <maxgraey@gmail.com>
10
+ * Igor Sbitnev <PinkaminaDianePie@gmail.com>
11
+ * Norton Wang <me@nortonwang.com>
12
+ * Alan Pierce <alangpierce@gmail.com>
13
+ * Palmer <pengliao@live.cn>
14
+ * Linus Unnebäck <linus@folkdatorn.se>
15
+ * Joshua Tenner <tenner.joshua@gmail.com>
16
+ * Nidin Vinayakan <01@01alchemist.com>
17
+ * Aaron Turner <aaron@aaronthedev.com>
18
+ * Willem Wyndham <willem@cs.umd.edu>
19
+ * Bowen Wang <bowen@nearprotocol.com>
20
+ * Emil Laine <laine.emil@gmail.com>
21
+ * Stephen Paul Weber <stephen.weber@shopify.com>
22
+ * Jay Phelps <hello@jayphelps.com>
23
+ * jhwgh1968 <jhwgh1968@protonmail.com>
24
+ * Jeffrey Charles <jeffreycharles@gmail.com>
25
+ * Vladimir Tikhonov <reg@tikhonov.by>
26
+ * Duncan Uszkay <duncan.uszkay@shopify.com>
27
+ * Surma <surma@surma.dev>
28
+ * Julien Letellier <letellier.julien@gmail.com>
29
+ * Guido Zuidhof <me@guido.io>
30
+ * ncave <777696+ncave@users.noreply.github.com>
31
+ * Andrew Davis <pulpdrew@gmail.com>
32
+ * Maël Nison <nison.mael@gmail.com>
33
+ * Valeria Viana Gusmao <valeria.viana.gusmao@gmail.com>
34
+ * Gabor Greif <ggreif@gmail.com>
35
+ * Martin Fredriksson <martin.fredriksson@vikinganalytics.se>
36
+ * forcepusher <bionitsoup@gmail.com>
37
+ * Piotr Oleś <piotrek.oles@gmail.com>
38
+ * Saúl Cabrera <saulecabrera@gmail.com>
39
+ * Chance Snow <git@chancesnow.me>
40
+ * Peter Salomonsen <petersalomonsen@runbox.com>
41
+ * ookangzheng <git-ed@runbox.no>
42
+ * yjhmelody <yjh465402634@gmail.com>
43
+ * bnbarak <bn.barak@gmail.com>
44
+ * Colin Eberhardt <colin.eberhardt@gmail.com>
45
+ * Ryan Pivovar <ryanpivovar@gmail.com>
46
+ * Roman F. <70765447+romdotdog@users.noreply.github.com>
47
+ * Joe Pea <trusktr@gmail.com>
48
+ * Felipe Gasper <FGasper@users.noreply.github.com>
49
+ * Congcong Cai <congcongcai0907@163.com>
50
+ * mooooooi <emwings@outlook.com>
51
+ * Yasushi Ando <andyjpn@gmail.com>
52
+ * Syed Jafri <syed@metalpay.co>
53
+ * Peter Hayman <peteyhayman@gmail.com>
54
+ * ApsarasX <apsarax@outlook.com>
55
+ * Adrien Zinger <zinger.ad@gmail.com>
56
+ * Ruixiang Chen <xiang19890319@gmail.com>
57
+ * Daniel Salvadori <danaugrs@gmail.com>
58
+ * Jairus Tanaka <me@jairus.dev>
59
+ * CountBleck <Mr.YouKnowWhoIAm@protonmail.com>
60
+ * Abdul Rauf <abdulraufmujahid@gmail.com>
61
+ * Bach Le <bach@bullno1.com>
62
+ * Xinquan Xu <xinquan0203@163.com>
63
+ * Matt Johnson-Pint <mattjohnsonpint@gmail.com>
64
+ * Fabián Heredia Montiel <fabianhjr@users.noreply.github.com>
65
+ * Jonas Minnberg <sasq64@gmail.com>
66
+ * Kam Chehresa <kaz.che@gmail.com>
67
+ * Mopsgamer <79159094+Mopsgamer@users.noreply.github.com>
68
+ * EDM115 <github@edm115.dev>
69
+ * Weixie Cui <cuiweixie@gmail.com>
70
+
71
+ Portions of this software are derived from third-party works licensed under
72
+ the following terms:
73
+
74
+ * TypeScript: https://github.com/Microsoft/TypeScript
75
+
76
+ Copyright (c) Microsoft Corporation
77
+ Apache License, Version 2.0 (https://opensource.org/licenses/Apache-2.0)
78
+
79
+ * Binaryen: https://github.com/WebAssembly/binaryen
80
+
81
+ Copyright (c) WebAssembly Community Group participants
82
+ Apache License, Version 2.0 (https://opensource.org/licenses/Apache-2.0)
83
+
84
+ * musl libc: http://www.musl-libc.org
85
+
86
+ Copyright (c) Rich Felker, et al.
87
+ The MIT License (https://opensource.org/licenses/MIT)
88
+
89
+ * V8: https://developers.google.com/v8/
90
+
91
+ Copyright (c) the V8 project authors
92
+ The 3-Clause BSD License (https://opensource.org/licenses/BSD-3-Clause)
93
+
94
+ * Arm Optimized Routines: https://github.com/ARM-software/optimized-routines
95
+
96
+ Copyright (c) Arm Limited
97
+ The MIT License (https://opensource.org/licenses/MIT)
package/README.md CHANGED
@@ -1,3 +1,157 @@
1
- # Temporary Holding Version
1
+ # TensionScript
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **A TypeScript-shaped language for WebAssembly** — the compiler Tension's guests
4
+ are written in.
5
+
6
+ TensionScript compiles TypeScript syntax to WebAssembly using
7
+ [Binaryen](https://github.com/WebAssembly/binaryen). It is maintained for the
8
+ [Tension](https://github.com/Yabgu/Tension) engine as a fork of
9
+ [AssemblyScript](https://github.com/AssemblyScript/assemblyscript). The command
10
+ and the package are its own: it does not collide with `asc` (AssemblyScript's
11
+ compiler) or `tsc` (TypeScript's), so a project that installs both compilers
12
+ always resolves the one it named.
13
+
14
+ **Current version: 0.11.0.** The [feature showcase](docs/showcase.md) has one
15
+ section per capability, with runnable examples and the refused forms; the scoping
16
+ notes it draws from are in [`docs/`](docs/).
17
+
18
+ ## Install
19
+
20
+ ```sh
21
+ npm install @yabgu_gm/tensionscript
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ The command is `tensionscript`. From an npm script, `tensionscript …` resolves to
27
+ the installed package's binary; from a shell, `npx tensionscript …` does:
28
+
29
+ ```sh
30
+ npx tensionscript assembly/index.ts -o build/index.wasm --runtime incremental --target release
31
+ ```
32
+
33
+ The compiler is also a library, under the package's `asc` subpath:
34
+
35
+ ```js
36
+ import tensionscript from "@yabgu_gm/tensionscript/asc";
37
+ ```
38
+
39
+ ## Status
40
+
41
+ TensionScript is a **fork of AssemblyScript**, and it does not aim for upstream
42
+ merge: AssemblyScript's repository is a reference, not a target. The base is
43
+ pinned at `b6bda05c` (upstream's tip at fork time) and the fork is **154
44
+ commits ahead of it**, measured at `ef18ae56`. Why the fork exists, what it
45
+ shares, and how it stays current: [`docs/fork-posture.md`](docs/fork-posture.md).
46
+
47
+ ### What this fork adds
48
+
49
+ - **C-model interop.** `@unmanaged struct` (a plain C-shaped record),
50
+ `@managed struct` (a GC-owned record with the same layout), `T[N]` inline
51
+ arrays, `@abi.alias` + `abiNameOf` (a field's C name, distinct from its
52
+ TensionScript name), `COPY_STRUCT`, and a C-compatible `sizeof` that includes
53
+ trailing padding. A `layout_hash` computed against the engine catches layout
54
+ drift when a session opens. See [showcase §1](docs/showcase.md) and
55
+ §2 for `@managed struct`.
56
+ - **Value types.** `@inline struct` gives a record value semantics: SROA locals,
57
+ copy on assignment, flattened (SROA) parameters, sret returns through a hidden
58
+ destination parameter, an `@external` argument temp, and an export-side byval
59
+ mirror. One-field records are refused at every boundary — the C/WASM tool
60
+ convention passes a one-scalar struct as the scalar itself, which would
61
+ disagree silently. See
62
+ [showcase §3](docs/showcase.md).
63
+ - **Memory-model overrides.** A *use* can name the model it wants
64
+ (`v: @inline Vec3`) while the declaration keeps its own. `@managed` ↔
65
+ `@unmanaged` is the free cell; `@inline` over a pointer declaration is the
66
+ boundary cell (import temp copy, export byval). Three cells are refused by
67
+ principle: a use cannot confer storage the value does not have. See
68
+ [showcase §4](docs/showcase.md).
69
+ - **Async/await.** `await` is the marker. The scheduler contract is
70
+ park / wake / resume with the task table owned by the guest; the shipped
71
+ implementation is the push path (the pull path was retired in 0.7.0).
72
+ Host-driven runtime tests cover it. See
73
+ [showcase §5](docs/showcase.md).
74
+ - **Closures.** Capture, a synthesized environment class, and `this`/environment
75
+ unification. The captured binding has exactly one home. `this` in an arrow
76
+ function resolves to the nearest enclosing non-arrow receiver — TypeScript's
77
+ rule. See [showcase §6](docs/showcase.md).
78
+ - **Lazy expressions.** `@lazy` defers an expression's evaluation to the binding's
79
+ first read, memoized. Three forms: `@lazy f()` (deferred, synchronous),
80
+ `@lazy await f()` (deferred, awaited at the read), and
81
+ `@lazy await spawn(f)` (launched at the declaration, joined at the read).
82
+ `spawn` is the eager primitive. See
83
+ [showcase §7](docs/showcase.md).
84
+ - **Bootstrap self-compile.** The compiler compiles its own source: 229 errors
85
+ down to 0, with the `.wast` fixpoint byte-identical across the stages.
86
+
87
+ ### What the fork deliberately shares
88
+
89
+ The divergence is bounded, and the sharing is a decision rather than an accident:
90
+ the **parser structure**, the **standard library's core**, and the **Binaryen
91
+ backend** are AssemblyScript's. Where the fork extends one of those, the extension
92
+ lands with fixtures — the `@lazy` prefix arm sits inside AS's expression dispatch,
93
+ the record layout builds on AS's `Type` machinery, and std gains
94
+ `task.ts`/`task-rt.ts` rather than replacing anything.
95
+
96
+ ## Differences from TypeScript
97
+
98
+ - **No exceptions.** `try`/`catch` is `AS100: Not implemented: Exceptions`.
99
+ - **No implicit `any`.** The type system is strict; a value has a type or the
100
+ program does not compile.
101
+ - **`async` is the scheduler's contract, not `Promise`'s.** There is no
102
+ microtask queue and no `Promise<T>`; an async call produces a `Task<T>`, and
103
+ awaiting it parks the current task until the host resumes it.
104
+ - **Structs are C-shaped, not TypeScript classes.** `@unmanaged struct` and
105
+ `@managed struct` have C layout and `sizeof`/`offsetof`; a class is a GC
106
+ reference, as in AssemblyScript.
107
+
108
+ ## Differences from AssemblyScript
109
+
110
+ The fork is a fork. The divergence is deliberate, it is bounded, and each change
111
+ lands with fixtures — see *What this fork adds* above for the list, and
112
+ [`docs/fork-posture.md`](docs/fork-posture.md) for the measurement that
113
+ established the posture. Features AssemblyScript cannot express — memory-model
114
+ overrides, the scheduler contract — are in scope here; a feature is not rejected
115
+ for lacking an AS equivalent.
116
+
117
+ ## What's next
118
+
119
+ [`docs/fork-posture.md`](docs/fork-posture.md) is the frame: what this fork is,
120
+ what it deliberately shares with AssemblyScript, what it diverges on, and the
121
+ quarterly sync cadence. [`docs/showcase.md`](docs/showcase.md) is the
122
+ per-capability reference — examples, semantics, and what each feature refuses.
123
+ [`docs/roadmap.md`](docs/roadmap.md) carries the deferred items, the durable
124
+ findings, and the workflow this repository uses. Deferred and named, each with
125
+ its reason there:
126
+
127
+ - **Inline nesting** — an `@inline struct` as a field of another record.
128
+ - **`T[N]` fields in `@inline struct`** — deep SROA, one local per element.
129
+ - **GC-reference fields in `@inline struct`** — an SROA'd field has no address,
130
+ and the write barrier needs one.
131
+ - **Closure capture of an `@inline` value** — needs inline nesting first.
132
+ - **`@external` return of `@inline struct`** — an ABI version.
133
+ - **SROA for top-level statics** — per-field globals, or a shadow slot.
134
+ - **`lazy-await-type-inference`** — lifting `@lazy await`'s declared-type
135
+ requirement (`TS6399`).
136
+
137
+ The full deferred list, with the reason for each, is
138
+ [showcase §9](docs/showcase.md) and [`docs/roadmap.md`](docs/roadmap.md).
139
+
140
+ ## Links
141
+
142
+ - Tension (the engine these guests run on): https://github.com/Yabgu/Tension
143
+ - TensionScript (this compiler): https://github.com/Yabgu/TensionScript
144
+ - Fork posture — what the fork is, what it shares, how it stays current:
145
+ [`docs/fork-posture.md`](docs/fork-posture.md)
146
+ - Roadmap — deferred features, durable findings, and the workflow:
147
+ [`docs/roadmap.md`](docs/roadmap.md)
148
+ - Scheduler contract: [`docs/scheduler-contract.md`](docs/scheduler-contract.md)
149
+ - Changelog: [`CHANGELOG.md`](CHANGELOG.md)
150
+
151
+ ## Attribution and license
152
+
153
+ Based on AssemblyScript, Apache-2.0 licensed. Original project at
154
+ https://github.com/AssemblyScript/assemblyscript.
155
+
156
+ The `NOTICE` file retains the original project's attribution, and the license is
157
+ the Apache License 2.0 (`LICENSE`).
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ const [ nodePath, thisPath, ...args ] = process.argv;
4
+ const nodeArgs = process.execArgv;
5
+
6
+ const hasSourceMaps = nodeArgs.includes("--enable-source-maps");
7
+ const posCustomArgs = args.indexOf("--");
8
+ const isDeno = typeof Deno !== "undefined";
9
+
10
+ if (isDeno) {
11
+ process.on = function() { /* suppress 'not implemented' message */ };
12
+ }
13
+
14
+ if ((!hasSourceMaps || ~posCustomArgs) && !isDeno) {
15
+ if (!hasSourceMaps) {
16
+ nodeArgs.push("--enable-source-maps");
17
+ }
18
+ if (~posCustomArgs) {
19
+ nodeArgs.push(...args.slice(posCustomArgs + 1));
20
+ args.length = posCustomArgs;
21
+ }
22
+ const { status, signal } = (await import("child_process")).spawnSync(
23
+ nodePath,
24
+ [...nodeArgs, thisPath, ...args],
25
+ { stdio: "inherit" }
26
+ );
27
+ if (status || signal) process.exitCode = 1;
28
+ } else {
29
+ const apiResult = (await import("../dist/asc.js")).main(process.argv.slice(2), {
30
+ stdout: process.stdout,
31
+ stderr: process.stderr
32
+ });
33
+ const { error } = await apiResult;
34
+ if (error) process.exitCode = 1;
35
+ }
package/dist/asc.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /// <reference path="./asc.generated.d.ts" />
2
+ export * from "types:tensionscript/cli/index";
3
+ import * as asc from "types:tensionscript/cli/index";
4
+ export default asc;