@astrojs/compiler 0.0.0-compact-20231220212312
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 +53 -0
- package/README.md +66 -0
- package/dist/astro.wasm +0 -0
- package/dist/browser/index.cjs +2 -0
- package/dist/browser/index.d.ts +11 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/utils.cjs +3 -0
- package/dist/browser/utils.d.ts +30 -0
- package/dist/browser/utils.js +3 -0
- package/dist/browser/wasm_exec.cjs +2 -0
- package/dist/browser/wasm_exec.d.ts +37 -0
- package/dist/browser/wasm_exec.js +1 -0
- package/dist/chunk-GFDH6LQW.js +1 -0
- package/dist/chunk-XZNZIE5X.js +2 -0
- package/dist/node/index.cjs +1 -0
- package/dist/node/index.d.ts +12 -0
- package/dist/node/index.js +1 -0
- package/dist/node/sync.cjs +1 -0
- package/dist/node/sync.d.ts +16 -0
- package/dist/node/sync.js +1 -0
- package/dist/node/utils.cjs +3 -0
- package/dist/node/utils.d.ts +30 -0
- package/dist/node/utils.js +3 -0
- package/dist/node/wasm_exec.cjs +1 -0
- package/dist/node/wasm_exec.d.ts +37 -0
- package/dist/node/wasm_exec.js +1 -0
- package/dist/shared/ast.cjs +1 -0
- package/dist/shared/ast.d.ts +74 -0
- package/dist/shared/ast.js +0 -0
- package/dist/shared/diagnostics.cjs +1 -0
- package/dist/shared/diagnostics.d.ts +18 -0
- package/dist/shared/diagnostics.js +1 -0
- package/dist/shared/types.cjs +1 -0
- package/dist/shared/types.d.ts +117 -0
- package/dist/shared/types.js +1 -0
- package/package.json +58 -0
- package/sync.d.ts +1 -0
- package/types.d.ts +1 -0
- package/utils.d.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 [Astro contributors](https://github.com/withastro/compiler/graphs/contributors)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
This license applies to parts of the `internal/` subdirectory originating from
|
|
25
|
+
the https://cs.opensource.google/go/x/net/+/master:html/ repository:
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2009 The Go Authors. All rights reserved.
|
|
28
|
+
|
|
29
|
+
Redistribution and use in source and binary forms, with or without
|
|
30
|
+
modification, are permitted provided that the following conditions are
|
|
31
|
+
met:
|
|
32
|
+
|
|
33
|
+
* Redistributions of source code must retain the above copyright
|
|
34
|
+
notice, this list of conditions and the following disclaimer.
|
|
35
|
+
* Redistributions in binary form must reproduce the above
|
|
36
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
37
|
+
in the documentation and/or other materials provided with the
|
|
38
|
+
distribution.
|
|
39
|
+
* Neither the name of Google Inc. nor the names of its
|
|
40
|
+
contributors may be used to endorse or promote products derived from
|
|
41
|
+
this software without specific prior written permission.
|
|
42
|
+
|
|
43
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
44
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
45
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
46
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
47
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
48
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
49
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
50
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
51
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
52
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
53
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Astro Compiler
|
|
2
|
+
|
|
3
|
+
Astro’s [Go](https://golang.org/) + WASM compiler.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @astrojs/compiler
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
#### Transform `.astro` to valid TypeScript
|
|
14
|
+
|
|
15
|
+
The Astro compiler can convert `.astro` syntax to a TypeScript Module whose default export generates HTML.
|
|
16
|
+
|
|
17
|
+
**Some notes**...
|
|
18
|
+
|
|
19
|
+
- TypeScript is valid `.astro` syntax! The output code may need an additional post-processing step to generate valid JavaScript.
|
|
20
|
+
- `.astro` files rely on a server implementation exposed as `astro/runtime/server/index.js` in the Node ecosystem. Other runtimes currently need to bring their own rendering implementation and reference it via `internalURL`. This is a pain point we're looking into fixing.
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { transform } from '@astrojs/compiler';
|
|
24
|
+
|
|
25
|
+
const result = await transform(source, {
|
|
26
|
+
filename: '/Users/astro/Code/project/src/pages/index.astro',
|
|
27
|
+
sourcemap: 'both',
|
|
28
|
+
internalURL: 'astro/runtime/server/index.js',
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Parse `.astro` and return an AST
|
|
33
|
+
|
|
34
|
+
The Astro compiler can emit an AST using the `parse` method.
|
|
35
|
+
|
|
36
|
+
**Some notes**...
|
|
37
|
+
|
|
38
|
+
- Position data is currently incomplete and in some cases incorrect. We're working on it!
|
|
39
|
+
- A `TextNode` can represent both HTML `text` and JavaScript/TypeScript source code.
|
|
40
|
+
- The `@astrojs/compiler/utils` entrypoint exposes a `walk` function that can be used to traverse the AST. It also exposes the `is` helper which can be used as guards to derive the proper types for each `node`.
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { parse } from '@astrojs/compiler';
|
|
44
|
+
import { walk, is } from '@astrojs/compiler/utils';
|
|
45
|
+
|
|
46
|
+
const result = await parse(source, {
|
|
47
|
+
position: false, // defaults to `true`
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
walk(result.ast, (node) => {
|
|
51
|
+
// `tag` nodes are `element` | `custom-element` | `component`
|
|
52
|
+
if (is.tag(node)) {
|
|
53
|
+
console.log(node.name);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Develop
|
|
59
|
+
|
|
60
|
+
### VSCode / CodeSpaces
|
|
61
|
+
|
|
62
|
+
A `devcontainer` configuration is available for use with VSCode's [Remote Development extension pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) and GitHub CodeSpaces.
|
|
63
|
+
|
|
64
|
+
## Contributing
|
|
65
|
+
|
|
66
|
+
[CONTRIBUTING.md](/CONTRIBUTING.md)
|
package/dist/astro.wasm
ADDED
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var j=(i,s)=>{for(var n in s)p(i,n,{get:s[n],enumerable:!0})},I=(i,s,n,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of U(s))!R.call(i,o)&&o!==n&&p(i,o,{get:()=>s[o],enumerable:!(r=S(s,o))||r.enumerable});return i};var P=i=>I(p({},"__esModule",{value:!0}),i);var L={};j(L,{convertToTSX:()=>C,initialize:()=>N,parse:()=>O,teardown:()=>D,transform:()=>k});module.exports=P(L);var l=()=>{let i=new Error("not implemented");return i.code="ENOSYS",i},y="",x={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){y+=T.decode(s);let n=y.lastIndexOf(`
|
|
2
|
+
`);return n!=-1&&(console.log(y.substr(0,n)),y=y.substr(n+1)),s.length},write(i,s,n,r,o,h){if(n!==0||r!==s.length||o!==null){h(l());return}let u=this.writeSync(i,s);h(null,u)},chmod(i,s,n){n(l())},chown(i,s,n,r){r(l())},close(i,s){s(l())},fchmod(i,s,n){n(l())},fchown(i,s,n,r){r(l())},fstat(i,s){s(l())},fsync(i,s){s(null)},ftruncate(i,s,n){n(l())},lchown(i,s,n,r){r(l())},link(i,s,n){n(l())},lstat(i,s){s(l())},mkdir(i,s,n){n(l())},open(i,s,n,r){r(l())},read(i,s,n,r,o,h){h(l())},readdir(i,s){s(l())},readlink(i,s){s(l())},rename(i,s,n){n(l())},rmdir(i,s){s(l())},stat(i,s){s(l())},symlink(i,s,n){n(l())},truncate(i,s,n){n(l())},unlink(i,s){s(l())},utimes(i,s,n,r){r(l())}},A={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw l()},pid:-1,ppid:-1,umask(){throw l()},cwd(){throw l()},chdir(){throw l()}};Object.defineProperties(globalThis,{fs:{value:x,enumerable:!0},process:{value:A,enumerable:!0}});var b=new TextEncoder("utf-8"),T=new TextDecoder("utf-8");var w=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let s=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},n=e=>{let t=this.mem.getUint32(e+0,!0),a=this.mem.getInt32(e+4,!0);return t+a*4294967296},r=e=>{let t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;let a=this.mem.getUint32(e,!0);return this._values[a]},o=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let c=this._ids.get(t);c===void 0&&(c=this._idPool.pop(),c===void 0&&(c=this._values.length),this._values[c]=t,this._goRefCounts[c]=0,this._ids.set(t,c)),this._goRefCounts[c]++;let m=0;switch(typeof t){case"object":t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,2146959360|m,!0),this.mem.setUint32(e,c,!0)},h=e=>{let t=n(e+0),a=n(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,a)},u=e=>{let t=n(e+0),a=n(e+8),c=new Array(a);for(let m=0;m<a;m++)c[m]=r(t+m*8);return c},d=e=>{let t=n(e+0),a=n(e+8);return T.decode(new DataView(this._inst.exports.mem.buffer,t,a))},f=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;let t=n(e+8),a=n(e+16),c=this.mem.getInt32(e+24,!0);x.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,a,c))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,s(e+8,(f+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;let t=new Date().getTime();s(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;let t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},n(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,globalThis.crypto.getRandomValues(h(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;let t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){let a=this._values[t];this._values[t]=null,this._ids.delete(a),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,o(e+24,d(e+8))},"syscall/js.valueGet":e=>{e>>>=0;let t=Reflect.get(r(e+8),d(e+16));e=this._inst.exports.getsp()>>>0,o(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(r(e+8),d(e+16),r(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(r(e+8),d(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,o(e+24,Reflect.get(r(e+8),n(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(r(e+8),n(e+16),r(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{let t=r(e+8),a=Reflect.get(t,d(e+16)),c=u(e+32),m=Reflect.apply(a,t,c);e=this._inst.exports.getsp()>>>0,o(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,o(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{let t=r(e+8),a=u(e+16),c=Reflect.apply(t,void 0,a);e=this._inst.exports.getsp()>>>0,o(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{let t=r(e+8),a=u(e+16),c=Reflect.construct(t,a);e=this._inst.exports.getsp()>>>0,o(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,s(e+16,parseInt(r(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;let t=b.encode(String(r(e+8)));o(e+16,t),s(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;let t=r(e+8);h(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,r(e+8)instanceof r(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;let t=h(e+8),a=r(e+32);if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let c=a.subarray(0,t.length);t.set(c),s(e+40,c.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;let t=r(e+8),a=h(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let c=a.subarray(0,t.length);t.set(c),s(e+40,c.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(s){if(!(s instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=s,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let n=4096,r=f=>{let e=n,t=b.encode(f+"\0");return new Uint8Array(this.mem.buffer,n,t.length).set(t),n+=t.length,n%8!==0&&(n+=8-n%8),e},o=this.argv.length,h=[];this.argv.forEach(f=>{h.push(r(f))}),h.push(0),Object.keys(this.env).sort().forEach(f=>{h.push(r(`${f}=${this.env[f]}`))}),h.push(0);let d=n;h.forEach(f=>{this.mem.setUint32(n,f,!0),this.mem.setUint32(n+4,0,!0),n+=8}),this._inst.exports.run(o,d),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(s){let n=this;return function(){let r={id:s,this:this,args:arguments};return n._pendingEvent=r,n._resume(),r.result}}};var k=(i,s)=>v().transform(i,s),O=(i,s)=>v().parse(i,s),C=(i,s)=>v().convertToTSX(i,s),g,_,D=()=>{g=void 0,_=void 0,globalThis["@astrojs/compiler"]=void 0},N=async i=>{let s=i.wasmURL;if(!s)throw new Error('Must provide the "wasmURL" option');s+="",g||(g=V(s).catch(n=>{throw g=void 0,n})),_=_||await g},v=()=>{if(!g)throw new Error('You need to call "initialize" before calling this');if(!_)throw new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this');return _},W=async(i,s)=>{let n;return WebAssembly.instantiateStreaming?n=await WebAssembly.instantiateStreaming(fetch(i),s):n=await(async()=>{let o=await fetch(i).then(h=>h.arrayBuffer());return WebAssembly.instantiate(o,s)})(),n},V=async i=>{let s=new w,n=await W(i,s.importObject);s.run(n.instance);let r=globalThis["@astrojs/compiler"];return{transform:(o,h)=>new Promise(u=>u(r.transform(o,h||{}))),convertToTSX:(o,h)=>new Promise(u=>u(r.convertToTSX(o,h||{}))).then(u=>({...u,map:JSON.parse(u.map)})),parse:(o,h)=>new Promise(u=>u(r.parse(o,h||{}))).then(u=>({...u,ast:JSON.parse(u.ast)}))}};0&&(module.exports={convertToTSX,initialize,parse,teardown,transform});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { transform as transform$1, parse as parse$1, convertToTSX as convertToTSX$1, teardown as teardown$1, initialize as initialize$1 } from '../shared/types.js';
|
|
2
|
+
import '../shared/ast.js';
|
|
3
|
+
import '../shared/diagnostics.js';
|
|
4
|
+
|
|
5
|
+
declare const transform: typeof transform$1;
|
|
6
|
+
declare const parse: typeof parse$1;
|
|
7
|
+
declare const convertToTSX: typeof convertToTSX$1;
|
|
8
|
+
declare const teardown: typeof teardown$1;
|
|
9
|
+
declare const initialize: typeof initialize$1;
|
|
10
|
+
|
|
11
|
+
export { convertToTSX, initialize, parse, teardown, transform };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"../chunk-XZNZIE5X.js";var u=(t,e)=>p().transform(t,e),S=(t,e)=>p().parse(t,e),v=(t,e)=>p().convertToTSX(t,e),a,i,h=()=>{a=void 0,i=void 0,globalThis["@astrojs/compiler"]=void 0},T=async t=>{let e=t.wasmURL;if(!e)throw new Error('Must provide the "wasmURL" option');e+="",a||(a=m(e).catch(n=>{throw a=void 0,n})),i=i||await a},p=()=>{if(!a)throw new Error('You need to call "initialize" before calling this');if(!i)throw new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this');return i},y=async(t,e)=>{let n;return WebAssembly.instantiateStreaming?n=await WebAssembly.instantiateStreaming(fetch(t),e):n=await(async()=>{let s=await fetch(t).then(o=>o.arrayBuffer());return WebAssembly.instantiate(s,e)})(),n},m=async t=>{let e=new f,n=await y(t,e.importObject);e.run(n.instance);let c=globalThis["@astrojs/compiler"];return{transform:(s,o)=>new Promise(r=>r(c.transform(s,o||{}))),convertToTSX:(s,o)=>new Promise(r=>r(c.convertToTSX(s,o||{}))).then(r=>({...r,map:JSON.parse(r.map)})),parse:(s,o)=>new Promise(r=>r(c.parse(s,o||{}))).then(r=>({...r,ast:JSON.parse(r.ast)}))}};export{v as convertToTSX,T as initialize,S as parse,h as teardown,u as transform};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)l(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!N.call(o,r)&&r!==t&&l(o,r,{get:()=>e[r],enumerable:!(n=d(e,r))||n.enumerable});return o};var h=o=>f(l({},"__esModule",{value:!0}),o);var v={};u(v,{is:()=>s,serialize:()=>g,walk:()=>y});module.exports=h(v);function i(o){return e=>e.type===o}var s={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:i("root"),element:i("element"),customElement:i("custom-element"),component:i("component"),fragment:i("fragment"),expression:i("expression"),text:i("text"),doctype:i("doctype"),comment:i("comment"),frontmatter:i("frontmatter")},m=class{constructor(e){this.callback=e}async visit(e,t,n){if(await this.callback(e,t,n),s.parent(e)){let r=[];for(let a=0;a<e.children.length;a++){let c=e.children[a];r.push(this.callback(c,e,a))}await Promise.all(r)}}};function y(o,e){new m(e).visit(o)}function x(o){let e="";for(let t of o.attributes)switch(e+=" ",t.kind){case"empty":{e+=`${t.name}`;break}case"expression":{e+=`${t.name}={${t.value}}`;break}case"quoted":{e+=`${t.name}=${t.raw}`;break}case"template-literal":{e+=`${t.name}=\`${t.value}\``;break}case"shorthand":{e+=`{${t.name}}`;break}case"spread":{e+=`{...${t.value}}`;break}}return e}function g(o,e={selfClose:!0}){let t="";function n(r){s.root(r)?r.children.forEach(a=>n(a)):s.frontmatter(r)?t+=`---${r.value}---
|
|
2
|
+
|
|
3
|
+
`:s.comment(r)?t+=`<!--${r.value}-->`:s.expression(r)?(t+="{",r.children.forEach(a=>n(a)),t+="}"):s.literal(r)?t+=r.value:s.tag(r)&&(t+=`<${r.name}`,t+=x(r),r.children.length==0&&e.selfClose?t+=" />":(t+=">",r.children.forEach(a=>n(a)),t+=`</${r.name}>`))}return n(o),t}0&&(module.exports={is,serialize,walk});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Node, ParentNode, LiteralNode, TagLikeNode, TextNode, RootNode, ElementNode, CustomElementNode, ComponentNode, FragmentNode, ExpressionNode, DoctypeNode, CommentNode, FrontmatterNode } from '../shared/ast.js';
|
|
2
|
+
|
|
3
|
+
interface Visitor {
|
|
4
|
+
(node: Node, parent?: ParentNode, index?: number): void | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
declare const is: {
|
|
7
|
+
parent(node: Node): node is ParentNode;
|
|
8
|
+
literal(node: Node): node is LiteralNode;
|
|
9
|
+
tag(node: Node): node is TagLikeNode;
|
|
10
|
+
whitespace(node: Node): node is TextNode;
|
|
11
|
+
root: (node: Node) => node is RootNode;
|
|
12
|
+
element: (node: Node) => node is ElementNode;
|
|
13
|
+
customElement: (node: Node) => node is CustomElementNode;
|
|
14
|
+
component: (node: Node) => node is ComponentNode;
|
|
15
|
+
fragment: (node: Node) => node is FragmentNode;
|
|
16
|
+
expression: (node: Node) => node is ExpressionNode;
|
|
17
|
+
text: (node: Node) => node is TextNode;
|
|
18
|
+
doctype: (node: Node) => node is DoctypeNode;
|
|
19
|
+
comment: (node: Node) => node is CommentNode;
|
|
20
|
+
frontmatter: (node: Node) => node is FrontmatterNode;
|
|
21
|
+
};
|
|
22
|
+
declare function walk(node: ParentNode, callback: Visitor): void;
|
|
23
|
+
interface SerializeOptions {
|
|
24
|
+
selfClose: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** @deprecated Please use `SerializeOptions` */
|
|
27
|
+
type SerializeOtions = SerializeOptions;
|
|
28
|
+
declare function serialize(root: Node, opts?: SerializeOptions): string;
|
|
29
|
+
|
|
30
|
+
export { SerializeOptions, SerializeOtions, Visitor, is, serialize, walk };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function i(o){return t=>t.type===o}var n={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:i("root"),element:i("element"),customElement:i("custom-element"),component:i("component"),fragment:i("fragment"),expression:i("expression"),text:i("text"),doctype:i("doctype"),comment:i("comment"),frontmatter:i("frontmatter")},l=class{constructor(t){this.callback=t}async visit(t,e,s){if(await this.callback(t,e,s),n.parent(t)){let r=[];for(let a=0;a<t.children.length;a++){let m=t.children[a];r.push(this.callback(m,t,a))}await Promise.all(r)}}};function N(o,t){new l(t).visit(o)}function c(o){let t="";for(let e of o.attributes)switch(t+=" ",e.kind){case"empty":{t+=`${e.name}`;break}case"expression":{t+=`${e.name}={${e.value}}`;break}case"quoted":{t+=`${e.name}=${e.raw}`;break}case"template-literal":{t+=`${e.name}=\`${e.value}\``;break}case"shorthand":{t+=`{${e.name}}`;break}case"spread":{t+=`{...${e.value}}`;break}}return t}function u(o,t={selfClose:!0}){let e="";function s(r){n.root(r)?r.children.forEach(a=>s(a)):n.frontmatter(r)?e+=`---${r.value}---
|
|
2
|
+
|
|
3
|
+
`:n.comment(r)?e+=`<!--${r.value}-->`:n.expression(r)?(e+="{",r.children.forEach(a=>s(a)),e+="}"):n.literal(r)?e+=r.value:n.tag(r)&&(e+=`<${r.name}`,e+=c(r),r.children.length==0&&t.selfClose?e+=" />":(e+=">",r.children.forEach(a=>s(a)),e+=`</${r.name}>`))}return s(o),e}export{n as is,u as serialize,N as walk};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var R=(r,s)=>{for(var n in s)y(r,n,{get:s[n],enumerable:!0})},j=(r,s,n,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let h of U(s))!T.call(r,h)&&h!==n&&y(r,h,{get:()=>s[h],enumerable:!(i=b(s,h))||i.enumerable});return r};var E=r=>j(y({},"__esModule",{value:!0}),r);var k={};R(k,{default:()=>_});module.exports=E(k);var l=()=>{let r=new Error("not implemented");return r.code="ENOSYS",r},g="",x={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(r,s){g+=v.decode(s);let n=g.lastIndexOf(`
|
|
2
|
+
`);return n!=-1&&(console.log(g.substr(0,n)),g=g.substr(n+1)),s.length},write(r,s,n,i,h,c){if(n!==0||i!==s.length||h!==null){c(l());return}let d=this.writeSync(r,s);c(null,d)},chmod(r,s,n){n(l())},chown(r,s,n,i){i(l())},close(r,s){s(l())},fchmod(r,s,n){n(l())},fchown(r,s,n,i){i(l())},fstat(r,s){s(l())},fsync(r,s){s(null)},ftruncate(r,s,n){n(l())},lchown(r,s,n,i){i(l())},link(r,s,n){n(l())},lstat(r,s){s(l())},mkdir(r,s,n){n(l())},open(r,s,n,i){i(l())},read(r,s,n,i,h,c){c(l())},readdir(r,s){s(l())},readlink(r,s){s(l())},rename(r,s,n){n(l())},rmdir(r,s){s(l())},stat(r,s){s(l())},symlink(r,s,n){n(l())},truncate(r,s,n){n(l())},unlink(r,s){s(l())},utimes(r,s,n,i){i(l())}},I={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw l()},pid:-1,ppid:-1,umask(){throw l()},cwd(){throw l()},chdir(){throw l()}};Object.defineProperties(globalThis,{fs:{value:x,enumerable:!0},process:{value:I,enumerable:!0}});var w=new TextEncoder("utf-8"),v=new TextDecoder("utf-8");var _=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let s=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},n=t=>{let e=this.mem.getUint32(t+0,!0),o=this.mem.getInt32(t+4,!0);return e+o*4294967296},i=t=>{let e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;let o=this.mem.getUint32(t,!0);return this._values[o]},h=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let a=this._ids.get(e);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=e,this._goRefCounts[a]=0,this._ids.set(e,a)),this._goRefCounts[a]++;let u=0;switch(typeof e){case"object":e!==null&&(u=1);break;case"string":u=2;break;case"symbol":u=3;break;case"function":u=4;break}this.mem.setUint32(t+4,2146959360|u,!0),this.mem.setUint32(t,a,!0)},c=t=>{let e=n(t+0),o=n(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,o)},d=t=>{let e=n(t+0),o=n(t+8),a=new Array(o);for(let u=0;u<o;u++)a[u]=i(e+u*8);return a},f=t=>{let e=n(t+0),o=n(t+8);return v.decode(new DataView(this._inst.exports.mem.buffer,e,o))},m=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":t=>{t>>>=0;let e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;let e=n(t+8),o=n(t+16),a=this.mem.getInt32(t+24,!0);x.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,o,a))},"runtime.resetMemoryDataView":t=>{t>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,s(t+8,(m+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;let e=new Date().getTime();s(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;let e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},n(t+8)+1)),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;let e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,globalThis.crypto.getRandomValues(c(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;let e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){let o=this._values[e];this._values[e]=null,this._ids.delete(o),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,h(t+24,f(t+8))},"syscall/js.valueGet":t=>{t>>>=0;let e=Reflect.get(i(t+8),f(t+16));t=this._inst.exports.getsp()>>>0,h(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(i(t+8),f(t+16),i(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(i(t+8),f(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,h(t+24,Reflect.get(i(t+8),n(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(i(t+8),n(t+16),i(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{let e=i(t+8),o=Reflect.get(e,f(t+16)),a=d(t+32),u=Reflect.apply(o,e,a);t=this._inst.exports.getsp()>>>0,h(t+56,u),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,h(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{let e=i(t+8),o=d(t+16),a=Reflect.apply(e,void 0,o);t=this._inst.exports.getsp()>>>0,h(t+40,a),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,h(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{let e=i(t+8),o=d(t+16),a=Reflect.construct(e,o);t=this._inst.exports.getsp()>>>0,h(t+40,a),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,h(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,s(t+16,parseInt(i(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;let e=w.encode(String(i(t+8)));h(t+16,e),s(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;let e=i(t+8);c(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,i(t+8)instanceof i(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;let e=c(t+8),o=i(t+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}let a=o.subarray(0,e.length);e.set(a),s(t+40,a.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;let e=i(t+8),o=c(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}let a=o.subarray(0,e.length);e.set(a),s(t+40,a.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(s){if(!(s instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=s,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let n=4096,i=m=>{let t=n,e=w.encode(m+"\0");return new Uint8Array(this.mem.buffer,n,e.length).set(e),n+=e.length,n%8!==0&&(n+=8-n%8),t},h=this.argv.length,c=[];this.argv.forEach(m=>{c.push(i(m))}),c.push(0),Object.keys(this.env).sort().forEach(m=>{c.push(i(`${m}=${this.env[m]}`))}),c.push(0);let f=n;c.forEach(m=>{this.mem.setUint32(n,m,!0),this.mem.setUint32(n+4,0,!0),n+=8}),this._inst.exports.run(h,f),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(s){let n=this;return function(){let i={id:s,this:this,args:arguments};return n._pendingEvent=i,n._resume(),i.result}}};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare class Go {
|
|
2
|
+
importObject: {
|
|
3
|
+
go: {
|
|
4
|
+
'runtime.wasmExit': (sp: any) => void;
|
|
5
|
+
'runtime.wasmWrite': (sp: any) => void;
|
|
6
|
+
'runtime.resetMemoryDataView': (sp: any) => void;
|
|
7
|
+
'runtime.nanotime1': (sp: any) => void;
|
|
8
|
+
'runtime.walltime': (sp: any) => void;
|
|
9
|
+
'runtime.scheduleTimeoutEvent': (sp: any) => void;
|
|
10
|
+
'runtime.clearTimeoutEvent': (sp: any) => void;
|
|
11
|
+
'runtime.getRandomData': (sp: any) => void;
|
|
12
|
+
'syscall/js.finalizeRef': (sp: any) => void;
|
|
13
|
+
'syscall/js.stringVal': (sp: any) => void;
|
|
14
|
+
'syscall/js.valueGet': (sp: any) => void;
|
|
15
|
+
'syscall/js.valueSet': (sp: any) => void;
|
|
16
|
+
'syscall/js.valueDelete': (sp: any) => void;
|
|
17
|
+
'syscall/js.valueIndex': (sp: any) => void;
|
|
18
|
+
'syscall/js.valueSetIndex': (sp: any) => void;
|
|
19
|
+
'syscall/js.valueCall': (sp: any) => void;
|
|
20
|
+
'syscall/js.valueInvoke': (sp: any) => void;
|
|
21
|
+
'syscall/js.valueNew': (sp: any) => void;
|
|
22
|
+
'syscall/js.valueLength': (sp: any) => void;
|
|
23
|
+
'syscall/js.valuePrepareString': (sp: any) => void;
|
|
24
|
+
'syscall/js.valueLoadString': (sp: any) => void;
|
|
25
|
+
'syscall/js.valueInstanceOf': (sp: any) => void;
|
|
26
|
+
'syscall/js.copyBytesToGo': (sp: any) => void;
|
|
27
|
+
'syscall/js.copyBytesToJS': (sp: any) => void;
|
|
28
|
+
debug: (value: any) => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
constructor();
|
|
32
|
+
run(instance: any): Promise<void>;
|
|
33
|
+
private _resume;
|
|
34
|
+
private _makeFuncWrapper;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { Go as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-XZNZIE5X.js";export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import g from"crypto";import _ from"fs";import{TextDecoder as b,TextEncoder as v}from"util";globalThis.fs||Object.defineProperty(globalThis,"fs",{value:_});globalThis.process||Object.defineProperties(globalThis,"process",{value:process});globalThis.crypto||Object.defineProperty(globalThis,"crypto",{value:g.webcrypto?g.webcrypto:{getRandomValues(m){return g.randomFillSync(m)}}});globalThis.performance||Object.defineProperty(globalThis,"performance",{value:{now(){let[m,o]=process.hrtime();return m*1e3+o/1e6}}});var y=new v("utf-8"),w=new b("utf-8");var d=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let o=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},n=t=>{let e=this.mem.getUint32(t+0,!0),s=this.mem.getInt32(t+4,!0);return e+s*4294967296},r=t=>{let e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;let s=this.mem.getUint32(t,!0);return this._values[s]},l=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let i=this._ids.get(e);i===void 0&&(i=this._idPool.pop(),i===void 0&&(i=this._values.length),this._values[i]=e,this._goRefCounts[i]=0,this._ids.set(e,i)),this._goRefCounts[i]++;let a=0;switch(typeof e){case"object":e!==null&&(a=1);break;case"string":a=2;break;case"symbol":a=3;break;case"function":a=4;break}this.mem.setUint32(t+4,2146959360|a,!0),this.mem.setUint32(t,i,!0)},c=t=>{let e=n(t+0),s=n(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,s)},f=t=>{let e=n(t+0),s=n(t+8),i=new Array(s);for(let a=0;a<s;a++)i[a]=r(e+a*8);return i},u=t=>{let e=n(t+0),s=n(t+8);return w.decode(new DataView(this._inst.exports.mem.buffer,e,s))},h=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":t=>{t>>>=0;let e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;let e=n(t+8),s=n(t+16),i=this.mem.getInt32(t+24,!0);_.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,s,i))},"runtime.resetMemoryDataView":t=>{t>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,o(t+8,(h+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;let e=new Date().getTime();o(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;let e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},n(t+8)+1)),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;let e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,globalThis.crypto.getRandomValues(c(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;let e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){let s=this._values[e];this._values[e]=null,this._ids.delete(s),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,l(t+24,u(t+8))},"syscall/js.valueGet":t=>{t>>>=0;let e=Reflect.get(r(t+8),u(t+16));t=this._inst.exports.getsp()>>>0,l(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(r(t+8),u(t+16),r(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(r(t+8),u(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,l(t+24,Reflect.get(r(t+8),n(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(r(t+8),n(t+16),r(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{let e=r(t+8),s=Reflect.get(e,u(t+16)),i=f(t+32),a=Reflect.apply(s,e,i);t=this._inst.exports.getsp()>>>0,l(t+56,a),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,l(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{let e=r(t+8),s=f(t+16),i=Reflect.apply(e,void 0,s);t=this._inst.exports.getsp()>>>0,l(t+40,i),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,l(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{let e=r(t+8),s=f(t+16),i=Reflect.construct(e,s);t=this._inst.exports.getsp()>>>0,l(t+40,i),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,l(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,o(t+16,parseInt(r(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;let e=y.encode(String(r(t+8)));l(t+16,e),o(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;let e=r(t+8);c(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,r(t+8)instanceof r(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;let e=c(t+8),s=r(t+32);if(!(s instanceof Uint8Array||s instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}let i=s.subarray(0,e.length);e.set(i),o(t+40,i.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;let e=r(t+8),s=c(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}let i=s.subarray(0,e.length);e.set(i),o(t+40,i.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(o){if(!(o instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=o,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let n=4096,r=h=>{let t=n,e=y.encode(h+"\0");return new Uint8Array(this.mem.buffer,n,e.length).set(e),n+=e.length,n%8!==0&&(n+=8-n%8),t},l=this.argv.length,c=[];this.argv.forEach(h=>{c.push(r(h))}),c.push(0),Object.keys(this.env).sort().forEach(h=>{c.push(r(`${h}=${this.env[h]}`))}),c.push(0);let u=n;c.forEach(h=>{this.mem.setUint32(n,h,!0),this.mem.setUint32(n+4,0,!0),n+=8}),this._inst.exports.run(l,u),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(o){let n=this;return function(){let r={id:o,this:this,args:arguments};return n._pendingEvent=r,n._resume(),r.result}}};export{d as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var l=()=>{let r=new Error("not implemented");return r.code="ENOSYS",r},g="",w={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(r,n){g+=x.decode(n);let s=g.lastIndexOf(`
|
|
2
|
+
`);return s!=-1&&(console.log(g.substr(0,s)),g=g.substr(s+1)),n.length},write(r,n,s,i,h,c){if(s!==0||i!==n.length||h!==null){c(l());return}let d=this.writeSync(r,n);c(null,d)},chmod(r,n,s){s(l())},chown(r,n,s,i){i(l())},close(r,n){n(l())},fchmod(r,n,s){s(l())},fchown(r,n,s,i){i(l())},fstat(r,n){n(l())},fsync(r,n){n(null)},ftruncate(r,n,s){s(l())},lchown(r,n,s,i){i(l())},link(r,n,s){s(l())},lstat(r,n){n(l())},mkdir(r,n,s){s(l())},open(r,n,s,i){i(l())},read(r,n,s,i,h,c){c(l())},readdir(r,n){n(l())},readlink(r,n){n(l())},rename(r,n,s){s(l())},rmdir(r,n){n(l())},stat(r,n){n(l())},symlink(r,n,s){s(l())},truncate(r,n,s){s(l())},unlink(r,n){n(l())},utimes(r,n,s,i){i(l())}},v={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw l()},pid:-1,ppid:-1,umask(){throw l()},cwd(){throw l()},chdir(){throw l()}};Object.defineProperties(globalThis,{fs:{value:w,enumerable:!0},process:{value:v,enumerable:!0}});var y=new TextEncoder("utf-8"),x=new TextDecoder("utf-8");var _=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let n=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},s=t=>{let e=this.mem.getUint32(t+0,!0),o=this.mem.getInt32(t+4,!0);return e+o*4294967296},i=t=>{let e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;let o=this.mem.getUint32(t,!0);return this._values[o]},h=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let a=this._ids.get(e);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=e,this._goRefCounts[a]=0,this._ids.set(e,a)),this._goRefCounts[a]++;let u=0;switch(typeof e){case"object":e!==null&&(u=1);break;case"string":u=2;break;case"symbol":u=3;break;case"function":u=4;break}this.mem.setUint32(t+4,2146959360|u,!0),this.mem.setUint32(t,a,!0)},c=t=>{let e=s(t+0),o=s(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,o)},d=t=>{let e=s(t+0),o=s(t+8),a=new Array(o);for(let u=0;u<o;u++)a[u]=i(e+u*8);return a},f=t=>{let e=s(t+0),o=s(t+8);return x.decode(new DataView(this._inst.exports.mem.buffer,e,o))},m=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":t=>{t>>>=0;let e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;let e=s(t+8),o=s(t+16),a=this.mem.getInt32(t+24,!0);w.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,o,a))},"runtime.resetMemoryDataView":t=>{t>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,n(t+8,(m+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;let e=new Date().getTime();n(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;let e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(t+8)+1)),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;let e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,globalThis.crypto.getRandomValues(c(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;let e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){let o=this._values[e];this._values[e]=null,this._ids.delete(o),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,h(t+24,f(t+8))},"syscall/js.valueGet":t=>{t>>>=0;let e=Reflect.get(i(t+8),f(t+16));t=this._inst.exports.getsp()>>>0,h(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(i(t+8),f(t+16),i(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(i(t+8),f(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,h(t+24,Reflect.get(i(t+8),s(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(i(t+8),s(t+16),i(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{let e=i(t+8),o=Reflect.get(e,f(t+16)),a=d(t+32),u=Reflect.apply(o,e,a);t=this._inst.exports.getsp()>>>0,h(t+56,u),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,h(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{let e=i(t+8),o=d(t+16),a=Reflect.apply(e,void 0,o);t=this._inst.exports.getsp()>>>0,h(t+40,a),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,h(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{let e=i(t+8),o=d(t+16),a=Reflect.construct(e,o);t=this._inst.exports.getsp()>>>0,h(t+40,a),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,h(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,n(t+16,parseInt(i(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;let e=y.encode(String(i(t+8)));h(t+16,e),n(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;let e=i(t+8);c(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,i(t+8)instanceof i(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;let e=c(t+8),o=i(t+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}let a=o.subarray(0,e.length);e.set(a),n(t+40,a.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;let e=i(t+8),o=c(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}let a=o.subarray(0,e.length);e.set(a),n(t+40,a.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(n){if(!(n instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=n,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let s=4096,i=m=>{let t=s,e=y.encode(m+"\0");return new Uint8Array(this.mem.buffer,s,e.length).set(e),s+=e.length,s%8!==0&&(s+=8-s%8),t},h=this.argv.length,c=[];this.argv.forEach(m=>{c.push(i(m))}),c.push(0),Object.keys(this.env).sort().forEach(m=>{c.push(i(`${m}=${this.env[m]}`))}),c.push(0);let f=s;c.forEach(m=>{this.mem.setUint32(s,m,!0),this.mem.setUint32(s+4,0,!0),s+=8}),this._inst.exports.run(h,f),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(n){let s=this;return function(){let i={id:n,this:this,args:arguments};return s._pendingEvent=i,s._resume(),i.result}}};export{_ as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=Object.create;var g=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var O=(r,n)=>{for(var s in n)g(r,s,{get:n[s],enumerable:!0})},T=(r,n,s,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of I(n))!E.call(r,c)&&c!==s&&g(r,c,{get:()=>n[c],enumerable:!(i=R(n,c))||i.enumerable});return r};var x=(r,n,s)=>(s=r!=null?P(A(r)):{},T(n||!r||!r.__esModule?g(s,"default",{value:r,enumerable:!0}):s,r)),C=r=>T(g({},"__esModule",{value:!0}),r);var B={};O(B,{compile:()=>W,convertToTSX:()=>L,parse:()=>N,teardown:()=>F,transform:()=>V});module.exports=C(B);var k=()=>typeof document>"u"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,v=k();var S=require("fs"),j=require("url");var p=x(require("crypto"),1),w=x(require("fs"),1),_=require("util");globalThis.fs||Object.defineProperty(globalThis,"fs",{value:w.default});globalThis.process||Object.defineProperties(globalThis,"process",{value:process});globalThis.crypto||Object.defineProperty(globalThis,"crypto",{value:p.default.webcrypto?p.default.webcrypto:{getRandomValues(r){return p.default.randomFillSync(r)}}});globalThis.performance||Object.defineProperty(globalThis,"performance",{value:{now(){let[r,n]=process.hrtime();return r*1e3+n/1e6}}});var U=new _.TextEncoder("utf-8"),D=new _.TextDecoder("utf-8");var d=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let n=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},s=e=>{let t=this.mem.getUint32(e+0,!0),a=this.mem.getInt32(e+4,!0);return t+a*4294967296},i=e=>{let t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;let a=this.mem.getUint32(e,!0);return this._values[a]},c=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let l=this._ids.get(t);l===void 0&&(l=this._idPool.pop(),l===void 0&&(l=this._values.length),this._values[l]=t,this._goRefCounts[l]=0,this._ids.set(t,l)),this._goRefCounts[l]++;let m=0;switch(typeof t){case"object":t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,2146959360|m,!0),this.mem.setUint32(e,l,!0)},o=e=>{let t=s(e+0),a=s(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,a)},y=e=>{let t=s(e+0),a=s(e+8),l=new Array(a);for(let m=0;m<a;m++)l[m]=i(t+m*8);return l},f=e=>{let t=s(e+0),a=s(e+8);return D.decode(new DataView(this._inst.exports.mem.buffer,t,a))},h=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;let t=s(e+8),a=s(e+16),l=this.mem.getInt32(e+24,!0);w.default.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,a,l))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,n(e+8,(h+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;let t=new Date().getTime();n(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;let t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,globalThis.crypto.getRandomValues(o(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;let t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){let a=this._values[t];this._values[t]=null,this._ids.delete(a),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,c(e+24,f(e+8))},"syscall/js.valueGet":e=>{e>>>=0;let t=Reflect.get(i(e+8),f(e+16));e=this._inst.exports.getsp()>>>0,c(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(i(e+8),f(e+16),i(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(i(e+8),f(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,c(e+24,Reflect.get(i(e+8),s(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(i(e+8),s(e+16),i(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{let t=i(e+8),a=Reflect.get(t,f(e+16)),l=y(e+32),m=Reflect.apply(a,t,l);e=this._inst.exports.getsp()>>>0,c(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{let t=i(e+8),a=y(e+16),l=Reflect.apply(t,void 0,a);e=this._inst.exports.getsp()>>>0,c(e+40,l),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{let t=i(e+8),a=y(e+16),l=Reflect.construct(t,a);e=this._inst.exports.getsp()>>>0,c(e+40,l),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,n(e+16,parseInt(i(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;let t=U.encode(String(i(e+8)));c(e+16,t),n(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;let t=i(e+8);o(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,i(e+8)instanceof i(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;let t=o(e+8),a=i(e+32);if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let l=a.subarray(0,t.length);t.set(l),n(e+40,l.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;let t=i(e+8),a=o(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let l=a.subarray(0,t.length);t.set(l),n(e+40,l.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(n){if(!(n instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=n,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let s=4096,i=h=>{let e=s,t=U.encode(h+"\0");return new Uint8Array(this.mem.buffer,s,t.length).set(t),s+=t.length,s%8!==0&&(s+=8-s%8),e},c=this.argv.length,o=[];this.argv.forEach(h=>{o.push(i(h))}),o.push(0),Object.keys(this.env).sort().forEach(h=>{o.push(i(`${h}=${this.env[h]}`))}),o.push(0);let f=s;o.forEach(h=>{this.mem.setUint32(s,h,!0),this.mem.setUint32(s+4,0,!0),s+=8}),this._inst.exports.run(c,f),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(n){let s=this;return function(){let i={id:n,this:this,args:arguments};return s._pendingEvent=i,s._resume(),i.result}}};var V=async(r,n)=>b().then(s=>s.transform(r,n)),N=async(r,n)=>b().then(s=>s.parse(r,n)),L=async(r,n)=>b().then(s=>s.convertToTSX(r,n)),W=async r=>{let{default:n}=await import(`data:text/javascript;charset=utf-8;base64,${Buffer.from(r).toString("base64")}`);return n},u,F=()=>{u=void 0,globalThis["@astrojs/compiler"]=void 0},b=()=>(u||(u=M().catch(r=>{throw u=void 0,r})),u),X=async(r,n)=>{let s;return s=await(async()=>{let c=await S.promises.readFile(r).then(o=>o.buffer);return WebAssembly.instantiate(new Uint8Array(c),n)})(),s},M=async()=>{let r=new d,n=await X((0,j.fileURLToPath)(new URL("../astro.wasm",v)),r.importObject);r.run(n.instance);let s=globalThis["@astrojs/compiler"];return{transform:(i,c)=>new Promise(o=>{try{o(s.transform(i,c||{}))}catch(y){throw u=void 0,y}}),parse:(i,c)=>new Promise(o=>o(s.parse(i,c||{}))).catch(o=>{throw u=void 0,o}).then(o=>({...o,ast:JSON.parse(o.ast)})),convertToTSX:(i,c)=>new Promise(o=>o(s.convertToTSX(i,c||{}))).catch(o=>{throw u=void 0,o}).then(o=>({...o,map:JSON.parse(o.map)}))}};0&&(module.exports={compile,convertToTSX,parse,teardown,transform});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { transform as transform$1, parse as parse$1, convertToTSX as convertToTSX$1, teardown as teardown$1 } from '../shared/types.js';
|
|
2
|
+
export { HoistedScript, ParseOptions, ParseResult, PreprocessorResult, TransformOptions, TransformResult } from '../shared/types.js';
|
|
3
|
+
import '../shared/ast.js';
|
|
4
|
+
import '../shared/diagnostics.js';
|
|
5
|
+
|
|
6
|
+
declare const transform: typeof transform$1;
|
|
7
|
+
declare const parse: typeof parse$1;
|
|
8
|
+
declare const convertToTSX: typeof convertToTSX$1;
|
|
9
|
+
declare const compile: (template: string) => Promise<string>;
|
|
10
|
+
declare const teardown: typeof teardown$1;
|
|
11
|
+
|
|
12
|
+
export { compile, convertToTSX, parse, teardown, transform };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"../chunk-GFDH6LQW.js";import{promises as m}from"fs";import{fileURLToPath as f}from"url";var l=async(t,s)=>i().then(r=>r.transform(t,s)),w=async(t,s)=>i().then(r=>r.parse(t,s)),b=async(t,s)=>i().then(r=>r.convertToTSX(t,s)),P=async t=>{let{default:s}=await import(`data:text/javascript;charset=utf-8;base64,${Buffer.from(t).toString("base64")}`);return s},n,g=()=>{n=void 0,globalThis["@astrojs/compiler"]=void 0},i=()=>(n||(n=d().catch(t=>{throw n=void 0,t})),n),y=async(t,s)=>{let r;return r=await(async()=>{let o=await m.readFile(t).then(e=>e.buffer);return WebAssembly.instantiate(new Uint8Array(o),s)})(),r},d=async()=>{let t=new c,s=await y(f(new URL("../astro.wasm",import.meta.url)),t.importObject);t.run(s.instance);let r=globalThis["@astrojs/compiler"];return{transform:(a,o)=>new Promise(e=>{try{e(r.transform(a,o||{}))}catch(p){throw n=void 0,p}}),parse:(a,o)=>new Promise(e=>e(r.parse(a,o||{}))).catch(e=>{throw n=void 0,e}).then(e=>({...e,ast:JSON.parse(e.ast)})),convertToTSX:(a,o)=>new Promise(e=>e(r.convertToTSX(a,o||{}))).catch(e=>{throw n=void 0,e}).then(e=>({...e,map:JSON.parse(e.map)}))}};export{P as compile,b as convertToTSX,w as parse,g as teardown,l as transform};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=Object.create;var y=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var O=(i,n)=>{for(var s in n)y(i,s,{get:n[s],enumerable:!0})},T=(i,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of A(n))!C.call(i,c)&&c!==s&&y(i,c,{get:()=>n[c],enumerable:!(r=I(n,c))||r.enumerable});return i};var x=(i,n,s)=>(s=i!=null?P(E(i)):{},T(n||!i||!i.__esModule?y(s,"default",{value:i,enumerable:!0}):s,i)),D=i=>T(y({},"__esModule",{value:!0}),i);var M={};O(M,{convertToTSX:()=>W,parse:()=>L,startRunningService:()=>R,transform:()=>N});module.exports=D(M);var k=()=>typeof document>"u"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,w=k();var S=require("fs"),j=require("url");var v=x(require("crypto"),1),b=x(require("fs"),1),_=require("util");globalThis.fs||Object.defineProperty(globalThis,"fs",{value:b.default});globalThis.process||Object.defineProperties(globalThis,"process",{value:process});globalThis.crypto||Object.defineProperty(globalThis,"crypto",{value:v.default.webcrypto?v.default.webcrypto:{getRandomValues(i){return v.default.randomFillSync(i)}}});globalThis.performance||Object.defineProperty(globalThis,"performance",{value:{now(){let[i,n]=process.hrtime();return i*1e3+n/1e6}}});var U=new _.TextEncoder("utf-8"),V=new _.TextDecoder("utf-8");var d=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let n=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},s=e=>{let t=this.mem.getUint32(e+0,!0),o=this.mem.getInt32(e+4,!0);return t+o*4294967296},r=e=>{let t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;let o=this.mem.getUint32(e,!0);return this._values[o]},c=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let a=this._ids.get(t);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=t,this._goRefCounts[a]=0,this._ids.set(t,a)),this._goRefCounts[a]++;let m=0;switch(typeof t){case"object":t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,2146959360|m,!0),this.mem.setUint32(e,a,!0)},l=e=>{let t=s(e+0),o=s(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},g=e=>{let t=s(e+0),o=s(e+8),a=new Array(o);for(let m=0;m<o;m++)a[m]=r(t+m*8);return a},h=e=>{let t=s(e+0),o=s(e+8);return V.decode(new DataView(this._inst.exports.mem.buffer,t,o))},u=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;let t=s(e+8),o=s(e+16),a=this.mem.getInt32(e+24,!0);b.default.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,o,a))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,n(e+8,(u+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;let t=new Date().getTime();n(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;let t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,globalThis.crypto.getRandomValues(l(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;let t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){let o=this._values[t];this._values[t]=null,this._ids.delete(o),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,c(e+24,h(e+8))},"syscall/js.valueGet":e=>{e>>>=0;let t=Reflect.get(r(e+8),h(e+16));e=this._inst.exports.getsp()>>>0,c(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(r(e+8),h(e+16),r(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(r(e+8),h(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,c(e+24,Reflect.get(r(e+8),s(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(r(e+8),s(e+16),r(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{let t=r(e+8),o=Reflect.get(t,h(e+16)),a=g(e+32),m=Reflect.apply(o,t,a);e=this._inst.exports.getsp()>>>0,c(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{let t=r(e+8),o=g(e+16),a=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,c(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{let t=r(e+8),o=g(e+16),a=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,c(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,c(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,n(e+16,parseInt(r(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;let t=U.encode(String(r(e+8)));c(e+16,t),n(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;let t=r(e+8);l(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,r(e+8)instanceof r(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;let t=l(e+8),o=r(e+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let a=o.subarray(0,t.length);t.set(a),n(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;let t=r(e+8),o=l(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let a=o.subarray(0,t.length);t.set(a),n(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(n){if(!(n instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=n,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let s=4096,r=u=>{let e=s,t=U.encode(u+"\0");return new Uint8Array(this.mem.buffer,s,t.length).set(t),s+=t.length,s%8!==0&&(s+=8-s%8),e},c=this.argv.length,l=[];this.argv.forEach(u=>{l.push(r(u))}),l.push(0),Object.keys(this.env).sort().forEach(u=>{l.push(r(`${u}=${this.env[u]}`))}),l.push(0);let h=s;l.forEach(u=>{this.mem.setUint32(s,u,!0),this.mem.setUint32(s+4,0,!0),s+=8}),this._inst.exports.run(c,h),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(n){let s=this;return function(){let r={id:n,this:this,args:arguments};return s._pendingEvent=r,s._resume(),r.result}}};function p(){return f||(f=R()),f}var f,N=(i,n)=>p().transform(i,n),L=(i,n)=>p().parse(i,n),W=(i,n)=>p().convertToTSX(i,n);function R(){let i=new d,n=F((0,j.fileURLToPath)(new URL("../astro.wasm",w)),i.importObject);i.run(n);let s=globalThis["@astrojs/compiler"];return{transform:(r,c)=>{try{return s.transform(r,c||{})}catch(l){throw f=void 0,l}},parse:(r,c)=>{try{let l=s.parse(r,c||{});return{...l,ast:JSON.parse(l.ast)}}catch(l){throw f=void 0,l}},convertToTSX:(r,c)=>{try{let l=s.convertToTSX(r,c||{});return{...l,map:JSON.parse(l.map)}}catch(l){throw f=void 0,l}}}}function F(i,n){let s=(0,S.readFileSync)(i);return new WebAssembly.Instance(new WebAssembly.Module(s),n)}0&&(module.exports={convertToTSX,parse,startRunningService,transform});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TransformOptions, TransformResult, ParseOptions, ParseResult, ConvertToTSXOptions, TSXResult, transform as transform$1, parse as parse$1, convertToTSX as convertToTSX$1 } from '../shared/types.js';
|
|
2
|
+
import '../shared/ast.js';
|
|
3
|
+
import '../shared/diagnostics.js';
|
|
4
|
+
|
|
5
|
+
type UnwrappedPromise<T> = T extends (...params: any) => Promise<infer Return> ? (...params: Parameters<T>) => Return : T;
|
|
6
|
+
interface Service {
|
|
7
|
+
transform: UnwrappedPromise<typeof transform$1>;
|
|
8
|
+
parse: UnwrappedPromise<typeof parse$1>;
|
|
9
|
+
convertToTSX: UnwrappedPromise<typeof convertToTSX$1>;
|
|
10
|
+
}
|
|
11
|
+
declare const transform: (input: string, options: TransformOptions | undefined) => TransformResult;
|
|
12
|
+
declare const parse: (input: string, options: ParseOptions | undefined) => ParseResult;
|
|
13
|
+
declare const convertToTSX: (input: string, options: ConvertToTSXOptions | undefined) => TSXResult;
|
|
14
|
+
declare function startRunningService(): Service;
|
|
15
|
+
|
|
16
|
+
export { convertToTSX, parse, startRunningService, transform };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"../chunk-GFDH6LQW.js";import{readFileSync as p}from"fs";import{fileURLToPath as m}from"url";function i(){return s||(s=f()),s}var s,l=(e,t)=>i().transform(e,t),w=(e,t)=>i().parse(e,t),h=(e,t)=>i().convertToTSX(e,t);function f(){let e=new c,t=v(m(new URL("../astro.wasm",import.meta.url)),e.importObject);e.run(t);let o=globalThis["@astrojs/compiler"];return{transform:(n,a)=>{try{return o.transform(n,a||{})}catch(r){throw s=void 0,r}},parse:(n,a)=>{try{let r=o.parse(n,a||{});return{...r,ast:JSON.parse(r.ast)}}catch(r){throw s=void 0,r}},convertToTSX:(n,a)=>{try{let r=o.convertToTSX(n,a||{});return{...r,map:JSON.parse(r.map)}}catch(r){throw s=void 0,r}}}}function v(e,t){let o=p(e);return new WebAssembly.Instance(new WebAssembly.Module(o),t)}export{h as convertToTSX,w as parse,f as startRunningService,l as transform};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)l(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!N.call(o,r)&&r!==t&&l(o,r,{get:()=>e[r],enumerable:!(n=d(e,r))||n.enumerable});return o};var h=o=>f(l({},"__esModule",{value:!0}),o);var k={};u(k,{is:()=>s,serialize:()=>g,walk:()=>y});module.exports=h(k);function i(o){return e=>e.type===o}var s={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:i("root"),element:i("element"),customElement:i("custom-element"),component:i("component"),fragment:i("fragment"),expression:i("expression"),text:i("text"),doctype:i("doctype"),comment:i("comment"),frontmatter:i("frontmatter")},m=class{constructor(e){this.callback=e}async visit(e,t,n){if(await this.callback(e,t,n),s.parent(e)){let r=[];for(let a=0;a<e.children.length;a++){let c=e.children[a];r.push(this.callback(c,e,a))}await Promise.all(r)}}};function y(o,e){new m(e).visit(o)}function x(o){let e="";for(let t of o.attributes)switch(e+=" ",t.kind){case"empty":{e+=`${t.name}`;break}case"expression":{e+=`${t.name}={${t.value}}`;break}case"quoted":{e+=`${t.name}=${t.raw}`;break}case"template-literal":{e+=`${t.name}=\`${t.value}\``;break}case"shorthand":{e+=`{${t.name}}`;break}case"spread":{e+=`{...${t.name}}`;break}}return e}function g(o,e={selfClose:!0}){let t="";function n(r){s.root(r)?r.children.forEach(a=>n(a)):s.frontmatter(r)?t+=`---${r.value}---
|
|
2
|
+
|
|
3
|
+
`:s.comment(r)?t+=`<!--${r.value}-->`:s.expression(r)?(t+="{",r.children.forEach(a=>n(a)),t+="}"):s.literal(r)?t+=r.value:s.tag(r)&&(t+=`<${r.name}`,t+=x(r),r.children.length==0&&e.selfClose?t+=" />":(t+=">",r.children.forEach(a=>n(a)),t+=`</${r.name}>`))}return n(o),t}0&&(module.exports={is,serialize,walk});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Node, ParentNode, LiteralNode, TagLikeNode, TextNode, RootNode, ElementNode, CustomElementNode, ComponentNode, FragmentNode, ExpressionNode, DoctypeNode, CommentNode, FrontmatterNode } from '../shared/ast.js';
|
|
2
|
+
|
|
3
|
+
interface Visitor {
|
|
4
|
+
(node: Node, parent?: ParentNode, index?: number): void | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
declare const is: {
|
|
7
|
+
parent(node: Node): node is ParentNode;
|
|
8
|
+
literal(node: Node): node is LiteralNode;
|
|
9
|
+
tag(node: Node): node is TagLikeNode;
|
|
10
|
+
whitespace(node: Node): node is TextNode;
|
|
11
|
+
root: (node: Node) => node is RootNode;
|
|
12
|
+
element: (node: Node) => node is ElementNode;
|
|
13
|
+
customElement: (node: Node) => node is CustomElementNode;
|
|
14
|
+
component: (node: Node) => node is ComponentNode;
|
|
15
|
+
fragment: (node: Node) => node is FragmentNode;
|
|
16
|
+
expression: (node: Node) => node is ExpressionNode;
|
|
17
|
+
text: (node: Node) => node is TextNode;
|
|
18
|
+
doctype: (node: Node) => node is DoctypeNode;
|
|
19
|
+
comment: (node: Node) => node is CommentNode;
|
|
20
|
+
frontmatter: (node: Node) => node is FrontmatterNode;
|
|
21
|
+
};
|
|
22
|
+
declare function walk(node: ParentNode, callback: Visitor): void;
|
|
23
|
+
interface SerializeOptions {
|
|
24
|
+
selfClose: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** @deprecated Please use `SerializeOptions` */
|
|
27
|
+
type SerializeOtions = SerializeOptions;
|
|
28
|
+
declare function serialize(root: Node, opts?: SerializeOptions): string;
|
|
29
|
+
|
|
30
|
+
export { SerializeOptions, SerializeOtions, Visitor, is, serialize, walk };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function i(o){return t=>t.type===o}var n={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:i("root"),element:i("element"),customElement:i("custom-element"),component:i("component"),fragment:i("fragment"),expression:i("expression"),text:i("text"),doctype:i("doctype"),comment:i("comment"),frontmatter:i("frontmatter")},l=class{constructor(t){this.callback=t}async visit(t,e,s){if(await this.callback(t,e,s),n.parent(t)){let r=[];for(let a=0;a<t.children.length;a++){let m=t.children[a];r.push(this.callback(m,t,a))}await Promise.all(r)}}};function N(o,t){new l(t).visit(o)}function c(o){let t="";for(let e of o.attributes)switch(t+=" ",e.kind){case"empty":{t+=`${e.name}`;break}case"expression":{t+=`${e.name}={${e.value}}`;break}case"quoted":{t+=`${e.name}=${e.raw}`;break}case"template-literal":{t+=`${e.name}=\`${e.value}\``;break}case"shorthand":{t+=`{${e.name}}`;break}case"spread":{t+=`{...${e.name}}`;break}}return t}function u(o,t={selfClose:!0}){let e="";function s(r){n.root(r)?r.children.forEach(a=>s(a)):n.frontmatter(r)?e+=`---${r.value}---
|
|
2
|
+
|
|
3
|
+
`:n.comment(r)?e+=`<!--${r.value}-->`:n.expression(r)?(e+="{",r.children.forEach(a=>s(a)),e+="}"):n.literal(r)?e+=r.value:n.tag(r)&&(e+=`<${r.name}`,e+=c(r),r.children.length==0&&t.selfClose?e+=" />":(e+=">",r.children.forEach(a=>s(a)),e+=`</${r.name}>`))}return s(o),e}export{n as is,u as serialize,N as walk};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var T=Object.create;var g=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var P=(l,o)=>{for(var s in o)g(l,s,{get:o[s],enumerable:!0})},v=(l,o,s,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of j(o))!R.call(l,a)&&a!==s&&g(l,a,{get:()=>o[a],enumerable:!(i=U(o,a))||i.enumerable});return l};var w=(l,o,s)=>(s=l!=null?T(I(l)):{},v(o||!l||!l.__esModule?g(s,"default",{value:l,enumerable:!0}):s,l)),E=l=>v(g({},"__esModule",{value:!0}),l);var D={};P(D,{default:()=>y});module.exports=E(D);var d=w(require("crypto"),1),b=w(require("fs"),1),_=require("util");globalThis.fs||Object.defineProperty(globalThis,"fs",{value:b.default});globalThis.process||Object.defineProperties(globalThis,"process",{value:process});globalThis.crypto||Object.defineProperty(globalThis,"crypto",{value:d.default.webcrypto?d.default.webcrypto:{getRandomValues(l){return d.default.randomFillSync(l)}}});globalThis.performance||Object.defineProperty(globalThis,"performance",{value:{now(){let[l,o]=process.hrtime();return l*1e3+o/1e6}}});var x=new _.TextEncoder("utf-8"),C=new _.TextDecoder("utf-8");var y=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let o=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},s=t=>{let e=this.mem.getUint32(t+0,!0),n=this.mem.getInt32(t+4,!0);return e+n*4294967296},i=t=>{let e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;let n=this.mem.getUint32(t,!0);return this._values[n]},a=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let r=this._ids.get(e);r===void 0&&(r=this._idPool.pop(),r===void 0&&(r=this._values.length),this._values[r]=e,this._goRefCounts[r]=0,this._ids.set(e,r)),this._goRefCounts[r]++;let c=0;switch(typeof e){case"object":e!==null&&(c=1);break;case"string":c=2;break;case"symbol":c=3;break;case"function":c=4;break}this.mem.setUint32(t+4,2146959360|c,!0),this.mem.setUint32(t,r,!0)},h=t=>{let e=s(t+0),n=s(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,n)},f=t=>{let e=s(t+0),n=s(t+8),r=new Array(n);for(let c=0;c<n;c++)r[c]=i(e+c*8);return r},m=t=>{let e=s(t+0),n=s(t+8);return C.decode(new DataView(this._inst.exports.mem.buffer,e,n))},u=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":t=>{t>>>=0;let e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;let e=s(t+8),n=s(t+16),r=this.mem.getInt32(t+24,!0);b.default.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,n,r))},"runtime.resetMemoryDataView":t=>{t>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,o(t+8,(u+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;let e=new Date().getTime();o(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;let e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(t+8)+1)),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;let e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,globalThis.crypto.getRandomValues(h(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;let e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){let n=this._values[e];this._values[e]=null,this._ids.delete(n),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,a(t+24,m(t+8))},"syscall/js.valueGet":t=>{t>>>=0;let e=Reflect.get(i(t+8),m(t+16));t=this._inst.exports.getsp()>>>0,a(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(i(t+8),m(t+16),i(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(i(t+8),m(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,a(t+24,Reflect.get(i(t+8),s(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(i(t+8),s(t+16),i(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{let e=i(t+8),n=Reflect.get(e,m(t+16)),r=f(t+32),c=Reflect.apply(n,e,r);t=this._inst.exports.getsp()>>>0,a(t+56,c),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,a(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{let e=i(t+8),n=f(t+16),r=Reflect.apply(e,void 0,n);t=this._inst.exports.getsp()>>>0,a(t+40,r),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,a(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{let e=i(t+8),n=f(t+16),r=Reflect.construct(e,n);t=this._inst.exports.getsp()>>>0,a(t+40,r),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,a(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,o(t+16,parseInt(i(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;let e=x.encode(String(i(t+8)));a(t+16,e),o(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;let e=i(t+8);h(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,i(t+8)instanceof i(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;let e=h(t+8),n=i(t+32);if(!(n instanceof Uint8Array||n instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}let r=n.subarray(0,e.length);e.set(r),o(t+40,r.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;let e=i(t+8),n=h(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}let r=n.subarray(0,e.length);e.set(r),o(t+40,r.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(o){if(!(o instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=o,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let s=4096,i=u=>{let t=s,e=x.encode(u+"\0");return new Uint8Array(this.mem.buffer,s,e.length).set(e),s+=e.length,s%8!==0&&(s+=8-s%8),t},a=this.argv.length,h=[];this.argv.forEach(u=>{h.push(i(u))}),h.push(0),Object.keys(this.env).sort().forEach(u=>{h.push(i(`${u}=${this.env[u]}`))}),h.push(0);let m=s;h.forEach(u=>{this.mem.setUint32(s,u,!0),this.mem.setUint32(s+4,0,!0),s+=8}),this._inst.exports.run(a,m),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(o){let s=this;return function(){let i={id:o,this:this,args:arguments};return s._pendingEvent=i,s._resume(),i.result}}};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare class Go {
|
|
2
|
+
importObject: {
|
|
3
|
+
go: {
|
|
4
|
+
'runtime.wasmExit': (sp: any) => void;
|
|
5
|
+
'runtime.wasmWrite': (sp: any) => void;
|
|
6
|
+
'runtime.resetMemoryDataView': (sp: any) => void;
|
|
7
|
+
'runtime.nanotime1': (sp: any) => void;
|
|
8
|
+
'runtime.walltime': (sp: any) => void;
|
|
9
|
+
'runtime.scheduleTimeoutEvent': (sp: any) => void;
|
|
10
|
+
'runtime.clearTimeoutEvent': (sp: any) => void;
|
|
11
|
+
'runtime.getRandomData': (sp: any) => void;
|
|
12
|
+
'syscall/js.finalizeRef': (sp: any) => void;
|
|
13
|
+
'syscall/js.stringVal': (sp: any) => void;
|
|
14
|
+
'syscall/js.valueGet': (sp: any) => void;
|
|
15
|
+
'syscall/js.valueSet': (sp: any) => void;
|
|
16
|
+
'syscall/js.valueDelete': (sp: any) => void;
|
|
17
|
+
'syscall/js.valueIndex': (sp: any) => void;
|
|
18
|
+
'syscall/js.valueSetIndex': (sp: any) => void;
|
|
19
|
+
'syscall/js.valueCall': (sp: any) => void;
|
|
20
|
+
'syscall/js.valueInvoke': (sp: any) => void;
|
|
21
|
+
'syscall/js.valueNew': (sp: any) => void;
|
|
22
|
+
'syscall/js.valueLength': (sp: any) => void;
|
|
23
|
+
'syscall/js.valuePrepareString': (sp: any) => void;
|
|
24
|
+
'syscall/js.valueLoadString': (sp: any) => void;
|
|
25
|
+
'syscall/js.valueInstanceOf': (sp: any) => void;
|
|
26
|
+
'syscall/js.copyBytesToGo': (sp: any) => void;
|
|
27
|
+
'syscall/js.copyBytesToJS': (sp: any) => void;
|
|
28
|
+
debug: (value: any) => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
constructor();
|
|
32
|
+
run(instance: any): Promise<void>;
|
|
33
|
+
private _resume;
|
|
34
|
+
private _makeFuncWrapper;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { Go as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-GFDH6LQW.js";export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var p=(t,e,d,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of i(e))!N.call(t,o)&&o!==d&&r(t,o,{get:()=>e[o],enumerable:!(n=a(e,o))||n.enumerable});return t};var s=t=>p(r({},"__esModule",{value:!0}),t);var m={};module.exports=s(m);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
type ParentNode = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode;
|
|
2
|
+
type LiteralNode = TextNode | DoctypeNode | CommentNode | FrontmatterNode;
|
|
3
|
+
type Node = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode | TextNode | FrontmatterNode | DoctypeNode | CommentNode;
|
|
4
|
+
interface Position {
|
|
5
|
+
start: Point;
|
|
6
|
+
end?: Point;
|
|
7
|
+
}
|
|
8
|
+
interface Point {
|
|
9
|
+
/** 1-based line number */
|
|
10
|
+
line: number;
|
|
11
|
+
/** 1-based column number, per-line */
|
|
12
|
+
column: number;
|
|
13
|
+
/** 0-based byte offset */
|
|
14
|
+
offset: number;
|
|
15
|
+
}
|
|
16
|
+
interface BaseNode {
|
|
17
|
+
type: string;
|
|
18
|
+
position?: Position;
|
|
19
|
+
}
|
|
20
|
+
interface ParentLikeNode extends BaseNode {
|
|
21
|
+
type: 'element' | 'component' | 'custom-element' | 'fragment' | 'expression' | 'root';
|
|
22
|
+
children: Node[];
|
|
23
|
+
}
|
|
24
|
+
interface ValueNode extends BaseNode {
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
27
|
+
interface RootNode extends ParentLikeNode {
|
|
28
|
+
type: 'root';
|
|
29
|
+
}
|
|
30
|
+
interface AttributeNode extends BaseNode {
|
|
31
|
+
type: 'attribute';
|
|
32
|
+
kind: 'quoted' | 'empty' | 'expression' | 'spread' | 'shorthand' | 'template-literal';
|
|
33
|
+
name: string;
|
|
34
|
+
value: string;
|
|
35
|
+
raw?: string;
|
|
36
|
+
}
|
|
37
|
+
interface TextNode extends ValueNode {
|
|
38
|
+
type: 'text';
|
|
39
|
+
}
|
|
40
|
+
interface ElementNode extends ParentLikeNode {
|
|
41
|
+
type: 'element';
|
|
42
|
+
name: string;
|
|
43
|
+
attributes: AttributeNode[];
|
|
44
|
+
}
|
|
45
|
+
interface FragmentNode extends ParentLikeNode {
|
|
46
|
+
type: 'fragment';
|
|
47
|
+
name: string;
|
|
48
|
+
attributes: AttributeNode[];
|
|
49
|
+
}
|
|
50
|
+
interface ComponentNode extends ParentLikeNode {
|
|
51
|
+
type: 'component';
|
|
52
|
+
name: string;
|
|
53
|
+
attributes: AttributeNode[];
|
|
54
|
+
}
|
|
55
|
+
interface CustomElementNode extends ParentLikeNode {
|
|
56
|
+
type: 'custom-element';
|
|
57
|
+
name: string;
|
|
58
|
+
attributes: AttributeNode[];
|
|
59
|
+
}
|
|
60
|
+
type TagLikeNode = ElementNode | FragmentNode | ComponentNode | CustomElementNode;
|
|
61
|
+
interface DoctypeNode extends ValueNode {
|
|
62
|
+
type: 'doctype';
|
|
63
|
+
}
|
|
64
|
+
interface CommentNode extends ValueNode {
|
|
65
|
+
type: 'comment';
|
|
66
|
+
}
|
|
67
|
+
interface FrontmatterNode extends ValueNode {
|
|
68
|
+
type: 'frontmatter';
|
|
69
|
+
}
|
|
70
|
+
interface ExpressionNode extends ParentLikeNode {
|
|
71
|
+
type: 'expression';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { AttributeNode, BaseNode, CommentNode, ComponentNode, CustomElementNode, DoctypeNode, ElementNode, ExpressionNode, FragmentNode, FrontmatterNode, LiteralNode, Node, ParentLikeNode, ParentNode, Point, Position, RootNode, TagLikeNode, TextNode, ValueNode };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var I=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var U=(E,N)=>{for(var _ in N)I(E,_,{get:N[_],enumerable:!0})},H=(E,N,_,A)=>{if(N&&typeof N=="object"||typeof N=="function")for(let T of G(N))!S.call(E,T)&&T!==_&&I(E,T,{get:()=>N[T],enumerable:!(A=M(N,T))||A.enumerable});return E};var W=E=>H(I({},"__esModule",{value:!0}),E);var P={};U(P,{DiagnosticCode:()=>O});module.exports=W(P);var O=(R=>(R[R.ERROR=1e3]="ERROR",R[R.ERROR_UNTERMINATED_JS_COMMENT=1001]="ERROR_UNTERMINATED_JS_COMMENT",R[R.ERROR_FRAGMENT_SHORTHAND_ATTRS=1002]="ERROR_FRAGMENT_SHORTHAND_ATTRS",R[R.ERROR_UNMATCHED_IMPORT=1003]="ERROR_UNMATCHED_IMPORT",R[R.ERROR_UNSUPPORTED_SLOT_ATTRIBUTE=1004]="ERROR_UNSUPPORTED_SLOT_ATTRIBUTE",R[R.WARNING=2e3]="WARNING",R[R.WARNING_UNTERMINATED_HTML_COMMENT=2001]="WARNING_UNTERMINATED_HTML_COMMENT",R[R.WARNING_UNCLOSED_HTML_TAG=2002]="WARNING_UNCLOSED_HTML_TAG",R[R.WARNING_DEPRECATED_DIRECTIVE=2003]="WARNING_DEPRECATED_DIRECTIVE",R[R.WARNING_IGNORED_DIRECTIVE=2004]="WARNING_IGNORED_DIRECTIVE",R[R.WARNING_UNSUPPORTED_EXPRESSION=2005]="WARNING_UNSUPPORTED_EXPRESSION",R[R.WARNING_SET_WITH_CHILDREN=2006]="WARNING_SET_WITH_CHILDREN",R[R.INFO=3e3]="INFO",R[R.HINT=4e3]="HINT",R))(O||{});0&&(module.exports={DiagnosticCode});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare const enum DiagnosticCode {
|
|
2
|
+
ERROR = 1000,
|
|
3
|
+
ERROR_UNTERMINATED_JS_COMMENT = 1001,
|
|
4
|
+
ERROR_FRAGMENT_SHORTHAND_ATTRS = 1002,
|
|
5
|
+
ERROR_UNMATCHED_IMPORT = 1003,
|
|
6
|
+
ERROR_UNSUPPORTED_SLOT_ATTRIBUTE = 1004,
|
|
7
|
+
WARNING = 2000,
|
|
8
|
+
WARNING_UNTERMINATED_HTML_COMMENT = 2001,
|
|
9
|
+
WARNING_UNCLOSED_HTML_TAG = 2002,
|
|
10
|
+
WARNING_DEPRECATED_DIRECTIVE = 2003,
|
|
11
|
+
WARNING_IGNORED_DIRECTIVE = 2004,
|
|
12
|
+
WARNING_UNSUPPORTED_EXPRESSION = 2005,
|
|
13
|
+
WARNING_SET_WITH_CHILDREN = 2006,
|
|
14
|
+
INFO = 3000,
|
|
15
|
+
HINT = 4000
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { DiagnosticCode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var N=(R=>(R[R.ERROR=1e3]="ERROR",R[R.ERROR_UNTERMINATED_JS_COMMENT=1001]="ERROR_UNTERMINATED_JS_COMMENT",R[R.ERROR_FRAGMENT_SHORTHAND_ATTRS=1002]="ERROR_FRAGMENT_SHORTHAND_ATTRS",R[R.ERROR_UNMATCHED_IMPORT=1003]="ERROR_UNMATCHED_IMPORT",R[R.ERROR_UNSUPPORTED_SLOT_ATTRIBUTE=1004]="ERROR_UNSUPPORTED_SLOT_ATTRIBUTE",R[R.WARNING=2e3]="WARNING",R[R.WARNING_UNTERMINATED_HTML_COMMENT=2001]="WARNING_UNTERMINATED_HTML_COMMENT",R[R.WARNING_UNCLOSED_HTML_TAG=2002]="WARNING_UNCLOSED_HTML_TAG",R[R.WARNING_DEPRECATED_DIRECTIVE=2003]="WARNING_DEPRECATED_DIRECTIVE",R[R.WARNING_IGNORED_DIRECTIVE=2004]="WARNING_IGNORED_DIRECTIVE",R[R.WARNING_UNSUPPORTED_EXPRESSION=2005]="WARNING_UNSUPPORTED_EXPRESSION",R[R.WARNING_SET_WITH_CHILDREN=2006]="WARNING_SET_WITH_CHILDREN",R[R.INFO=3e3]="INFO",R[R.HINT=4e3]="HINT",R))(N||{});export{N as DiagnosticCode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(r,t)=>{for(var o in t)n(r,o,{get:t[o],enumerable:!0})},g=(r,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of p(t))!c.call(r,e)&&e!==o&&n(r,e,{get:()=>t[e],enumerable:!(s=a(t,e))||s.enumerable});return r};var m=r=>g(n({},"__esModule",{value:!0}),r);var d={};l(d,{DiagnosticSeverity:()=>i});module.exports=m(d);var i=(e=>(e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Information=3]="Information",e[e.Hint=4]="Hint",e))(i||{});0&&(module.exports={DiagnosticSeverity});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { RootNode } from './ast.js';
|
|
2
|
+
export { AttributeNode, BaseNode, CommentNode, ComponentNode, CustomElementNode, DoctypeNode, ElementNode, ExpressionNode, FragmentNode, FrontmatterNode, LiteralNode, Node, ParentLikeNode, ParentNode, Point, Position, TagLikeNode, TextNode, ValueNode } from './ast.js';
|
|
3
|
+
import { DiagnosticCode } from './diagnostics.js';
|
|
4
|
+
|
|
5
|
+
interface PreprocessorResult {
|
|
6
|
+
code: string;
|
|
7
|
+
map?: string;
|
|
8
|
+
}
|
|
9
|
+
interface PreprocessorError {
|
|
10
|
+
error: string;
|
|
11
|
+
}
|
|
12
|
+
interface ParseOptions {
|
|
13
|
+
position?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare enum DiagnosticSeverity {
|
|
16
|
+
Error = 1,
|
|
17
|
+
Warning = 2,
|
|
18
|
+
Information = 3,
|
|
19
|
+
Hint = 4
|
|
20
|
+
}
|
|
21
|
+
interface DiagnosticMessage {
|
|
22
|
+
severity: DiagnosticSeverity;
|
|
23
|
+
code: DiagnosticCode;
|
|
24
|
+
location: DiagnosticLocation;
|
|
25
|
+
hint?: string;
|
|
26
|
+
text: string;
|
|
27
|
+
}
|
|
28
|
+
interface DiagnosticLocation {
|
|
29
|
+
file: string;
|
|
30
|
+
line: number;
|
|
31
|
+
column: number;
|
|
32
|
+
length: number;
|
|
33
|
+
}
|
|
34
|
+
interface TransformOptions {
|
|
35
|
+
internalURL?: string;
|
|
36
|
+
filename?: string;
|
|
37
|
+
normalizedFilename?: string;
|
|
38
|
+
sourcemap?: boolean | 'inline' | 'external' | 'both';
|
|
39
|
+
astroGlobalArgs?: string;
|
|
40
|
+
compact?: boolean;
|
|
41
|
+
resultScopedSlot?: boolean;
|
|
42
|
+
scopedStyleStrategy?: 'where' | 'class' | 'attribute';
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated "as" has been removed and no longer has any effect!
|
|
45
|
+
*/
|
|
46
|
+
as?: 'document' | 'fragment';
|
|
47
|
+
transitionsAnimationURL?: string;
|
|
48
|
+
resolvePath?: (specifier: string) => Promise<string>;
|
|
49
|
+
preprocessStyle?: (content: string, attrs: Record<string, string>) => null | Promise<PreprocessorResult | PreprocessorError>;
|
|
50
|
+
annotateSourceFile?: boolean;
|
|
51
|
+
}
|
|
52
|
+
type ConvertToTSXOptions = Pick<TransformOptions, 'filename' | 'normalizedFilename'>;
|
|
53
|
+
type HoistedScript = {
|
|
54
|
+
type: string;
|
|
55
|
+
} & ({
|
|
56
|
+
type: 'external';
|
|
57
|
+
src: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'inline';
|
|
60
|
+
code: string;
|
|
61
|
+
map: string;
|
|
62
|
+
});
|
|
63
|
+
interface HydratedComponent {
|
|
64
|
+
exportName: string;
|
|
65
|
+
specifier: string;
|
|
66
|
+
resolvedPath: string;
|
|
67
|
+
}
|
|
68
|
+
interface TransformResult {
|
|
69
|
+
code: string;
|
|
70
|
+
map: string;
|
|
71
|
+
scope: string;
|
|
72
|
+
styleError: string[];
|
|
73
|
+
diagnostics: DiagnosticMessage[];
|
|
74
|
+
css: string[];
|
|
75
|
+
scripts: HoistedScript[];
|
|
76
|
+
hydratedComponents: HydratedComponent[];
|
|
77
|
+
clientOnlyComponents: HydratedComponent[];
|
|
78
|
+
containsHead: boolean;
|
|
79
|
+
propagation: boolean;
|
|
80
|
+
}
|
|
81
|
+
interface SourceMap {
|
|
82
|
+
file: string;
|
|
83
|
+
mappings: string;
|
|
84
|
+
names: string[];
|
|
85
|
+
sources: string[];
|
|
86
|
+
sourcesContent: string[];
|
|
87
|
+
version: number;
|
|
88
|
+
}
|
|
89
|
+
interface TSXResult {
|
|
90
|
+
code: string;
|
|
91
|
+
map: SourceMap;
|
|
92
|
+
diagnostics: DiagnosticMessage[];
|
|
93
|
+
}
|
|
94
|
+
interface ParseResult {
|
|
95
|
+
ast: RootNode;
|
|
96
|
+
diagnostics: DiagnosticMessage[];
|
|
97
|
+
}
|
|
98
|
+
declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
|
|
99
|
+
declare function parse(input: string, options?: ParseOptions): Promise<ParseResult>;
|
|
100
|
+
declare function convertToTSX(input: string, options?: ConvertToTSXOptions): Promise<TSXResult>;
|
|
101
|
+
declare function initialize(options: InitializeOptions): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* When calling the core compiler APIs, e.g. `transform`, `parse`, etc, they
|
|
104
|
+
* would automatically instantiate a WASM instance to process the input. When
|
|
105
|
+
* done, you can call this to manually teardown the WASM instance.
|
|
106
|
+
*
|
|
107
|
+
* If the APIs are called again, they will automatically instantiate a new WASM
|
|
108
|
+
* instance. In browsers, you have to call `initialize()` again before using the APIs.
|
|
109
|
+
*
|
|
110
|
+
* Note: Calling teardown is optional and exists mostly as an optimization only.
|
|
111
|
+
*/
|
|
112
|
+
declare function teardown(): void;
|
|
113
|
+
interface InitializeOptions {
|
|
114
|
+
wasmURL?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { ConvertToTSXOptions, DiagnosticLocation, DiagnosticMessage, DiagnosticSeverity, HoistedScript, HydratedComponent, InitializeOptions, ParseOptions, ParseResult, PreprocessorError, PreprocessorResult, RootNode, SourceMap, TSXResult, TransformOptions, TransformResult, convertToTSX, initialize, parse, teardown, transform };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=(e=>(e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Information=3]="Information",e[e.Hint=4]="Hint",e))(t||{});export{t as DiagnosticSeverity};
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@astrojs/compiler",
|
|
3
|
+
"author": "withastro",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bugs": "https://github.com/withastro/compiler/issues",
|
|
7
|
+
"homepage": "https://astro.build",
|
|
8
|
+
"version": "0.0.0-compact-20231220212312",
|
|
9
|
+
"main": "./dist/node/index.js",
|
|
10
|
+
"types": "./dist/shared/types.d.ts",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/withastro/compiler.git"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"types.d.ts",
|
|
18
|
+
"utils.d.ts",
|
|
19
|
+
"sync.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/node/index.d.ts",
|
|
24
|
+
"browser": "./dist/browser/index.js",
|
|
25
|
+
"import": "./dist/node/index.js",
|
|
26
|
+
"require": "./dist/node/index.cjs",
|
|
27
|
+
"default": "./dist/browser/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./sync": {
|
|
30
|
+
"types": "./dist/node/sync.d.ts",
|
|
31
|
+
"import": "./dist/node/sync.js",
|
|
32
|
+
"require": "./dist/node/sync.cjs",
|
|
33
|
+
"default": "./dist/node/sync.js"
|
|
34
|
+
},
|
|
35
|
+
"./utils": {
|
|
36
|
+
"types": "./dist/node/utils.d.ts",
|
|
37
|
+
"browser": "./dist/browser/utils.js",
|
|
38
|
+
"import": "./dist/node/utils.js",
|
|
39
|
+
"require": "./dist/node/utils.cjs",
|
|
40
|
+
"default": "./dist/browser/utils.js"
|
|
41
|
+
},
|
|
42
|
+
"./astro.wasm": "./dist/astro.wasm",
|
|
43
|
+
"./types": "./dist/shared/types.d.ts",
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@jridgewell/trace-mapping": "^0.3.16",
|
|
48
|
+
"@types/node": "^18.15.11",
|
|
49
|
+
"@types/sass": "^1.43.1",
|
|
50
|
+
"acorn": "^8.8.1",
|
|
51
|
+
"esbuild": "^0.17.17",
|
|
52
|
+
"tsup": "^6.7.0",
|
|
53
|
+
"typescript": "~5.0.2"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/sync.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/node/sync.js';
|
package/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './dist/shared/types.js';
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/node/utils.js';
|