@sciexpr/presets 0.1.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.js ADDED
@@ -0,0 +1,582 @@
1
+ // src/math-templates.ts
2
+ var CALCULUS_TEMPLATES = [
3
+ {
4
+ id: "derivative-def",
5
+ name: "\u5BFC\u6570\u5B9A\u4E49",
6
+ latex: "f'(x) = \\lim_{h \\to 0} \\frac{f(x+h) - f(x)}{h}",
7
+ category: "calculus",
8
+ description: "\u5BFC\u6570\u7684\u6781\u9650\u5B9A\u4E49",
9
+ tags: ["derivative", "limit", "definition"]
10
+ },
11
+ {
12
+ id: "power-rule",
13
+ name: "\u5E42\u51FD\u6570\u6C42\u5BFC",
14
+ latex: "\\frac{d}{dx} x^{n} = n x^{n-1}",
15
+ category: "calculus",
16
+ description: "\u5E42\u6CD5\u5219",
17
+ tags: ["derivative", "power", "rule"]
18
+ },
19
+ {
20
+ id: "product-rule",
21
+ name: "\u4E58\u79EF\u6CD5\u5219",
22
+ latex: "\\frac{d}{dx} [f(x) g(x)] = f'(x)g(x) + f(x)g'(x)",
23
+ category: "calculus",
24
+ description: "\u4E58\u79EF\u6C42\u5BFC\u6CD5\u5219",
25
+ tags: ["derivative", "product", "rule"]
26
+ },
27
+ {
28
+ id: "chain-rule",
29
+ name: "\u94FE\u5F0F\u6CD5\u5219",
30
+ latex: "\\frac{d}{dx} f(g(x)) = f'(g(x)) \\cdot g'(x)",
31
+ category: "calculus",
32
+ description: "\u94FE\u5F0F\u6C42\u5BFC\u6CD5\u5219",
33
+ tags: ["derivative", "chain", "rule"]
34
+ },
35
+ {
36
+ id: "integral-def",
37
+ name: "\u5B9A\u79EF\u5206\u5B9A\u4E49",
38
+ latex: "\\int_{a}^{b} f(x) dx = \\lim_{n \\to \\infty} \\sum_{i=1}^{n} f(x_i^*) \\Delta x",
39
+ category: "calculus",
40
+ description: "\u9ECE\u66FC\u548C\u5B9A\u4E49",
41
+ tags: ["integral", "limit", "definition"]
42
+ },
43
+ {
44
+ id: "ftc",
45
+ name: "\u5FAE\u79EF\u5206\u57FA\u672C\u5B9A\u7406",
46
+ latex: "\\frac{d}{dx} \\int_{a}^{x} f(t) dt = f(x)",
47
+ category: "calculus",
48
+ description: "\u5FAE\u79EF\u5206\u57FA\u672C\u5B9A\u7406",
49
+ tags: ["integral", "derivative", "fundamental"]
50
+ },
51
+ {
52
+ id: "integration-by-parts",
53
+ name: "\u5206\u90E8\u79EF\u5206",
54
+ latex: "\\int u dv = uv - \\int v du",
55
+ category: "calculus",
56
+ description: "\u5206\u90E8\u79EF\u5206\u516C\u5F0F",
57
+ tags: ["integral", "by-parts"]
58
+ },
59
+ {
60
+ id: "taylor-series",
61
+ name: "\u6CF0\u52D2\u5C55\u5F00",
62
+ latex: "f(x) = \\sum_{n=0}^{\\infty} \\frac{f^{(n)}(a)}{n!} (x-a)^{n}",
63
+ category: "calculus",
64
+ description: "\u6CF0\u52D2\u7EA7\u6570\u5C55\u5F00",
65
+ tags: ["series", "taylor", "expansion"]
66
+ }
67
+ ];
68
+ var ALGEBRA_TEMPLATES = [
69
+ {
70
+ id: "quadratic-formula",
71
+ name: "\u6C42\u6839\u516C\u5F0F",
72
+ latex: "x = \\frac{-b \\pm \\sqrt{b^{2} - 4ac}}{2a}",
73
+ category: "algebra",
74
+ description: "\u4E00\u5143\u4E8C\u6B21\u65B9\u7A0B\u6C42\u6839\u516C\u5F0F",
75
+ tags: ["quadratic", "root"]
76
+ },
77
+ {
78
+ id: "discriminant",
79
+ name: "\u5224\u522B\u5F0F",
80
+ latex: "\\Delta = b^{2} - 4ac",
81
+ category: "algebra",
82
+ description: "\u4E8C\u6B21\u65B9\u7A0B\u5224\u522B\u5F0F",
83
+ tags: ["quadratic", "discriminant"]
84
+ },
85
+ {
86
+ id: "binomial-theorem",
87
+ name: "\u4E8C\u9879\u5F0F\u5B9A\u7406",
88
+ latex: "(a+b)^{n} = \\sum_{k=0}^{n} \\binom{n}{k} a^{n-k} b^{k}",
89
+ category: "algebra",
90
+ description: "\u4E8C\u9879\u5F0F\u5C55\u5F00",
91
+ tags: ["binomial", "theorem"]
92
+ },
93
+ {
94
+ id: "geometric-series",
95
+ name: "\u7B49\u6BD4\u6570\u5217\u6C42\u548C",
96
+ latex: "\\sum_{k=0}^{n-1} ar^{k} = a \\frac{1 - r^{n}}{1 - r}",
97
+ category: "algebra",
98
+ description: "\u7B49\u6BD4\u6570\u5217\u524D n \u9879\u548C",
99
+ tags: ["series", "geometric"]
100
+ },
101
+ {
102
+ id: "arithmetic-series",
103
+ name: "\u7B49\u5DEE\u6570\u5217\u6C42\u548C",
104
+ latex: "\\sum_{k=1}^{n} k = \\frac{n(n+1)}{2}",
105
+ category: "algebra",
106
+ description: "\u81EA\u7136\u6570\u6C42\u548C\u516C\u5F0F",
107
+ tags: ["series", "arithmetic"]
108
+ },
109
+ {
110
+ id: "log-properties",
111
+ name: "\u5BF9\u6570\u8FD0\u7B97",
112
+ latex: "\\log_{a}(xy) = \\log_{a}x + \\log_{a}y",
113
+ category: "algebra",
114
+ description: "\u5BF9\u6570\u4E58\u6CD5\u6027\u8D28",
115
+ tags: ["logarithm", "properties"]
116
+ },
117
+ {
118
+ id: "exp-log-inverse",
119
+ name: "\u6307\u6570\u4E0E\u5BF9\u6570",
120
+ latex: "a^{\\log_{a} x} = x",
121
+ category: "algebra",
122
+ description: "\u6307\u6570\u4E0E\u5BF9\u6570\u4E92\u4E3A\u9006\u8FD0\u7B97",
123
+ tags: ["logarithm", "exponential"]
124
+ }
125
+ ];
126
+ var TRIG_TEMPLATES = [
127
+ {
128
+ id: "pythagorean-id",
129
+ name: "\u6BD5\u8FBE\u54E5\u62C9\u65AF\u6052\u7B49\u5F0F",
130
+ latex: "\\sin^{2}\\theta + \\cos^{2}\\theta = 1",
131
+ category: "trigonometry",
132
+ description: "\u6BD5\u8FBE\u54E5\u62C9\u65AF\u6052\u7B49\u5F0F",
133
+ tags: ["sin", "cos", "identity"]
134
+ },
135
+ {
136
+ id: "sin-double-angle",
137
+ name: "\u6B63\u5F26\u500D\u89D2\u516C\u5F0F",
138
+ latex: "\\sin(2\\theta) = 2\\sin\\theta \\cos\\theta",
139
+ category: "trigonometry",
140
+ description: "\u6B63\u5F26\u500D\u89D2\u516C\u5F0F",
141
+ tags: ["sin", "double-angle"]
142
+ },
143
+ {
144
+ id: "cos-double-angle",
145
+ name: "\u4F59\u5F26\u500D\u89D2\u516C\u5F0F",
146
+ latex: "\\cos(2\\theta) = \\cos^{2}\\theta - \\sin^{2}\\theta",
147
+ category: "trigonometry",
148
+ description: "\u4F59\u5F26\u500D\u89D2\u516C\u5F0F",
149
+ tags: ["cos", "double-angle"]
150
+ },
151
+ {
152
+ id: "sin-sum",
153
+ name: "\u6B63\u5F26\u548C\u89D2\u516C\u5F0F",
154
+ latex: "\\sin(A+B) = \\sin A \\cos B + \\cos A \\sin B",
155
+ category: "trigonometry",
156
+ description: "\u6B63\u5F26\u548C\u89D2\u516C\u5F0F",
157
+ tags: ["sin", "sum", "angle"]
158
+ },
159
+ {
160
+ id: "cos-sum",
161
+ name: "\u4F59\u5F26\u548C\u89D2\u516C\u5F0F",
162
+ latex: "\\cos(A+B) = \\cos A \\cos B - \\sin A \\sin B",
163
+ category: "trigonometry",
164
+ description: "\u4F59\u5F26\u548C\u89D2\u516C\u5F0F",
165
+ tags: ["cos", "sum", "angle"]
166
+ },
167
+ {
168
+ id: "law-of-sines",
169
+ name: "\u6B63\u5F26\u5B9A\u7406",
170
+ latex: "\\frac{a}{\\sin A} = \\frac{b}{\\sin B} = \\frac{c}{\\sin C} = 2R",
171
+ category: "trigonometry",
172
+ description: "\u6B63\u5F26\u5B9A\u7406",
173
+ tags: ["law-of-sines", "triangle"]
174
+ },
175
+ {
176
+ id: "law-of-cosines",
177
+ name: "\u4F59\u5F26\u5B9A\u7406",
178
+ latex: "c^{2} = a^{2} + b^{2} - 2ab\\cos C",
179
+ category: "trigonometry",
180
+ description: "\u4F59\u5F26\u5B9A\u7406",
181
+ tags: ["law-of-cosines", "triangle"]
182
+ },
183
+ {
184
+ id: "euler-formula",
185
+ name: "\u6B27\u62C9\u516C\u5F0F",
186
+ latex: "e^{i\\theta} = \\cos\\theta + i\\sin\\theta",
187
+ category: "trigonometry",
188
+ description: "\u6B27\u62C9\u516C\u5F0F",
189
+ tags: ["euler", "complex"]
190
+ }
191
+ ];
192
+ var LINEAR_ALGEBRA_TEMPLATES = [
193
+ {
194
+ id: "matrix-mult",
195
+ name: "\u77E9\u9635\u4E58\u6CD5",
196
+ latex: "(AB)_{ij} = \\sum_{k=1}^{n} a_{ik} b_{kj}",
197
+ category: "linear-algebra",
198
+ description: "\u77E9\u9635\u4E58\u6CD5\u5B9A\u4E49",
199
+ tags: ["matrix", "multiplication"]
200
+ },
201
+ {
202
+ id: "det-2x2",
203
+ name: "\u4E8C\u9636\u884C\u5217\u5F0F",
204
+ latex: "\\det\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix} = ad - bc",
205
+ category: "linear-algebra",
206
+ description: "2\xD72 \u884C\u5217\u5F0F",
207
+ tags: ["determinant"]
208
+ },
209
+ {
210
+ id: "eigenvalue",
211
+ name: "\u7279\u5F81\u503C\u65B9\u7A0B",
212
+ latex: "A\\vec{v} = \\lambda \\vec{v}",
213
+ category: "linear-algebra",
214
+ description: "\u7279\u5F81\u503C\u4E0E\u7279\u5F81\u5411\u91CF",
215
+ tags: ["eigenvalue", "eigenvector"]
216
+ },
217
+ {
218
+ id: "cramers-rule",
219
+ name: "\u514B\u62C9\u9ED8\u6CD5\u5219",
220
+ latex: "x_i = \\frac{\\det(A_i)}{\\det(A)}",
221
+ category: "linear-algebra",
222
+ description: "\u89E3\u7EBF\u6027\u65B9\u7A0B\u7EC4",
223
+ tags: ["cramers-rule", "determinant"]
224
+ },
225
+ {
226
+ id: "vector-dot",
227
+ name: "\u5411\u91CF\u70B9\u79EF",
228
+ latex: "\\vec{a} \\cdot \\vec{b} = a_1 b_1 + a_2 b_2 + a_3 b_3",
229
+ category: "linear-algebra",
230
+ description: "\u70B9\u79EF",
231
+ tags: ["vector", "dot"]
232
+ },
233
+ {
234
+ id: "vector-cross",
235
+ name: "\u5411\u91CF\u53C9\u79EF",
236
+ latex: "\\vec{a} \\times \\vec{b} = \\begin{vmatrix} \\vec{i} & \\vec{j} & \\vec{k} \\\\ a_1 & a_2 & a_3 \\\\ b_1 & b_2 & b_3 \\end{vmatrix}",
237
+ category: "linear-algebra",
238
+ description: "\u4E09\u7EF4\u5411\u91CF\u53C9\u79EF",
239
+ tags: ["vector", "cross"]
240
+ }
241
+ ];
242
+ var STATS_TEMPLATES = [
243
+ {
244
+ id: "normal-dist",
245
+ name: "\u6B63\u6001\u5206\u5E03",
246
+ latex: "f(x) = \\frac{1}{\\sigma\\sqrt{2\\pi}} e^{-\\frac{(x-\\mu)^{2}}{2\\sigma^{2}}}",
247
+ category: "statistics",
248
+ description: "\u6B63\u6001\u5206\u5E03\u6982\u7387\u5BC6\u5EA6\u51FD\u6570",
249
+ tags: ["normal", "distribution", "gaussian"]
250
+ },
251
+ {
252
+ id: "bayes-theorem",
253
+ name: "\u8D1D\u53F6\u65AF\u5B9A\u7406",
254
+ latex: "P(A|B) = \\frac{P(B|A) \\cdot P(A)}{P(B)}",
255
+ category: "statistics",
256
+ description: "\u8D1D\u53F6\u65AF\u5B9A\u7406",
257
+ tags: ["bayes", "probability", "conditional"]
258
+ },
259
+ {
260
+ id: "expected-value",
261
+ name: "\u671F\u671B",
262
+ latex: "E[X] = \\sum_{i} x_i p_i",
263
+ category: "statistics",
264
+ description: "\u79BB\u6563\u671F\u671B",
265
+ tags: ["expected", "value"]
266
+ },
267
+ {
268
+ id: "variance",
269
+ name: "\u65B9\u5DEE",
270
+ latex: "Var(X) = E[(X - \\mu)^{2}] = E[X^{2}] - (E[X])^{2}",
271
+ category: "statistics",
272
+ description: "\u65B9\u5DEE\u516C\u5F0F",
273
+ tags: ["variance", "standard-deviation"]
274
+ }
275
+ ];
276
+ var PHYSICS_TEMPLATES = [
277
+ {
278
+ id: "einstein-emc2",
279
+ name: "\u8D28\u80FD\u65B9\u7A0B",
280
+ latex: "E = mc^{2}",
281
+ category: "physics",
282
+ description: "\u7231\u56E0\u65AF\u5766\u8D28\u80FD\u65B9\u7A0B",
283
+ tags: ["einstein", "energy", "mass"]
284
+ },
285
+ {
286
+ id: "newton-2nd",
287
+ name: "\u725B\u987F\u7B2C\u4E8C\u5B9A\u5F8B",
288
+ latex: "\\vec{F} = m\\vec{a}",
289
+ category: "physics",
290
+ description: "\u725B\u987F\u7B2C\u4E8C\u5B9A\u5F8B",
291
+ tags: ["newton", "force", "acceleration"]
292
+ },
293
+ {
294
+ id: "schrodinger",
295
+ name: "\u859B\u5B9A\u8C14\u65B9\u7A0B",
296
+ latex: "i\\hbar \\frac{\\partial}{\\partial t} \\Psi = \\hat{H} \\Psi",
297
+ category: "physics",
298
+ description: "\u542B\u65F6\u859B\u5B9A\u8C14\u65B9\u7A0B",
299
+ tags: ["quantum", "schrodinger"]
300
+ },
301
+ {
302
+ id: "maxwell-faraday",
303
+ name: "\u6CD5\u62C9\u7B2C\u5B9A\u5F8B",
304
+ latex: "\\nabla \\times \\vec{E} = -\\frac{\\partial\\vec{B}}{\\partial t}",
305
+ category: "physics",
306
+ description: "\u9EA6\u514B\u65AF\u97E6-\u6CD5\u62C9\u7B2C\u65B9\u7A0B",
307
+ tags: ["maxwell", "electromagnetism"]
308
+ },
309
+ {
310
+ id: "gravitation",
311
+ name: "\u4E07\u6709\u5F15\u529B",
312
+ latex: "F = G \\frac{m_1 m_2}{r^{2}}",
313
+ category: "physics",
314
+ description: "\u725B\u987F\u4E07\u6709\u5F15\u529B\u5B9A\u5F8B",
315
+ tags: ["newton", "gravitation"]
316
+ }
317
+ ];
318
+ var ALL_MATH_TEMPLATES = [
319
+ ...CALCULUS_TEMPLATES,
320
+ ...ALGEBRA_TEMPLATES,
321
+ ...TRIG_TEMPLATES,
322
+ ...LINEAR_ALGEBRA_TEMPLATES,
323
+ ...STATS_TEMPLATES,
324
+ ...PHYSICS_TEMPLATES
325
+ ];
326
+ function getTemplatesByCategory(category) {
327
+ return ALL_MATH_TEMPLATES.filter((t) => t.category === category);
328
+ }
329
+ function searchTemplates(query) {
330
+ const q = query.toLowerCase();
331
+ return ALL_MATH_TEMPLATES.filter(
332
+ (t) => t.name.toLowerCase().includes(q) || t.description.toLowerCase().includes(q) || t.tags.some((tag) => tag.toLowerCase().includes(q))
333
+ );
334
+ }
335
+ function getTemplateById(id) {
336
+ return ALL_MATH_TEMPLATES.find((t) => t.id === id);
337
+ }
338
+
339
+ // src/chem-templates.ts
340
+ var COMPOUND_TEMPLATES = [
341
+ // 无机酸
342
+ { id: "h2o", name: "\u6C34", latex: "\\ce{H2O}", category: "compound", description: "\u6C34", tags: ["water", "inorganic"] },
343
+ { id: "h2so4", name: "\u786B\u9178", latex: "\\ce{H2SO4}", category: "compound", description: "\u786B\u9178", tags: ["acid", "strong"] },
344
+ { id: "hcl", name: "\u76D0\u9178", latex: "\\ce{HCl}", category: "compound", description: "\u76D0\u9178 / \u6C2F\u5316\u6C22", tags: ["acid", "strong"] },
345
+ { id: "hno3", name: "\u785D\u9178", latex: "\\ce{HNO3}", category: "compound", description: "\u785D\u9178", tags: ["acid", "strong"] },
346
+ { id: "h3po4", name: "\u78F7\u9178", latex: "\\ce{H3PO4}", category: "compound", description: "\u78F7\u9178", tags: ["acid"] },
347
+ { id: "naoh", name: "\u6C22\u6C27\u5316\u94A0", latex: "\\ce{NaOH}", category: "compound", description: "\u6C22\u6C27\u5316\u94A0 / \u70E7\u78B1", tags: ["base", "strong"] },
348
+ { id: "caoh2", name: "\u6C22\u6C27\u5316\u9499", latex: "\\ce{Ca(OH)2}", category: "compound", description: "\u6C22\u6C27\u5316\u9499 / \u719F\u77F3\u7070", tags: ["base"] },
349
+ // 盐
350
+ { id: "nacl", name: "\u6C2F\u5316\u94A0", latex: "\\ce{NaCl}", category: "compound", description: "\u98DF\u76D0 / \u6C2F\u5316\u94A0", tags: ["salt", "table"] },
351
+ { id: "na2co3", name: "\u78B3\u9178\u94A0", latex: "\\ce{Na2CO3}", category: "compound", description: "\u7EAF\u78B1 / \u78B3\u9178\u94A0", tags: ["salt", "soda"] },
352
+ { id: "nahco3", name: "\u78B3\u9178\u6C22\u94A0", latex: "\\ce{NaHCO3}", category: "compound", description: "\u5C0F\u82CF\u6253", tags: ["salt", "baking"] },
353
+ { id: "caco3", name: "\u78B3\u9178\u9499", latex: "\\ce{CaCO3}", category: "compound", description: "\u77F3\u7070\u77F3 / \u5927\u7406\u77F3", tags: ["salt", "limestone"] },
354
+ { id: "caso4", name: "\u786B\u9178\u9499", latex: "\\ce{CaSO4}", category: "compound", description: "\u77F3\u818F", tags: ["salt", "gypsum"] },
355
+ // 氧化物
356
+ { id: "co2", name: "\u4E8C\u6C27\u5316\u78B3", latex: "\\ce{CO2}", category: "compound", description: "\u4E8C\u6C27\u5316\u78B3", tags: ["oxide", "gas"] },
357
+ { id: "fe2o3", name: "\u6C27\u5316\u94C1", latex: "\\ce{Fe2O3}", category: "compound", description: "\u94C1\u9508 / \u8D64\u94C1\u77FF", tags: ["oxide", "rust"] },
358
+ { id: "al2o3", name: "\u6C27\u5316\u94DD", latex: "\\ce{Al2O3}", category: "compound", description: "\u6C27\u5316\u94DD", tags: ["oxide"] },
359
+ { id: "sio2", name: "\u4E8C\u6C27\u5316\u7845", latex: "\\ce{SiO2}", category: "compound", description: "\u77F3\u82F1 / \u4E8C\u6C27\u5316\u7845", tags: ["oxide", "quartz"] },
360
+ // 有机物
361
+ { id: "ch4", name: "\u7532\u70F7", latex: "\\ce{CH4}", category: "compound", description: "\u7532\u70F7 / \u5929\u7136\u6C14", tags: ["organic", "alkane"] },
362
+ { id: "c2h5oh", name: "\u4E59\u9187", latex: "\\ce{C2H5OH}", category: "compound", description: "\u9152\u7CBE / \u4E59\u9187", tags: ["organic", "alcohol"] },
363
+ { id: "c6h12o6", name: "\u8461\u8404\u7CD6", latex: "\\ce{C6H12O6}", category: "compound", description: "\u8461\u8404\u7CD6", tags: ["organic", "sugar"] },
364
+ { id: "ch3cooh", name: "\u4E59\u9178", latex: "\\ce{CH3COOH}", category: "compound", description: "\u918B\u9178", tags: ["organic", "acid"] }
365
+ ];
366
+ var REACTION_TEMPLATES = [
367
+ {
368
+ id: "neutralization",
369
+ name: "\u4E2D\u548C\u53CD\u5E94",
370
+ latex: "\\ce{HCl + NaOH -> NaCl + H2O}",
371
+ category: "reaction",
372
+ description: "\u9178\u78B1\u4E2D\u548C",
373
+ tags: ["neutralization", "acid-base"]
374
+ },
375
+ {
376
+ id: "combustion-methane",
377
+ name: "\u7532\u70F7\u71C3\u70E7",
378
+ latex: "\\ce{CH4 + 2O2 -> CO2 + 2H2O}",
379
+ category: "reaction",
380
+ description: "\u7532\u70F7\u5B8C\u5168\u71C3\u70E7",
381
+ tags: ["combustion", "organic"]
382
+ },
383
+ {
384
+ id: "photosynthesis",
385
+ name: "\u5149\u5408\u4F5C\u7528",
386
+ latex: "\\ce{6CO2 + 6H2O ->[\u5149] C6H12O6 + 6O2}",
387
+ category: "reaction",
388
+ description: "\u5149\u5408\u4F5C\u7528\u603B\u53CD\u5E94\u5F0F",
389
+ tags: ["photosynthesis", "biology"]
390
+ },
391
+ {
392
+ id: "respiration",
393
+ name: "\u7EC6\u80DE\u547C\u5438",
394
+ latex: "\\ce{C6H12O6 + 6O2 -> 6CO2 + 6H2O + \u80FD\u91CF}",
395
+ category: "reaction",
396
+ description: "\u6709\u6C27\u547C\u5438\u603B\u53CD\u5E94\u5F0F",
397
+ tags: ["respiration", "biology"]
398
+ },
399
+ {
400
+ id: "rust-iron",
401
+ name: "\u94C1\u751F\u9508",
402
+ latex: "\\ce{4Fe + 3O2 + 6H2O -> 4Fe(OH)3}",
403
+ category: "reaction",
404
+ description: "\u94C1\u5728\u6C34\u548C\u6C27\u6C14\u4E2D\u751F\u9508",
405
+ tags: ["rust", "oxidation"]
406
+ },
407
+ {
408
+ id: "electrolysis-water",
409
+ name: "\u7535\u89E3\u6C34",
410
+ latex: "\\ce{2H2O ->[\u7535\u89E3] 2H2 ^ + O2 ^}",
411
+ category: "reaction",
412
+ description: "\u7535\u89E3\u6C34\u5236\u6C22",
413
+ tags: ["electrolysis", "water"]
414
+ },
415
+ {
416
+ id: "haber-process",
417
+ name: "\u54C8\u67CF\u6CD5",
418
+ latex: "\\ce{N2 + 3H2 <=>[Fe][\u9AD8\u6E29\u9AD8\u538B] 2NH3}",
419
+ category: "reaction",
420
+ description: "\u5408\u6210\u6C28",
421
+ tags: ["haber", "ammonia", "industrial"]
422
+ },
423
+ {
424
+ id: "equilibrium",
425
+ name: "\u5316\u5B66\u5E73\u8861",
426
+ latex: "\\ce{aA + bB <=> cC + dD}",
427
+ category: "reaction",
428
+ description: "\u53EF\u9006\u53CD\u5E94\u901A\u7528\u5F0F",
429
+ tags: ["equilibrium", "reversible"]
430
+ }
431
+ ];
432
+ var ELECTROCHEM_TEMPLATES = [
433
+ {
434
+ id: "nernst-equation",
435
+ name: "\u80FD\u65AF\u7279\u65B9\u7A0B",
436
+ latex: "E = E^{\\circ} - \\frac{RT}{nF} \\ln Q",
437
+ category: "electrochemistry",
438
+ description: "\u80FD\u65AF\u7279\u65B9\u7A0B",
439
+ tags: ["nernst", "potential"]
440
+ },
441
+ {
442
+ id: "faraday-law",
443
+ name: "\u6CD5\u62C9\u7B2C\u7535\u89E3\u5B9A\u5F8B",
444
+ latex: "m = \\frac{MIt}{nF}",
445
+ category: "electrochemistry",
446
+ description: "\u6CD5\u62C9\u7B2C\u7535\u89E3\u7B2C\u4E00\u5B9A\u5F8B",
447
+ tags: ["faraday", "electrolysis"]
448
+ }
449
+ ];
450
+ var ALL_CHEM_TEMPLATES = [
451
+ ...COMPOUND_TEMPLATES,
452
+ ...REACTION_TEMPLATES,
453
+ ...ELECTROCHEM_TEMPLATES
454
+ ];
455
+ function searchCompounds(query) {
456
+ const q = query.toLowerCase();
457
+ return COMPOUND_TEMPLATES.filter(
458
+ (t) => t.name.toLowerCase().includes(q) || t.latex.toLowerCase().includes(q) || t.tags.some((tag) => tag.toLowerCase().includes(q))
459
+ );
460
+ }
461
+ function getAcids() {
462
+ return COMPOUND_TEMPLATES.filter((t) => t.tags.includes("acid"));
463
+ }
464
+ function getBases() {
465
+ return COMPOUND_TEMPLATES.filter((t) => t.tags.includes("base"));
466
+ }
467
+
468
+ // src/greek-presets.ts
469
+ var GREEK_LOWERCASE_GROUP = {
470
+ id: "greek-lowercase",
471
+ label: "Greek Lowercase (\u5C0F\u5199)",
472
+ letters: [
473
+ { latex: "\\alpha", unicode: "\u03B1", name: "Alpha", englishName: "alpha" },
474
+ { latex: "\\beta", unicode: "\u03B2", name: "Beta", englishName: "beta" },
475
+ { latex: "\\gamma", unicode: "\u03B3", name: "Gamma", englishName: "gamma" },
476
+ { latex: "\\delta", unicode: "\u03B4", name: "Delta", englishName: "delta" },
477
+ { latex: "\\epsilon", unicode: "\u03B5", name: "Epsilon", englishName: "epsilon", variants: [
478
+ { latex: "\\varepsilon", unicode: "\u03B5", name: "Epsilon (var)" }
479
+ ] },
480
+ { latex: "\\zeta", unicode: "\u03B6", name: "Zeta", englishName: "zeta" },
481
+ { latex: "\\eta", unicode: "\u03B7", name: "Eta", englishName: "eta" },
482
+ { latex: "\\theta", unicode: "\u03B8", name: "Theta", englishName: "theta", variants: [
483
+ { latex: "\\vartheta", unicode: "\u03D1", name: "Theta (var)" }
484
+ ] },
485
+ { latex: "\\iota", unicode: "\u03B9", name: "Iota", englishName: "iota" },
486
+ { latex: "\\kappa", unicode: "\u03BA", name: "Kappa", englishName: "kappa" },
487
+ { latex: "\\lambda", unicode: "\u03BB", name: "Lambda", englishName: "lambda" },
488
+ { latex: "\\mu", unicode: "\u03BC", name: "Mu", englishName: "mu" },
489
+ { latex: "\\nu", unicode: "\u03BD", name: "Nu", englishName: "nu" },
490
+ { latex: "\\xi", unicode: "\u03BE", name: "Xi", englishName: "xi" },
491
+ { latex: "\\omicron", unicode: "\u03BF", name: "Omicron", englishName: "omicron" },
492
+ { latex: "\\pi", unicode: "\u03C0", name: "Pi", englishName: "pi", variants: [
493
+ { latex: "\\varpi", unicode: "\u03D6", name: "Pi (var)" }
494
+ ] },
495
+ { latex: "\\rho", unicode: "\u03C1", name: "Rho", englishName: "rho", variants: [
496
+ { latex: "\\varrho", unicode: "\u03F1", name: "Rho (var)" }
497
+ ] },
498
+ { latex: "\\sigma", unicode: "\u03C3", name: "Sigma", englishName: "sigma", variants: [
499
+ { latex: "\\varsigma", unicode: "\u03C2", name: "Sigma (final)" }
500
+ ] },
501
+ { latex: "\\tau", unicode: "\u03C4", name: "Tau", englishName: "tau" },
502
+ { latex: "\\upsilon", unicode: "\u03C5", name: "Upsilon", englishName: "upsilon" },
503
+ { latex: "\\phi", unicode: "\u03C6", name: "Phi", englishName: "phi", variants: [
504
+ { latex: "\\varphi", unicode: "\u03D5", name: "Phi (var)" }
505
+ ] },
506
+ { latex: "\\chi", unicode: "\u03C7", name: "Chi", englishName: "chi" },
507
+ { latex: "\\psi", unicode: "\u03C8", name: "Psi", englishName: "psi" },
508
+ { latex: "\\omega", unicode: "\u03C9", name: "Omega", englishName: "omega" }
509
+ ]
510
+ };
511
+ var GREEK_UPPERCASE_GROUP = {
512
+ id: "greek-uppercase",
513
+ label: "Greek Uppercase (\u5927\u5199)",
514
+ letters: [
515
+ { latex: "\\Gamma", unicode: "\u0393", name: "Gamma", englishName: "Gamma" },
516
+ { latex: "\\Delta", unicode: "\u0394", name: "Delta", englishName: "Delta" },
517
+ { latex: "\\Theta", unicode: "\u0398", name: "Theta", englishName: "Theta" },
518
+ { latex: "\\Lambda", unicode: "\u039B", name: "Lambda", englishName: "Lambda" },
519
+ { latex: "\\Xi", unicode: "\u039E", name: "Xi", englishName: "Xi" },
520
+ { latex: "\\Pi", unicode: "\u03A0", name: "Pi", englishName: "Pi" },
521
+ { latex: "\\Sigma", unicode: "\u03A3", name: "Sigma", englishName: "Sigma" },
522
+ { latex: "\\Upsilon", unicode: "\u03A5", name: "Upsilon", englishName: "Upsilon" },
523
+ { latex: "\\Phi", unicode: "\u03A6", name: "Phi", englishName: "Phi" },
524
+ { latex: "\\Psi", unicode: "\u03A8", name: "Psi", englishName: "Psi" },
525
+ { latex: "\\Omega", unicode: "\u03A9", name: "Omega", englishName: "Omega" }
526
+ ]
527
+ };
528
+ var GREEK_GROUPS = [
529
+ GREEK_LOWERCASE_GROUP,
530
+ GREEK_UPPERCASE_GROUP
531
+ ];
532
+ var ALL_GREEK = [
533
+ ...GREEK_LOWERCASE_GROUP.letters,
534
+ ...GREEK_UPPERCASE_GROUP.letters
535
+ ];
536
+ function searchGreek(query) {
537
+ const q = query.toLowerCase();
538
+ return ALL_GREEK.filter(
539
+ (l) => l.name.toLowerCase().includes(q) || l.englishName.toLowerCase().includes(q) || l.latex.toLowerCase().includes(q)
540
+ );
541
+ }
542
+ function searchGreekWithVariants(query) {
543
+ const q = query.toLowerCase();
544
+ const results = searchGreek(query);
545
+ for (const letter of ALL_GREEK) {
546
+ if (!letter.variants) continue;
547
+ for (const v of letter.variants) {
548
+ if (v.name.toLowerCase().includes(q) || v.latex.toLowerCase().includes(q)) {
549
+ if (!results.some((r) => r.latex === letter.latex)) {
550
+ results.push(letter);
551
+ }
552
+ break;
553
+ }
554
+ }
555
+ }
556
+ return results;
557
+ }
558
+ export {
559
+ ALGEBRA_TEMPLATES,
560
+ ALL_CHEM_TEMPLATES,
561
+ ALL_GREEK,
562
+ ALL_MATH_TEMPLATES,
563
+ CALCULUS_TEMPLATES,
564
+ COMPOUND_TEMPLATES,
565
+ ELECTROCHEM_TEMPLATES,
566
+ GREEK_GROUPS,
567
+ GREEK_LOWERCASE_GROUP,
568
+ GREEK_UPPERCASE_GROUP,
569
+ LINEAR_ALGEBRA_TEMPLATES,
570
+ PHYSICS_TEMPLATES,
571
+ REACTION_TEMPLATES,
572
+ STATS_TEMPLATES,
573
+ TRIG_TEMPLATES,
574
+ getAcids,
575
+ getBases,
576
+ getTemplateById,
577
+ getTemplatesByCategory,
578
+ searchCompounds,
579
+ searchGreek,
580
+ searchGreekWithVariants,
581
+ searchTemplates
582
+ };
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@sciexpr/presets",
3
+ "version": "0.1.0",
4
+ "description": "Scientific Expression Engine - Preset templates library (math formulas, chemical reactions, Greek letters)",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "sideEffects": false,
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "keywords": [
21
+ "scientific",
22
+ "expression",
23
+ "presets",
24
+ "templates",
25
+ "math",
26
+ "chemistry",
27
+ "formula"
28
+ ],
29
+ "license": "MIT",
30
+ "author": {
31
+ "name": "haoguodong09-svg",
32
+ "email": "haoguodong09@gmail.com"
33
+ },
34
+ "homepage": "https://github.com/haoguodong09-svg/scientific-expression-engine#readme",
35
+ "bugs": {
36
+ "url": "https://github.com/haoguodong09-svg/scientific-expression-engine/issues"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/haoguodong09-svg/scientific-expression-engine",
41
+ "directory": "packages/presets"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "dependencies": {
47
+ "@sciexpr/math": "0.1.0",
48
+ "@sciexpr/core": "0.1.0"
49
+ },
50
+ "devDependencies": {
51
+ "tsup": "^8.0.0",
52
+ "typescript": "^5.5.0",
53
+ "vitest": "^2.0.0",
54
+ "rimraf": "^5.0.0"
55
+ },
56
+ "scripts": {
57
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
58
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
59
+ "lint": "tsc --noEmit",
60
+ "clean": "rimraf dist",
61
+ "test": "vitest run"
62
+ }
63
+ }