@heyo-sh/heyo-cms 0.1.0 → 0.2.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/astro.d.ts +12 -5
- package/dist/adapters/astro.d.ts.map +1 -1
- package/dist/adapters/astro.js +1 -1
- package/dist/adapters/deliver.d.ts +26 -0
- package/dist/adapters/deliver.d.ts.map +1 -0
- package/dist/adapters/next.d.ts +26 -12
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +1 -1
- package/dist/adapters/nuxt.d.ts +10 -6
- package/dist/adapters/nuxt.d.ts.map +1 -1
- package/dist/adapters/nuxt.js +1 -1
- package/dist/adapters/react-router.d.ts +12 -5
- package/dist/adapters/react-router.d.ts.map +1 -1
- package/dist/adapters/react-router.js +1 -1
- package/dist/adapters/sveltekit.d.ts +9 -5
- package/dist/adapters/sveltekit.d.ts.map +1 -1
- package/dist/adapters/sveltekit.js +1 -1
- package/dist/ai.js +1 -1
- package/dist/auth.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +24 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/content.js +1 -1
- package/dist/db/d1.js +1 -1
- package/dist/db/mongodb.js +2 -2
- package/dist/db/postgres.js +1 -1
- package/dist/db/sql/dialect.d.ts +2 -0
- package/dist/db/sql/dialect.d.ts.map +1 -1
- package/dist/db/sqlite.d.ts +13 -2
- package/dist/db/sqlite.d.ts.map +1 -1
- package/dist/db/sqlite.js +1 -1
- package/dist/editor/builtin.d.ts.map +1 -1
- package/dist/editor/serialize.d.ts.map +1 -1
- package/dist/editor.d.ts +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +1 -1
- package/dist/engine/engine.d.ts +19 -0
- package/dist/engine/engine.d.ts.map +1 -1
- package/dist/engine/slugs.d.ts +124 -0
- package/dist/engine/slugs.d.ts.map +1 -0
- package/dist/fields/builtin.d.ts +42 -15
- package/dist/fields/builtin.d.ts.map +1 -1
- package/dist/fields.d.ts +1 -0
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +1 -1
- package/dist/http/handler.d.ts.map +1 -1
- package/dist/http/rich-text.d.ts +12 -1
- package/dist/http/rich-text.d.ts.map +1 -1
- package/dist/http/routes/documents.d.ts.map +1 -1
- package/dist/http/routes/media.d.ts +30 -0
- package/dist/http/routes/media.d.ts.map +1 -1
- package/dist/http.js +1 -1
- package/dist/index-2ddk43me.js +2 -0
- package/dist/index-2prbs05k.js +2 -0
- package/dist/index-385ggnge.js +2 -0
- package/dist/{index-7k091gpe.js → index-466cwb0b.js} +2 -2
- package/dist/{index-b2ecggck.js → index-4qrep5f0.js} +6 -6
- package/dist/{index-k8wbg1dw.js → index-67e458ws.js} +2 -2
- package/dist/index-6m1kjq9g.js +2 -0
- package/dist/index-6w10rch0.js +3 -0
- package/dist/index-761dec5z.js +2 -0
- package/dist/{index-2kb5nbxx.js → index-8nzmqy0f.js} +2 -2
- package/dist/{index-vq2978e7.js → index-8x2em6c8.js} +8 -8
- package/dist/index-91fa1gzf.js +2 -0
- package/dist/index-a8jcwqsf.js +2 -0
- package/dist/index-abfzb1ve.js +2 -0
- package/dist/index-cv0hpz3d.js +2 -0
- package/dist/index-g041kfa5.js +18 -0
- package/dist/index-hbx67b20.js +7 -0
- package/dist/index-hpast878.js +40 -0
- package/dist/index-kc1j3h6z.js +2 -0
- package/dist/index-p2cqsmvw.js +2 -0
- package/dist/index-rg9tpg3p.js +5 -0
- package/dist/{index-cbwwtcm4.js → index-rw0hze6x.js} +2 -2
- package/dist/index-s9x07zb3.js +2 -0
- package/dist/index-sgdnp83t.js +2 -0
- package/dist/{index-34s342fz.js → index-szaq03qq.js} +2 -2
- package/dist/{index-9x1z3b85.js → index-vkwzdfte.js} +4 -4
- package/dist/{index-gpwcmmvr.js → index-vzhxn50e.js} +2 -2
- package/dist/index-y8kzzn94.js +2 -0
- package/dist/{index-7a231xfp.js → index-ypcmns0v.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/jobs.js +1 -1
- package/dist/media/cloudflare.d.ts +58 -0
- package/dist/media/cloudflare.d.ts.map +1 -0
- package/dist/media/document.d.ts +7 -6
- package/dist/media/document.d.ts.map +1 -1
- package/dist/media/gc.d.ts.map +1 -1
- package/dist/media/pipeline.d.ts +19 -0
- package/dist/media/pipeline.d.ts.map +1 -1
- package/dist/media/service.d.ts.map +1 -1
- package/dist/media/urls.d.ts +77 -0
- package/dist/media/urls.d.ts.map +1 -0
- package/dist/media/usages.d.ts +9 -1
- package/dist/media/usages.d.ts.map +1 -1
- package/dist/media/variants.d.ts +11 -0
- package/dist/media/variants.d.ts.map +1 -1
- package/dist/migrations.js +1 -1
- package/dist/plugins/indexnow.d.ts +82 -0
- package/dist/plugins/indexnow.d.ts.map +1 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +1 -0
- package/dist/query.js +1 -1
- package/dist/{run-3r72dwhs.js → run-bjge3v8e.js} +4 -4
- package/dist/schema/snapshot.d.ts +2 -0
- package/dist/schema/snapshot.d.ts.map +1 -1
- package/dist/schema/system.d.ts +9 -0
- package/dist/schema/system.d.ts.map +1 -1
- package/dist/schema.js +1 -1
- package/dist/slugify.d.ts +31 -0
- package/dist/slugify.d.ts.map +1 -0
- package/dist/telemetry.js +1 -1
- package/dist/types/api.d.ts +56 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/config.d.ts +15 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/editor.d.ts +26 -0
- package/dist/types/editor.d.ts.map +1 -1
- package/dist/types/media.d.ts +97 -0
- package/dist/types/media.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +23 -1
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/uploads.d.ts +1 -0
- package/dist/uploads.d.ts.map +1 -1
- package/dist/uploads.js +4 -4
- package/dist/webhooks.js +1 -1
- package/package.json +9 -5
- package/dist/index-2757kej5.js +0 -2
- package/dist/index-2z1qe5mw.js +0 -2
- package/dist/index-5ngtc7gy.js +0 -2
- package/dist/index-9zqnf6gx.js +0 -23
- package/dist/index-hq05mc1n.js +0 -3
- package/dist/index-hy1x46nf.js +0 -2
- package/dist/index-kbsgt44t.js +0 -2
- package/dist/index-m82a0shw.js +0 -2
- package/dist/index-md79xr6h.js +0 -5
- package/dist/index-nvgwyykk.js +0 -40
- package/dist/index-ty698y02.js +0 -2
- package/dist/index-vxw0a03g.js +0 -2
- package/dist/index-wj8y1xcj.js +0 -2
- package/dist/index-y5mwknr9.js +0 -2
- package/dist/index-ymq6jsar.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
export{
|
|
1
|
+
function Ce(e,n){let t=[],a=[],r=[],i=[],c=[],o=[],s=[],f=[],p=d(e.tables),x=d(n.tables),g=[];for(let u of l(n.tables)){let h=p.get(u.name);if(!h){g.push(u);for(let M of l(u.indexes))c.push({kind:"create_index",index:M});continue}C(h,u,a,r,s),T(h,u,i,c)}for(let u of _(g))t.push({kind:"create_table",table:u});let y=l(e.tables).filter((u)=>!x.has(u.name));for(let u of _(y).reverse())f.push({kind:"drop_table",table:u.name});return w(e,n,o),[...t,...a,...r,...i,...c,...o,...s,...f]}function _(e){let n=new Map(l(e).map((i)=>[i.name,i])),t=[],a=new Set,r=(i)=>{if(!n.has(i.name))return;if(a.has(i.name))return;a.add(i.name);for(let c of l(i.columns)){let o=c.references?.table;if(o===void 0||o===i.name)continue;let s=n.get(o);if(s)r(s)}if(a.delete(i.name),n.delete(i.name))t.push(i)};for(let i of l(e))r(i);return t}function C(e,n,t,a,r){let i=d(e.columns),c=d(n.columns);for(let o of l(n.columns)){let s=i.get(o.name);if(!s){t.push({kind:"add_column",table:n.name,column:o});continue}let f=k(s,o);if(f.length>0)a.push({kind:"alter_column",table:n.name,column:o,previous:s,changes:f})}for(let o of l(e.columns))if(!c.has(o.name))r.push({kind:"drop_column",table:e.name,column:o.name})}function k(e,n){let t=[];if(e.type!==n.type||e.array!==n.array)t.push("type");if(e.nullable!==n.nullable)t.push("nullable");if(!m(e.default,n.default))t.push("default");if(!m(e.references,n.references))t.push("references");return t}function T(e,n,t,a){let r=d(e.indexes),i=d(n.indexes);for(let c of l(e.indexes)){let o=i.get(c.name);if(!o){t.push({kind:"drop_index",table:e.name,index:c.name});continue}if(!b(c,o))t.push({kind:"drop_index",table:e.name,index:c.name})}for(let c of l(n.indexes)){let o=r.get(c.name);if(!o||!b(o,c))a.push({kind:"create_index",index:c})}}function b(e,n){return e.unique===n.unique&&m(e.targets,n.targets)&&m(e.where,n.where)}function w(e,n,t){let a=d(e.collections);for(let r of l(n.collections)){let i=a.get(r.name),c=d(i?.fields??[]);for(let o of l(r.fields)){let s=c.get(o.name),f=!m(s?.default,o.default),p=s===void 0;if(o.localized)continue;if(o.default!==void 0&&(p||f))t.push({kind:"set_document_field",table:r.table,collection:r.slug,documentColumn:r.documentColumn,path:S(o),value:o.default})}if(i){let o=d(r.fields);for(let s of l(i.fields))if(!o.has(s.name)&&!s.localized)t.push({kind:"unset_document_field",table:r.table,collection:r.slug,documentColumn:r.documentColumn,path:S(s)})}}}function S(e){return[e.name]}function d(e){return new Map(e.map((n)=>[n.name,n]))}function l(e){return[...e].sort((n,t)=>n.name.localeCompare(t.name))}function m(e,n){if(e===n)return!0;if(e===void 0||n===void 0)return!1;return Ue(e)===Ue(n)}function Ue(e){if(e===null||typeof e!=="object")return JSON.stringify(e)??"null";if(Array.isArray(e))return`[${e.map((t)=>Ue(t)).join(",")}]`;return`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[a])=>t.localeCompare(a)).map(([t,a])=>`${JSON.stringify(t)}:${Ue(a)}`).join(",")}}`}function Oe(e){switch(e.kind){case"create_table":return`create table ${e.table.name}`;case"drop_table":return`drop table ${e.table}`;case"add_column":return`add ${e.table}.${e.column.name} (${v(e.column.type,e.column.array)})`;case"drop_column":return`drop ${e.table}.${e.column}`;case"alter_column":return`alter ${e.table}.${e.column.name} (${e.changes.join(", ")})`;case"create_index":return`create ${e.index.unique?"unique ":""}index ${e.index.name}`;case"drop_index":return`drop index ${e.index}`;case"set_document_field":return`backfill ${e.collection}.${e.path.join(".")} = ${JSON.stringify(e.value)}`;case"unset_document_field":return`remove ${e.collection}.${e.path.join(".")} from stored documents`}}function v(e,n){return n===!0?`${e}[]`:e}function Fn(e){if(e.length===0)return"empty";let n=e[0],t=(()=>{switch(n.kind){case"create_table":return e.filter((a)=>a.kind==="create_table").length>1?"create_schema":`create_${n.table.name}`;case"drop_table":return`drop_${n.table}`;case"add_column":return`add_${n.table}_${n.column.name}`;case"drop_column":return`drop_${n.table}_${n.column}`;case"alter_column":return`alter_${n.table}_${n.column.name}`;case"create_index":return`index_${n.index.name.replace(/^(idx|uniq)_/,"")}`;case"drop_index":return`drop_index_${n.index.replace(/^(idx|uniq)_/,"")}`;case"set_document_field":return`backfill_${n.collection}_${n.path.join("_")}`;case"unset_document_field":return`remove_${n.collection}_${n.path.join("_")}`}})();return j(e.length>1?`${t}_and_${e.length-1}_more`:t)}function j(e){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,"_"),t=0,a=n.length;while(t<a&&n[t]==="_")t++;while(a>t&&n[a-1]==="_")a--;return n.slice(t,a).slice(0,60)}
|
|
2
|
+
export{Ce,Ue,Oe,Fn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e}from"./index-x72d1hzh.js";var c=new Set(["dashboard","collection-list","document","global","media","trash","settings"]),g=100,r=200,f=120,m=new Set(["users","roles","locales","keys","ai","webhooks","deployment","activity"]);function
|
|
2
|
-
export{
|
|
1
|
+
import{e}from"./index-x72d1hzh.js";var c=new Set(["dashboard","collection-list","document","global","media","trash","settings"]),g=100,r=200,f=120,m=new Set(["users","roles","locales","keys","ai","webhooks","deployment","activity"]);function no(l){if(typeof l!=="object"||l===null||Array.isArray(l))return;let n=l,i=n.kind;if(typeof i!=="string"||!c.has(i))return;let t=Array.isArray(n.dirtyFields)?n.dirtyFields.filter((s)=>typeof s==="string").slice(0,g):void 0,o=Number(n.baselineRevision);return{kind:i,...typeof n.collectionSlug==="string"?{collectionSlug:n.collectionSlug.slice(0,r)}:{},...typeof n.documentId==="string"?{documentId:n.documentId.slice(0,r)}:{},...typeof n.mediaId==="string"?{mediaId:n.mediaId.slice(0,r)}:{},...typeof n.tab==="string"&&n.tab.trim().length>0?{tab:n.tab.trim().slice(0,f)}:{},...typeof n.locale==="string"?{locale:n.locale}:{},...t&&t.length>0?{dirtyFields:t}:{},...Number.isInteger(o)&&o>0?{baselineRevision:o}:{}}}function oo(l,n,i){let t=i!==void 0&&a(l,i)?i:l.i18n.defaultLocale;if(!n)return{kind:"dashboard",collection:null,documentId:null,mediaId:null,tab:null,locale:t,dirtyFields:[],baselineRevision:null};let o=n.locale!==void 0&&a(l,n.locale)?n.locale:t,s=C(l,n);return{kind:n.kind,collection:s,documentId:n.documentId??null,mediaId:n.kind==="media"?n.mediaId??null:null,tab:b(n,s),locale:o,dirtyFields:n.dirtyFields??[],baselineRevision:n.baselineRevision??null}}function b(l,n){let i=l.tab;if(!i)return null;if(l.kind==="settings")return m.has(i)?i:null;if(l.kind==="media")return i==="active"||i==="orphaned"?i:null;if(l.kind==="document"||l.kind==="global")return n?.fields[i]?.type==="richText"?i:null;return null}function C(l,n){if(n.collectionSlug===void 0)return null;let i=n.kind==="global"?"global":n.kind==="document"||n.kind==="collection-list"?"collection":void 0;if(i===void 0)return null;let t={...l.collections,...l.globals},o=Object.values(t).find((s)=>s.slug===n.collectionSlug);if(!o||o.kind!==i)return null;return o}function L(l,n,i){let t={...l.collections,...l.globals},o=t[n],s=Object.values(t).find((u)=>u.slug===n);if(o&&s&&o.name!==s.name)throw e.validation(`"${n}" is ambiguous: it names ${o.name} and is the slug of ${s.name}. Use an unambiguous name or slug from describe_cms.`);let d=o??s;if(!d)throw e.notFound(`There is no collection called "${n}". Call describe_cms for the list.`);if(i&&d.kind!==i)throw e.validation(`"${n}" is a ${d.kind}, not a ${i}.`);return d}function a(l,n){return l.i18n.locales.includes(n)}function de(l,n,i){if(i!==void 0&&a(l,i))return i;if(i!==void 0)throw e.validation(`"${i}" is not a configured locale. Call describe_cms for the list.`);return n.locale}var ue={maxTurns:8,maxToolCalls:16,timeoutMs:90000};
|
|
2
|
+
export{no,oo,L,de,ue};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{he,En}from"./index-g041kfa5.js";import{pe,Y,Le,me,fe,I}from"./index-8x2em6c8.js";import{It,Wn,E,rt,jt,Et,_e,C,fn,A,$e,Je,Ie}from"./index-sgdnp83t.js";import"./index-6m1kjq9g.js";import"./index-abfzb1ve.js";import{dt,je,He,Wt,ut,pt,mt,ft,vn,zt,ht,te,Ht,Bt,Vt,xn,Gt,Kt,Vn,Gn,Kn,yt}from"./index-cv0hpz3d.js";import{Se,jn,qe}from"./index-hpast878.js";import{V,J,Ee,bt,Be,F,Yt,Ge,An,Zt}from"./index-kc1j3h6z.js";import"./index-g4crf47y.js";import{ct,bn,wn}from"./index-a8jcwqsf.js";import{Ke,Rt}from"./index-6w10rch0.js";import{Ae,ke,Cn}from"./index-466cwb0b.js";import{en,tn,nn}from"./index-91fa1gzf.js";import{d}from"./index-9g2n7xa6.js";import{k,Z,Ot,rn,ao,lo,Te,Q,co,X,uo}from"./index-hbx67b20.js";import{ge,et,tt}from"./index-y8kzzn94.js";import{O}from"./index-67e458ws.js";import{Ce}from"./index-vzhxn50e.js";import{p,ln,Pt,_t}from"./index-s9x07zb3.js";import{nt,ot}from"./index-761dec5z.js";import"./index-2prbs05k.js";import{w,se}from"./index-rw0hze6x.js";import{b,ve}from"./index-8nzmqy0f.js";import{e,n}from"./index-x72d1hzh.js";export{n as CmsConfigError,ht as CmsEngine,e as CmsError,pt as EventBuffer,ut as JobRunner,Ht as LOCALE_NAMES,mt as Outbox,ft as RelationLoader,Se as Router,Le as aiActionsFor,fe as applyFieldReadAccess,I as assertFieldWriteAccess,dt as buildHookPipeline,Pt as buildSchemaSnapshot,wn as cmsScheduled,tn as collectMediaReferences,Rt as createAi,qe as createCmsHttp,b as createId,Zt as createMedia,ve as createOrderedId,Gt as createWebhooks,J as cursorWhere,et as defaultAdminPath,ge as defaultBasePath,tt as defaultMigrationsDirectory,pe as defineAiAction,Vn as defineCollection,Z as defineEditorMark,k as defineEditorNode,O as defineField,Gn as defineGlobal,Te as describeEditorSchema,jn as describePanel,ln as documentsDataColumn,p as documentsTableName,_t as emptySnapshot,V as encodeCursor,rt as expandRoles,Y as getAiAction,rn as getEditorMark,Ot as getEditorNode,te as globalRowId,Wn as grants,Kn as heyoCms,Wt as hookPipelineEntries,jt as intersectPermissions,Vt as isRtlLocale,_e as isValidScope,zt as listTrashed,C as localeContext,Bt as localeName,xn as localeRecords,Yt as mediaGcJob,se as parseByteSize,w as parseDuration,It as permissionFor,E as permits,Ke as piCompletion,Ce as planMigration,An as prepareUpload,Ee as probeImage,en as referencesMedia,me as registeredAiActions,lo as registeredEditorMarks,ao as registeredEditorNodes,vn as relationTarget,Q as renderRichText,fn as resolveLocalized,he as richTextFromMarkdown,En as richTextFromText,co as richTextToHtml,X as richTextToMarkdown,uo as richTextToPlainText,A as rowToDocument,He as runAfterHooks,je as runBeforeHooks,ct as runDueJobs,Ie as scheduledPatch,Et as scopePermissions,d as scopedDb,ke as signPayload,Ae as signatureHeader,bn as startJobRunner,Ge as stripImageMetadata,nn as syncMediaUsages,yt as systemActor,ot as systemTableNames,nt as systemTables,F as toMediaDocument,$e as toStoredData,Je as validateFields,Be as variantKey,bt as variantTransform,Cn as verifySignature,Kt as webhookRetryJob};
|
package/dist/jobs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ct,bn,wn}from"./index-a8jcwqsf.js";export{wn as cmsScheduled,ct as runDueJobs,bn as startJobRunner};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ImageInfo, ImageProcessor, ImageTransform } from "../types/media";
|
|
2
|
+
/** The Workers Images binding, structurally. Typing it avoids depending on the types. */
|
|
3
|
+
export interface CloudflareImagesBinding {
|
|
4
|
+
input(image: ReadableStream<Uint8Array>): CloudflareImageTransformer;
|
|
5
|
+
}
|
|
6
|
+
export interface CloudflareImageTransformer {
|
|
7
|
+
transform(options: Record<string, unknown>): CloudflareImageTransformer;
|
|
8
|
+
output(options: Record<string, unknown>): Promise<CloudflareImageOutput>;
|
|
9
|
+
}
|
|
10
|
+
export interface CloudflareImageOutput {
|
|
11
|
+
contentType(): string;
|
|
12
|
+
image(): ReadableStream<Uint8Array>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The binding, or where to get it.
|
|
16
|
+
*
|
|
17
|
+
* A function, usually: the processor is constructed while the configuration
|
|
18
|
+
* module loads, and on Workers the bindings only exist once a request (or the
|
|
19
|
+
* `cloudflare:workers` module) hands them over. Returning `undefined` is
|
|
20
|
+
* allowed — that is "this runtime has no binding", reported as an error only
|
|
21
|
+
* if something actually asks for pixels.
|
|
22
|
+
*/
|
|
23
|
+
export type CloudflareImagesSource = CloudflareImagesBinding | (() => CloudflareImagesBinding | undefined | Promise<CloudflareImagesBinding | undefined>);
|
|
24
|
+
export declare function cloudflareImages(source: CloudflareImagesSource): ImageProcessor;
|
|
25
|
+
export interface CloudflarePlan {
|
|
26
|
+
/** What to pass to `.transform()`, or null when only re-encoding. */
|
|
27
|
+
options: Record<string, unknown> | null;
|
|
28
|
+
/** The dimensions the output should have, for when the probe cannot say. */
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* One `ImageTransform`, translated into the binding's vocabulary.
|
|
34
|
+
*
|
|
35
|
+
* The crop and the focal point are resolved here rather than delegated:
|
|
36
|
+
* `sourceRegion` already turns both into a single rectangle of the original
|
|
37
|
+
* (the exact logic the sharp processor uses, tested in isolation), and that
|
|
38
|
+
* rectangle becomes a `trim`. It is sent as an origin and a size —
|
|
39
|
+
* `{ top, left, width, height }` — rather than as four margins: the size is
|
|
40
|
+
* what the rest of the plan is computed from, and stating it means the
|
|
41
|
+
* service cannot round its way to a rectangle one pixel off the one the
|
|
42
|
+
* dimensions were reported for.
|
|
43
|
+
*
|
|
44
|
+
* The fit names do not line up one to one, and two of them are false friends:
|
|
45
|
+
*
|
|
46
|
+
* | heyo-cms (sharp) | Cloudflare |
|
|
47
|
+
* | ---------------------- | ---------------- |
|
|
48
|
+
* | `inside` (default) | `scale-down` |
|
|
49
|
+
* | `contain` (letterbox) | `pad` |
|
|
50
|
+
* | `cover` | `cover`, clamped |
|
|
51
|
+
* | `outside` | computed + `scale-down` |
|
|
52
|
+
*
|
|
53
|
+
* `scale-down` never enlarges, which matches the `withoutEnlargement` the
|
|
54
|
+
* sharp processor always sets; `cover` would enlarge, so the requested box is
|
|
55
|
+
* shrunk to the source first — a 400px logo asked for at 1920 stays 400px.
|
|
56
|
+
*/
|
|
57
|
+
export declare function cloudflareTransform(info: ImageInfo, transform: ImageTransform): CloudflarePlan;
|
|
58
|
+
//# sourceMappingURL=cloudflare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../src/media/cloudflare.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAuCxB,yFAAyF;AACzF,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,0BAA0B,CAAC;CACtE;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,0BAA0B,CAAC;IACxE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,IAAI,MAAM,CAAC;IACtB,KAAK,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;CACrC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAC9B,uBAAuB,GACvB,CAAC,MACG,uBAAuB,GACvB,SAAS,GACT,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC,CAAC;AAEtD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,sBAAsB,GAC7B,cAAc,CA+ChB;AAED,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,cAAc,GACxB,cAAc,CAiEhB"}
|
package/dist/media/document.d.ts
CHANGED
|
@@ -16,13 +16,14 @@ export declare const reservedMetadata: readonly ["crop", "variants"];
|
|
|
16
16
|
/**
|
|
17
17
|
* A `media` row as the rest of the world sees it.
|
|
18
18
|
*
|
|
19
|
-
* `url` is the
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* `url` is where the deployment serves the file: under `uploads.publicPath`
|
|
20
|
+
* when there is one, otherwise the adapter's public URL. Never a signed one:
|
|
21
|
+
* signing is cryptography, and making this asynchronous would charge every
|
|
22
|
+
* list of twenty-five files twenty-five signatures for a feature most
|
|
23
|
+
* deployments do not use. A private bucket signs at the moment of serving
|
|
24
|
+
* instead, which is what `cms.media.variant()` returns.
|
|
24
25
|
*/
|
|
25
|
-
export declare function toMediaDocument(row: Row, storage: StorageAdapter): MediaDocument;
|
|
26
|
+
export declare function toMediaDocument(row: Row, storage: StorageAdapter, publicPath?: string): MediaDocument;
|
|
26
27
|
/** The document as an event payload: plain JSON, no behaviour, no aliasing. */
|
|
27
28
|
export declare function mediaJson(media: MediaDocument): JsonObject;
|
|
28
29
|
//# sourceMappingURL=document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/media/document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAwB,aAAa,EAAe,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/media/document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAwB,aAAa,EAAe,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,YAAI,MAAM,EAAE,UAAU,CAAU,CAAC;AAE9D;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,cAAc,EACvB,UAAU,CAAC,EAAE,MAAM,GAClB,aAAa,CAmCf;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAE1D"}
|
package/dist/media/gc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gc.d.ts","sourceRoot":"","sources":["../../src/media/gc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAmBvD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IACvC,IAAI,EAAE,CACJ,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,qEAAqE;AACrE,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,EAAE,CAAC,CAqBhB;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,cAAc,EACvB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAyB7B;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,IAAI,GACR,OAAO,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"gc.d.ts","sourceRoot":"","sources":["../../src/media/gc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAmBvD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IACvC,IAAI,EAAE,CACJ,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,qEAAqE;AACrE,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,EAAE,CAAC,CAqBhB;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,cAAc,EACvB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAyB7B;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,IAAI,GACR,OAAO,CAAC,cAAc,CAAC,CAyDzB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAcjE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,aAAa,GAAG,SAAS,GACjC,MAAM,EAAE,CASV"}
|
package/dist/media/pipeline.d.ts
CHANGED
|
@@ -16,6 +16,15 @@ export interface PreparedUpload {
|
|
|
16
16
|
info: ImageInfo | null;
|
|
17
17
|
checksum: string;
|
|
18
18
|
extension: string;
|
|
19
|
+
/**
|
|
20
|
+
* Why the configured processing did not happen, when it failed.
|
|
21
|
+
*
|
|
22
|
+
* Null when it ran, or when there was nothing to run. Set when the
|
|
23
|
+
* processor threw and the original was stored instead (see
|
|
24
|
+
* `renderOriginal`): the upload succeeds, and the caller reports this as
|
|
25
|
+
* `media.processing.failed` so somebody can notice.
|
|
26
|
+
*/
|
|
27
|
+
processingError: string | null;
|
|
19
28
|
}
|
|
20
29
|
export interface PrepareUploadOptions {
|
|
21
30
|
bytes: Uint8Array;
|
|
@@ -25,6 +34,16 @@ export interface PrepareUploadOptions {
|
|
|
25
34
|
uploads: UploadsConfig;
|
|
26
35
|
}
|
|
27
36
|
export declare function prepareUpload(options: PrepareUploadOptions): Promise<PreparedUpload>;
|
|
37
|
+
/**
|
|
38
|
+
* A processor that cannot run at all, as opposed to one that failed once.
|
|
39
|
+
*
|
|
40
|
+
* `image_processor_missing` is a deployment mistake — no binding, no `sharp`
|
|
41
|
+
* installed — and degrading to the original would hide it until somebody
|
|
42
|
+
* wondered, months later, why nothing was ever converted. Every other error
|
|
43
|
+
* is the kind that goes away on its own.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isProcessorMisconfigured(error: unknown): boolean;
|
|
46
|
+
export declare function describeError(error: unknown): string;
|
|
28
47
|
export declare function matchesMime(contentType: string, pattern: string): boolean;
|
|
29
48
|
/**
|
|
30
49
|
* A filename that is safe to show, log and put in a header.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/media/pipeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAIhE;;;;;;;GAOG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/media/pipeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAIhE;;;;;;;GAOG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAgEzB;AAwGD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUpD;AAoBD,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMzE;AAWD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/media/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/media/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQvE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EACV,QAAQ,EAiBT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAO,EAAE,EAAS,MAAM,gBAAgB,CAAC;AA4BrD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,oEAAoE;IACpE,IAAI,EAAE,CACJ,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,aAAa,EAAE,EACvB,IAAI,EAAE,eAAe,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,QAAQ,CA8uBlE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ImagesConfig, ResolvedCmsConfig } from "../types/config";
|
|
2
|
+
import type { MediaDocument, MediaImage, MediaImageInput, MediaImageOptions, MediaSrcsetOptions, MediaUrlInput, MediaUrlOptions } from "../types/media";
|
|
3
|
+
/**
|
|
4
|
+
* Where a file is served from, and what an `<img>` needs to show it well.
|
|
5
|
+
*
|
|
6
|
+
* Everything here is arithmetic on the configuration and the `media` row: no
|
|
7
|
+
* storage call, no rendering, no database. That is what lets a page with
|
|
8
|
+
* forty pictures build forty `srcset`s without forty round trips — the sizes
|
|
9
|
+
* a variant *will* have are known before it has ever been rendered, because
|
|
10
|
+
* the processors never enlarge and the fits are deterministic.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The file name in a public URL: the uploaded name, as a slug, with the
|
|
14
|
+
* extension of what is actually served.
|
|
15
|
+
*
|
|
16
|
+
* Only for people and image search, which reads it; the route ignores it.
|
|
17
|
+
* The extension follows the content type rather than the upload, so a PNG
|
|
18
|
+
* converted to WebP is `diagram.webp` and not a `.png` that is not one.
|
|
19
|
+
*/
|
|
20
|
+
export declare function publicFileName(media: Pick<MediaDocument, "filename">, contentType: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* The address of the original under `uploads.publicPath`, or null without one.
|
|
23
|
+
*
|
|
24
|
+
* Kept separate from `mediaUrl` because `toMediaDocument` needs it and has no
|
|
25
|
+
* use for the rest: `MediaDocument.url` is this, when the deployment serves
|
|
26
|
+
* its own files.
|
|
27
|
+
*/
|
|
28
|
+
export declare function publicOriginalUrl(publicPath: string | undefined, media: Pick<MediaDocument, "id" | "filename" | "mimeType">): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* `cms.media.url()`.
|
|
31
|
+
*
|
|
32
|
+
* With `uploads.publicPath`:
|
|
33
|
+
*
|
|
34
|
+
* /media/med_…/condition-report.png the original
|
|
35
|
+
* /media/med_…/card/condition-report.webp a declared size
|
|
36
|
+
*
|
|
37
|
+
* Without it, the CMS's own API route, `<basePath>/media/med_…/card`. A size
|
|
38
|
+
* nothing here can render — no processor, or an SVG — is the original's URL
|
|
39
|
+
* with the size in the query, which is what an image CDN in front of the
|
|
40
|
+
* deployment reads. A size that would not change the picture is the
|
|
41
|
+
* original's URL outright, so the browser reuses what it already has.
|
|
42
|
+
*/
|
|
43
|
+
export declare function mediaUrl(config: ResolvedCmsConfig, media: MediaUrlInput, options?: MediaUrlOptions): string;
|
|
44
|
+
/**
|
|
45
|
+
* The pixel size a named size will have for this file, before it exists.
|
|
46
|
+
*
|
|
47
|
+
* The same arithmetic the processors perform: the crop first, then the fit,
|
|
48
|
+
* never enlarging. Null when the file has no known dimensions (not an image,
|
|
49
|
+
* or one whose header could not be read).
|
|
50
|
+
*/
|
|
51
|
+
export declare function variantDimensions(images: ImagesConfig | undefined, name: string, media: Pick<MediaUrlInput, "width" | "height" | "crop">): {
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
} | null;
|
|
55
|
+
/**
|
|
56
|
+
* `cms.media.srcset()`: the declared sizes that keep the picture's shape, as
|
|
57
|
+
* a width-descriptor list, with the original at the top end.
|
|
58
|
+
*
|
|
59
|
+
* Only sizes that do not change the aspect ratio belong in one `srcset` —
|
|
60
|
+
* the browser assumes every candidate is the same picture — so a `cover`
|
|
61
|
+
* square is left out unless asked for by name. Sizes the file is too small
|
|
62
|
+
* for collapse into the original. With a crop the original is not the same
|
|
63
|
+
* picture as its sizes, so it is left out and the largest size tops the list.
|
|
64
|
+
*
|
|
65
|
+
* Null when there is nothing to choose between: a vector, a file with no
|
|
66
|
+
* known width, or a configuration without sizes.
|
|
67
|
+
*/
|
|
68
|
+
export declare function mediaSrcset(config: ResolvedCmsConfig, media: MediaUrlInput, options?: MediaSrcsetOptions): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* `cms.media.image()`: everything an `<img>` needs for one file.
|
|
71
|
+
*
|
|
72
|
+
* Width and height are always the ones of the `src` — that is what the
|
|
73
|
+
* browser reserves space with before a byte arrives, and a wrong ratio there
|
|
74
|
+
* is the layout shift it exists to prevent.
|
|
75
|
+
*/
|
|
76
|
+
export declare function mediaImage(config: ResolvedCmsConfig, media: MediaImageInput, options?: MediaImageOptions): MediaImage;
|
|
77
|
+
//# sourceMappingURL=urls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/media/urls.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAUxB;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,EACtC,WAAW,EAAE,MAAM,GAClB,MAAM,CAGR;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC,GACzD,MAAM,GAAG,IAAI,CAGf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,eAAoB,GAC5B,MAAM,CAmCR;AAOD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC,GACtD;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA6C1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,GAAG,IAAI,CAKf;AA4CD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,iBAAsB,GAC9B,UAAU,CAqCZ"}
|
package/dist/media/usages.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ResolvedCollection } from "../types/config";
|
|
2
2
|
import type { ScopedDb } from "../types/hooks";
|
|
3
|
-
import type { JsonObject } from "../types/json";
|
|
3
|
+
import type { JsonObject, JsonValue } from "../types/json";
|
|
4
4
|
import type { RetentionConfig } from "../types/config";
|
|
5
5
|
export declare const mediaTable = "media";
|
|
6
6
|
export declare const mediaUsagesTable = "media_usages";
|
|
@@ -66,4 +66,12 @@ export interface SyncMediaUsagesResult {
|
|
|
66
66
|
*/
|
|
67
67
|
export declare function syncMediaUsages(options: SyncMediaUsagesOptions): Promise<SyncMediaUsagesResult>;
|
|
68
68
|
export declare function purgeDeadline(retention: RetentionConfig | undefined, now: Date): Date | null;
|
|
69
|
+
/**
|
|
70
|
+
* Files referenced from inside a rich-text document.
|
|
71
|
+
*
|
|
72
|
+
* ProseMirror content is a tree of arbitrary depth and a custom node may put
|
|
73
|
+
* its attributes anywhere, so this walks the whole structure rather than
|
|
74
|
+
* assuming the shape TipTap's image node happens to have today.
|
|
75
|
+
*/
|
|
76
|
+
export declare function richTextMedia(value: JsonValue | undefined): string[];
|
|
69
77
|
//# sourceMappingURL=usages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usages.d.ts","sourceRoot":"","sources":["../../src/media/usages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"usages.d.ts","sourceRoot":"","sources":["../../src/media/usages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAOvE;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,kBAAkB,EAC9B,MAAM,EAAE,UAAU,GACjB,cAAc,EAAE,CAuBlB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,QAAQ,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,eAAe,GAAG,SAAS,CAAC;IACvC,GAAG,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CA4ChC;AAqED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,GAAG,EAAE,IAAI,GACR,IAAI,GAAG,IAAI,CAIb;AA4BD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,EAAE,CAqBpE"}
|
package/dist/media/variants.d.ts
CHANGED
|
@@ -19,6 +19,17 @@ export declare function variantSize(images: ImagesConfig | undefined, name: stri
|
|
|
19
19
|
* the editor made once in the panel and that every size inherits.
|
|
20
20
|
*/
|
|
21
21
|
export declare function variantTransform(images: ImagesConfig | undefined, name: string, media: Pick<MediaDocument, "focalPoint" | "crop" | "mimeType">): ImageTransform;
|
|
22
|
+
/**
|
|
23
|
+
* Whether rendering this transform would give back the original's pixels.
|
|
24
|
+
*
|
|
25
|
+
* Only the fits that never crop are considered: `inside` (the default) and
|
|
26
|
+
* `outside` leave an image alone when it is already within the box, and
|
|
27
|
+
* every processor here refuses to enlarge. `cover` and `contain` change the
|
|
28
|
+
* aspect ratio, and the two processors disagree about what they do to an
|
|
29
|
+
* image smaller than the box, so those are always rendered. A crop always
|
|
30
|
+
* changes the pixels; a format change is the caller's to check.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isIdentityTransform(transform: ImageTransform, media: Pick<MediaDocument, "width" | "height">): boolean;
|
|
22
33
|
/** The content type a variant will have, before anything is rendered. */
|
|
23
34
|
export declare function variantContentType(images: ImagesConfig | undefined, mimeType: string): string;
|
|
24
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/media/variants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,gBAAgB,CAAC;AAGxB;;;;;;;;GAQG;AAEH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,EAAE,CAEvE;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,GACX,eAAe,CAWjB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC,GAC7D,cAAc,CAqBhB;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,QAAQ,EAAE,MAAM,GACf,MAAM,CAIR;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,MAAM,CAKR;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,GACX,MAAM,CAUR;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,cAAc,GAAG,SAAS,EACrC,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,GAC1D,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAQhC"}
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/media/variants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,gBAAgB,CAAC;AAGxB;;;;;;;;GAQG;AAEH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,EAAE,CAEvE;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,GACX,eAAe,CAWjB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC,GAC7D,cAAc,CAqBhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,CAAC,GAC7C,OAAO,CA4BT;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,QAAQ,EAAE,MAAM,GACf,MAAM,CAIR;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,MAAM,CAKR;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,GACX,MAAM,CAUR;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,cAAc,GAAG,SAAS,EACrC,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,GAC1D,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAQhC"}
|
package/dist/migrations.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{an,Zo,Dn,qn,Ln}from"./index-vkwzdfte.js";export{an as MigrationStore,Dn as generateMigration,Zo as generatePluginMigrations,Ln as migrationStatus,qn as runMigrations};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { JsonObject } from "../types/json";
|
|
2
|
+
import type { CmsPlugin } from "../types/plugin";
|
|
3
|
+
/**
|
|
4
|
+
* IndexNow: tells Bing, Yandex, Seznam, Naver and the other engines that
|
|
5
|
+
* share the protocol that a page changed, so they recrawl it now rather than
|
|
6
|
+
* whenever they next pass by. Google does not take part; it reads the
|
|
7
|
+
* sitemap.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* plugins: [
|
|
11
|
+
* indexNow({
|
|
12
|
+
* key: () => env.INDEXNOW_KEY,
|
|
13
|
+
* url: (post, { collection, locale }) =>
|
|
14
|
+
* post.status === "published" ? `https://example.com/${locale}/blog/${post.slug}` : null,
|
|
15
|
+
* enabled: import.meta.env.PROD,
|
|
16
|
+
* }),
|
|
17
|
+
* ]
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Two halves, both of which have to live in the CMS rather than in a hook of
|
|
21
|
+
* the site:
|
|
22
|
+
*
|
|
23
|
+
* - **After the commit.** The ping is an event listener, delivered from the
|
|
24
|
+
* outbox once the write has committed — a rolled back save announces
|
|
25
|
+
* nothing, and a ping is never sent from inside a transaction that may
|
|
26
|
+
* still fail. On a serverless runtime the framework adapter hands the
|
|
27
|
+
* delivery to `waitUntil`, so it is not lost when the request ends.
|
|
28
|
+
* - **The key file.** The protocol checks a submission by fetching
|
|
29
|
+
* `https://<host>/<key>.txt`, and only a file at the root covers every URL
|
|
30
|
+
* of the host. The plugin serves it as a root route: mount the CMS handler
|
|
31
|
+
* on `/[key].txt` as well (`src/pages/[key].txt.ts` in Astro).
|
|
32
|
+
*
|
|
33
|
+
* For an update, both the address the page has now and the one it had are
|
|
34
|
+
* sent — a changed slug, or a page that stopped being public, is a URL the
|
|
35
|
+
* engines should look at again. A trashed or purged page sends its last
|
|
36
|
+
* address, which now answers 404. A failed ping is logged and dropped: the
|
|
37
|
+
* document is saved, and a search engine that did not answer is no reason
|
|
38
|
+
* to replay the event to every other listener.
|
|
39
|
+
*/
|
|
40
|
+
export interface IndexNowContext {
|
|
41
|
+
/** The collection's name, as in `collections`. */
|
|
42
|
+
collection: string;
|
|
43
|
+
/** The language the write was made in. */
|
|
44
|
+
locale: string;
|
|
45
|
+
}
|
|
46
|
+
export interface IndexNowOptions {
|
|
47
|
+
/**
|
|
48
|
+
* The key: 8 to 128 letters, digits and dashes. Not a secret — the
|
|
49
|
+
* protocol publishes it at `/<key>.txt` — but usually a deployment
|
|
50
|
+
* setting, hence the function form, read when it is needed.
|
|
51
|
+
*/
|
|
52
|
+
key: string | (() => string | null | undefined | Promise<string | null | undefined>);
|
|
53
|
+
/**
|
|
54
|
+
* The public address of a document in one language, or null when it has
|
|
55
|
+
* none there: a draft, a `noindex` page, a collection with no pages.
|
|
56
|
+
*/
|
|
57
|
+
url: (document: JsonObject, context: IndexNowContext) => string | null | undefined | Promise<string | null | undefined>;
|
|
58
|
+
/** Only these collections. Every one by default; `url` decides the rest. */
|
|
59
|
+
collections?: string[];
|
|
60
|
+
/**
|
|
61
|
+
* Whether to send anything. A development server and a preview deployment
|
|
62
|
+
* must not tell search engines about pages that do not exist publicly.
|
|
63
|
+
*/
|
|
64
|
+
enabled?: boolean | (() => boolean | Promise<boolean>);
|
|
65
|
+
/** `https://api.indexnow.org/indexnow`, which shares with every member engine. */
|
|
66
|
+
endpoint?: string;
|
|
67
|
+
fetch?: IndexNowFetch;
|
|
68
|
+
}
|
|
69
|
+
/** `fetch`, as much of it as a submission uses. */
|
|
70
|
+
export type IndexNowFetch = (input: string, init: RequestInit) => Promise<Response>;
|
|
71
|
+
export declare function indexNow(options: IndexNowOptions): CmsPlugin<unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* One submission per host: the protocol takes a single `host` per request,
|
|
74
|
+
* with a key file on that host.
|
|
75
|
+
*/
|
|
76
|
+
export declare function submitIndexNow(args: {
|
|
77
|
+
key: string;
|
|
78
|
+
urls: string[];
|
|
79
|
+
endpoint?: string;
|
|
80
|
+
fetch?: IndexNowFetch;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
//# sourceMappingURL=indexnow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexnow.d.ts","sourceRoot":"","sources":["../../src/plugins/indexnow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,GAAG,EACC,MAAM,GACN,CAAC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3E;;;OAGG;IACH,GAAG,EAAE,CACH,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,eAAe,KACrB,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACpE,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,mDAAmD;AACnD,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,WAAW,KACd,OAAO,CAAC,QAAQ,CAAC,CAAC;AAavB,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,CAgGrE;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@heyo-sh/heyo-cms/plugins` — plugins that ship with the package.
|
|
3
|
+
*
|
|
4
|
+
* Built with nothing but the public plugin API (`CmsPlugin`): root routes and
|
|
5
|
+
* post-commit event listeners. A plugin here has no access a third-party one
|
|
6
|
+
* would not have.
|
|
7
|
+
*/
|
|
8
|
+
export { indexNow, submitIndexNow, type IndexNowFetch, type IndexNowContext, type IndexNowOptions, } from "./plugins/indexnow";
|
|
9
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,QAAQ,EACR,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC"}
|
package/dist/plugins.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n}from"./index-x72d1hzh.js";var y=/^[A-Za-z0-9-]{8,128}$/,g=["document.created","document.updated","document.trashed","document.restored","document.purged"];function h(e){if(typeof e.key==="string"&&!y.test(e.key))throw new n("plugins.indexnow.key","must be 8 to 128 letters, digits or dashes");if(typeof e.url!=="function")throw new n("plugins.indexnow.url","must be a function returning a document's public URL");let d=e.endpoint??"https://api.indexnow.org/indexnow",a=e.fetch??((t,o)=>fetch(t,o)),s=e.collections?new Set(e.collections):null,r=async()=>{let t=typeof e.key==="function"?await e.key():e.key,o=typeof t==="string"?t.trim():"";return y.test(o)?o:null},l=async()=>typeof e.enabled==="function"?await e.enabled():e.enabled!==!1,i=async(t,o)=>{if(typeof t!=="object"||t===null)return null;let u=await e.url(t,o);if(typeof u!=="string")return null;try{let c=new URL(u);return c.protocol==="https:"||c.protocol==="http:"?c.href:null}catch{return null}},x=async(t)=>{let o=String(t.data.collection??"");if(!o||s&&!s.has(o))return;if(!await l())return;let u={collection:o,locale:String(t.data.locale??"")},c=new Set,f=await i(t.data.document,u);if(f)c.add(f);let w=await i(t.previous?.document,u);if(w)c.add(w);if(c.size===0)return;let p=await r();if(!p){console.warn("[indexnow] no valid key; nothing was sent.");return}await m({endpoint:d,key:p,urls:[...c],fetch:a})};return{id:"indexnow",events:Object.fromEntries(g.map((t)=>[t,x])),routes:[{method:"GET",path:"/:file",root:!0,handler:async({params:t})=>{let o=await r();if(!o||t.file!==`${o}.txt`)return new Response("Not found",{status:404,headers:{"content-type":"text/plain; charset=utf-8"}});return new Response(o,{headers:{"content-type":"text/plain; charset=utf-8","cache-control":"public, max-age=86400"}})}}]}}async function m(e){let d=e.fetch??((s,r)=>fetch(s,r)),a=new Map;for(let s of e.urls){let r=new URL(s),l=a.get(r.host)??{origin:r.origin,urls:[]};l.urls.push(r.href),a.set(r.host,l)}for(let[s,{origin:r,urls:l}]of a)try{let i=await d(e.endpoint??"https://api.indexnow.org/indexnow",{method:"POST",headers:{"content-type":"application/json; charset=utf-8"},body:JSON.stringify({host:s,key:e.key,keyLocation:`${r}/${e.key}.txt`,urlList:l}),signal:AbortSignal.timeout(1e4)});if(!i.ok)console.warn(`[indexnow] ${s}: HTTP ${i.status} for ${l.length} URL(s).`);await i.body?.cancel()}catch(i){console.warn(`[indexnow] ${s}: not delivered: ${i instanceof Error?i.message:String(i)}`)}}export{h as indexNow,m as submitIndexNow};
|
package/dist/query.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s,
|
|
1
|
+
import{s,R,zn,er,t,We,it,tr,H,M,S,nr,ae,rr,le,m,Xo,ir}from"./index-6m1kjq9g.js";export{s as and,rr as contains,t as eq,le as exists,it as gt,tr as gte,S as inList,ae as like,H as lt,M as lte,We as ne,zn as not,nr as notInList,R as or,m as orderBy,Xo as restrict,ir as restrictQuery,er as where};
|