@openpolicy/vite 0.0.12 → 0.0.15

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.
@@ -0,0 +1,39 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
2
+ //#region ../renderers/src/html.ts
3
+ var html_exports = /* @__PURE__ */ __exportAll({ renderHTML: () => renderHTML });
4
+ function escapeHtml(str) {
5
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
6
+ }
7
+ function renderInline(node) {
8
+ switch (node.type) {
9
+ case "text": return escapeHtml(node.value);
10
+ case "bold": return `<strong>${escapeHtml(node.value)}</strong>`;
11
+ case "italic": return `<em>${escapeHtml(node.value)}</em>`;
12
+ case "link": return `<a href="${escapeHtml(node.href)}">${escapeHtml(node.value)}</a>`;
13
+ }
14
+ }
15
+ function renderListItem(item) {
16
+ return `<li>${item.children.map((child) => child.type === "list" ? renderList(child) : renderInline(child)).join("")}</li>`;
17
+ }
18
+ function renderList(node) {
19
+ const tag = node.ordered ? "ol" : "ul";
20
+ return `<${tag}>${node.items.map(renderListItem).join("")}</${tag}>`;
21
+ }
22
+ function renderHTML(doc) {
23
+ return doc.sections.map((section) => {
24
+ return section.content.map((node) => {
25
+ switch (node.type) {
26
+ case "heading": {
27
+ const level = node.level ?? 2;
28
+ return `<h${level}>${escapeHtml(node.value)}</h${level}>`;
29
+ }
30
+ case "paragraph": return `<p>${node.children.map(renderInline).join("")}</p>`;
31
+ case "list": return renderList(node);
32
+ }
33
+ }).join("\n");
34
+ }).join("\n");
35
+ }
36
+ //#endregion
37
+ export { html_exports as t };
38
+
39
+ //# sourceMappingURL=html-D0xZQ7Fi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-D0xZQ7Fi.js","names":[],"sources":["../../renderers/src/html.ts"],"sourcesContent":["import type {\n\tDocument,\n\tInlineNode,\n\tListItemNode,\n\tListNode,\n} from \"@openpolicy/core\";\n\nfunction escapeHtml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\");\n}\n\nfunction renderInline(node: InlineNode): string {\n\tswitch (node.type) {\n\t\tcase \"text\":\n\t\t\treturn escapeHtml(node.value);\n\t\tcase \"bold\":\n\t\t\treturn `<strong>${escapeHtml(node.value)}</strong>`;\n\t\tcase \"italic\":\n\t\t\treturn `<em>${escapeHtml(node.value)}</em>`;\n\t\tcase \"link\":\n\t\t\treturn `<a href=\"${escapeHtml(node.href)}\">${escapeHtml(node.value)}</a>`;\n\t}\n}\n\nfunction renderListItem(item: ListItemNode): string {\n\tconst content = item.children\n\t\t.map((child) =>\n\t\t\tchild.type === \"list\"\n\t\t\t\t? renderList(child)\n\t\t\t\t: renderInline(child as InlineNode),\n\t\t)\n\t\t.join(\"\");\n\treturn `<li>${content}</li>`;\n}\n\nfunction renderList(node: ListNode): string {\n\tconst tag = node.ordered ? \"ol\" : \"ul\";\n\tconst items = node.items.map(renderListItem).join(\"\");\n\treturn `<${tag}>${items}</${tag}>`;\n}\n\nexport function renderHTML(doc: Document): string {\n\treturn doc.sections\n\t\t.map((section) => {\n\t\t\t// biome-ignore lint/suspicious/useIterableCallbackReturn: typed\n\t\t\tconst blocks = section.content.map((node) => {\n\t\t\t\tswitch (node.type) {\n\t\t\t\t\tcase \"heading\": {\n\t\t\t\t\t\tconst level = node.level ?? 2;\n\t\t\t\t\t\treturn `<h${level}>${escapeHtml(node.value)}</h${level}>`;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"paragraph\":\n\t\t\t\t\t\treturn `<p>${node.children.map(renderInline).join(\"\")}</p>`;\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\treturn renderList(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn blocks.join(\"\\n\");\n\t\t})\n\t\t.join(\"\\n\");\n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","Jurisdiction","CompanyConfig","name","legalName","address","contact","PrivacyPolicyConfig","Record","effectiveDate","company","dataCollected","legalBasis","retention","cookies","essential","analytics","marketing","thirdParties","purpose","userRights","jurisdictions","children","underAge","noticeUrl","DisputeResolutionMethod","TermsOfServiceConfig","acceptance","methods","eligibility","minimumAge","jurisdictionRestrictions","accounts","registrationRequired","userResponsibleForCredentials","companyCanTerminate","prohibitedUses","userContent","usersOwnContent","licenseGrantedToCompany","licenseDescription","companyCanRemoveContent","intellectualProperty","companyOwnsService","usersMayNotCopy","payments","hasPaidFeatures","refundPolicy","priceChangesNotice","availability","noUptimeGuarantee","maintenanceWindows","termination","userCanTerminate","effectOfTermination","disclaimers","serviceProvidedAsIs","noWarranties","limitationOfLiability","excludesIndirectDamages","liabilityCap","indemnification","userIndemnifiesCompany","scope","thirdPartyServices","disputeResolution","method","venue","classActionWaiver","governingLaw","jurisdiction","changesPolicy","noticeMethod","noticePeriodDays","privacyPolicyUrl","CookiePolicyConfig","functional","policyUrl","trackingTechnologies","consentMechanism","hasBanner","hasPreferencePanel","canWithdraw","PolicyInput","type","OpenPolicyConfig","Omit","privacy","terms","cookie","isOpenPolicyConfig","value","ValidationIssue","level","message","compileCookiePolicy","config","options","format","content","sections","compilePrivacyPolicy","compileTermsOfService","validatePrivacyPolicy","validateCookiePolicy","validateTermsOfService","expandOpenPolicyConfig","compilePolicy","input"],"sources":["../../core/dist/index.d.ts","../src/index.ts"],"mappings":";;;;KACKA,YAAAA;;;UCYY,iBAAA;EAChB,UAAA;EACA,OAAA,GAAU,YAAA;EACV,MAAA;AAAA;AAAA,iBAGqB,gBAAA,CACrB,UAAA,UACA,MAAA,UACA,OAAA,EAAS,YAAA,KACP,OAAA;AAAA,iBAoDa,UAAA,CAAW,OAAA,GAAS,iBAAA,GAAyB,MAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["OutputFormat","CompileOptions","formats","Jurisdiction","CompanyConfig","name","legalName","address","contact","PrivacyPolicyConfig","Record","effectiveDate","company","dataCollected","legalBasis","retention","cookies","essential","analytics","marketing","thirdParties","purpose","userRights","jurisdictions","children","underAge","noticeUrl","DisputeResolutionMethod","TermsOfServiceConfig","acceptance","methods","eligibility","minimumAge","jurisdictionRestrictions","accounts","registrationRequired","userResponsibleForCredentials","companyCanTerminate","prohibitedUses","userContent","usersOwnContent","licenseGrantedToCompany","licenseDescription","companyCanRemoveContent","intellectualProperty","companyOwnsService","usersMayNotCopy","payments","hasPaidFeatures","refundPolicy","priceChangesNotice","availability","noUptimeGuarantee","maintenanceWindows","termination","userCanTerminate","effectOfTermination","disclaimers","serviceProvidedAsIs","noWarranties","limitationOfLiability","excludesIndirectDamages","liabilityCap","indemnification","userIndemnifiesCompany","scope","thirdPartyServices","disputeResolution","method","venue","classActionWaiver","governingLaw","jurisdiction","changesPolicy","noticeMethod","noticePeriodDays","privacyPolicyUrl","CookiePolicyConfig","functional","policyUrl","trackingTechnologies","consentMechanism","hasBanner","hasPreferencePanel","canWithdraw","PolicyInput","type","OpenPolicyConfig","Omit","privacy","terms","cookie","isOpenPolicyConfig","value","ValidationIssue","level","message","NodeContext","reason","TextNode","context","BoldNode","ItalicNode","LinkNode","href","InlineNode","HeadingNode","ParagraphNode","ListItemNode","ListNode","ordered","items","ContentNode","DocumentSection","id","content","PolicyType","Document","policyType","sections","Node","heading","levelOrContext","text","bold","italic","link","p","li","ul","ol","section","compile","input","validatePrivacyPolicy","config","validateCookiePolicy","validateTermsOfService","expandOpenPolicyConfig"],"sources":["../../core/dist/index.d.ts","../src/index.ts"],"mappings":";;;;KACKA,YAAAA;;;UCYY,iBAAA;EAChB,UAAA;EACA,OAAA,GAAU,YAAA;EACV,MAAA;AAAA;AAAA,iBAGqB,gBAAA,CACrB,UAAA,UACA,MAAA,UACA,OAAA,EAAS,YAAA,KACP,OAAA;AAAA,iBAoDa,UAAA,CAAW,OAAA,GAAS,iBAAA,GAAyB,MAAA"}