lineputscript 1.0.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.
@@ -0,0 +1,158 @@
1
+ 'use strict';
2
+
3
+ var chunkWZIZGAEG_js = require('./chunk-WZIZGAEG.js');
4
+
5
+ // src/structure/string-structure.ts
6
+ var StringStructure = class {
7
+ constructor(setstr, getstr, single = true) {
8
+ this._cache = null;
9
+ this.setstr = setstr;
10
+ this.getstr = getstr;
11
+ this.single = single;
12
+ }
13
+ get cache() {
14
+ if (!this.single || this._cache === null) {
15
+ this._cache = /* @__PURE__ */ new Map();
16
+ const raw = this.getstr();
17
+ if (raw) {
18
+ const pairs = chunkWZIZGAEG_js.splitLimited(raw, "/n");
19
+ for (const pair of pairs) {
20
+ const eqIdx = pair.indexOf("=");
21
+ if (eqIdx >= 0) {
22
+ const key = pair.substring(0, eqIdx);
23
+ const val = pair.substring(eqIdx + 1);
24
+ this._cache.set(key, val);
25
+ }
26
+ }
27
+ }
28
+ }
29
+ return this._cache;
30
+ }
31
+ set cache(value) {
32
+ const parts = [];
33
+ for (const [key, val] of value) {
34
+ parts.push(`${key}=${val}`);
35
+ }
36
+ this.setstr(parts.join("/n"));
37
+ }
38
+ getString(key, defaultValue) {
39
+ if (this._cache?.has(key) ?? this.cache.has(key)) {
40
+ return chunkWZIZGAEG_js.textDeReplace(this.cache.get(key)).replace("/!n", "\n");
41
+ }
42
+ return defaultValue !== void 0 ? defaultValue : null;
43
+ }
44
+ setString(key, value) {
45
+ const c = this.cache;
46
+ if (value === null) {
47
+ c.delete(key);
48
+ } else {
49
+ c.set(key, chunkWZIZGAEG_js.textReplace(value.replace("\n", "/!n")));
50
+ }
51
+ this.cache = c;
52
+ }
53
+ get(key) {
54
+ return this.getString(key) ?? "";
55
+ }
56
+ set(key, value) {
57
+ this.setString(key, value);
58
+ }
59
+ getBool(key, defaultValue = false) {
60
+ if (this.cache.has(key)) {
61
+ const val = this.cache.get(key).toLowerCase();
62
+ return val === "true" || val === "1" || val === "t";
63
+ }
64
+ return defaultValue;
65
+ }
66
+ setBool(key, value) {
67
+ this.setString(key, value ? "true" : "false");
68
+ }
69
+ getInt(key, defaultValue = 0) {
70
+ if (this.cache.has(key)) {
71
+ return parseInt(this.cache.get(key), 10) || 0;
72
+ }
73
+ return defaultValue;
74
+ }
75
+ setInt(key, value) {
76
+ this.setString(key, value.toString());
77
+ }
78
+ getInt64(key, defaultValue = 0n) {
79
+ if (this.cache.has(key)) {
80
+ return BigInt(this.cache.get(key));
81
+ }
82
+ return defaultValue;
83
+ }
84
+ setInt64(key, value) {
85
+ this.setString(key, value.toString());
86
+ }
87
+ getFloat(key, defaultValue) {
88
+ if (this.cache.has(key)) {
89
+ return chunkWZIZGAEG_js.FInt64.parse(this.cache.get(key));
90
+ }
91
+ return defaultValue ?? chunkWZIZGAEG_js.FInt64.Zero;
92
+ }
93
+ setFloat(key, value) {
94
+ this.setString(key, value.toStoreString());
95
+ }
96
+ getDateTime(key, defaultValue) {
97
+ if (this.cache.has(key)) {
98
+ const raw = this.cache.get(key);
99
+ const longMatch = /^-?\d+$/.test(raw);
100
+ if (longMatch) {
101
+ try {
102
+ const ticks = BigInt(raw);
103
+ const ticksPerMs = 10000n;
104
+ const epochOffset = 621355968000000000n;
105
+ const ms = Number((ticks - epochOffset) / ticksPerMs);
106
+ return new Date(ms);
107
+ } catch {
108
+ return defaultValue ?? null;
109
+ }
110
+ }
111
+ const d = new Date(raw);
112
+ if (!isNaN(d.getTime())) return d;
113
+ }
114
+ return defaultValue ?? null;
115
+ }
116
+ setDateTime(key, value) {
117
+ const ticksPerMs = 10000n;
118
+ const epochOffset = 621355968000000000n;
119
+ const ticks = BigInt(value.getTime()) * ticksPerMs + epochOffset;
120
+ this.setString(key, ticks.toString());
121
+ }
122
+ getDouble(key, defaultValue = 0) {
123
+ if (this.cache.has(key)) {
124
+ return parseFloat(this.cache.get(key)) || 0;
125
+ }
126
+ return defaultValue;
127
+ }
128
+ setDouble(key, value) {
129
+ this.setString(key, value.toString());
130
+ }
131
+ containsKey(key) {
132
+ return this.cache.has(key);
133
+ }
134
+ get keys() {
135
+ return Array.from(this.cache.keys());
136
+ }
137
+ get values() {
138
+ return Array.from(this.cache.values());
139
+ }
140
+ get count() {
141
+ return this.cache.size;
142
+ }
143
+ clear() {
144
+ this._cache = null;
145
+ this.setstr("");
146
+ }
147
+ remove(key) {
148
+ const c = this.cache;
149
+ const result = c.delete(key);
150
+ if (result) this.cache = c;
151
+ return result;
152
+ }
153
+ [Symbol.iterator]() {
154
+ return this.cache.entries();
155
+ }
156
+ };
157
+
158
+ exports.StringStructure = StringStructure;
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1 @@
1
+