Initial commit: New MoreminiMore website with fresh design
This commit is contained in:
1
node_modules/.astro/data-store.json
generated
vendored
Normal file
1
node_modules/.astro/data-store.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[["Map",1,2],"meta::meta",["Map",3,4,5,6,7,8],"astro-config-digest","{\"root\":{},\"srcDir\":{},\"publicDir\":{},\"outDir\":{},\"cacheDir\":{},\"site\":\"https://www.moreminimore.com\",\"compressHTML\":true,\"base\":\"/\",\"trailingSlash\":\"ignore\",\"output\":\"server\",\"scopedStyleStrategy\":\"attribute\",\"build\":{\"format\":\"directory\",\"client\":{},\"server\":{},\"assets\":\"_astro\",\"serverEntry\":\"entry.mjs\",\"redirects\":false,\"inlineStylesheets\":\"auto\",\"concurrency\":1},\"server\":{\"open\":false,\"host\":false,\"port\":4321,\"streaming\":true,\"allowedHosts\":[]},\"redirects\":{},\"image\":{\"endpoint\":{\"route\":\"/_image\",\"entrypoint\":\"astro/assets/endpoint/node\"},\"service\":{\"entrypoint\":\"astro/assets/services/sharp\",\"config\":{}},\"domains\":[],\"remotePatterns\":[],\"responsiveStyles\":false},\"devToolbar\":{\"enabled\":true},\"markdown\":{\"syntaxHighlight\":{\"type\":\"shiki\",\"excludeLangs\":[\"math\"]},\"shikiConfig\":{\"langs\":[],\"langAlias\":{},\"theme\":\"github-dark\",\"themes\":{},\"wrap\":false,\"transformers\":[]},\"remarkPlugins\":[],\"rehypePlugins\":[],\"remarkRehype\":{},\"gfm\":true,\"smartypants\":{\"backticks\":true,\"closingQuotes\":{\"double\":\"”\",\"single\":\"’\"},\"dashes\":true,\"ellipses\":true,\"openingQuotes\":{\"double\":\"“\",\"single\":\"‘\"},\"quotes\":true}},\"security\":{\"checkOrigin\":true,\"allowedDomains\":[],\"csp\":false,\"actionBodySizeLimit\":1048576,\"serverIslandBodySizeLimit\":1048576},\"env\":{\"schema\":{},\"validateSecrets\":false},\"prerenderConflictBehavior\":\"warn\",\"experimental\":{\"clientPrerender\":false,\"contentIntellisense\":false,\"chromeDevtoolsWorkspace\":false,\"svgo\":false,\"rustCompiler\":false,\"queuedRendering\":{\"enabled\":false}},\"legacy\":{\"collectionsBackwardsCompat\":false},\"session\":{\"driver\":{\"entrypoint\":\"unstorage/drivers/fs-lite\",\"config\":{\"base\":\"/Users/kunthawatgreethong/Gitea/moreminimore-new/node_modules/.astro/sessions\"}}}}","astro-version","6.1.8","content-config-digest","29418499c0163d6c"]
|
||||
1
node_modules/.bin/astro
generated
vendored
Symbolic link
1
node_modules/.bin/astro
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../astro/bin/astro.mjs
|
||||
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../esbuild/bin/esbuild
|
||||
1
node_modules/.bin/is-docker
generated
vendored
Symbolic link
1
node_modules/.bin/is-docker
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../is-docker/cli.js
|
||||
1
node_modules/.bin/is-inside-container
generated
vendored
Symbolic link
1
node_modules/.bin/is-inside-container
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../is-inside-container/cli.js
|
||||
1
node_modules/.bin/jiti
generated
vendored
Symbolic link
1
node_modules/.bin/jiti
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jiti/lib/jiti-cli.mjs
|
||||
1
node_modules/.bin/js-yaml
generated
vendored
Symbolic link
1
node_modules/.bin/js-yaml
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../js-yaml/bin/js-yaml.js
|
||||
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../nanoid/bin/nanoid.js
|
||||
1
node_modules/.bin/parser
generated
vendored
Symbolic link
1
node_modules/.bin/parser
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../@babel/parser/bin/babel-parser.js
|
||||
1
node_modules/.bin/rolldown
generated
vendored
Symbolic link
1
node_modules/.bin/rolldown
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../rolldown/bin/cli.mjs
|
||||
1
node_modules/.bin/rollup
generated
vendored
Symbolic link
1
node_modules/.bin/rollup
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../rollup/dist/bin/rollup
|
||||
1
node_modules/.bin/semver
generated
vendored
Symbolic link
1
node_modules/.bin/semver
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../semver/bin/semver.js
|
||||
1
node_modules/.bin/sitemap
generated
vendored
Symbolic link
1
node_modules/.bin/sitemap
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../sitemap/dist/esm/cli.js
|
||||
1
node_modules/.bin/svgo
generated
vendored
Symbolic link
1
node_modules/.bin/svgo
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../svgo/bin/svgo.js
|
||||
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsc
|
||||
1
node_modules/.bin/tsconfck
generated
vendored
Symbolic link
1
node_modules/.bin/tsconfck
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../tsconfck/bin/tsconfck.js
|
||||
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsserver
|
||||
1
node_modules/.bin/vite
generated
vendored
Symbolic link
1
node_modules/.bin/vite
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../vite/bin/vite.js
|
||||
4765
node_modules/.package-lock.json
generated
vendored
Normal file
4765
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
32
node_modules/.vite/deps/_metadata.json
generated
vendored
Normal file
32
node_modules/.vite/deps/_metadata.json
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"hash": "54ca2ad6",
|
||||
"configHash": "b72eebe6",
|
||||
"lockfileHash": "46a9de66",
|
||||
"browserHash": "2780b9ac",
|
||||
"optimized": {
|
||||
"astro > aria-query": {
|
||||
"src": "../../aria-query/lib/index.js",
|
||||
"file": "astro_n_aria-query.js",
|
||||
"fileHash": "c18eadfb",
|
||||
"needsInterop": true
|
||||
},
|
||||
"astro > axobject-query": {
|
||||
"src": "../../axobject-query/lib/index.js",
|
||||
"file": "astro_n_axobject-query.js",
|
||||
"fileHash": "5e6b6b3e",
|
||||
"needsInterop": true
|
||||
},
|
||||
"astro > html-escaper": {
|
||||
"src": "../../html-escaper/esm/index.js",
|
||||
"file": "astro_n_html-escaper.js",
|
||||
"fileHash": "1f9347b8",
|
||||
"needsInterop": false
|
||||
}
|
||||
},
|
||||
"chunks": {
|
||||
"chunk-CFx7f7Oh": {
|
||||
"file": "chunk-CFx7f7Oh.js",
|
||||
"isDynamicEntry": false
|
||||
}
|
||||
}
|
||||
}
|
||||
6391
node_modules/.vite/deps/astro_n_aria-query.js
generated
vendored
Normal file
6391
node_modules/.vite/deps/astro_n_aria-query.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/.vite/deps/astro_n_aria-query.js.map
generated
vendored
Normal file
1
node_modules/.vite/deps/astro_n_aria-query.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2703
node_modules/.vite/deps/astro_n_axobject-query.js
generated
vendored
Normal file
2703
node_modules/.vite/deps/astro_n_axobject-query.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/.vite/deps/astro_n_axobject-query.js.map
generated
vendored
Normal file
1
node_modules/.vite/deps/astro_n_axobject-query.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
67
node_modules/.vite/deps/astro_n_html-escaper.js
generated
vendored
Normal file
67
node_modules/.vite/deps/astro_n_html-escaper.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
//#region node_modules/html-escaper/esm/index.js
|
||||
/**
|
||||
* Copyright (C) 2017-present by Andrea Giammarchi - @WebReflection
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
var { replace } = "";
|
||||
var es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
|
||||
var ca = /[&<>'"]/g;
|
||||
var esca = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
"'": "'",
|
||||
"\"": """
|
||||
};
|
||||
var pe = (m) => esca[m];
|
||||
/**
|
||||
* Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`.
|
||||
* @param {string} es the input to safely escape
|
||||
* @returns {string} the escaped input, and it **throws** an error if
|
||||
* the input type is unexpected, except for boolean and numbers,
|
||||
* converted as string.
|
||||
*/
|
||||
var escape = (es) => replace.call(es, ca, pe);
|
||||
var unes = {
|
||||
"&": "&",
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
">": ">",
|
||||
"'": "'",
|
||||
"'": "'",
|
||||
""": "\"",
|
||||
""": "\""
|
||||
};
|
||||
var cape = (m) => unes[m];
|
||||
/**
|
||||
* Safely unescape previously escaped entities such as `&`, `<`, `>`, `"`,
|
||||
* and `'`.
|
||||
* @param {string} un a previously escaped string
|
||||
* @returns {string} the unescaped input, and it **throws** an error if
|
||||
* the input type is unexpected, except for boolean and numbers,
|
||||
* converted as string.
|
||||
*/
|
||||
var unescape = (un) => replace.call(un, es, cape);
|
||||
//#endregion
|
||||
export { escape, unescape };
|
||||
|
||||
//# sourceMappingURL=astro_n_html-escaper.js.map
|
||||
1
node_modules/.vite/deps/astro_n_html-escaper.js.map
generated
vendored
Normal file
1
node_modules/.vite/deps/astro_n_html-escaper.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"astro_n_html-escaper.js","names":[],"sources":["../../html-escaper/esm/index.js"],"sourcesContent":["/**\n * Copyright (C) 2017-present by Andrea Giammarchi - @WebReflection\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\nconst {replace} = '';\n\n// escape\nconst es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;\nconst ca = /[&<>'\"]/g;\n\nconst esca = {\n '&': '&',\n '<': '<',\n '>': '>',\n \"'\": ''',\n '\"': '"'\n};\nconst pe = m => esca[m];\n\n/**\n * Safely escape HTML entities such as `&`, `<`, `>`, `\"`, and `'`.\n * @param {string} es the input to safely escape\n * @returns {string} the escaped input, and it **throws** an error if\n * the input type is unexpected, except for boolean and numbers,\n * converted as string.\n */\nexport const escape = es => replace.call(es, ca, pe);\n\n\n// unescape\nconst unes = {\n '&': '&',\n '&': '&',\n '<': '<',\n '<': '<',\n '>': '>',\n '>': '>',\n ''': \"'\",\n ''': \"'\",\n '"': '\"',\n '"': '\"'\n};\nconst cape = m => unes[m];\n\n/**\n * Safely unescape previously escaped entities such as `&`, `<`, `>`, `\"`,\n * and `'`.\n * @param {string} un a previously escaped string\n * @returns {string} the unescaped input, and it **throws** an error if\n * the input type is unexpected, except for boolean and numbers,\n * converted as string.\n */\nexport const unescape = un => replace.call(un, es, cape);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAM,EAAC,YAAW;AAGlB,IAAM,KAAK;AACX,IAAM,KAAK;AAEX,IAAM,OAAO;CACX,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACN;AACD,IAAM,MAAK,MAAK,KAAK;;;;;;;;AASrB,IAAa,UAAS,OAAM,QAAQ,KAAK,IAAI,IAAI,GAAG;AAIpD,IAAM,OAAO;CACX,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,UAAU;CACV,SAAS;CACT,UAAU;CACV,SAAS;CACV;AACD,IAAM,QAAO,MAAK,KAAK;;;;;;;;;AAUvB,IAAa,YAAW,OAAM,QAAQ,KAAK,IAAI,IAAI,KAAK"}
|
||||
4
node_modules/.vite/deps/chunk-CFx7f7Oh.js
generated
vendored
Normal file
4
node_modules/.vite/deps/chunk-CFx7f7Oh.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
//#region \0rolldown/runtime.js
|
||||
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
||||
//#endregion
|
||||
export { __commonJSMin as t };
|
||||
3
node_modules/.vite/deps/package.json
generated
vendored
Normal file
3
node_modules/.vite/deps/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
53
node_modules/@astrojs/compiler/LICENSE
generated
vendored
Normal file
53
node_modules/@astrojs/compiler/LICENSE
generated
vendored
Normal 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.
|
||||
72
node_modules/@astrojs/compiler/README.md
generated
vendored
Normal file
72
node_modules/@astrojs/compiler/README.md
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# Astro Compiler
|
||||
|
||||
Astro’s [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 `walk` and `walkAsync` functions 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, walkAsync, 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);
|
||||
}
|
||||
});
|
||||
|
||||
await walkAsync(result.ast, async (node) => {
|
||||
if (is.tag(node)) {
|
||||
node.value = await expensiveCalculation(node)
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## 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
BIN
node_modules/@astrojs/compiler/dist/astro.wasm
generated
vendored
Normal file
Binary file not shown.
2
node_modules/@astrojs/compiler/dist/browser/index.cjs
generated
vendored
Normal file
2
node_modules/@astrojs/compiler/dist/browser/index.cjs
generated
vendored
Normal file
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
11
node_modules/@astrojs/compiler/dist/browser/index.d.ts
generated
vendored
Normal 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
1
node_modules/@astrojs/compiler/dist/browser/index.js
generated
vendored
Normal 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};
|
||||
3
node_modules/@astrojs/compiler/dist/browser/utils.cjs
generated
vendored
Normal file
3
node_modules/@astrojs/compiler/dist/browser/utils.cjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";var c=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)c(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&&c(o,r,{get:()=>e[r],enumerable:!(a=d(e,r))||a.enumerable});return o};var y=o=>f(c({},"__esModule",{value:!0}),o);var v={};u(v,{is:()=>s,serialize:()=>k,walk:()=>h,walkAsync:()=>x});module.exports=y(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")},l=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 m=e.children[i];r.push(this.callback(m,e,i))}await Promise.all(r)}}};function h(o,e){new l(e).visit(o)}function x(o,e){return new l(e).visit(o)}function g(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 k(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+=g(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,walkAsync});
|
||||
29
node_modules/@astrojs/compiler/dist/browser/utils.d.ts
generated
vendored
Normal file
29
node_modules/@astrojs/compiler/dist/browser/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
declare function walkAsync(node: ParentNode, callback: Visitor): Promise<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, walkAsync };
|
||||
3
node_modules/@astrojs/compiler/dist/browser/utils.js
generated
vendored
Normal file
3
node_modules/@astrojs/compiler/dist/browser/utils.js
generated
vendored
Normal 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 c=t.children[i];r.push(this.callback(c,t,i))}await Promise.all(r)}}};function N(o,t){new l(t).visit(o)}function u(o,t){return new l(t).visit(o)}function m(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 f(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+=m(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,f as serialize,N as walk,u as walkAsync};
|
||||
2
node_modules/@astrojs/compiler/dist/browser/wasm_exec.cjs
generated
vendored
Normal file
2
node_modules/@astrojs/compiler/dist/browser/wasm_exec.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
node_modules/@astrojs/compiler/dist/browser/wasm_exec.d.ts
generated
vendored
Normal file
37
node_modules/@astrojs/compiler/dist/browser/wasm_exec.d.ts
generated
vendored
Normal 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 };
|
||||
1
node_modules/@astrojs/compiler/dist/browser/wasm_exec.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/browser/wasm_exec.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{a}from"../chunk-QR6QDSEV.js";export{a as default};
|
||||
2
node_modules/@astrojs/compiler/dist/chunk-QR6QDSEV.js
generated
vendored
Normal file
2
node_modules/@astrojs/compiler/dist/chunk-QR6QDSEV.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@astrojs/compiler/dist/node/index.cjs
generated
vendored
Normal file
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
12
node_modules/@astrojs/compiler/dist/node/index.d.ts
generated
vendored
Normal 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
1
node_modules/@astrojs/compiler/dist/node/index.js
generated
vendored
Normal 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
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
16
node_modules/@astrojs/compiler/dist/node/sync.d.ts
generated
vendored
Normal 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
1
node_modules/@astrojs/compiler/dist/node/sync.js
generated
vendored
Normal 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
3
node_modules/@astrojs/compiler/dist/node/utils.cjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)m(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&&m(o,r,{get:()=>e[r],enumerable:!(a=d(e,r))||a.enumerable});return o};var y=o=>f(m({},"__esModule",{value:!0}),o);var v={};u(v,{is:()=>s,serialize:()=>k,walk:()=>h,walkAsync:()=>x});module.exports=y(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")},l=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 h(o,e){new l(e).visit(o)}function x(o,e){return new l(e).visit(o)}function g(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 k(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+=g(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,walkAsync});
|
||||
29
node_modules/@astrojs/compiler/dist/node/utils.d.ts
generated
vendored
Normal file
29
node_modules/@astrojs/compiler/dist/node/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
declare function walkAsync(node: ParentNode, callback: Visitor): Promise<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, walkAsync };
|
||||
3
node_modules/@astrojs/compiler/dist/node/utils.js
generated
vendored
Normal file
3
node_modules/@astrojs/compiler/dist/node/utils.js
generated
vendored
Normal 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 u(o,t){return 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 f(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,f as serialize,N as walk,u as walkAsync};
|
||||
1
node_modules/@astrojs/compiler/dist/node/wasm_exec.cjs
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/node/wasm_exec.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
node_modules/@astrojs/compiler/dist/node/wasm_exec.d.ts
generated
vendored
Normal file
37
node_modules/@astrojs/compiler/dist/node/wasm_exec.d.ts
generated
vendored
Normal 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 };
|
||||
1
node_modules/@astrojs/compiler/dist/node/wasm_exec.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/node/wasm_exec.js
generated
vendored
Normal 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
1
node_modules/@astrojs/compiler/dist/shared/ast.cjs
generated
vendored
Normal 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
74
node_modules/@astrojs/compiler/dist/shared/ast.d.ts
generated
vendored
Normal 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
0
node_modules/@astrojs/compiler/dist/shared/ast.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/diagnostics.cjs
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/diagnostics.cjs
generated
vendored
Normal 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});
|
||||
18
node_modules/@astrojs/compiler/dist/shared/diagnostics.d.ts
generated
vendored
Normal file
18
node_modules/@astrojs/compiler/dist/shared/diagnostics.d.ts
generated
vendored
Normal 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 };
|
||||
1
node_modules/@astrojs/compiler/dist/shared/diagnostics.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/diagnostics.js
generated
vendored
Normal 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
1
node_modules/@astrojs/compiler/dist/shared/types.cjs
generated
vendored
Normal 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,e)=>{for(var n in e)o(r,n,{get:e[n],enumerable:!0})},g=(r,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!c.call(r,t)&&t!==n&&o(r,t,{get:()=>e[t],enumerable:!(s=a(e,t))||s.enumerable});return r};var m=r=>g(o({},"__esModule",{value:!0}),r);var d={};l(d,{DiagnosticSeverity:()=>i});module.exports=m(d);var i=(t=>(t[t.Error=1]="Error",t[t.Warning=2]="Warning",t[t.Information=3]="Information",t[t.Hint=4]="Hint",t))(i||{});0&&(module.exports={DiagnosticSeverity});
|
||||
153
node_modules/@astrojs/compiler/dist/shared/types.d.ts
generated
vendored
Normal file
153
node_modules/@astrojs/compiler/dist/shared/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
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;
|
||||
}
|
||||
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
1
node_modules/@astrojs/compiler/dist/shared/types.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var e=(t=>(t[t.Error=1]="Error",t[t.Warning=2]="Warning",t[t.Information=3]="Information",t[t.Hint=4]="Hint",t))(e||{});export{e as DiagnosticSeverity};
|
||||
58
node_modules/@astrojs/compiler/package.json
generated
vendored
Normal file
58
node_modules/@astrojs/compiler/package.json
generated
vendored
Normal 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": "3.0.1",
|
||||
"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
1
node_modules/@astrojs/compiler/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/node/sync.js';
|
||||
1
node_modules/@astrojs/compiler/types.d.ts
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export type * from './dist/shared/types.js';
|
||||
1
node_modules/@astrojs/compiler/utils.d.ts
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/node/utils.js';
|
||||
59
node_modules/@astrojs/db/LICENSE
generated
vendored
Normal file
59
node_modules/@astrojs/db/LICENSE
generated
vendored
Normal 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/db/README.md
generated
vendored
Normal file
38
node_modules/@astrojs/db/README.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# @astrojs/db (experimental) 💿
|
||||
|
||||
This **[Astro integration][astro-integration]** enables the usage of [SQLite](https://www.sqlite.org/) in Astro Projects.
|
||||
|
||||
## Documentation
|
||||
|
||||
Read the [`@astrojs/db` 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) 2023–present [Astro][astro]
|
||||
|
||||
[astro]: https://astro.build/
|
||||
[docs]: https://docs.astro.build/en/guides/integrations-guide/db/
|
||||
[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/
|
||||
2
node_modules/@astrojs/db/dist/_internal/core/integration/error-map.d.ts
generated
vendored
Normal file
2
node_modules/@astrojs/db/dist/_internal/core/integration/error-map.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { $ZodErrorMap } from 'zod/v4/core';
|
||||
export declare const errorMap: $ZodErrorMap;
|
||||
1444
node_modules/@astrojs/db/dist/_internal/core/schemas.d.ts
generated
vendored
Normal file
1444
node_modules/@astrojs/db/dist/_internal/core/schemas.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
60
node_modules/@astrojs/db/dist/_internal/core/types.d.ts
generated
vendored
Normal file
60
node_modules/@astrojs/db/dist/_internal/core/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import type * as z from 'zod/v4';
|
||||
import type { booleanColumnSchema, columnSchema, columnsSchema, dateColumnSchema, dbConfigSchema, indexSchema, jsonColumnSchema, MaybeArray, numberColumnOptsSchema, numberColumnSchema, referenceableColumnSchema, resolvedIndexSchema, tableSchema, textColumnOptsSchema, textColumnSchema } from './schemas.js';
|
||||
export type ResolvedIndexes = z.output<typeof dbConfigSchema>['tables'][string]['indexes'];
|
||||
export type BooleanColumn = z.infer<typeof booleanColumnSchema>;
|
||||
export type BooleanColumnInput = z.input<typeof booleanColumnSchema>;
|
||||
export type NumberColumn = z.infer<typeof numberColumnSchema>;
|
||||
export type NumberColumnInput = z.input<typeof numberColumnSchema>;
|
||||
export type TextColumn = z.infer<typeof textColumnSchema>;
|
||||
export type TextColumnInput = z.input<typeof textColumnSchema>;
|
||||
export type DateColumn = z.infer<typeof dateColumnSchema>;
|
||||
export type DateColumnInput = z.input<typeof dateColumnSchema>;
|
||||
export type JsonColumn = z.infer<typeof jsonColumnSchema>;
|
||||
export type JsonColumnInput = z.input<typeof jsonColumnSchema>;
|
||||
export type ColumnType = BooleanColumn['type'] | NumberColumn['type'] | TextColumn['type'] | DateColumn['type'] | JsonColumn['type'];
|
||||
export type DBColumn = z.infer<typeof columnSchema>;
|
||||
export type DBColumnInput = DateColumnInput | BooleanColumnInput | NumberColumnInput | TextColumnInput | JsonColumnInput;
|
||||
export type DBColumns = z.infer<typeof columnsSchema>;
|
||||
export type DBTable = z.infer<typeof tableSchema>;
|
||||
export type DBTables = Record<string, DBTable>;
|
||||
export type ResolvedDBTables = z.output<typeof dbConfigSchema>['tables'];
|
||||
export type ResolvedDBTable = z.output<typeof dbConfigSchema>['tables'][string];
|
||||
export type DBSnapshot = {
|
||||
schema: Record<string, ResolvedDBTable>;
|
||||
version: string;
|
||||
};
|
||||
export type DBConfigInput = z.input<typeof dbConfigSchema>;
|
||||
export type DBConfig = z.infer<typeof dbConfigSchema>;
|
||||
export type ColumnsConfig = z.input<typeof tableSchema>['columns'];
|
||||
export type OutputColumnsConfig = z.output<typeof tableSchema>['columns'];
|
||||
export interface TableConfig<TColumns extends ColumnsConfig = ColumnsConfig> extends Pick<z.input<typeof tableSchema>, 'columns' | 'indexes' | 'foreignKeys'> {
|
||||
columns: TColumns;
|
||||
foreignKeys?: Array<{
|
||||
columns: MaybeArray<Extract<keyof TColumns, string>>;
|
||||
references: () => MaybeArray<z.input<typeof referenceableColumnSchema>>;
|
||||
}>;
|
||||
indexes?: Array<IndexConfig<TColumns>> | Record<string, LegacyIndexConfig<TColumns>>;
|
||||
deprecated?: boolean;
|
||||
}
|
||||
interface IndexConfig<TColumns extends ColumnsConfig> extends z.input<typeof indexSchema> {
|
||||
on: MaybeArray<Extract<keyof TColumns, string>>;
|
||||
}
|
||||
/** @deprecated */
|
||||
interface LegacyIndexConfig<TColumns extends ColumnsConfig> extends z.input<typeof resolvedIndexSchema> {
|
||||
on: MaybeArray<Extract<keyof TColumns, string>>;
|
||||
}
|
||||
export type NumberColumnOpts = z.input<typeof numberColumnOptsSchema>;
|
||||
export type TextColumnOpts = z.input<typeof textColumnOptsSchema>;
|
||||
declare global {
|
||||
namespace Astro {
|
||||
interface IntegrationHooks {
|
||||
'astro:db:setup'?: (options: {
|
||||
extendDb: (options: {
|
||||
configEntrypoint?: URL | string;
|
||||
seedEntrypoint?: URL | string;
|
||||
}) => void;
|
||||
}) => void | Promise<void>;
|
||||
}
|
||||
}
|
||||
}
|
||||
export {};
|
||||
19
node_modules/@astrojs/db/dist/_internal/core/utils.d.ts
generated
vendored
Normal file
19
node_modules/@astrojs/db/dist/_internal/core/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { AstroConfig, AstroIntegration } from 'astro';
|
||||
import type { Arguments } from 'yargs-parser';
|
||||
import './types.js';
|
||||
export type VitePlugin = Required<AstroConfig['vite']>['plugins'][number];
|
||||
export declare function getAstroEnv(envMode?: string): Record<`ASTRO_${string}`, string>;
|
||||
export type RemoteDatabaseInfo = {
|
||||
url: string;
|
||||
token: string;
|
||||
};
|
||||
export declare function getRemoteDatabaseInfo(): RemoteDatabaseInfo;
|
||||
export declare function resolveDbAppToken(flags: Arguments, envToken: string): string;
|
||||
export declare function resolveDbAppToken(flags: Arguments, envToken: string | undefined): string | undefined;
|
||||
export declare function getDbDirectoryUrl(root: URL | string): URL;
|
||||
export declare function defineDbIntegration(integration: AstroIntegration): AstroIntegration;
|
||||
/**
|
||||
* Map an object's values to a new set of values
|
||||
* while preserving types.
|
||||
*/
|
||||
export declare function mapObject<T, U = T>(item: Record<string, T>, callback: (key: string, value: T) => U): Record<string, U>;
|
||||
92
node_modules/@astrojs/db/dist/_internal/runtime/types.d.ts
generated
vendored
Normal file
92
node_modules/@astrojs/db/dist/_internal/runtime/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
import type { ColumnBaseConfig, ColumnDataType } from 'drizzle-orm';
|
||||
import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
|
||||
import type { ColumnsConfig, DBColumn, OutputColumnsConfig } from '../core/types.js';
|
||||
type GeneratedConfig<T extends ColumnDataType = ColumnDataType> = Pick<ColumnBaseConfig<T, string>, 'name' | 'tableName' | 'notNull' | 'hasDefault' | 'hasRuntimeDefault' | 'isPrimaryKey'>;
|
||||
type AstroText<T extends GeneratedConfig<'string'>, E extends readonly [string, ...string[]] | string> = SQLiteColumn<T & {
|
||||
data: E extends readonly (infer U)[] ? U : string;
|
||||
dataType: 'string';
|
||||
columnType: 'SQLiteText';
|
||||
driverParam: string;
|
||||
enumValues: E extends [string, ...string[]] ? E : never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type AstroDate<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
|
||||
data: Date;
|
||||
dataType: 'custom';
|
||||
columnType: 'SQLiteCustomColumn';
|
||||
driverParam: string;
|
||||
enumValues: never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type AstroBoolean<T extends GeneratedConfig<'boolean'>> = SQLiteColumn<T & {
|
||||
data: boolean;
|
||||
dataType: 'boolean';
|
||||
columnType: 'SQLiteBoolean';
|
||||
driverParam: number;
|
||||
enumValues: never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type AstroNumber<T extends GeneratedConfig<'number'>> = SQLiteColumn<T & {
|
||||
data: number;
|
||||
dataType: 'number';
|
||||
columnType: 'SQLiteInteger';
|
||||
driverParam: number;
|
||||
enumValues: never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
|
||||
data: unknown;
|
||||
dataType: 'custom';
|
||||
columnType: 'SQLiteCustomColumn';
|
||||
driverParam: string;
|
||||
enumValues: never;
|
||||
baseColumn: never;
|
||||
isAutoincrement: boolean;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}>;
|
||||
type Column<T extends DBColumn['type'], E extends readonly [string, ...string[]] | string, S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> : T extends 'text' ? AstroText<S, E> : T extends 'date' ? AstroDate<S> : T extends 'json' ? AstroJson<S> : never;
|
||||
export type Table<TTableName extends string, TColumns extends OutputColumnsConfig | ColumnsConfig> = SQLiteTableWithColumns<{
|
||||
name: TTableName;
|
||||
schema: undefined;
|
||||
dialect: 'sqlite';
|
||||
columns: {
|
||||
[K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], TColumns[K]['schema'] extends {
|
||||
enum: infer E;
|
||||
} ? E extends readonly [string, ...string[]] ? E : string : string, {
|
||||
tableName: TTableName;
|
||||
name: K;
|
||||
isPrimaryKey: TColumns[K]['schema'] extends {
|
||||
primaryKey: true;
|
||||
} ? true : false;
|
||||
hasDefault: TColumns[K]['schema'] extends {
|
||||
default: NonNullable<unknown>;
|
||||
} ? true : TColumns[K]['schema'] extends {
|
||||
primaryKey: true;
|
||||
} ? true : false;
|
||||
hasRuntimeDefault: TColumns[K]['schema'] extends {
|
||||
default: NonNullable<unknown>;
|
||||
} ? true : false;
|
||||
notNull: TColumns[K]['schema']['optional'] extends true ? false : true;
|
||||
}>;
|
||||
};
|
||||
}>;
|
||||
export declare const SERIALIZED_SQL_KEY = "__serializedSQL";
|
||||
export type SerializedSQL = {
|
||||
[SERIALIZED_SQL_KEY]: true;
|
||||
sql: string;
|
||||
};
|
||||
export declare function isSerializedSQL(value: any): value is SerializedSQL;
|
||||
export {};
|
||||
9
node_modules/@astrojs/db/dist/_internal/runtime/utils.d.ts
generated
vendored
Normal file
9
node_modules/@astrojs/db/dist/_internal/runtime/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { LibsqlError } from '@libsql/client';
|
||||
import { AstroError } from 'astro/errors';
|
||||
import type { DBColumn } from '../core/types.js';
|
||||
export declare function hasPrimaryKey(column: DBColumn): boolean;
|
||||
export declare class AstroDbError extends AstroError {
|
||||
name: string;
|
||||
}
|
||||
export declare function isDbError(err: unknown): err is LibsqlError;
|
||||
export declare function pathToFileURL(path: string): URL;
|
||||
48
node_modules/@astrojs/db/dist/_internal/runtime/virtual.d.ts
generated
vendored
Normal file
48
node_modules/@astrojs/db/dist/_internal/runtime/virtual.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { BooleanColumnInput, ColumnsConfig, DateColumnInput, DBConfigInput, JsonColumnInput, NumberColumnOpts, TableConfig, TextColumnOpts } from '../core/types.js';
|
||||
export declare const column: {
|
||||
number: <T extends NumberColumnOpts>(opts?: T) => {
|
||||
type: "number";
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
schema: T;
|
||||
};
|
||||
boolean: <T extends BooleanColumnInput["schema"]>(opts?: T) => {
|
||||
type: "boolean";
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
schema: T;
|
||||
};
|
||||
text: <T extends TextColumnOpts, const E extends T["enum"] extends readonly [string, ...string[]] ? Omit<T, "enum"> & T["enum"] : T>(opts?: E) => {
|
||||
type: "text";
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
schema: E;
|
||||
};
|
||||
date<T extends DateColumnInput["schema"]>(opts?: T): {
|
||||
type: "date";
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
schema: T;
|
||||
};
|
||||
json<T extends JsonColumnInput["schema"]>(opts?: T): {
|
||||
type: "json";
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
schema: T;
|
||||
};
|
||||
};
|
||||
export declare function defineTable<TColumns extends ColumnsConfig>(userConfig: TableConfig<TColumns>): TableConfig<TColumns>;
|
||||
export declare function defineDb(userConfig: DBConfigInput): {
|
||||
tables?: unknown;
|
||||
};
|
||||
export declare const NOW: import("drizzle-orm").SQL<unknown>;
|
||||
export declare const TRUE: import("drizzle-orm").SQL<unknown>;
|
||||
export declare const FALSE: import("drizzle-orm").SQL<unknown>;
|
||||
export { and, asc, avg, avgDistinct, between, count, countDistinct, desc, eq, exists, gt, gte, ilike, inArray, isNotNull, isNull, like, lt, lte, max, min, ne, not, notBetween, notExists, notIlike, notInArray, or, sql, sum, sumDistinct, } from 'drizzle-orm';
|
||||
export { alias } from 'drizzle-orm/sqlite-core';
|
||||
export { isDbError } from './utils.js';
|
||||
8
node_modules/@astrojs/db/dist/core/cli/commands/execute/index.d.ts
generated
vendored
Normal file
8
node_modules/@astrojs/db/dist/core/cli/commands/execute/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { AstroConfig } from 'astro';
|
||||
import type { Arguments } from 'yargs-parser';
|
||||
import type { DBConfig } from '../../../types.js';
|
||||
export declare function cmd({ astroConfig, dbConfig, flags, }: {
|
||||
astroConfig: AstroConfig;
|
||||
dbConfig: DBConfig;
|
||||
flags: Arguments;
|
||||
}): Promise<void>;
|
||||
65
node_modules/@astrojs/db/dist/core/cli/commands/execute/index.js
generated
vendored
Normal file
65
node_modules/@astrojs/db/dist/core/cli/commands/execute/index.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import colors from "piccolore";
|
||||
import { isDbError } from "../../../../runtime/utils.js";
|
||||
import {
|
||||
EXEC_DEFAULT_EXPORT_ERROR,
|
||||
EXEC_ERROR,
|
||||
FILE_NOT_FOUND_ERROR,
|
||||
MISSING_EXECUTE_PATH_ERROR
|
||||
} from "../../../errors.js";
|
||||
import {
|
||||
getLocalVirtualModContents,
|
||||
getRemoteVirtualModContents
|
||||
} from "../../../integration/vite-plugin-db.js";
|
||||
import { bundleFile, importBundledFile } from "../../../load-file.js";
|
||||
import { getRemoteDatabaseInfo, resolveDbAppToken } from "../../../utils.js";
|
||||
async function cmd({
|
||||
astroConfig,
|
||||
dbConfig,
|
||||
flags
|
||||
}) {
|
||||
const filePath = flags._[4];
|
||||
if (typeof filePath !== "string") {
|
||||
console.error(MISSING_EXECUTE_PATH_ERROR);
|
||||
process.exit(1);
|
||||
}
|
||||
const fileUrl = new URL(filePath, astroConfig.root);
|
||||
if (!existsSync(fileUrl)) {
|
||||
console.error(FILE_NOT_FOUND_ERROR(filePath));
|
||||
process.exit(1);
|
||||
}
|
||||
let virtualModContents;
|
||||
if (flags.remote) {
|
||||
const dbInfo = getRemoteDatabaseInfo();
|
||||
const appToken = resolveDbAppToken(flags, dbInfo.token);
|
||||
virtualModContents = getRemoteVirtualModContents({
|
||||
tables: dbConfig.tables ?? {},
|
||||
appToken,
|
||||
isBuild: false,
|
||||
output: "server",
|
||||
localExecution: true
|
||||
});
|
||||
} else {
|
||||
virtualModContents = getLocalVirtualModContents({
|
||||
tables: dbConfig.tables ?? {},
|
||||
root: astroConfig.root,
|
||||
localExecution: true
|
||||
});
|
||||
}
|
||||
const { code } = await bundleFile({ virtualModContents, root: astroConfig.root, fileUrl });
|
||||
const mod = await importBundledFile({ code, root: astroConfig.root });
|
||||
if (typeof mod.default !== "function") {
|
||||
console.error(EXEC_DEFAULT_EXPORT_ERROR(filePath));
|
||||
process.exit(1);
|
||||
}
|
||||
try {
|
||||
await mod.default();
|
||||
console.info(`${colors.green("\u2714")} File run successfully.`);
|
||||
} catch (e) {
|
||||
if (isDbError(e)) throw new Error(EXEC_ERROR(e.message));
|
||||
else throw e;
|
||||
}
|
||||
}
|
||||
export {
|
||||
cmd
|
||||
};
|
||||
8
node_modules/@astrojs/db/dist/core/cli/commands/push/index.d.ts
generated
vendored
Normal file
8
node_modules/@astrojs/db/dist/core/cli/commands/push/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { AstroConfig } from 'astro';
|
||||
import type { Arguments } from 'yargs-parser';
|
||||
import type { DBConfig } from '../../../types.js';
|
||||
export declare function cmd({ dbConfig, flags, }: {
|
||||
astroConfig: AstroConfig;
|
||||
dbConfig: DBConfig;
|
||||
flags: Arguments;
|
||||
}): Promise<void>;
|
||||
106
node_modules/@astrojs/db/dist/core/cli/commands/push/index.js
generated
vendored
Normal file
106
node_modules/@astrojs/db/dist/core/cli/commands/push/index.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
import * as clack from "@clack/prompts";
|
||||
import { sql } from "drizzle-orm";
|
||||
import { MIGRATION_VERSION } from "../../../consts.js";
|
||||
import { createClient } from "../../../db-client/libsql-node.js";
|
||||
import {
|
||||
getRemoteDatabaseInfo,
|
||||
resolveDbAppToken
|
||||
} from "../../../utils.js";
|
||||
import {
|
||||
createCurrentSnapshot,
|
||||
createEmptySnapshot,
|
||||
formatDataLossMessage,
|
||||
getMigrationQueries,
|
||||
getProductionCurrentSnapshot
|
||||
} from "../../migration-queries.js";
|
||||
async function cmd({
|
||||
dbConfig,
|
||||
flags
|
||||
}) {
|
||||
const isDryRun = flags.dryRun;
|
||||
const isForceReset = flags.forceReset;
|
||||
const dbInfo = getRemoteDatabaseInfo();
|
||||
const appToken = resolveDbAppToken(flags, dbInfo.token);
|
||||
const productionSnapshot = await getProductionCurrentSnapshot({ ...dbInfo, token: appToken });
|
||||
const currentSnapshot = createCurrentSnapshot(dbConfig);
|
||||
const isFromScratch = !productionSnapshot;
|
||||
const { queries: migrationQueries, confirmations } = await getMigrationQueries({
|
||||
oldSnapshot: isFromScratch ? createEmptySnapshot() : productionSnapshot,
|
||||
newSnapshot: currentSnapshot,
|
||||
reset: isForceReset
|
||||
});
|
||||
if (migrationQueries.length === 0) {
|
||||
console.log("Database schema is up to date.");
|
||||
} else {
|
||||
console.log(`Database schema is out of date.`);
|
||||
}
|
||||
if (isForceReset) {
|
||||
const begin = await clack.confirm({
|
||||
message: `Reset your database? All of your data will be erased and your schema created from scratch.`,
|
||||
initialValue: false,
|
||||
withGuide: false
|
||||
});
|
||||
if (begin !== true) {
|
||||
console.log("Canceled.");
|
||||
process.exit(0);
|
||||
}
|
||||
console.log(`Force-pushing to the database. All existing data will be erased.`);
|
||||
} else if (confirmations.length > 0) {
|
||||
console.log("\n" + formatDataLossMessage(confirmations) + "\n");
|
||||
throw new Error("Exiting.");
|
||||
}
|
||||
if (isDryRun) {
|
||||
console.log("Statements:", JSON.stringify(migrationQueries, void 0, 2));
|
||||
} else {
|
||||
console.log(`Pushing database schema updates...`);
|
||||
await pushSchema({
|
||||
statements: migrationQueries,
|
||||
dbInfo,
|
||||
appToken,
|
||||
isDryRun,
|
||||
currentSnapshot
|
||||
});
|
||||
}
|
||||
console.info("Push complete!");
|
||||
}
|
||||
async function pushSchema({
|
||||
statements,
|
||||
dbInfo,
|
||||
appToken,
|
||||
isDryRun,
|
||||
currentSnapshot
|
||||
}) {
|
||||
const requestBody = {
|
||||
snapshot: currentSnapshot,
|
||||
sql: statements,
|
||||
version: MIGRATION_VERSION
|
||||
};
|
||||
if (isDryRun) {
|
||||
console.info("[DRY RUN] Batch query:", JSON.stringify(requestBody, null, 2));
|
||||
return new Response(null, { status: 200 });
|
||||
}
|
||||
return pushToDb(requestBody, appToken, dbInfo.url);
|
||||
}
|
||||
async function pushToDb(requestBody, appToken, remoteUrl) {
|
||||
const client = createClient({
|
||||
token: appToken,
|
||||
url: remoteUrl
|
||||
});
|
||||
await client.run(sql`create table if not exists _astro_db_snapshot (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
version TEXT,
|
||||
snapshot BLOB
|
||||
);`);
|
||||
await client.transaction(async (tx) => {
|
||||
for (const stmt of requestBody.sql) {
|
||||
await tx.run(sql.raw(stmt));
|
||||
}
|
||||
await tx.run(sql`insert into _astro_db_snapshot (version, snapshot) values (
|
||||
${requestBody.version},
|
||||
${JSON.stringify(requestBody.snapshot)}
|
||||
)`);
|
||||
});
|
||||
}
|
||||
export {
|
||||
cmd
|
||||
};
|
||||
8
node_modules/@astrojs/db/dist/core/cli/commands/shell/index.d.ts
generated
vendored
Normal file
8
node_modules/@astrojs/db/dist/core/cli/commands/shell/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { AstroConfig } from 'astro';
|
||||
import type { Arguments } from 'yargs-parser';
|
||||
import type { DBConfigInput } from '../../../types.js';
|
||||
export declare function cmd({ flags, astroConfig, }: {
|
||||
dbConfig: DBConfigInput;
|
||||
astroConfig: AstroConfig;
|
||||
flags: Arguments;
|
||||
}): Promise<void>;
|
||||
36
node_modules/@astrojs/db/dist/core/cli/commands/shell/index.js
generated
vendored
Normal file
36
node_modules/@astrojs/db/dist/core/cli/commands/shell/index.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import { normalizeDatabaseUrl } from "../../../../runtime/index.js";
|
||||
import { DB_PATH } from "../../../consts.js";
|
||||
import { createClient as createLocalDatabaseClient } from "../../../db-client/libsql-local.js";
|
||||
import { createClient as createRemoteDatabaseClient } from "../../../db-client/libsql-node.js";
|
||||
import { SHELL_QUERY_MISSING_ERROR } from "../../../errors.js";
|
||||
import { getAstroEnv, getRemoteDatabaseInfo, resolveDbAppToken } from "../../../utils.js";
|
||||
async function cmd({
|
||||
flags,
|
||||
astroConfig
|
||||
}) {
|
||||
const query = flags.query;
|
||||
if (!query) {
|
||||
console.error(SHELL_QUERY_MISSING_ERROR);
|
||||
process.exit(1);
|
||||
}
|
||||
const dbInfo = getRemoteDatabaseInfo();
|
||||
if (flags.remote) {
|
||||
const appToken = resolveDbAppToken(flags, dbInfo.token);
|
||||
const db = createRemoteDatabaseClient({ ...dbInfo, token: appToken });
|
||||
const result = await db.run(sql.raw(query));
|
||||
console.log(result);
|
||||
} else {
|
||||
const { ASTRO_DATABASE_FILE } = getAstroEnv();
|
||||
const dbUrl = normalizeDatabaseUrl(
|
||||
ASTRO_DATABASE_FILE,
|
||||
new URL(DB_PATH, astroConfig.root).href
|
||||
);
|
||||
const db = createLocalDatabaseClient({ url: dbUrl });
|
||||
const result = await db.run(sql.raw(query));
|
||||
console.log(result);
|
||||
}
|
||||
}
|
||||
export {
|
||||
cmd
|
||||
};
|
||||
8
node_modules/@astrojs/db/dist/core/cli/commands/verify/index.d.ts
generated
vendored
Normal file
8
node_modules/@astrojs/db/dist/core/cli/commands/verify/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { AstroConfig } from 'astro';
|
||||
import type { Arguments } from 'yargs-parser';
|
||||
import type { DBConfig } from '../../../types.js';
|
||||
export declare function cmd({ dbConfig, flags, }: {
|
||||
astroConfig: AstroConfig;
|
||||
dbConfig: DBConfig;
|
||||
flags: Arguments;
|
||||
}): Promise<void>;
|
||||
46
node_modules/@astrojs/db/dist/core/cli/commands/verify/index.js
generated
vendored
Normal file
46
node_modules/@astrojs/db/dist/core/cli/commands/verify/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { getRemoteDatabaseInfo, resolveDbAppToken } from "../../../utils.js";
|
||||
import {
|
||||
createCurrentSnapshot,
|
||||
createEmptySnapshot,
|
||||
formatDataLossMessage,
|
||||
getMigrationQueries,
|
||||
getProductionCurrentSnapshot
|
||||
} from "../../migration-queries.js";
|
||||
async function cmd({
|
||||
dbConfig,
|
||||
flags
|
||||
}) {
|
||||
const isJson = flags.json;
|
||||
const dbInfo = getRemoteDatabaseInfo();
|
||||
const appToken = resolveDbAppToken(flags, dbInfo.token);
|
||||
const productionSnapshot = await getProductionCurrentSnapshot({ ...dbInfo, token: appToken });
|
||||
const currentSnapshot = createCurrentSnapshot(dbConfig);
|
||||
const { queries: migrationQueries, confirmations } = await getMigrationQueries({
|
||||
oldSnapshot: productionSnapshot || createEmptySnapshot(),
|
||||
newSnapshot: currentSnapshot
|
||||
});
|
||||
const result = { exitCode: 0, message: "", code: "", data: void 0 };
|
||||
if (migrationQueries.length === 0) {
|
||||
result.code = "MATCH";
|
||||
result.message = `Database schema is up to date.`;
|
||||
} else {
|
||||
result.code = "NO_MATCH";
|
||||
result.message = `Database schema is out of date.
|
||||
Run 'astro db push' to push up your latest changes.`;
|
||||
}
|
||||
if (confirmations.length > 0) {
|
||||
result.code = "DATA_LOSS";
|
||||
result.exitCode = 1;
|
||||
result.data = confirmations;
|
||||
result.message = formatDataLossMessage(confirmations, !isJson);
|
||||
}
|
||||
if (isJson) {
|
||||
console.log(JSON.stringify(result));
|
||||
} else {
|
||||
console.log(result.message);
|
||||
}
|
||||
process.exit(result.exitCode);
|
||||
}
|
||||
export {
|
||||
cmd
|
||||
};
|
||||
6
node_modules/@astrojs/db/dist/core/cli/index.d.ts
generated
vendored
Normal file
6
node_modules/@astrojs/db/dist/core/cli/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { AstroConfig } from 'astro';
|
||||
import type { Arguments } from 'yargs-parser';
|
||||
export declare function cli({ flags, config: astroConfig, }: {
|
||||
flags: Arguments;
|
||||
config: AstroConfig;
|
||||
}): Promise<void>;
|
||||
75
node_modules/@astrojs/db/dist/core/cli/index.js
generated
vendored
Normal file
75
node_modules/@astrojs/db/dist/core/cli/index.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
import { resolveDbConfig } from "../load-file.js";
|
||||
import { printHelp } from "./print-help.js";
|
||||
async function cli({
|
||||
flags,
|
||||
config: astroConfig
|
||||
}) {
|
||||
const args = flags._;
|
||||
const command = args[2] === "db" ? args[3] : args[2];
|
||||
validateDbAppTokenFlag(command, flags);
|
||||
const { dbConfig } = await resolveDbConfig(astroConfig);
|
||||
switch (command) {
|
||||
case "shell": {
|
||||
const { cmd } = await import("./commands/shell/index.js");
|
||||
return await cmd({ astroConfig, dbConfig, flags });
|
||||
}
|
||||
case "gen": {
|
||||
console.log('"astro db gen" is no longer needed! Visit the docs for more information.');
|
||||
return;
|
||||
}
|
||||
case "sync": {
|
||||
console.log('"astro db sync" is no longer needed! Visit the docs for more information.');
|
||||
return;
|
||||
}
|
||||
case "push": {
|
||||
const { cmd } = await import("./commands/push/index.js");
|
||||
return await cmd({ astroConfig, dbConfig, flags });
|
||||
}
|
||||
case "verify": {
|
||||
const { cmd } = await import("./commands/verify/index.js");
|
||||
return await cmd({ astroConfig, dbConfig, flags });
|
||||
}
|
||||
case "execute": {
|
||||
const { cmd } = await import("./commands/execute/index.js");
|
||||
return await cmd({ astroConfig, dbConfig, flags });
|
||||
}
|
||||
default: {
|
||||
if (command != null) {
|
||||
console.error(`Unknown command: ${command}`);
|
||||
}
|
||||
printHelp({
|
||||
commandName: "astro db",
|
||||
usage: "[command] [...flags]",
|
||||
headline: " ",
|
||||
tables: {
|
||||
Commands: [
|
||||
["push", "Push table schema updates to libSQL."],
|
||||
["verify", "Test schema updates with libSQL (good for CI)."],
|
||||
[
|
||||
"astro db execute <file-path>",
|
||||
"Execute a ts/js file using astro:db. Use --remote to connect to libSQL."
|
||||
],
|
||||
[
|
||||
"astro db shell --query <sql-string>",
|
||||
"Execute a SQL string. Use --remote to connect to libSQL."
|
||||
]
|
||||
]
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
function validateDbAppTokenFlag(command, flags) {
|
||||
if (command !== "execute" && command !== "push" && command !== "verify" && command !== "shell")
|
||||
return;
|
||||
const dbAppToken = flags.dbAppToken;
|
||||
if (dbAppToken == null) return;
|
||||
if (typeof dbAppToken !== "string") {
|
||||
console.error(`Invalid value for --db-app-token; expected a string.`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
export {
|
||||
cli
|
||||
};
|
||||
22
node_modules/@astrojs/db/dist/core/cli/migration-queries.d.ts
generated
vendored
Normal file
22
node_modules/@astrojs/db/dist/core/cli/migration-queries.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { DBConfig, DBSnapshot, ResolvedDBTable } from '../types.js';
|
||||
import type { RemoteDatabaseInfo } from '../utils.js';
|
||||
export declare function getMigrationQueries({ oldSnapshot, newSnapshot, reset, }: {
|
||||
oldSnapshot: DBSnapshot;
|
||||
newSnapshot: DBSnapshot;
|
||||
reset?: boolean;
|
||||
}): Promise<{
|
||||
queries: string[];
|
||||
confirmations: string[];
|
||||
}>;
|
||||
export declare function getTableChangeQueries({ tableName, oldTable, newTable, }: {
|
||||
tableName: string;
|
||||
oldTable: ResolvedDBTable;
|
||||
newTable: ResolvedDBTable;
|
||||
}): Promise<{
|
||||
queries: string[];
|
||||
confirmations: string[];
|
||||
}>;
|
||||
export declare function getProductionCurrentSnapshot({ url, token, }: RemoteDatabaseInfo): Promise<DBSnapshot | undefined>;
|
||||
export declare function createCurrentSnapshot({ tables }: DBConfig): DBSnapshot;
|
||||
export declare function createEmptySnapshot(): DBSnapshot;
|
||||
export declare function formatDataLossMessage(confirmations: string[], isColor?: boolean): string;
|
||||
373
node_modules/@astrojs/db/dist/core/cli/migration-queries.js
generated
vendored
Normal file
373
node_modules/@astrojs/db/dist/core/cli/migration-queries.js
generated
vendored
Normal file
@@ -0,0 +1,373 @@
|
||||
import { stripVTControlCharacters } from "node:util";
|
||||
import diff from "microdiff";
|
||||
import { sql } from "drizzle-orm";
|
||||
import { SQLiteAsyncDialect } from "drizzle-orm/sqlite-core";
|
||||
import { customAlphabet } from "nanoid";
|
||||
import color from "piccolore";
|
||||
import { isSerializedSQL } from "../../runtime/types.js";
|
||||
import { hasPrimaryKey, isDbError } from "../../runtime/utils.js";
|
||||
import { MIGRATION_VERSION } from "../consts.js";
|
||||
import { createClient } from "../db-client/libsql-node.js";
|
||||
import { RENAME_COLUMN_ERROR, RENAME_TABLE_ERROR } from "../errors.js";
|
||||
import {
|
||||
getCreateIndexQueries,
|
||||
getCreateTableQuery,
|
||||
getDropTableIfExistsQuery,
|
||||
getModifiers,
|
||||
getReferencesConfig,
|
||||
hasDefault,
|
||||
schemaTypeToSqlType
|
||||
} from "../queries.js";
|
||||
import { columnSchema } from "../schemas.js";
|
||||
const sqlite = new SQLiteAsyncDialect();
|
||||
const genTempTableName = customAlphabet("abcdefghijklmnopqrstuvwxyz", 10);
|
||||
async function getMigrationQueries({
|
||||
oldSnapshot,
|
||||
newSnapshot,
|
||||
reset = false
|
||||
}) {
|
||||
const queries = [];
|
||||
const confirmations = [];
|
||||
if (reset) {
|
||||
const currentSnapshot = oldSnapshot;
|
||||
oldSnapshot = createEmptySnapshot();
|
||||
queries.push(...getDropTableQueriesForSnapshot(currentSnapshot));
|
||||
}
|
||||
const addedTables = getAddedTables(oldSnapshot, newSnapshot);
|
||||
const droppedTables = getDroppedTables(oldSnapshot, newSnapshot);
|
||||
const notDeprecatedDroppedTables = Object.fromEntries(
|
||||
Object.entries(droppedTables).filter(([, table]) => !table.deprecated)
|
||||
);
|
||||
if (!isEmpty(addedTables) && !isEmpty(notDeprecatedDroppedTables)) {
|
||||
const oldTable = Object.keys(notDeprecatedDroppedTables)[0];
|
||||
const newTable = Object.keys(addedTables)[0];
|
||||
throw new Error(RENAME_TABLE_ERROR(oldTable, newTable));
|
||||
}
|
||||
for (const [tableName, table] of Object.entries(addedTables)) {
|
||||
queries.push(getCreateTableQuery(tableName, table));
|
||||
queries.push(...getCreateIndexQueries(tableName, table));
|
||||
}
|
||||
for (const [tableName] of Object.entries(droppedTables)) {
|
||||
const dropQuery = `DROP TABLE ${sqlite.escapeName(tableName)}`;
|
||||
queries.push(dropQuery);
|
||||
}
|
||||
for (const [tableName, newTable] of Object.entries(newSnapshot.schema)) {
|
||||
const oldTable = oldSnapshot.schema[tableName];
|
||||
if (!oldTable) continue;
|
||||
const addedColumns = getAdded(oldTable.columns, newTable.columns);
|
||||
const droppedColumns = getDropped(oldTable.columns, newTable.columns);
|
||||
const notDeprecatedDroppedColumns = Object.fromEntries(
|
||||
Object.entries(droppedColumns).filter(([, col]) => !col.schema.deprecated)
|
||||
);
|
||||
if (!isEmpty(addedColumns) && !isEmpty(notDeprecatedDroppedColumns)) {
|
||||
throw new Error(
|
||||
RENAME_COLUMN_ERROR(
|
||||
`${tableName}.${Object.keys(addedColumns)[0]}`,
|
||||
`${tableName}.${Object.keys(notDeprecatedDroppedColumns)[0]}`
|
||||
)
|
||||
);
|
||||
}
|
||||
const result = await getTableChangeQueries({
|
||||
tableName,
|
||||
oldTable,
|
||||
newTable
|
||||
});
|
||||
queries.push(...result.queries);
|
||||
confirmations.push(...result.confirmations);
|
||||
}
|
||||
return { queries, confirmations };
|
||||
}
|
||||
async function getTableChangeQueries({
|
||||
tableName,
|
||||
oldTable,
|
||||
newTable
|
||||
}) {
|
||||
const queries = [];
|
||||
const confirmations = [];
|
||||
const updated = getUpdatedColumns(oldTable.columns, newTable.columns);
|
||||
const added = getAdded(oldTable.columns, newTable.columns);
|
||||
const dropped = getDropped(oldTable.columns, newTable.columns);
|
||||
const hasForeignKeyChanges = diff(oldTable.foreignKeys ?? [], newTable.foreignKeys ?? []).length > 0;
|
||||
if (!hasForeignKeyChanges && isEmpty(updated) && isEmpty(added) && isEmpty(dropped)) {
|
||||
return {
|
||||
queries: getChangeIndexQueries({
|
||||
tableName,
|
||||
oldIndexes: oldTable.indexes,
|
||||
newIndexes: newTable.indexes
|
||||
}),
|
||||
confirmations
|
||||
};
|
||||
}
|
||||
if (!hasForeignKeyChanges && isEmpty(updated) && Object.values(dropped).every(canAlterTableDropColumn) && Object.values(added).every(canAlterTableAddColumn)) {
|
||||
queries.push(
|
||||
...getAlterTableQueries(tableName, added, dropped),
|
||||
...getChangeIndexQueries({
|
||||
tableName,
|
||||
oldIndexes: oldTable.indexes,
|
||||
newIndexes: newTable.indexes
|
||||
})
|
||||
);
|
||||
return { queries, confirmations };
|
||||
}
|
||||
const dataLossCheck = canRecreateTableWithoutDataLoss(added, updated);
|
||||
if (dataLossCheck.dataLoss) {
|
||||
const { reason, columnName } = dataLossCheck;
|
||||
const reasonMsgs = {
|
||||
"added-required": `You added new required column '${color.bold(
|
||||
tableName + "." + columnName
|
||||
)}' with no default value.
|
||||
This cannot be executed on an existing table.`,
|
||||
"updated-type": `Updating existing column ${color.bold(
|
||||
tableName + "." + columnName
|
||||
)} to a new type that cannot be handled automatically.`
|
||||
};
|
||||
confirmations.push(reasonMsgs[reason]);
|
||||
}
|
||||
const primaryKeyExists = Object.entries(newTable.columns).find(
|
||||
([, column]) => hasPrimaryKey(column)
|
||||
);
|
||||
const droppedPrimaryKey = Object.entries(dropped).find(([, column]) => hasPrimaryKey(column));
|
||||
const recreateTableQueries = getRecreateTableQueries({
|
||||
tableName,
|
||||
newTable,
|
||||
added,
|
||||
hasDataLoss: dataLossCheck.dataLoss,
|
||||
migrateHiddenPrimaryKey: !primaryKeyExists && !droppedPrimaryKey
|
||||
});
|
||||
queries.push(...recreateTableQueries, ...getCreateIndexQueries(tableName, newTable));
|
||||
return { queries, confirmations };
|
||||
}
|
||||
function getChangeIndexQueries({
|
||||
tableName,
|
||||
oldIndexes = {},
|
||||
newIndexes = {}
|
||||
}) {
|
||||
const added = getAdded(oldIndexes, newIndexes);
|
||||
const dropped = getDropped(oldIndexes, newIndexes);
|
||||
const updated = getUpdated(oldIndexes, newIndexes);
|
||||
Object.assign(dropped, updated);
|
||||
Object.assign(added, updated);
|
||||
const queries = [];
|
||||
for (const indexName of Object.keys(dropped)) {
|
||||
const dropQuery = `DROP INDEX ${sqlite.escapeName(indexName)}`;
|
||||
queries.push(dropQuery);
|
||||
}
|
||||
queries.push(...getCreateIndexQueries(tableName, { indexes: added }));
|
||||
return queries;
|
||||
}
|
||||
function getAddedTables(oldTables, newTables) {
|
||||
const added = {};
|
||||
for (const [key, newTable] of Object.entries(newTables.schema)) {
|
||||
if (!(key in oldTables.schema)) added[key] = newTable;
|
||||
}
|
||||
return added;
|
||||
}
|
||||
function getDroppedTables(oldTables, newTables) {
|
||||
const dropped = {};
|
||||
for (const [key, oldTable] of Object.entries(oldTables.schema)) {
|
||||
if (!(key in newTables.schema)) dropped[key] = oldTable;
|
||||
}
|
||||
return dropped;
|
||||
}
|
||||
function getAlterTableQueries(unescTableName, added, dropped) {
|
||||
const queries = [];
|
||||
const tableName = sqlite.escapeName(unescTableName);
|
||||
for (const [unescColumnName, column] of Object.entries(added)) {
|
||||
const columnName = sqlite.escapeName(unescColumnName);
|
||||
const type = schemaTypeToSqlType(column.type);
|
||||
const q = `ALTER TABLE ${tableName} ADD COLUMN ${columnName} ${type}${getModifiers(
|
||||
columnName,
|
||||
column
|
||||
)}`;
|
||||
queries.push(q);
|
||||
}
|
||||
for (const unescColumnName of Object.keys(dropped)) {
|
||||
const columnName = sqlite.escapeName(unescColumnName);
|
||||
const q = `ALTER TABLE ${tableName} DROP COLUMN ${columnName}`;
|
||||
queries.push(q);
|
||||
}
|
||||
return queries;
|
||||
}
|
||||
function getRecreateTableQueries({
|
||||
tableName: unescTableName,
|
||||
newTable,
|
||||
added,
|
||||
hasDataLoss,
|
||||
migrateHiddenPrimaryKey
|
||||
}) {
|
||||
const unescTempName = `${unescTableName}_${genTempTableName()}`;
|
||||
const tempName = sqlite.escapeName(unescTempName);
|
||||
const tableName = sqlite.escapeName(unescTableName);
|
||||
if (hasDataLoss) {
|
||||
return [`DROP TABLE ${tableName}`, getCreateTableQuery(unescTableName, newTable)];
|
||||
}
|
||||
const newColumns = [...Object.keys(newTable.columns)];
|
||||
if (migrateHiddenPrimaryKey) {
|
||||
newColumns.unshift("_id");
|
||||
}
|
||||
const escapedColumns = newColumns.filter((i) => !(i in added)).map((c) => sqlite.escapeName(c)).join(", ");
|
||||
return [
|
||||
getCreateTableQuery(unescTempName, newTable),
|
||||
`INSERT INTO ${tempName} (${escapedColumns}) SELECT ${escapedColumns} FROM ${tableName}`,
|
||||
`DROP TABLE ${tableName}`,
|
||||
`ALTER TABLE ${tempName} RENAME TO ${tableName}`
|
||||
];
|
||||
}
|
||||
function isEmpty(obj) {
|
||||
return Object.keys(obj).length === 0;
|
||||
}
|
||||
function canAlterTableAddColumn(column) {
|
||||
if (column.schema.unique) return false;
|
||||
if (hasRuntimeDefault(column)) return false;
|
||||
if (!column.schema.optional && !hasDefault(column)) return false;
|
||||
if (hasPrimaryKey(column)) return false;
|
||||
if (getReferencesConfig(column)) return false;
|
||||
return true;
|
||||
}
|
||||
function canAlterTableDropColumn(column) {
|
||||
if (column.schema.unique) return false;
|
||||
if (hasPrimaryKey(column)) return false;
|
||||
return true;
|
||||
}
|
||||
function canRecreateTableWithoutDataLoss(added, updated) {
|
||||
for (const [columnName, a] of Object.entries(added)) {
|
||||
if (hasPrimaryKey(a) && a.type !== "number" && !hasDefault(a)) {
|
||||
return { dataLoss: true, columnName, reason: "added-required" };
|
||||
}
|
||||
if (!a.schema.optional && !hasDefault(a)) {
|
||||
return { dataLoss: true, columnName, reason: "added-required" };
|
||||
}
|
||||
}
|
||||
for (const [columnName, u] of Object.entries(updated)) {
|
||||
if (u.old.type !== u.new.type && !canChangeTypeWithoutQuery(u.old, u.new)) {
|
||||
return { dataLoss: true, columnName, reason: "updated-type" };
|
||||
}
|
||||
}
|
||||
return { dataLoss: false };
|
||||
}
|
||||
function getAdded(oldObj, newObj) {
|
||||
const added = {};
|
||||
for (const [key, value] of Object.entries(newObj)) {
|
||||
if (!(key in oldObj)) added[key] = value;
|
||||
}
|
||||
return added;
|
||||
}
|
||||
function getDropped(oldObj, newObj) {
|
||||
const dropped = {};
|
||||
for (const [key, value] of Object.entries(oldObj)) {
|
||||
if (!(key in newObj)) dropped[key] = value;
|
||||
}
|
||||
return dropped;
|
||||
}
|
||||
function getUpdated(oldObj, newObj) {
|
||||
const updated = {};
|
||||
for (const [key, value] of Object.entries(newObj)) {
|
||||
const oldValue = oldObj[key];
|
||||
if (!oldValue) continue;
|
||||
if (diff(oldValue, value).length > 0) updated[key] = value;
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
function getUpdatedColumns(oldColumns, newColumns) {
|
||||
const updated = {};
|
||||
for (const [key, newColumn] of Object.entries(newColumns)) {
|
||||
let oldColumn = oldColumns[key];
|
||||
if (!oldColumn) continue;
|
||||
if (oldColumn.type !== newColumn.type && canChangeTypeWithoutQuery(oldColumn, newColumn)) {
|
||||
const asNewColumn = columnSchema.safeParse({
|
||||
type: newColumn.type,
|
||||
schema: oldColumn.schema
|
||||
});
|
||||
if (asNewColumn.success) {
|
||||
oldColumn = asNewColumn.data;
|
||||
}
|
||||
}
|
||||
const diffResult = diff(oldColumn, newColumn);
|
||||
if (diffResult.length > 0) {
|
||||
updated[key] = { old: oldColumn, new: newColumn };
|
||||
}
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
const typeChangesWithoutQuery = [
|
||||
{ from: "boolean", to: "number" },
|
||||
{ from: "date", to: "text" },
|
||||
{ from: "json", to: "text" }
|
||||
];
|
||||
function canChangeTypeWithoutQuery(oldColumn, newColumn) {
|
||||
return typeChangesWithoutQuery.some(
|
||||
({ from, to }) => oldColumn.type === from && newColumn.type === to
|
||||
);
|
||||
}
|
||||
function hasRuntimeDefault(column) {
|
||||
return !!(column.schema.default && isSerializedSQL(column.schema.default));
|
||||
}
|
||||
function getProductionCurrentSnapshot({
|
||||
url,
|
||||
token
|
||||
}) {
|
||||
return getDbCurrentSnapshot(token, url);
|
||||
}
|
||||
async function getDbCurrentSnapshot(appToken, remoteUrl) {
|
||||
const client = createClient({
|
||||
token: appToken,
|
||||
url: remoteUrl
|
||||
});
|
||||
try {
|
||||
const res = await client.get(
|
||||
// Latest snapshot
|
||||
sql`select snapshot from _astro_db_snapshot order by id desc limit 1;`
|
||||
);
|
||||
return JSON.parse(res.snapshot);
|
||||
} catch (error) {
|
||||
if (isDbError(error) && // If the schema was never pushed to the database yet the table won't exist.
|
||||
// Treat a missing snapshot table as an empty table.
|
||||
// When connecting to a remote database in that condition
|
||||
// the query will fail with the following error code and message.
|
||||
(error.code === "SQLITE_UNKNOWN" && error.message === "SQLITE_UNKNOWN: SQLite error: no such table: _astro_db_snapshot" || // When connecting to a local or in-memory database that does not have a snapshot table yet
|
||||
// the query will fail with the following error code and message.
|
||||
error.code === "SQLITE_ERROR" && error.message === "SQLITE_ERROR: no such table: _astro_db_snapshot")) {
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
function getDropTableQueriesForSnapshot(snapshot) {
|
||||
const queries = [];
|
||||
for (const tableName of Object.keys(snapshot.schema)) {
|
||||
const dropQuery = getDropTableIfExistsQuery(tableName);
|
||||
queries.unshift(dropQuery);
|
||||
}
|
||||
return queries;
|
||||
}
|
||||
function createCurrentSnapshot({ tables = {} }) {
|
||||
const schema = JSON.parse(JSON.stringify(tables));
|
||||
return { version: MIGRATION_VERSION, schema };
|
||||
}
|
||||
function createEmptySnapshot() {
|
||||
return { version: MIGRATION_VERSION, schema: {} };
|
||||
}
|
||||
function formatDataLossMessage(confirmations, isColor = true) {
|
||||
const messages = [];
|
||||
messages.push(color.red("\u2716 We found some schema changes that cannot be handled automatically:"));
|
||||
messages.push(``);
|
||||
messages.push(...confirmations.map((m, i) => color.red(` (${i + 1}) `) + m));
|
||||
messages.push(``);
|
||||
messages.push(`To resolve, revert these changes or update your schema, and re-run the command.`);
|
||||
messages.push(
|
||||
`You may also run 'astro db push --force-reset' to ignore all warnings and force-push your local database schema to production instead. All data will be lost and the database will be reset.`
|
||||
);
|
||||
let finalMessage = messages.join("\n");
|
||||
if (!isColor) {
|
||||
finalMessage = stripVTControlCharacters(finalMessage);
|
||||
}
|
||||
return finalMessage;
|
||||
}
|
||||
export {
|
||||
createCurrentSnapshot,
|
||||
createEmptySnapshot,
|
||||
formatDataLossMessage,
|
||||
getMigrationQueries,
|
||||
getProductionCurrentSnapshot,
|
||||
getTableChangeQueries
|
||||
};
|
||||
11
node_modules/@astrojs/db/dist/core/cli/print-help.d.ts
generated
vendored
Normal file
11
node_modules/@astrojs/db/dist/core/cli/print-help.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Uses implementation from Astro core
|
||||
* @see https://github.com/withastro/astro/blob/main/packages/astro/src/core/messages.ts#L303
|
||||
*/
|
||||
export declare function printHelp({ commandName, headline, usage, tables, description, }: {
|
||||
commandName: string;
|
||||
headline?: string;
|
||||
usage?: string;
|
||||
tables?: Record<string, [command: string, help: string][]>;
|
||||
description?: string;
|
||||
}): void;
|
||||
55
node_modules/@astrojs/db/dist/core/cli/print-help.js
generated
vendored
Normal file
55
node_modules/@astrojs/db/dist/core/cli/print-help.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import colors from "piccolore";
|
||||
function printHelp({
|
||||
commandName,
|
||||
headline,
|
||||
usage,
|
||||
tables,
|
||||
description
|
||||
}) {
|
||||
const linebreak = () => "";
|
||||
const title = (label) => ` ${colors.bgWhite(colors.black(` ${label} `))}`;
|
||||
const table = (rows, { padding }) => {
|
||||
const split = process.stdout.columns < 60;
|
||||
let raw = "";
|
||||
for (const row of rows) {
|
||||
if (split) {
|
||||
raw += ` ${row[0]}
|
||||
`;
|
||||
} else {
|
||||
raw += `${`${row[0]}`.padStart(padding)}`;
|
||||
}
|
||||
raw += " " + colors.dim(row[1]) + "\n";
|
||||
}
|
||||
return raw.slice(0, -1);
|
||||
};
|
||||
let message = [];
|
||||
if (headline) {
|
||||
message.push(
|
||||
linebreak(),
|
||||
` ${colors.bgGreen(colors.black(` ${commandName} `))} ${colors.green(
|
||||
`v${"0.20.1"}`
|
||||
)} ${headline}`
|
||||
);
|
||||
}
|
||||
if (usage) {
|
||||
message.push(linebreak(), ` ${colors.green(commandName)} ${colors.bold(usage)}`);
|
||||
}
|
||||
if (tables) {
|
||||
let calculateTablePadding2 = function(rows) {
|
||||
return rows.reduce((val, [first]) => Math.max(val, first.length), 0) + 2;
|
||||
};
|
||||
var calculateTablePadding = calculateTablePadding2;
|
||||
const tableEntries = Object.entries(tables);
|
||||
const padding = Math.max(...tableEntries.map(([, rows]) => calculateTablePadding2(rows)));
|
||||
for (const [tableTitle, tableRows] of tableEntries) {
|
||||
message.push(linebreak(), title(tableTitle), table(tableRows, { padding }));
|
||||
}
|
||||
}
|
||||
if (description) {
|
||||
message.push(linebreak(), `${description}`);
|
||||
}
|
||||
console.log(message.join("\n") + "\n");
|
||||
}
|
||||
export {
|
||||
printHelp
|
||||
};
|
||||
12
node_modules/@astrojs/db/dist/core/consts.d.ts
generated
vendored
Normal file
12
node_modules/@astrojs/db/dist/core/consts.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export declare const RUNTIME_IMPORT: string;
|
||||
export declare const RUNTIME_VIRTUAL_IMPORT: string;
|
||||
export declare const VIRTUAL_MODULE_ID = "astro:db";
|
||||
export declare const DB_PATH = ".astro/content.db";
|
||||
export declare const CONFIG_FILE_NAMES: string[];
|
||||
export declare const MIGRATION_VERSION = "2024-03-12";
|
||||
export declare const VIRTUAL_CLIENT_MODULE_ID = "virtual:astro:db-client";
|
||||
export declare const DB_CLIENTS: {
|
||||
node: string;
|
||||
web: string;
|
||||
local: string;
|
||||
};
|
||||
26
node_modules/@astrojs/db/dist/core/consts.js
generated
vendored
Normal file
26
node_modules/@astrojs/db/dist/core/consts.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
const PACKAGE_NAME = JSON.parse(
|
||||
readFileSync(new URL("../../package.json", import.meta.url), "utf8")
|
||||
).name;
|
||||
const RUNTIME_IMPORT = JSON.stringify(`${PACKAGE_NAME}/runtime`);
|
||||
const RUNTIME_VIRTUAL_IMPORT = JSON.stringify(`${PACKAGE_NAME}/dist/runtime/virtual.js`);
|
||||
const VIRTUAL_MODULE_ID = "astro:db";
|
||||
const DB_PATH = ".astro/content.db";
|
||||
const CONFIG_FILE_NAMES = ["config.ts", "config.js", "config.mts", "config.mjs"];
|
||||
const MIGRATION_VERSION = "2024-03-12";
|
||||
const VIRTUAL_CLIENT_MODULE_ID = "virtual:astro:db-client";
|
||||
const DB_CLIENTS = {
|
||||
node: `${PACKAGE_NAME}/db-client/libsql-node.js`,
|
||||
web: `${PACKAGE_NAME}/db-client/libsql-web.js`,
|
||||
local: `${PACKAGE_NAME}/db-client/libsql-local.js`
|
||||
};
|
||||
export {
|
||||
CONFIG_FILE_NAMES,
|
||||
DB_CLIENTS,
|
||||
DB_PATH,
|
||||
MIGRATION_VERSION,
|
||||
RUNTIME_IMPORT,
|
||||
RUNTIME_VIRTUAL_IMPORT,
|
||||
VIRTUAL_CLIENT_MODULE_ID,
|
||||
VIRTUAL_MODULE_ID
|
||||
};
|
||||
6
node_modules/@astrojs/db/dist/core/db-client/libsql-local.d.ts
generated
vendored
Normal file
6
node_modules/@astrojs/db/dist/core/db-client/libsql-local.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { type LibSQLDatabase } from 'drizzle-orm/libsql';
|
||||
type LocalDbClientOptions = {
|
||||
url: string;
|
||||
};
|
||||
export declare function createClient(options: LocalDbClientOptions): LibSQLDatabase;
|
||||
export {};
|
||||
12
node_modules/@astrojs/db/dist/core/db-client/libsql-local.js
generated
vendored
Normal file
12
node_modules/@astrojs/db/dist/core/db-client/libsql-local.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createClient as createLibsqlClient } from "@libsql/client";
|
||||
import { drizzle as drizzleLibsql } from "drizzle-orm/libsql";
|
||||
const isWebContainer = !!process.versions?.webcontainer;
|
||||
function createClient(options) {
|
||||
const url = isWebContainer ? "file:content.db" : options.url;
|
||||
const client = createLibsqlClient({ url });
|
||||
const db = drizzleLibsql(client);
|
||||
return db;
|
||||
}
|
||||
export {
|
||||
createClient
|
||||
};
|
||||
8
node_modules/@astrojs/db/dist/core/db-client/libsql-node.d.ts
generated
vendored
Normal file
8
node_modules/@astrojs/db/dist/core/db-client/libsql-node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
type RemoteDbClientOptions = {
|
||||
token: string;
|
||||
url: string;
|
||||
};
|
||||
export declare function createClient(opts: RemoteDbClientOptions): import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>> & {
|
||||
$client: import("@libsql/client").Client;
|
||||
};
|
||||
export {};
|
||||
21
node_modules/@astrojs/db/dist/core/db-client/libsql-node.js
generated
vendored
Normal file
21
node_modules/@astrojs/db/dist/core/db-client/libsql-node.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createClient as createLibsqlClient } from "@libsql/client";
|
||||
import { drizzle as drizzleLibsql } from "drizzle-orm/libsql";
|
||||
import { parseLibSQLConfig } from "./utils.js";
|
||||
function createClient(opts) {
|
||||
const { token, url: rawUrl } = opts;
|
||||
let parsedUrl = new URL(rawUrl);
|
||||
const options = Object.fromEntries(parsedUrl.searchParams.entries());
|
||||
parsedUrl.search = "";
|
||||
let url = parsedUrl.toString();
|
||||
if (parsedUrl.protocol === "memory:") {
|
||||
url = ":memory:";
|
||||
} else if (parsedUrl.protocol === "file:" && parsedUrl.pathname.startsWith("/") && !rawUrl.startsWith("file:/")) {
|
||||
url = "file:" + parsedUrl.pathname.substring(1);
|
||||
}
|
||||
const libSQLOptions = parseLibSQLConfig(options);
|
||||
const client = createLibsqlClient({ ...libSQLOptions, url, authToken: token });
|
||||
return drizzleLibsql(client);
|
||||
}
|
||||
export {
|
||||
createClient
|
||||
};
|
||||
8
node_modules/@astrojs/db/dist/core/db-client/libsql-web.d.ts
generated
vendored
Normal file
8
node_modules/@astrojs/db/dist/core/db-client/libsql-web.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
type RemoteDbClientOptions = {
|
||||
token: string;
|
||||
url: string;
|
||||
};
|
||||
export declare function createClient(opts: RemoteDbClientOptions): import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>> & {
|
||||
$client: import("@libsql/client/web").Client;
|
||||
};
|
||||
export {};
|
||||
22
node_modules/@astrojs/db/dist/core/db-client/libsql-web.js
generated
vendored
Normal file
22
node_modules/@astrojs/db/dist/core/db-client/libsql-web.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { createClient as createLibsqlClient } from "@libsql/client/web";
|
||||
import { drizzle as drizzleLibsql } from "drizzle-orm/libsql/web";
|
||||
import { parseLibSQLConfig } from "./utils.js";
|
||||
function createClient(opts) {
|
||||
const { token, url: rawUrl } = opts;
|
||||
let parsedUrl = new URL(rawUrl);
|
||||
const options = Object.fromEntries(parsedUrl.searchParams.entries());
|
||||
parsedUrl.search = "";
|
||||
let url = parsedUrl.toString();
|
||||
const supportedProtocols = ["http:", "https:", "libsql:"];
|
||||
if (!supportedProtocols.includes(parsedUrl.protocol)) {
|
||||
throw new Error(
|
||||
`Unsupported protocol "${parsedUrl.protocol}" for libSQL web client. Supported protocols are: ${supportedProtocols.join(", ")}.`
|
||||
);
|
||||
}
|
||||
const libSQLOptions = parseLibSQLConfig(options);
|
||||
const client = createLibsqlClient({ ...libSQLOptions, url, authToken: token });
|
||||
return drizzleLibsql(client);
|
||||
}
|
||||
export {
|
||||
createClient
|
||||
};
|
||||
2
node_modules/@astrojs/db/dist/core/db-client/utils.d.ts
generated
vendored
Normal file
2
node_modules/@astrojs/db/dist/core/db-client/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { Config as LibSQLConfig } from '@libsql/client';
|
||||
export declare const parseLibSQLConfig: (config: Record<string, string>) => Partial<LibSQLConfig>;
|
||||
46
node_modules/@astrojs/db/dist/core/db-client/utils.js
generated
vendored
Normal file
46
node_modules/@astrojs/db/dist/core/db-client/utils.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import * as z from "zod/v4";
|
||||
const rawLibSQLOptions = z.record(z.string(), z.string());
|
||||
const parseNumber = (value) => z.coerce.number().parse(value);
|
||||
const parseBoolean = (value) => z.coerce.boolean().parse(value);
|
||||
const booleanValues = ["true", "false"];
|
||||
const parseOptionalBoolean = (value) => {
|
||||
if (booleanValues.includes(value)) {
|
||||
return parseBoolean(value);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const libSQLConfigTransformed = rawLibSQLOptions.transform((raw) => {
|
||||
const parsed = {};
|
||||
for (const [key, value] of Object.entries(raw)) {
|
||||
switch (key) {
|
||||
case "syncInterval":
|
||||
case "concurrency":
|
||||
parsed[key] = parseNumber(value);
|
||||
break;
|
||||
case "readYourWrites":
|
||||
case "offline":
|
||||
case "tls":
|
||||
parsed[key] = parseOptionalBoolean(value);
|
||||
break;
|
||||
case "authToken":
|
||||
case "encryptionKey":
|
||||
case "syncUrl":
|
||||
parsed[key] = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parsed;
|
||||
});
|
||||
const parseLibSQLConfig = (config) => {
|
||||
try {
|
||||
return libSQLConfigTransformed.parse(config);
|
||||
} catch (error) {
|
||||
if (error instanceof z.ZodError) {
|
||||
throw new Error(`Invalid LibSQL config: ${error.issues.map((e) => e.message).join(", ")}`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
export {
|
||||
parseLibSQLConfig
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user