foldkit-mixins 0.4.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.
Files changed (74) hide show
  1. package/README.md +228 -13
  2. package/dist/app.d.mts +46 -0
  3. package/dist/app.d.mts.map +1 -0
  4. package/dist/app.mjs +45 -0
  5. package/dist/app.mjs.map +1 -0
  6. package/dist/{core-izIY2GSX.mjs → core-Bxj0UQDF.mjs} +2 -2
  7. package/dist/{core-izIY2GSX.mjs.map → core-Bxj0UQDF.mjs.map} +1 -1
  8. package/dist/{core-B86QnDhB.d.mts → core-CUw_n1Nd.d.mts} +2 -2
  9. package/dist/{core-B86QnDhB.d.mts.map → core-CUw_n1Nd.d.mts.map} +1 -1
  10. package/dist/defaults.d.mts +6 -2
  11. package/dist/defaults.d.mts.map +1 -1
  12. package/dist/defaults.mjs +7 -3
  13. package/dist/defaults.mjs.map +1 -1
  14. package/dist/foundations.d.mts +30 -0
  15. package/dist/foundations.d.mts.map +1 -0
  16. package/dist/foundations.mjs +71 -0
  17. package/dist/foundations.mjs.map +1 -0
  18. package/dist/index.d.mts +11 -566
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +63 -1076
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/{layers-CJS5d1i7.mjs → layers-B31M0tDi.mjs} +3 -7
  23. package/dist/layers-B31M0tDi.mjs.map +1 -0
  24. package/dist/layers.d.mts +1 -1
  25. package/dist/layers.d.mts.map +1 -1
  26. package/dist/layers.mjs +1 -1
  27. package/dist/layout.d.mts +1 -1
  28. package/dist/layout.mjs +1 -1
  29. package/dist/oklch-BxvCD0oi.d.mts +135 -0
  30. package/dist/oklch-BxvCD0oi.d.mts.map +1 -0
  31. package/dist/prose.d.mts +8 -2
  32. package/dist/prose.d.mts.map +1 -1
  33. package/dist/prose.mjs +11 -7
  34. package/dist/prose.mjs.map +1 -1
  35. package/dist/root-C1u12YMD.mjs +37 -0
  36. package/dist/root-C1u12YMD.mjs.map +1 -0
  37. package/dist/root-xyWS6geK.d.mts +25 -0
  38. package/dist/root-xyWS6geK.d.mts.map +1 -0
  39. package/dist/slotItem-D6_m6IqP.d.mts +18 -0
  40. package/dist/slotItem-D6_m6IqP.d.mts.map +1 -0
  41. package/dist/slotMark-Rdsjb7XI.mjs +135 -0
  42. package/dist/slotMark-Rdsjb7XI.mjs.map +1 -0
  43. package/dist/slotView-BtIF2pHo.d.mts +476 -0
  44. package/dist/slotView-BtIF2pHo.d.mts.map +1 -0
  45. package/dist/style-CKjLee4e.mjs +1266 -0
  46. package/dist/style-CKjLee4e.mjs.map +1 -0
  47. package/dist/style-CtCqaL0l.d.mts +182 -0
  48. package/dist/style-CtCqaL0l.d.mts.map +1 -0
  49. package/dist/{styleValue-C9vAKt7A.d.mts → styleValue-BavTe9MZ.d.mts} +13 -18
  50. package/dist/styleValue-BavTe9MZ.d.mts.map +1 -0
  51. package/dist/{styleValue--iQMTcPn.mjs → styleValue-_G9jwb17.mjs} +84 -78
  52. package/dist/styleValue-_G9jwb17.mjs.map +1 -0
  53. package/dist/testing.d.mts +30 -0
  54. package/dist/testing.d.mts.map +1 -0
  55. package/dist/testing.mjs +167 -0
  56. package/dist/testing.mjs.map +1 -0
  57. package/dist/theme.d.mts +21 -240
  58. package/dist/theme.d.mts.map +1 -1
  59. package/dist/theme.mjs +11 -143
  60. package/dist/theme.mjs.map +1 -1
  61. package/dist/tokens-BR_qxDR7.d.mts +91 -0
  62. package/dist/tokens-BR_qxDR7.d.mts.map +1 -0
  63. package/dist/tokens-DteBJVN-.mjs +117 -0
  64. package/dist/tokens-DteBJVN-.mjs.map +1 -0
  65. package/dist/utilities.d.mts +73 -0
  66. package/dist/utilities.d.mts.map +1 -0
  67. package/dist/utilities.mjs +90 -0
  68. package/dist/utilities.mjs.map +1 -0
  69. package/package.json +30 -3
  70. package/dist/diagnostics-YJ7991-A.mjs +0 -15
  71. package/dist/diagnostics-YJ7991-A.mjs.map +0 -1
  72. package/dist/layers-CJS5d1i7.mjs.map +0 -1
  73. package/dist/styleValue--iQMTcPn.mjs.map +0 -1
  74. package/dist/styleValue-C9vAKt7A.d.mts.map +0 -1
@@ -0,0 +1,71 @@
1
+ //#region src/foundations.ts
2
+ /** Workspace packages resolve to their source, so the foundations build as edited. */
3
+ const conditions = ["foldkit-plus:source"];
4
+ const loadVite = async () => {
5
+ try {
6
+ return await import("vite");
7
+ } catch {
8
+ throw new Error("foldkit-mixins/foundations needs the 'vite' package: add it where the build runs");
9
+ }
10
+ };
11
+ /** The stylesheet text a loaded module holds, or a refusal naming the export. */
12
+ const readStylesheet = (exported, module, name) => {
13
+ const stylesheet = exported[name];
14
+ if (typeof stylesheet !== "string") throw new Error(`foldkit-mixins/foundations: ${module} exports no ${name} stylesheet`);
15
+ return stylesheet;
16
+ };
17
+ /**
18
+ * Compiles the stylesheet a module exports: what the page's first paint is
19
+ * styled with before any script runs. The module is evaluated, so it must be
20
+ * pure (building a string, like the CMS example's sheet).
21
+ */
22
+ const loadFoundations = async (options) => {
23
+ const { createServer } = await loadVite();
24
+ const server = await createServer({
25
+ configFile: false,
26
+ root: options.root ?? process.cwd(),
27
+ logLevel: "error",
28
+ appType: "custom",
29
+ server: {
30
+ middlewareMode: true,
31
+ hmr: false
32
+ },
33
+ resolve: { conditions },
34
+ ssr: { resolve: { conditions } },
35
+ optimizeDeps: {
36
+ noDiscovery: true,
37
+ include: []
38
+ }
39
+ });
40
+ try {
41
+ return readStylesheet(await server.ssrLoadModule(options.module), options.module, options.export ?? "stylesheet");
42
+ } finally {
43
+ await server.close();
44
+ }
45
+ };
46
+ /**
47
+ * Writes the foundations into the page's head: in development through the
48
+ * running server, in a build through one of its own. Without it, each move
49
+ * between pages paints unstyled until the script runs.
50
+ */
51
+ const foundations = (options) => ({
52
+ name: "foldkit-foundations",
53
+ transformIndexHtml: {
54
+ order: "pre",
55
+ handler: async (_html, context) => {
56
+ return [{
57
+ tag: "style",
58
+ children: context.server === void 0 ? await loadFoundations({
59
+ module: options.module,
60
+ export: options.export,
61
+ root: options.root
62
+ }) : readStylesheet(await context.server.ssrLoadModule(options.module), options.module, options.export ?? "stylesheet"),
63
+ injectTo: "head"
64
+ }];
65
+ }
66
+ }
67
+ });
68
+ //#endregion
69
+ export { foundations, loadFoundations };
70
+
71
+ //# sourceMappingURL=foundations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundations.mjs","names":[],"sources":["../src/foundations.ts"],"sourcesContent":["/**\n * `foldkit-mixins/foundations`: the page's foundations (the reset, the\n * palette, the type) in the HTML, so its first paint already has the\n * theme's background. A view's own Styles still arrive as it draws; this is\n * the one stylesheet that belongs to no view.\n *\n * The stylesheet is compiled from a module the application owns, through a\n * server, as the page would compile it — so the build's foundations are the\n * application's, not a copy. `vite` is loaded only here, never by a page:\n * this subpath is node-only, and a page that imports it by mistake fails\n * fast naming `vite`.\n */\nimport type { HtmlTagDescriptor, Plugin, ViteDevServer } from 'vite'\n\n/** Workspace packages resolve to their source, so the foundations build as edited. */\nconst conditions = ['foldkit-plus:source']\n\nconst loadVite = async (): Promise<typeof import('vite')> => {\n try {\n return await import('vite')\n } catch {\n throw new Error(\n \"foldkit-mixins/foundations needs the 'vite' package: add it where the build runs\",\n )\n }\n}\n\n/** The stylesheet text a loaded module holds, or a refusal naming the export. */\nconst readStylesheet = (\n exported: Record<string, unknown>,\n module: string,\n name: string,\n): string => {\n const stylesheet = exported[name]\n if (typeof stylesheet !== 'string')\n throw new Error(`foldkit-mixins/foundations: ${module} exports no ${name} stylesheet`)\n return stylesheet\n}\n\n/**\n * Compiles the stylesheet a module exports: what the page's first paint is\n * styled with before any script runs. The module is evaluated, so it must be\n * pure (building a string, like the CMS example's sheet).\n */\nexport const loadFoundations = async (options: {\n /** The stylesheet module, root-relative (`/src/styles/sheet.ts`). */\n readonly module: string\n /** The export holding the stylesheet text. Default `stylesheet`. */\n readonly export?: string | undefined\n /** What `vite build` runs from. Default the current directory. */\n readonly root?: string | undefined\n}): Promise<string> => {\n const { createServer } = await loadVite()\n const server = await createServer({\n configFile: false,\n root: options.root ?? process.cwd(),\n logLevel: 'error',\n appType: 'custom',\n server: { middlewareMode: true, hmr: false },\n resolve: { conditions },\n ssr: { resolve: { conditions } },\n optimizeDeps: { noDiscovery: true, include: [] },\n })\n try {\n return readStylesheet(\n (await server.ssrLoadModule(options.module)) as Record<string, unknown>,\n options.module,\n options.export ?? 'stylesheet',\n )\n } finally {\n await server.close()\n }\n}\n\n/**\n * Writes the foundations into the page's head: in development through the\n * running server, in a build through one of its own. Without it, each move\n * between pages paints unstyled until the script runs.\n */\nexport const foundations = (options: {\n /** The stylesheet module, root-relative (`/src/styles/sheet.ts`). */\n readonly module: string\n /** The export holding the stylesheet text. Default `stylesheet`. */\n readonly export?: string | undefined\n /** What `vite build` runs from. Default the current directory. */\n readonly root?: string | undefined\n}): Plugin => ({\n name: 'foldkit-foundations',\n transformIndexHtml: {\n order: 'pre',\n handler: async (\n _html,\n context: { readonly server?: ViteDevServer | undefined },\n ): Promise<Array<HtmlTagDescriptor>> => {\n const stylesheet =\n context.server === undefined\n ? await loadFoundations({\n module: options.module,\n export: options.export,\n root: options.root,\n })\n : readStylesheet(\n (await context.server.ssrLoadModule(options.module)) as Record<string, unknown>,\n options.module,\n options.export ?? 'stylesheet',\n )\n return [{ tag: 'style', children: stylesheet, injectTo: 'head' as const }]\n },\n },\n})\n"],"mappings":";;AAeA,MAAM,aAAa,CAAC,qBAAqB;AAEzC,MAAM,WAAW,YAA4C;CAC3D,IAAI;EACF,OAAO,MAAM,OAAO;CACtB,QAAQ;EACN,MAAM,IAAI,MACR,kFACF;CACF;AACF;;AAGA,MAAM,kBACJ,UACA,QACA,SACW;CACX,MAAM,aAAa,SAAS;CAC5B,IAAI,OAAO,eAAe,UACxB,MAAM,IAAI,MAAM,+BAA+B,OAAO,cAAc,KAAK,YAAY;CACvF,OAAO;AACT;;;;;;AAOA,MAAa,kBAAkB,OAAO,YAOf;CACrB,MAAM,EA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