@sanity-labs/groq-content-mapper 0.1.6 → 0.1.7
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 +1 -0
- package/dist/jest.js +1 -1
- package/dist/next.js +1 -1
- package/dist/{nodeHooks-CUol2rIz.js → nodeHooks-DopXuN7Q.js} +2 -2
- package/dist/{nodeHooks-CUol2rIz.js.map → nodeHooks-DopXuN7Q.js.map} +1 -1
- package/dist/nodeHooks.js +1 -1
- package/dist/register.js +1 -1
- package/dist/{runtime-DNC5x51t.js → runtime-DVYxuRi3.js} +3 -2
- package/dist/runtime-DVYxuRi3.js.map +1 -0
- package/dist/vite.js +1 -1
- package/package.json +1 -1
- package/dist/runtime-DNC5x51t.js.map +0 -1
package/README.md
CHANGED
package/dist/jest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as groqModuleSourceCommonJs, t as groqModuleSource } from "./runtime-
|
|
1
|
+
import { n as groqModuleSourceCommonJs, t as groqModuleSource } from "./runtime-DVYxuRi3.js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
/**
|
|
4
4
|
* A transformer for `transform` in Jest's config, which is where Jest takes a file it does not
|
package/dist/next.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname, join, resolve } from "node:path";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
const WEBPACK_TEST = /\.groq$/;
|
|
6
6
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as isGroqFile, t as groqModuleSource } from "./runtime-
|
|
1
|
+
import { r as isGroqFile, t as groqModuleSource } from "./runtime-DVYxuRi3.js";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import "node:module";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -20,4 +20,4 @@ const load = (url, context, nextLoad) => {
|
|
|
20
20
|
};
|
|
21
21
|
export { load as t };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=nodeHooks-
|
|
23
|
+
//# sourceMappingURL=nodeHooks-DopXuN7Q.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHooks-
|
|
1
|
+
{"version":3,"file":"nodeHooks-DopXuN7Q.js","names":[],"sources":["../src/nodeHooks.ts"],"sourcesContent":["import {readFileSync} from 'node:fs'\nimport {type LoadHookSync} from 'node:module'\nimport {fileURLToPath} from 'node:url'\n\nimport {groqModuleSource, isGroqFile} from './runtime.js'\n\n/**\n * Node's `load` hook for `.groq` files. Synchronous, as `module.registerHooks` requires, and so\n * also what `module.register` accepts for the off-thread hooks of Node before 22.15. A URL that\n * is not a plain `.groq` file goes on to the next hook.\n */\nexport const load: LoadHookSync = (url, context, nextLoad) => {\n if (!url.startsWith('file:')) return nextLoad(url, context)\n const {hash, pathname, search} = new URL(url)\n // The path is checked as the URL has it: a `#` or `?` in a folder or file name is encoded\n // there, and only a real query or hash makes the import ask for something else.\n if (search || hash || !isGroqFile(pathname)) return nextLoad(url, context)\n const path = fileURLToPath(url)\n return {\n format: 'module',\n shortCircuit: true,\n source: groqModuleSource(readFileSync(path, 'utf8')),\n }\n}\n"],"mappings":";;;;;;;;;AAWA,MAAa,QAAsB,KAAK,SAAS,aAAa;CAC5D,IAAI,CAAC,IAAI,WAAW,OAAO,GAAG,OAAO,SAAS,KAAK,OAAO;CAC1D,IAAM,EAAC,MAAM,UAAU,WAAU,IAAI,IAAI,GAAG;CAG5C,IAAI,UAAU,QAAQ,CAAC,WAAW,QAAQ,GAAG,OAAO,SAAS,KAAK,OAAO;CACzE,IAAM,OAAO,cAAc,GAAG;CAC9B,OAAO;EACL,QAAQ;EACR,cAAc;EACd,QAAQ,iBAAiB,aAAa,MAAM,MAAM,CAAC;CACrD;AACF"}
|
package/dist/nodeHooks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as load } from "./nodeHooks-
|
|
1
|
+
export { t as load } from "./nodeHooks-DopXuN7Q.js";
|
package/dist/register.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as load } from "./nodeHooks-
|
|
1
|
+
import { t as load } from "./nodeHooks-DopXuN7Q.js";
|
|
2
2
|
import * as nodeModule from "node:module";
|
|
3
3
|
const { register, registerHooks } = nodeModule;
|
|
4
4
|
registerHooks ? registerHooks({ load }) : register("./nodeHooks.js", import.meta.url);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
/** The module source for a `.groq` file's content. */
|
|
2
3
|
function groqModuleSource(content) {
|
|
3
4
|
return `export default ${JSON.stringify(content)}\n`;
|
|
@@ -8,7 +9,7 @@ function groqModuleSource(content) {
|
|
|
8
9
|
* alone, as is a virtual id.
|
|
9
10
|
*/
|
|
10
11
|
function isGroqFile(id) {
|
|
11
|
-
return
|
|
12
|
+
return id.startsWith("\0") || !id.endsWith(".groq") ? !1 : !/[?#]/.test(id) || existsSync(id);
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* The same module as CommonJS, for Jest when it loads the file that way. The default export is
|
|
@@ -20,4 +21,4 @@ function groqModuleSourceCommonJs(content) {
|
|
|
20
21
|
}
|
|
21
22
|
export { groqModuleSourceCommonJs as n, isGroqFile as r, groqModuleSource as t };
|
|
22
23
|
|
|
23
|
-
//# sourceMappingURL=runtime-
|
|
24
|
+
//# sourceMappingURL=runtime-DVYxuRi3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-DVYxuRi3.js","names":[],"sources":["../src/runtime.ts"],"sourcesContent":["// What the Node preload, the Vite plugin and the Jest transformer share: a `.groq` file is a\n// module whose default export is the file's text, and nothing else. The text is the file as it\n// is, which is what `import query from './posts.groq' with {type: 'text'}` evaluates to where a\n// runtime or bundler handles the attribute itself, and what the content mapper types.\n\nimport {existsSync} from 'node:fs'\n\n/** The module source for a `.groq` file's content. */\nexport function groqModuleSource(content: string): string {\n return `export default ${JSON.stringify(content)}\\n`\n}\n\n/**\n * Whether an id names a `.groq` file outright. An id with a query or a hash, as in\n * `./posts.groq?raw`, asks another plugin for something this one does not make, so it is left\n * alone, as is a virtual id.\n */\nexport function isGroqFile(id: string): boolean {\n if (id.startsWith('\\0') || !id.endsWith('.groq')) return false\n // A folder or file name can have a `#` or `?` in it too, as in `c#/posts.groq`, and only the\n // file system tells that apart from a query or hash.\n return !/[?#]/.test(id) || existsSync(id)\n}\n\n/**\n * The same module as CommonJS, for Jest when it loads the file that way. The default export is\n * a JSON string, so nothing in it can be mistaken for code, and `__esModule` lets a default\n * import compiled by Babel or TypeScript read `exports.default`.\n */\nexport function groqModuleSourceCommonJs(content: string): string {\n return `Object.defineProperty(exports, \"__esModule\", {value: true});\\nexports.default = ${JSON.stringify(content)};\\n`\n}\n"],"mappings":";;AAQA,SAAgB,iBAAiB,SAAyB;CACxD,OAAO,kBAAkB,KAAK,UAAU,OAAO,EAAE;AACnD;;;;;;AAOA,SAAgB,WAAW,IAAqB;CAI9C,OAHI,GAAG,WAAW,IAAI,KAAK,CAAC,GAAG,SAAS,OAAO,IAAU,KAGlD,CAAC,OAAO,KAAK,EAAE,KAAK,WAAW,EAAE;AAC1C;;;;;;AAOA,SAAgB,yBAAyB,SAAyB;CAChE,OAAO,mFAAmF,KAAK,UAAU,OAAO,EAAE;AACpH"}
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as isGroqFile, t as groqModuleSource } from "./runtime-
|
|
1
|
+
import { r as isGroqFile, t as groqModuleSource } from "./runtime-DVYxuRi3.js";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
/**
|
|
4
4
|
* The plugin for Vite, Vitest, Rollup and Rolldown: a `.groq` import evaluates to the file's
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-DNC5x51t.js","names":[],"sources":["../src/runtime.ts"],"sourcesContent":["// What the Node preload, the Vite plugin and the Jest transformer share: a `.groq` file is a\n// module whose default export is the file's text, and nothing else. The text is the file as it\n// is, which is what `import query from './posts.groq' with {type: 'text'}` evaluates to where a\n// runtime or bundler handles the attribute itself, and what the content mapper types.\n\n/** The module source for a `.groq` file's content. */\nexport function groqModuleSource(content: string): string {\n return `export default ${JSON.stringify(content)}\\n`\n}\n\n/**\n * Whether an id names a `.groq` file outright. An id with a query or a hash, as in\n * `./posts.groq?raw`, asks another plugin for something this one does not make, so it is left\n * alone, as is a virtual id.\n */\nexport function isGroqFile(id: string): boolean {\n return !id.startsWith('\\0') && !/[?#]/.test(id) && id.endsWith('.groq')\n}\n\n/**\n * The same module as CommonJS, for Jest when it loads the file that way. The default export is\n * a JSON string, so nothing in it can be mistaken for code, and `__esModule` lets a default\n * import compiled by Babel or TypeScript read `exports.default`.\n */\nexport function groqModuleSourceCommonJs(content: string): string {\n return `Object.defineProperty(exports, \"__esModule\", {value: true});\\nexports.default = ${JSON.stringify(content)};\\n`\n}\n"],"mappings":";AAMA,SAAgB,iBAAiB,SAAyB;CACxD,OAAO,kBAAkB,KAAK,UAAU,OAAO,EAAE;AACnD;;;;;;AAOA,SAAgB,WAAW,IAAqB;CAC9C,OAAO,CAAC,GAAG,WAAW,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE,KAAK,GAAG,SAAS,OAAO;AACxE;;;;;;AAOA,SAAgB,yBAAyB,SAAyB;CAChE,OAAO,mFAAmF,KAAK,UAAU,OAAO,EAAE;AACpH"}
|