tetrons 2.3.35 → 2.3.37
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 +49 -27
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +56 -27
- package/package.json +11 -5
- package/dist/src/index.d.ts +0 -7
- package/dist/src/index.js +0 -61
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +30,38 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// src/server/licenseUtils.ts
|
|
34
|
+
var licenseUtils_exports = {};
|
|
35
|
+
__export(licenseUtils_exports, {
|
|
36
|
+
getOrCreateInstallDate: () => getOrCreateInstallDate,
|
|
37
|
+
getRemainingDays: () => getRemainingDays
|
|
38
|
+
});
|
|
39
|
+
function getOrCreateInstallDate() {
|
|
40
|
+
if (import_fs.default.existsSync(USAGE_FILE_PATH)) {
|
|
41
|
+
const data = JSON.parse(import_fs.default.readFileSync(USAGE_FILE_PATH, "utf-8"));
|
|
42
|
+
return new Date(data.installedAt);
|
|
43
|
+
}
|
|
44
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
45
|
+
import_fs.default.writeFileSync(USAGE_FILE_PATH, JSON.stringify({ installedAt: now }));
|
|
46
|
+
return new Date(now);
|
|
47
|
+
}
|
|
48
|
+
function getRemainingDays(installedAt, validityDays) {
|
|
49
|
+
const now = /* @__PURE__ */ new Date();
|
|
50
|
+
const diff = Math.floor(
|
|
51
|
+
(now.getTime() - installedAt.getTime()) / (1e3 * 60 * 60 * 24)
|
|
52
|
+
);
|
|
53
|
+
return validityDays - diff;
|
|
54
|
+
}
|
|
55
|
+
var import_fs, import_path, USAGE_FILE_PATH;
|
|
56
|
+
var init_licenseUtils = __esm({
|
|
57
|
+
"src/server/licenseUtils.ts"() {
|
|
58
|
+
"use strict";
|
|
59
|
+
import_fs = __toESM(require("fs"));
|
|
60
|
+
import_path = __toESM(require("path"));
|
|
61
|
+
USAGE_FILE_PATH = import_path.default.join(process.cwd(), ".tetrons-usage.json");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
30
65
|
// src/index.ts
|
|
31
66
|
var index_exports = {};
|
|
32
67
|
__export(index_exports, {
|
|
@@ -16979,27 +17014,8 @@ function EditorContent({ apiKey }) {
|
|
|
16979
17014
|
}
|
|
16980
17015
|
|
|
16981
17016
|
// src/index.ts
|
|
16982
|
-
var import_fs = __toESM(require("fs"));
|
|
16983
|
-
var import_path = __toESM(require("path"));
|
|
16984
17017
|
var API_VALID = false;
|
|
16985
17018
|
var API_VERSION = "";
|
|
16986
|
-
var USAGE_FILE_PATH = import_path.default.join(process.cwd(), ".tetrons-usage.json");
|
|
16987
|
-
function getOrCreateInstallDate() {
|
|
16988
|
-
if (import_fs.default.existsSync(USAGE_FILE_PATH)) {
|
|
16989
|
-
const data = JSON.parse(import_fs.default.readFileSync(USAGE_FILE_PATH, "utf-8"));
|
|
16990
|
-
return new Date(data.installedAt);
|
|
16991
|
-
}
|
|
16992
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
16993
|
-
import_fs.default.writeFileSync(USAGE_FILE_PATH, JSON.stringify({ installedAt: now }));
|
|
16994
|
-
return new Date(now);
|
|
16995
|
-
}
|
|
16996
|
-
function getRemainingDays(installedAt, validityDays) {
|
|
16997
|
-
const now = /* @__PURE__ */ new Date();
|
|
16998
|
-
const diff = Math.floor(
|
|
16999
|
-
(now.getTime() - installedAt.getTime()) / (1e3 * 60 * 60 * 24)
|
|
17000
|
-
);
|
|
17001
|
-
return validityDays - diff;
|
|
17002
|
-
}
|
|
17003
17019
|
async function initializeTetrons(apiKey) {
|
|
17004
17020
|
const res = await fetch("https://staging.tetrons.com/api/validate", {
|
|
17005
17021
|
method: "POST",
|
|
@@ -17018,9 +17034,13 @@ async function initializeTetrons(apiKey) {
|
|
|
17018
17034
|
if (!API_VALID) {
|
|
17019
17035
|
throw new Error("API Key is not valid.");
|
|
17020
17036
|
}
|
|
17037
|
+
if (typeof window !== "undefined") {
|
|
17038
|
+
throw new Error("initializeTetrons must be called server-side");
|
|
17039
|
+
}
|
|
17040
|
+
const { getOrCreateInstallDate: getOrCreateInstallDate2, getRemainingDays: getRemainingDays2 } = await Promise.resolve().then(() => (init_licenseUtils(), licenseUtils_exports));
|
|
17021
17041
|
const validityDays = API_VERSION === "free" ? 14 : 30;
|
|
17022
|
-
const installedAt =
|
|
17023
|
-
const remainingDays =
|
|
17042
|
+
const installedAt = getOrCreateInstallDate2();
|
|
17043
|
+
const remainingDays = getRemainingDays2(installedAt, validityDays);
|
|
17024
17044
|
if (remainingDays <= 0) {
|
|
17025
17045
|
throw new Error(`Your ${API_VERSION} license has expired.`);
|
|
17026
17046
|
}
|
|
@@ -17028,18 +17048,20 @@ async function initializeTetrons(apiKey) {
|
|
|
17028
17048
|
`[TETRONS] Initialized: ${API_VERSION} | Remaining days: ${remainingDays}`
|
|
17029
17049
|
);
|
|
17030
17050
|
}
|
|
17051
|
+
async function getTetronsRemainingDays() {
|
|
17052
|
+
if (!API_VALID || !API_VERSION) return null;
|
|
17053
|
+
if (typeof window !== "undefined") return null;
|
|
17054
|
+
const { getOrCreateInstallDate: getOrCreateInstallDate2, getRemainingDays: getRemainingDays2 } = await Promise.resolve().then(() => (init_licenseUtils(), licenseUtils_exports));
|
|
17055
|
+
const validityDays = API_VERSION === "free" ? 14 : 30;
|
|
17056
|
+
const installedAt = getOrCreateInstallDate2();
|
|
17057
|
+
return getRemainingDays2(installedAt, validityDays);
|
|
17058
|
+
}
|
|
17031
17059
|
function getTetronsVersion() {
|
|
17032
17060
|
return API_VERSION;
|
|
17033
17061
|
}
|
|
17034
17062
|
function isApiKeyValid() {
|
|
17035
17063
|
return API_VALID;
|
|
17036
17064
|
}
|
|
17037
|
-
function getTetronsRemainingDays() {
|
|
17038
|
-
if (!API_VALID || !API_VERSION) return null;
|
|
17039
|
-
const validityDays = API_VERSION === "free" ? 14 : 30;
|
|
17040
|
-
const installedAt = getOrCreateInstallDate();
|
|
17041
|
-
return getRemainingDays(installedAt, validityDays);
|
|
17042
|
-
}
|
|
17043
17065
|
var index_default = EditorContent;
|
|
17044
17066
|
// Annotate the CommonJS export names for ESM import in node:
|
|
17045
17067
|
0 && (module.exports = {
|
package/dist/index.d.mts
CHANGED
|
@@ -6,8 +6,8 @@ type EditorContentProps = {
|
|
|
6
6
|
declare function EditorContent({ apiKey }: EditorContentProps): React.JSX.Element;
|
|
7
7
|
|
|
8
8
|
declare function initializeTetrons(apiKey: string): Promise<void>;
|
|
9
|
+
declare function getTetronsRemainingDays(): Promise<number | null>;
|
|
9
10
|
declare function getTetronsVersion(): "" | "free" | "pro" | "premium" | "platinum";
|
|
10
11
|
declare function isApiKeyValid(): boolean;
|
|
11
|
-
declare function getTetronsRemainingDays(): number | null;
|
|
12
12
|
|
|
13
13
|
export { EditorContent, EditorContent as default, getTetronsRemainingDays, getTetronsVersion, initializeTetrons, isApiKeyValid };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ type EditorContentProps = {
|
|
|
6
6
|
declare function EditorContent({ apiKey }: EditorContentProps): React.JSX.Element;
|
|
7
7
|
|
|
8
8
|
declare function initializeTetrons(apiKey: string): Promise<void>;
|
|
9
|
+
declare function getTetronsRemainingDays(): Promise<number | null>;
|
|
9
10
|
declare function getTetronsVersion(): "" | "free" | "pro" | "premium" | "platinum";
|
|
10
11
|
declare function isApiKeyValid(): boolean;
|
|
11
|
-
declare function getTetronsRemainingDays(): number | null;
|
|
12
12
|
|
|
13
13
|
export { EditorContent, EditorContent as default, getTetronsRemainingDays, getTetronsVersion, initializeTetrons, isApiKeyValid };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/server/licenseUtils.ts
|
|
12
|
+
var licenseUtils_exports = {};
|
|
13
|
+
__export(licenseUtils_exports, {
|
|
14
|
+
getOrCreateInstallDate: () => getOrCreateInstallDate,
|
|
15
|
+
getRemainingDays: () => getRemainingDays
|
|
16
|
+
});
|
|
17
|
+
import fs from "fs";
|
|
18
|
+
import path from "path";
|
|
19
|
+
function getOrCreateInstallDate() {
|
|
20
|
+
if (fs.existsSync(USAGE_FILE_PATH)) {
|
|
21
|
+
const data = JSON.parse(fs.readFileSync(USAGE_FILE_PATH, "utf-8"));
|
|
22
|
+
return new Date(data.installedAt);
|
|
23
|
+
}
|
|
24
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
25
|
+
fs.writeFileSync(USAGE_FILE_PATH, JSON.stringify({ installedAt: now }));
|
|
26
|
+
return new Date(now);
|
|
27
|
+
}
|
|
28
|
+
function getRemainingDays(installedAt, validityDays) {
|
|
29
|
+
const now = /* @__PURE__ */ new Date();
|
|
30
|
+
const diff = Math.floor(
|
|
31
|
+
(now.getTime() - installedAt.getTime()) / (1e3 * 60 * 60 * 24)
|
|
32
|
+
);
|
|
33
|
+
return validityDays - diff;
|
|
34
|
+
}
|
|
35
|
+
var USAGE_FILE_PATH;
|
|
36
|
+
var init_licenseUtils = __esm({
|
|
37
|
+
"src/server/licenseUtils.ts"() {
|
|
38
|
+
"use strict";
|
|
39
|
+
USAGE_FILE_PATH = path.join(process.cwd(), ".tetrons-usage.json");
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
1
43
|
// src/components/tetrons/EditorContent.tsx
|
|
2
44
|
import React14, { useEffect as useEffect8, useRef as useRef7, useState as useState9 } from "react";
|
|
3
45
|
import {
|
|
@@ -16985,27 +17027,8 @@ function EditorContent({ apiKey }) {
|
|
|
16985
17027
|
}
|
|
16986
17028
|
|
|
16987
17029
|
// src/index.ts
|
|
16988
|
-
import fs from "fs";
|
|
16989
|
-
import path from "path";
|
|
16990
17030
|
var API_VALID = false;
|
|
16991
17031
|
var API_VERSION = "";
|
|
16992
|
-
var USAGE_FILE_PATH = path.join(process.cwd(), ".tetrons-usage.json");
|
|
16993
|
-
function getOrCreateInstallDate() {
|
|
16994
|
-
if (fs.existsSync(USAGE_FILE_PATH)) {
|
|
16995
|
-
const data = JSON.parse(fs.readFileSync(USAGE_FILE_PATH, "utf-8"));
|
|
16996
|
-
return new Date(data.installedAt);
|
|
16997
|
-
}
|
|
16998
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
16999
|
-
fs.writeFileSync(USAGE_FILE_PATH, JSON.stringify({ installedAt: now }));
|
|
17000
|
-
return new Date(now);
|
|
17001
|
-
}
|
|
17002
|
-
function getRemainingDays(installedAt, validityDays) {
|
|
17003
|
-
const now = /* @__PURE__ */ new Date();
|
|
17004
|
-
const diff = Math.floor(
|
|
17005
|
-
(now.getTime() - installedAt.getTime()) / (1e3 * 60 * 60 * 24)
|
|
17006
|
-
);
|
|
17007
|
-
return validityDays - diff;
|
|
17008
|
-
}
|
|
17009
17032
|
async function initializeTetrons(apiKey) {
|
|
17010
17033
|
const res = await fetch("https://staging.tetrons.com/api/validate", {
|
|
17011
17034
|
method: "POST",
|
|
@@ -17024,9 +17047,13 @@ async function initializeTetrons(apiKey) {
|
|
|
17024
17047
|
if (!API_VALID) {
|
|
17025
17048
|
throw new Error("API Key is not valid.");
|
|
17026
17049
|
}
|
|
17050
|
+
if (typeof window !== "undefined") {
|
|
17051
|
+
throw new Error("initializeTetrons must be called server-side");
|
|
17052
|
+
}
|
|
17053
|
+
const { getOrCreateInstallDate: getOrCreateInstallDate2, getRemainingDays: getRemainingDays2 } = await Promise.resolve().then(() => (init_licenseUtils(), licenseUtils_exports));
|
|
17027
17054
|
const validityDays = API_VERSION === "free" ? 14 : 30;
|
|
17028
|
-
const installedAt =
|
|
17029
|
-
const remainingDays =
|
|
17055
|
+
const installedAt = getOrCreateInstallDate2();
|
|
17056
|
+
const remainingDays = getRemainingDays2(installedAt, validityDays);
|
|
17030
17057
|
if (remainingDays <= 0) {
|
|
17031
17058
|
throw new Error(`Your ${API_VERSION} license has expired.`);
|
|
17032
17059
|
}
|
|
@@ -17034,18 +17061,20 @@ async function initializeTetrons(apiKey) {
|
|
|
17034
17061
|
`[TETRONS] Initialized: ${API_VERSION} | Remaining days: ${remainingDays}`
|
|
17035
17062
|
);
|
|
17036
17063
|
}
|
|
17064
|
+
async function getTetronsRemainingDays() {
|
|
17065
|
+
if (!API_VALID || !API_VERSION) return null;
|
|
17066
|
+
if (typeof window !== "undefined") return null;
|
|
17067
|
+
const { getOrCreateInstallDate: getOrCreateInstallDate2, getRemainingDays: getRemainingDays2 } = await Promise.resolve().then(() => (init_licenseUtils(), licenseUtils_exports));
|
|
17068
|
+
const validityDays = API_VERSION === "free" ? 14 : 30;
|
|
17069
|
+
const installedAt = getOrCreateInstallDate2();
|
|
17070
|
+
return getRemainingDays2(installedAt, validityDays);
|
|
17071
|
+
}
|
|
17037
17072
|
function getTetronsVersion() {
|
|
17038
17073
|
return API_VERSION;
|
|
17039
17074
|
}
|
|
17040
17075
|
function isApiKeyValid() {
|
|
17041
17076
|
return API_VALID;
|
|
17042
17077
|
}
|
|
17043
|
-
function getTetronsRemainingDays() {
|
|
17044
|
-
if (!API_VALID || !API_VERSION) return null;
|
|
17045
|
-
const validityDays = API_VERSION === "free" ? 14 : 30;
|
|
17046
|
-
const installedAt = getOrCreateInstallDate();
|
|
17047
|
-
return getRemainingDays(installedAt, validityDays);
|
|
17048
|
-
}
|
|
17049
17078
|
var index_default = EditorContent;
|
|
17050
17079
|
export {
|
|
17051
17080
|
EditorContent,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tetrons",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.37",
|
|
4
4
|
"description": "A Next.js project written in TypeScript",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"react",
|
|
71
71
|
"web"
|
|
72
72
|
],
|
|
73
|
-
"
|
|
73
|
+
"sideEffects": false,
|
|
74
|
+
"author": "Swastik Jha <swastik.jha@finapsys.co.in>",
|
|
74
75
|
"license": "MIT",
|
|
75
76
|
"exports": {
|
|
76
77
|
".": {
|
|
@@ -101,12 +102,17 @@
|
|
|
101
102
|
"./app/api/validate/route": {
|
|
102
103
|
"import": "./dist/app/api/validate/route.mjs",
|
|
103
104
|
"require": "./dist/app/api/validate/route.cjs"
|
|
105
|
+
},
|
|
106
|
+
"./server/licenseUtils": {
|
|
107
|
+
"import": "./dist/server/licenseUtils.js",
|
|
108
|
+
"require": "./dist/server/licenseUtils.js"
|
|
104
109
|
}
|
|
105
110
|
},
|
|
106
111
|
"files": [
|
|
107
|
-
"dist",
|
|
112
|
+
"dist",
|
|
108
113
|
"dist/styles/tetrons.css",
|
|
109
|
-
"dist/components"
|
|
114
|
+
"dist/components",
|
|
115
|
+
"dist/server"
|
|
110
116
|
],
|
|
111
117
|
"bugs": {
|
|
112
118
|
"url": "https://github.com/Finapsys/Tetrons/issues"
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import EditorContent from "./components/tetrons/EditorContent";
|
|
2
|
-
export declare function initializeTetrons(apiKey: string): Promise<void>;
|
|
3
|
-
export declare function getTetronsVersion(): "" | "free" | "pro" | "premium" | "platinum";
|
|
4
|
-
export declare function isApiKeyValid(): boolean;
|
|
5
|
-
export declare function getTetronsRemainingDays(): number | null;
|
|
6
|
-
export { EditorContent };
|
|
7
|
-
export default EditorContent;
|
package/dist/src/index.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import EditorContent from "./components/tetrons/EditorContent";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
let API_VALID = false;
|
|
5
|
-
let API_VERSION = "";
|
|
6
|
-
const USAGE_FILE_PATH = path.join(process.cwd(), ".tetrons-usage.json");
|
|
7
|
-
function getOrCreateInstallDate() {
|
|
8
|
-
if (fs.existsSync(USAGE_FILE_PATH)) {
|
|
9
|
-
const data = JSON.parse(fs.readFileSync(USAGE_FILE_PATH, "utf-8"));
|
|
10
|
-
return new Date(data.installedAt);
|
|
11
|
-
}
|
|
12
|
-
const now = new Date().toISOString();
|
|
13
|
-
fs.writeFileSync(USAGE_FILE_PATH, JSON.stringify({ installedAt: now }));
|
|
14
|
-
return new Date(now);
|
|
15
|
-
}
|
|
16
|
-
function getRemainingDays(installedAt, validityDays) {
|
|
17
|
-
const now = new Date();
|
|
18
|
-
const diff = Math.floor((now.getTime() - installedAt.getTime()) / (1000 * 60 * 60 * 24));
|
|
19
|
-
return validityDays - diff;
|
|
20
|
-
}
|
|
21
|
-
export async function initializeTetrons(apiKey) {
|
|
22
|
-
const res = await fetch("https://staging.tetrons.com/api/validate", {
|
|
23
|
-
method: "POST",
|
|
24
|
-
headers: {
|
|
25
|
-
"Content-Type": "application/json",
|
|
26
|
-
},
|
|
27
|
-
body: JSON.stringify({ apiKey }),
|
|
28
|
-
});
|
|
29
|
-
if (!res.ok) {
|
|
30
|
-
const error = await res.json();
|
|
31
|
-
throw new Error(`API Key validation failed: ${error.error}`);
|
|
32
|
-
}
|
|
33
|
-
const data = await res.json();
|
|
34
|
-
API_VALID = data.valid;
|
|
35
|
-
API_VERSION = data.version;
|
|
36
|
-
if (!API_VALID) {
|
|
37
|
-
throw new Error("API Key is not valid.");
|
|
38
|
-
}
|
|
39
|
-
const validityDays = API_VERSION === "free" ? 14 : 30;
|
|
40
|
-
const installedAt = getOrCreateInstallDate();
|
|
41
|
-
const remainingDays = getRemainingDays(installedAt, validityDays);
|
|
42
|
-
if (remainingDays <= 0) {
|
|
43
|
-
throw new Error(`Your ${API_VERSION} license has expired.`);
|
|
44
|
-
}
|
|
45
|
-
console.log(`[TETRONS] Initialized: ${API_VERSION} | Remaining days: ${remainingDays}`);
|
|
46
|
-
}
|
|
47
|
-
export function getTetronsVersion() {
|
|
48
|
-
return API_VERSION;
|
|
49
|
-
}
|
|
50
|
-
export function isApiKeyValid() {
|
|
51
|
-
return API_VALID;
|
|
52
|
-
}
|
|
53
|
-
export function getTetronsRemainingDays() {
|
|
54
|
-
if (!API_VALID || !API_VERSION)
|
|
55
|
-
return null;
|
|
56
|
-
const validityDays = API_VERSION === "free" ? 14 : 30;
|
|
57
|
-
const installedAt = getOrCreateInstallDate();
|
|
58
|
-
return getRemainingDays(installedAt, validityDays);
|
|
59
|
-
}
|
|
60
|
-
export { EditorContent };
|
|
61
|
-
export default EditorContent;
|