qstd 0.2.9 → 0.2.10
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/client/index.cjs +28 -1
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +28 -1
- package/dist/{log-ERvLs2Dx.d.cts → log-DlaF8tUZ.d.cts} +37 -1
- package/dist/{log-ERvLs2Dx.d.ts → log-DlaF8tUZ.d.ts} +37 -1
- package/dist/server/index.cjs +28 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +28 -1
- package/package.json +18 -19
package/dist/client/index.cjs
CHANGED
|
@@ -133,8 +133,35 @@ __export(str_exports, {
|
|
|
133
133
|
concat: () => concat,
|
|
134
134
|
countChar: () => countChar,
|
|
135
135
|
countWords: () => countWords,
|
|
136
|
-
createSentences: () => createSentences
|
|
136
|
+
createSentences: () => createSentences,
|
|
137
|
+
parseJson: () => parseJson
|
|
137
138
|
});
|
|
139
|
+
function parseJson(input, opts) {
|
|
140
|
+
const strict = opts?.strict ?? false;
|
|
141
|
+
if (input === null || input === void 0) {
|
|
142
|
+
const error2 = new Error("[parseJson] input is null or undefined");
|
|
143
|
+
if (strict) throw error2;
|
|
144
|
+
return { ok: false, error: error2 };
|
|
145
|
+
}
|
|
146
|
+
if (input === "") {
|
|
147
|
+
const error2 = new Error("[parseJson] input is empty string");
|
|
148
|
+
if (strict) throw error2;
|
|
149
|
+
return { ok: false, error: error2 };
|
|
150
|
+
}
|
|
151
|
+
if (typeof input === "object") {
|
|
152
|
+
if (strict) return input;
|
|
153
|
+
return { ok: true, data: input };
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
const data = JSON.parse(input);
|
|
157
|
+
if (strict) return data;
|
|
158
|
+
return { ok: true, data };
|
|
159
|
+
} catch (e) {
|
|
160
|
+
const error2 = e instanceof Error ? e : new Error("[parseJson] failed to parse JSON");
|
|
161
|
+
if (strict) throw error2;
|
|
162
|
+
return { ok: false, error: error2 };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
138
165
|
var createSentences = (text) => {
|
|
139
166
|
if (!text) return [];
|
|
140
167
|
return text?.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DlaF8tUZ.cjs';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DlaF8tUZ.js';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/client/index.js
CHANGED
|
@@ -131,8 +131,35 @@ __export(str_exports, {
|
|
|
131
131
|
concat: () => concat,
|
|
132
132
|
countChar: () => countChar,
|
|
133
133
|
countWords: () => countWords,
|
|
134
|
-
createSentences: () => createSentences
|
|
134
|
+
createSentences: () => createSentences,
|
|
135
|
+
parseJson: () => parseJson
|
|
135
136
|
});
|
|
137
|
+
function parseJson(input, opts) {
|
|
138
|
+
const strict = opts?.strict ?? false;
|
|
139
|
+
if (input === null || input === void 0) {
|
|
140
|
+
const error2 = new Error("[parseJson] input is null or undefined");
|
|
141
|
+
if (strict) throw error2;
|
|
142
|
+
return { ok: false, error: error2 };
|
|
143
|
+
}
|
|
144
|
+
if (input === "") {
|
|
145
|
+
const error2 = new Error("[parseJson] input is empty string");
|
|
146
|
+
if (strict) throw error2;
|
|
147
|
+
return { ok: false, error: error2 };
|
|
148
|
+
}
|
|
149
|
+
if (typeof input === "object") {
|
|
150
|
+
if (strict) return input;
|
|
151
|
+
return { ok: true, data: input };
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const data = JSON.parse(input);
|
|
155
|
+
if (strict) return data;
|
|
156
|
+
return { ok: true, data };
|
|
157
|
+
} catch (e) {
|
|
158
|
+
const error2 = e instanceof Error ? e : new Error("[parseJson] failed to parse JSON");
|
|
159
|
+
if (strict) throw error2;
|
|
160
|
+
return { ok: false, error: error2 };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
136
163
|
var createSentences = (text) => {
|
|
137
164
|
if (!text) return [];
|
|
138
165
|
return text?.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
|
|
@@ -104,6 +104,41 @@ declare namespace dict {
|
|
|
104
104
|
export { dict_byteSizeOfObj as byteSizeOfObj, dict_exists as exists, dict_filter as filter, dict_isEmpty as isEmpty, dict_omit as omit, dict_partition as partition, dict_pick as pick, dict_transform as transform };
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
type ParseJsonResult<T> = {
|
|
108
|
+
ok: true;
|
|
109
|
+
data: T;
|
|
110
|
+
} | {
|
|
111
|
+
ok: false;
|
|
112
|
+
error: Error;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Parse a JSON string into an object
|
|
116
|
+
* - Safe by default: returns { ok, data/error }
|
|
117
|
+
* - Strict mode: throws on error, returns data directly
|
|
118
|
+
* - If input is already an object, returns it as-is
|
|
119
|
+
* - If input is null/undefined/empty string, returns error (or throws if strict)
|
|
120
|
+
* - Optional generic for typed output (no runtime validation)
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* // Safe mode (default)
|
|
124
|
+
* const result = parseJson(event.body);
|
|
125
|
+
* if (result.ok) console.log(result.data);
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* // Safe mode with type
|
|
129
|
+
* const result = parseJson<{ name: string }>(event.body);
|
|
130
|
+
* if (result.ok) console.log(result.data.name);
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* // Strict mode - throws on error
|
|
134
|
+
* const data = parseJson<MyType>(event.body, { strict: true });
|
|
135
|
+
*/
|
|
136
|
+
declare function parseJson<T = Record<string, unknown>>(input: string | object | null | undefined, opts: {
|
|
137
|
+
strict: true;
|
|
138
|
+
}): T;
|
|
139
|
+
declare function parseJson<T = Record<string, unknown>>(input: string | object | null | undefined, opts?: {
|
|
140
|
+
strict?: false;
|
|
141
|
+
}): ParseJsonResult<T>;
|
|
107
142
|
type CaseOpts = {
|
|
108
143
|
to: "title" | "snake" | "kebab";
|
|
109
144
|
clean?: boolean;
|
|
@@ -147,8 +182,9 @@ declare const str_concat: typeof concat;
|
|
|
147
182
|
declare const str_countChar: typeof countChar;
|
|
148
183
|
declare const str_countWords: typeof countWords;
|
|
149
184
|
declare const str_createSentences: typeof createSentences;
|
|
185
|
+
declare const str_parseJson: typeof parseJson;
|
|
150
186
|
declare namespace str {
|
|
151
|
-
export { str_changeCase as changeCase, str_concat as concat, str_countChar as countChar, str_countWords as countWords, str_createSentences as createSentences };
|
|
187
|
+
export { str_changeCase as changeCase, str_concat as concat, str_countChar as countChar, str_countWords as countWords, str_createSentences as createSentences, str_parseJson as parseJson };
|
|
152
188
|
}
|
|
153
189
|
|
|
154
190
|
type Range = {
|
|
@@ -104,6 +104,41 @@ declare namespace dict {
|
|
|
104
104
|
export { dict_byteSizeOfObj as byteSizeOfObj, dict_exists as exists, dict_filter as filter, dict_isEmpty as isEmpty, dict_omit as omit, dict_partition as partition, dict_pick as pick, dict_transform as transform };
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
type ParseJsonResult<T> = {
|
|
108
|
+
ok: true;
|
|
109
|
+
data: T;
|
|
110
|
+
} | {
|
|
111
|
+
ok: false;
|
|
112
|
+
error: Error;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Parse a JSON string into an object
|
|
116
|
+
* - Safe by default: returns { ok, data/error }
|
|
117
|
+
* - Strict mode: throws on error, returns data directly
|
|
118
|
+
* - If input is already an object, returns it as-is
|
|
119
|
+
* - If input is null/undefined/empty string, returns error (or throws if strict)
|
|
120
|
+
* - Optional generic for typed output (no runtime validation)
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* // Safe mode (default)
|
|
124
|
+
* const result = parseJson(event.body);
|
|
125
|
+
* if (result.ok) console.log(result.data);
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* // Safe mode with type
|
|
129
|
+
* const result = parseJson<{ name: string }>(event.body);
|
|
130
|
+
* if (result.ok) console.log(result.data.name);
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* // Strict mode - throws on error
|
|
134
|
+
* const data = parseJson<MyType>(event.body, { strict: true });
|
|
135
|
+
*/
|
|
136
|
+
declare function parseJson<T = Record<string, unknown>>(input: string | object | null | undefined, opts: {
|
|
137
|
+
strict: true;
|
|
138
|
+
}): T;
|
|
139
|
+
declare function parseJson<T = Record<string, unknown>>(input: string | object | null | undefined, opts?: {
|
|
140
|
+
strict?: false;
|
|
141
|
+
}): ParseJsonResult<T>;
|
|
107
142
|
type CaseOpts = {
|
|
108
143
|
to: "title" | "snake" | "kebab";
|
|
109
144
|
clean?: boolean;
|
|
@@ -147,8 +182,9 @@ declare const str_concat: typeof concat;
|
|
|
147
182
|
declare const str_countChar: typeof countChar;
|
|
148
183
|
declare const str_countWords: typeof countWords;
|
|
149
184
|
declare const str_createSentences: typeof createSentences;
|
|
185
|
+
declare const str_parseJson: typeof parseJson;
|
|
150
186
|
declare namespace str {
|
|
151
|
-
export { str_changeCase as changeCase, str_concat as concat, str_countChar as countChar, str_countWords as countWords, str_createSentences as createSentences };
|
|
187
|
+
export { str_changeCase as changeCase, str_concat as concat, str_countChar as countChar, str_countWords as countWords, str_createSentences as createSentences, str_parseJson as parseJson };
|
|
152
188
|
}
|
|
153
189
|
|
|
154
190
|
type Range = {
|
package/dist/server/index.cjs
CHANGED
|
@@ -138,8 +138,35 @@ __export(str_exports, {
|
|
|
138
138
|
concat: () => concat,
|
|
139
139
|
countChar: () => countChar,
|
|
140
140
|
countWords: () => countWords,
|
|
141
|
-
createSentences: () => createSentences
|
|
141
|
+
createSentences: () => createSentences,
|
|
142
|
+
parseJson: () => parseJson
|
|
142
143
|
});
|
|
144
|
+
function parseJson(input, opts) {
|
|
145
|
+
const strict = opts?.strict ?? false;
|
|
146
|
+
if (input === null || input === void 0) {
|
|
147
|
+
const error2 = new Error("[parseJson] input is null or undefined");
|
|
148
|
+
if (strict) throw error2;
|
|
149
|
+
return { ok: false, error: error2 };
|
|
150
|
+
}
|
|
151
|
+
if (input === "") {
|
|
152
|
+
const error2 = new Error("[parseJson] input is empty string");
|
|
153
|
+
if (strict) throw error2;
|
|
154
|
+
return { ok: false, error: error2 };
|
|
155
|
+
}
|
|
156
|
+
if (typeof input === "object") {
|
|
157
|
+
if (strict) return input;
|
|
158
|
+
return { ok: true, data: input };
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const data = JSON.parse(input);
|
|
162
|
+
if (strict) return data;
|
|
163
|
+
return { ok: true, data };
|
|
164
|
+
} catch (e) {
|
|
165
|
+
const error2 = e instanceof Error ? e : new Error("[parseJson] failed to parse JSON");
|
|
166
|
+
if (strict) throw error2;
|
|
167
|
+
return { ok: false, error: error2 };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
143
170
|
var createSentences = (text) => {
|
|
144
171
|
if (!text) return [];
|
|
145
172
|
return text?.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DlaF8tUZ.cjs';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DlaF8tUZ.js';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/server/index.js
CHANGED
|
@@ -132,8 +132,35 @@ __export(str_exports, {
|
|
|
132
132
|
concat: () => concat,
|
|
133
133
|
countChar: () => countChar,
|
|
134
134
|
countWords: () => countWords,
|
|
135
|
-
createSentences: () => createSentences
|
|
135
|
+
createSentences: () => createSentences,
|
|
136
|
+
parseJson: () => parseJson
|
|
136
137
|
});
|
|
138
|
+
function parseJson(input, opts) {
|
|
139
|
+
const strict = opts?.strict ?? false;
|
|
140
|
+
if (input === null || input === void 0) {
|
|
141
|
+
const error2 = new Error("[parseJson] input is null or undefined");
|
|
142
|
+
if (strict) throw error2;
|
|
143
|
+
return { ok: false, error: error2 };
|
|
144
|
+
}
|
|
145
|
+
if (input === "") {
|
|
146
|
+
const error2 = new Error("[parseJson] input is empty string");
|
|
147
|
+
if (strict) throw error2;
|
|
148
|
+
return { ok: false, error: error2 };
|
|
149
|
+
}
|
|
150
|
+
if (typeof input === "object") {
|
|
151
|
+
if (strict) return input;
|
|
152
|
+
return { ok: true, data: input };
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const data = JSON.parse(input);
|
|
156
|
+
if (strict) return data;
|
|
157
|
+
return { ok: true, data };
|
|
158
|
+
} catch (e) {
|
|
159
|
+
const error2 = e instanceof Error ? e : new Error("[parseJson] failed to parse JSON");
|
|
160
|
+
if (strict) throw error2;
|
|
161
|
+
return { ok: false, error: error2 };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
137
164
|
var createSentences = (text) => {
|
|
138
165
|
if (!text) return [];
|
|
139
166
|
return text?.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qstd",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Standard Block component and utilities library with Panda CSS",
|
|
5
5
|
"author": "malin1",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,22 +41,6 @@
|
|
|
41
41
|
"sideEffects": [
|
|
42
42
|
"dist/react/index.css"
|
|
43
43
|
],
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "panda codegen && panda cssgen && tsup && node scripts/inject-css-import.js",
|
|
46
|
-
"dev": "tsup --watch",
|
|
47
|
-
"prepublishOnly": "pnpm build",
|
|
48
|
-
"prepare:local": "pnpm build && cd playground && pnpm prepare",
|
|
49
|
-
"test": "vitest run",
|
|
50
|
-
"test:watch": "vitest",
|
|
51
|
-
"test:all": "pnpx tsx tests/test-all.ts",
|
|
52
|
-
"test:block": "node tests/test-block.tsx",
|
|
53
|
-
"test:playground": "node tests/playground-e2e.mjs",
|
|
54
|
-
"typecheck": "tsc --noEmit",
|
|
55
|
-
"typecheck:perf": "tsc --noEmit --extendedDiagnostics",
|
|
56
|
-
"typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
|
|
57
|
-
"analyze:tsserver": "bash performance/analyze-tsserver.sh",
|
|
58
|
-
"lint": "eslint ."
|
|
59
|
-
},
|
|
60
44
|
"peerDependencies": {
|
|
61
45
|
"react": "^18.0.0 || ^19.0.0",
|
|
62
46
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
@@ -112,5 +96,20 @@
|
|
|
112
96
|
"bugs": {
|
|
113
97
|
"url": "https://github.com/55cancri/qstd/issues"
|
|
114
98
|
},
|
|
115
|
-
"homepage": "https://github.com/55cancri/qstd#readme"
|
|
116
|
-
|
|
99
|
+
"homepage": "https://github.com/55cancri/qstd#readme",
|
|
100
|
+
"scripts": {
|
|
101
|
+
"build": "panda codegen && panda cssgen && tsup && node scripts/inject-css-import.js",
|
|
102
|
+
"dev": "tsup --watch",
|
|
103
|
+
"prepare:local": "pnpm build && cd playground && pnpm prepare",
|
|
104
|
+
"test": "vitest run",
|
|
105
|
+
"test:watch": "vitest",
|
|
106
|
+
"test:all": "pnpx tsx tests/test-all.ts",
|
|
107
|
+
"test:block": "node tests/test-block.tsx",
|
|
108
|
+
"test:playground": "node tests/playground-e2e.mjs",
|
|
109
|
+
"typecheck": "tsc --noEmit",
|
|
110
|
+
"typecheck:perf": "tsc --noEmit --extendedDiagnostics",
|
|
111
|
+
"typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
|
|
112
|
+
"analyze:tsserver": "bash performance/analyze-tsserver.sh",
|
|
113
|
+
"lint": "eslint ."
|
|
114
|
+
}
|
|
115
|
+
}
|