@driftime/sanity-plugin-font 0.0.0-stage → 0.1.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 +459 -2
- package/dist/catalog-BVw1r_SG.js +183 -0
- package/dist/catalog-BVw1r_SG.js.map +1 -0
- package/dist/catalog-KAqAIjzw.js +96 -0
- package/dist/catalog-KAqAIjzw.js.map +1 -0
- package/dist/catalog.d.ts +29 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +10 -0
- package/dist/catalog.js.map +1 -0
- package/dist/family-BAGnEjZg.js +36 -0
- package/dist/family-BAGnEjZg.js.map +1 -0
- package/dist/font-styles.d.ts +21 -0
- package/dist/font-styles.d.ts.map +1 -0
- package/dist/font-styles.js +43 -0
- package/dist/font-styles.js.map +1 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2364 -0
- package/dist/index.js.map +1 -0
- package/dist/names.d.ts +8 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +0 -0
- package/dist/next-loader.d.ts +19 -0
- package/dist/next-loader.d.ts.map +1 -0
- package/dist/next-loader.js +28 -0
- package/dist/next-loader.js.map +1 -0
- package/dist/next.d.ts +42 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +48 -0
- package/dist/next.js.map +1 -0
- package/dist/render.d.ts +12 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +183 -0
- package/dist/render.js.map +1 -0
- package/dist/resolve-Bkp0dEmr.d.ts +81 -0
- package/dist/resolve-Bkp0dEmr.d.ts.map +1 -0
- package/dist/types-DZl90ROd.d.ts +106 -0
- package/dist/types-DZl90ROd.d.ts.map +1 -0
- package/dist/types-DheP5tax.js +27 -0
- package/dist/types-DheP5tax.js.map +1 -0
- package/dist/utils-BV38iODp.js +29 -0
- package/dist/utils-BV38iODp.js.map +1 -0
- package/dist/vite.d.ts +61 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +53 -0
- package/dist/vite.js.map +1 -0
- package/package.json +120 -4
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Vite plugin, limited to the hooks the build step uses, so the package doesn't depend on Vite's own types.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
interface SanityFontVitePlugin {
|
|
7
|
+
/** Name Vite reports the plugin under. */
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* Keeps the placeholder catalog out of Vite's pre-bundling in development, which would fix it in place, while the
|
|
11
|
+
* rest of the plugin and its dependencies are pre-bundled as usual.
|
|
12
|
+
*
|
|
13
|
+
* @returns The configuration to merge.
|
|
14
|
+
*/
|
|
15
|
+
config: () => {
|
|
16
|
+
optimizeDeps: {
|
|
17
|
+
exclude: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Reads the project folder once Vite has resolved its configuration.
|
|
22
|
+
*
|
|
23
|
+
* @param config - Vite's resolved configuration.
|
|
24
|
+
*/
|
|
25
|
+
configResolved: (config: {
|
|
26
|
+
root: string;
|
|
27
|
+
}) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Claims the module the catalog is loaded from.
|
|
30
|
+
*
|
|
31
|
+
* @param id - The module requested.
|
|
32
|
+
* @returns The module's resolved id, or undefined when it isn't the catalog.
|
|
33
|
+
*/
|
|
34
|
+
resolveId: (id: string) => string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Generates the catalog module in place of the placeholder, and the module holding the catalog itself.
|
|
37
|
+
*
|
|
38
|
+
* @param id - The resolved module id.
|
|
39
|
+
* @returns The module's code, or undefined when it isn't the build step's.
|
|
40
|
+
*/
|
|
41
|
+
load: (id: string) => Promise<string | undefined>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates the Vite plugin that downloads the Google Fonts catalog when the Studio starts or builds.
|
|
45
|
+
*
|
|
46
|
+
* @returns The Vite plugin.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare function googleFonts(): SanityFontVitePlugin;
|
|
50
|
+
/**
|
|
51
|
+
* Adds the font build step to a Vite configuration, for the `vite` option in `sanity.cli.ts` or a framework's own
|
|
52
|
+
* Vite settings.
|
|
53
|
+
*
|
|
54
|
+
* @returns A function that extends the Vite configuration.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export declare function withFonts(): <Config extends {
|
|
58
|
+
plugins?: unknown[];
|
|
59
|
+
}>(config: Config) => Config;
|
|
60
|
+
export type { SanityFontVitePlugin };
|
|
61
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","names":["SanityFontVitePlugin","Promise","googleFonts","withFonts","Config"],"sources":["../src/build/vite.ts"],"mappings":"AAWA;;;;;UAAiBA;;EAEf;;;;;;;EAOA;IAAgB;MAAgB;;;;;;;;EAMhC,iBAAiB;IAAU;;;;;;;;EAO3B,YAAY;;;;;;;EAOZ,OAAO,eAAeC;;;;;;;;wBAYRC,eAAeF;;;;;;;;wBAoCfG,cACe;EAAiB;GAAqB,QAAUC,WAASA"}
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { t as isDefined } from "./utils-BV38iODp.js";
|
|
2
|
+
import { i as isCatalogModule, r as createCatalogModule, t as writeFontCatalog } from "./catalog-BVw1r_SG.js";
|
|
3
|
+
import { l as pluginName } from "./catalog-KAqAIjzw.js";
|
|
4
|
+
/** Module the catalog is loaded from, so it's only downloaded when a picker opens. */
|
|
5
|
+
const catalogDataModule = `virtual:${pluginName}/catalog-data`;
|
|
6
|
+
/**
|
|
7
|
+
* Creates the Vite plugin that downloads the Google Fonts catalog when the Studio starts or builds.
|
|
8
|
+
*
|
|
9
|
+
* @returns The Vite plugin.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
function googleFonts() {
|
|
13
|
+
let root = process.cwd();
|
|
14
|
+
return {
|
|
15
|
+
name: pluginName,
|
|
16
|
+
config() {
|
|
17
|
+
return { optimizeDeps: { exclude: [`${pluginName}/catalog`] } };
|
|
18
|
+
},
|
|
19
|
+
configResolved(config) {
|
|
20
|
+
({root} = config);
|
|
21
|
+
},
|
|
22
|
+
resolveId(id) {
|
|
23
|
+
return id === catalogDataModule ? `\0${id}` : void 0;
|
|
24
|
+
},
|
|
25
|
+
async load(id) {
|
|
26
|
+
if (isCatalogModule(id)) {
|
|
27
|
+
let catalog = await writeFontCatalog(root);
|
|
28
|
+
return createCatalogModule(isDefined(catalog) ? catalogDataModule : void 0);
|
|
29
|
+
}
|
|
30
|
+
if (id !== `\0${catalogDataModule}`) return;
|
|
31
|
+
let catalog = await writeFontCatalog(root);
|
|
32
|
+
return `export default JSON.parse(${JSON.stringify(JSON.stringify(catalog?.families ?? []))});`;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Adds the font build step to a Vite configuration, for the `vite` option in `sanity.cli.ts` or a framework's own
|
|
38
|
+
* Vite settings.
|
|
39
|
+
*
|
|
40
|
+
* @returns A function that extends the Vite configuration.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
function withFonts() {
|
|
44
|
+
return function extendConfig(config) {
|
|
45
|
+
return {
|
|
46
|
+
...config,
|
|
47
|
+
plugins: [...config.plugins ?? [], googleFonts()]
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export { googleFonts, withFonts };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","names":["isDefined","writeFontCatalog","createCatalogModule","isCatalogModule","pluginName","SanityFontVitePlugin","name","config","optimizeDeps","exclude","configResolved","root","resolveId","id","load","Promise","catalogDataModule","googleFonts","process","cwd","undefined","catalog","JSON","stringify","families","withFonts","extendConfig","plugins","Config"],"sources":["../src/build/vite.ts"],"sourcesContent":["import { isDefined } from \"@repo/lib/utils\";\n\nimport { writeFontCatalog } from \"@/build/catalog\";\nimport { createCatalogModule, isCatalogModule } from \"@/build/module\";\nimport { pluginName } from \"@/config/defaults\";\n\n/**\n * A Vite plugin, limited to the hooks the build step uses, so the package doesn't depend on Vite's own types.\n *\n * @public\n */\nexport interface SanityFontVitePlugin {\n /** Name Vite reports the plugin under. */\n name: string;\n /**\n * Keeps the placeholder catalog out of Vite's pre-bundling in development, which would fix it in place, while the\n * rest of the plugin and its dependencies are pre-bundled as usual.\n *\n * @returns The configuration to merge.\n */\n config: () => { optimizeDeps: { exclude: string[] } };\n /**\n * Reads the project folder once Vite has resolved its configuration.\n *\n * @param config - Vite's resolved configuration.\n */\n configResolved: (config: { root: string }) => void;\n /**\n * Claims the module the catalog is loaded from.\n *\n * @param id - The module requested.\n * @returns The module's resolved id, or undefined when it isn't the catalog.\n */\n resolveId: (id: string) => string | undefined;\n /**\n * Generates the catalog module in place of the placeholder, and the module holding the catalog itself.\n *\n * @param id - The resolved module id.\n * @returns The module's code, or undefined when it isn't the build step's.\n */\n load: (id: string) => Promise<string | undefined>;\n}\n\n/** Module the catalog is loaded from, so it's only downloaded when a picker opens. */\nconst catalogDataModule = `virtual:${pluginName}/catalog-data`;\n\n/**\n * Creates the Vite plugin that downloads the Google Fonts catalog when the Studio starts or builds.\n *\n * @returns The Vite plugin.\n * @public\n */\nexport function googleFonts(): SanityFontVitePlugin {\n let root = process.cwd();\n\n return {\n name: pluginName,\n config() {\n return { optimizeDeps: { exclude: [`${pluginName}/catalog`] } };\n },\n configResolved(config) {\n ({ root } = config);\n },\n resolveId(id) {\n return id === catalogDataModule ? `\\0${id}` : undefined;\n },\n async load(id) {\n if (isCatalogModule(id)) {\n const catalog = await writeFontCatalog(root);\n\n return createCatalogModule(isDefined(catalog) ? catalogDataModule : undefined);\n }\n if (id !== `\\0${catalogDataModule}`) return undefined;\n\n const catalog = await writeFontCatalog(root);\n\n return `export default JSON.parse(${JSON.stringify(JSON.stringify(catalog?.families ?? []))});`;\n },\n };\n}\n\n/**\n * Adds the font build step to a Vite configuration, for the `vite` option in `sanity.cli.ts` or a framework's own\n * Vite settings.\n *\n * @returns A function that extends the Vite configuration.\n * @public\n */\nexport function withFonts() {\n return function extendConfig<Config extends { plugins?: unknown[] }>(config: Config): Config {\n return { ...config, plugins: [...(config.plugins ?? []), googleFonts()] };\n };\n}\n"],"mappings":";;;;AA4CA,MAAMgB,oBAAoB,WAAWZ,WAAU;;;;;;;AAQ/C,SAAgBa,cAAoC;CAClD,IAAIN,OAAOO,QAAQC,IAAI;CAEvB,OAAO;EACLb,MAAMF;EACNG,SAAS;GACP,OAAO,EAAEC,cAAc,EAAEC,SAAS,CAAC,GAAGL,WAAU,SAAU,EAAE,EAAE;EAChE;EACAM,eAAeH,QAAQ;GACrB,CAAC,CAAEI,QAASJ;EACd;EACAK,UAAUC,IAAI;GACZ,OAAOA,OAAOG,oBAAoB,KAAKH,OAAOO,KAAAA;EAChD;EACA,MAAMN,KAAKD,IAAI;GACb,IAAIV,gBAAgBU,EAAE,GAAG;IACvB,IAAMQ,UAAU,MAAMpB,iBAAiBU,IAAI;IAE3C,OAAOT,oBAAoBF,UAAUqB,OAAO,IAAIL,oBAAoBI,KAAAA,CAAS;GAC/E;GACA,IAAIP,OAAO,KAAKG,qBAAqB;GAErC,IAAMK,UAAU,MAAMpB,iBAAiBU,IAAI;GAE3C,OAAO,6BAA6BW,KAAKC,UAAUD,KAAKC,UAAUF,SAASG,YAAY,CAAA,CAAE,CAAC,EAAC;EAC7F;CACF;AACF;;;;;;;;AASA,SAAgBC,YAAY;CAC1B,OAAO,SAASC,aAAqDnB,QAAwB;EAC3F,OAAO;GAAE,GAAGA;GAAQoB,SAAS,CAAC,GAAIpB,OAAOoB,WAAW,CAAA,GAAKV,YAAY,CAAC;EAAE;CAC1E;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,122 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driftime/sanity-plugin-font",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fonts for Sanity Studio, from the Google Fonts catalog or a brand's own files.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"font",
|
|
7
|
+
"font-picker",
|
|
8
|
+
"fonts",
|
|
9
|
+
"google-fonts",
|
|
10
|
+
"sanity",
|
|
11
|
+
"sanity-plugin",
|
|
12
|
+
"typeface",
|
|
13
|
+
"typography",
|
|
14
|
+
"webfont",
|
|
15
|
+
"woff2"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/driftime/sanity-plugins/tree/main/packages/font#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/driftime/sanity-plugins/issues"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "Kenny Heard",
|
|
24
|
+
"email": "kenny@driftime.com",
|
|
25
|
+
"url": "https://driftime.com"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/driftime/sanity-plugins.git",
|
|
30
|
+
"directory": "packages/font"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"type": "module",
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"source": "./src/index.ts",
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./render": {
|
|
44
|
+
"source": "./src/render.ts",
|
|
45
|
+
"default": "./dist/render.js"
|
|
46
|
+
},
|
|
47
|
+
"./vite": {
|
|
48
|
+
"source": "./src/vite.ts",
|
|
49
|
+
"default": "./dist/vite.js"
|
|
50
|
+
},
|
|
51
|
+
"./next": {
|
|
52
|
+
"source": "./src/next.ts",
|
|
53
|
+
"default": "./dist/next.js"
|
|
54
|
+
},
|
|
55
|
+
"./next-loader": {
|
|
56
|
+
"source": "./src/next-loader.ts",
|
|
57
|
+
"default": "./dist/next-loader.js"
|
|
58
|
+
},
|
|
59
|
+
"./catalog": {
|
|
60
|
+
"source": "./src/catalog.ts",
|
|
61
|
+
"default": "./dist/catalog.js"
|
|
62
|
+
},
|
|
63
|
+
"./names": {
|
|
64
|
+
"source": "./src/names.ts",
|
|
65
|
+
"default": "./dist/names.js"
|
|
66
|
+
},
|
|
67
|
+
"./font-styles": {
|
|
68
|
+
"source": "./src/font-styles.ts",
|
|
69
|
+
"default": "./dist/font-styles.js"
|
|
70
|
+
},
|
|
71
|
+
"./package.json": "./package.json"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"exports": {
|
|
75
|
+
".": "./dist/index.js",
|
|
76
|
+
"./render": "./dist/render.js",
|
|
77
|
+
"./vite": "./dist/vite.js",
|
|
78
|
+
"./next": "./dist/next.js",
|
|
79
|
+
"./next-loader": "./dist/next-loader.js",
|
|
80
|
+
"./catalog": "./dist/catalog.js",
|
|
81
|
+
"./names": "./dist/names.js",
|
|
82
|
+
"./font-styles": "./dist/font-styles.js",
|
|
83
|
+
"./package.json": "./package.json"
|
|
84
|
+
},
|
|
85
|
+
"access": "public"
|
|
86
|
+
},
|
|
87
|
+
"scripts": {
|
|
88
|
+
"typecheck": "tsc",
|
|
89
|
+
"dev": "plugin-kit link-watch",
|
|
90
|
+
"build": "bun run typecheck && plugin-kit verify-package --silent && pkg-utils build --strict --check --clean && node --check dist/index.js && node --check dist/render.js && node --check dist/vite.js && node --check dist/next.js",
|
|
91
|
+
"prepublishOnly": "bun run build",
|
|
92
|
+
"push": "yalc push"
|
|
93
|
+
},
|
|
94
|
+
"dependencies": {
|
|
95
|
+
"@sanity/client": "^7.26.2 || ^8.0.0",
|
|
96
|
+
"@sanity/icons": "^5.2.1",
|
|
97
|
+
"@sanity/ui": "^4.0.3",
|
|
98
|
+
"@sanity/util": "^6.13.2",
|
|
99
|
+
"brotli": "^2.1.0"
|
|
100
|
+
},
|
|
101
|
+
"devDependencies": {
|
|
102
|
+
"@repo/components": "workspace:*",
|
|
103
|
+
"@repo/lib": "workspace:*",
|
|
104
|
+
"@sanity/pkg-utils": "catalog:"
|
|
105
|
+
},
|
|
106
|
+
"peerDependencies": {
|
|
107
|
+
"react": "19",
|
|
108
|
+
"sanity": "^6.10.0"
|
|
109
|
+
},
|
|
110
|
+
"browserslist": "extends @sanity/browserslist-config",
|
|
111
|
+
"engines": {
|
|
112
|
+
"node": ">=20.19 <22 || >=22.12"
|
|
113
|
+
},
|
|
114
|
+
"sanityPlugin": {
|
|
115
|
+
"verifyPackage": {
|
|
116
|
+
"tsconfig": false,
|
|
117
|
+
"scripts": false,
|
|
118
|
+
"oxlint": false,
|
|
119
|
+
"oxfmt": false
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|