content-query 0.3.0 → 0.5.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/README.md +46 -15
- package/dist/{build-CI4s0oFP.mjs → build-DWpB69_c.mjs} +826 -69
- package/dist/{build-jKnjDjQE.d.mts → build-DfoncKL8.d.mts} +17 -5
- package/dist/build.d.mts +1 -1
- package/dist/build.mjs +1 -1
- package/dist/cli.mjs +14 -8
- package/dist/{content-N1gYshjg.mjs → collection-Cb5eWGnv.mjs} +998 -344
- package/dist/collection-types-CsQtGw7_.d.mts +119 -0
- package/dist/computed.d.mts +2 -2
- package/dist/{types-FmUJ3cH1.d.mts → descriptor-bcPa6XLk.d.mts} +17 -1
- package/dist/{diagnostics-Cu94mZhl.mjs → diagnostics-DmUZtrJ6.mjs} +3 -1
- package/dist/{errors-C2iuBM0G.mjs → errors-Bfd0R4_P.mjs} +16 -1
- package/dist/file-DSOcdFj0.mjs +81 -0
- package/dist/{glob-Bv0dpvCQ.mjs → glob-BXJuwy_p.mjs} +94 -6
- package/dist/index.d.mts +76 -18
- package/dist/index.mjs +1 -1
- package/dist/internal.d.mts +54 -7
- package/dist/internal.mjs +424 -19
- package/dist/loaders.d.mts +1 -2
- package/dist/loaders.mjs +2 -81
- package/dist/next.d.mts +3 -2
- package/dist/next.mjs +67 -14
- package/dist/operators-D-w1-gDg.mjs +391 -0
- package/dist/query-style-C2FcT1f9.d.mts +23 -0
- package/dist/query.d.mts +25 -2
- package/dist/query.mjs +1 -1
- package/dist/{relational-types-B45zM34W.d.mts → relational-types-CTcalUNW.d.mts} +241 -50
- package/dist/revision-DBwU-aC9.d.mts +56 -0
- package/dist/runtime.d.mts +3 -2
- package/dist/runtime.mjs +1 -1
- package/dist/types-Dz1vTXa2.d.mts +214 -0
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +77 -35
- package/package.json +1 -1
- package/dist/content-lwPxE9Yu.d.mts +0 -109
- package/dist/descriptor-BUPT2J7X.d.mts +0 -18
- package/dist/operators-UqWUhKQJ.mjs +0 -173
- package/dist/types-BC8gVJ6u.d.mts +0 -69
- package/dist/validation-D_XdE1pF.mjs +0 -84
package/dist/internal.d.mts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as Collection, r as CollectionHandles, s as ContentError } from "./collection-types-CsQtGw7_.mjs";
|
|
2
2
|
import { n as ContentRenderResult } from "./types-Dh-Sydyw.mjs";
|
|
3
|
-
import { i as CollectionRegistry } from "./types-
|
|
4
|
-
import {
|
|
3
|
+
import { i as CollectionRegistry } from "./types-Dz1vTXa2.mjs";
|
|
4
|
+
import { O as QueryRegistry } from "./relational-types-CTcalUNW.mjs";
|
|
5
|
+
import { n as QueryStyle } from "./query-style-C2FcT1f9.mjs";
|
|
6
|
+
import { n as PreparedRevision, t as ContentState } from "./revision-DBwU-aC9.mjs";
|
|
5
7
|
//#region src/artifacts/types.d.ts
|
|
6
8
|
type ArtifactManifest = {
|
|
7
9
|
version: number;
|
|
8
10
|
codec: string;
|
|
9
11
|
collections: QueryRegistry;
|
|
12
|
+
/** Optional and additive, so it needs no version bump; absent allows both query styles. */
|
|
13
|
+
queryStyle?: QueryStyle;
|
|
10
14
|
};
|
|
11
15
|
type EncodedCollection = {
|
|
12
16
|
records: readonly string[];
|
|
@@ -14,13 +18,43 @@ type EncodedCollection = {
|
|
|
14
18
|
builtins: Record<string, () => Promise<{
|
|
15
19
|
default: string;
|
|
16
20
|
}>>;
|
|
21
|
+
/** Lazy encoded custom payloads by payload name, entry ID, and canonical variant key. */
|
|
22
|
+
payloads?: Record<string, Record<string, Record<string, () => Promise<{
|
|
23
|
+
default: string;
|
|
24
|
+
}>>>>;
|
|
17
25
|
};
|
|
18
26
|
//#endregion
|
|
19
27
|
//#region src/artifacts/runtime.d.ts
|
|
20
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Initializes generated/embedded prepared content. This versioned wiring is internal.
|
|
30
|
+
* Relationships are related when a query scope combines the collections it loads.
|
|
31
|
+
*
|
|
32
|
+
* @param manifest - The entry's manifest; its registry lists exactly the collections it serves.
|
|
33
|
+
* @param collections - Generated collection modules by name.
|
|
34
|
+
* @param renderMarkdown - The packaged renderer, when a served collection captured Markdown.
|
|
35
|
+
* @returns The prepared revision.
|
|
36
|
+
*/
|
|
21
37
|
export declare function createArtifactRevision(manifest: ArtifactManifest, collections: Record<string, EncodedCollection>, renderMarkdown?: (body: string) => Promise<ContentRenderResult>): PreparedRevision;
|
|
22
|
-
/**
|
|
23
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Initializes one generated collection entry's export.
|
|
40
|
+
*
|
|
41
|
+
* @param manifest - The entry's manifest, which lists only this collection.
|
|
42
|
+
* @param name - The collection's name.
|
|
43
|
+
* @param collection - The generated collection module.
|
|
44
|
+
* @param renderMarkdown - The packaged renderer, when the collection captured Markdown.
|
|
45
|
+
* @returns The collection handle the entry exports.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createArtifactCollection<Registry extends CollectionRegistry, Name extends keyof Registry & string, Style extends QueryStyle = QueryStyle>(manifest: ArtifactManifest, name: Name, collection: EncodedCollection, renderMarkdown?: (body: string) => Promise<ContentRenderResult>): Collection<Registry, Name, Style>;
|
|
48
|
+
/**
|
|
49
|
+
* Initializes handles for every collection of one artifact revision, sharing its caches. Tests
|
|
50
|
+
* and integrations use it; applications import each collection's own entry instead.
|
|
51
|
+
*
|
|
52
|
+
* @param manifest - A manifest that lists every collection in `collections`.
|
|
53
|
+
* @param collections - Generated collection modules by name.
|
|
54
|
+
* @param renderMarkdown - The packaged renderer, when a collection captured Markdown.
|
|
55
|
+
* @returns Collection handles keyed by collection name.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createArtifactCollections<Registry extends CollectionRegistry, Style extends QueryStyle = QueryStyle>(manifest: ArtifactManifest, collections: Record<string, EncodedCollection>, renderMarkdown?: (body: string) => Promise<ContentRenderResult>): CollectionHandles<Registry, Style>;
|
|
24
58
|
//#endregion
|
|
25
59
|
//#region src/artifacts/payloads.d.ts
|
|
26
60
|
/**
|
|
@@ -47,8 +81,21 @@ type PayloadChunk = {
|
|
|
47
81
|
*/
|
|
48
82
|
export declare function createPayloadLoaders(chunks: readonly PayloadChunk[]): EncodedCollection["builtins"];
|
|
49
83
|
//#endregion
|
|
84
|
+
//#region src/runtime/collection.d.ts
|
|
85
|
+
/**
|
|
86
|
+
* Keeps one collection handle live across host-delivered development revisions.
|
|
87
|
+
*
|
|
88
|
+
* @param initial - The first prepared state.
|
|
89
|
+
* @param name - The collection the handle queries.
|
|
90
|
+
* @returns The handle and an `update()` that switches its state to a newer revision or error.
|
|
91
|
+
*/
|
|
92
|
+
export declare function createLiveCollection(initial: ContentState, name: string): {
|
|
93
|
+
collection: object;
|
|
94
|
+
update(next: ContentState): void;
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
50
97
|
//#region src/runtime/diagnostics.d.ts
|
|
51
98
|
/** Restores the library error and its causes in a generated or isolated development runtime. */
|
|
52
99
|
export declare function restoreContentError(encoded: string): ContentError;
|
|
53
100
|
//#endregion
|
|
54
|
-
export {
|
|
101
|
+
export {};
|
package/dist/internal.mjs
CHANGED
|
@@ -1,13 +1,62 @@
|
|
|
1
|
-
import { t as ContentError } from "./errors-
|
|
1
|
+
import { t as ContentError } from "./errors-Bfd0R4_P.mjs";
|
|
2
2
|
import { r as decode } from "./values-BbTV4QT-.mjs";
|
|
3
|
-
import { i as
|
|
4
|
-
import { t as restoreContentError } from "./diagnostics-
|
|
5
|
-
import { gunzipSync } from "fflate/browser";
|
|
3
|
+
import { i as isQueryStyle, n as createCollections, r as createLiveCollection, t as createCollection } from "./collection-Cb5eWGnv.mjs";
|
|
4
|
+
import { t as restoreContentError } from "./diagnostics-DmUZtrJ6.mjs";
|
|
6
5
|
//#region src/artifacts/runtime.ts
|
|
7
|
-
/**
|
|
6
|
+
/** Checks that a value is a plain record before reading generated payload tables from it. */
|
|
7
|
+
function isTable(value) {
|
|
8
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Restores lazy custom payload loaders from a generated payload table.
|
|
12
|
+
*
|
|
13
|
+
* @param collection - The collection name, for error messages.
|
|
14
|
+
* @param payloads - Encoded loaders by payload name, entry ID, and canonical variant key.
|
|
15
|
+
* @returns Decoding loaders with the same keys.
|
|
16
|
+
*/
|
|
17
|
+
function customPayloadTable(collection, payloads) {
|
|
18
|
+
if (!isTable(payloads)) throw new Error(`Invalid payload table for collection "${collection}".`);
|
|
19
|
+
return new Map(Object.entries(payloads).map(([payload, entries]) => {
|
|
20
|
+
if (!isTable(entries)) throw new Error(`Invalid payload table for collection "${collection}".`);
|
|
21
|
+
return [payload, new Map(Object.entries(entries).map(([id, variants]) => {
|
|
22
|
+
if (!isTable(variants) || Object.values(variants).some((load) => typeof load !== "function")) throw new Error(`Invalid payload table for collection "${collection}".`);
|
|
23
|
+
return [id, new Map(Object.entries(variants).map(([variant, load]) => [variant, async () => decode((await load()).default)]))];
|
|
24
|
+
}))];
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Decoded collections by generated collection module. The main server entry and collection
|
|
29
|
+
* entries import the same module, so a process that loads several entries decodes it once.
|
|
30
|
+
* Prepared records are never mutated, since queries project copies.
|
|
31
|
+
*/
|
|
32
|
+
const decodedCollections = /* @__PURE__ */ new WeakMap();
|
|
33
|
+
/** Decodes and checks one generated collection module, reusing an earlier decoding of it. */
|
|
34
|
+
function decodeCollection(name, encoded) {
|
|
35
|
+
const cached = decodedCollections.get(encoded);
|
|
36
|
+
if (cached) return cached;
|
|
37
|
+
const records = encoded.records.map((record) => decode(record));
|
|
38
|
+
if (records.some((record) => !record || typeof record !== "object" || Array.isArray(record) || !Object.hasOwn(record, "id") || typeof record.id !== "string" || !record.id || Object.hasOwn(record, "_adjacent") || Object.hasOwn(record, "_payloads")) || new Set(records.map((record) => record.id)).size !== records.length) throw new Error(`Invalid query records for collection "${name}".`);
|
|
39
|
+
const decoded = {
|
|
40
|
+
records,
|
|
41
|
+
builtins: new Map(Object.entries(encoded.builtins ?? {}).map(([id, load]) => [id, async () => decode((await load()).default)])),
|
|
42
|
+
...encoded.payloads ? { payloads: customPayloadTable(name, encoded.payloads) } : {}
|
|
43
|
+
};
|
|
44
|
+
decodedCollections.set(encoded, decoded);
|
|
45
|
+
return decoded;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Initializes generated/embedded prepared content. This versioned wiring is internal.
|
|
49
|
+
* Relationships are related when a query scope combines the collections it loads.
|
|
50
|
+
*
|
|
51
|
+
* @param manifest - The entry's manifest; its registry lists exactly the collections it serves.
|
|
52
|
+
* @param collections - Generated collection modules by name.
|
|
53
|
+
* @param renderMarkdown - The packaged renderer, when a served collection captured Markdown.
|
|
54
|
+
* @returns The prepared revision.
|
|
55
|
+
*/
|
|
8
56
|
function createArtifactRevision(manifest, collections, renderMarkdown) {
|
|
9
57
|
try {
|
|
10
|
-
if (manifest.version !==
|
|
58
|
+
if (manifest.version !== 3 || manifest.codec !== "devalue-6.0.2") throw new Error("Incompatible content artifact or codec version; regenerate content.");
|
|
59
|
+
if (manifest.queryStyle !== void 0 && !isQueryStyle(manifest.queryStyle)) throw new Error("Invalid query style in content artifact; regenerate content.");
|
|
11
60
|
const revision = {
|
|
12
61
|
registry: manifest.collections,
|
|
13
62
|
collections: Object.create(null),
|
|
@@ -15,21 +64,17 @@ function createArtifactRevision(manifest, collections, renderMarkdown) {
|
|
|
15
64
|
active: 0,
|
|
16
65
|
payloadCache: /* @__PURE__ */ new Map(),
|
|
17
66
|
renderCache: /* @__PURE__ */ new Map(),
|
|
18
|
-
renderMarkdown
|
|
67
|
+
renderMarkdown,
|
|
68
|
+
...manifest.queryStyle ? { queryStyle: manifest.queryStyle } : {}
|
|
19
69
|
};
|
|
20
70
|
for (const [name, descriptor] of Object.entries(manifest.collections)) {
|
|
21
71
|
const encoded = collections[name];
|
|
22
|
-
if (!encoded || !Array.isArray(encoded.records)) throw new Error(`Missing collection artifact "${name}".`);
|
|
23
|
-
const records = encoded.records.map((record) => decode(record));
|
|
24
|
-
if (records.some((record) => !record || typeof record !== "object" || Array.isArray(record) || !Object.hasOwn(record, "id") || typeof record.id !== "string" || !record.id || Object.hasOwn(record, "_adjacent") || Object.hasOwn(record, "_payloads")) || new Set(records.map((record) => record.id)).size !== records.length) throw new Error(`Invalid query records for collection "${name}".`);
|
|
72
|
+
if (!encoded || typeof encoded !== "object" || !Array.isArray(encoded.records)) throw new Error(`Missing collection artifact "${name}".`);
|
|
25
73
|
revision.collections[name] = {
|
|
26
|
-
|
|
27
|
-
relationships: descriptor.relationships
|
|
28
|
-
builtins: new Map(Object.entries(encoded.builtins ?? {}).map(([id, load]) => [id, async () => decode((await load()).default)]))
|
|
74
|
+
...decodeCollection(name, encoded),
|
|
75
|
+
relationships: descriptor.relationships
|
|
29
76
|
};
|
|
30
77
|
}
|
|
31
|
-
const errors = prepareRelationships(revision);
|
|
32
|
-
if (errors.length) throw errors[0];
|
|
33
78
|
return revision;
|
|
34
79
|
} catch (cause) {
|
|
35
80
|
throw new ContentError({
|
|
@@ -39,10 +84,370 @@ function createArtifactRevision(manifest, collections, renderMarkdown) {
|
|
|
39
84
|
});
|
|
40
85
|
}
|
|
41
86
|
}
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Initializes one generated collection entry's export.
|
|
89
|
+
*
|
|
90
|
+
* @param manifest - The entry's manifest, which lists only this collection.
|
|
91
|
+
* @param name - The collection's name.
|
|
92
|
+
* @param collection - The generated collection module.
|
|
93
|
+
* @param renderMarkdown - The packaged renderer, when the collection captured Markdown.
|
|
94
|
+
* @returns The collection handle the entry exports.
|
|
95
|
+
*/
|
|
96
|
+
function createArtifactCollection(manifest, name, collection, renderMarkdown) {
|
|
97
|
+
const revision = createArtifactRevision(manifest, { [name]: collection }, renderMarkdown);
|
|
98
|
+
if (!Object.hasOwn(revision.collections, name)) throw new ContentError({
|
|
99
|
+
code: "artifact-error",
|
|
100
|
+
message: `Missing collection artifact "${name}".`
|
|
101
|
+
});
|
|
102
|
+
return createCollection({
|
|
103
|
+
name,
|
|
104
|
+
state: { revision }
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Initializes handles for every collection of one artifact revision, sharing its caches. Tests
|
|
109
|
+
* and integrations use it; applications import each collection's own entry instead.
|
|
110
|
+
*
|
|
111
|
+
* @param manifest - A manifest that lists every collection in `collections`.
|
|
112
|
+
* @param collections - Generated collection modules by name.
|
|
113
|
+
* @param renderMarkdown - The packaged renderer, when a collection captured Markdown.
|
|
114
|
+
* @returns Collection handles keyed by collection name.
|
|
115
|
+
*/
|
|
116
|
+
function createArtifactCollections(manifest, collections, renderMarkdown) {
|
|
117
|
+
return createCollections({ revision: createArtifactRevision(manifest, collections, renderMarkdown) });
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js
|
|
121
|
+
var u8 = Uint8Array;
|
|
122
|
+
var u16 = Uint16Array;
|
|
123
|
+
var i32 = Int32Array;
|
|
124
|
+
var fleb = new u8([
|
|
125
|
+
0,
|
|
126
|
+
0,
|
|
127
|
+
0,
|
|
128
|
+
0,
|
|
129
|
+
0,
|
|
130
|
+
0,
|
|
131
|
+
0,
|
|
132
|
+
0,
|
|
133
|
+
1,
|
|
134
|
+
1,
|
|
135
|
+
1,
|
|
136
|
+
1,
|
|
137
|
+
2,
|
|
138
|
+
2,
|
|
139
|
+
2,
|
|
140
|
+
2,
|
|
141
|
+
3,
|
|
142
|
+
3,
|
|
143
|
+
3,
|
|
144
|
+
3,
|
|
145
|
+
4,
|
|
146
|
+
4,
|
|
147
|
+
4,
|
|
148
|
+
4,
|
|
149
|
+
5,
|
|
150
|
+
5,
|
|
151
|
+
5,
|
|
152
|
+
5,
|
|
153
|
+
0,
|
|
154
|
+
0,
|
|
155
|
+
0,
|
|
156
|
+
0
|
|
157
|
+
]);
|
|
158
|
+
var fdeb = new u8([
|
|
159
|
+
0,
|
|
160
|
+
0,
|
|
161
|
+
0,
|
|
162
|
+
0,
|
|
163
|
+
1,
|
|
164
|
+
1,
|
|
165
|
+
2,
|
|
166
|
+
2,
|
|
167
|
+
3,
|
|
168
|
+
3,
|
|
169
|
+
4,
|
|
170
|
+
4,
|
|
171
|
+
5,
|
|
172
|
+
5,
|
|
173
|
+
6,
|
|
174
|
+
6,
|
|
175
|
+
7,
|
|
176
|
+
7,
|
|
177
|
+
8,
|
|
178
|
+
8,
|
|
179
|
+
9,
|
|
180
|
+
9,
|
|
181
|
+
10,
|
|
182
|
+
10,
|
|
183
|
+
11,
|
|
184
|
+
11,
|
|
185
|
+
12,
|
|
186
|
+
12,
|
|
187
|
+
13,
|
|
188
|
+
13,
|
|
189
|
+
0,
|
|
190
|
+
0
|
|
191
|
+
]);
|
|
192
|
+
var clim = new u8([
|
|
193
|
+
16,
|
|
194
|
+
17,
|
|
195
|
+
18,
|
|
196
|
+
0,
|
|
197
|
+
8,
|
|
198
|
+
7,
|
|
199
|
+
9,
|
|
200
|
+
6,
|
|
201
|
+
10,
|
|
202
|
+
5,
|
|
203
|
+
11,
|
|
204
|
+
4,
|
|
205
|
+
12,
|
|
206
|
+
3,
|
|
207
|
+
13,
|
|
208
|
+
2,
|
|
209
|
+
14,
|
|
210
|
+
1,
|
|
211
|
+
15
|
|
212
|
+
]);
|
|
213
|
+
var freb = function(eb, start) {
|
|
214
|
+
var b = new u16(31);
|
|
215
|
+
for (var i = 0; i < 31; ++i) b[i] = start += 1 << eb[i - 1];
|
|
216
|
+
var r = new i32(b[30]);
|
|
217
|
+
for (var i = 1; i < 30; ++i) for (var j = b[i]; j < b[i + 1]; ++j) r[j] = j - b[i] << 5 | i;
|
|
218
|
+
return {
|
|
219
|
+
b,
|
|
220
|
+
r
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
var _a = freb(fleb, 2);
|
|
224
|
+
var fl = _a.b;
|
|
225
|
+
var revfl = _a.r;
|
|
226
|
+
fl[28] = 258, revfl[258] = 28;
|
|
227
|
+
var _b = freb(fdeb, 0);
|
|
228
|
+
var fd = _b.b;
|
|
229
|
+
_b.r;
|
|
230
|
+
var rev = new u16(32768);
|
|
231
|
+
for (var i = 0; i < 32768; ++i) {
|
|
232
|
+
var x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
233
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
234
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
235
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
236
|
+
}
|
|
237
|
+
var hMap = (function(cd, mb, r) {
|
|
238
|
+
var s = cd.length;
|
|
239
|
+
var i = 0;
|
|
240
|
+
var l = new u16(mb);
|
|
241
|
+
for (; i < s; ++i) if (cd[i]) ++l[cd[i] - 1];
|
|
242
|
+
var le = new u16(mb);
|
|
243
|
+
for (i = 1; i < mb; ++i) le[i] = le[i - 1] + l[i - 1] << 1;
|
|
244
|
+
var co;
|
|
245
|
+
if (r) {
|
|
246
|
+
co = new u16(1 << mb);
|
|
247
|
+
var rvb = 15 - mb;
|
|
248
|
+
for (i = 0; i < s; ++i) if (cd[i]) {
|
|
249
|
+
var sv = i << 4 | cd[i];
|
|
250
|
+
var r_1 = mb - cd[i];
|
|
251
|
+
var v = le[cd[i] - 1]++ << r_1;
|
|
252
|
+
for (var m = v | (1 << r_1) - 1; v <= m; ++v) co[rev[v] >> rvb] = sv;
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
co = new u16(s);
|
|
256
|
+
for (i = 0; i < s; ++i) if (cd[i]) co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
|
|
257
|
+
}
|
|
258
|
+
return co;
|
|
259
|
+
});
|
|
260
|
+
var flt = new u8(288);
|
|
261
|
+
for (var i = 0; i < 144; ++i) flt[i] = 8;
|
|
262
|
+
for (var i = 144; i < 256; ++i) flt[i] = 9;
|
|
263
|
+
for (var i = 256; i < 280; ++i) flt[i] = 7;
|
|
264
|
+
for (var i = 280; i < 288; ++i) flt[i] = 8;
|
|
265
|
+
var fdt = new u8(32);
|
|
266
|
+
for (var i = 0; i < 32; ++i) fdt[i] = 5;
|
|
267
|
+
var flrm = /*#__PURE__*/ hMap(flt, 9, 1);
|
|
268
|
+
var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
|
|
269
|
+
var max = function(a) {
|
|
270
|
+
var m = a[0];
|
|
271
|
+
for (var i = 1; i < a.length; ++i) if (a[i] > m) m = a[i];
|
|
272
|
+
return m;
|
|
273
|
+
};
|
|
274
|
+
var bits = function(d, p, m) {
|
|
275
|
+
var o = p / 8 | 0;
|
|
276
|
+
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
|
|
277
|
+
};
|
|
278
|
+
var bits16 = function(d, p) {
|
|
279
|
+
var o = p / 8 | 0;
|
|
280
|
+
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
|
|
281
|
+
};
|
|
282
|
+
var shft = function(p) {
|
|
283
|
+
return (p + 7) / 8 | 0;
|
|
284
|
+
};
|
|
285
|
+
var slc = function(v, s, e) {
|
|
286
|
+
if (s == null || s < 0) s = 0;
|
|
287
|
+
if (e == null || e > v.length) e = v.length;
|
|
288
|
+
return new u8(v.subarray(s, e));
|
|
289
|
+
};
|
|
290
|
+
var ec = [
|
|
291
|
+
"unexpected EOF",
|
|
292
|
+
"invalid block type",
|
|
293
|
+
"invalid length/literal",
|
|
294
|
+
"invalid distance",
|
|
295
|
+
"stream finished",
|
|
296
|
+
"no stream handler",
|
|
297
|
+
,
|
|
298
|
+
"no callback",
|
|
299
|
+
"invalid UTF-8 data",
|
|
300
|
+
"extra field too long",
|
|
301
|
+
"date not in range 1980-2099",
|
|
302
|
+
"filename too long",
|
|
303
|
+
"stream finishing",
|
|
304
|
+
"invalid zip data"
|
|
305
|
+
];
|
|
306
|
+
var err = function(ind, msg, nt) {
|
|
307
|
+
var e = new Error(msg || ec[ind]);
|
|
308
|
+
e.code = ind;
|
|
309
|
+
if (Error.captureStackTrace) Error.captureStackTrace(e, err);
|
|
310
|
+
if (!nt) throw e;
|
|
311
|
+
return e;
|
|
312
|
+
};
|
|
313
|
+
var inflt = function(dat, st, buf, dict) {
|
|
314
|
+
var sl = dat.length, dl = dict ? dict.length : 0;
|
|
315
|
+
if (!sl || st.f && !st.l) return buf || new u8(0);
|
|
316
|
+
var noBuf = !buf;
|
|
317
|
+
var resize = noBuf || st.i != 2;
|
|
318
|
+
var noSt = st.i;
|
|
319
|
+
if (noBuf) buf = new u8(sl * 3);
|
|
320
|
+
var cbuf = function(l) {
|
|
321
|
+
var bl = buf.length;
|
|
322
|
+
if (l > bl) {
|
|
323
|
+
var nbuf = new u8(Math.max(bl * 2, l));
|
|
324
|
+
nbuf.set(buf);
|
|
325
|
+
buf = nbuf;
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
329
|
+
var tbts = sl * 8;
|
|
330
|
+
do {
|
|
331
|
+
if (!lm) {
|
|
332
|
+
final = bits(dat, pos, 1);
|
|
333
|
+
var type = bits(dat, pos + 1, 3);
|
|
334
|
+
pos += 3;
|
|
335
|
+
if (!type) {
|
|
336
|
+
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
|
|
337
|
+
if (t > sl) {
|
|
338
|
+
if (noSt) err(0);
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
if (resize) cbuf(bt + l);
|
|
342
|
+
buf.set(dat.subarray(s, t), bt);
|
|
343
|
+
st.b = bt += l, st.p = pos = t * 8, st.f = final;
|
|
344
|
+
continue;
|
|
345
|
+
} else if (type == 1) lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
346
|
+
else if (type == 2) {
|
|
347
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
348
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
349
|
+
pos += 14;
|
|
350
|
+
var ldt = new u8(tl);
|
|
351
|
+
var clt = new u8(19);
|
|
352
|
+
for (var i = 0; i < hcLen; ++i) clt[clim[i]] = bits(dat, pos + i * 3, 7);
|
|
353
|
+
pos += hcLen * 3;
|
|
354
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
355
|
+
var clm = hMap(clt, clb, 1);
|
|
356
|
+
for (var i = 0; i < tl;) {
|
|
357
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
358
|
+
pos += r & 15;
|
|
359
|
+
var s = r >> 4;
|
|
360
|
+
if (s < 16) ldt[i++] = s;
|
|
361
|
+
else {
|
|
362
|
+
var c = 0, n = 0;
|
|
363
|
+
if (s == 16) n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
|
|
364
|
+
else if (s == 17) n = 3 + bits(dat, pos, 7), pos += 3;
|
|
365
|
+
else if (s == 18) n = 11 + bits(dat, pos, 127), pos += 7;
|
|
366
|
+
while (n--) ldt[i++] = c;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
370
|
+
lbt = max(lt);
|
|
371
|
+
dbt = max(dt);
|
|
372
|
+
lm = hMap(lt, lbt, 1);
|
|
373
|
+
dm = hMap(dt, dbt, 1);
|
|
374
|
+
} else err(1);
|
|
375
|
+
if (pos > tbts) {
|
|
376
|
+
if (noSt) err(0);
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (resize) cbuf(bt + 131072);
|
|
381
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
382
|
+
var lpos = pos;
|
|
383
|
+
for (;; lpos = pos) {
|
|
384
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
|
|
385
|
+
pos += c & 15;
|
|
386
|
+
if (pos > tbts) {
|
|
387
|
+
if (noSt) err(0);
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
if (!c) err(2);
|
|
391
|
+
if (sym < 256) buf[bt++] = sym;
|
|
392
|
+
else if (sym == 256) {
|
|
393
|
+
lpos = pos, lm = null;
|
|
394
|
+
break;
|
|
395
|
+
} else {
|
|
396
|
+
var add = sym - 254;
|
|
397
|
+
if (sym > 264) {
|
|
398
|
+
var i = sym - 257, b = fleb[i];
|
|
399
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i];
|
|
400
|
+
pos += b;
|
|
401
|
+
}
|
|
402
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
|
|
403
|
+
if (!d) err(3);
|
|
404
|
+
pos += d & 15;
|
|
405
|
+
var dt = fd[dsym];
|
|
406
|
+
if (dsym > 3) {
|
|
407
|
+
var b = fdeb[dsym];
|
|
408
|
+
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
409
|
+
}
|
|
410
|
+
if (pos > tbts) {
|
|
411
|
+
if (noSt) err(0);
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
if (resize) cbuf(bt + 131072);
|
|
415
|
+
var end = bt + add;
|
|
416
|
+
if (bt < dt) {
|
|
417
|
+
var shift = dl - dt, dend = Math.min(dt, end);
|
|
418
|
+
if (shift + bt < 0) err(3);
|
|
419
|
+
for (; bt < dend; ++bt) buf[bt] = dict[shift + bt];
|
|
420
|
+
}
|
|
421
|
+
for (; bt < end; ++bt) buf[bt] = buf[bt - dt];
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
425
|
+
if (lm) final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
426
|
+
} while (!final);
|
|
427
|
+
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
|
|
428
|
+
};
|
|
429
|
+
var et = /*#__PURE__*/ new u8(0);
|
|
430
|
+
var gzs = function(d) {
|
|
431
|
+
if (d[0] != 31 || d[1] != 139 || d[2] != 8) err(6, "invalid gzip data");
|
|
432
|
+
var flg = d[3];
|
|
433
|
+
var st = 10;
|
|
434
|
+
if (flg & 4) st += (d[10] | d[11] << 8) + 2;
|
|
435
|
+
for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]);
|
|
436
|
+
return st + (flg & 2);
|
|
437
|
+
};
|
|
438
|
+
var gzl = function(d) {
|
|
439
|
+
var l = d.length;
|
|
440
|
+
return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
|
|
441
|
+
};
|
|
442
|
+
function gunzipSync(data, opts) {
|
|
443
|
+
var st = gzs(data);
|
|
444
|
+
if (st + 8 > data.length) err(6, "invalid gzip data");
|
|
445
|
+
return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary);
|
|
45
446
|
}
|
|
447
|
+
var td = typeof TextDecoder != "undefined" && /*#__PURE__*/ new TextDecoder();
|
|
448
|
+
try {
|
|
449
|
+
td.decode(et, { stream: true });
|
|
450
|
+
} catch (e) {}
|
|
46
451
|
//#endregion
|
|
47
452
|
//#region src/artifacts/payloads.ts
|
|
48
453
|
/**
|
|
@@ -86,4 +491,4 @@ function createPayloadLoaders(chunks) {
|
|
|
86
491
|
return loaders;
|
|
87
492
|
}
|
|
88
493
|
//#endregion
|
|
89
|
-
export {
|
|
494
|
+
export { createArtifactCollection, createArtifactCollections, createArtifactRevision, createLiveCollection, createPayloadLoaders, decodeCompressed, restoreContentError };
|
package/dist/loaders.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as GlobOptions, t as FileOptions } from "./descriptor-BUPT2J7X.mjs";
|
|
1
|
+
import { a as DataStore, c as Loader, d as LoaderLogger, f as LoaderSource, h as RecordLoader, i as DataEntry, l as LoaderConfig, m as MetaStore, n as GlobOptions, o as FileEntrySource, p as LoaderWatcher, r as BodyLoader, s as FileSource, t as FileOptions, u as LoaderContext } from "./descriptor-bcPa6XLk.mjs";
|
|
3
2
|
//#region src/loaders/file.d.ts
|
|
4
3
|
/** Declares a multi-entry data file with typed source paths and record keys, plus an optional parser. */
|
|
5
4
|
export declare function file(filename: string, options?: FileOptions): RecordLoader<FileEntrySource>;
|
package/dist/loaders.mjs
CHANGED
|
@@ -1,85 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as groupDiagnostics, n as contentError, r as describeCause, t as ContentError } from "./errors-C2iuBM0G.mjs";
|
|
3
|
-
import { a as populateStore, i as recordData, n as coerceIdentity, r as parseData, t as glob } from "./glob-Bv0dpvCQ.mjs";
|
|
1
|
+
import { t as glob } from "./glob-BXJuwy_p.mjs";
|
|
4
2
|
import { t as assertServerOnly } from "./server-only-CIJUlyL-.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
//#region src/loaders/file.ts
|
|
9
|
-
/** Declares a multi-entry data file with typed source paths and record keys, plus an optional parser. */
|
|
10
|
-
function file(filename, options = {}) {
|
|
11
|
-
if (typeof filename !== "string" || !filename) throw new TypeError("file() requires a filename.");
|
|
12
|
-
const descriptor = {
|
|
13
|
-
kind: "file",
|
|
14
|
-
filename,
|
|
15
|
-
options
|
|
16
|
-
};
|
|
17
|
-
return {
|
|
18
|
-
[builtinSymbol]: descriptor,
|
|
19
|
-
name: "content-query/file",
|
|
20
|
-
async load(context) {
|
|
21
|
-
const entries = await loadFile(descriptor, fileURLToPath(context.config.root), context.signal ?? new AbortController().signal);
|
|
22
|
-
await populateStore(context, entries);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/** Captures a complete multi-entry data source without applying collection validation. */
|
|
27
|
-
async function loadFile(descriptor, root, signal) {
|
|
28
|
-
const resolved = builtinPath(descriptor, root);
|
|
29
|
-
let parsed;
|
|
30
|
-
try {
|
|
31
|
-
const text = await readFile(resolved, {
|
|
32
|
-
encoding: "utf8",
|
|
33
|
-
signal
|
|
34
|
-
});
|
|
35
|
-
parsed = descriptor.options.parser ? await descriptor.options.parser(text) : parseData(text, resolved);
|
|
36
|
-
} catch (cause) {
|
|
37
|
-
signal.throwIfAborted();
|
|
38
|
-
throw contentError(cause, {
|
|
39
|
-
code: "source-error",
|
|
40
|
-
source: resolved,
|
|
41
|
-
message: `Could not load "${descriptor.filename}": ${describeCause(cause)}`,
|
|
42
|
-
cause
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const array = Array.isArray(parsed);
|
|
46
|
-
if (!array && (!parsed || typeof parsed !== "object")) throw new ContentError({
|
|
47
|
-
code: "source-error",
|
|
48
|
-
source: resolved,
|
|
49
|
-
message: `"${descriptor.filename}" must parse to an array or keyed record.`
|
|
50
|
-
});
|
|
51
|
-
const diagnostics = [];
|
|
52
|
-
const entries = Object.entries(parsed).flatMap(([key, value]) => {
|
|
53
|
-
if (!array && key === "$schema" && typeof value === "string") return [];
|
|
54
|
-
const source = `${resolved}#${key}`;
|
|
55
|
-
try {
|
|
56
|
-
const data = recordData(value);
|
|
57
|
-
const identity = array ? data.id ?? data.slug : key;
|
|
58
|
-
if (identity == null || coerceIdentity(identity) === "") throw new Error("Array entries require a nonempty id or slug.");
|
|
59
|
-
const { id: _transportId, ...metadata } = data;
|
|
60
|
-
return [{
|
|
61
|
-
id: coerceIdentity(identity),
|
|
62
|
-
data: metadata,
|
|
63
|
-
source: array ? source : `${resolved}#${coerceIdentity(identity)}`,
|
|
64
|
-
sourceData: {
|
|
65
|
-
filePath: path.relative(root, resolved).split(path.sep).join("/"),
|
|
66
|
-
key
|
|
67
|
-
}
|
|
68
|
-
}];
|
|
69
|
-
} catch (cause) {
|
|
70
|
-
diagnostics.push({
|
|
71
|
-
code: "source-error",
|
|
72
|
-
source,
|
|
73
|
-
message: `Invalid entry "${key}" in "${descriptor.filename}": ${describeCause(cause)}`,
|
|
74
|
-
cause
|
|
75
|
-
});
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (diagnostics.length) throw groupDiagnostics(diagnostics);
|
|
80
|
-
return entries;
|
|
81
|
-
}
|
|
82
|
-
//#endregion
|
|
3
|
+
import { t as file } from "./file-DSOcdFj0.mjs";
|
|
83
4
|
//#region src/loaders.ts
|
|
84
5
|
assertServerOnly();
|
|
85
6
|
//#endregion
|
package/dist/next.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BuildContentOptions } from "./build-
|
|
1
|
+
import { t as BuildContentOptions } from "./build-DfoncKL8.mjs";
|
|
2
2
|
import { NextConfig } from "next";
|
|
3
3
|
//#region src/integrations/next/plugin.d.ts
|
|
4
4
|
/** Content locations for Next.js; the adapter chooses generated storage and the watch lifecycle. */
|
|
@@ -9,7 +9,8 @@ type ConfigContext = {
|
|
|
9
9
|
type ConfigInput = NextConfig | Promise<NextConfig> | ((phase: string, context: ConfigContext) => NextConfig | Promise<NextConfig>);
|
|
10
10
|
/**
|
|
11
11
|
* Builds content before Next compiles, retaining one managed watcher during `next dev`.
|
|
12
|
-
* Import
|
|
12
|
+
* Import each collection's generated entry, such as `#content-query/posts`, from Server
|
|
13
|
+
* Components; Next's HMR observes their updates, and each route traces only what it imports.
|
|
13
14
|
* Next's detached telemetry helper evaluates configuration without starting content sessions.
|
|
14
15
|
* @param nextConfig Existing object, promise, or phase-aware Next.js configuration.
|
|
15
16
|
* @param options Optional content configuration file and generated output directory.
|