cella-lang 0.0.0-stage → 0.1.202610031357

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ Cella
2
+ Copyright 2026 SungYu Chang
3
+
4
+ This product includes software developed by SungYu Chang
5
+ (the Cella proof language: checker, standard library, and playground).
6
+
7
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
package/README.md CHANGED
@@ -1,3 +1,40 @@
1
- # Temporary Holding Version
1
+ # cella-lang
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
+ The **Cella** proof checker, compiled to WebAssembly — the same build that runs the
4
+ [Cella Playground](https://timcsy.github.io/cella-playground/). Runs in browsers and in Node (≥ 18).
5
+
6
+ Cella 證明檢查器的 WebAssembly 版本,與 playground 同一份建置。瀏覽器與 Node(18 以上)都能用。
7
+
8
+ ## Contents
9
+
10
+ | file | what |
11
+ |---|---|
12
+ | `cella.js`, `cella_bg.wasm` | the checker (wasm-bindgen, ES module) |
13
+ | `stdlib.cell` | the preloaded standard library (snapshot) |
14
+ | `modules/<name>.cell`, `modules/index.json` | importable library modules, loaded on `import` |
15
+
16
+ ## Two modes
17
+
18
+ ```js
19
+ import { readFileSync } from 'node:fs';
20
+ import init, { check, stdlib_mode, init_stdlib_cached, load_module_pack } from 'cella-lang';
21
+ import { assets } from 'cella-lang/assets';
22
+
23
+ await init({ module_or_path: readFileSync(assets.wasm) });
24
+
25
+ // 1. standalone — no stdlib: single file, no imports, nothing preloaded
26
+ stdlib_mode(); // "standalone"
27
+ check(source); // JSON verdict: {"ok", "verdict", "checker", "unknown", "assumptions", "errors"?}
28
+
29
+ // 2. preloaded — after loading the standard library (process-wide, cannot go back)
30
+ init_stdlib_cached(readFileSync(assets.stdlib));
31
+ stdlib_mode(); // "preloaded"
32
+ load_module_pack(readFileSync(assets.module('nat'))); // load `modules/index.json` deps first
33
+ check('import nat\n...');
34
+ ```
35
+
36
+ `checker.hash` in every verdict identifies the exact build; pin the package version.
37
+
38
+ ## License
39
+
40
+ Apache-2.0 — see `LICENSE` and `NOTICE`. Copyright 2026 SungYu Chang.
package/assets.js ADDED
@@ -0,0 +1,7 @@
1
+ // 套件裡資料檔的位置(Node:`fileURLToPath` 後 `readFileSync`;瀏覽器:直接 `fetch`)。
2
+ export const assets = {
3
+ wasm: new URL('./cella_bg.wasm', import.meta.url),
4
+ stdlib: new URL('./stdlib.cell', import.meta.url),
5
+ moduleIndex: new URL('./modules/index.json', import.meta.url),
6
+ module: (name) => new URL(`./modules/${name}.cell`, import.meta.url),
7
+ };
package/cella.d.ts ADDED
@@ -0,0 +1,116 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function check(source: string): string;
5
+
6
+ /**
7
+ * F335:把程式編成 WasmGC 模組(與 CLI 的 `run --wasm` 同一個後端),由瀏覽器執行(`main.js` 實作 `env.*` 匯入)。
8
+ * 失敗時丟出錯誤字串:檢查錯誤是 JSON(與 `check` 同形),執行不了的構造是 `{"refused":[…]}`。
9
+ */
10
+ export function compile_wasm(source: string): Uint8Array;
11
+
12
+ /**
13
+ * F319:游標處的證明目標(1 起算的行、列,字元)。回傳 `{"goals": 文字或 null}`。
14
+ */
15
+ export function goals_at(source: string, line: number, col: number): string;
16
+
17
+ /**
18
+ * F336:程式寫了哪些 `import`(JSON 字串陣列)——前端對照模組包清單(`modules/index.json`)決定要下載什麼。
19
+ */
20
+ export function imported_modules(source: string): string;
21
+
22
+ /**
23
+ * 從 `.cell` 快照載入 stdlib——playground 唯一的載入方式(wasm 不帶原始碼,沒有退路)。
24
+ *
25
+ * 失敗回 0:呼叫端要當成錯誤,不是「一個沒有定義的 stdlib」。
26
+ */
27
+ export function init_stdlib_cached(cache_bytes: Uint8Array): number;
28
+
29
+ /**
30
+ * F319:Inspect——使用者寫的每個定義展開成什麼(型別、elaborate 後的本體、資料值的正規形)。
31
+ */
32
+ export function inspect(source: string): string;
33
+
34
+ /**
35
+ * F336:把一個模組包疊到目前的 stdlib 上(依賴要先疊好),然後以疊好的 base 重新初始化。失敗回 0。
36
+ */
37
+ export function load_module_pack(pack: Uint8Array): number;
38
+
39
+ /**
40
+ * F322:檢查一次並回報各段耗時——瀏覽器裡找成本用。
41
+ */
42
+ export function profile_check(source: string): string;
43
+
44
+ /**
45
+ * Type check + NbE eval + IO execute.
46
+ * Uses NbE + io_runtime (not bytecode VM) — correct and fast.
47
+ */
48
+ export function run(source: string): string;
49
+
50
+ /**
51
+ * F321:elaborator 每條定義的步數上限(預設 10,000,000;0 不限)。打字路徑可以設得比批次檢查低,換一個更短的上界;
52
+ * 程式裡的 `set_option maxHeartbeats N in` 仍然優先。
53
+ */
54
+ export function set_max_heartbeats(n: number): void;
55
+
56
+ /**
57
+ * Set panic hook for better WASM error messages.
58
+ */
59
+ export function start(): void;
60
+
61
+ /**
62
+ * F338:`"standalone"`(沒有載入 stdlib:單檔檢查)或 `"preloaded"`(`init_stdlib_cached` 之後)。
63
+ */
64
+ export function stdlib_mode(): string;
65
+
66
+ /**
67
+ * F319:游標處的名字或運算式的型別。回傳 `{"expr": …, "type": …}`(沒有時都是 null)。
68
+ */
69
+ export function type_at(source: string, line: number, col: number): string;
70
+
71
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
72
+
73
+ export interface InitOutput {
74
+ readonly memory: WebAssembly.Memory;
75
+ readonly check: (a: number, b: number) => [number, number];
76
+ readonly compile_wasm: (a: number, b: number) => [number, number, number, number];
77
+ readonly goals_at: (a: number, b: number, c: number, d: number) => [number, number];
78
+ readonly imported_modules: (a: number, b: number) => [number, number];
79
+ readonly init_stdlib_cached: (a: number, b: number) => number;
80
+ readonly inspect: (a: number, b: number) => [number, number];
81
+ readonly load_module_pack: (a: number, b: number) => number;
82
+ readonly profile_check: (a: number, b: number) => [number, number];
83
+ readonly run: (a: number, b: number) => [number, number];
84
+ readonly set_max_heartbeats: (a: number) => void;
85
+ readonly start: () => void;
86
+ readonly stdlib_mode: () => [number, number];
87
+ readonly type_at: (a: number, b: number, c: number, d: number) => [number, number];
88
+ readonly __wbindgen_externrefs: WebAssembly.Table;
89
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
90
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
91
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
92
+ readonly __externref_table_dealloc: (a: number) => void;
93
+ readonly __wbindgen_start: () => void;
94
+ }
95
+
96
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
97
+
98
+ /**
99
+ * Instantiates the given `module`, which can either be bytes or
100
+ * a precompiled `WebAssembly.Module`.
101
+ *
102
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
103
+ *
104
+ * @returns {InitOutput}
105
+ */
106
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
107
+
108
+ /**
109
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
110
+ * for everything else, calls `WebAssembly.instantiate` directly.
111
+ *
112
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
113
+ *
114
+ * @returns {Promise<InitOutput>}
115
+ */
116
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/cella.js ADDED
@@ -0,0 +1,448 @@
1
+ /* @ts-self-types="./cella.d.ts" */
2
+
3
+ /**
4
+ * @param {string} source
5
+ * @returns {string}
6
+ */
7
+ export function check(source) {
8
+ let deferred2_0;
9
+ let deferred2_1;
10
+ try {
11
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
12
+ const len0 = WASM_VECTOR_LEN;
13
+ const ret = wasm.check(ptr0, len0);
14
+ deferred2_0 = ret[0];
15
+ deferred2_1 = ret[1];
16
+ return getStringFromWasm0(ret[0], ret[1]);
17
+ } finally {
18
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
19
+ }
20
+ }
21
+
22
+ /**
23
+ * F335:把程式編成 WasmGC 模組(與 CLI 的 `run --wasm` 同一個後端),由瀏覽器執行(`main.js` 實作 `env.*` 匯入)。
24
+ * 失敗時丟出錯誤字串:檢查錯誤是 JSON(與 `check` 同形),執行不了的構造是 `{"refused":[…]}`。
25
+ * @param {string} source
26
+ * @returns {Uint8Array}
27
+ */
28
+ export function compile_wasm(source) {
29
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
30
+ const len0 = WASM_VECTOR_LEN;
31
+ const ret = wasm.compile_wasm(ptr0, len0);
32
+ if (ret[3]) {
33
+ throw takeFromExternrefTable0(ret[2]);
34
+ }
35
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
36
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
37
+ return v2;
38
+ }
39
+
40
+ /**
41
+ * F319:游標處的證明目標(1 起算的行、列,字元)。回傳 `{"goals": 文字或 null}`。
42
+ * @param {string} source
43
+ * @param {number} line
44
+ * @param {number} col
45
+ * @returns {string}
46
+ */
47
+ export function goals_at(source, line, col) {
48
+ let deferred2_0;
49
+ let deferred2_1;
50
+ try {
51
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
52
+ const len0 = WASM_VECTOR_LEN;
53
+ const ret = wasm.goals_at(ptr0, len0, line, col);
54
+ deferred2_0 = ret[0];
55
+ deferred2_1 = ret[1];
56
+ return getStringFromWasm0(ret[0], ret[1]);
57
+ } finally {
58
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * F336:程式寫了哪些 `import`(JSON 字串陣列)——前端對照模組包清單(`modules/index.json`)決定要下載什麼。
64
+ * @param {string} source
65
+ * @returns {string}
66
+ */
67
+ export function imported_modules(source) {
68
+ let deferred2_0;
69
+ let deferred2_1;
70
+ try {
71
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ const ret = wasm.imported_modules(ptr0, len0);
74
+ deferred2_0 = ret[0];
75
+ deferred2_1 = ret[1];
76
+ return getStringFromWasm0(ret[0], ret[1]);
77
+ } finally {
78
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
79
+ }
80
+ }
81
+
82
+ /**
83
+ * 從 `.cell` 快照載入 stdlib——playground 唯一的載入方式(wasm 不帶原始碼,沒有退路)。
84
+ *
85
+ * 失敗回 0:呼叫端要當成錯誤,不是「一個沒有定義的 stdlib」。
86
+ * @param {Uint8Array} cache_bytes
87
+ * @returns {number}
88
+ */
89
+ export function init_stdlib_cached(cache_bytes) {
90
+ const ptr0 = passArray8ToWasm0(cache_bytes, wasm.__wbindgen_malloc);
91
+ const len0 = WASM_VECTOR_LEN;
92
+ const ret = wasm.init_stdlib_cached(ptr0, len0);
93
+ return ret >>> 0;
94
+ }
95
+
96
+ /**
97
+ * F319:Inspect——使用者寫的每個定義展開成什麼(型別、elaborate 後的本體、資料值的正規形)。
98
+ * @param {string} source
99
+ * @returns {string}
100
+ */
101
+ export function inspect(source) {
102
+ let deferred2_0;
103
+ let deferred2_1;
104
+ try {
105
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
106
+ const len0 = WASM_VECTOR_LEN;
107
+ const ret = wasm.inspect(ptr0, len0);
108
+ deferred2_0 = ret[0];
109
+ deferred2_1 = ret[1];
110
+ return getStringFromWasm0(ret[0], ret[1]);
111
+ } finally {
112
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
113
+ }
114
+ }
115
+
116
+ /**
117
+ * F336:把一個模組包疊到目前的 stdlib 上(依賴要先疊好),然後以疊好的 base 重新初始化。失敗回 0。
118
+ * @param {Uint8Array} pack
119
+ * @returns {number}
120
+ */
121
+ export function load_module_pack(pack) {
122
+ const ptr0 = passArray8ToWasm0(pack, wasm.__wbindgen_malloc);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ const ret = wasm.load_module_pack(ptr0, len0);
125
+ return ret >>> 0;
126
+ }
127
+
128
+ /**
129
+ * F322:檢查一次並回報各段耗時——瀏覽器裡找成本用。
130
+ * @param {string} source
131
+ * @returns {string}
132
+ */
133
+ export function profile_check(source) {
134
+ let deferred2_0;
135
+ let deferred2_1;
136
+ try {
137
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
138
+ const len0 = WASM_VECTOR_LEN;
139
+ const ret = wasm.profile_check(ptr0, len0);
140
+ deferred2_0 = ret[0];
141
+ deferred2_1 = ret[1];
142
+ return getStringFromWasm0(ret[0], ret[1]);
143
+ } finally {
144
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Type check + NbE eval + IO execute.
150
+ * Uses NbE + io_runtime (not bytecode VM) — correct and fast.
151
+ * @param {string} source
152
+ * @returns {string}
153
+ */
154
+ export function run(source) {
155
+ let deferred2_0;
156
+ let deferred2_1;
157
+ try {
158
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len0 = WASM_VECTOR_LEN;
160
+ const ret = wasm.run(ptr0, len0);
161
+ deferred2_0 = ret[0];
162
+ deferred2_1 = ret[1];
163
+ return getStringFromWasm0(ret[0], ret[1]);
164
+ } finally {
165
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
166
+ }
167
+ }
168
+
169
+ /**
170
+ * F321:elaborator 每條定義的步數上限(預設 10,000,000;0 不限)。打字路徑可以設得比批次檢查低,換一個更短的上界;
171
+ * 程式裡的 `set_option maxHeartbeats N in` 仍然優先。
172
+ * @param {number} n
173
+ */
174
+ export function set_max_heartbeats(n) {
175
+ wasm.set_max_heartbeats(n);
176
+ }
177
+
178
+ /**
179
+ * Set panic hook for better WASM error messages.
180
+ */
181
+ export function start() {
182
+ wasm.start();
183
+ }
184
+
185
+ /**
186
+ * F338:`"standalone"`(沒有載入 stdlib:單檔檢查)或 `"preloaded"`(`init_stdlib_cached` 之後)。
187
+ * @returns {string}
188
+ */
189
+ export function stdlib_mode() {
190
+ let deferred1_0;
191
+ let deferred1_1;
192
+ try {
193
+ const ret = wasm.stdlib_mode();
194
+ deferred1_0 = ret[0];
195
+ deferred1_1 = ret[1];
196
+ return getStringFromWasm0(ret[0], ret[1]);
197
+ } finally {
198
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
199
+ }
200
+ }
201
+
202
+ /**
203
+ * F319:游標處的名字或運算式的型別。回傳 `{"expr": …, "type": …}`(沒有時都是 null)。
204
+ * @param {string} source
205
+ * @param {number} line
206
+ * @param {number} col
207
+ * @returns {string}
208
+ */
209
+ export function type_at(source, line, col) {
210
+ let deferred2_0;
211
+ let deferred2_1;
212
+ try {
213
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
214
+ const len0 = WASM_VECTOR_LEN;
215
+ const ret = wasm.type_at(ptr0, len0, line, col);
216
+ deferred2_0 = ret[0];
217
+ deferred2_1 = ret[1];
218
+ return getStringFromWasm0(ret[0], ret[1]);
219
+ } finally {
220
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
221
+ }
222
+ }
223
+
224
+ function __wbg_get_imports() {
225
+ const import0 = {
226
+ __proto__: null,
227
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
228
+ throw new Error(getStringFromWasm0(arg0, arg1));
229
+ },
230
+ __wbg_error_38bec0a78dd8ded8: function(arg0) {
231
+ console.error(arg0);
232
+ },
233
+ __wbg_now_88621c9c9a4f3ffc: function() {
234
+ const ret = Date.now();
235
+ return ret;
236
+ },
237
+ __wbg_warn_2b0a27f629a4bb1e: function(arg0) {
238
+ console.warn(arg0);
239
+ },
240
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
241
+ // Cast intrinsic for `Ref(String) -> Externref`.
242
+ const ret = getStringFromWasm0(arg0, arg1);
243
+ return ret;
244
+ },
245
+ __wbindgen_init_externref_table: function() {
246
+ const table = wasm.__wbindgen_externrefs;
247
+ const offset = table.grow(4);
248
+ table.set(0, undefined);
249
+ table.set(offset + 0, undefined);
250
+ table.set(offset + 1, null);
251
+ table.set(offset + 2, true);
252
+ table.set(offset + 3, false);
253
+ },
254
+ };
255
+ return {
256
+ __proto__: null,
257
+ "./cella_bg.js": import0,
258
+ };
259
+ }
260
+
261
+ function getArrayU8FromWasm0(ptr, len) {
262
+ ptr = ptr >>> 0;
263
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
264
+ }
265
+
266
+ function getStringFromWasm0(ptr, len) {
267
+ ptr = ptr >>> 0;
268
+ return decodeText(ptr, len);
269
+ }
270
+
271
+ let cachedUint8ArrayMemory0 = null;
272
+ function getUint8ArrayMemory0() {
273
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
274
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
275
+ }
276
+ return cachedUint8ArrayMemory0;
277
+ }
278
+
279
+ function passArray8ToWasm0(arg, malloc) {
280
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
281
+ getUint8ArrayMemory0().set(arg, ptr / 1);
282
+ WASM_VECTOR_LEN = arg.length;
283
+ return ptr;
284
+ }
285
+
286
+ function passStringToWasm0(arg, malloc, realloc) {
287
+ if (realloc === undefined) {
288
+ const buf = cachedTextEncoder.encode(arg);
289
+ const ptr = malloc(buf.length, 1) >>> 0;
290
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
291
+ WASM_VECTOR_LEN = buf.length;
292
+ return ptr;
293
+ }
294
+
295
+ let len = arg.length;
296
+ let ptr = malloc(len, 1) >>> 0;
297
+
298
+ const mem = getUint8ArrayMemory0();
299
+
300
+ let offset = 0;
301
+
302
+ for (; offset < len; offset++) {
303
+ const code = arg.charCodeAt(offset);
304
+ if (code > 0x7F) break;
305
+ mem[ptr + offset] = code;
306
+ }
307
+ if (offset !== len) {
308
+ if (offset !== 0) {
309
+ arg = arg.slice(offset);
310
+ }
311
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
312
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
313
+ const ret = cachedTextEncoder.encodeInto(arg, view);
314
+
315
+ offset += ret.written;
316
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
317
+ }
318
+
319
+ WASM_VECTOR_LEN = offset;
320
+ return ptr;
321
+ }
322
+
323
+ function takeFromExternrefTable0(idx) {
324
+ const value = wasm.__wbindgen_externrefs.get(idx);
325
+ wasm.__externref_table_dealloc(idx);
326
+ return value;
327
+ }
328
+
329
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
330
+ cachedTextDecoder.decode();
331
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
332
+ let numBytesDecoded = 0;
333
+ function decodeText(ptr, len) {
334
+ numBytesDecoded += len;
335
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
336
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
337
+ cachedTextDecoder.decode();
338
+ numBytesDecoded = len;
339
+ }
340
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
341
+ }
342
+
343
+ const cachedTextEncoder = new TextEncoder();
344
+
345
+ if (!('encodeInto' in cachedTextEncoder)) {
346
+ cachedTextEncoder.encodeInto = function (arg, view) {
347
+ const buf = cachedTextEncoder.encode(arg);
348
+ view.set(buf);
349
+ return {
350
+ read: arg.length,
351
+ written: buf.length
352
+ };
353
+ };
354
+ }
355
+
356
+ let WASM_VECTOR_LEN = 0;
357
+
358
+ let wasmModule, wasm;
359
+ function __wbg_finalize_init(instance, module) {
360
+ wasm = instance.exports;
361
+ wasmModule = module;
362
+ cachedUint8ArrayMemory0 = null;
363
+ wasm.__wbindgen_start();
364
+ return wasm;
365
+ }
366
+
367
+ async function __wbg_load(module, imports) {
368
+ if (typeof Response === 'function' && module instanceof Response) {
369
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
370
+ try {
371
+ return await WebAssembly.instantiateStreaming(module, imports);
372
+ } catch (e) {
373
+ const validResponse = module.ok && expectedResponseType(module.type);
374
+
375
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
376
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
377
+
378
+ } else { throw e; }
379
+ }
380
+ }
381
+
382
+ const bytes = await module.arrayBuffer();
383
+ return await WebAssembly.instantiate(bytes, imports);
384
+ } else {
385
+ const instance = await WebAssembly.instantiate(module, imports);
386
+
387
+ if (instance instanceof WebAssembly.Instance) {
388
+ return { instance, module };
389
+ } else {
390
+ return instance;
391
+ }
392
+ }
393
+
394
+ function expectedResponseType(type) {
395
+ switch (type) {
396
+ case 'basic': case 'cors': case 'default': return true;
397
+ }
398
+ return false;
399
+ }
400
+ }
401
+
402
+ function initSync(module) {
403
+ if (wasm !== undefined) return wasm;
404
+
405
+
406
+ if (module !== undefined) {
407
+ if (Object.getPrototypeOf(module) === Object.prototype) {
408
+ ({module} = module)
409
+ } else {
410
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
411
+ }
412
+ }
413
+
414
+ const imports = __wbg_get_imports();
415
+ if (!(module instanceof WebAssembly.Module)) {
416
+ module = new WebAssembly.Module(module);
417
+ }
418
+ const instance = new WebAssembly.Instance(module, imports);
419
+ return __wbg_finalize_init(instance, module);
420
+ }
421
+
422
+ async function __wbg_init(module_or_path) {
423
+ if (wasm !== undefined) return wasm;
424
+
425
+
426
+ if (module_or_path !== undefined) {
427
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
428
+ ({module_or_path} = module_or_path)
429
+ } else {
430
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
431
+ }
432
+ }
433
+
434
+ if (module_or_path === undefined) {
435
+ module_or_path = new URL('cella_bg.wasm', import.meta.url);
436
+ }
437
+ const imports = __wbg_get_imports();
438
+
439
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
440
+ module_or_path = fetch(module_or_path);
441
+ }
442
+
443
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
444
+
445
+ return __wbg_finalize_init(instance, module);
446
+ }
447
+
448
+ export { initSync, __wbg_init as default };
package/cella_bg.wasm ADDED
Binary file
@@ -0,0 +1,22 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const check: (a: number, b: number) => [number, number];
5
+ export const compile_wasm: (a: number, b: number) => [number, number, number, number];
6
+ export const goals_at: (a: number, b: number, c: number, d: number) => [number, number];
7
+ export const imported_modules: (a: number, b: number) => [number, number];
8
+ export const init_stdlib_cached: (a: number, b: number) => number;
9
+ export const inspect: (a: number, b: number) => [number, number];
10
+ export const load_module_pack: (a: number, b: number) => number;
11
+ export const profile_check: (a: number, b: number) => [number, number];
12
+ export const run: (a: number, b: number) => [number, number];
13
+ export const set_max_heartbeats: (a: number) => void;
14
+ export const start: () => void;
15
+ export const stdlib_mode: () => [number, number];
16
+ export const type_at: (a: number, b: number, c: number, d: number) => [number, number];
17
+ export const __wbindgen_externrefs: WebAssembly.Table;
18
+ export const __wbindgen_malloc: (a: number, b: number) => number;
19
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
20
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
21
+ export const __externref_table_dealloc: (a: number) => void;
22
+ export const __wbindgen_start: () => void;
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,30 @@
1
+ {
2
+ "source_hash": "a76edb069b4e94bc3cdc157b3c52edb9d09b57b80c258e511cdc35bf10dc34e4",
3
+ "modules": {
4
+ "algebra": {"deps": ["int", "nat", "ring", "algebra"], "bytes": 2357338},
5
+ "decidable": {"deps": ["decidable"], "bytes": 1108233},
6
+ "either": {"deps": ["either"], "bytes": 914084},
7
+ "fin": {"deps": ["fin"], "bytes": 747877},
8
+ "function": {"deps": ["function"], "bytes": 278382},
9
+ "functor": {"deps": ["functor"], "bytes": 579273},
10
+ "int": {"deps": ["int"], "bytes": 4167807},
11
+ "intlinarith": {"deps": ["nat", "ring", "int", "intring", "linarith", "intlinarith"], "bytes": 1841737},
12
+ "intomega": {"deps": ["nat", "ring", "linarith", "omega", "int", "intring", "intlinarith", "intomega"], "bytes": 1485430},
13
+ "intring": {"deps": ["nat", "ring", "int", "intring"], "bytes": 2230387},
14
+ "linarith": {"deps": ["nat", "ring", "linarith"], "bytes": 1014602},
15
+ "linsys": {"deps": ["nat", "ring", "int", "intring", "linsys"], "bytes": 1654052},
16
+ "list": {"deps": ["list"], "bytes": 2687934},
17
+ "monad": {"deps": ["functor", "monad"], "bytes": 614947},
18
+ "nat": {"deps": ["nat"], "bytes": 3788544},
19
+ "omega": {"deps": ["nat", "ring", "linarith", "omega"], "bytes": 957099},
20
+ "option": {"deps": ["option"], "bytes": 931288},
21
+ "ordering": {"deps": ["decidable", "int", "ordering"], "bytes": 1766263},
22
+ "polyrith": {"deps": ["nat", "ring", "int", "intring", "linarith", "intlinarith", "polyrith"], "bytes": 1430337},
23
+ "prod": {"deps": ["prod"], "bytes": 579741},
24
+ "ring": {"deps": ["nat", "ring"], "bytes": 943710},
25
+ "sigma": {"deps": ["sigma"], "bytes": 231673},
26
+ "tree": {"deps": ["tree"], "bytes": 1117346},
27
+ "unit": {"deps": ["unit"], "bytes": 229443},
28
+ "vector": {"deps": ["fin", "vector"], "bytes": 995991}
29
+ }
30
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,21 @@
1
1
  {
2
2
  "name": "cella-lang",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.202610031357",
4
+ "description": "The Cella proof checker (cubical type theory with QTT) compiled to WebAssembly — browsers and Node.",
5
+ "type": "module",
6
+ "main": "cella.js",
7
+ "types": "cella.d.ts",
8
+ "exports": {
9
+ ".": { "types": "./cella.d.ts", "default": "./cella.js" },
10
+ "./assets": "./assets.js",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": ["cella.js", "cella_bg.wasm", "cella.d.ts", "cella_bg.wasm.d.ts",
14
+ "stdlib.cell", "modules/", "assets.js", "README.md", "LICENSE", "NOTICE"],
15
+ "keywords": ["cella", "proof", "type-theory", "cubical", "wasm", "theorem-prover"],
16
+ "homepage": "https://timcsy.github.io/cella-playground/",
17
+ "license": "Apache-2.0",
18
+ "author": "SungYu Chang",
19
+ "engines": { "node": ">=18" },
20
+ "cella": { "checkerHash": "530d4c8770e21ad8" }
21
+ }
package/stdlib.cell ADDED
Binary file