@fayz-ai/core 0.7.0 → 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.
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var chunk56GH3WC2_cjs = require('./chunk-56GH3WC2.cjs');
4
4
  var chunkP5OJUH25_cjs = require('./chunk-P5OJUH25.cjs');
5
- var chunkVFW6KHBA_cjs = require('./chunk-VFW6KHBA.cjs');
5
+ var chunk54SRL7AJ_cjs = require('./chunk-54SRL7AJ.cjs');
6
6
  var chunk2NTHNWEH_cjs = require('./chunk-2NTHNWEH.cjs');
7
7
  var chunk5X2VX3RQ_cjs = require('./chunk-5X2VX3RQ.cjs');
8
8
  var chunkQR7U2URY_cjs = require('./chunk-QR7U2URY.cjs');
@@ -49,7 +49,7 @@ function createSafeDataProvider(makeSupabase, makeMock) {
49
49
  let resolved = null;
50
50
  const get = () => {
51
51
  if (!resolved) {
52
- resolved = chunkVFW6KHBA_cjs.getSupabaseClientOptional() ? makeSupabase() : makeMock();
52
+ resolved = chunk54SRL7AJ_cjs.getSupabaseClientOptional() ? makeSupabase() : makeMock();
53
53
  }
54
54
  return resolved;
55
55
  };
@@ -58,6 +58,129 @@ function createSafeDataProvider(makeSupabase, makeMock) {
58
58
  });
59
59
  }
60
60
 
61
+ // src/phone/index.ts
62
+ function flagOf(iso2) {
63
+ return iso2.toUpperCase().replace(/[^A-Z]/g, "").split("").map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
64
+ }
65
+ var RAW = [
66
+ { iso2: "BR", name: "Brasil", dial: "+55", mask: "(##) #####-####" },
67
+ { iso2: "US", name: "Estados Unidos", dial: "+1", mask: "(###) ###-####" },
68
+ { iso2: "PT", name: "Portugal", dial: "+351", mask: "### ### ###" },
69
+ { iso2: "AR", name: "Argentina", dial: "+54", mask: "(##) ####-####" },
70
+ { iso2: "ES", name: "Espanha", dial: "+34", mask: "### ### ###" },
71
+ { iso2: "MX", name: "M\xE9xico", dial: "+52", mask: "## #### ####" },
72
+ { iso2: "GB", name: "Reino Unido", dial: "+44", mask: "##### ######" },
73
+ { iso2: "FR", name: "Fran\xE7a", dial: "+33", mask: "# ## ## ## ##" },
74
+ { iso2: "DE", name: "Alemanha", dial: "+49", mask: "#### #######" },
75
+ { iso2: "IT", name: "It\xE1lia", dial: "+39", mask: "### #######" }
76
+ ];
77
+ var COUNTRIES = RAW.map((c) => ({ ...c, flag: flagOf(c.iso2) }));
78
+ var DEFAULT_COUNTRY = "BR";
79
+ var BY_ISO = new Map(COUNTRIES.map((c) => [c.iso2, c]));
80
+ function getCountry(iso2) {
81
+ return iso2 && BY_ISO.get(iso2.toUpperCase()) || BY_ISO.get(DEFAULT_COUNTRY);
82
+ }
83
+ function unmaskPhone(value) {
84
+ return (value || "").replace(/\D/g, "");
85
+ }
86
+ function maskPhone(value, mask) {
87
+ const digits = unmaskPhone(value);
88
+ let out = "";
89
+ let di = 0;
90
+ for (const ch of mask) {
91
+ if (di >= digits.length) break;
92
+ if (ch === "#") {
93
+ out += digits[di++];
94
+ } else {
95
+ out += ch;
96
+ }
97
+ }
98
+ return out;
99
+ }
100
+ function maskDigitCount(mask) {
101
+ let n = 0;
102
+ for (const ch of mask) if (ch === "#") n++;
103
+ return n;
104
+ }
105
+ var MANAGED = "data-fayz-seo";
106
+ function seoOrigin() {
107
+ return typeof window !== "undefined" ? window.location.origin : "";
108
+ }
109
+ function absoluteUrl(path) {
110
+ return `${seoOrigin()}${path.startsWith("/") ? path : `/${path}`}`;
111
+ }
112
+ function upsertMeta(attr, key, content) {
113
+ if (!content) return;
114
+ let el = document.head.querySelector(`meta[${attr}="${key}"]`);
115
+ if (!el) {
116
+ el = document.createElement("meta");
117
+ el.setAttribute(attr, key);
118
+ el.setAttribute(MANAGED, "");
119
+ document.head.appendChild(el);
120
+ }
121
+ el.setAttribute("content", content);
122
+ }
123
+ function upsertLink(rel, href) {
124
+ if (!href) return;
125
+ let el = document.head.querySelector(`link[rel="${rel}"]`);
126
+ if (!el) {
127
+ el = document.createElement("link");
128
+ el.setAttribute("rel", rel);
129
+ el.setAttribute(MANAGED, "");
130
+ document.head.appendChild(el);
131
+ }
132
+ el.setAttribute("href", href);
133
+ }
134
+ function clearManaged() {
135
+ document.head.querySelectorAll(`[${MANAGED}]`).forEach((el) => el.remove());
136
+ }
137
+ function applySeo(config) {
138
+ if (typeof document === "undefined") return;
139
+ clearManaged();
140
+ document.title = config.title;
141
+ upsertMeta("name", "description", config.description ?? "");
142
+ if (config.canonical) upsertLink("canonical", config.canonical);
143
+ upsertMeta("property", "og:title", config.title);
144
+ upsertMeta("property", "og:description", config.description ?? "");
145
+ upsertMeta("property", "og:type", config.type === "article" ? "article" : "website");
146
+ if (config.canonical) upsertMeta("property", "og:url", config.canonical);
147
+ if (config.image) upsertMeta("property", "og:image", config.image);
148
+ if (config.siteName) upsertMeta("property", "og:site_name", config.siteName);
149
+ upsertMeta("name", "twitter:card", config.image ? "summary_large_image" : "summary");
150
+ upsertMeta("name", "twitter:title", config.title);
151
+ upsertMeta("name", "twitter:description", config.description ?? "");
152
+ if (config.image) upsertMeta("name", "twitter:image", config.image);
153
+ for (const obj of config.jsonLd ?? []) {
154
+ const script = document.createElement("script");
155
+ script.type = "application/ld+json";
156
+ script.setAttribute(MANAGED, "");
157
+ script.text = JSON.stringify(obj);
158
+ document.head.appendChild(script);
159
+ }
160
+ }
161
+ function useSeo(config) {
162
+ const key = JSON.stringify(config);
163
+ React2.useEffect(() => {
164
+ applySeo(config);
165
+ return () => clearManaged();
166
+ }, [key]);
167
+ }
168
+ function breadcrumbJsonLd(items) {
169
+ return {
170
+ "@context": "https://schema.org",
171
+ "@type": "BreadcrumbList",
172
+ itemListElement: items.map((c, i) => ({
173
+ "@type": "ListItem",
174
+ position: i + 1,
175
+ name: c.name,
176
+ item: c.url
177
+ }))
178
+ };
179
+ }
180
+ function organizationJsonLd(name, extra) {
181
+ return { "@type": "Organization", name, ...extra };
182
+ }
183
+
61
184
  // src/lib/format.ts
62
185
  var CURRENCY_BY_LOCALE = {
63
186
  "pt-BR": "BRL",
@@ -668,61 +791,73 @@ Object.defineProperty(exports, "assertPluginManifestContract", {
668
791
  enumerable: true,
669
792
  get: function () { return chunkP5OJUH25_cjs.assertPluginManifestContract; }
670
793
  });
794
+ Object.defineProperty(exports, "FAYZ_CLOUD_PUBLISHABLE_KEY", {
795
+ enumerable: true,
796
+ get: function () { return chunk54SRL7AJ_cjs.FAYZ_CLOUD_PUBLISHABLE_KEY; }
797
+ });
798
+ Object.defineProperty(exports, "FAYZ_CLOUD_URL", {
799
+ enumerable: true,
800
+ get: function () { return chunk54SRL7AJ_cjs.FAYZ_CLOUD_URL; }
801
+ });
671
802
  Object.defineProperty(exports, "clearGlobalCache", {
672
803
  enumerable: true,
673
- get: function () { return chunkVFW6KHBA_cjs.clearGlobalCache; }
804
+ get: function () { return chunk54SRL7AJ_cjs.clearGlobalCache; }
674
805
  });
675
806
  Object.defineProperty(exports, "createArchetypeProvider", {
676
807
  enumerable: true,
677
- get: function () { return chunkVFW6KHBA_cjs.createArchetypeProvider; }
808
+ get: function () { return chunk54SRL7AJ_cjs.createArchetypeProvider; }
678
809
  });
679
810
  Object.defineProperty(exports, "createCacheStore", {
680
811
  enumerable: true,
681
- get: function () { return chunkVFW6KHBA_cjs.createCacheStore; }
812
+ get: function () { return chunk54SRL7AJ_cjs.createCacheStore; }
682
813
  });
683
814
  Object.defineProperty(exports, "createFayzApiProvider", {
684
815
  enumerable: true,
685
- get: function () { return chunkVFW6KHBA_cjs.createFayzApiProvider; }
816
+ get: function () { return chunk54SRL7AJ_cjs.createFayzApiProvider; }
686
817
  });
687
818
  Object.defineProperty(exports, "createMockProvider", {
688
819
  enumerable: true,
689
- get: function () { return chunkVFW6KHBA_cjs.createMockProvider; }
820
+ get: function () { return chunk54SRL7AJ_cjs.createMockProvider; }
690
821
  });
691
822
  Object.defineProperty(exports, "createSupabaseProvider", {
692
823
  enumerable: true,
693
- get: function () { return chunkVFW6KHBA_cjs.createSupabaseProvider; }
824
+ get: function () { return chunk54SRL7AJ_cjs.createSupabaseProvider; }
694
825
  });
695
826
  Object.defineProperty(exports, "getActiveTenantId", {
696
827
  enumerable: true,
697
- get: function () { return chunkVFW6KHBA_cjs.getActiveTenantId; }
828
+ get: function () { return chunk54SRL7AJ_cjs.getActiveTenantId; }
829
+ });
830
+ Object.defineProperty(exports, "getFayzCloudClient", {
831
+ enumerable: true,
832
+ get: function () { return chunk54SRL7AJ_cjs.getFayzCloudClient; }
698
833
  });
699
834
  Object.defineProperty(exports, "getSupabaseClientOptional", {
700
835
  enumerable: true,
701
- get: function () { return chunkVFW6KHBA_cjs.getSupabaseClientOptional; }
836
+ get: function () { return chunk54SRL7AJ_cjs.getSupabaseClientOptional; }
702
837
  });
703
838
  Object.defineProperty(exports, "globalCache", {
704
839
  enumerable: true,
705
- get: function () { return chunkVFW6KHBA_cjs.globalCache; }
840
+ get: function () { return chunk54SRL7AJ_cjs.globalCache; }
706
841
  });
707
842
  Object.defineProperty(exports, "resolveDataProvider", {
708
843
  enumerable: true,
709
- get: function () { return chunkVFW6KHBA_cjs.resolveDataProvider; }
844
+ get: function () { return chunk54SRL7AJ_cjs.resolveDataProvider; }
710
845
  });
711
846
  Object.defineProperty(exports, "setActiveTenantId", {
712
847
  enumerable: true,
713
- get: function () { return chunkVFW6KHBA_cjs.setActiveTenantId; }
848
+ get: function () { return chunk54SRL7AJ_cjs.setActiveTenantId; }
714
849
  });
715
850
  Object.defineProperty(exports, "setGlobalSupabaseClient", {
716
851
  enumerable: true,
717
- get: function () { return chunkVFW6KHBA_cjs.setGlobalSupabaseClient; }
852
+ get: function () { return chunk54SRL7AJ_cjs.setGlobalSupabaseClient; }
718
853
  });
719
854
  Object.defineProperty(exports, "stableKey", {
720
855
  enumerable: true,
721
- get: function () { return chunkVFW6KHBA_cjs.stableKey; }
856
+ get: function () { return chunk54SRL7AJ_cjs.stableKey; }
722
857
  });
723
858
  Object.defineProperty(exports, "withCache", {
724
859
  enumerable: true,
725
- get: function () { return chunkVFW6KHBA_cjs.withCache; }
860
+ get: function () { return chunk54SRL7AJ_cjs.withCache; }
726
861
  });
727
862
  Object.defineProperty(exports, "clearEntityRegistry", {
728
863
  enumerable: true,
@@ -946,9 +1081,14 @@ Object.defineProperty(exports, "createFayzRuntimeClient", {
946
1081
  });
947
1082
  exports.BlockChildren = BlockChildren;
948
1083
  exports.BlockRenderer = BlockRenderer;
1084
+ exports.COUNTRIES = COUNTRIES;
949
1085
  exports.CURRENT_MANIFEST_VERSION = CURRENT_MANIFEST_VERSION;
1086
+ exports.DEFAULT_COUNTRY = DEFAULT_COUNTRY;
950
1087
  exports.WidgetZone = WidgetZone;
1088
+ exports.absoluteUrl = absoluteUrl;
951
1089
  exports.appManifestSchema = app_manifest_schema_default;
1090
+ exports.applySeo = applySeo;
1091
+ exports.breadcrumbJsonLd = breadcrumbJsonLd;
952
1092
  exports.buildCSV = buildCSV;
953
1093
  exports.createEventBus = createEventBus;
954
1094
  exports.createSafeDataProvider = createSafeDataProvider;
@@ -960,19 +1100,26 @@ exports.formatCurrency = formatCurrency;
960
1100
  exports.formatDate = formatDate;
961
1101
  exports.formatDateTime = formatDateTime;
962
1102
  exports.getActiveLocale = getActiveLocale;
1103
+ exports.getCountry = getCountry;
963
1104
  exports.getDefaultCurrency = getDefaultCurrency;
1105
+ exports.maskDigitCount = maskDigitCount;
1106
+ exports.maskPhone = maskPhone;
964
1107
  exports.migrateManifest = migrateManifest;
965
1108
  exports.navHistoryBack = navHistoryBack;
1109
+ exports.organizationJsonLd = organizationJsonLd;
966
1110
  exports.recordNavigation = recordNavigation;
967
1111
  exports.registerManifestMigration = registerManifestMigration;
968
1112
  exports.renderApp = renderApp;
969
1113
  exports.renderBlocks = renderBlocks;
970
1114
  exports.routeModule = routeModule;
1115
+ exports.seoOrigin = seoOrigin;
971
1116
  exports.setDefaultCurrency = setDefaultCurrency;
1117
+ exports.unmaskPhone = unmaskPhone;
972
1118
  exports.useManifest = useManifest;
973
1119
  exports.useNavHistoryStore = useNavHistoryStore;
974
1120
  exports.useNavReferrer = useNavReferrer;
975
1121
  exports.useOnEvent = useOnEvent;
1122
+ exports.useSeo = useSeo;
976
1123
  exports.validateManifest = validateManifest;
977
1124
  //# sourceMappingURL=index.cjs.map
978
1125
  //# sourceMappingURL=index.cjs.map