@freegridjs/core 0.7.0 → 0.7.1

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.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { G as GridOptions, a as GridApi, L as LocalePack } from './types-DZ66BpLd.js';
2
- export { A as Aggregator, C as CellEvent, b as CellParams, c as ChartHandle, d as ChartOptions, e as ColumnDef, f as ColumnState, g as ColumnType, h as ContextMenuItem, i as ContextMenuParams, j as CustomEditor, D as Datasource, k as DateFilterModel, l as DateOp, E as EditorParams, m as EditorSpec, n as ExportOptions, F as FilterModel, o as FilterOp, p as FilterType, q as GridEvents, r as GridRange, K as KeyAction, M as Messages, N as NumberFilterModel, s as NumberOp, P as PivotConfig, R as Region, t as Row, S as SelectOption, u as ServerParams, v as SetFilterModel, w as SortDir, x as SortItem, y as SummaryCell, z as SummaryOptions, B as SummaryRowDef, T as TextFilterModel, H as TextOp } from './types-DZ66BpLd.js';
1
+ import { G as GridOptions, a as GridApi, L as LocalePack } from './types-CusLVNhk.js';
2
+ export { A as Aggregator, C as CellEvent, b as CellParams, c as ChartHandle, d as ChartOptions, e as ColumnDef, f as ColumnState, g as ColumnType, h as ContextMenuItem, i as ContextMenuParams, j as CustomEditor, D as Datasource, k as DateFilterModel, l as DateOp, E as EditorParams, m as EditorSpec, n as ExportOptions, F as FilterModel, o as FilterOp, p as FilterType, q as GridEvents, r as GridRange, K as KeyAction, M as Messages, N as NumberFilterModel, s as NumberOp, P as PivotConfig, R as Region, t as Row, S as SelectOption, u as ServerParams, v as SetFilterModel, w as SortDir, x as SortItem, y as SummaryCell, z as SummaryOptions, B as SummaryRowDef, T as TextFilterModel, H as TextOp } from './types-CusLVNhk.js';
3
3
  export { default as en } from './locales/en.js';
4
4
 
5
5
  declare function createGrid(host: HTMLElement, options: GridOptions): GridApi;
6
6
 
7
7
  /** FreeGrid version (kept in sync with releases.json by scripts/release.mjs). */
8
- declare const version = "0.7.0";
8
+ declare const version = "0.7.1";
9
9
 
10
10
  interface LicenseInfo {
11
11
  /** Licensed domains; each also covers its subdomains. */
package/dist/index.js CHANGED
@@ -1374,6 +1374,16 @@ var Renderer = class {
1374
1374
  );
1375
1375
  this.pagerEl.replaceChildren(...parts);
1376
1376
  }
1377
+ /** Small "free version" mark in the bottom-right corner (unlicensed company domains flagged on freegrid.app). */
1378
+ showFreeBadge() {
1379
+ if (this.root.querySelector(".fg-free-badge")) return;
1380
+ const a = el("a", "fg-free-badge", { href: "https://freegrid.app/pricing/", target: "_blank", rel: "noopener" });
1381
+ a.innerHTML = '<svg viewBox="0 0 32 32" width="14" height="14" aria-hidden="true"><rect width="32" height="32" rx="7" fill="#0E1726"/><path d="M7 11.5h18M7 16.5h18M7 21.5h18M13 7v18" stroke="#fff" stroke-width="2" stroke-linecap="round"/><rect x="14" y="12.5" width="11" height="3" rx="1" fill="#F2A900"/></svg>';
1382
+ const text = el("span");
1383
+ text.textContent = `FreeGrid \xB7 ${this.grid.store.state.locale.freeBadge}`;
1384
+ a.append(text);
1385
+ this.root.append(a);
1386
+ }
1377
1387
  /** Forget cached detail panels (one master, or all). */
1378
1388
  dropDetail(id) {
1379
1389
  if (id === void 0) this.details.clear();
@@ -1633,6 +1643,7 @@ var en = {
1633
1643
  chartLine: "Line chart",
1634
1644
  chartArea: "Area chart",
1635
1645
  chartPie: "Pie chart",
1646
+ freeBadge: "Free version",
1636
1647
  ops: {
1637
1648
  contains: "Contains",
1638
1649
  equals: "Equals",
@@ -4468,12 +4479,13 @@ function buildPivot(source, config, defOf, labels, locale) {
4468
4479
  }
4469
4480
 
4470
4481
  // src/version.ts
4471
- var version = "0.7.0";
4482
+ var version = "0.7.1";
4472
4483
 
4473
4484
  // src/license.ts
4474
4485
  var PUBLIC_KEY = { kty: "EC", crv: "P-256", x: "sUTKkglZmk-HMKPNub8p7AeLBKesHCU8irIkw9rJlbE", y: "j0U_aKRDR7iApY9UpaD3hUemhBLZJwDv9-QiT_hUyw8" };
4475
4486
  var PRICING_URL = "https://freegrid.app/pricing/";
4476
4487
  var USAGE_URL = "https://freegrid.app/api/usage";
4488
+ var STATUS_URL = "https://freegrid.app/api/domain-status";
4477
4489
  var b64urlDecode = (s) => {
4478
4490
  const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - s.length % 4) % 4));
4479
4491
  return Uint8Array.from(bin, (c) => c.charCodeAt(0));
@@ -4515,7 +4527,8 @@ async function verifyLicense(key, host, opts = {}) {
4515
4527
  return { ok: true, info };
4516
4528
  }
4517
4529
  var globalKey;
4518
- var reported = /* @__PURE__ */ new Set();
4530
+ var statuses = /* @__PURE__ */ new Map();
4531
+ var badgeCheck = null;
4519
4532
  function setLicenseKey(key) {
4520
4533
  globalKey = key;
4521
4534
  }
@@ -4542,22 +4555,52 @@ function reportUsage(info, host = typeof location !== "undefined" ? location.hos
4542
4555
  }
4543
4556
  }
4544
4557
  function checkLicense(key = globalKey, host = typeof location !== "undefined" ? location.hostname : "") {
4558
+ if (isDevHost(host)) return Promise.resolve(true);
4545
4559
  const k = key ?? globalKey;
4546
4560
  const id = `${k ?? ""}@${host}`;
4547
- if (reported.has(id) || isDevHost(host)) return Promise.resolve();
4548
- reported.add(id);
4561
+ let status = statuses.get(id);
4562
+ if (status) return status;
4549
4563
  if (!k) {
4550
4564
  console.info(NOTICE.missing);
4551
4565
  reportUsage({ version, licensed: false }, host);
4552
- return Promise.resolve();
4553
- }
4554
- return verifyLicense(k, host).then((res) => {
4555
- reportUsage({ version, licensed: res.ok, company: res.ok ? res.info.company : void 0 }, host);
4556
- if (res.ok || res.reason === "unsupported") return;
4557
- const extra = res.info ? ` (${res.info.domains.join(", ")}, ${res.info.expires})` : "";
4558
- console.warn(`${NOTICE[res.reason]}${extra}
4566
+ status = Promise.resolve(false);
4567
+ } else {
4568
+ status = verifyLicense(k, host).then((res) => {
4569
+ reportUsage({ version, licensed: res.ok, company: res.ok ? res.info.company : void 0 }, host);
4570
+ if (res.ok || res.reason === "unsupported") return res.ok || res.reason === "unsupported";
4571
+ const extra = res.info ? ` (${res.info.domains.join(", ")}, ${res.info.expires})` : "";
4572
+ console.warn(`${NOTICE[res.reason]}${extra}
4559
4573
  ${PRICING_URL}`);
4560
- }, () => void 0);
4574
+ return false;
4575
+ }, () => false);
4576
+ }
4577
+ statuses.set(id, status);
4578
+ return status;
4579
+ }
4580
+ function badgeRequested(host = typeof location !== "undefined" ? location.hostname : "") {
4581
+ if (isDevHost(host) || typeof fetch !== "function") return Promise.resolve(false);
4582
+ if (badgeCheck) return badgeCheck;
4583
+ const day = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
4584
+ let store = null;
4585
+ try {
4586
+ store = typeof localStorage !== "undefined" ? localStorage : null;
4587
+ const cached = JSON.parse(store?.getItem("freegrid:badge") ?? "null");
4588
+ if (cached && cached.host === host && cached.day === day) return badgeCheck = Promise.resolve(cached.show);
4589
+ } catch {
4590
+ }
4591
+ badgeCheck = fetch(STATUS_URL, { mode: "cors", credentials: "omit" }).then((r) => r.ok ? r.json() : { badge: false }).then((d) => {
4592
+ const show = d.badge === true;
4593
+ try {
4594
+ store?.setItem("freegrid:badge", JSON.stringify({ host, day, show }));
4595
+ } catch {
4596
+ }
4597
+ return show;
4598
+ }, () => false);
4599
+ return badgeCheck;
4600
+ }
4601
+ async function needsFreeBadge(key, host = typeof location !== "undefined" ? location.hostname : "") {
4602
+ if (await checkLicense(key, host)) return false;
4603
+ return badgeRequested(host);
4561
4604
  }
4562
4605
 
4563
4606
  // src/interactions/menu.ts
@@ -5367,7 +5410,9 @@ var Grid = class {
5367
5410
  this.disposers.push(() => ro.disconnect());
5368
5411
  }
5369
5412
  if (options.pivot) this.setPivot(options.pivot);
5370
- void checkLicense(options.licenseKey);
5413
+ void needsFreeBadge(options.licenseKey).then((show) => {
5414
+ if (show && !this.destroyed) this.renderer.showFreeBadge();
5415
+ });
5371
5416
  this.renderer.render();
5372
5417
  this.api = this.createApi();
5373
5418
  }
@@ -1,4 +1,4 @@
1
- import { L as LocalePack } from '../types-DZ66BpLd.js';
1
+ import { L as LocalePack } from '../types-CusLVNhk.js';
2
2
 
3
3
  declare const de: LocalePack;
4
4
 
@@ -78,6 +78,7 @@ var de = {
78
78
  chartLine: "Liniendiagramm",
79
79
  chartArea: "Fl\xE4chendiagramm",
80
80
  chartPie: "Kreisdiagramm",
81
+ freeBadge: "Kostenlose Version",
81
82
  ops: {
82
83
  contains: "Enth\xE4lt",
83
84
  equals: "Gleich",
@@ -1,4 +1,4 @@
1
- import { L as LocalePack } from '../types-DZ66BpLd.js';
1
+ import { L as LocalePack } from '../types-CusLVNhk.js';
2
2
 
3
3
  declare const en: LocalePack;
4
4
 
@@ -78,6 +78,7 @@ var en = {
78
78
  chartLine: "Line chart",
79
79
  chartArea: "Area chart",
80
80
  chartPie: "Pie chart",
81
+ freeBadge: "Free version",
81
82
  ops: {
82
83
  contains: "Contains",
83
84
  equals: "Equals",
@@ -1,4 +1,4 @@
1
- import { L as LocalePack } from '../types-DZ66BpLd.js';
1
+ import { L as LocalePack } from '../types-CusLVNhk.js';
2
2
 
3
3
  declare const es: LocalePack;
4
4
 
@@ -78,6 +78,7 @@ var es = {
78
78
  chartLine: "Gr\xE1fico de l\xEDneas",
79
79
  chartArea: "Gr\xE1fico de \xE1reas",
80
80
  chartPie: "Gr\xE1fico circular",
81
+ freeBadge: "Versi\xF3n gratuita",
81
82
  ops: {
82
83
  contains: "Contiene",
83
84
  equals: "Igual a",
@@ -1,4 +1,4 @@
1
- import { L as LocalePack } from '../types-DZ66BpLd.js';
1
+ import { L as LocalePack } from '../types-CusLVNhk.js';
2
2
 
3
3
  declare const fr: LocalePack;
4
4
 
@@ -78,6 +78,7 @@ var fr = {
78
78
  chartLine: "Courbes",
79
79
  chartArea: "Aires",
80
80
  chartPie: "Secteurs",
81
+ freeBadge: "Version gratuite",
81
82
  ops: {
82
83
  contains: "Contient",
83
84
  equals: "\xC9gal \xE0",
@@ -1,4 +1,4 @@
1
- import { L as LocalePack } from '../types-DZ66BpLd.js';
1
+ import { L as LocalePack } from '../types-CusLVNhk.js';
2
2
 
3
3
  declare const ja: LocalePack;
4
4
 
@@ -78,6 +78,7 @@ var ja = {
78
78
  chartLine: "\u6298\u308C\u7DDA\u30B0\u30E9\u30D5",
79
79
  chartArea: "\u9762\u30B0\u30E9\u30D5",
80
80
  chartPie: "\u5186\u30B0\u30E9\u30D5",
81
+ freeBadge: "\u7121\u6599\u7248\u3092\u4F7F\u7528\u4E2D",
81
82
  ops: {
82
83
  contains: "\u542B\u3080",
83
84
  equals: "\u7B49\u3057\u3044",
@@ -1,4 +1,4 @@
1
- import { L as LocalePack } from '../types-DZ66BpLd.js';
1
+ import { L as LocalePack } from '../types-CusLVNhk.js';
2
2
 
3
3
  declare const ko: LocalePack;
4
4
 
@@ -78,6 +78,7 @@ var ko = {
78
78
  chartLine: "\uAEBE\uC740\uC120 \uCC28\uD2B8",
79
79
  chartArea: "\uC601\uC5ED \uCC28\uD2B8",
80
80
  chartPie: "\uC6D0\uD615 \uCC28\uD2B8",
81
+ freeBadge: "\uBB34\uB8CC \uC0AC\uC6A9 \uC911",
81
82
  ops: {
82
83
  contains: "\uD3EC\uD568",
83
84
  equals: "\uAC19\uC74C",
@@ -1,4 +1,4 @@
1
- import { L as LocalePack } from '../types-DZ66BpLd.js';
1
+ import { L as LocalePack } from '../types-CusLVNhk.js';
2
2
 
3
3
  declare const zhCN: LocalePack;
4
4
 
@@ -78,6 +78,7 @@ var zhCN = {
78
78
  chartLine: "\u6298\u7EBF\u56FE",
79
79
  chartArea: "\u9762\u79EF\u56FE",
80
80
  chartPie: "\u997C\u56FE",
81
+ freeBadge: "\u514D\u8D39\u4F7F\u7528\u4E2D",
81
82
  ops: {
82
83
  contains: "\u5305\u542B",
83
84
  equals: "\u7B49\u4E8E",
package/dist/styles.css CHANGED
@@ -366,3 +366,12 @@ textarea.fg-editor-control { padding-top: 8px; resize: none; }
366
366
  .fg-chart-plot:hover .fg-chart-bar:not(:hover), .fg-chart:hover .fg-chart-slice:not(:hover) { opacity: .55; }
367
367
  .fg-chart-slice { stroke: var(--fg-popup-bg, #fff); stroke-width: 1.5; }
368
368
  @media (prefers-reduced-motion: reduce) { .fg-chart-bar, .fg-chart-slice, .fg-chart-point { transition: none; } }
369
+
370
+ /* free-use badge (unlicensed company domains) */
371
+ .fg-free-badge {
372
+ position: absolute; right: 22px; bottom: 22px; z-index: 30; display: inline-flex; align-items: center; gap: 6px;
373
+ padding: 4px 10px 4px 6px; border-radius: 999px; background: rgba(255, 255, 255, .92); border: 1px solid rgba(14, 23, 38, .15);
374
+ box-shadow: 0 2px 8px rgba(14, 23, 38, .12); color: #0E1726; font: 600 11px/1.2 var(--fg-font); text-decoration: none; opacity: .9;
375
+ }
376
+ .fg-free-badge:hover { opacity: 1; }
377
+ .fg-free-badge svg { flex: none; }
@@ -194,6 +194,7 @@ interface Messages {
194
194
  chartLine: string;
195
195
  chartArea: string;
196
196
  chartPie: string;
197
+ freeBadge: string;
197
198
  ops: Record<FilterOp, string>;
198
199
  }
199
200
  interface LocalePack extends Messages {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freegridjs/core",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "FreeGrid — a fast data grid for the web (free for personal use): virtual scrolling, grouping, pivot, charts, Excel export, 7 languages.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",