emdash 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapters-C2BzVy0p.d.mts → adapters-Di31kZ28.d.mts} +16 -1
- package/dist/adapters-Di31kZ28.d.mts.map +1 -0
- package/dist/{apply-Cma_PiF6.mjs → apply-B4MsLM-w.mjs} +27 -12
- package/dist/apply-B4MsLM-w.mjs.map +1 -0
- package/dist/astro/index.d.mts +6 -6
- package/dist/astro/index.d.mts.map +1 -1
- package/dist/astro/index.mjs +199 -33
- package/dist/astro/index.mjs.map +1 -1
- package/dist/astro/middleware/auth.d.mts +5 -5
- package/dist/astro/middleware/auth.d.mts.map +1 -1
- package/dist/astro/middleware/auth.mjs +30 -4
- package/dist/astro/middleware/auth.mjs.map +1 -1
- package/dist/astro/middleware/redirect.mjs +1 -1
- package/dist/astro/middleware/request-context.d.mts.map +1 -1
- package/dist/astro/middleware/request-context.mjs +5 -3
- package/dist/astro/middleware/request-context.mjs.map +1 -1
- package/dist/astro/middleware/setup.mjs +1 -1
- package/dist/astro/middleware.d.mts.map +1 -1
- package/dist/astro/middleware.mjs +460 -180
- package/dist/astro/middleware.mjs.map +1 -1
- package/dist/astro/types.d.mts +8 -9
- package/dist/astro/types.d.mts.map +1 -1
- package/dist/{byline-WuOq9MFJ.mjs → byline-C4OVd8b3.mjs} +3 -19
- package/dist/byline-C4OVd8b3.mjs.map +1 -0
- package/dist/{bylines-C_Wsnz4L.mjs → bylines-hPTW79hw.mjs} +20 -33
- package/dist/bylines-hPTW79hw.mjs.map +1 -0
- package/dist/{cache-E3Dts-yT.mjs → cache-BkKBuIvS.mjs} +1 -1
- package/dist/{cache-E3Dts-yT.mjs.map → cache-BkKBuIvS.mjs.map} +1 -1
- package/dist/chunks-HGz06Soa.mjs +19 -0
- package/dist/chunks-HGz06Soa.mjs.map +1 -0
- package/dist/cli/index.mjs +9 -8
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/cf-access.d.mts +1 -1
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/{config-DkxPrM9l.mjs → config-BXwuX8Bx.mjs} +1 -1
- package/dist/{config-DkxPrM9l.mjs.map → config-BXwuX8Bx.mjs.map} +1 -1
- package/dist/{connection-B4zVnQIa.mjs → connection-2igzM-AT.mjs} +19 -2
- package/dist/connection-2igzM-AT.mjs.map +1 -0
- package/dist/database/instrumentation.d.mts +45 -0
- package/dist/database/instrumentation.d.mts.map +1 -0
- package/dist/database/instrumentation.mjs +61 -0
- package/dist/database/instrumentation.mjs.map +1 -0
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs.map +1 -1
- package/dist/db/libsql.d.mts +1 -1
- package/dist/db/postgres.d.mts +1 -1
- package/dist/db/sqlite.d.mts +1 -1
- package/dist/db-errors-D0UT85nC.mjs +41 -0
- package/dist/db-errors-D0UT85nC.mjs.map +1 -0
- package/dist/{default-PUx9RK6u.mjs → default-CME5YdZ3.mjs} +1 -1
- package/dist/{default-PUx9RK6u.mjs.map → default-CME5YdZ3.mjs.map} +1 -1
- package/dist/{error-HBeQbVhV.mjs → error-CiYn9yDu.mjs} +1 -1
- package/dist/{error-HBeQbVhV.mjs.map → error-CiYn9yDu.mjs.map} +1 -1
- package/dist/{index-CCWzlriB.d.mts → index-BYv0mB9g.d.mts} +135 -19
- package/dist/index-BYv0mB9g.d.mts.map +1 -0
- package/dist/index.d.mts +11 -11
- package/dist/index.mjs +20 -18
- package/dist/{load-BhSSm-TS.mjs → load-CBcmDIot.mjs} +1 -1
- package/dist/{load-BhSSm-TS.mjs.map → load-CBcmDIot.mjs.map} +1 -1
- package/dist/{loader-BYzwzORf.mjs → loader-DeiBJEMe.mjs} +18 -12
- package/dist/loader-DeiBJEMe.mjs.map +1 -0
- package/dist/{manifest-schema-BsXINkQD.mjs → manifest-schema-V30qsMft.mjs} +1 -1
- package/dist/{manifest-schema-BsXINkQD.mjs.map → manifest-schema-V30qsMft.mjs.map} +1 -1
- package/dist/media/index.d.mts +1 -1
- package/dist/media/index.mjs +1 -1
- package/dist/media/local-runtime.d.mts +7 -7
- package/dist/{mode-CyPLdO3C.mjs → mode-CpNnGkPz.mjs} +1 -1
- package/dist/{mode-CyPLdO3C.mjs.map → mode-CpNnGkPz.mjs.map} +1 -1
- package/dist/page/index.d.mts +11 -2
- package/dist/page/index.d.mts.map +1 -1
- package/dist/page/index.mjs +23 -1
- package/dist/page/index.mjs.map +1 -1
- package/dist/{placeholder-DntBEQo7.mjs → placeholder-C-fk5hYI.mjs} +1 -1
- package/dist/{placeholder-DntBEQo7.mjs.map → placeholder-C-fk5hYI.mjs.map} +1 -1
- package/dist/{placeholder-BBCtpTES.d.mts → placeholder-tzpqGWII.d.mts} +1 -1
- package/dist/{placeholder-BBCtpTES.d.mts.map → placeholder-tzpqGWII.d.mts.map} +1 -1
- package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
- package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
- package/dist/{query-B6Vu0d2i.mjs → query-Bk_3vKvU.mjs} +78 -11
- package/dist/query-Bk_3vKvU.mjs.map +1 -0
- package/dist/{registry-BgnP3ysR.mjs → registry-Ci3WxVAr.mjs} +133 -97
- package/dist/registry-Ci3WxVAr.mjs.map +1 -0
- package/dist/request-cache-DiR961CV.mjs +79 -0
- package/dist/request-cache-DiR961CV.mjs.map +1 -0
- package/dist/request-context.d.mts +19 -16
- package/dist/request-context.d.mts.map +1 -1
- package/dist/request-context.mjs.map +1 -1
- package/dist/{runner-DYv3rX8P.d.mts → runner-Fl2NcUUz.d.mts} +2 -2
- package/dist/{runner-DYv3rX8P.d.mts.map → runner-Fl2NcUUz.d.mts.map} +1 -1
- package/dist/runtime.d.mts +6 -6
- package/dist/runtime.mjs +1 -1
- package/dist/{search-Cn1SYvYF.mjs → search-DI4bM2w9.mjs} +96 -206
- package/dist/search-DI4bM2w9.mjs.map +1 -0
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +8 -7
- package/dist/seo/index.d.mts +1 -1
- package/dist/storage/local.d.mts +1 -1
- package/dist/storage/local.mjs +1 -1
- package/dist/storage/s3.d.mts +1 -1
- package/dist/storage/s3.mjs +1 -1
- package/dist/taxonomies-DbrKzDju.mjs +308 -0
- package/dist/taxonomies-DbrKzDju.mjs.map +1 -0
- package/dist/{tokens-DKHiCYCB.mjs → tokens-BFPFx3CA.mjs} +1 -1
- package/dist/{tokens-DKHiCYCB.mjs.map → tokens-BFPFx3CA.mjs.map} +1 -1
- package/dist/{transport-BtcQ-Z7T.mjs → transport-BykRfpyy.mjs} +1 -1
- package/dist/{transport-BtcQ-Z7T.mjs.map → transport-BykRfpyy.mjs.map} +1 -1
- package/dist/{transport-CKQA_G44.d.mts → transport-H4Iwx7tC.d.mts} +1 -1
- package/dist/{transport-CKQA_G44.d.mts.map → transport-H4Iwx7tC.d.mts.map} +1 -1
- package/dist/{types-BmkQR1En.d.mts → types-6CUZRrZP.d.mts} +1 -1
- package/dist/{types-BmkQR1En.d.mts.map → types-6CUZRrZP.d.mts.map} +1 -1
- package/dist/{types-B6BzlZxx.d.mts → types-8xrvl_68.d.mts} +1 -1
- package/dist/{types-B6BzlZxx.d.mts.map → types-8xrvl_68.d.mts.map} +1 -1
- package/dist/{types-Dz9_WMS6.mjs → types-BH2L167P.mjs} +1 -1
- package/dist/{types-Dz9_WMS6.mjs.map → types-BH2L167P.mjs.map} +1 -1
- package/dist/{types-DNZpaCBk.d.mts → types-CFWjXmus.d.mts} +1 -1
- package/dist/{types-DNZpaCBk.d.mts.map → types-CFWjXmus.d.mts.map} +1 -1
- package/dist/{types-DeG21anB.d.mts → types-CnZYHyLW.d.mts} +55 -5
- package/dist/types-CnZYHyLW.d.mts.map +1 -0
- package/dist/{types-xxCWI3j0.mjs → types-DDS4MxsT.mjs} +11 -3
- package/dist/types-DDS4MxsT.mjs.map +1 -0
- package/dist/{types-C3ronwXb.d.mts → types-DgrIP0tF.d.mts} +102 -4
- package/dist/types-DgrIP0tF.d.mts.map +1 -0
- package/dist/{validate-Db1yNL3i.d.mts → validate-CaLH1Ia2.d.mts} +5 -52
- package/dist/validate-CaLH1Ia2.d.mts.map +1 -0
- package/dist/{validate-DuZDIxfy.mjs → validate-CqsNItbt.mjs} +2 -2
- package/dist/{validate-DuZDIxfy.mjs.map → validate-CqsNItbt.mjs.map} +1 -1
- package/dist/version-Uaf2ynPX.mjs +7 -0
- package/dist/{version-CMMjTuqu.mjs.map → version-Uaf2ynPX.mjs.map} +1 -1
- package/package.json +10 -5
- package/src/after.ts +62 -0
- package/src/api/handlers/oauth-authorization.ts +2 -32
- package/src/api/handlers/oauth-clients.ts +40 -4
- package/src/api/handlers/taxonomies.ts +13 -0
- package/src/api/oauth/redirect-uri.ts +34 -0
- package/src/api/openapi/document.ts +126 -118
- package/src/api/schemas/media.ts +26 -15
- package/src/api/schemas/schema.ts +1 -0
- package/src/astro/integration/font-provider.ts +176 -0
- package/src/astro/integration/index.ts +42 -0
- package/src/astro/integration/routes.ts +6 -0
- package/src/astro/integration/runtime.ts +63 -0
- package/src/astro/integration/virtual-modules.ts +41 -39
- package/src/astro/integration/vite-config.ts +16 -5
- package/src/astro/middleware/auth.ts +33 -1
- package/src/astro/middleware/request-context.ts +15 -3
- package/src/astro/middleware.ts +340 -263
- package/src/astro/routes/admin.astro +7 -3
- package/src/astro/routes/api/auth/passkey/verify.ts +5 -1
- package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +5 -0
- package/src/astro/routes/api/import/wordpress/execute.ts +1 -1
- package/src/astro/routes/api/import/wordpress-plugin/execute.ts +1 -1
- package/src/astro/routes/api/media/upload-url.ts +10 -2
- package/src/astro/routes/api/media.ts +10 -7
- package/src/astro/routes/api/oauth/register.ts +178 -0
- package/src/astro/routes/api/oauth/token.ts +15 -0
- package/src/astro/routes/api/openapi.json.ts +15 -5
- package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +2 -0
- package/src/astro/routes/api/schema/collections/[slug]/fields/index.ts +1 -0
- package/src/astro/routes/api/schema/collections/[slug]/fields/reorder.ts +1 -0
- package/src/astro/routes/api/search/index.ts +5 -0
- package/src/astro/routes/api/search/suggest.ts +3 -0
- package/src/astro/routes/api/taxonomies/index.ts +1 -0
- package/src/astro/routes/api/well-known/oauth-authorization-server.ts +1 -1
- package/src/bylines/index.ts +22 -45
- package/src/components/EmDashHead.astro +23 -7
- package/src/database/connection.ts +23 -1
- package/src/database/instrumentation.ts +98 -0
- package/src/db/adapters.ts +15 -0
- package/src/emdash-runtime.ts +309 -91
- package/src/index.ts +6 -0
- package/src/loader.ts +19 -24
- package/src/menus/index.ts +6 -3
- package/src/page/index.ts +1 -1
- package/src/page/seo-contributions.ts +36 -0
- package/src/query.ts +104 -7
- package/src/request-cache.ts +106 -0
- package/src/request-context.ts +19 -0
- package/src/schema/query.ts +5 -2
- package/src/schema/registry.ts +243 -166
- package/src/schema/types.ts +13 -2
- package/src/schema/zod-generator.ts +4 -0
- package/src/search/fts-manager.ts +19 -5
- package/src/search/query.ts +4 -3
- package/src/seed/apply.ts +15 -1
- package/src/settings/index.ts +24 -5
- package/src/taxonomies/index.ts +324 -124
- package/src/utils/db-errors.ts +46 -0
- package/src/virtual-modules.d.ts +31 -10
- package/src/widgets/index.ts +54 -25
- package/dist/adapters-C2BzVy0p.d.mts.map +0 -1
- package/dist/apply-Cma_PiF6.mjs.map +0 -1
- package/dist/byline-WuOq9MFJ.mjs.map +0 -1
- package/dist/bylines-C_Wsnz4L.mjs.map +0 -1
- package/dist/connection-B4zVnQIa.mjs.map +0 -1
- package/dist/index-CCWzlriB.d.mts.map +0 -1
- package/dist/loader-BYzwzORf.mjs.map +0 -1
- package/dist/query-B6Vu0d2i.mjs.map +0 -1
- package/dist/registry-BgnP3ysR.mjs.map +0 -1
- package/dist/search-Cn1SYvYF.mjs.map +0 -1
- package/dist/types-C3ronwXb.d.mts.map +0 -1
- package/dist/types-DeG21anB.d.mts.map +0 -1
- package/dist/types-xxCWI3j0.mjs.map +0 -1
- package/dist/validate-Db1yNL3i.d.mts.map +0 -1
- package/dist/version-CMMjTuqu.mjs +0 -7
package/dist/astro/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { t as defaultSeed } from "../default-
|
|
2
|
-
import { n as VERSION, t as COMMIT } from "../version-
|
|
1
|
+
import { t as defaultSeed } from "../default-CME5YdZ3.mjs";
|
|
2
|
+
import { n as VERSION, t as COMMIT } from "../version-Uaf2ynPX.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import { fontProviders } from "astro/config";
|
|
4
5
|
import { dirname, resolve } from "node:path";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -63,6 +64,128 @@ function local(config) {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/astro/integration/font-provider.ts
|
|
69
|
+
/**
|
|
70
|
+
* EmDash Noto Sans font provider
|
|
71
|
+
*
|
|
72
|
+
* A custom Astro font provider that wraps Google Fonts to resolve
|
|
73
|
+
* multiple Noto Sans families (Latin, Arabic, JP, etc.) under a
|
|
74
|
+
* single logical font entry. This lets all @font-face blocks share
|
|
75
|
+
* the same font-family name, so the browser picks the right file
|
|
76
|
+
* per character via unicode-range.
|
|
77
|
+
*
|
|
78
|
+
* Without this, registering "Noto Sans" and "Noto Sans Arabic" as
|
|
79
|
+
* separate font entries on the same cssVariable triggers an Astro
|
|
80
|
+
* warning and the last entry overwrites the first.
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* All subset names used by Google Fonts CSS responses.
|
|
84
|
+
* Passed when resolving extra script families so the unifont
|
|
85
|
+
* provider doesn't filter out any faces.
|
|
86
|
+
*/
|
|
87
|
+
const ALL_GOOGLE_SUBSETS = [
|
|
88
|
+
"arabic",
|
|
89
|
+
"armenian",
|
|
90
|
+
"bengali",
|
|
91
|
+
"chinese-simplified",
|
|
92
|
+
"chinese-traditional",
|
|
93
|
+
"chinese-hongkong",
|
|
94
|
+
"cyrillic",
|
|
95
|
+
"cyrillic-ext",
|
|
96
|
+
"devanagari",
|
|
97
|
+
"ethiopic",
|
|
98
|
+
"georgian",
|
|
99
|
+
"greek",
|
|
100
|
+
"greek-ext",
|
|
101
|
+
"gujarati",
|
|
102
|
+
"gurmukhi",
|
|
103
|
+
"hebrew",
|
|
104
|
+
"japanese",
|
|
105
|
+
"kannada",
|
|
106
|
+
"khmer",
|
|
107
|
+
"korean",
|
|
108
|
+
"lao",
|
|
109
|
+
"latin",
|
|
110
|
+
"latin-ext",
|
|
111
|
+
"malayalam",
|
|
112
|
+
"math",
|
|
113
|
+
"myanmar",
|
|
114
|
+
"oriya",
|
|
115
|
+
"sinhala",
|
|
116
|
+
"symbols",
|
|
117
|
+
"tamil",
|
|
118
|
+
"telugu",
|
|
119
|
+
"thai",
|
|
120
|
+
"tibetan",
|
|
121
|
+
"vietnamese"
|
|
122
|
+
];
|
|
123
|
+
/**
|
|
124
|
+
* Known Noto Sans script families on Google Fonts.
|
|
125
|
+
* Maps user-friendly script names to Google Fonts family names.
|
|
126
|
+
*/
|
|
127
|
+
const NOTO_SCRIPT_FAMILIES = {
|
|
128
|
+
arabic: "Noto Sans Arabic",
|
|
129
|
+
armenian: "Noto Sans Armenian",
|
|
130
|
+
bengali: "Noto Sans Bengali",
|
|
131
|
+
"chinese-simplified": "Noto Sans SC",
|
|
132
|
+
"chinese-traditional": "Noto Sans TC",
|
|
133
|
+
"chinese-hongkong": "Noto Sans HK",
|
|
134
|
+
devanagari: "Noto Sans Devanagari",
|
|
135
|
+
ethiopic: "Noto Sans Ethiopic",
|
|
136
|
+
georgian: "Noto Sans Georgian",
|
|
137
|
+
gujarati: "Noto Sans Gujarati",
|
|
138
|
+
gurmukhi: "Noto Sans Gurmukhi",
|
|
139
|
+
hebrew: "Noto Sans Hebrew",
|
|
140
|
+
japanese: "Noto Sans JP",
|
|
141
|
+
kannada: "Noto Sans Kannada",
|
|
142
|
+
khmer: "Noto Sans Khmer",
|
|
143
|
+
korean: "Noto Sans KR",
|
|
144
|
+
lao: "Noto Sans Lao",
|
|
145
|
+
malayalam: "Noto Sans Malayalam",
|
|
146
|
+
myanmar: "Noto Sans Myanmar",
|
|
147
|
+
oriya: "Noto Sans Oriya",
|
|
148
|
+
sinhala: "Noto Sans Sinhala",
|
|
149
|
+
tamil: "Noto Sans Tamil",
|
|
150
|
+
telugu: "Noto Sans Telugu",
|
|
151
|
+
thai: "Noto Sans Thai",
|
|
152
|
+
tibetan: "Noto Sans Tibetan"
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Create a font provider that resolves Noto Sans plus additional
|
|
156
|
+
* script-specific Noto families from Google Fonts, all under one
|
|
157
|
+
* font-family name.
|
|
158
|
+
*/
|
|
159
|
+
function notoSans(options) {
|
|
160
|
+
const googleProvider = fontProviders.google();
|
|
161
|
+
return {
|
|
162
|
+
name: "emdash-noto",
|
|
163
|
+
async init(context) {
|
|
164
|
+
await googleProvider.init?.(context);
|
|
165
|
+
},
|
|
166
|
+
async resolveFont(resolveFontOptions) {
|
|
167
|
+
const base = await googleProvider.resolveFont(resolveFontOptions);
|
|
168
|
+
const baseFonts = base?.fonts ?? [];
|
|
169
|
+
if (!options?.scripts?.length) return base;
|
|
170
|
+
const baseSubsets = new Set(baseFonts.map((f) => f.meta?.subset).filter(Boolean));
|
|
171
|
+
const extraFaces = (await Promise.all(options.scripts.map(async (script) => {
|
|
172
|
+
const family = NOTO_SCRIPT_FAMILIES[script];
|
|
173
|
+
if (!family) {
|
|
174
|
+
if (ALL_GOOGLE_SUBSETS.includes(script)) return;
|
|
175
|
+
console.warn(`[emdash] Unknown Noto Sans script "${script}". Available: ${Object.keys(NOTO_SCRIPT_FAMILIES).join(", ")}`);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
return googleProvider.resolveFont({
|
|
179
|
+
...resolveFontOptions,
|
|
180
|
+
familyName: family,
|
|
181
|
+
subsets: ALL_GOOGLE_SUBSETS
|
|
182
|
+
});
|
|
183
|
+
}))).flatMap((r) => (r?.fonts ?? []).filter((f) => !f.meta?.subset || !baseSubsets.has(f.meta.subset)));
|
|
184
|
+
return { fonts: [...baseFonts, ...extraFaces] };
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
66
189
|
//#endregion
|
|
67
190
|
//#region src/astro/integration/routes.ts
|
|
68
191
|
/**
|
|
@@ -447,6 +570,10 @@ function injectCoreRoutes(injectRoute) {
|
|
|
447
570
|
pattern: "/.well-known/oauth-authorization-server/_emdash",
|
|
448
571
|
entrypoint: resolveRoute("api/well-known/oauth-authorization-server.ts")
|
|
449
572
|
});
|
|
573
|
+
injectRoute({
|
|
574
|
+
pattern: "/_emdash/api/oauth/register",
|
|
575
|
+
entrypoint: resolveRoute("api/oauth/register.ts")
|
|
576
|
+
});
|
|
450
577
|
injectRoute({
|
|
451
578
|
pattern: "/_emdash/api/plugins/[pluginId]/[...path]",
|
|
452
579
|
entrypoint: resolveRoute("api/plugins/[pluginId]/[...path].ts")
|
|
@@ -741,6 +868,8 @@ const VIRTUAL_BLOCK_COMPONENTS_ID = "virtual:emdash/block-components";
|
|
|
741
868
|
const RESOLVED_VIRTUAL_BLOCK_COMPONENTS_ID = "\0" + VIRTUAL_BLOCK_COMPONENTS_ID;
|
|
742
869
|
const VIRTUAL_SEED_ID = "virtual:emdash/seed";
|
|
743
870
|
const RESOLVED_VIRTUAL_SEED_ID = "\0" + VIRTUAL_SEED_ID;
|
|
871
|
+
const VIRTUAL_WAIT_UNTIL_ID = "virtual:emdash/wait-until";
|
|
872
|
+
const RESOLVED_VIRTUAL_WAIT_UNTIL_ID = "\0" + VIRTUAL_WAIT_UNTIL_ID;
|
|
744
873
|
/**
|
|
745
874
|
* Generates the config virtual module.
|
|
746
875
|
*/
|
|
@@ -749,42 +878,32 @@ function generateConfigModule(serializableConfig) {
|
|
|
749
878
|
}
|
|
750
879
|
/**
|
|
751
880
|
* Generates the dialect virtual module.
|
|
752
|
-
* Statically imports the configured database dialect and exports the dialect type.
|
|
753
881
|
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
* middleware for per-request
|
|
757
|
-
*
|
|
758
|
-
*
|
|
882
|
+
* Adapters that set `supportsRequestScope: true` on their descriptor are
|
|
883
|
+
* expected to export `createRequestScopedDb` from their runtime entrypoint;
|
|
884
|
+
* the generator re-exports it so middleware can ask for a per-request Kysely
|
|
885
|
+
* (used for D1 Sessions API, bookmark cookies, read-replica routing). Other
|
|
886
|
+
* adapters get a stub that returns null.
|
|
759
887
|
*/
|
|
760
|
-
function generateDialectModule(
|
|
761
|
-
|
|
888
|
+
function generateDialectModule(opts) {
|
|
889
|
+
const { entrypoint, supportsRequestScope } = opts;
|
|
890
|
+
if (!entrypoint) return [
|
|
762
891
|
`export const createDialect = undefined;`,
|
|
763
892
|
`export const dialectType = "sqlite";`,
|
|
764
|
-
`export const
|
|
765
|
-
`export const getD1Binding = () => null;`,
|
|
766
|
-
`export const getDefaultConstraint = () => "first-unconstrained";`,
|
|
767
|
-
`export const getBookmarkCookieName = () => "";`,
|
|
768
|
-
`export const createSessionDialect = undefined;`
|
|
893
|
+
`export const createRequestScopedDb = (_opts) => null;`
|
|
769
894
|
].join("\n");
|
|
770
|
-
const type =
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
import { createDialect as _createDialect } from "${dbEntrypoint}";
|
|
775
|
-
export { isSessionEnabled, getD1Binding, getDefaultConstraint, getBookmarkCookieName, createSessionDialect } from "${dbEntrypoint}";
|
|
895
|
+
const type = opts.type ?? "sqlite";
|
|
896
|
+
if (supportsRequestScope) return `
|
|
897
|
+
import { createDialect as _createDialect } from "${entrypoint}";
|
|
898
|
+
export { createRequestScopedDb } from "${entrypoint}";
|
|
776
899
|
export const createDialect = _createDialect;
|
|
777
900
|
export const dialectType = ${JSON.stringify(type)};
|
|
778
901
|
`;
|
|
779
902
|
return `
|
|
780
|
-
import { createDialect as _createDialect } from "${
|
|
903
|
+
import { createDialect as _createDialect } from "${entrypoint}";
|
|
781
904
|
export const createDialect = _createDialect;
|
|
782
905
|
export const dialectType = ${JSON.stringify(type)};
|
|
783
|
-
export const
|
|
784
|
-
export const getD1Binding = () => null;
|
|
785
|
-
export const getDefaultConstraint = () => "first-unconstrained";
|
|
786
|
-
export const getBookmarkCookieName = () => "";
|
|
787
|
-
export const createSessionDialect = undefined;
|
|
906
|
+
export const createRequestScopedDb = (_opts) => null;
|
|
788
907
|
`;
|
|
789
908
|
}
|
|
790
909
|
/**
|
|
@@ -960,6 +1079,22 @@ function generateBlockComponentsModule(descriptors) {
|
|
|
960
1079
|
return `${imports.join("\n")}\nexport const pluginBlockComponents = { ${spreads.join(", ")} };`;
|
|
961
1080
|
}
|
|
962
1081
|
/**
|
|
1082
|
+
* Generates the wait-until virtual module.
|
|
1083
|
+
*
|
|
1084
|
+
* Under @astrojs/cloudflare, re-exports `waitUntil` from `cloudflare:workers`
|
|
1085
|
+
* so `after(fn)` in core can extend the worker's lifetime past the response
|
|
1086
|
+
* for deferred bookkeeping. For any other adapter, exports `undefined` —
|
|
1087
|
+
* Node's long-lived event loop keeps deferred promises running without a
|
|
1088
|
+
* lifetime extender.
|
|
1089
|
+
*
|
|
1090
|
+
* Keeping the adapter check here — rather than in core — means core itself
|
|
1091
|
+
* has no Cloudflare-specific imports or code paths.
|
|
1092
|
+
*/
|
|
1093
|
+
function generateWaitUntilModule(adapterName) {
|
|
1094
|
+
if (adapterName === "@astrojs/cloudflare") return `export { waitUntil } from "cloudflare:workers";`;
|
|
1095
|
+
return `export const waitUntil = undefined;`;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
963
1098
|
* Generates the seed virtual module.
|
|
964
1099
|
* Reads the user's seed file at build time (in Node context) and embeds it,
|
|
965
1100
|
* so the runtime doesn't need filesystem access (required for workerd).
|
|
@@ -1117,10 +1252,15 @@ function createVirtualModulesPlugin(options) {
|
|
|
1117
1252
|
if (id === VIRTUAL_MEDIA_PROVIDERS_ID) return RESOLVED_VIRTUAL_MEDIA_PROVIDERS_ID;
|
|
1118
1253
|
if (id === VIRTUAL_BLOCK_COMPONENTS_ID) return RESOLVED_VIRTUAL_BLOCK_COMPONENTS_ID;
|
|
1119
1254
|
if (id === VIRTUAL_SEED_ID) return RESOLVED_VIRTUAL_SEED_ID;
|
|
1255
|
+
if (id === VIRTUAL_WAIT_UNTIL_ID) return RESOLVED_VIRTUAL_WAIT_UNTIL_ID;
|
|
1120
1256
|
},
|
|
1121
1257
|
load(id) {
|
|
1122
1258
|
if (id === RESOLVED_VIRTUAL_CONFIG_ID) return generateConfigModule(serializableConfig);
|
|
1123
|
-
if (id === RESOLVED_VIRTUAL_DIALECT_ID) return generateDialectModule(
|
|
1259
|
+
if (id === RESOLVED_VIRTUAL_DIALECT_ID) return generateDialectModule({
|
|
1260
|
+
entrypoint: resolvedConfig.database?.entrypoint,
|
|
1261
|
+
type: resolvedConfig.database?.type,
|
|
1262
|
+
supportsRequestScope: resolvedConfig.database?.supportsRequestScope ?? false
|
|
1263
|
+
});
|
|
1124
1264
|
if (id === RESOLVED_VIRTUAL_STORAGE_ID) return generateStorageModule(resolvedConfig.storage?.entrypoint);
|
|
1125
1265
|
if (id === RESOLVED_VIRTUAL_PLUGINS_ID) return generatePluginsModule(pluginDescriptors);
|
|
1126
1266
|
if (id === RESOLVED_VIRTUAL_ADMIN_REGISTRY_ID) return generateAdminRegistryModule([...pluginDescriptors, ...resolvedConfig.sandboxed ?? []]);
|
|
@@ -1137,6 +1277,7 @@ function createVirtualModulesPlugin(options) {
|
|
|
1137
1277
|
if (id === RESOLVED_VIRTUAL_MEDIA_PROVIDERS_ID) return generateMediaProvidersModule(resolvedConfig.mediaProviders ?? []);
|
|
1138
1278
|
if (id === RESOLVED_VIRTUAL_BLOCK_COMPONENTS_ID) return generateBlockComponentsModule(pluginDescriptors);
|
|
1139
1279
|
if (id === RESOLVED_VIRTUAL_SEED_ID) return generateSeedModule(fileURLToPath(astroConfig.root));
|
|
1280
|
+
if (id === RESOLVED_VIRTUAL_WAIT_UNTIL_ID) return generateWaitUntilModule(astroConfig.adapter?.name);
|
|
1140
1281
|
}
|
|
1141
1282
|
};
|
|
1142
1283
|
}
|
|
@@ -1320,7 +1461,8 @@ function emdash(config = {}) {
|
|
|
1320
1461
|
storage: resolvedConfig.storage,
|
|
1321
1462
|
auth: resolvedConfig.auth,
|
|
1322
1463
|
marketplace: resolvedConfig.marketplace,
|
|
1323
|
-
siteUrl: resolvedConfig.siteUrl
|
|
1464
|
+
siteUrl: resolvedConfig.siteUrl,
|
|
1465
|
+
maxUploadSize: resolvedConfig.maxUploadSize
|
|
1324
1466
|
};
|
|
1325
1467
|
const useExternalAuth = !!(resolvedConfig.auth && "entrypoint" in resolvedConfig.auth);
|
|
1326
1468
|
return {
|
|
@@ -1337,11 +1479,35 @@ function emdash(config = {}) {
|
|
|
1337
1479
|
prefixDefaultLocale: typeof routing === "object" ? routing.prefixDefaultLocale ?? false : false
|
|
1338
1480
|
};
|
|
1339
1481
|
}
|
|
1482
|
+
const securityConfig = {
|
|
1483
|
+
checkOrigin: false,
|
|
1484
|
+
...resolvedConfig.siteUrl ? { allowedDomains: [{ hostname: new URL(resolvedConfig.siteUrl).hostname }] } : {}
|
|
1485
|
+
};
|
|
1486
|
+
const fontsConfig = resolvedConfig.fonts;
|
|
1340
1487
|
updateConfig({
|
|
1341
|
-
security:
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1488
|
+
security: securityConfig,
|
|
1489
|
+
fonts: fontsConfig === false ? [] : [{
|
|
1490
|
+
provider: notoSans({ scripts: fontsConfig?.scripts }),
|
|
1491
|
+
name: "Noto Sans",
|
|
1492
|
+
cssVariable: "--font-emdash",
|
|
1493
|
+
weights: ["100 900"],
|
|
1494
|
+
styles: ["normal", "italic"],
|
|
1495
|
+
subsets: [
|
|
1496
|
+
"latin",
|
|
1497
|
+
"latin-ext",
|
|
1498
|
+
"cyrillic",
|
|
1499
|
+
"cyrillic-ext",
|
|
1500
|
+
"devanagari",
|
|
1501
|
+
"greek",
|
|
1502
|
+
"greek-ext",
|
|
1503
|
+
"vietnamese"
|
|
1504
|
+
],
|
|
1505
|
+
fallbacks: [
|
|
1506
|
+
"ui-sans-serif",
|
|
1507
|
+
"system-ui",
|
|
1508
|
+
"sans-serif"
|
|
1509
|
+
]
|
|
1510
|
+
}],
|
|
1345
1511
|
vite: createViteConfig({
|
|
1346
1512
|
serializableConfig,
|
|
1347
1513
|
resolvedConfig,
|