@r_masseater/masseater-utils 0.6.1 → 0.8.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 (163) hide show
  1. package/README.md +40 -22
  2. package/dist/browser-test/vite.d.mts +6 -0
  3. package/dist/browser-test/vite.mjs +29 -0
  4. package/dist/browser-test/vite.mjs.map +1 -0
  5. package/dist/button-variants-BLMlMm-s.mjs +31 -0
  6. package/dist/button-variants-BLMlMm-s.mjs.map +1 -0
  7. package/dist/button-variants-Bupz7GI3.d.mts +6 -0
  8. package/dist/cn-DtxpfSUK.mjs +7 -0
  9. package/dist/cn-DtxpfSUK.mjs.map +1 -0
  10. package/dist/effect2cs.d.mts +27 -0
  11. package/dist/effect2cs.mjs +75 -0
  12. package/dist/effect2cs.mjs.map +1 -0
  13. package/dist/effect2rs.d.mts +52 -0
  14. package/dist/effect2rs.mjs +870 -0
  15. package/dist/effect2rs.mjs.map +1 -0
  16. package/dist/github-workflow.d.mts +3 -33
  17. package/dist/github-workflow.mjs +2 -46
  18. package/dist/github-workflow.mjs.map +1 -1
  19. package/dist/headers-BK-aW9Kw.d.mts +81 -0
  20. package/dist/headers-Cr6gAurg.mjs +115 -0
  21. package/dist/headers-Cr6gAurg.mjs.map +1 -0
  22. package/dist/heading-class-CDq0WZpR.d.mts +10 -0
  23. package/dist/heading-class-H4Z13Bpn.mjs +14 -0
  24. package/dist/heading-class-H4Z13Bpn.mjs.map +1 -0
  25. package/dist/index-BkZOsFv4.d.mts +139 -0
  26. package/dist/index-CLb1-l_c.d.mts +28 -0
  27. package/dist/index-ChbPLmqu.d.mts +33 -0
  28. package/dist/lapse/sdk.d.mts +4 -0
  29. package/dist/lapse/sdk.mjs +11 -0
  30. package/dist/lapse/sdk.mjs.map +1 -0
  31. package/dist/lapse.d.mts +8 -0
  32. package/dist/lapse.mjs +43 -0
  33. package/dist/lapse.mjs.map +1 -0
  34. package/dist/local-server/node.d.mts +21 -0
  35. package/dist/local-server/node.mjs +81 -0
  36. package/dist/local-server/node.mjs.map +1 -0
  37. package/dist/local-server/serve.d.mts +9 -0
  38. package/dist/local-server/serve.mjs +13 -0
  39. package/dist/local-server/serve.mjs.map +1 -0
  40. package/dist/local-server.d.mts +19 -0
  41. package/dist/local-server.mjs +36 -0
  42. package/dist/local-server.mjs.map +1 -0
  43. package/dist/plugin-kit.d.mts +103 -2
  44. package/dist/plugin-kit.mjs +310 -8
  45. package/dist/plugin-kit.mjs.map +1 -1
  46. package/dist/portfolio-BQJtJtfK.mjs +45 -0
  47. package/dist/portfolio-BQJtJtfK.mjs.map +1 -0
  48. package/dist/process-_W_7DeKe.d.mts +34 -0
  49. package/dist/process-lKS6nYWh.mjs +49 -0
  50. package/dist/process-lKS6nYWh.mjs.map +1 -0
  51. package/dist/process.d.mts +2 -0
  52. package/dist/process.mjs +1 -0
  53. package/dist/security-headers/http.d.mts +10 -0
  54. package/dist/security-headers/http.mjs +25 -0
  55. package/dist/security-headers/http.mjs.map +1 -0
  56. package/dist/security-headers/request.d.mts +3 -0
  57. package/dist/security-headers/request.mjs +15 -0
  58. package/dist/security-headers/request.mjs.map +1 -0
  59. package/dist/security-headers/response.d.mts +2 -0
  60. package/dist/security-headers/response.mjs +17 -0
  61. package/dist/security-headers/response.mjs.map +1 -0
  62. package/dist/security-headers/static.d.mts +2 -0
  63. package/dist/security-headers/static.mjs +1 -0
  64. package/dist/security-headers/vite.d.mts +2 -0
  65. package/dist/security-headers/vite.mjs +1 -0
  66. package/dist/security-headers.d.mts +3 -0
  67. package/dist/security-headers.mjs +3 -0
  68. package/dist/socket-port-CTg-qfiP.mjs +20 -0
  69. package/dist/socket-port-CTg-qfiP.mjs.map +1 -0
  70. package/dist/static-page-headers-_B0WGkew.mjs +133 -0
  71. package/dist/static-page-headers-_B0WGkew.mjs.map +1 -0
  72. package/dist/sync-BkyZGGDA.mjs +121 -0
  73. package/dist/sync-BkyZGGDA.mjs.map +1 -0
  74. package/dist/table-class-BeiCXlFj.d.mts +14 -0
  75. package/dist/table-class-RQvT6MYy.mjs +21 -0
  76. package/dist/table-class-RQvT6MYy.mjs.map +1 -0
  77. package/dist/ui/backdrop-palette.d.mts +10 -0
  78. package/dist/ui/backdrop-palette.mjs +13 -0
  79. package/dist/ui/backdrop-palette.mjs.map +1 -0
  80. package/dist/ui/badge.d.mts +12 -0
  81. package/dist/ui/badge.mjs +18 -0
  82. package/dist/ui/badge.mjs.map +1 -0
  83. package/dist/ui/browser-runtime.d.mts +3 -0
  84. package/dist/ui/browser-runtime.mjs +18 -0
  85. package/dist/ui/browser-runtime.mjs.map +1 -0
  86. package/dist/ui/button-variants.d.mts +2 -0
  87. package/dist/ui/button-variants.mjs +1 -0
  88. package/dist/ui/button.d.mts +7 -0
  89. package/dist/ui/button.mjs +30 -0
  90. package/dist/ui/button.mjs.map +1 -0
  91. package/dist/ui/cn.d.mts +3 -0
  92. package/dist/ui/cn.mjs +1 -0
  93. package/dist/ui/color-scheme.d.mts +2 -0
  94. package/dist/ui/color-scheme.mjs +13 -0
  95. package/dist/ui/color-scheme.mjs.map +1 -0
  96. package/dist/ui/heading-class.d.mts +2 -0
  97. package/dist/ui/heading-class.mjs +1 -0
  98. package/dist/ui/heading.d.mts +8 -0
  99. package/dist/ui/heading.mjs +34 -0
  100. package/dist/ui/heading.mjs.map +1 -0
  101. package/dist/ui/input-class.d.mts +2 -0
  102. package/dist/ui/input-class.mjs +5 -0
  103. package/dist/ui/input-class.mjs.map +1 -0
  104. package/dist/ui/native-select-class.d.mts +2 -0
  105. package/dist/ui/native-select-class.mjs +5 -0
  106. package/dist/ui/native-select-class.mjs.map +1 -0
  107. package/dist/ui/next-page-trigger.d.mts +5 -0
  108. package/dist/ui/next-page-trigger.mjs +29 -0
  109. package/dist/ui/next-page-trigger.mjs.map +1 -0
  110. package/dist/ui/page-footer.d.mts +10 -0
  111. package/dist/ui/page-footer.mjs +24 -0
  112. package/dist/ui/page-footer.mjs.map +1 -0
  113. package/dist/ui/page-header.d.mts +11 -0
  114. package/dist/ui/page-header.mjs +22 -0
  115. package/dist/ui/page-header.mjs.map +1 -0
  116. package/dist/ui/pointer.d.mts +14 -0
  117. package/dist/ui/pointer.mjs +51 -0
  118. package/dist/ui/pointer.mjs.map +1 -0
  119. package/dist/ui/portfolio.d.mts +31 -0
  120. package/dist/ui/portfolio.mjs +1 -0
  121. package/dist/ui/table-class.d.mts +2 -0
  122. package/dist/ui/table-class.mjs +1 -0
  123. package/dist/ui/table.d.mts +30 -0
  124. package/dist/ui/table.mjs +64 -0
  125. package/dist/ui/table.mjs.map +1 -0
  126. package/dist/ui/to-wavy-letters.d.mts +12 -0
  127. package/dist/ui/to-wavy-letters.mjs +9 -0
  128. package/dist/ui/to-wavy-letters.mjs.map +1 -0
  129. package/dist/ui/web-analytics.d.mts +18 -0
  130. package/dist/ui/web-analytics.mjs +19 -0
  131. package/dist/ui/web-analytics.mjs.map +1 -0
  132. package/dist/web-analytics-BM9LdncT.d.mts +4 -0
  133. package/dist/web-analytics-Bz6nyJmQ.mjs +6 -0
  134. package/dist/web-analytics-Bz6nyJmQ.mjs.map +1 -0
  135. package/dist/yohaku-protocol/sync.d.mts +2 -0
  136. package/dist/yohaku-protocol/sync.mjs +1 -0
  137. package/dist/yohaku-protocol.d.mts +2 -0
  138. package/dist/yohaku-protocol.mjs +1 -0
  139. package/package.json +131 -4
  140. package/skills/share-types-with-rust/SKILL.md +90 -0
  141. package/src/app/browser-test-fonts.conf +28 -0
  142. package/src/app/ui-styles.css +185 -0
  143. package/src/app/ui-theme.css +81 -0
  144. package/src/app/ui-view-transition.css +5 -0
  145. package/src/shared/lib/button-variants.ts +33 -0
  146. package/src/shared/lib/input-class.ts +2 -0
  147. package/src/shared/lib/native-select-class.ts +2 -0
  148. package/src/shared/lib/table-class.ts +35 -0
  149. package/src/shared/ui/badge.tsx +29 -0
  150. package/src/shared/ui/button.tsx +39 -0
  151. package/src/shared/ui/heading.tsx +38 -0
  152. package/src/shared/ui/next-page-trigger.tsx +34 -0
  153. package/src/shared/ui/page-footer.tsx +34 -0
  154. package/src/shared/ui/page-header.tsx +29 -0
  155. package/src/shared/ui/table/column-headings.tsx +30 -0
  156. package/src/shared/ui/table/index.ts +10 -0
  157. package/src/shared/ui/table/table-body.tsx +8 -0
  158. package/src/shared/ui/table/table-caption.tsx +8 -0
  159. package/src/shared/ui/table/table-cell.tsx +8 -0
  160. package/src/shared/ui/table/table-head.tsx +13 -0
  161. package/src/shared/ui/table/table-header.tsx +8 -0
  162. package/src/shared/ui/table/table-row.tsx +8 -0
  163. package/src/shared/ui/table/table.tsx +31 -0
@@ -0,0 +1,25 @@
1
+ import { f as serverPageHeaders, s as SERVER_RESPONSE_HEADERS } from "../headers-Cr6gAurg.mjs";
2
+ import { Effect, Option, Record, String, pipe } from "effect";
3
+ import { Headers, HttpEffect, HttpRouter, HttpServerResponse } from "effect/http";
4
+ // src/features/secure-http/model/security-headers.ts
5
+ const CONTENT_TYPE = "content-type";
6
+ const HTML = "text/html";
7
+ const declaredType = (body) => Option.fromNullishOr(body.contentType);
8
+ const contentTypeOf = (response) => pipe(declaredType(response.body), Option.orElse(() => Headers.get(response.headers, CONTENT_TYPE)));
9
+ /** @stability experimental */
10
+ const isHtml = (response) => pipe(contentTypeOf(response), Option.exists(String.startsWith(HTML)));
11
+ const policyOf = (page, response) => {
12
+ if (isHtml(response)) return page;
13
+ return SERVER_RESPONSE_HEADERS;
14
+ };
15
+ const withSecurityHeaders = (page) => (response) => HttpServerResponse.setHeaders(response, pipe(policyOf(page, response), Record.filter((_value, name) => !Headers.has(response.headers, name))));
16
+ /** @stability experimental */
17
+ const securityHeadersFor = (sources) => {
18
+ const secured = withSecurityHeaders(serverPageHeaders(sources));
19
+ return HttpRouter.middleware((effect) => HttpEffect.withPreResponseHandler(effect, (_request, response) => response.pipe(secured, Effect.succeed)), { global: true });
20
+ };
21
+ /** @stability experimental */
22
+ const securityHeaders = securityHeadersFor({});
23
+ export { isHtml, securityHeaders, securityHeadersFor };
24
+
25
+ //# sourceMappingURL=http.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.mjs","names":["Str","Rec"],"sources":["../../src/features/secure-http/model/security-headers.ts"],"sourcesContent":["import { Effect, Option, Record as Rec, String as Str, pipe } from \"effect\";\nimport type { Layer } from \"effect\";\nimport { Headers, HttpEffect, HttpRouter, HttpServerResponse } from \"effect/http\";\nimport type { HttpBody } from \"effect/http\";\n\nimport { SERVER_RESPONSE_HEADERS, serverPageHeaders } from \"#/entities/policy/index.ts\";\nimport type { PageSources } from \"#/entities/policy/index.ts\";\n\nconst CONTENT_TYPE = \"content-type\";\n\nconst HTML = \"text/html\";\n\nconst declaredType = (body: HttpBody.HttpBody.Proto): Option.Option<string> =>\n Option.fromNullishOr(body.contentType);\n\nconst contentTypeOf = (response: HttpServerResponse.HttpServerResponse): Option.Option<string> =>\n pipe(\n declaredType(response.body),\n Option.orElse(() => Headers.get(response.headers, CONTENT_TYPE)),\n );\n\n/** @stability experimental */\nexport const isHtml = (response: HttpServerResponse.HttpServerResponse): boolean =>\n pipe(contentTypeOf(response), Option.exists(Str.startsWith(HTML)));\n\nconst policyOf = (\n page: Readonly<Record<string, string>>,\n response: HttpServerResponse.HttpServerResponse,\n): Readonly<Record<string, string>> => {\n if (isHtml(response)) {\n return page;\n }\n return SERVER_RESPONSE_HEADERS;\n};\n\nconst withSecurityHeaders =\n (page: Readonly<Record<string, string>>) =>\n (response: HttpServerResponse.HttpServerResponse): HttpServerResponse.HttpServerResponse =>\n HttpServerResponse.setHeaders(\n response,\n pipe(\n policyOf(page, response),\n Rec.filter((_value, name) => !Headers.has(response.headers, name)),\n ),\n );\n\n/** @stability experimental */\nexport const securityHeadersFor = (\n sources: PageSources,\n): Layer.Layer<never, never, HttpRouter.HttpRouter> => {\n const secured = withSecurityHeaders(serverPageHeaders(sources));\n return HttpRouter.middleware(\n (effect) =>\n HttpEffect.withPreResponseHandler(effect, (_request, response) =>\n response.pipe(secured, Effect.succeed),\n ),\n { global: true },\n );\n};\n\n/** @stability experimental */\nexport const securityHeaders = securityHeadersFor({});\n"],"mappings":";;;;AAQA,MAAM,eAAe;AAErB,MAAM,OAAO;AAEb,MAAM,gBAAgB,SACpB,OAAO,cAAc,KAAK,WAAW;AAEvC,MAAM,iBAAiB,aACrB,KACE,aAAa,SAAS,IAAI,GAC1B,OAAO,aAAa,QAAQ,IAAI,SAAS,SAAS,YAAY,CAAC,CACjE;;AAGF,MAAa,UAAU,aACrB,KAAK,cAAc,QAAQ,GAAG,OAAO,OAAOA,OAAI,WAAW,IAAI,CAAC,CAAC;AAEnE,MAAM,YACJ,MACA,aACqC;CACrC,IAAI,OAAO,QAAQ,GACjB,OAAO;CAET,OAAO;AACT;AAEA,MAAM,uBACH,UACA,aACC,mBAAmB,WACjB,UACA,KACE,SAAS,MAAM,QAAQ,GACvBC,OAAI,QAAQ,QAAQ,SAAS,CAAC,QAAQ,IAAI,SAAS,SAAS,IAAI,CAAC,CACnE,CACF;;AAGJ,MAAa,sBACX,YACqD;CACrD,MAAM,UAAU,oBAAoB,kBAAkB,OAAO,CAAC;CAC9D,OAAO,WAAW,YACf,WACC,WAAW,uBAAuB,SAAS,UAAU,aACnD,SAAS,KAAK,SAAS,OAAO,OAAO,CACvC,GACF,EAAE,QAAQ,KAAK,CACjB;AACF;;AAGA,MAAa,kBAAkB,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const writesFromAnotherSite: (request: Request) => boolean;
2
+ export declare const writesWithoutJson: (request: Request) => boolean;
3
+ //# sourceMappingURL=request.d.mts.map
@@ -0,0 +1,15 @@
1
+ import { Option, pipe } from "effect";
2
+ // src/features/guard-writes/model/write-guard.ts
3
+ const READS = /* @__PURE__ */ new Set([
4
+ "GET",
5
+ "HEAD",
6
+ "OPTIONS"
7
+ ]);
8
+ const JSON_BODY = /^application\/json[\t ]*(?:;|$)/iu;
9
+ const headerOf = (request, name) => Option.fromNullishOr(request.headers.get(name));
10
+ const writes = (request) => !READS.has(request.method);
11
+ const writesFromAnotherSite = (request) => writes(request) && pipe(headerOf(request, "origin"), Option.exists((origin) => origin !== new URL(request.url).origin));
12
+ const writesWithoutJson = (request) => writes(request) && !pipe(headerOf(request, "content-type"), Option.exists((type) => JSON_BODY.test(type)));
13
+ export { writesFromAnotherSite, writesWithoutJson };
14
+
15
+ //# sourceMappingURL=request.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.mjs","names":[],"sources":["../../src/features/guard-writes/model/write-guard.ts"],"sourcesContent":["import { Option, pipe } from \"effect\";\n\nconst READS: ReadonlySet<string> = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\nconst JSON_BODY = /^application\\/json[\\t ]*(?:;|$)/iu;\n\nconst headerOf = (request: Request, name: string): Option.Option<string> =>\n Option.fromNullishOr(request.headers.get(name));\n\nconst writes = (request: Request): boolean => !READS.has(request.method);\n\nexport const writesFromAnotherSite = (request: Request): boolean =>\n writes(request) &&\n pipe(\n headerOf(request, \"origin\"),\n Option.exists((origin) => origin !== new URL(request.url).origin),\n );\n\nexport const writesWithoutJson = (request: Request): boolean =>\n writes(request) &&\n !pipe(\n headerOf(request, \"content-type\"),\n Option.exists((type) => JSON_BODY.test(type)),\n );\n"],"mappings":";;AAEA,MAAM,wBAA6B,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAS,CAAC;AACrE,MAAM,YAAY;AAElB,MAAM,YAAY,SAAkB,SAClC,OAAO,cAAc,QAAQ,QAAQ,IAAI,IAAI,CAAC;AAEhD,MAAM,UAAU,YAA8B,CAAC,MAAM,IAAI,QAAQ,MAAM;AAEvE,MAAa,yBAAyB,YACpC,OAAO,OAAO,KACd,KACE,SAAS,SAAS,QAAQ,GAC1B,OAAO,QAAQ,WAAW,WAAW,IAAI,IAAI,QAAQ,GAAG,CAAC,CAAC,MAAM,CAClE;AAEF,MAAa,qBAAqB,YAChC,OAAO,OAAO,KACd,CAAC,KACC,SAAS,SAAS,cAAc,GAChC,OAAO,QAAQ,SAAS,UAAU,KAAK,IAAI,CAAC,CAC9C"}
@@ -0,0 +1,2 @@
1
+ export declare const securedResponse: (serve: () => PromiseLike<Response> | Response) => Promise<Response>;
2
+ //# sourceMappingURL=response.d.mts.map
@@ -0,0 +1,17 @@
1
+ import { s as SERVER_RESPONSE_HEADERS } from "../headers-Cr6gAurg.mjs";
2
+ import { Array, Effect, Option, Record, pipe } from "effect";
3
+ // src/features/secure-response/model/response.ts
4
+ const addMissingHeaders = (response) => {
5
+ const missing = pipe(Record.toEntries(SERVER_RESPONSE_HEADERS), Array.filter(([name]) => !response.headers.has(name)));
6
+ for (const [name, value] of missing) response.headers.set(name, value);
7
+ return response;
8
+ };
9
+ const addInPlace = Option.liftThrowable(addMissingHeaders);
10
+ const withSecurityHeaders = (response) => pipe(addInPlace(response), Option.getOrElse(() => addMissingHeaders(new Response(response.body, response))));
11
+ const securedResponse = (serve) => {
12
+ const pending = Promise.resolve(serve());
13
+ return Effect.runPromise(Effect.promise(() => pending).pipe(Effect.map(withSecurityHeaders)));
14
+ };
15
+ export { securedResponse };
16
+
17
+ //# sourceMappingURL=response.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.mjs","names":["Rec","Arr"],"sources":["../../src/features/secure-response/model/response.ts"],"sourcesContent":["import { Array as Arr, Effect, Option, Record as Rec, pipe } from \"effect\";\n\nimport { SERVER_RESPONSE_HEADERS } from \"#/entities/policy/index.ts\";\n\nconst addMissingHeaders = (response: Response): Response => {\n const missing = pipe(\n Rec.toEntries(SERVER_RESPONSE_HEADERS),\n Arr.filter(([name]) => !response.headers.has(name)),\n );\n for (const [name, value] of missing) {\n response.headers.set(name, value);\n }\n return response;\n};\n\nconst addInPlace = Option.liftThrowable(addMissingHeaders);\n\nconst withSecurityHeaders = (response: Response): Response =>\n pipe(\n addInPlace(response),\n Option.getOrElse(() => addMissingHeaders(new Response(response.body, response))),\n );\n\nexport const securedResponse = (\n serve: () => PromiseLike<Response> | Response,\n): Promise<Response> => {\n const pending = Promise.resolve(serve());\n return Effect.runPromise(Effect.promise(() => pending).pipe(Effect.map(withSecurityHeaders)));\n};\n"],"mappings":";;;AAIA,MAAM,qBAAqB,aAAiC;CAC1D,MAAM,UAAU,KACdA,OAAI,UAAU,uBAAuB,GACrCC,MAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,QAAQ,IAAI,IAAI,CAAC,CACpD;CACA,KAAK,MAAM,CAAC,MAAM,UAAU,SAC1B,SAAS,QAAQ,IAAI,MAAM,KAAK;CAElC,OAAO;AACT;AAEA,MAAM,aAAa,OAAO,cAAc,iBAAiB;AAEzD,MAAM,uBAAuB,aAC3B,KACE,WAAW,QAAQ,GACnB,OAAO,gBAAgB,kBAAkB,IAAI,SAAS,SAAS,MAAM,QAAQ,CAAC,CAAC,CACjF;AAEF,MAAa,mBACX,UACsB;CACtB,MAAM,UAAU,QAAQ,QAAQ,MAAM,CAAC;CACvC,OAAO,OAAO,WAAW,OAAO,cAAc,OAAO,CAAC,CAAC,KAAK,OAAO,IAAI,mBAAmB,CAAC,CAAC;AAC9F"}
@@ -0,0 +1,2 @@
1
+ import { a as headersFileFor, c as pageHashes, i as headerLines, l as pageSlug, n as PageHashes, o as inlineScriptHashes, r as PageHeaders, s as inlineStyleHashes, t as staticPageHeaders, u as sourceHash } from "../index-ChbPLmqu.mjs";
2
+ export { type PageHashes, type PageHeaders, headerLines, headersFileFor, inlineScriptHashes, inlineStyleHashes, pageHashes, pageSlug, sourceHash, staticPageHeaders };
@@ -0,0 +1 @@
1
+ export { n as headerLines, r as headersFileFor, i as inlineScriptHashes, a as inlineStyleHashes, o as pageHashes, s as pageSlug, c as sourceHash, t as staticPageHeaders } from "../static-page-headers-_B0WGkew.mjs";
@@ -0,0 +1,2 @@
1
+ import { t as staticPageHeaders } from "../index-ChbPLmqu.mjs";
2
+ export { staticPageHeaders };
@@ -0,0 +1 @@
1
+ export { t as staticPageHeaders } from "../static-page-headers-_B0WGkew.mjs";
@@ -0,0 +1,3 @@
1
+ import { a as SECURITY_HEADERS_CREDENTIALLESS, c as SERVER_RESPONSE_HEADERS, d as assetHeaders, f as contentSecurityPolicy, i as SECURITY_HEADERS, l as SPECULATION_RULES_FILE, n as EMBEDDED_VIDEO_SOURCES, o as SECURITY_HEADERS_EMBEDDING, p as serverPageHeaders, r as PageSources, s as SERVER_PAGE_HEADERS, t as ASSET_CACHE_CONTROL, u as STATIC_PAGE_HEADERS } from "./headers-BK-aW9Kw.mjs";
2
+ import { n as WEB_ANALYTICS_SCRIPT_ORIGIN, t as WEB_ANALYTICS_REPORT_ORIGIN } from "./web-analytics-BM9LdncT.mjs";
3
+ export { ASSET_CACHE_CONTROL, EMBEDDED_VIDEO_SOURCES, type PageSources, SECURITY_HEADERS, SECURITY_HEADERS_CREDENTIALLESS, SECURITY_HEADERS_EMBEDDING, SERVER_PAGE_HEADERS, SERVER_RESPONSE_HEADERS, SPECULATION_RULES_FILE, STATIC_PAGE_HEADERS, WEB_ANALYTICS_REPORT_ORIGIN, WEB_ANALYTICS_SCRIPT_ORIGIN, assetHeaders, contentSecurityPolicy, serverPageHeaders };
@@ -0,0 +1,3 @@
1
+ import { a as SECURITY_HEADERS_EMBEDDING, c as SPECULATION_RULES_FILE, d as contentSecurityPolicy, f as serverPageHeaders, i as SECURITY_HEADERS_CREDENTIALLESS, l as STATIC_PAGE_HEADERS, n as EMBEDDED_VIDEO_SOURCES, o as SERVER_PAGE_HEADERS, r as SECURITY_HEADERS, s as SERVER_RESPONSE_HEADERS, t as ASSET_CACHE_CONTROL, u as assetHeaders } from "./headers-Cr6gAurg.mjs";
2
+ import { n as WEB_ANALYTICS_SCRIPT_ORIGIN, t as WEB_ANALYTICS_REPORT_ORIGIN } from "./web-analytics-Bz6nyJmQ.mjs";
3
+ export { ASSET_CACHE_CONTROL, EMBEDDED_VIDEO_SOURCES, SECURITY_HEADERS, SECURITY_HEADERS_CREDENTIALLESS, SECURITY_HEADERS_EMBEDDING, SERVER_PAGE_HEADERS, SERVER_RESPONSE_HEADERS, SPECULATION_RULES_FILE, STATIC_PAGE_HEADERS, WEB_ANALYTICS_REPORT_ORIGIN, WEB_ANALYTICS_SCRIPT_ORIGIN, assetHeaders, contentSecurityPolicy, serverPageHeaders };
@@ -0,0 +1,20 @@
1
+ import { Duration, Effect, Match, Option, Schedule, Schema } from "effect";
2
+ // src/entities/endpoint/model/endpoint.ts
3
+ const ENDPOINT_FILE = "endpoint.json";
4
+ const HOST = "127.0.0.1";
5
+ const TOKEN_PARAMETER = "token";
6
+ const READ_INTERVAL = Duration.fromInputUnsafe("1 second");
7
+ const ServerEndpoint = Schema.Struct({
8
+ port: Schema.Int,
9
+ token: Schema.String
10
+ }).annotate({ identifier: "ServerEndpoint" });
11
+ const ServerEndpointJson = Schema.fromJsonString(ServerEndpoint);
12
+ const decodeEndpoint = Schema.decodeUnknownEffect(ServerEndpointJson);
13
+ const urlOf = ({ port, token }) => `ws://${HOST}:${port.toString()}/?${TOKEN_PARAMETER}=${encodeURIComponent(token)}`;
14
+ const awaitEndpoint = (read) => read.pipe(Effect.flatMap(decodeEndpoint), Effect.map(urlOf), Effect.retry({ schedule: Schedule.spaced(READ_INTERVAL) }), Effect.orDie);
15
+ // src/shared/lib/socket-port.ts
16
+ /** @internal */
17
+ const portOf = Match.type().pipe(Match.tag("UnixPathAddress", () => Option.none()), Match.orElse(({ port }) => Option.some(port)));
18
+ export { TOKEN_PARAMETER as a, ServerEndpoint as i, ENDPOINT_FILE as n, awaitEndpoint as o, HOST as r, portOf as t };
19
+
20
+ //# sourceMappingURL=socket-port-CTg-qfiP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket-port-CTg-qfiP.mjs","names":[],"sources":["../src/entities/endpoint/model/endpoint.ts","../src/shared/lib/socket-port.ts"],"sourcesContent":["import { Duration, Effect, Schedule, Schema } from \"effect\";\n\nexport const ENDPOINT_FILE = \"endpoint.json\";\nexport const HOST = \"127.0.0.1\";\nexport const TOKEN_PARAMETER = \"token\";\nconst READ_INTERVAL = Duration.fromInputUnsafe(\"1 second\");\n\nexport const ServerEndpoint = Schema.Struct({ port: Schema.Int, token: Schema.String }).annotate({\n identifier: \"ServerEndpoint\",\n});\n\nconst ServerEndpointJson = Schema.fromJsonString(ServerEndpoint);\n\nconst decodeEndpoint = Schema.decodeUnknownEffect(ServerEndpointJson);\n\nconst urlOf = ({ port, token }: typeof ServerEndpoint.Type): string =>\n `ws://${HOST}:${port.toString()}/?${TOKEN_PARAMETER}=${encodeURIComponent(token)}`;\n\nexport const awaitEndpoint = <Failure>(\n read: Effect.Effect<string, Failure>,\n): Effect.Effect<string> =>\n read.pipe(\n Effect.flatMap(decodeEndpoint),\n Effect.map(urlOf),\n Effect.retry({ schedule: Schedule.spaced(READ_INTERVAL) }),\n Effect.orDie,\n );\n","import { Match, Option } from \"effect\";\nimport type { NetAddress } from \"effect/net\";\n\n/** @internal */\nexport const portOf = Match.type<NetAddress.SocketAddress>().pipe(\n Match.tag(\"UnixPathAddress\", () => Option.none<number>()),\n Match.orElse(({ port }) => Option.some(port)),\n);\n"],"mappings":";;AAEA,MAAa,gBAAgB;AAC7B,MAAa,OAAO;AACpB,MAAa,kBAAkB;AAC/B,MAAM,gBAAgB,SAAS,gBAAgB,UAAU;AAEzD,MAAa,iBAAiB,OAAO,OAAO;CAAE,MAAM,OAAO;CAAK,OAAO,OAAO;AAAO,CAAC,CAAC,CAAC,SAAS,EAC/F,YAAY,iBACd,CAAC;AAED,MAAM,qBAAqB,OAAO,eAAe,cAAc;AAE/D,MAAM,iBAAiB,OAAO,oBAAoB,kBAAkB;AAEpE,MAAM,SAAS,EAAE,MAAM,YACrB,QAAQ,KAAK,GAAG,KAAK,SAAS,EAAE,IAAI,gBAAgB,GAAG,mBAAmB,KAAK;AAEjF,MAAa,iBACX,SAEA,KAAK,KACH,OAAO,QAAQ,cAAc,GAC7B,OAAO,IAAI,KAAK,GAChB,OAAO,MAAM,EAAE,UAAU,SAAS,OAAO,aAAa,EAAE,CAAC,GACzD,OAAO,KACT;;;ACtBF,MAAa,SAAS,MAAM,KAA+B,CAAC,CAAC,KAC3D,MAAM,IAAI,yBAAyB,OAAO,KAAa,CAAC,GACxD,MAAM,QAAQ,EAAE,WAAW,OAAO,KAAK,IAAI,CAAC,CAC9C"}
@@ -0,0 +1,133 @@
1
+ import { d as contentSecurityPolicy, i as SECURITY_HEADERS_CREDENTIALLESS, r as SECURITY_HEADERS, t as ASSET_CACHE_CONTROL } from "./headers-Cr6gAurg.mjs";
2
+ import { Array, Effect, Option, Record, String, pipe } from "effect";
3
+ import { Base64 } from "effect/encoding";
4
+ // src/features/write-static-headers/model/static.ts
5
+ const encoder = new TextEncoder();
6
+ const INDEX_PAGE = /(?<=^|\/)index\.html$/u;
7
+ const HTML_EXTENSION = /\.html$/u;
8
+ const INLINE_SCRIPT = /<script(?<attributes>[^>]*)>(?<body>[\s\S]*?)<\/script>/gu;
9
+ const INLINE_STYLE = /<style(?<attributes>[^>]*)>(?<body>[\s\S]*?)<\/style>/gu;
10
+ const EXTERNAL = /\ssrc=/u;
11
+ const SCRIPT_TYPE = /\stype=["']?(?<type>[^"'\s>]+)/u;
12
+ const EXECUTED_TYPES = /* @__PURE__ */ new Set([
13
+ "module",
14
+ "importmap",
15
+ "text/javascript",
16
+ "application/javascript"
17
+ ]);
18
+ const MAX_RULES = 100;
19
+ const MAX_LINE_LENGTH = 2e3;
20
+ const PREVIEW_START = 0;
21
+ const PREVIEW_LENGTH = 60;
22
+ const headerLines = (headers) => pipe(Record.toEntries(headers), Array.map(([name, value]) => ` ${name}: ${value}`));
23
+ const detachLines = (headers) => pipe(Record.keys(headers), Array.map((name) => ` ! ${name}`));
24
+ const pageRule$1 = ({ path, headers }) => [
25
+ path,
26
+ ...detachLines(headers),
27
+ ...headerLines(headers)
28
+ ];
29
+ const immutableRule = (path) => [path, ` Cache-Control: ${ASSET_CACHE_CONTROL}`];
30
+ const renderHeadersFile = (rules) => {
31
+ if (rules.length > MAX_RULES) throw new RangeError(`_headers は ${MAX_RULES} 個までのルールしか持てない: ${rules.length}`);
32
+ const lines = Array.flatten(rules);
33
+ const overlong = Array.findFirst(lines, (line) => line.length > MAX_LINE_LENGTH);
34
+ if (Option.isSome(overlong)) {
35
+ const { value } = overlong;
36
+ const preview = String.slice(PREVIEW_START, PREVIEW_LENGTH)(value);
37
+ throw new RangeError(`_headers は 1 行 ${MAX_LINE_LENGTH} 文字までしか持てない(超えた行は Cloudflare に捨てられ、ヘッダーが付かない): ${preview}… ${value.length} 文字`);
38
+ }
39
+ return pipe(lines, Array.append(""), Array.join("\n"));
40
+ };
41
+ const headersFileFor = (immutablePaths) => ({ documentHeaders, pages }) => {
42
+ const rules = [
43
+ [
44
+ "/*",
45
+ ...headerLines(SECURITY_HEADERS),
46
+ ...headerLines(documentHeaders)
47
+ ],
48
+ ...pipe(pages, Array.map(pageRule$1)),
49
+ ...pipe(immutablePaths, Array.map(immutableRule))
50
+ ];
51
+ return renderHeadersFile(rules);
52
+ };
53
+ const sourceHash = (body) => Effect.promise(() => crypto.subtle.digest("SHA-256", encoder.encode(body))).pipe(Effect.map((digest) => `'sha256-${Base64.encode(new Uint8Array(digest))}'`));
54
+ const groupOf = (groups, name) => pipe(Option.fromNullishOr(groups), Option.flatMap(Record.get(name)), Option.getOrElse(() => ""));
55
+ const inlineElements = (pattern) => (html) => pipe(html, String.matchAll(pattern), Array.fromIterable, Array.map(({ groups }) => ({
56
+ attributes: groupOf(groups, "attributes"),
57
+ body: groupOf(groups, "body")
58
+ })));
59
+ const isExecutedScript = ({ attributes }) => !EXTERNAL.test(attributes) && pipe(String.match(SCRIPT_TYPE)(attributes), Option.match({
60
+ onNone: () => true,
61
+ onSome: ({ groups }) => EXECUTED_TYPES.has(String.toLowerCase(groupOf(groups, "type")))
62
+ }));
63
+ const inlineHashes = (pattern, keep) => (html) => pipe(inlineElements(pattern)(html), Array.filter(keep), Array.map(({ body }) => body), Array.dedupe, (items) => Effect.forEach(items, sourceHash, { concurrency: 1 }));
64
+ const inlineScriptHashes = inlineHashes(INLINE_SCRIPT, isExecutedScript);
65
+ const inlineStyleHashes = inlineHashes(INLINE_STYLE, () => true);
66
+ const pageSlug = (page) => pipe(page, String.replace(INDEX_PAGE, ""), String.replace(HTML_EXTENSION, ""));
67
+ const pageHashes = ({ entries, read }) => pipe(entries, Array.filter(String.endsWith(".html")), (items) => Effect.forEach(items, (page) => read(page).pipe(Effect.flatMap(inlineScriptHashes), Effect.map((hashes) => ({
68
+ page,
69
+ hashes
70
+ }))), { concurrency: 1 }));
71
+ // src/features/write-static-headers/api/static-page-headers.ts
72
+ const HEADERS_FILE = "_headers";
73
+ const PAGE_HTML = /^(?:(?<page>.+)\/)?index\.html$/u;
74
+ const scriptSourcesOf = (scriptSources) => (page) => pipe(Record.toEntries(scriptSources), Array.filter(([scope]) => page === scope || String.startsWith(`${scope}/`)(page)), Array.flatMap(([, sources]) => sources));
75
+ const homePattern = (home) => pipe([home], Array.filter(String.isNonEmpty), Array.prepend(""), Array.append(""), Array.join("/"));
76
+ const pagePattern = (home) => (page) => Option.match(Option.liftPredicate(page, (name) => name !== home), {
77
+ onNone: () => homePattern(home),
78
+ onSome: (name) => `/${name}/*`
79
+ });
80
+ const headersOf = (permissions) => (page) => Option.match(Record.get(permissions, page), {
81
+ onNone: () => SECURITY_HEADERS_CREDENTIALLESS,
82
+ onSome: (policy) => ({
83
+ ...SECURITY_HEADERS_CREDENTIALLESS,
84
+ "Permissions-Policy": policy
85
+ })
86
+ });
87
+ const pageRule = ({ home = "", ...options }) => ({ page, hashes }) => [
88
+ pagePattern(home)(page),
89
+ ...headerLines(headersOf(options.permissions)(page)),
90
+ ` Content-Security-Policy: ${contentSecurityPolicy({
91
+ script: scriptSourcesOf(options.scriptSources)(page),
92
+ style: hashes,
93
+ image: ["blob:"],
94
+ styleAttr: true
95
+ })}`
96
+ ];
97
+ const assetsRule = (assetsDir) => [
98
+ `/${assetsDir}/*`,
99
+ ...headerLines(SECURITY_HEADERS_CREDENTIALLESS),
100
+ ` Cache-Control: ${ASSET_CACHE_CONTROL}`
101
+ ];
102
+ const headersFile = (options, pages) => {
103
+ const rules = pipe(pages, Array.map(pageRule(options)));
104
+ return renderHeadersFile([...rules, assetsRule(options.assetsDir)]);
105
+ };
106
+ const pageOf = (fileName) => pipe(Option.fromNullishOr(PAGE_HTML.exec(fileName)), Option.map(({ groups }) => pipe(Option.fromNullishOr(groups), Option.flatMap(Record.get("page")), Option.flatMap(Option.fromNullishOr), Option.getOrElse(() => ""))));
107
+ const pageStyles = ({ fileName, html }) => pipe(pageOf(fileName), Option.map((page) => pipe(inlineStyleHashes(html), Effect.map((hashes) => ({
108
+ page,
109
+ hashes
110
+ })))));
111
+ const bundleHeaders = (options) => (files) => pipe(files, Array.flatMap((file) => Option.toArray(pageStyles(file))), (styles) => Effect.all(styles, { concurrency: 1 }), Effect.map((pages) => headersFile(options, pages)));
112
+ const staticPageHeaders = (options) => ({
113
+ name: "static-page-headers",
114
+ apply: "build",
115
+ transformIndexHtml: () => [...options.headTags],
116
+ generateBundle: {
117
+ order: "post",
118
+ handler(_options, bundle) {
119
+ const files = pipe(Record.values(bundle), Array.filter((output) => output.type === "asset"), Array.flatMap(({ fileName, source }) => pipe(Option.liftPredicate(source, String.isString), Option.map((html) => ({
120
+ fileName,
121
+ html
122
+ })), Option.toArray)));
123
+ return Effect.runPromise(bundleHeaders(options)(files).pipe(Effect.flatMap((source) => Effect.sync(() => this.emitFile({
124
+ type: "asset",
125
+ fileName: HEADERS_FILE,
126
+ source
127
+ }))), Effect.asVoid));
128
+ }
129
+ }
130
+ });
131
+ export { inlineStyleHashes as a, sourceHash as c, inlineScriptHashes as i, headerLines as n, pageHashes as o, headersFileFor as r, pageSlug as s, staticPageHeaders as t };
132
+
133
+ //# sourceMappingURL=static-page-headers-_B0WGkew.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-page-headers-_B0WGkew.mjs","names":["Rec","Arr","pageRule","Str","Rec","Arr","Str"],"sources":["../src/features/write-static-headers/model/static.ts","../src/features/write-static-headers/api/static-page-headers.ts"],"sourcesContent":["import { Array as Arr, Effect, Option, Record as Rec, String as Str, pipe } from \"effect\";\nimport { Base64 } from \"effect/encoding\";\n\nimport { ASSET_CACHE_CONTROL, SECURITY_HEADERS } from \"#/entities/policy/index.ts\";\n\nexport type PageHeaders = Readonly<{ path: string; headers: Readonly<Record<string, string>> }>;\n\nexport type PageHashes = Readonly<{ page: string; hashes: readonly string[] }>;\n\nconst encoder = new TextEncoder();\nconst INDEX_PAGE = /(?<=^|\\/)index\\.html$/u;\nconst HTML_EXTENSION = /\\.html$/u;\nconst INLINE_SCRIPT = /<script(?<attributes>[^>]*)>(?<body>[\\s\\S]*?)<\\/script>/gu;\nconst INLINE_STYLE = /<style(?<attributes>[^>]*)>(?<body>[\\s\\S]*?)<\\/style>/gu;\nconst EXTERNAL = /\\ssrc=/u;\nconst SCRIPT_TYPE = /\\stype=[\"']?(?<type>[^\"'\\s>]+)/u;\nconst EXECUTED_TYPES: ReadonlySet<string> = new Set([\n \"module\",\n \"importmap\",\n \"text/javascript\",\n \"application/javascript\",\n]);\nconst MAX_RULES = 100;\nconst MAX_LINE_LENGTH = 2000;\nconst PREVIEW_START = 0;\nconst PREVIEW_LENGTH = 60;\n\nexport const headerLines = (headers: Readonly<Record<string, string>>): readonly string[] =>\n pipe(\n Rec.toEntries(headers),\n Arr.map(([name, value]) => ` ${name}: ${value}`),\n );\n\nconst detachLines = (headers: Readonly<Record<string, string>>): readonly string[] =>\n pipe(\n Rec.keys(headers),\n Arr.map((name) => ` ! ${name}`),\n );\n\nconst pageRule = ({ path, headers }: PageHeaders): readonly string[] => [\n path,\n ...detachLines(headers),\n ...headerLines(headers),\n];\n\nconst immutableRule = (path: string): readonly string[] => [\n path,\n ` Cache-Control: ${ASSET_CACHE_CONTROL}`,\n];\n\nexport const renderHeadersFile = (rules: readonly (readonly string[])[]): string => {\n if (rules.length > MAX_RULES) {\n throw new RangeError(`_headers は ${MAX_RULES} 個までのルールしか持てない: ${rules.length}`);\n }\n const lines = Arr.flatten(rules);\n const overlong = Arr.findFirst(lines, (line) => line.length > MAX_LINE_LENGTH);\n if (Option.isSome(overlong)) {\n const { value } = overlong;\n const preview = Str.slice(PREVIEW_START, PREVIEW_LENGTH)(value);\n throw new RangeError(\n `_headers は 1 行 ${MAX_LINE_LENGTH} 文字までしか持てない(超えた行は Cloudflare に捨てられ、ヘッダーが付かない): ${preview}… ${value.length} 文字`,\n );\n }\n return pipe(lines, Arr.append(\"\"), Arr.join(\"\\n\"));\n};\n\nexport const headersFileFor =\n (immutablePaths: readonly string[]) =>\n ({\n documentHeaders,\n pages,\n }: Readonly<{\n documentHeaders: Readonly<Record<string, string>>;\n pages: readonly PageHeaders[];\n }>): string => {\n const rules = [\n [\"/*\", ...headerLines(SECURITY_HEADERS), ...headerLines(documentHeaders)],\n ...pipe(pages, Arr.map(pageRule)),\n ...pipe(immutablePaths, Arr.map(immutableRule)),\n ];\n return renderHeadersFile(rules);\n };\n\nexport const sourceHash = (body: string): Effect.Effect<string> =>\n Effect.promise(() => crypto.subtle.digest(\"SHA-256\", encoder.encode(body))).pipe(\n Effect.map((digest) => `'sha256-${Base64.encode(new Uint8Array(digest))}'`),\n );\n\ntype Inline = Readonly<{ attributes: string; body: string }>;\n\nconst groupOf = (groups: Readonly<Record<string, string>> | undefined, name: string): string =>\n pipe(\n Option.fromNullishOr(groups),\n Option.flatMap(Rec.get(name)),\n Option.getOrElse(() => \"\"),\n );\n\nconst inlineElements =\n (pattern: RegExp) =>\n (html: string): readonly Inline[] =>\n pipe(\n html,\n Str.matchAll(pattern),\n Arr.fromIterable,\n Arr.map(({ groups }) => ({\n attributes: groupOf(groups, \"attributes\"),\n body: groupOf(groups, \"body\"),\n })),\n );\n\nconst isExecutedScript = ({ attributes }: Inline): boolean =>\n !EXTERNAL.test(attributes) &&\n pipe(\n Str.match(SCRIPT_TYPE)(attributes),\n Option.match({\n onNone: () => true,\n onSome: ({ groups }) => EXECUTED_TYPES.has(Str.toLowerCase(groupOf(groups, \"type\"))),\n }),\n );\n\nconst inlineHashes =\n (pattern: RegExp, keep: (inline: Inline) => boolean) =>\n (html: string): Effect.Effect<readonly string[]> =>\n pipe(\n inlineElements(pattern)(html),\n Arr.filter(keep),\n Arr.map(({ body }) => body),\n Arr.dedupe,\n (items) => Effect.forEach(items, sourceHash, { concurrency: 1 }),\n );\n\nexport const inlineScriptHashes = inlineHashes(INLINE_SCRIPT, isExecutedScript);\n\nexport const inlineStyleHashes = inlineHashes(INLINE_STYLE, () => true);\n\nexport const pageSlug = (page: string): string =>\n pipe(page, Str.replace(INDEX_PAGE, \"\"), Str.replace(HTML_EXTENSION, \"\"));\n\nexport const pageHashes = <Failure, Requirements>({\n entries,\n read,\n}: Readonly<{\n entries: readonly string[];\n read: (page: string) => Effect.Effect<string, Failure, Requirements>;\n}>): Effect.Effect<readonly PageHashes[], Failure, Requirements> =>\n pipe(entries, Arr.filter(Str.endsWith(\".html\")), (items) =>\n Effect.forEach(\n items,\n (page) =>\n read(page).pipe(\n Effect.flatMap(inlineScriptHashes),\n Effect.map((hashes): PageHashes => ({ page, hashes })),\n ),\n { concurrency: 1 },\n ),\n );\n","import { Array as Arr, Effect, Option, Record as Rec, String as Str, pipe } from \"effect\";\nimport type { HtmlTagDescriptor, Plugin, Rolldown } from \"vite-plus\";\n\nimport {\n ASSET_CACHE_CONTROL,\n SECURITY_HEADERS_CREDENTIALLESS,\n contentSecurityPolicy,\n} from \"#/entities/policy/index.ts\";\nimport {\n headerLines,\n inlineStyleHashes,\n renderHeadersFile,\n} from \"#/features/write-static-headers/model/static.ts\";\n\nconst HEADERS_FILE = \"_headers\";\nconst PAGE_HTML = /^(?:(?<page>.+)\\/)?index\\.html$/u;\n\nexport type StaticPageHeadersOptions = Readonly<{\n assetsDir: string;\n home?: string;\n scriptSources: Readonly<Record<string, readonly string[]>>;\n permissions: Readonly<Record<string, string>>;\n headTags: readonly HtmlTagDescriptor[];\n}>;\n\ntype PageStyles = Readonly<{ page: string; hashes: readonly string[] }>;\n\nexport type HtmlFile = Readonly<{ fileName: string; html: string }>;\n\nconst scriptSourcesOf =\n (scriptSources: StaticPageHeadersOptions[\"scriptSources\"]) =>\n (page: string): readonly string[] =>\n pipe(\n Rec.toEntries(scriptSources),\n Arr.filter(([scope]) => page === scope || Str.startsWith(`${scope}/`)(page)),\n Arr.flatMap(([, sources]) => sources),\n );\n\nconst homePattern = (home: string): string =>\n pipe([home], Arr.filter(Str.isNonEmpty), Arr.prepend(\"\"), Arr.append(\"\"), Arr.join(\"/\"));\n\nconst pagePattern =\n (home: string) =>\n (page: string): string =>\n Option.match(\n Option.liftPredicate(page, (name) => name !== home),\n {\n onNone: () => homePattern(home),\n onSome: (name) => `/${name}/*`,\n },\n );\n\nconst headersOf =\n (permissions: StaticPageHeadersOptions[\"permissions\"]) =>\n (page: string): Readonly<Record<string, string>> =>\n Option.match(Rec.get(permissions, page), {\n onNone: () => SECURITY_HEADERS_CREDENTIALLESS,\n onSome: (policy) => ({ ...SECURITY_HEADERS_CREDENTIALLESS, \"Permissions-Policy\": policy }),\n });\n\nconst pageRule =\n ({ home = \"\", ...options }: StaticPageHeadersOptions) =>\n ({ page, hashes }: PageStyles): readonly string[] => [\n pagePattern(home)(page),\n ...headerLines(headersOf(options.permissions)(page)),\n ` Content-Security-Policy: ${contentSecurityPolicy({\n script: scriptSourcesOf(options.scriptSources)(page),\n style: hashes,\n image: [\"blob:\"],\n styleAttr: true,\n })}`,\n ];\n\nconst assetsRule = (assetsDir: string): readonly string[] => [\n `/${assetsDir}/*`,\n ...headerLines(SECURITY_HEADERS_CREDENTIALLESS),\n ` Cache-Control: ${ASSET_CACHE_CONTROL}`,\n];\n\nconst headersFile = (options: StaticPageHeadersOptions, pages: readonly PageStyles[]): string => {\n const rules = pipe(pages, Arr.map(pageRule(options)));\n return renderHeadersFile([...rules, assetsRule(options.assetsDir)]);\n};\n\nconst pageOf = (fileName: string): Option.Option<string> =>\n pipe(\n Option.fromNullishOr(PAGE_HTML.exec(fileName)),\n Option.map(({ groups }) =>\n pipe(\n Option.fromNullishOr(groups),\n Option.flatMap(Rec.get(\"page\")),\n Option.flatMap(Option.fromNullishOr),\n Option.getOrElse(() => \"\"),\n ),\n ),\n );\n\nconst pageStyles = ({ fileName, html }: HtmlFile): Option.Option<Effect.Effect<PageStyles>> =>\n pipe(\n pageOf(fileName),\n Option.map((page) =>\n pipe(\n inlineStyleHashes(html),\n Effect.map((hashes) => ({ page, hashes })),\n ),\n ),\n );\n\nexport const bundleHeaders =\n (options: StaticPageHeadersOptions) =>\n (files: readonly HtmlFile[]): Effect.Effect<string> =>\n pipe(\n files,\n Arr.flatMap((file) => Option.toArray(pageStyles(file))),\n (styles) => Effect.all(styles, { concurrency: 1 }),\n Effect.map((pages) => headersFile(options, pages)),\n );\n\nexport const staticPageHeaders = (options: StaticPageHeadersOptions): Plugin => ({\n name: \"static-page-headers\",\n apply: \"build\",\n transformIndexHtml: () => [...options.headTags],\n generateBundle: {\n order: \"post\",\n handler(_options, bundle): Promise<void> {\n const files = pipe(\n Rec.values(bundle),\n Arr.filter((output): output is Rolldown.OutputAsset => output.type === \"asset\"),\n Arr.flatMap(({ fileName, source }) =>\n pipe(\n Option.liftPredicate(source, Str.isString),\n Option.map((html) => ({ fileName, html })),\n Option.toArray,\n ),\n ),\n );\n return Effect.runPromise(\n bundleHeaders(options)(files).pipe(\n Effect.flatMap((source) =>\n Effect.sync(() => this.emitFile({ type: \"asset\", fileName: HEADERS_FILE, source })),\n ),\n Effect.asVoid,\n ),\n );\n },\n },\n});\n"],"mappings":";;;;AASA,MAAM,UAAU,IAAI,YAAY;AAChC,MAAM,aAAa;AACnB,MAAM,iBAAiB;AACvB,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,iCAAsC,IAAI,IAAI;CAClD;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,YAAY;AAClB,MAAM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WAAW,KAAK,SAAS;IAAE,MAAM;IAAS,UAAU;IAAc;GAAO,CAAC,CAAC,CACpF,GACA,OAAO,MACT,CACF;EACF;CACF;AACF"}
@@ -0,0 +1,121 @@
1
+ import { Schema } from "effect";
2
+ // src/entities/document/model/models.ts
3
+ const ManuscriptId = Schema.String;
4
+ const ParagraphId = Schema.String;
5
+ const SourceId = Schema.String;
6
+ const Count = Schema.Finite.check(Schema.isUint32());
7
+ const ParagraphKind = Schema.Literals([
8
+ "prose",
9
+ "memo",
10
+ "idea"
11
+ ]).annotate({ identifier: "ParagraphKind" });
12
+ const TitleAuthor = Schema.Literals(["writer", "ai"]).annotate({ identifier: "TitleAuthor" });
13
+ const Title = Schema.Struct({
14
+ text: Schema.String,
15
+ by: TitleAuthor
16
+ }).annotate({ identifier: "Title" });
17
+ const Manuscript = Schema.Struct({
18
+ id: ManuscriptId,
19
+ title: Schema.NullOr(Title),
20
+ excerpt: Schema.String,
21
+ updatedAt: Schema.Int
22
+ }).annotate({ identifier: "Manuscript" });
23
+ const Paragraph = Schema.Struct({
24
+ id: ParagraphId,
25
+ text: Schema.String
26
+ }).annotate({ identifier: "Paragraph" });
27
+ const Classified = Schema.Struct({
28
+ paragraphId: ParagraphId,
29
+ kind: ParagraphKind
30
+ }).annotate({ identifier: "Classified" });
31
+ const Remark = Schema.Struct({
32
+ paragraphId: ParagraphId,
33
+ from: Count,
34
+ to: Count,
35
+ rule: Schema.String,
36
+ message: Schema.String
37
+ }).annotate({ identifier: "Remark" });
38
+ const Annotations = Schema.Struct({
39
+ title: Schema.NullOr(Title),
40
+ kinds: Schema.Array(Classified),
41
+ remarks: Schema.Array(Remark)
42
+ }).annotate({ identifier: "Annotations" });
43
+ const FactKind = Schema.Literals([
44
+ "character",
45
+ "voice",
46
+ "event",
47
+ "knowledge",
48
+ "setting",
49
+ "idea"
50
+ ]).annotate({ identifier: "FactKind" });
51
+ const Fact = Schema.Struct({
52
+ kind: FactKind,
53
+ subject: Schema.String,
54
+ body: Schema.String,
55
+ when: Schema.NullOr(Schema.String)
56
+ }).annotate({ identifier: "Fact" });
57
+ const SourceOrigin = Schema.Literals([
58
+ "manuscript",
59
+ "mcp",
60
+ "agent"
61
+ ]).annotate({ identifier: "SourceOrigin" });
62
+ const Reaction = Schema.Literals([
63
+ "draft-accepted",
64
+ "draft-rewritten",
65
+ "draft-kept",
66
+ "remark-dismissed",
67
+ "remark-rewritten",
68
+ "question-deferred"
69
+ ]).annotate({ identifier: "Reaction" });
70
+ const Source = Schema.Struct({
71
+ id: SourceId,
72
+ label: Schema.String,
73
+ origin: SourceOrigin,
74
+ client: Schema.String,
75
+ facts: Count,
76
+ createdAt: Schema.Int
77
+ }).annotate({ identifier: "Source" });
78
+ // src/entities/document/model/sync.ts
79
+ const SYNC_HOST = "yohaku.masseater.dev";
80
+ const SYNC_ORIGIN = `https://${SYNC_HOST}`;
81
+ const CHANGES_PATH = "/api/changes";
82
+ const DOCUMENTS_PATH = "/api/documents";
83
+ const DocumentKind = Schema.Literals(["manuscript", "source"]).annotate({ identifier: "DocumentKind" });
84
+ const SyncDocument = Schema.Struct({
85
+ kind: DocumentKind,
86
+ id: Schema.String,
87
+ updatedAt: Schema.Int,
88
+ deleted: Schema.Boolean,
89
+ body: Schema.String
90
+ }).annotate({ identifier: "SyncDocument" });
91
+ const StoredDocument = Schema.Struct({
92
+ ...SyncDocument.fields,
93
+ revision: Schema.Int
94
+ }).annotate({ identifier: "StoredDocument" });
95
+ const Changes = Schema.Struct({
96
+ documents: Schema.Array(StoredDocument),
97
+ more: Schema.Boolean
98
+ }).annotate({ identifier: "Changes" });
99
+ const Pushed = Schema.Struct({ documents: Schema.Array(SyncDocument) }).annotate({ identifier: "Pushed" });
100
+ const SyncStatus = Schema.Struct({
101
+ connected: Schema.Boolean,
102
+ syncedAt: Schema.NullOr(Schema.Int),
103
+ pending: Count,
104
+ problem: Schema.NullOr(Schema.String)
105
+ }).annotate({ identifier: "SyncStatus" });
106
+ const ManuscriptBody = Schema.Struct({
107
+ title: Schema.NullOr(Title),
108
+ createdAt: Schema.Int,
109
+ paragraphs: Schema.Array(Paragraph)
110
+ }).annotate({ identifier: "ManuscriptBody" });
111
+ const SourceBody = Schema.Struct({
112
+ manuscriptId: Schema.NullOr(Schema.String),
113
+ label: Schema.String,
114
+ origin: SourceOrigin,
115
+ client: Schema.String,
116
+ createdAt: Schema.Int,
117
+ facts: Schema.Array(Fact)
118
+ }).annotate({ identifier: "SourceBody" });
119
+ export { Remark as C, Title as D, SourceOrigin as E, Reaction as S, SourceId as T, Manuscript as _, ManuscriptBody as a, ParagraphId as b, SYNC_ORIGIN as c, SyncDocument as d, SyncStatus as f, FactKind as g, Fact as h, DocumentKind as i, SourceBody as l, Classified as m, Changes as n, Pushed as o, Annotations as p, DOCUMENTS_PATH as r, SYNC_HOST as s, CHANGES_PATH as t, StoredDocument as u, ManuscriptId as v, Source as w, ParagraphKind as x, Paragraph as y };
120
+
121
+ //# sourceMappingURL=sync-BkyZGGDA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-BkyZGGDA.mjs","names":[],"sources":["../src/entities/document/model/models.ts","../src/entities/document/model/sync.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport const ManuscriptId = Schema.String;\n\nexport const ParagraphId = Schema.String;\n\nexport const SourceId = Schema.String;\n\nexport const Count = Schema.Finite.check(Schema.isUint32());\n\nexport const ParagraphKind = Schema.Literals([\"prose\", \"memo\", \"idea\"]).annotate({\n identifier: \"ParagraphKind\",\n});\n\nconst TitleAuthor = Schema.Literals([\"writer\", \"ai\"]).annotate({ identifier: \"TitleAuthor\" });\n\nexport const Title = Schema.Struct({ text: Schema.String, by: TitleAuthor }).annotate({\n identifier: \"Title\",\n});\n\nexport const Manuscript = Schema.Struct({\n id: ManuscriptId,\n title: Schema.NullOr(Title),\n excerpt: Schema.String,\n updatedAt: Schema.Int,\n}).annotate({ identifier: \"Manuscript\" });\n\nexport const Paragraph = Schema.Struct({ id: ParagraphId, text: Schema.String }).annotate({\n identifier: \"Paragraph\",\n});\n\nexport const Classified = Schema.Struct({ paragraphId: ParagraphId, kind: ParagraphKind }).annotate(\n {\n identifier: \"Classified\",\n },\n);\n\nexport const Remark = Schema.Struct({\n paragraphId: ParagraphId,\n from: Count,\n to: Count,\n rule: Schema.String,\n message: Schema.String,\n}).annotate({ identifier: \"Remark\" });\n\nexport const Annotations = Schema.Struct({\n title: Schema.NullOr(Title),\n kinds: Schema.Array(Classified),\n remarks: Schema.Array(Remark),\n}).annotate({ identifier: \"Annotations\" });\n\nexport const FactKind = Schema.Literals([\n \"character\",\n \"voice\",\n \"event\",\n \"knowledge\",\n \"setting\",\n \"idea\",\n]).annotate({ identifier: \"FactKind\" });\n\nexport const Fact = Schema.Struct({\n kind: FactKind,\n subject: Schema.String,\n body: Schema.String,\n when: Schema.NullOr(Schema.String),\n}).annotate({ identifier: \"Fact\" });\n\nexport const SourceOrigin = Schema.Literals([\"manuscript\", \"mcp\", \"agent\"]).annotate({\n identifier: \"SourceOrigin\",\n});\n\nexport const Reaction = Schema.Literals([\n \"draft-accepted\",\n \"draft-rewritten\",\n \"draft-kept\",\n \"remark-dismissed\",\n \"remark-rewritten\",\n \"question-deferred\",\n]).annotate({ identifier: \"Reaction\" });\n\nexport const Source = Schema.Struct({\n id: SourceId,\n label: Schema.String,\n origin: SourceOrigin,\n client: Schema.String,\n facts: Count,\n createdAt: Schema.Int,\n}).annotate({ identifier: \"Source\" });\n","import { Schema } from \"effect\";\n\nimport { Count, Fact, Paragraph, SourceOrigin, Title } from \"#/entities/document/model/models.ts\";\n\nexport const SYNC_HOST = \"yohaku.masseater.dev\";\nexport const SYNC_ORIGIN = `https://${SYNC_HOST}`;\nexport const CHANGES_PATH = \"/api/changes\";\nexport const DOCUMENTS_PATH = \"/api/documents\";\n\nexport const DocumentKind = Schema.Literals([\"manuscript\", \"source\"]).annotate({\n identifier: \"DocumentKind\",\n});\n\nexport const SyncDocument = Schema.Struct({\n kind: DocumentKind,\n id: Schema.String,\n updatedAt: Schema.Int,\n deleted: Schema.Boolean,\n body: Schema.String,\n}).annotate({ identifier: \"SyncDocument\" });\n\nexport const StoredDocument = Schema.Struct({\n ...SyncDocument.fields,\n revision: Schema.Int,\n}).annotate({ identifier: \"StoredDocument\" });\n\nexport const Changes = Schema.Struct({\n documents: Schema.Array(StoredDocument),\n more: Schema.Boolean,\n}).annotate({ identifier: \"Changes\" });\n\nexport const Pushed = Schema.Struct({ documents: Schema.Array(SyncDocument) }).annotate({\n identifier: \"Pushed\",\n});\n\nexport const SyncStatus = Schema.Struct({\n connected: Schema.Boolean,\n syncedAt: Schema.NullOr(Schema.Int),\n pending: Count,\n problem: Schema.NullOr(Schema.String),\n}).annotate({ identifier: \"SyncStatus\" });\n\nexport const ManuscriptBody = Schema.Struct({\n title: Schema.NullOr(Title),\n createdAt: Schema.Int,\n paragraphs: Schema.Array(Paragraph),\n}).annotate({ identifier: \"ManuscriptBody\" });\n\nexport const SourceBody = Schema.Struct({\n manuscriptId: Schema.NullOr(Schema.String),\n label: Schema.String,\n origin: SourceOrigin,\n client: Schema.String,\n createdAt: Schema.Int,\n facts: Schema.Array(Fact),\n}).annotate({ identifier: \"SourceBody\" });\n"],"mappings":";;AAEA,MAAa,eAAe,OAAO;AAEnC,MAAa,cAAc,OAAO;AAElC,MAAa,WAAW,OAAO;AAE/B,MAAa,QAAQ,OAAO,OAAO,MAAM,OAAO,SAAS,CAAC;AAE1D,MAAa,gBAAgB,OAAO,SAAS;CAAC;CAAS;CAAQ;AAAM,CAAC,CAAC,CAAC,SAAS,EAC/E,YAAY,gBACd,CAAC;AAED,MAAM,cAAc,OAAO,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,cAAc,CAAC;AAE5F,MAAa,QAAQ,OAAO,OAAO;CAAE,MAAM,OAAO;CAAQ,IAAI;AAAY,CAAC,CAAC,CAAC,SAAS,EACpF,YAAY,QACd,CAAC;AAED,MAAa,aAAa,OA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;CACtC,cAAc,OAAO,OAAO,OAAO,MAAM;CACzC,OAAO,OAAO;CACd,QAAQ;CACR,QAAQ,OAAO;CACf,WAAW,OAAO;CAClB,OAAO,OAAO,MAAM,IAAI;AAC1B,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,aAAa,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { VariantProps } from "class-variance-authority";
2
+ declare const TABLE_CONTAINER_CLASS = "relative w-full overflow-x-auto";
3
+ declare const TABLE_CLASS = "w-full caption-bottom text-sm";
4
+ declare const TABLE_HEADER_CLASS = "[&_tr]:border-b";
5
+ declare const TABLE_BODY_CLASS = "[&_tr:last-child]:border-0";
6
+ declare const TABLE_ROW_CLASS = "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted";
7
+ declare const TABLE_CELL_CLASS = "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5";
8
+ declare const TABLE_CAPTION_CLASS = "mt-4 text-sm text-muted-foreground";
9
+ declare const tableHeadVariants: (props?: ({
10
+ variant?: "compact" | "plain" | "ruled" | "tinted" | null | undefined;
11
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
12
+ type TableHeadVariant = NonNullable<VariantProps<typeof tableHeadVariants>["variant"]>;
13
+ export { TABLE_CONTAINER_CLASS as a, TableHeadVariant as c, TABLE_CLASS as i, tableHeadVariants as l, TABLE_CAPTION_CLASS as n, TABLE_HEADER_CLASS as o, TABLE_CELL_CLASS as r, TABLE_ROW_CLASS as s, TABLE_BODY_CLASS as t };
14
+ //# sourceMappingURL=table-class-BeiCXlFj.d.mts.map
@@ -0,0 +1,21 @@
1
+ import { cva } from "class-variance-authority";
2
+ // src/shared/lib/table-class.ts
3
+ const TABLE_CONTAINER_CLASS = "relative w-full overflow-x-auto";
4
+ const TABLE_CLASS = "w-full caption-bottom text-sm";
5
+ const TABLE_HEADER_CLASS = "[&_tr]:border-b";
6
+ const TABLE_BODY_CLASS = "[&_tr:last-child]:border-0";
7
+ const TABLE_ROW_CLASS = "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted";
8
+ const TABLE_CELL_CLASS = "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5";
9
+ const TABLE_CAPTION_CLASS = "mt-4 text-sm text-muted-foreground";
10
+ const tableHeadVariants = cva("text-left align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5", {
11
+ variants: { variant: {
12
+ plain: "h-10 px-2 font-medium text-foreground",
13
+ tinted: "h-10 bg-muted px-4 text-xs font-bold text-muted-foreground",
14
+ ruled: "border-b-2 border-input px-2 py-2 text-xs font-bold text-muted-foreground",
15
+ compact: "bg-muted px-3 py-2 font-medium"
16
+ } },
17
+ defaultVariants: { variant: "plain" }
18
+ });
19
+ export { TABLE_CONTAINER_CLASS as a, tableHeadVariants as c, TABLE_CLASS as i, TABLE_CAPTION_CLASS as n, TABLE_HEADER_CLASS as o, TABLE_CELL_CLASS as r, TABLE_ROW_CLASS as s, TABLE_BODY_CLASS as t };
20
+
21
+ //# sourceMappingURL=table-class-RQvT6MYy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-class-RQvT6MYy.mjs","names":[],"sources":["../src/shared/lib/table-class.ts"],"sourcesContent":["import { cva } from \"class-variance-authority\";\nimport type { VariantProps } from \"class-variance-authority\";\n\nexport const TABLE_CONTAINER_CLASS = \"relative w-full overflow-x-auto\";\n\nexport const TABLE_CLASS = \"w-full caption-bottom text-sm\";\n\nexport const TABLE_HEADER_CLASS = \"[&_tr]:border-b\";\n\nexport const TABLE_BODY_CLASS = \"[&_tr:last-child]:border-0\";\n\nexport const TABLE_ROW_CLASS =\n \"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted\";\n\nexport const TABLE_CELL_CLASS =\n \"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5\";\n\nexport const TABLE_CAPTION_CLASS = \"mt-4 text-sm text-muted-foreground\";\n\nexport const tableHeadVariants = cva(\n \"text-left align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5\",\n {\n variants: {\n variant: {\n plain: \"h-10 px-2 font-medium text-foreground\",\n tinted: \"h-10 bg-muted px-4 text-xs font-bold text-muted-foreground\",\n ruled: \"border-b-2 border-input px-2 py-2 text-xs font-bold text-muted-foreground\",\n compact: \"bg-muted px-3 py-2 font-medium\",\n },\n },\n defaultVariants: { variant: \"plain\" },\n },\n);\n\nexport type TableHeadVariant = NonNullable<VariantProps<typeof tableHeadVariants>[\"variant\"]>;\n"],"mappings":";;AAGA,MAAa,wBAAwB;AAErC,MAAa,cAAc;AAE3B,MAAa,qBAAqB;AAElC,MAAa,mBAAmB;AAEhC,MAAa,kBACX;AAEF,MAAa,mBACX;AAEF,MAAa,sBAAsB;AAEnC,MAAa,oBAAoB,IAC/B,8GACA;CACE,UAAU,EACR,SAAS;EACP,OAAO;EACP,QAAQ;EACR,OAAO;EACP,SAAS;CACX,EACF;CACA,iBAAiB,EAAE,SAAS,QAAQ;AACtC,CACF"}
@@ -0,0 +1,10 @@
1
+ export declare const backdropPalette: {
2
+ readonly base: "#ffffff";
3
+ readonly sky: "#dbeafe";
4
+ readonly pink: "#fbcfe8";
5
+ readonly amber: "#fef3c7";
6
+ readonly indigo: "#c7d2fe";
7
+ readonly mint: "#d1fae5";
8
+ };
9
+ export declare const BACKDROP_STYLE_HASH = "'sha256-bcX2M6hOeEgeI9Ttj3KtXWZuoRsKenyQAlXswSnLakA='";
10
+ //# sourceMappingURL=backdrop-palette.d.mts.map
@@ -0,0 +1,13 @@
1
+ // src/shared/lib/backdrop-palette.ts
2
+ const backdropPalette = {
3
+ base: "#ffffff",
4
+ sky: "#dbeafe",
5
+ pink: "#fbcfe8",
6
+ amber: "#fef3c7",
7
+ indigo: "#c7d2fe",
8
+ mint: "#d1fae5"
9
+ };
10
+ const BACKDROP_STYLE_HASH = "'sha256-bcX2M6hOeEgeI9Ttj3KtXWZuoRsKenyQAlXswSnLakA='";
11
+ export { BACKDROP_STYLE_HASH, backdropPalette };
12
+
13
+ //# sourceMappingURL=backdrop-palette.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backdrop-palette.mjs","names":[],"sources":["../../src/shared/lib/backdrop-palette.ts"],"sourcesContent":["export const backdropPalette = {\n base: \"#ffffff\",\n sky: \"#dbeafe\",\n pink: \"#fbcfe8\",\n amber: \"#fef3c7\",\n indigo: \"#c7d2fe\",\n mint: \"#d1fae5\",\n} as const;\n\nexport const BACKDROP_STYLE_HASH = \"'sha256-bcX2M6hOeEgeI9Ttj3KtXWZuoRsKenyQAlXswSnLakA='\";\n"],"mappings":";AAAA,MAAa,kBAAkB;CAC7B,MAAM;CACN,KAAK;CACL,MAAM;CACN,OAAO;CACP,QAAQ;CACR,MAAM;AACR;AAEA,MAAa,sBAAsB"}
@@ -0,0 +1,12 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+ type BadgeStyle<Variant extends string> = Readonly<{
3
+ base: string;
4
+ variants: Readonly<Record<Variant, string>>;
5
+ fallback: NoInfer<Variant>;
6
+ }>;
7
+ type BadgeProps<Variant extends string> = ComponentProps<"span"> & Readonly<{
8
+ variant?: Variant | null | undefined;
9
+ }>;
10
+ export declare const badgeOf: <Variant extends string>(style: BadgeStyle<Variant>) => ((props: BadgeProps<Variant>) => ReactNode);
11
+ export type { BadgeProps, BadgeStyle };
12
+ //# sourceMappingURL=badge.d.mts.map
@@ -0,0 +1,18 @@
1
+ import { t as cn } from "../cn-DtxpfSUK.mjs";
2
+ import { jsx } from "react/jsx-runtime";
3
+ // src/shared/ui/badge.tsx
4
+ const badgeOf = (style) => {
5
+ const Badge = ({ className, variant, ...props }) => {
6
+ const kind = variant ?? style.fallback;
7
+ return /* @__PURE__ */ jsx("span", {
8
+ "data-slot": "badge",
9
+ "data-variant": kind,
10
+ className: cn(style.base, style.variants[kind], className),
11
+ ...props
12
+ });
13
+ };
14
+ return Badge;
15
+ };
16
+ export { badgeOf };
17
+
18
+ //# sourceMappingURL=badge.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.mjs","names":[],"sources":["../../src/shared/ui/badge.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from \"react\";\n\nimport { cn } from \"#/shared/lib/cn.ts\";\n\nexport type BadgeStyle<Variant extends string> = Readonly<{\n base: string;\n variants: Readonly<Record<Variant, string>>;\n fallback: NoInfer<Variant>;\n}>;\n\nexport type BadgeProps<Variant extends string> = ComponentProps<\"span\"> &\n Readonly<{ variant?: Variant | null | undefined }>;\n\nexport const badgeOf = <Variant extends string>(\n style: BadgeStyle<Variant>,\n): ((props: BadgeProps<Variant>) => ReactNode) => {\n const Badge = ({ className, variant, ...props }: BadgeProps<Variant>): ReactNode => {\n const kind = variant ?? style.fallback;\n return (\n <span\n data-slot=\"badge\"\n data-variant={kind}\n className={cn(style.base, style.variants[kind], className)}\n {...props}\n />\n );\n };\n return Badge;\n};\n"],"mappings":";;;AAaA,MAAa,WACX,UACgD;CAChD,MAAM,SAAS,EAAE,WAAW,SAAS,GAAG,YAA4C;EAClF,MAAM,OAAO,WAAW,MAAM;EAC9B,OACE,oBAAC,QAAD;GACE,aAAU;GACV,gBAAc;GACd,WAAW,GAAG,MAAM,MAAM,MAAM,SAAS,OAAO,SAAS;GACzD,GAAI;EACL,CAAA;CAEL;CACA,OAAO;AACT"}
@@ -0,0 +1,3 @@
1
+ import { ManagedRuntime } from "effect";
2
+ export declare const browserRuntime: ManagedRuntime.ManagedRuntime<import("effect/observability/OtlpExporter").Flusher, never>;
3
+ //# sourceMappingURL=browser-runtime.d.mts.map
@@ -0,0 +1,18 @@
1
+ import { r as tracesUrl, t as portfolio } from "../portfolio-BQJtJtfK.mjs";
2
+ import { Duration, Effect, Layer, ManagedRuntime } from "effect";
3
+ import { FetchHttpClient } from "effect/http";
4
+ import { OtlpSerialization, OtlpTracer } from "effect/observability";
5
+ // src/shared/lib/browser-runtime.ts
6
+ const EXPORT_INTERVAL = Duration.fromInputUnsafe("2 seconds");
7
+ const MAX_BATCH = 64;
8
+ const keepAlive = Layer.succeed(FetchHttpClient.RequestInit, { keepalive: true });
9
+ const browserTelemetry = Layer.unwrap(Effect.sync(() => OtlpTracer.layer({
10
+ url: tracesUrl(globalThis.location.href),
11
+ resource: { serviceName: portfolio.traces.service },
12
+ exportInterval: EXPORT_INTERVAL,
13
+ maxBatchSize: MAX_BATCH
14
+ }))).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer), Layer.provide(keepAlive));
15
+ const browserRuntime = ManagedRuntime.make(browserTelemetry);
16
+ export { browserRuntime };
17
+
18
+ //# sourceMappingURL=browser-runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-runtime.mjs","names":[],"sources":["../../src/shared/lib/browser-runtime.ts"],"sourcesContent":["import { Duration, Effect, Layer, ManagedRuntime } from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { OtlpSerialization, OtlpTracer } from \"effect/observability\";\n\nimport { portfolio, tracesUrl } from \"#/shared/lib/portfolio.ts\";\n\nconst EXPORT_INTERVAL = Duration.fromInputUnsafe(\"2 seconds\");\nconst MAX_BATCH = 64;\n\nconst keepAlive = Layer.succeed(FetchHttpClient.RequestInit, { keepalive: true });\n\nconst tracer = Layer.unwrap(\n Effect.sync(() =>\n OtlpTracer.layer({\n url: tracesUrl(globalThis.location.href),\n resource: { serviceName: portfolio.traces.service },\n exportInterval: EXPORT_INTERVAL,\n maxBatchSize: MAX_BATCH,\n }),\n ),\n);\n\nconst browserTelemetry = tracer.pipe(\n Layer.provide(OtlpSerialization.layerJson),\n Layer.provide(FetchHttpClient.layer),\n Layer.provide(keepAlive),\n);\n\nexport const browserRuntime = ManagedRuntime.make(browserTelemetry);\n"],"mappings":";;;;;AAMA,MAAM,kBAAkB,SAAS,gBAAgB,WAAW;AAC5D,MAAM,YAAY;AAElB,MAAM,YAAY,MAAM,QAAQ,gBAAgB,aAAa,EAAE,WAAW,KAAK,CAAC;AAahF,MAAM,mBAXS,MAAM,OACnB,OAAO,WACL,WAAW,MAAM;CACf,KAAK,UAAU,WAAW,SAAS,IAAI;CACvC,UAAU,EAAE,aAAa,UAAU,OAAO,QAAQ;CAClD,gBAAgB;CAChB,cAAc;AAChB,CAAC,CACH,CAG4B,CAAC,CAAC,KAC9B,MAAM,QAAQ,kBAAkB,SAAS,GACzC,MAAM,QAAQ,gBAAgB,KAAK,GACnC,MAAM,QAAQ,SAAS,CACzB;AAEA,MAAa,iBAAiB,eAAe,KAAK,gBAAgB"}
@@ -0,0 +1,2 @@
1
+ import { t as buttonVariants } from "../button-variants-Bupz7GI3.mjs";
2
+ export { buttonVariants };
@@ -0,0 +1 @@
1
+ export { t as buttonVariants } from "../button-variants-BLMlMm-s.mjs";