Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.

This commit is contained in:
becarta
2025-05-23 12:43:00 +02:00
parent f40db0f5c9
commit a544759a3b
11127 changed files with 1647032 additions and 0 deletions

53
node_modules/@astrojs/compiler/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,53 @@
MIT License
Copyright (c) 2021 [Astro contributors](https://github.com/withastro/compiler/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
This license applies to parts of the `internal/` subdirectory originating from
the https://cs.opensource.google/go/x/net/+/master:html/ repository:
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

66
node_modules/@astrojs/compiler/README.md generated vendored Normal file
View File

@@ -0,0 +1,66 @@
# Astro Compiler
Astros [Go](https://golang.org/) + WASM compiler.
## Install
```
npm install @astrojs/compiler
```
## Usage
#### Transform `.astro` to valid TypeScript
The Astro compiler can convert `.astro` syntax to a TypeScript Module whose default export generates HTML.
**Some notes**...
- TypeScript is valid `.astro` syntax! The output code may need an additional post-processing step to generate valid JavaScript.
- `.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.
```js
import { transform, type TransformResult } from "@astrojs/compiler";
const result = await transform(source, {
filename: "/Users/astro/Code/project/src/pages/index.astro",
sourcemap: "both",
internalURL: "astro/runtime/server/index.js",
});
```
#### Parse `.astro` and return an AST
The Astro compiler can emit an AST using the `parse` method.
**Some notes**...
- Position data is currently incomplete and in some cases incorrect. We're working on it!
- A `TextNode` can represent both HTML `text` and JavaScript/TypeScript source code.
- 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`.
```js
import { parse } from "@astrojs/compiler";
import { walk, is } from "@astrojs/compiler/utils";
const result = await parse(source, {
position: false, // defaults to `true`
});
walk(result.ast, (node) => {
// `tag` nodes are `element` | `custom-element` | `component`
if (is.tag(node)) {
console.log(node.name);
}
});
```
## Develop
### VSCode / CodeSpaces
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.
## Contributing
[CONTRIBUTING.md](/CONTRIBUTING.md)

BIN
node_modules/@astrojs/compiler/dist/astro.wasm generated vendored Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

11
node_modules/@astrojs/compiler/dist/browser/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
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';
import '../shared/ast.js';
import '../shared/diagnostics.js';
declare const transform: typeof transform$1;
declare const parse: typeof parse$1;
declare const convertToTSX: typeof convertToTSX$1;
declare const teardown: typeof teardown$1;
declare const initialize: typeof initialize$1;
export { convertToTSX, initialize, parse, teardown, transform };

1
node_modules/@astrojs/compiler/dist/browser/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
import{a as f}from"../chunk-QR6QDSEV.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};

View File

@@ -0,0 +1,3 @@
"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,a)=>{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:!(a=d(e,r))||a.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 n(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:n("root"),element:n("element"),customElement:n("custom-element"),component:n("component"),fragment:n("fragment"),expression:n("expression"),text:n("text"),doctype:n("doctype"),comment:n("comment"),frontmatter:n("frontmatter")},m=class{constructor(e){this.callback=e}async visit(e,t,a){if(await this.callback(e,t,a),s.parent(e)){let r=[];for(let i=0;i<e.children.length;i++){let c=e.children[i];r.push(this.callback(c,e,i))}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 a(r){if(s.root(r))for(let i of r.children)a(i);else if(s.frontmatter(r))t+=`---${r.value}---
`;else if(s.comment(r))t+=`<!--${r.value}-->`;else if(s.expression(r)){t+="{";for(let i of r.children)a(i);t+="}"}else if(s.literal(r))t+=r.value;else if(s.tag(r))if(t+=`<${r.name}`,t+=x(r),r.children.length===0&&e.selfClose)t+=" />";else{t+=">";for(let i of r.children)a(i);t+=`</${r.name}>`}}return a(o),t}0&&(module.exports={is,serialize,walk});

28
node_modules/@astrojs/compiler/dist/browser/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import { Node, ParentNode, LiteralNode, TagLikeNode, TextNode, RootNode, ElementNode, CustomElementNode, ComponentNode, FragmentNode, ExpressionNode, DoctypeNode, CommentNode, FrontmatterNode } from '../shared/ast.js';
type Visitor = (node: Node, parent?: ParentNode, index?: number) => void | Promise<void>;
declare const is: {
parent(node: Node): node is ParentNode;
literal(node: Node): node is LiteralNode;
tag(node: Node): node is TagLikeNode;
whitespace(node: Node): node is TextNode;
root: (node: Node) => node is RootNode;
element: (node: Node) => node is ElementNode;
customElement: (node: Node) => node is CustomElementNode;
component: (node: Node) => node is ComponentNode;
fragment: (node: Node) => node is FragmentNode;
expression: (node: Node) => node is ExpressionNode;
text: (node: Node) => node is TextNode;
doctype: (node: Node) => node is DoctypeNode;
comment: (node: Node) => node is CommentNode;
frontmatter: (node: Node) => node is FrontmatterNode;
};
declare function walk(node: ParentNode, callback: Visitor): void;
interface SerializeOptions {
selfClose: boolean;
}
/** @deprecated Please use `SerializeOptions` */
type SerializeOtions = SerializeOptions;
declare function serialize(root: Node, opts?: SerializeOptions): string;
export { SerializeOptions, SerializeOtions, Visitor, is, serialize, walk };

3
node_modules/@astrojs/compiler/dist/browser/utils.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
function n(o){return t=>t.type===o}var a={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:n("root"),element:n("element"),customElement:n("custom-element"),component:n("component"),fragment:n("fragment"),expression:n("expression"),text:n("text"),doctype:n("doctype"),comment:n("comment"),frontmatter:n("frontmatter")},l=class{constructor(t){this.callback=t}async visit(t,e,s){if(await this.callback(t,e,s),a.parent(t)){let r=[];for(let i=0;i<t.children.length;i++){let m=t.children[i];r.push(this.callback(m,t,i))}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){if(a.root(r))for(let i of r.children)s(i);else if(a.frontmatter(r))e+=`---${r.value}---
`;else if(a.comment(r))e+=`<!--${r.value}-->`;else if(a.expression(r)){e+="{";for(let i of r.children)s(i);e+="}"}else if(a.literal(r))e+=r.value;else if(a.tag(r))if(e+=`<${r.name}`,e+=c(r),r.children.length===0&&t.selfClose)e+=" />";else{e+=">";for(let i of r.children)s(i);e+=`</${r.name}>`}}return s(o),e}export{a as is,u as serialize,N as walk};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
declare class Go {
importObject: {
gojs: {
'runtime.wasmExit': (sp: any) => void;
'runtime.wasmWrite': (sp: any) => void;
'runtime.resetMemoryDataView': (sp: any) => void;
'runtime.nanotime1': (sp: any) => void;
'runtime.walltime': (sp: any) => void;
'runtime.scheduleTimeoutEvent': (sp: any) => void;
'runtime.clearTimeoutEvent': (sp: any) => void;
'runtime.getRandomData': (sp: any) => void;
'syscall/js.finalizeRef': (sp: any) => void;
'syscall/js.stringVal': (sp: any) => void;
'syscall/js.valueGet': (sp: any) => void;
'syscall/js.valueSet': (sp: any) => void;
'syscall/js.valueDelete': (sp: any) => void;
'syscall/js.valueIndex': (sp: any) => void;
'syscall/js.valueSetIndex': (sp: any) => void;
'syscall/js.valueCall': (sp: any) => void;
'syscall/js.valueInvoke': (sp: any) => void;
'syscall/js.valueNew': (sp: any) => void;
'syscall/js.valueLength': (sp: any) => void;
'syscall/js.valuePrepareString': (sp: any) => void;
'syscall/js.valueLoadString': (sp: any) => void;
'syscall/js.valueInstanceOf': (sp: any) => void;
'syscall/js.copyBytesToGo': (sp: any) => void;
'syscall/js.copyBytesToJS': (sp: any) => void;
debug: (value: any) => void;
};
};
constructor();
run(instance: any): Promise<void>;
private _resume;
private _makeFuncWrapper;
}
export { Go as default };

View File

@@ -0,0 +1 @@
import{a}from"../chunk-QR6QDSEV.js";export{a as default};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
node_modules/@astrojs/compiler/dist/node/index.cjs generated vendored Normal file

File diff suppressed because one or more lines are too long

12
node_modules/@astrojs/compiler/dist/node/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { transform as transform$1, parse as parse$1, convertToTSX as convertToTSX$1, teardown as teardown$1 } from '../shared/types.js';
export { HoistedScript, ParseOptions, ParseResult, PreprocessorResult, TransformOptions, TransformResult } from '../shared/types.js';
import '../shared/ast.js';
import '../shared/diagnostics.js';
declare const transform: typeof transform$1;
declare const parse: typeof parse$1;
declare const convertToTSX: typeof convertToTSX$1;
declare const compile: (template: string) => Promise<string>;
declare const teardown: typeof teardown$1;
export { compile, convertToTSX, parse, teardown, transform };

1
node_modules/@astrojs/compiler/dist/node/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
import{a as c}from"../chunk-W5DTLHV4.js";import{promises as m}from"fs";import{fileURLToPath as f}from"url";var w=async(t,s)=>i().then(r=>r.transform(t,s)),l=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,l as parse,g as teardown,w as transform};

1
node_modules/@astrojs/compiler/dist/node/sync.cjs generated vendored Normal file

File diff suppressed because one or more lines are too long

16
node_modules/@astrojs/compiler/dist/node/sync.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import { TransformOptions, TransformResult, ParseOptions, ParseResult, ConvertToTSXOptions, TSXResult, transform as transform$1, parse as parse$1, convertToTSX as convertToTSX$1 } from '../shared/types.js';
import '../shared/ast.js';
import '../shared/diagnostics.js';
type UnwrappedPromise<T> = T extends (...params: any) => Promise<infer Return> ? (...params: Parameters<T>) => Return : T;
interface Service {
transform: UnwrappedPromise<typeof transform$1>;
parse: UnwrappedPromise<typeof parse$1>;
convertToTSX: UnwrappedPromise<typeof convertToTSX$1>;
}
declare const transform: (input: string, options: TransformOptions | undefined) => TransformResult;
declare const parse: (input: string, options: ParseOptions | undefined) => ParseResult;
declare const convertToTSX: (input: string, options: ConvertToTSXOptions | undefined) => TSXResult;
declare function startRunningService(): Service;
export { convertToTSX, parse, startRunningService, transform };

1
node_modules/@astrojs/compiler/dist/node/sync.js generated vendored Normal file
View File

@@ -0,0 +1 @@
import{a as c}from"../chunk-W5DTLHV4.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};

3
node_modules/@astrojs/compiler/dist/node/utils.cjs generated vendored Normal file
View File

@@ -0,0 +1,3 @@
"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,a)=>{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:!(a=d(e,r))||a.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 n(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:n("root"),element:n("element"),customElement:n("custom-element"),component:n("component"),fragment:n("fragment"),expression:n("expression"),text:n("text"),doctype:n("doctype"),comment:n("comment"),frontmatter:n("frontmatter")},m=class{constructor(e){this.callback=e}async visit(e,t,a){if(await this.callback(e,t,a),s.parent(e)){let r=[];for(let i=0;i<e.children.length;i++){let c=e.children[i];r.push(this.callback(c,e,i))}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 a(r){if(s.root(r))for(let i of r.children)a(i);else if(s.frontmatter(r))t+=`---${r.value}---
`;else if(s.comment(r))t+=`<!--${r.value}-->`;else if(s.expression(r)){t+="{";for(let i of r.children)a(i);t+="}"}else if(s.literal(r))t+=r.value;else if(s.tag(r))if(t+=`<${r.name}`,t+=x(r),r.children.length===0&&e.selfClose)t+=" />";else{t+=">";for(let i of r.children)a(i);t+=`</${r.name}>`}}return a(o),t}0&&(module.exports={is,serialize,walk});

28
node_modules/@astrojs/compiler/dist/node/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import { Node, ParentNode, LiteralNode, TagLikeNode, TextNode, RootNode, ElementNode, CustomElementNode, ComponentNode, FragmentNode, ExpressionNode, DoctypeNode, CommentNode, FrontmatterNode } from '../shared/ast.js';
type Visitor = (node: Node, parent?: ParentNode, index?: number) => void | Promise<void>;
declare const is: {
parent(node: Node): node is ParentNode;
literal(node: Node): node is LiteralNode;
tag(node: Node): node is TagLikeNode;
whitespace(node: Node): node is TextNode;
root: (node: Node) => node is RootNode;
element: (node: Node) => node is ElementNode;
customElement: (node: Node) => node is CustomElementNode;
component: (node: Node) => node is ComponentNode;
fragment: (node: Node) => node is FragmentNode;
expression: (node: Node) => node is ExpressionNode;
text: (node: Node) => node is TextNode;
doctype: (node: Node) => node is DoctypeNode;
comment: (node: Node) => node is CommentNode;
frontmatter: (node: Node) => node is FrontmatterNode;
};
declare function walk(node: ParentNode, callback: Visitor): void;
interface SerializeOptions {
selfClose: boolean;
}
/** @deprecated Please use `SerializeOptions` */
type SerializeOtions = SerializeOptions;
declare function serialize(root: Node, opts?: SerializeOptions): string;
export { SerializeOptions, SerializeOtions, Visitor, is, serialize, walk };

3
node_modules/@astrojs/compiler/dist/node/utils.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
function n(o){return t=>t.type===o}var a={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:n("root"),element:n("element"),customElement:n("custom-element"),component:n("component"),fragment:n("fragment"),expression:n("expression"),text:n("text"),doctype:n("doctype"),comment:n("comment"),frontmatter:n("frontmatter")},l=class{constructor(t){this.callback=t}async visit(t,e,s){if(await this.callback(t,e,s),a.parent(t)){let r=[];for(let i=0;i<t.children.length;i++){let m=t.children[i];r.push(this.callback(m,t,i))}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){if(a.root(r))for(let i of r.children)s(i);else if(a.frontmatter(r))e+=`---${r.value}---
`;else if(a.comment(r))e+=`<!--${r.value}-->`;else if(a.expression(r)){e+="{";for(let i of r.children)s(i);e+="}"}else if(a.literal(r))e+=r.value;else if(a.tag(r))if(e+=`<${r.name}`,e+=c(r),r.children.length===0&&t.selfClose)e+=" />";else{e+=">";for(let i of r.children)s(i);e+=`</${r.name}>`}}return s(o),e}export{a as is,u as serialize,N as walk};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
declare class Go {
importObject: {
gojs: {
'runtime.wasmExit': (sp: any) => void;
'runtime.wasmWrite': (sp: any) => void;
'runtime.resetMemoryDataView': (sp: any) => void;
'runtime.nanotime1': (sp: any) => void;
'runtime.walltime': (sp: any) => void;
'runtime.scheduleTimeoutEvent': (sp: any) => void;
'runtime.clearTimeoutEvent': (sp: any) => void;
'runtime.getRandomData': (sp: any) => void;
'syscall/js.finalizeRef': (sp: any) => void;
'syscall/js.stringVal': (sp: any) => void;
'syscall/js.valueGet': (sp: any) => void;
'syscall/js.valueSet': (sp: any) => void;
'syscall/js.valueDelete': (sp: any) => void;
'syscall/js.valueIndex': (sp: any) => void;
'syscall/js.valueSetIndex': (sp: any) => void;
'syscall/js.valueCall': (sp: any) => void;
'syscall/js.valueInvoke': (sp: any) => void;
'syscall/js.valueNew': (sp: any) => void;
'syscall/js.valueLength': (sp: any) => void;
'syscall/js.valuePrepareString': (sp: any) => void;
'syscall/js.valueLoadString': (sp: any) => void;
'syscall/js.valueInstanceOf': (sp: any) => void;
'syscall/js.copyBytesToGo': (sp: any) => void;
'syscall/js.copyBytesToJS': (sp: any) => void;
debug: (value: any) => void;
};
};
constructor();
run(instance: any): Promise<void>;
private _resume;
private _makeFuncWrapper;
}
export { Go as default };

View File

@@ -0,0 +1 @@
import{a}from"../chunk-W5DTLHV4.js";export{a as default};

1
node_modules/@astrojs/compiler/dist/shared/ast.cjs generated vendored Normal file
View File

@@ -0,0 +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);

74
node_modules/@astrojs/compiler/dist/shared/ast.d.ts generated vendored Normal file
View File

@@ -0,0 +1,74 @@
type ParentNode = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode;
type LiteralNode = TextNode | DoctypeNode | CommentNode | FrontmatterNode;
type Node = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode | TextNode | FrontmatterNode | DoctypeNode | CommentNode;
interface Position {
start: Point;
end?: Point;
}
interface Point {
/** 1-based line number */
line: number;
/** 1-based column number, per-line */
column: number;
/** 0-based byte offset */
offset: number;
}
interface BaseNode {
type: string;
position?: Position;
}
interface ParentLikeNode extends BaseNode {
type: 'element' | 'component' | 'custom-element' | 'fragment' | 'expression' | 'root';
children: Node[];
}
interface ValueNode extends BaseNode {
value: string;
}
interface RootNode extends ParentLikeNode {
type: 'root';
}
interface AttributeNode extends BaseNode {
type: 'attribute';
kind: 'quoted' | 'empty' | 'expression' | 'spread' | 'shorthand' | 'template-literal';
name: string;
value: string;
raw?: string;
}
interface TextNode extends ValueNode {
type: 'text';
}
interface ElementNode extends ParentLikeNode {
type: 'element';
name: string;
attributes: AttributeNode[];
}
interface FragmentNode extends ParentLikeNode {
type: 'fragment';
name: string;
attributes: AttributeNode[];
}
interface ComponentNode extends ParentLikeNode {
type: 'component';
name: string;
attributes: AttributeNode[];
}
interface CustomElementNode extends ParentLikeNode {
type: 'custom-element';
name: string;
attributes: AttributeNode[];
}
type TagLikeNode = ElementNode | FragmentNode | ComponentNode | CustomElementNode;
interface DoctypeNode extends ValueNode {
type: 'doctype';
}
interface CommentNode extends ValueNode {
type: 'comment';
}
interface FrontmatterNode extends ValueNode {
type: 'frontmatter';
}
interface ExpressionNode extends ParentLikeNode {
type: 'expression';
}
export { AttributeNode, BaseNode, CommentNode, ComponentNode, CustomElementNode, DoctypeNode, ElementNode, ExpressionNode, FragmentNode, FrontmatterNode, LiteralNode, Node, ParentLikeNode, ParentNode, Point, Position, RootNode, TagLikeNode, TextNode, ValueNode };

0
node_modules/@astrojs/compiler/dist/shared/ast.js generated vendored Normal file
View File

View File

@@ -0,0 +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});

View File

@@ -0,0 +1,18 @@
declare enum DiagnosticCode {
ERROR = 1000,
ERROR_UNTERMINATED_JS_COMMENT = 1001,
ERROR_FRAGMENT_SHORTHAND_ATTRS = 1002,
ERROR_UNMATCHED_IMPORT = 1003,
ERROR_UNSUPPORTED_SLOT_ATTRIBUTE = 1004,
WARNING = 2000,
WARNING_UNTERMINATED_HTML_COMMENT = 2001,
WARNING_UNCLOSED_HTML_TAG = 2002,
WARNING_DEPRECATED_DIRECTIVE = 2003,
WARNING_IGNORED_DIRECTIVE = 2004,
WARNING_UNSUPPORTED_EXPRESSION = 2005,
WARNING_SET_WITH_CHILDREN = 2006,
INFO = 3000,
HINT = 4000
}
export { DiagnosticCode };

View File

@@ -0,0 +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};

1
node_modules/@astrojs/compiler/dist/shared/types.cjs generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(r,t)=>{for(var n in t)o(r,n,{get:t[n],enumerable:!0})},g=(r,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of p(t))!c.call(r,e)&&e!==n&&o(r,e,{get:()=>t[e],enumerable:!(s=a(t,e))||s.enumerable});return r};var d=r=>g(o({},"__esModule",{value:!0}),r);var m={};l(m,{DiagnosticSeverity:()=>i});module.exports=d(m);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});

160
node_modules/@astrojs/compiler/dist/shared/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,160 @@
import { RootNode } from './ast.js';
export { AttributeNode, BaseNode, CommentNode, ComponentNode, CustomElementNode, DoctypeNode, ElementNode, ExpressionNode, FragmentNode, FrontmatterNode, LiteralNode, Node, ParentLikeNode, ParentNode, Point, Position, TagLikeNode, TextNode, ValueNode } from './ast.js';
import { DiagnosticCode } from './diagnostics.js';
interface PreprocessorResult {
code: string;
map?: string;
}
interface PreprocessorError {
error: string;
}
interface ParseOptions {
position?: boolean;
}
declare enum DiagnosticSeverity {
Error = 1,
Warning = 2,
Information = 3,
Hint = 4
}
interface DiagnosticMessage {
severity: DiagnosticSeverity;
code: DiagnosticCode;
location: DiagnosticLocation;
hint?: string;
text: string;
}
interface DiagnosticLocation {
file: string;
line: number;
column: number;
length: number;
}
interface TransformOptions {
internalURL?: string;
filename?: string;
normalizedFilename?: string;
sourcemap?: boolean | 'inline' | 'external' | 'both';
astroGlobalArgs?: string;
compact?: boolean;
resultScopedSlot?: boolean;
scopedStyleStrategy?: 'where' | 'class' | 'attribute';
/**
* @deprecated "as" has been removed and no longer has any effect!
*/
as?: 'document' | 'fragment';
transitionsAnimationURL?: string;
resolvePath?: (specifier: string) => Promise<string> | string;
preprocessStyle?: (content: string, attrs: Record<string, string>) => null | Promise<PreprocessorResult | PreprocessorError>;
annotateSourceFile?: boolean;
/**
* Render script tags to be processed (e.g. script tags that have no attributes or only a `src` attribute)
* using a `renderScript` function from `internalURL`, instead of stripping the script entirely.
* @experimental
*/
renderScript?: boolean;
experimentalScriptOrder?: boolean;
}
type ConvertToTSXOptions = Pick<TransformOptions, 'filename' | 'normalizedFilename' | 'sourcemap'> & {
/** If set to true, script tags content will be included in the generated TSX
* Scripts will be wrapped in an arrow function to be compatible with JSX's spec
*/
includeScripts?: boolean;
/** If set to true, style tags content will be included in the generated TSX
* Styles will be wrapped in a template literal to be compatible with JSX's spec
*/
includeStyles?: boolean;
};
type HoistedScript = {
type: string;
} & ({
type: 'external';
src: string;
} | {
type: 'inline';
code: string;
map: string;
});
interface HydratedComponent {
exportName: string;
localName: string;
specifier: string;
resolvedPath: string;
}
interface TransformResult {
code: string;
map: string;
scope: string;
styleError: string[];
diagnostics: DiagnosticMessage[];
css: string[];
scripts: HoistedScript[];
hydratedComponents: HydratedComponent[];
clientOnlyComponents: HydratedComponent[];
serverComponents: HydratedComponent[];
containsHead: boolean;
propagation: boolean;
}
interface SourceMap {
file: string;
mappings: string;
names: string[];
sources: string[];
sourcesContent: string[];
version: number;
}
/**
* Represents a location in a TSX file.
* Both the `start` and `end` properties are 0-based, and are based off utf-16 code units. (i.e. JavaScript's `String.prototype.length`)
*/
interface TSXLocation {
start: number;
end: number;
}
interface TSXExtractedTag {
position: TSXLocation;
content: string;
}
interface TSXExtractedScript extends TSXExtractedTag {
type: 'processed-module' | 'module' | 'inline' | 'event-attribute' | 'json' | 'raw' | 'unknown';
}
interface TSXExtractedStyle extends TSXExtractedTag {
type: 'tag' | 'style-attribute';
lang: 'css' | 'scss' | 'sass' | 'less' | 'stylus' | 'styl' | 'postcss' | 'pcss' | 'unknown' | (string & {});
}
interface TSXResult {
code: string;
map: SourceMap;
diagnostics: DiagnosticMessage[];
metaRanges: {
frontmatter: TSXLocation;
body: TSXLocation;
scripts?: TSXExtractedScript[];
styles?: TSXExtractedStyle[];
};
}
interface ParseResult {
ast: RootNode;
diagnostics: DiagnosticMessage[];
}
declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
declare function parse(input: string, options?: ParseOptions): Promise<ParseResult>;
declare function convertToTSX(input: string, options?: ConvertToTSXOptions): Promise<TSXResult>;
declare function initialize(options: InitializeOptions): Promise<void>;
/**
* When calling the core compiler APIs, e.g. `transform`, `parse`, etc, they
* would automatically instantiate a WASM instance to process the input. When
* done, you can call this to manually teardown the WASM instance.
*
* If the APIs are called again, they will automatically instantiate a new WASM
* instance. In browsers, you have to call `initialize()` again before using the APIs.
*
* Note: Calling teardown is optional and exists mostly as an optimization only.
*/
declare function teardown(): void;
interface InitializeOptions {
wasmURL?: string;
}
export { ConvertToTSXOptions, DiagnosticLocation, DiagnosticMessage, DiagnosticSeverity, HoistedScript, HydratedComponent, InitializeOptions, ParseOptions, ParseResult, PreprocessorError, PreprocessorResult, RootNode, SourceMap, TSXExtractedScript, TSXExtractedStyle, TSXExtractedTag, TSXLocation, TSXResult, TransformOptions, TransformResult, convertToTSX, initialize, parse, teardown, transform };

1
node_modules/@astrojs/compiler/dist/shared/types.js generated vendored Normal file
View File

@@ -0,0 +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};

58
node_modules/@astrojs/compiler/package.json generated vendored Normal file
View File

@@ -0,0 +1,58 @@
{
"name": "@astrojs/compiler",
"author": "withastro",
"license": "MIT",
"type": "module",
"bugs": "https://github.com/withastro/compiler/issues",
"homepage": "https://astro.build",
"version": "2.12.0",
"main": "./dist/node/index.js",
"types": "./dist/shared/types.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/withastro/compiler.git"
},
"files": [
"dist",
"types.d.ts",
"utils.d.ts",
"sync.d.ts"
],
"exports": {
".": {
"types": "./dist/node/index.d.ts",
"browser": "./dist/browser/index.js",
"import": "./dist/node/index.js",
"require": "./dist/node/index.cjs",
"default": "./dist/browser/index.js"
},
"./sync": {
"types": "./dist/node/sync.d.ts",
"import": "./dist/node/sync.js",
"require": "./dist/node/sync.cjs",
"default": "./dist/node/sync.js"
},
"./utils": {
"types": "./dist/node/utils.d.ts",
"browser": "./dist/browser/utils.js",
"import": "./dist/node/utils.js",
"require": "./dist/node/utils.cjs",
"default": "./dist/browser/utils.js"
},
"./astro.wasm": "./dist/astro.wasm",
"./types": "./dist/shared/types.d.ts",
"./package.json": "./package.json"
},
"devDependencies": {
"@jridgewell/trace-mapping": "^0.3.16",
"@types/node": "^18.15.11",
"@types/sass": "^1.43.1",
"acorn": "^8.8.1",
"esbuild": "^0.17.17",
"tsup": "^6.7.0",
"typescript": "~5.0.2"
},
"scripts": {
"build": "tsup"
}
}

1
node_modules/@astrojs/compiler/sync.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/node/sync.js';

1
node_modules/@astrojs/compiler/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export type * from './dist/shared/types.js';

1
node_modules/@astrojs/compiler/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/node/utils.js';

59
node_modules/@astrojs/internal-helpers/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,59 @@
MIT License
Copyright (c) 2021 Fred K. Schott
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
MIT License
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

15
node_modules/@astrojs/internal-helpers/dist/fs.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import type { PathLike } from 'node:fs';
export declare function writeJson<T>(path: PathLike, data: T): Promise<void>;
export declare function removeDir(dir: PathLike): Promise<void>;
export declare function emptyDir(dir: PathLike): Promise<void>;
export declare function getFilesFromFolder(dir: URL): Promise<URL[]>;
/**
* Copies files into a folder keeping the folder structure intact.
* The resulting file tree will start at the common ancestor.
*
* @param {URL[]} files A list of files to copy (absolute path).
* @param {URL} outDir Destination folder where to copy the files to (absolute path).
* @param {URL[]} [exclude] A list of files to exclude (absolute path).
* @returns {Promise<string>} The common ancestor of the copied files.
*/
export declare function copyFilesToFolder(files: URL[], outDir: URL, exclude?: URL[]): Promise<string>;

66
node_modules/@astrojs/internal-helpers/dist/fs.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
import { existsSync } from "node:fs";
import * as fs from "node:fs/promises";
import nodePath from "node:path";
import { fileURLToPath } from "node:url";
async function writeJson(path, data) {
await fs.writeFile(path, JSON.stringify(data, null, " "), { encoding: "utf-8" });
}
async function removeDir(dir) {
await fs.rm(dir, { recursive: true, force: true, maxRetries: 3 });
}
async function emptyDir(dir) {
await removeDir(dir);
await fs.mkdir(dir, { recursive: true });
}
async function getFilesFromFolder(dir) {
const data = await fs.readdir(dir, { withFileTypes: true });
let files = [];
for (const item of data) {
if (item.isDirectory()) {
const moreFiles = await getFilesFromFolder(new URL(`./${item.name}/`, dir));
files = files.concat(moreFiles);
} else {
files.push(new URL(`./${item.name}`, dir));
}
}
return files;
}
async function copyFilesToFolder(files, outDir, exclude = []) {
const excludeList = exclude.map(fileURLToPath);
const fileList = files.map(fileURLToPath).filter((f) => !excludeList.includes(f));
if (files.length === 0) throw new Error("No files found to copy");
let commonAncestor = nodePath.dirname(fileList[0]);
for (const file of fileList.slice(1)) {
while (!file.startsWith(commonAncestor)) {
commonAncestor = nodePath.dirname(commonAncestor);
}
}
for (const origin of fileList) {
const dest = new URL(nodePath.relative(commonAncestor, origin), outDir);
const realpath = await fs.realpath(origin);
const isSymlink = realpath !== origin;
const isDir = (await fs.stat(origin)).isDirectory();
if (isDir && !isSymlink) {
await fs.mkdir(new URL("..", dest), { recursive: true });
} else {
await fs.mkdir(new URL(".", dest), { recursive: true });
}
if (isSymlink) {
const realdest = fileURLToPath(new URL(nodePath.relative(commonAncestor, realpath), outDir));
const target = nodePath.relative(fileURLToPath(new URL(".", dest)), realdest);
if (!existsSync(dest)) {
await fs.symlink(target, dest, isDir ? "dir" : "file");
}
} else if (!isDir) {
await fs.copyFile(origin, dest);
}
}
return commonAncestor;
}
export {
copyFilesToFolder,
emptyDir,
getFilesFromFolder,
removeDir,
writeJson
};

23
node_modules/@astrojs/internal-helpers/dist/path.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/**
* A set of common path utilities commonly used through the Astro core and integration
* projects. These do things like ensure a forward slash prepends paths.
*/
export declare function appendExtension(path: string, extension: string): string;
export declare function appendForwardSlash(path: string): string;
export declare function prependForwardSlash(path: string): string;
export declare function collapseDuplicateSlashes(path: string): string;
export declare function removeTrailingForwardSlash(path: string): string;
export declare function removeLeadingForwardSlash(path: string): string;
export declare function removeLeadingForwardSlashWindows(path: string): string;
export declare function trimSlashes(path: string): string;
export declare function startsWithForwardSlash(path: string): boolean;
export declare function startsWithDotDotSlash(path: string): boolean;
export declare function startsWithDotSlash(path: string): boolean;
export declare function isRelativePath(path: string): boolean;
export declare function joinPaths(...paths: (string | undefined)[]): string;
export declare function removeFileExtension(path: string): string;
export declare function removeQueryString(path: string): string;
export declare function isRemotePath(src: string): boolean;
export declare function slash(path: string): string;
export declare function fileExtension(path: string): string;
export declare function removeBase(path: string, base: string): string;

100
node_modules/@astrojs/internal-helpers/dist/path.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
function appendExtension(path, extension) {
return path + "." + extension;
}
function appendForwardSlash(path) {
return path.endsWith("/") ? path : path + "/";
}
function prependForwardSlash(path) {
return path[0] === "/" ? path : "/" + path;
}
function collapseDuplicateSlashes(path) {
return path.replace(/(?<!:)\/{2,}/g, "/");
}
function removeTrailingForwardSlash(path) {
return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
}
function removeLeadingForwardSlash(path) {
return path.startsWith("/") ? path.substring(1) : path;
}
function removeLeadingForwardSlashWindows(path) {
return path.startsWith("/") && path[2] === ":" ? path.substring(1) : path;
}
function trimSlashes(path) {
return path.replace(/^\/|\/$/g, "");
}
function startsWithForwardSlash(path) {
return path[0] === "/";
}
function startsWithDotDotSlash(path) {
const c1 = path[0];
const c2 = path[1];
const c3 = path[2];
return c1 === "." && c2 === "." && c3 === "/";
}
function startsWithDotSlash(path) {
const c1 = path[0];
const c2 = path[1];
return c1 === "." && c2 === "/";
}
function isRelativePath(path) {
return startsWithDotDotSlash(path) || startsWithDotSlash(path);
}
function isString(path) {
return typeof path === "string" || path instanceof String;
}
function joinPaths(...paths) {
return paths.filter(isString).map((path, i) => {
if (i === 0) {
return removeTrailingForwardSlash(path);
} else if (i === paths.length - 1) {
return removeLeadingForwardSlash(path);
} else {
return trimSlashes(path);
}
}).join("/");
}
function removeFileExtension(path) {
let idx = path.lastIndexOf(".");
return idx === -1 ? path : path.slice(0, idx);
}
function removeQueryString(path) {
const index = path.lastIndexOf("?");
return index > 0 ? path.substring(0, index) : path;
}
function isRemotePath(src) {
return /^(?:http|ftp|https|ws):?\/\//.test(src) || src.startsWith("data:");
}
function slash(path) {
return path.replace(/\\/g, "/");
}
function fileExtension(path) {
const ext = path.split(".").pop();
return ext !== path ? `.${ext}` : "";
}
function removeBase(path, base) {
if (path.startsWith(base)) {
return path.slice(removeTrailingForwardSlash(base).length);
}
return path;
}
export {
appendExtension,
appendForwardSlash,
collapseDuplicateSlashes,
fileExtension,
isRelativePath,
isRemotePath,
joinPaths,
prependForwardSlash,
removeBase,
removeFileExtension,
removeLeadingForwardSlash,
removeLeadingForwardSlashWindows,
removeQueryString,
removeTrailingForwardSlash,
slash,
startsWithDotDotSlash,
startsWithDotSlash,
startsWithForwardSlash,
trimSlashes
};

48
node_modules/@astrojs/internal-helpers/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "@astrojs/internal-helpers",
"description": "Internal helpers used by core Astro packages.",
"version": "0.4.1",
"type": "module",
"author": "withastro",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/withastro/astro.git",
"directory": "packages/internal-helpers"
},
"bugs": "https://github.com/withastro/astro/issues",
"exports": {
"./path": "./dist/path.js",
"./fs": "./dist/fs.js"
},
"typesVersions": {
"*": {
"path": [
"./dist/path.d.ts"
],
"fs": [
"./dist/fs.d.ts"
]
}
},
"files": [
"dist"
],
"devDependencies": {
"astro-scripts": "0.0.14"
},
"keywords": [
"astro",
"astro-component"
],
"publishConfig": {
"provenance": true
},
"scripts": {
"prepublish": "pnpm build",
"build": "astro-scripts build \"src/**/*.ts\" && tsc -p tsconfig.json",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"postbuild": "astro-scripts copy \"src/**/*.js\"",
"dev": "astro-scripts dev \"src/**/*.ts\""
}
}

3
node_modules/@astrojs/internal-helpers/readme.md generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# @astrojs/internal-helpers
These are internal helpers used by core Astro packages. This package does not follow semver and should not be used externally.

59
node_modules/@astrojs/markdown-remark/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,59 @@
MIT License
Copyright (c) 2021 Fred K. Schott
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
MIT License
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

View File

@@ -0,0 +1,6 @@
import type { VFileData as Data, VFile } from 'vfile';
import type { MarkdownAstroData } from './types.js';
export declare class InvalidAstroDataError extends TypeError {
}
export declare function safelyGetAstroData(vfileData: Data): MarkdownAstroData | InvalidAstroDataError;
export declare function setVfileFrontmatter(vfile: VFile, frontmatter: Record<string, any>): void;

View File

@@ -0,0 +1,31 @@
function isValidAstroData(obj) {
if (typeof obj === "object" && obj !== null && obj.hasOwnProperty("frontmatter")) {
const { frontmatter } = obj;
try {
JSON.stringify(frontmatter);
} catch {
return false;
}
return typeof frontmatter === "object" && frontmatter !== null;
}
return false;
}
class InvalidAstroDataError extends TypeError {
}
function safelyGetAstroData(vfileData) {
const { astro } = vfileData;
if (!astro || !isValidAstroData(astro)) {
return new InvalidAstroDataError();
}
return astro;
}
function setVfileFrontmatter(vfile, frontmatter) {
vfile.data ??= {};
vfile.data.astro ??= {};
vfile.data.astro.frontmatter = frontmatter;
}
export {
InvalidAstroDataError,
safelyGetAstroData,
setVfileFrontmatter
};

View File

@@ -0,0 +1,15 @@
import type { Root } from 'hast';
type Highlighter = (code: string, language: string, options?: {
meta?: string;
}) => Promise<string>;
/**
* A hast utility to syntax highlight code blocks with a given syntax highlighter.
*
* @param tree
* The hast tree in which to syntax highlight code blocks.
* @param highlighter
* A function which receives the code and language, and returns the HTML of a syntax
* highlighted `<pre>` element.
*/
export declare function highlightCodeBlocks(tree: Root, highlighter: Highlighter): Promise<void>;
export {};

View File

@@ -0,0 +1,53 @@
import { fromHtml } from "hast-util-from-html";
import { toText } from "hast-util-to-text";
import { removePosition } from "unist-util-remove-position";
import { visitParents } from "unist-util-visit-parents";
const languagePattern = /\blanguage-(\S+)\b/;
async function highlightCodeBlocks(tree, highlighter) {
const nodes = [];
visitParents(tree, { type: "element", tagName: "code" }, (node, ancestors) => {
const parent = ancestors.at(-1);
if (parent?.type !== "element" || parent.tagName !== "pre") {
return;
}
if (parent.children.length !== 1) {
return;
}
let languageMatch;
let { className } = node.properties;
if (typeof className === "string") {
languageMatch = languagePattern.exec(className);
} else if (Array.isArray(className)) {
for (const cls of className) {
if (typeof cls !== "string") {
continue;
}
languageMatch = languagePattern.exec(cls);
if (languageMatch) {
break;
}
}
}
if (languageMatch?.[1] === "math") {
return;
}
nodes.push({
node,
language: languageMatch?.[1] || "plaintext",
parent,
grandParent: ancestors.at(-2)
});
});
for (const { node, language, grandParent, parent } of nodes) {
const meta = node.data?.meta ?? node.properties.metastring ?? void 0;
const code = toText(node, { whitespace: "pre" });
const html = await highlighter(code, language, { meta });
const replacement = fromHtml(html, { fragment: true }).children[0];
removePosition(replacement);
const index = grandParent.children.indexOf(parent);
grandParent.children[index] = replacement;
}
}
export {
highlightCodeBlocks
};

View File

@@ -0,0 +1,2 @@
import type * as unified from 'unified';
export declare function importPlugin(p: string): Promise<unified.Plugin>;

View File

@@ -0,0 +1,7 @@
async function importPlugin(p) {
const importResult = await import(p);
return importResult.default;
}
export {
importPlugin
};

View File

@@ -0,0 +1,2 @@
import type * as unified from 'unified';
export declare function importPlugin(p: string): Promise<unified.Plugin>;

View File

@@ -0,0 +1,18 @@
import path from "node:path";
import { pathToFileURL } from "node:url";
import { resolve as importMetaResolve } from "import-meta-resolve";
let cwdUrlStr;
async function importPlugin(p) {
try {
const importResult2 = await import(p);
return importResult2.default;
} catch {
}
cwdUrlStr ??= pathToFileURL(path.join(process.cwd(), "package.json")).toString();
const resolved = importMetaResolve(p, cwdUrlStr);
const importResult = await import(resolved);
return importResult.default;
}
export {
importPlugin
};

13
node_modules/@astrojs/markdown-remark/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import type { AstroMarkdownOptions, MarkdownProcessor } from './types.js';
export { InvalidAstroDataError, setVfileFrontmatter } from './frontmatter-injection.js';
export { rehypeHeadingIds } from './rehype-collect-headings.js';
export { remarkCollectImages } from './remark-collect-images.js';
export { rehypePrism } from './rehype-prism.js';
export { rehypeShiki } from './rehype-shiki.js';
export { createShikiHighlighter, type ShikiHighlighter } from './shiki.js';
export * from './types.js';
export declare const markdownConfigDefaults: Required<AstroMarkdownOptions>;
/**
* Create a markdown preprocessor to render multiple markdown files
*/
export declare function createMarkdownProcessor(opts?: AstroMarkdownOptions): Promise<MarkdownProcessor>;

142
node_modules/@astrojs/markdown-remark/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,142 @@
import {
InvalidAstroDataError,
safelyGetAstroData,
setVfileFrontmatter
} from "./frontmatter-injection.js";
import { loadPlugins } from "./load-plugins.js";
import { rehypeHeadingIds } from "./rehype-collect-headings.js";
import { rehypePrism } from "./rehype-prism.js";
import { rehypeShiki } from "./rehype-shiki.js";
import { remarkCollectImages } from "./remark-collect-images.js";
import rehypeRaw from "rehype-raw";
import rehypeStringify from "rehype-stringify";
import remarkGfm from "remark-gfm";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import remarkSmartypants from "remark-smartypants";
import { unified } from "unified";
import { VFile } from "vfile";
import { rehypeImages } from "./rehype-images.js";
import { InvalidAstroDataError as InvalidAstroDataError2, setVfileFrontmatter as setVfileFrontmatter2 } from "./frontmatter-injection.js";
import { rehypeHeadingIds as rehypeHeadingIds2 } from "./rehype-collect-headings.js";
import { remarkCollectImages as remarkCollectImages2 } from "./remark-collect-images.js";
import { rehypePrism as rehypePrism2 } from "./rehype-prism.js";
import { rehypeShiki as rehypeShiki2 } from "./rehype-shiki.js";
import { createShikiHighlighter } from "./shiki.js";
export * from "./types.js";
const markdownConfigDefaults = {
syntaxHighlight: "shiki",
shikiConfig: {
langs: [],
theme: "github-dark",
themes: {},
wrap: false,
transformers: [],
langAlias: {}
},
remarkPlugins: [],
rehypePlugins: [],
remarkRehype: {},
gfm: true,
smartypants: true
};
const isPerformanceBenchmark = Boolean(process.env.ASTRO_PERFORMANCE_BENCHMARK);
async function createMarkdownProcessor(opts) {
const {
syntaxHighlight = markdownConfigDefaults.syntaxHighlight,
shikiConfig = markdownConfigDefaults.shikiConfig,
remarkPlugins = markdownConfigDefaults.remarkPlugins,
rehypePlugins = markdownConfigDefaults.rehypePlugins,
remarkRehype: remarkRehypeOptions = markdownConfigDefaults.remarkRehype,
gfm = markdownConfigDefaults.gfm,
smartypants = markdownConfigDefaults.smartypants
} = opts ?? {};
const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
const loadedRehypePlugins = await Promise.all(loadPlugins(rehypePlugins));
const parser = unified().use(remarkParse);
if (!isPerformanceBenchmark) {
if (gfm) {
parser.use(remarkGfm);
}
if (smartypants) {
parser.use(remarkSmartypants);
}
}
for (const [plugin, pluginOpts] of loadedRemarkPlugins) {
parser.use(plugin, pluginOpts);
}
if (!isPerformanceBenchmark) {
parser.use(remarkCollectImages);
}
parser.use(remarkRehype, {
allowDangerousHtml: true,
passThrough: [],
...remarkRehypeOptions
});
if (!isPerformanceBenchmark) {
if (syntaxHighlight === "shiki") {
parser.use(rehypeShiki, shikiConfig);
} else if (syntaxHighlight === "prism") {
parser.use(rehypePrism);
}
}
for (const [plugin, pluginOpts] of loadedRehypePlugins) {
parser.use(plugin, pluginOpts);
}
parser.use(rehypeImages());
if (!isPerformanceBenchmark) {
parser.use(rehypeHeadingIds);
}
parser.use(rehypeRaw).use(rehypeStringify, { allowDangerousHtml: true });
return {
async render(content, renderOpts) {
const vfile = new VFile({ value: content, path: renderOpts?.fileURL });
setVfileFrontmatter(vfile, renderOpts?.frontmatter ?? {});
const result = await parser.process(vfile).catch((err) => {
err = prefixError(err, `Failed to parse Markdown file "${vfile.path}"`);
console.error(err);
throw err;
});
const astroData = safelyGetAstroData(result.data);
if (astroData instanceof InvalidAstroDataError) {
throw astroData;
}
return {
code: String(result.value),
metadata: {
headings: result.data.__astroHeadings ?? [],
imagePaths: result.data.imagePaths ?? /* @__PURE__ */ new Set(),
frontmatter: astroData.frontmatter ?? {}
}
};
}
};
}
function prefixError(err, prefix) {
if (err?.message) {
try {
err.message = `${prefix}:
${err.message}`;
return err;
} catch {
}
}
const wrappedError = new Error(`${prefix}${err ? `: ${err}` : ""}`);
try {
wrappedError.stack = err.stack;
wrappedError.cause = err;
} catch {
}
return wrappedError;
}
export {
InvalidAstroDataError2 as InvalidAstroDataError,
createMarkdownProcessor,
createShikiHighlighter,
markdownConfigDefaults,
rehypeHeadingIds2 as rehypeHeadingIds,
rehypePrism2 as rehypePrism,
rehypeShiki2 as rehypeShiki,
remarkCollectImages2 as remarkCollectImages,
setVfileFrontmatter2 as setVfileFrontmatter
};

View File

@@ -0,0 +1 @@
export { InvalidAstroDataError, safelyGetAstroData } from './frontmatter-injection.js';

View File

@@ -0,0 +1,5 @@
import { InvalidAstroDataError, safelyGetAstroData } from "./frontmatter-injection.js";
export {
InvalidAstroDataError,
safelyGetAstroData
};

View File

@@ -0,0 +1,2 @@
import type * as unified from 'unified';
export declare function loadPlugins(items: (string | [string, any] | unified.Plugin<any[], any> | [unified.Plugin<any[], any>, any])[]): Promise<[unified.Plugin, any?]>[];

View File

@@ -0,0 +1,22 @@
import { importPlugin as _importPlugin } from "#import-plugin";
async function importPlugin(p) {
if (typeof p === "string") {
return await _importPlugin(p);
} else {
return p;
}
}
function loadPlugins(items) {
return items.map((p) => {
return new Promise((resolve, reject) => {
if (Array.isArray(p)) {
const [plugin, opts] = p;
return importPlugin(plugin).then((m) => resolve([m, opts])).catch((e) => reject(e));
}
return importPlugin(p).then((m) => resolve([m])).catch((e) => reject(e));
});
});
}
export {
loadPlugins
};

View File

@@ -0,0 +1,2 @@
import type { RehypePlugin } from './types.js';
export declare function rehypeHeadingIds(): ReturnType<RehypePlugin>;

View File

@@ -0,0 +1,90 @@
import Slugger from "github-slugger";
import { visit } from "unist-util-visit";
import { InvalidAstroDataError, safelyGetAstroData } from "./frontmatter-injection.js";
const rawNodeTypes = /* @__PURE__ */ new Set(["text", "raw", "mdxTextExpression"]);
const codeTagNames = /* @__PURE__ */ new Set(["code", "pre"]);
function rehypeHeadingIds() {
return function(tree, file) {
const headings = [];
const slugger = new Slugger();
const isMDX = isMDXFile(file);
const astroData = safelyGetAstroData(file.data);
visit(tree, (node) => {
if (node.type !== "element") return;
const { tagName } = node;
if (tagName[0] !== "h") return;
const [, level] = /h([0-6])/.exec(tagName) ?? [];
if (!level) return;
const depth = Number.parseInt(level);
let text = "";
visit(node, (child, __, parent) => {
if (child.type === "element" || parent == null) {
return;
}
if (child.type === "raw") {
if (/^\n?<.*>\n?$/.test(child.value)) {
return;
}
}
if (rawNodeTypes.has(child.type)) {
if (isMDX || codeTagNames.has(parent.tagName)) {
let value = child.value;
if (isMdxTextExpression(child) && !(astroData instanceof InvalidAstroDataError)) {
const frontmatterPath = getMdxFrontmatterVariablePath(child);
if (Array.isArray(frontmatterPath) && frontmatterPath.length > 0) {
const frontmatterValue = getMdxFrontmatterVariableValue(astroData, frontmatterPath);
if (typeof frontmatterValue === "string") {
value = frontmatterValue;
}
}
}
text += value;
} else {
text += child.value.replace(/\{/g, "${");
}
}
});
node.properties = node.properties || {};
if (typeof node.properties.id !== "string") {
let slug = slugger.slug(text);
if (slug.endsWith("-")) slug = slug.slice(0, -1);
node.properties.id = slug;
}
headings.push({ depth, slug: node.properties.id, text });
});
file.data.__astroHeadings = headings;
};
}
function isMDXFile(file) {
return Boolean(file.history[0]?.endsWith(".mdx"));
}
function getMdxFrontmatterVariablePath(node) {
if (!node.data?.estree || node.data.estree.body.length !== 1) return new Error();
const statement = node.data.estree.body[0];
if (statement?.type !== "ExpressionStatement" || statement.expression.type !== "MemberExpression")
return new Error();
let expression = statement.expression;
const expressionPath = [];
while (expression.type === "MemberExpression" && expression.property.type === (expression.computed ? "Literal" : "Identifier")) {
expressionPath.push(
expression.property.type === "Literal" ? String(expression.property.value) : expression.property.name
);
expression = expression.object;
}
if (expression.type !== "Identifier" || expression.name !== "frontmatter") return new Error();
return expressionPath.reverse();
}
function getMdxFrontmatterVariableValue(astroData, path) {
let value = astroData.frontmatter;
for (const key of path) {
if (!value[key]) return void 0;
value = value[key];
}
return value;
}
function isMdxTextExpression(node) {
return node.type === "mdxTextExpression";
}
export {
rehypeHeadingIds
};

View File

@@ -0,0 +1,2 @@
import type { MarkdownVFile } from './types.js';
export declare function rehypeImages(): () => (tree: any, file: MarkdownVFile) => void;

View File

@@ -0,0 +1,25 @@
import { visit } from "unist-util-visit";
function rehypeImages() {
return () => function(tree, file) {
const imageOccurrenceMap = /* @__PURE__ */ new Map();
visit(tree, (node) => {
if (node.type !== "element") return;
if (node.tagName !== "img") return;
if (node.properties?.src) {
node.properties.src = decodeURI(node.properties.src);
if (file.data.imagePaths?.has(node.properties.src)) {
const { ...props } = node.properties;
const index = imageOccurrenceMap.get(node.properties.src) || 0;
imageOccurrenceMap.set(node.properties.src, index + 1);
node.properties["__ASTRO_IMAGE_"] = JSON.stringify({ ...props, index });
Object.keys(props).forEach((prop) => {
delete node.properties[prop];
});
}
}
});
};
}
export {
rehypeImages
};

View File

@@ -0,0 +1,3 @@
import type { Root } from 'hast';
import type { Plugin } from 'unified';
export declare const rehypePrism: Plugin<[], Root>;

View File

@@ -0,0 +1,15 @@
import { runHighlighterWithAstro } from "@astrojs/prism/dist/highlighter";
import { highlightCodeBlocks } from "./highlight.js";
const rehypePrism = () => {
return async (tree) => {
await highlightCodeBlocks(tree, (code, language) => {
let { html, classLanguage } = runHighlighterWithAstro(language, code);
return Promise.resolve(
`<pre class="${classLanguage}" data-language="${language}"><code is:raw class="${classLanguage}">${html}</code></pre>`
);
});
};
};
export {
rehypePrism
};

View File

@@ -0,0 +1,4 @@
import type { Root } from 'hast';
import type { Plugin } from 'unified';
import type { ShikiConfig } from './types.js';
export declare const rehypeShiki: Plugin<[ShikiConfig?], Root>;

View File

@@ -0,0 +1,13 @@
import { highlightCodeBlocks } from "./highlight.js";
import { createShikiHighlighter } from "./shiki.js";
const rehypeShiki = (config) => {
let highlighterAsync;
return async (tree) => {
highlighterAsync ??= createShikiHighlighter(config);
const highlighter = await highlighterAsync;
await highlightCodeBlocks(tree, highlighter.highlight);
};
};
export {
rehypeShiki
};

View File

@@ -0,0 +1,2 @@
import type { MarkdownVFile } from './types.js';
export declare function remarkCollectImages(): (tree: any, vfile: MarkdownVFile) => void;

View File

@@ -0,0 +1,36 @@
import { definitions } from "mdast-util-definitions";
import { visit } from "unist-util-visit";
function remarkCollectImages() {
return function(tree, vfile) {
if (typeof vfile?.path !== "string") return;
const definition = definitions(tree);
const imagePaths = /* @__PURE__ */ new Set();
visit(tree, ["image", "imageReference"], (node) => {
if (node.type === "image") {
if (shouldOptimizeImage(node.url)) imagePaths.add(decodeURI(node.url));
}
if (node.type === "imageReference") {
const imageDefinition = definition(node.identifier);
if (imageDefinition) {
if (shouldOptimizeImage(imageDefinition.url))
imagePaths.add(decodeURI(imageDefinition.url));
}
}
});
vfile.data.imagePaths = imagePaths;
};
}
function shouldOptimizeImage(src) {
return !isValidUrl(src) && !src.startsWith("/");
}
function isValidUrl(str) {
try {
new URL(str);
return true;
} catch {
return false;
}
}
export {
remarkCollectImages
};

12
node_modules/@astrojs/markdown-remark/dist/shiki.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import type { ShikiConfig } from './types.js';
export interface ShikiHighlighter {
highlight(code: string, lang?: string, options?: {
inline?: boolean;
attributes?: Record<string, string>;
/**
* Raw `meta` information to be used by Shiki transformers
*/
meta?: string;
}): Promise<string>;
}
export declare function createShikiHighlighter({ langs, theme, themes, defaultColor, wrap, transformers, langAlias, }?: ShikiConfig): Promise<ShikiHighlighter>;

130
node_modules/@astrojs/markdown-remark/dist/shiki.js generated vendored Normal file
View File

@@ -0,0 +1,130 @@
import {
createCssVariablesTheme,
getHighlighter,
isSpecialLang
} from "shiki";
import { visit } from "unist-util-visit";
const ASTRO_COLOR_REPLACEMENTS = {
"--astro-code-foreground": "--astro-code-color-text",
"--astro-code-background": "--astro-code-color-background"
};
const COLOR_REPLACEMENT_REGEX = new RegExp(
`${Object.keys(ASTRO_COLOR_REPLACEMENTS).join("|")}`,
"g"
);
let _cssVariablesTheme;
const cssVariablesTheme = () => _cssVariablesTheme ?? (_cssVariablesTheme = createCssVariablesTheme({ variablePrefix: "--astro-code-" }));
async function createShikiHighlighter({
langs = [],
theme = "github-dark",
themes = {},
defaultColor,
wrap = false,
transformers = [],
langAlias = {}
} = {}) {
theme = theme === "css-variables" ? cssVariablesTheme() : theme;
const highlighter = await getHighlighter({
langs: ["plaintext", ...langs],
langAlias,
themes: Object.values(themes).length ? Object.values(themes) : [theme]
});
return {
async highlight(code, lang = "plaintext", options) {
const resolvedLang = langAlias[lang] ?? lang;
const loadedLanguages = highlighter.getLoadedLanguages();
if (!isSpecialLang(lang) && !loadedLanguages.includes(resolvedLang)) {
try {
await highlighter.loadLanguage(resolvedLang);
} catch (_err) {
const langStr = lang === resolvedLang ? `"${lang}"` : `"${lang}" (aliased to "${resolvedLang}")`;
console.warn(
`[Shiki] The language ${langStr} doesn't exist, falling back to "plaintext".`
);
lang = "plaintext";
}
}
const themeOptions = Object.values(themes).length ? { themes } : { theme };
const inline = options?.inline ?? false;
return highlighter.codeToHtml(code, {
...themeOptions,
defaultColor,
lang,
// NOTE: while we can spread `options.attributes` here so that Shiki can auto-serialize this as rendered
// attributes on the top-level tag, it's not clear whether it is fine to pass all attributes as meta, as
// they're technically not meta, nor parsed from Shiki's `parseMetaString` API.
meta: options?.meta ? { __raw: options?.meta } : void 0,
transformers: [
{
pre(node) {
if (inline) {
node.tagName = "code";
}
const {
class: attributesClass,
style: attributesStyle,
...rest
} = options?.attributes ?? {};
Object.assign(node.properties, rest);
const classValue = (normalizePropAsString(node.properties.class) ?? "") + (attributesClass ? ` ${attributesClass}` : "");
const styleValue = (normalizePropAsString(node.properties.style) ?? "") + (attributesStyle ? `; ${attributesStyle}` : "");
node.properties.class = classValue.replace(/shiki/g, "astro-code");
node.properties.dataLanguage = lang;
if (wrap === false) {
node.properties.style = styleValue + "; overflow-x: auto;";
} else if (wrap === true) {
node.properties.style = styleValue + "; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;";
}
},
line(node) {
if (resolvedLang === "diff") {
const innerSpanNode = node.children[0];
const innerSpanTextNode = innerSpanNode?.type === "element" && innerSpanNode.children?.[0];
if (innerSpanTextNode && innerSpanTextNode.type === "text") {
const start = innerSpanTextNode.value[0];
if (start === "+" || start === "-") {
innerSpanTextNode.value = innerSpanTextNode.value.slice(1);
innerSpanNode.children.unshift({
type: "element",
tagName: "span",
properties: { style: "user-select: none;" },
children: [{ type: "text", value: start }]
});
}
}
}
},
code(node) {
if (inline) {
return node.children[0];
}
},
root(node) {
if (Object.values(themes).length) {
return;
}
const themeName = typeof theme === "string" ? theme : theme.name;
if (themeName === "css-variables") {
visit(node, "element", (child) => {
if (child.properties?.style) {
child.properties.style = replaceCssVariables(child.properties.style);
}
});
}
}
},
...transformers
]
});
}
};
}
function normalizePropAsString(value) {
return Array.isArray(value) ? value.join(" ") : value;
}
function replaceCssVariables(str) {
return str.replace(COLOR_REPLACEMENT_REGEX, (match) => ASTRO_COLOR_REPLACEMENTS[match] || match);
}
export {
createShikiHighlighter
};

60
node_modules/@astrojs/markdown-remark/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,60 @@
import type * as hast from 'hast';
import type * as mdast from 'mdast';
import type { Options as RemarkRehypeOptions } from 'remark-rehype';
import type { BuiltinTheme, HighlighterCoreOptions, LanguageRegistration, ShikiTransformer, ThemeRegistration, ThemeRegistrationRaw } from 'shiki';
import type * as unified from 'unified';
import type { DataMap, VFile } from 'vfile';
export type { Node } from 'unist';
export type MarkdownAstroData = {
frontmatter: Record<string, any>;
};
export type RemarkPlugin<PluginParameters extends any[] = any[]> = unified.Plugin<PluginParameters, mdast.Root>;
export type RemarkPlugins = (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
export type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugin<PluginParameters, hast.Root>;
export type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
export type RemarkRehype = RemarkRehypeOptions;
export type ThemePresets = BuiltinTheme | 'css-variables';
export interface ShikiConfig {
langs?: LanguageRegistration[];
langAlias?: HighlighterCoreOptions['langAlias'];
theme?: ThemePresets | ThemeRegistration | ThemeRegistrationRaw;
themes?: Record<string, ThemePresets | ThemeRegistration | ThemeRegistrationRaw>;
defaultColor?: 'light' | 'dark' | string | false;
wrap?: boolean | null;
transformers?: ShikiTransformer[];
}
export interface AstroMarkdownOptions {
syntaxHighlight?: 'shiki' | 'prism' | false;
shikiConfig?: ShikiConfig;
remarkPlugins?: RemarkPlugins;
rehypePlugins?: RehypePlugins;
remarkRehype?: RemarkRehype;
gfm?: boolean;
smartypants?: boolean;
}
export interface MarkdownProcessor {
render: (content: string, opts?: MarkdownProcessorRenderOptions) => Promise<MarkdownProcessorRenderResult>;
}
export interface MarkdownProcessorRenderOptions {
/** Used for frontmatter injection plugins */
frontmatter?: Record<string, any>;
}
export interface MarkdownProcessorRenderResult {
code: string;
metadata: {
headings: MarkdownHeading[];
imagePaths: Set<string>;
frontmatter: Record<string, any>;
};
}
export interface MarkdownHeading {
depth: number;
slug: string;
text: string;
}
export interface MarkdownVFile extends VFile {
data: Record<string, unknown> & Partial<DataMap> & {
__astroHeadings?: MarkdownHeading[];
imagePaths?: Set<string>;
};
}

0
node_modules/@astrojs/markdown-remark/dist/types.js generated vendored Normal file
View File

67
node_modules/@astrojs/markdown-remark/package.json generated vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"name": "@astrojs/markdown-remark",
"version": "5.3.0",
"type": "module",
"author": "withastro",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/withastro/astro.git",
"directory": "packages/markdown/remark"
},
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://astro.build",
"main": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./dist/internal.js": "./dist/internal.js"
},
"imports": {
"#import-plugin": {
"browser": "./dist/import-plugin-browser.js",
"default": "./dist/import-plugin-default.js"
}
},
"files": [
"dist"
],
"dependencies": {
"github-slugger": "^2.0.0",
"hast-util-from-html": "^2.0.3",
"hast-util-to-text": "^4.0.2",
"import-meta-resolve": "^4.1.0",
"mdast-util-definitions": "^6.0.0",
"rehype-raw": "^7.0.0",
"rehype-stringify": "^10.0.1",
"remark-gfm": "^4.0.0",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.1",
"remark-smartypants": "^3.0.2",
"shiki": "^1.22.0",
"unified": "^11.0.5",
"unist-util-remove-position": "^5.0.0",
"unist-util-visit": "^5.0.0",
"unist-util-visit-parents": "^6.0.1",
"vfile": "^6.0.3",
"@astrojs/prism": "3.1.0"
},
"devDependencies": {
"@types/estree": "^1.0.6",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"@types/unist": "^3.0.3",
"esbuild": "^0.21.5",
"mdast-util-mdx-expression": "^2.0.1",
"astro-scripts": "0.0.14"
},
"publishConfig": {
"provenance": true
},
"scripts": {
"prepublish": "pnpm build",
"build": "astro-scripts build \"src/**/*.ts\" && tsc -p tsconfig.json",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "astro-scripts test \"test/**/*.test.js\""
}
}

59
node_modules/@astrojs/prism/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,59 @@
MIT License
Copyright (c) 2021 Fred K. Schott
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
MIT License
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

17
node_modules/@astrojs/prism/Prism.astro generated vendored Normal file
View File

@@ -0,0 +1,17 @@
---
import { runHighlighterWithAstro } from './dist/highlighter';
interface Props {
class?: string;
lang?: string;
code: string;
}
const { class: className, lang, code } = Astro.props as Props;
const { classLanguage, html } = runHighlighterWithAstro(lang, code);
---
<pre
class={[className, classLanguage]
.filter(Boolean)
.join(' ')}><code class={classLanguage} set:html={html} /></pre>

34
node_modules/@astrojs/prism/README.md generated vendored Normal file
View File

@@ -0,0 +1,34 @@
# @astrojs/prism
Supports Prism highlighting in Astro projects
## Component
This package exports a component to support highlighting inside an Astro file. Example:
```astro
---
import { Prism } from '@astrojs/prism';
---
<Prism lang="js" code={`const foo = 'bar';`} />
```
## Internal
This package exports a `runHighlighterWithAstro` function to highlight while making sure the Astro language is loaded beforehand
```typescript
import { runHighlighterWithAstro } from '@astrojs/prism';
runHighlighterWithAstro(
`
---
const helloAstro = 'Hello, Astro!';
---
<div>{helloAstro}</div>
`,
'astro'
);
```

4
node_modules/@astrojs/prism/dist/highlighter.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export declare function runHighlighterWithAstro(lang: string | undefined, code: string): {
classLanguage: string;
html: string;
};

36
node_modules/@astrojs/prism/dist/highlighter.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import Prism from "prismjs";
import loadLanguages from "prismjs/components/index.js";
import { addAstro } from "./plugin.js";
const languageMap = /* @__PURE__ */ new Map([["ts", "typescript"]]);
function runHighlighterWithAstro(lang, code) {
if (!lang) {
lang = "plaintext";
}
let classLanguage = `language-${lang}`;
const ensureLoaded = (language) => {
if (language && !Prism.languages[language]) {
loadLanguages([language]);
}
};
if (languageMap.has(lang)) {
ensureLoaded(languageMap.get(lang));
} else if (lang === "astro") {
ensureLoaded("typescript");
addAstro(Prism);
} else {
ensureLoaded("markup-templating");
ensureLoaded(lang);
}
if (lang && !Prism.languages[lang]) {
console.warn(`Unable to load the language: ${lang}`);
}
const grammar = Prism.languages[lang];
let html = code;
if (grammar) {
html = Prism.highlight(code, grammar, lang);
}
return { classLanguage, html };
}
export {
runHighlighterWithAstro
};

1
node_modules/@astrojs/prism/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export { default as Prism } from '../Prism.astro';

4
node_modules/@astrojs/prism/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { default as default2 } from "../Prism.astro";
export {
default2 as Prism
};

1
node_modules/@astrojs/prism/dist/plugin.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function addAstro(Prism: typeof import('prismjs')): void;

139
node_modules/@astrojs/prism/dist/plugin.js generated vendored Normal file
View File

@@ -0,0 +1,139 @@
function addAstro(Prism) {
if (Prism.languages.astro) {
return;
}
let scriptLang;
if (Prism.languages.typescript) {
scriptLang = "typescript";
} else {
scriptLang = "javascript";
console.warn(
"Prism TypeScript language not loaded, Astro scripts will be treated as JavaScript."
);
}
let script = Prism.util.clone(Prism.languages[scriptLang]);
let space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
let braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
let spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
function re(source, flags) {
source = source.replace(/<S>/g, function() {
return space;
}).replace(/<BRACES>/g, function() {
return braces;
}).replace(/<SPREAD>/g, function() {
return spread;
});
return RegExp(source, flags);
}
spread = re(spread).source;
Prism.languages.astro = Prism.languages.extend("markup", script);
Prism.languages.astro.tag.pattern = re(
/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source
);
Prism.languages.astro.tag.inside["tag"].pattern = /^<\/?[^\s>/]*/;
Prism.languages.astro.tag.inside["attr-value"].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
Prism.languages.astro.tag.inside["tag"].inside["class-name"] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
Prism.languages.astro.tag.inside["comment"] = script["comment"];
Prism.languages.insertBefore(
"inside",
"attr-name",
{
spread: {
pattern: re(/<SPREAD>/.source),
inside: Prism.languages.astro
}
},
Prism.languages.astro.tag
);
Prism.languages.insertBefore(
"inside",
"special-attr",
{
script: {
// Allow for two levels of nesting
pattern: re(/=<BRACES>/.source),
inside: {
"script-punctuation": {
pattern: /^=(?=\{)/,
alias: "punctuation"
},
rest: Prism.languages.astro
},
alias: `language-${scriptLang}`
}
},
Prism.languages.astro.tag
);
let stringifyToken = function(token) {
if (!token) {
return "";
}
if (typeof token === "string") {
return token;
}
if (typeof token.content === "string") {
return token.content;
}
return token.content.map(stringifyToken).join("");
};
let walkTokens = function(tokens) {
let openedTags = [];
for (let i = 0; i < tokens.length; i++) {
let token = tokens[i];
if (token.type === "style") {
return;
}
let notTagNorBrace = false;
if (typeof token !== "string") {
if (token.type === "tag" && token.content[0] && token.content[0].type === "tag") {
if (token.content[0].content[0].content === "</") {
if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
openedTags.pop();
}
} else {
if (token.content[token.content.length - 1].content === "/>") {
} else {
openedTags.push({
tagName: stringifyToken(token.content[0].content[1]),
openedBraces: 0
});
}
}
} else if (openedTags.length > 0 && token.type === "punctuation" && token.content === "{") {
openedTags[openedTags.length - 1].openedBraces++;
} else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === "punctuation" && token.content === "}") {
openedTags[openedTags.length - 1].openedBraces--;
} else {
notTagNorBrace = true;
}
}
if (notTagNorBrace || typeof token === "string") {
if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
let plainText = stringifyToken(token);
if (i < tokens.length - 1 && (typeof tokens[i + 1] === "string" || tokens[i + 1].type === "plain-text")) {
plainText += stringifyToken(tokens[i + 1]);
tokens.splice(i + 1, 1);
}
if (i > 0 && (typeof tokens[i - 1] === "string" || tokens[i - 1].type === "plain-text")) {
plainText = stringifyToken(tokens[i - 1]) + plainText;
tokens.splice(i - 1, 1);
i--;
}
tokens[i] = new Prism.Token("plain-text", plainText, void 0, plainText);
}
}
if (token.content && typeof token.content !== "string") {
walkTokens(token.content);
}
}
};
Prism.hooks.add("after-tokenize", function(env) {
if (env.language !== "astro") {
return;
}
walkTokens(env.tokens);
});
}
export {
addAstro
};

44
node_modules/@astrojs/prism/package.json generated vendored Normal file
View File

@@ -0,0 +1,44 @@
{
"name": "@astrojs/prism",
"version": "3.1.0",
"description": "Add Prism syntax highlighting support to your Astro site",
"author": "withastro",
"type": "module",
"license": "MIT",
"bugs": "https://github.com/withastro/astro/issues",
"repository": {
"type": "git",
"url": "https://github.com/withastro/astro.git",
"directory": "packages/astro-prism"
},
"homepage": "https://docs.astro.build/en/reference/api-reference/#prism-",
"main": "dist/index.js",
"exports": {
".": "./dist/index.js",
"./Prism.astro": "./Prism.astro",
"./dist/highlighter": "./dist/highlighter.js"
},
"files": [
"dist",
"Prism.astro"
],
"keywords": [
"astro",
"astro-component"
],
"dependencies": {
"prismjs": "^1.29.0"
},
"devDependencies": {
"@types/prismjs": "1.26.3",
"astro-scripts": "0.0.14"
},
"engines": {
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
},
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc -p ./tsconfig.json",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\""
}
}

59
node_modules/@astrojs/tailwind/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,59 @@
MIT License
Copyright (c) 2021 Fred K. Schott
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
MIT License
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

38
node_modules/@astrojs/tailwind/README.md generated vendored Normal file
View File

@@ -0,0 +1,38 @@
# @astrojs/tailwind 💨
This **[Astro integration][astro-integration]** brings [Tailwind's](https://tailwindcss.com/) utility CSS classes to every `.astro` file and [framework component](https://docs.astro.build/en/core-concepts/framework-components/) in your project, along with support for the Tailwind configuration file.
## Documentation
Read the [`@astrojs/tailwind` docs][docs]
## Support
- Get help in the [Astro Discord][discord]. Post questions in our `#support` forum, or visit our dedicated `#dev` channel to discuss current development and more!
- Check our [Astro Integration Documentation][astro-integration] for more on integrations.
- Submit bug reports and feature requests as [GitHub issues][issues].
## Contributing
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR! These links will help you get started:
- [Contributor Manual][contributing]
- [Code of Conduct][coc]
- [Community Guide][community]
## License
MIT
Copyright (c) 2023present [Astro][astro]
[astro]: https://astro.build/
[docs]: https://docs.astro.build/en/guides/integrations-guide/tailwind/
[contributing]: https://github.com/withastro/astro/blob/main/CONTRIBUTING.md
[coc]: https://github.com/withastro/.github/blob/main/CODE_OF_CONDUCT.md
[community]: https://github.com/withastro/.github/blob/main/COMMUNITY_GUIDE.md
[discord]: https://astro.build/chat/
[issues]: https://github.com/withastro/astro/issues
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/

3
node_modules/@astrojs/tailwind/base.css generated vendored Normal file
View File

@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

23
node_modules/@astrojs/tailwind/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import type { AstroIntegration } from 'astro';
type TailwindOptions = {
/**
* Path to your tailwind config file
* @default 'tailwind.config.mjs'
*/
configFile?: string;
/**
* Apply Tailwind's base styles
* Disabling this is useful when further customization of Tailwind styles
* and directives is required. See {@link https://tailwindcss.com/docs/functions-and-directives#tailwind Tailwind's docs}
* for more details on directives and customization.
* @default true
*/
applyBaseStyles?: boolean;
/**
* Add CSS nesting support using `tailwindcss/nesting`. See {@link https://tailwindcss.com/docs/using-with-preprocessors#nesting Tailwind's docs}
* for how this works with `postcss-nesting` and `postcss-nested`.
*/
nesting?: boolean;
};
export default function tailwindIntegration(options?: TailwindOptions): AstroIntegration;
export {};

61
node_modules/@astrojs/tailwind/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
import { fileURLToPath } from "node:url";
import autoprefixerPlugin from "autoprefixer";
import tailwindPlugin from "tailwindcss";
async function getPostCssConfig(root, postcssInlineOptions) {
let postcssConfigResult;
if (!(typeof postcssInlineOptions === "object" && postcssInlineOptions !== null)) {
let { default: postcssrc } = await import("postcss-load-config");
const searchPath = typeof postcssInlineOptions === "string" ? postcssInlineOptions : root;
try {
postcssConfigResult = await postcssrc({}, searchPath);
} catch {
postcssConfigResult = null;
}
}
return postcssConfigResult;
}
async function getViteConfiguration(tailwindConfigPath, nesting, root, postcssInlineOptions) {
const postcssConfigResult = await getPostCssConfig(root, postcssInlineOptions);
const postcssOptions = postcssConfigResult?.options ?? {};
const postcssPlugins = postcssConfigResult?.plugins?.slice() ?? [];
if (nesting) {
const tailwindcssNestingPlugin = (await import("tailwindcss/nesting/index.js")).default;
postcssPlugins.push(tailwindcssNestingPlugin());
}
postcssPlugins.push(tailwindPlugin(tailwindConfigPath));
postcssPlugins.push(autoprefixerPlugin());
return {
css: {
postcss: {
...postcssOptions,
plugins: postcssPlugins
}
}
};
}
function tailwindIntegration(options) {
const applyBaseStyles = options?.applyBaseStyles ?? true;
const customConfigPath = options?.configFile;
const nesting = options?.nesting ?? false;
return {
name: "@astrojs/tailwind",
hooks: {
"astro:config:setup": async ({ config, updateConfig, injectScript }) => {
updateConfig({
vite: await getViteConfiguration(
customConfigPath,
nesting,
fileURLToPath(config.root),
config.vite.css?.postcss
)
});
if (applyBaseStyles) {
injectScript("page-ssr", `import '@astrojs/tailwind/base.css';`);
}
}
}
};
}
export {
tailwindIntegration as default
};

55
node_modules/@astrojs/tailwind/package.json generated vendored Normal file
View File

@@ -0,0 +1,55 @@
{
"name": "@astrojs/tailwind",
"description": "Use Tailwind CSS to style your Astro site",
"version": "5.1.5",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/withastro/astro.git",
"directory": "packages/integrations/tailwind"
},
"keywords": [
"astro-integration",
"withastro",
"css",
"tailwindcss"
],
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://docs.astro.build/en/guides/integrations-guide/tailwind/",
"exports": {
".": "./dist/index.js",
"./base.css": "./base.css",
"./package.json": "./package.json"
},
"files": [
"dist",
"base.css"
],
"dependencies": {
"autoprefixer": "^10.4.20",
"postcss": "^8.5.1",
"postcss-load-config": "^4.0.2"
},
"devDependencies": {
"tailwindcss": "^3.4.17",
"vite": "^6.0.9",
"astro": "5.1.8",
"astro-scripts": "0.0.14"
},
"peerDependencies": {
"astro": "^3.0.0 || ^4.0.0 || ^5.0.0",
"tailwindcss": "^3.0.24"
},
"publishConfig": {
"provenance": true
},
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "astro-scripts test \"test/**/*.test.js\""
}
}

59
node_modules/@astrojs/telemetry/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,59 @@
MIT License
Copyright (c) 2021 Fred K. Schott
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
MIT License
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

17
node_modules/@astrojs/telemetry/README.md generated vendored Normal file
View File

@@ -0,0 +1,17 @@
# Astro Telemetry
This package is used to collect anonymous telemetry data within the Astro CLI.
It can be disabled in Astro using either method documented below:
```shell
# Option 1: Run this to disable telemetry globally across your entire machine.
astro telemetry disable
```
```shell
# Option 2: The ASTRO_TELEMETRY_DISABLED environment variable disables telemetry when set.
ASTRO_TELEMETRY_DISABLED=1 astro dev
```
Visit https://astro.build/telemetry/ for more information about our approach to anonymous telemetry in Astro.

View File

@@ -0,0 +1,6 @@
/** Specifies whether or not telemetry is enabled or disabled. */
export declare const TELEMETRY_ENABLED = "telemetry.enabled";
/** Specifies when the user was informed of anonymous telemetry. */
export declare const TELEMETRY_NOTIFY_DATE = "telemetry.notifiedAt";
/** Specifies an anonymous identifier used to dedupe events for a user. */
export declare const TELEMETRY_ID = "telemetry.anonymousId";

8
node_modules/@astrojs/telemetry/dist/config-keys.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
const TELEMETRY_ENABLED = "telemetry.enabled";
const TELEMETRY_NOTIFY_DATE = "telemetry.notifiedAt";
const TELEMETRY_ID = `telemetry.anonymousId`;
export {
TELEMETRY_ENABLED,
TELEMETRY_ID,
TELEMETRY_NOTIFY_DATE
};

19
node_modules/@astrojs/telemetry/dist/config.d.ts generated vendored Normal file
View File

@@ -0,0 +1,19 @@
export interface ConfigOptions {
name: string;
}
export declare class GlobalConfig {
private project;
private dir;
private file;
constructor(project: ConfigOptions);
private _store?;
private get store();
private set store(value);
private ensureDir;
write(): void;
clear(): void;
delete(key: string): boolean;
get(key: string): any;
has(key: string): boolean;
set(key: string, value: any): void;
}

84
node_modules/@astrojs/telemetry/dist/config.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import process from "node:process";
import dget from "dlv";
import { dset } from "dset";
function getConfigDir(name) {
const homedir = os.homedir();
const macos = () => path.join(homedir, "Library", "Preferences", name);
const win = () => {
const { APPDATA = path.join(homedir, "AppData", "Roaming") } = process.env;
return path.join(APPDATA, name, "Config");
};
const linux = () => {
const { XDG_CONFIG_HOME = path.join(homedir, ".config") } = process.env;
return path.join(XDG_CONFIG_HOME, name);
};
switch (process.platform) {
case "darwin":
return macos();
case "win32":
return win();
default:
return linux();
}
}
class GlobalConfig {
constructor(project) {
this.project = project;
this.dir = getConfigDir(this.project.name);
this.file = path.join(this.dir, "config.json");
}
dir;
file;
_store;
get store() {
if (this._store)
return this._store;
this.ensureDir();
if (fs.existsSync(this.file)) {
try {
this._store = JSON.parse(fs.readFileSync(this.file).toString());
} catch {
}
}
if (!this._store) {
this._store = {};
this.write();
}
return this._store;
}
set store(value) {
this._store = value;
this.write();
}
ensureDir() {
fs.mkdirSync(this.dir, { recursive: true });
}
write() {
fs.writeFileSync(this.file, JSON.stringify(this.store, null, " "));
}
clear() {
this.store = {};
fs.rmSync(this.file, { recursive: true });
}
delete(key) {
dset(this.store, key, void 0);
this.write();
return true;
}
get(key) {
return dget(this.store, key);
}
has(key) {
return typeof this.get(key) !== "undefined";
}
set(key, value) {
dset(this.store, key, value);
this.write();
}
}
export {
GlobalConfig
};

39
node_modules/@astrojs/telemetry/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,39 @@
export type AstroTelemetryOptions = {
astroVersion: string;
viteVersion: string;
};
export type TelemetryEvent = {
eventName: string;
payload: Record<string, any>;
};
export declare class AstroTelemetry {
private opts;
private _anonymousSessionId;
private _anonymousProjectInfo;
private config;
private debug;
private isCI;
private env;
private get astroVersion();
private get viteVersion();
private get ASTRO_TELEMETRY_DISABLED();
private get TELEMETRY_DISABLED();
constructor(opts: AstroTelemetryOptions);
/**
* Get value from either the global config or the provided fallback.
* If value is not set, the fallback is saved to the global config,
* persisted for later sessions.
*/
private getConfigWithFallback;
private get enabled();
private get notifyDate();
private get anonymousId();
private get anonymousSessionId();
private get anonymousProjectInfo();
private get isDisabled();
setEnabled(value: boolean): void;
clear(): void;
isValidNotice(): boolean;
notify(callback: () => boolean | Promise<boolean>): Promise<void>;
record(event?: TelemetryEvent | TelemetryEvent[]): Promise<any>;
}

132
node_modules/@astrojs/telemetry/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,132 @@
import { randomBytes } from "node:crypto";
import { isCI } from "ci-info";
import debug from "debug";
import * as KEY from "./config-keys.js";
import { GlobalConfig } from "./config.js";
import { post } from "./post.js";
import { getProjectInfo } from "./project-info.js";
import { getSystemInfo } from "./system-info.js";
const VALID_TELEMETRY_NOTICE_DATE = "2023-08-25";
class AstroTelemetry {
constructor(opts) {
this.opts = opts;
}
_anonymousSessionId;
_anonymousProjectInfo;
config = new GlobalConfig({ name: "astro" });
debug = debug("astro:telemetry");
isCI = isCI;
env = process.env;
get astroVersion() {
return this.opts.astroVersion;
}
get viteVersion() {
return this.opts.viteVersion;
}
get ASTRO_TELEMETRY_DISABLED() {
return this.env.ASTRO_TELEMETRY_DISABLED;
}
get TELEMETRY_DISABLED() {
return this.env.TELEMETRY_DISABLED;
}
/**
* Get value from either the global config or the provided fallback.
* If value is not set, the fallback is saved to the global config,
* persisted for later sessions.
*/
getConfigWithFallback(key, getValue) {
const currentValue = this.config.get(key);
if (currentValue !== void 0) {
return currentValue;
}
const newValue = getValue();
this.config.set(key, newValue);
return newValue;
}
get enabled() {
return this.getConfigWithFallback(KEY.TELEMETRY_ENABLED, () => true);
}
get notifyDate() {
return this.getConfigWithFallback(KEY.TELEMETRY_NOTIFY_DATE, () => "");
}
get anonymousId() {
return this.getConfigWithFallback(KEY.TELEMETRY_ID, () => randomBytes(32).toString("hex"));
}
get anonymousSessionId() {
this._anonymousSessionId = this._anonymousSessionId || randomBytes(32).toString("hex");
return this._anonymousSessionId;
}
get anonymousProjectInfo() {
this._anonymousProjectInfo = this._anonymousProjectInfo || getProjectInfo(this.isCI);
return this._anonymousProjectInfo;
}
get isDisabled() {
if (Boolean(this.ASTRO_TELEMETRY_DISABLED || this.TELEMETRY_DISABLED)) {
return true;
}
return this.enabled === false;
}
setEnabled(value) {
this.config.set(KEY.TELEMETRY_ENABLED, value);
}
clear() {
return this.config.clear();
}
isValidNotice() {
if (!this.notifyDate)
return false;
const current = Number(this.notifyDate);
const valid = new Date(VALID_TELEMETRY_NOTICE_DATE).valueOf();
return current > valid;
}
async notify(callback) {
if (this.isDisabled || this.isCI) {
this.debug(`[notify] telemetry has been disabled`);
return;
}
if (this.isValidNotice()) {
this.debug(`[notify] last notified on ${this.notifyDate}`);
return;
}
const enabled = await callback();
this.config.set(KEY.TELEMETRY_NOTIFY_DATE, (/* @__PURE__ */ new Date()).valueOf().toString());
this.config.set(KEY.TELEMETRY_ENABLED, enabled);
this.debug(`[notify] telemetry has been ${enabled ? "enabled" : "disabled"}`);
}
async record(event = []) {
const events = Array.isArray(event) ? event : [event];
if (events.length < 1) {
return Promise.resolve();
}
if (this.isDisabled) {
this.debug("[record] telemetry has been disabled");
return Promise.resolve();
}
const meta = {
...getSystemInfo({ astroVersion: this.astroVersion, viteVersion: this.viteVersion })
};
const context = {
...this.anonymousProjectInfo,
anonymousId: this.anonymousId,
anonymousSessionId: this.anonymousSessionId
};
if (meta.isCI) {
context.anonymousId = `CI.${meta.ciName || "UNKNOWN"}`;
}
if (this.debug.enabled) {
this.debug({ context, meta });
this.debug(JSON.stringify(events, null, 2));
return Promise.resolve();
}
return post({
context,
meta,
events
}).catch((err) => {
this.debug(`Error sending event: ${err.message}`);
});
}
}
export {
AstroTelemetry
};

Some files were not shown because too many files have changed in this diff Show More