eny-ai 1.0.0 → 2.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.
- package/V2_README.md +414 -0
- package/dist/chunk-2NUS77CI.js +195 -0
- package/dist/chunk-5KPALVCK.js +280 -0
- package/dist/{chunk-2WFUL4XJ.js → chunk-5PZUUNHS.js} +717 -751
- package/dist/{chunk-E4KJZEXX.js → chunk-AJH2I5ZI.js} +5 -0
- package/dist/chunk-LVJ3GJRQ.js +360 -0
- package/dist/{chunk-PNKVD2UK.js → chunk-MXA7TAAG.js} +11 -1
- package/dist/cli.js +5 -4
- package/dist/firebase.cjs +296 -0
- package/dist/firebase.d.cts +136 -0
- package/dist/firebase.d.ts +136 -0
- package/dist/firebase.js +17 -0
- package/dist/hooks.cjs +236 -0
- package/dist/hooks.d.cts +184 -0
- package/dist/hooks.d.ts +184 -0
- package/dist/hooks.js +31 -0
- package/dist/index.cjs +1622 -1092
- package/dist/index.d.cts +16 -195
- package/dist/index.d.ts +16 -195
- package/dist/index.js +68 -262
- package/dist/runtime.cjs +366 -0
- package/dist/runtime.d.cts +229 -0
- package/dist/runtime.d.ts +229 -0
- package/dist/runtime.js +25 -0
- package/dist/symbols.js +2 -2
- package/examples/app-simbolico-completo.tsx +249 -0
- package/examples/nextjs-integration.tsx +446 -0
- package/examples/v2-demo.tsx +377 -0
- package/package.json +23 -11
- package/dist/react/index.cjs +0 -342
- package/dist/react/index.d.cts +0 -751
- package/dist/react/index.d.ts +0 -751
- package/dist/react/index.js +0 -284
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__esm,
|
|
3
|
+
__export,
|
|
4
|
+
init_esm_shims
|
|
5
|
+
} from "./chunk-MXA7TAAG.js";
|
|
6
|
+
|
|
7
|
+
// src/runtime.ts
|
|
8
|
+
var runtime_exports = {};
|
|
9
|
+
__export(runtime_exports, {
|
|
10
|
+
ENYRuntime: () => ENYRuntime,
|
|
11
|
+
eny: () => eny,
|
|
12
|
+
filterArray: () => filterArray,
|
|
13
|
+
func: () => func,
|
|
14
|
+
lambda: () => lambda,
|
|
15
|
+
mapArray: () => mapArray,
|
|
16
|
+
reduceArray: () => reduceArray,
|
|
17
|
+
state: () => state,
|
|
18
|
+
substate: () => substate
|
|
19
|
+
});
|
|
20
|
+
var ENYRuntime, eny, state, substate, func, lambda, mapArray, filterArray, reduceArray;
|
|
21
|
+
var init_runtime = __esm({
|
|
22
|
+
"src/runtime.ts"() {
|
|
23
|
+
init_esm_shims();
|
|
24
|
+
ENYRuntime = class {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.context = {};
|
|
27
|
+
this.hooks = /* @__PURE__ */ new Map();
|
|
28
|
+
this.effects = [];
|
|
29
|
+
// ════════════════════════════════════════════════════════════════
|
|
30
|
+
// SÍMBOLOS HTTP/ASYNC
|
|
31
|
+
// ════════════════════════════════════════════════════════════════
|
|
32
|
+
/**
|
|
33
|
+
* http - HTTP methods
|
|
34
|
+
* http.GET(url), http.POST(url, data), etc
|
|
35
|
+
* Alias: ⇄
|
|
36
|
+
*/
|
|
37
|
+
this.http = {
|
|
38
|
+
GET: async (url) => {
|
|
39
|
+
const res = await fetch(url);
|
|
40
|
+
return res.json();
|
|
41
|
+
},
|
|
42
|
+
POST: async (url, data) => {
|
|
43
|
+
const res = await fetch(url, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { "Content-Type": "application/json" },
|
|
46
|
+
body: JSON.stringify(data)
|
|
47
|
+
});
|
|
48
|
+
return res.json();
|
|
49
|
+
},
|
|
50
|
+
PUT: async (url, data) => {
|
|
51
|
+
const res = await fetch(url, {
|
|
52
|
+
method: "PUT",
|
|
53
|
+
headers: { "Content-Type": "application/json" },
|
|
54
|
+
body: JSON.stringify(data)
|
|
55
|
+
});
|
|
56
|
+
return res.json();
|
|
57
|
+
},
|
|
58
|
+
DELETE: async (url) => {
|
|
59
|
+
const res = await fetch(url, { method: "DELETE" });
|
|
60
|
+
return res.json();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
// ════════════════════════════════════════════════════════════════
|
|
64
|
+
// SÍMBOLOS MEMÓRIA/STORAGE
|
|
65
|
+
// ════════════════════════════════════════════════════════════════
|
|
66
|
+
/**
|
|
67
|
+
* storage - Memory/Storage access
|
|
68
|
+
* storage.get(key), storage.set(key, value)
|
|
69
|
+
* Alias: 𝓜
|
|
70
|
+
*/
|
|
71
|
+
this.storage = {
|
|
72
|
+
get: (key) => localStorage.getItem(key),
|
|
73
|
+
set: (key, value) => localStorage.setItem(key, JSON.stringify(value)),
|
|
74
|
+
remove: (key) => localStorage.removeItem(key),
|
|
75
|
+
clear: () => localStorage.clear(),
|
|
76
|
+
session: {
|
|
77
|
+
get: (key) => sessionStorage.getItem(key),
|
|
78
|
+
set: (key, value) => sessionStorage.setItem(key, JSON.stringify(value))
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// ════════════════════════════════════════════════════════════════
|
|
82
|
+
// SÍMBOLOS SEGURANÇA
|
|
83
|
+
// ════════════════════════════════════════════════════════════════
|
|
84
|
+
/**
|
|
85
|
+
* validate - Validation helpers
|
|
86
|
+
* validate.email(str), validate.min(len)
|
|
87
|
+
* Alias: 🛡
|
|
88
|
+
*/
|
|
89
|
+
this.validate = {
|
|
90
|
+
email: (str) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(str),
|
|
91
|
+
min: (len) => (str) => str.length >= len,
|
|
92
|
+
max: (len) => (str) => str.length <= len,
|
|
93
|
+
regex: (pattern) => (str) => pattern.test(str),
|
|
94
|
+
required: (val) => val != null && val !== "",
|
|
95
|
+
equals: (expected) => (actual) => actual === expected
|
|
96
|
+
};
|
|
97
|
+
this.crypto = {
|
|
98
|
+
lock: (obj) => Object.freeze(obj),
|
|
99
|
+
unlock: (obj) => Object.assign({}, obj)
|
|
100
|
+
};
|
|
101
|
+
// ════════════════════════════════════════════════════════════════
|
|
102
|
+
// SÍMBOLOS NAVEGAÇÃO
|
|
103
|
+
// ════════════════════════════════════════════════════════════════
|
|
104
|
+
/**
|
|
105
|
+
* router - Router/Navigation
|
|
106
|
+
* router.navigate(path), router.back()
|
|
107
|
+
* Alias: 🧭
|
|
108
|
+
*/
|
|
109
|
+
this.router = {
|
|
110
|
+
navigate: (path) => window.location.href = path,
|
|
111
|
+
back: () => window.history.back(),
|
|
112
|
+
forward: () => window.history.forward(),
|
|
113
|
+
reload: () => window.location.reload(),
|
|
114
|
+
params: () => new URLSearchParams(window.location.search)
|
|
115
|
+
};
|
|
116
|
+
// ════════════════════════════════════════════════════════════════
|
|
117
|
+
// SISTEMA DE LOGS
|
|
118
|
+
// ════════════════════════════════════════════════════════════════
|
|
119
|
+
/**
|
|
120
|
+
* logger - Logging system
|
|
121
|
+
* logger.info(msg), logger.error(msg), logger.warn(msg)
|
|
122
|
+
* Alias: 📜
|
|
123
|
+
*/
|
|
124
|
+
this.logger = {
|
|
125
|
+
info: (msg, data) => console.log(`\u2139\uFE0F ${msg}`, data),
|
|
126
|
+
error: (msg, data) => console.error(`\u274C ${msg}`, data),
|
|
127
|
+
warn: (msg, data) => console.warn(`\u26A0\uFE0F ${msg}`, data),
|
|
128
|
+
log: (msg, data) => console.log(`\u{1F4DC} ${msg}`, data)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// ════════════════════════════════════════════════════════════════
|
|
132
|
+
// SÍMBOLOS BÁSICOS - ESTADO
|
|
133
|
+
// ════════════════════════════════════════════════════════════════
|
|
134
|
+
/**
|
|
135
|
+
* Σ - Cria estado global
|
|
136
|
+
* Σ('user', { name: 'João' })
|
|
137
|
+
*/
|
|
138
|
+
\u03A3(key, initialValue) {
|
|
139
|
+
if (!this.context[key]) {
|
|
140
|
+
this.context[key] = initialValue;
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
get: () => this.context[key],
|
|
144
|
+
set: (value) => {
|
|
145
|
+
this.context[key] = value;
|
|
146
|
+
this.notify();
|
|
147
|
+
},
|
|
148
|
+
value: this.context[key]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* σ - Sub-estado (local)
|
|
153
|
+
* σ(parent, 'field')
|
|
154
|
+
*/
|
|
155
|
+
\u03C3(parent, field) {
|
|
156
|
+
return {
|
|
157
|
+
get: () => parent[field],
|
|
158
|
+
set: (value) => {
|
|
159
|
+
parent[field] = value;
|
|
160
|
+
},
|
|
161
|
+
value: parent[field]
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* ⊤ e ⊥ - Booleanos
|
|
166
|
+
*/
|
|
167
|
+
get TRUE() {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
get FALSE() {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
// Aliases simbólicos para compatibilidade
|
|
174
|
+
get trueValue() {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
get falseValue() {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Ø - Nulo/Vazio
|
|
182
|
+
*/
|
|
183
|
+
get \u00D8() {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
// ════════════════════════════════════════════════════════════════
|
|
187
|
+
// SÍMBOLOS FUNCIONAIS - FUNÇÕES
|
|
188
|
+
// ════════════════════════════════════════════════════════════════
|
|
189
|
+
/**
|
|
190
|
+
* func - Define função normal
|
|
191
|
+
* func('myFunc', (a, b) => a + b)
|
|
192
|
+
*/
|
|
193
|
+
func(name, fn) {
|
|
194
|
+
const wrapped = fn;
|
|
195
|
+
this.context[name] = wrapped;
|
|
196
|
+
return wrapped;
|
|
197
|
+
}
|
|
198
|
+
// Alias: ƒ
|
|
199
|
+
get \u0192() {
|
|
200
|
+
return this.func.bind(this);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* lambda - Arrow function/Lambda
|
|
204
|
+
* lambda(fn) - wraps e memoiza
|
|
205
|
+
*/
|
|
206
|
+
lambda(fn) {
|
|
207
|
+
return fn;
|
|
208
|
+
}
|
|
209
|
+
// Alias: λ
|
|
210
|
+
get \u03BB() {
|
|
211
|
+
return this.lambda.bind(this);
|
|
212
|
+
}
|
|
213
|
+
// ════════════════════════════════════════════════════════════════
|
|
214
|
+
// SÍMBOLOS DE ARRAY - ITERAÇÃO
|
|
215
|
+
// ════════════════════════════════════════════════════════════════
|
|
216
|
+
/**
|
|
217
|
+
* map - Map operator
|
|
218
|
+
* arr.map((item) => item * 2)
|
|
219
|
+
* Alias: ↦
|
|
220
|
+
*/
|
|
221
|
+
map(arr, fn) {
|
|
222
|
+
return arr.map((item) => fn(item));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* filter - Filter operator
|
|
226
|
+
* arr.filter((item) => item > 5)
|
|
227
|
+
* Alias: ⊳
|
|
228
|
+
*/
|
|
229
|
+
filter(arr, predicate) {
|
|
230
|
+
return arr.filter((item) => predicate(item));
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* reduce - Reduce operator
|
|
234
|
+
* arr.reduce((acc, item) => acc + item, 0)
|
|
235
|
+
* Alias: ⊲
|
|
236
|
+
*/
|
|
237
|
+
reduce(arr, reducer, initial = 0) {
|
|
238
|
+
return arr.reduce((acc, item) => reducer(acc, item), initial);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* find - Find operator
|
|
242
|
+
* arr.find((item) => item.id === 5)
|
|
243
|
+
* Alias: ⊙
|
|
244
|
+
*/
|
|
245
|
+
find(arr, predicate) {
|
|
246
|
+
return arr.find((item) => predicate(item));
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* every - Every operator
|
|
250
|
+
* arr.every((item) => item > 0)
|
|
251
|
+
* Alias: ∀
|
|
252
|
+
*/
|
|
253
|
+
every(arr, predicate) {
|
|
254
|
+
return arr.every((item) => predicate(item));
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* some - Some operator
|
|
258
|
+
* arr.some((item) => item > 0)
|
|
259
|
+
* Alias: ∃
|
|
260
|
+
*/
|
|
261
|
+
some(arr, predicate) {
|
|
262
|
+
return arr.some((item) => predicate(item));
|
|
263
|
+
}
|
|
264
|
+
// ════════════════════════════════════════════════════════════════
|
|
265
|
+
// SÍMBOLOS OPERADORES
|
|
266
|
+
// ════════════════════════════════════════════════════════════════
|
|
267
|
+
/**
|
|
268
|
+
* assign - Assignment operator
|
|
269
|
+
* Alias: ←
|
|
270
|
+
*/
|
|
271
|
+
assign(target, value) {
|
|
272
|
+
return value;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* and - AND operator
|
|
276
|
+
* Alias: ∧
|
|
277
|
+
*/
|
|
278
|
+
and(a, b) {
|
|
279
|
+
return a && b;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* or - OR operator
|
|
283
|
+
* Alias: ∨
|
|
284
|
+
*/
|
|
285
|
+
or(a, b) {
|
|
286
|
+
return a || b;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* not - NOT operator
|
|
290
|
+
* Alias: ¬
|
|
291
|
+
*/
|
|
292
|
+
not(a) {
|
|
293
|
+
return !a;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* merge - Merge/Spread operator
|
|
297
|
+
* Alias: ⊕
|
|
298
|
+
*/
|
|
299
|
+
merge(...objs) {
|
|
300
|
+
return Object.assign({}, ...objs);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* encode - Basic encoding/decoding
|
|
304
|
+
* Alias: 🔑 🔒 🔓
|
|
305
|
+
*/
|
|
306
|
+
encode(data) {
|
|
307
|
+
return btoa(data);
|
|
308
|
+
}
|
|
309
|
+
// ════════════════════════════════════════════════════════════════
|
|
310
|
+
// INTERNALS
|
|
311
|
+
// ════════════════════════════════════════════════════════════════
|
|
312
|
+
notify() {
|
|
313
|
+
this.effects.forEach((effect) => effect());
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* effect - Register effect function
|
|
317
|
+
* Alias: ⚡
|
|
318
|
+
*/
|
|
319
|
+
effect(fn, deps = []) {
|
|
320
|
+
this.effects.push(() => fn());
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Obter todo contexto
|
|
324
|
+
*/
|
|
325
|
+
getContext() {
|
|
326
|
+
return { ...this.context };
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Limpar runtime
|
|
330
|
+
*/
|
|
331
|
+
clear() {
|
|
332
|
+
this.context = {};
|
|
333
|
+
this.hooks.clear();
|
|
334
|
+
this.effects = [];
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
eny = new ENYRuntime();
|
|
338
|
+
state = eny.\u03A3.bind(eny);
|
|
339
|
+
substate = eny.\u03C3.bind(eny);
|
|
340
|
+
func = eny.func.bind(eny);
|
|
341
|
+
lambda = eny.lambda.bind(eny);
|
|
342
|
+
mapArray = eny.map.bind(eny);
|
|
343
|
+
filterArray = eny.filter.bind(eny);
|
|
344
|
+
reduceArray = eny.reduce.bind(eny);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
export {
|
|
349
|
+
ENYRuntime,
|
|
350
|
+
eny,
|
|
351
|
+
state,
|
|
352
|
+
substate,
|
|
353
|
+
func,
|
|
354
|
+
lambda,
|
|
355
|
+
mapArray,
|
|
356
|
+
filterArray,
|
|
357
|
+
reduceArray,
|
|
358
|
+
runtime_exports,
|
|
359
|
+
init_runtime
|
|
360
|
+
};
|
|
@@ -19,8 +19,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
};
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
+
// node_modules/tsup/assets/esm_shims.js
|
|
23
|
+
import path from "path";
|
|
24
|
+
import { fileURLToPath } from "url";
|
|
25
|
+
var init_esm_shims = __esm({
|
|
26
|
+
"node_modules/tsup/assets/esm_shims.js"() {
|
|
27
|
+
"use strict";
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
22
31
|
export {
|
|
23
32
|
__esm,
|
|
24
33
|
__export,
|
|
25
|
-
__toCommonJS
|
|
34
|
+
__toCommonJS,
|
|
35
|
+
init_esm_shims
|
|
26
36
|
};
|
package/dist/cli.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
init_transpile,
|
|
4
3
|
runENY,
|
|
5
4
|
transpileToDTS,
|
|
6
5
|
transpileToJS,
|
|
7
6
|
transpileToWAT
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import
|
|
7
|
+
} from "./chunk-5PZUUNHS.js";
|
|
8
|
+
import {
|
|
9
|
+
init_esm_shims
|
|
10
|
+
} from "./chunk-MXA7TAAG.js";
|
|
10
11
|
|
|
11
12
|
// src/cli.ts
|
|
13
|
+
init_esm_shims();
|
|
12
14
|
import fs from "fs";
|
|
13
15
|
import path from "path";
|
|
14
|
-
init_transpile();
|
|
15
16
|
var argv = process.argv.slice(2);
|
|
16
17
|
var code = "";
|
|
17
18
|
var out;
|