tjs-lang 0.6.26 → 0.6.27
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/demo/docs.json +1 -1
- package/dist/bin/benchmarks.d.ts +9 -0
- package/dist/bin/dev.d.ts +1 -0
- package/dist/bin/docs.d.ts +1 -0
- package/dist/bin/select-local-models.d.ts +1 -0
- package/dist/examples/modules/dist/main.d.ts +34 -0
- package/dist/examples/modules/dist/math.d.ts +120 -0
- package/dist/index.js +423 -0
- package/dist/index.js.map +45 -0
- package/dist/scripts/build-demo.d.ts +2 -0
- package/dist/scripts/build.d.ts +11 -0
- package/dist/scripts/seed-blog-rules.d.ts +2 -0
- package/dist/scripts/seed-stored-function.d.ts +2 -0
- package/dist/src/atoms/batteries.d.ts +4 -0
- package/dist/src/atoms/browser.d.ts +4 -0
- package/dist/src/atoms/index.d.ts +4 -0
- package/dist/src/batteries/audit.d.ts +9 -0
- package/dist/src/batteries/index.d.ts +28 -0
- package/dist/src/batteries/llm.d.ts +18 -0
- package/dist/src/batteries/models.d.ts +19 -0
- package/dist/src/batteries/store.d.ts +13 -0
- package/dist/src/builder.d.ts +127 -0
- package/dist/src/bun-plugin/tjs-plugin.d.ts +12 -0
- package/dist/src/cli/commands/check.d.ts +4 -0
- package/dist/src/cli/commands/convert.d.ts +20 -0
- package/dist/src/cli/commands/emit.d.ts +34 -0
- package/dist/src/cli/commands/run.d.ts +6 -0
- package/dist/src/cli/commands/test.d.ts +21 -0
- package/dist/src/cli/commands/types.d.ts +4 -0
- package/dist/src/cli/create-app.d.ts +9 -0
- package/dist/src/cli/playground.d.ts +9 -0
- package/dist/src/cli/tjs.d.ts +15 -0
- package/dist/src/cli/tjsx.d.ts +16 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/inference.types.d.ts +1 -0
- package/dist/src/lang/core.d.ts +56 -0
- package/dist/src/lang/docs.d.ts +69 -0
- package/dist/src/lang/emitters/ast.d.ts +24 -0
- package/dist/src/lang/emitters/dts.d.ts +48 -0
- package/dist/src/lang/emitters/from-ts.d.ts +94 -0
- package/dist/src/lang/emitters/js-tests.d.ts +70 -0
- package/dist/src/lang/emitters/js-wasm.d.ts +15 -0
- package/dist/src/lang/emitters/js.d.ts +175 -0
- package/dist/src/lang/eval.d.ts +63 -0
- package/dist/src/lang/index.d.ts +216 -0
- package/dist/src/lang/inference.d.ts +40 -0
- package/dist/src/lang/linter.d.ts +53 -0
- package/dist/src/lang/metadata-cache.d.ts +172 -0
- package/dist/src/lang/parser-params.d.ts +37 -0
- package/dist/src/lang/parser-transforms.d.ts +281 -0
- package/dist/src/lang/parser-types.d.ts +175 -0
- package/dist/src/lang/parser.d.ts +56 -0
- package/dist/src/lang/runtime.d.ts +488 -0
- package/dist/src/lang/schema.d.ts +35 -0
- package/dist/src/lang/tests.d.ts +94 -0
- package/dist/src/lang/transpiler.d.ts +25 -0
- package/dist/src/lang/types.d.ts +147 -0
- package/dist/src/lang/wasm.d.ts +83 -0
- package/dist/src/rbac/index.d.ts +85 -0
- package/dist/src/rbac/rules.d.ts +184 -0
- package/dist/src/runtime.d.ts +4 -0
- package/dist/src/store/index.d.ts +3 -0
- package/dist/src/store/indexeddb.d.ts +6 -0
- package/dist/src/store/interface.d.ts +90 -0
- package/dist/src/store/memory.d.ts +10 -0
- package/dist/src/test-examples.d.ts +41 -0
- package/dist/src/test-utils.d.ts +86 -0
- package/dist/src/transpiler/index.d.ts +6 -0
- package/dist/src/transpiler/parser.d.ts +4 -0
- package/dist/src/transpiler/transformer.d.ts +4 -0
- package/dist/src/transpiler/type-system/inference.d.ts +1 -0
- package/dist/src/transpiler/types.d.ts +4 -0
- package/dist/src/types/LegalDate.d.ts +241 -0
- package/dist/src/types/Timestamp.d.ts +233 -0
- package/dist/src/types/Type.d.ts +234 -0
- package/dist/src/types/index.d.ts +8 -0
- package/dist/src/vm/atoms/batteries.d.ts +6 -0
- package/dist/src/vm/atoms/browser.d.ts +18 -0
- package/dist/src/vm/atoms/index.d.ts +10 -0
- package/dist/src/vm/index.d.ts +12 -0
- package/dist/src/vm/runtime.d.ts +333 -0
- package/dist/src/vm/vm.d.ts +28 -0
- package/dist/src/vm.d.ts +4 -0
- package/dist/test-preprocess.d.ts +1 -0
- package/dist/tjs-batteries.js +4 -0
- package/dist/tjs-batteries.js.map +15 -0
- package/dist/tjs-full.js +423 -0
- package/dist/tjs-full.js.map +45 -0
- package/dist/tjs-src/runtime.d.ts +1 -0
- package/dist/tjs-transpiler.js +3 -0
- package/dist/tjs-transpiler.js.map +11 -0
- package/dist/tjs-vm.js +54 -0
- package/dist/tjs-vm.js.map +22 -0
- package/package.json +1 -1
- package/src/cli/tjs.ts +1 -1
- package/src/lang/emitters/js.ts +3 -0
- package/src/lang/parser-transforms.ts +6 -0
- package/src/lang/roundtrip.test.ts +1 -1
- package/src/lang/runtime.ts +18 -1
- package/src/lang/wasm.ts +1 -1
package/demo/docs.json
CHANGED
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"type": "example",
|
|
116
116
|
"group": "basics",
|
|
117
117
|
"order": 15,
|
|
118
|
-
"code": "TjsEquals\n\n/*#\n## The Problem with JavaScript ==\n\nJavaScript's `==` does type coercion, producing surprises:\n\n 0 == '' // true in JS (!)\n false == [] // true in JS (!)\n '' == false // true in JS (!)\n null == 0 // false in JS (but null == undefined is true)\n\nJavaScript's `===` fixes coercion but can't compare values:\n\n new String('hi') === 'hi' // false in JS (different types)\n new Boolean(false) === false // false in JS (object vs primitive)\n\n## TJS Equality (TjsEquals)\n\n`==` becomes **honest equality**: no coercion, but unwraps\nboxed primitives. Fast O(1) — no deep comparison.\n\n`Is` / `IsNot` are **structural equality**: deep comparison\nfor when you explicitly need it. O(n) cost is visible.\n*/\n\n// --- Honest equality (==) fixes coercion ---\nconsole.log('== fixes JS coercion:')\nconsole.log(' 0 == \"\":', 0 == '') // false (JS: true)\nconsole.log(' false == []:', false == []) // false (JS: true)\nconsole.log(' false == \"\":', false == '') // false (JS: true)\nconsole.log(' 1 == \"1\":', 1 == '1') // false (JS: true)\n\n// --- Boxed primitives unwrap ---\nconsole.log('')\nconsole.log('== unwraps boxed primitives:')\nconsole.log(' new String(\"hi\") == \"hi\":', new String('hi') == 'hi') // true\nconsole.log(' new Boolean(false) == false:', new Boolean(false) == false) // true\nconsole.log(' new Number(42) == 42:', new Number(42) == 42) // true\n\n// --- Nullish equality preserved ---\nconsole.log('')\nconsole.log('Nullish equality (useful pattern preserved):')\nconsole.log(' null == undefined:', null == undefined) // true\nconsole.log(' null == 0:', null == 0) // false\nconsole.log(' null == \"\":', null == '') // false\n\n// --- Objects/arrays: reference equality (fast, O(1)) ---\nconsole.log('')\nconsole.log('== on objects/arrays is reference equality (fast):')\nconst obj = {x: 1}\nconsole.log(' obj == obj:', obj == obj) // true (same ref)\nconsole.log(' {x:1} == {x:1}:', {x: 1} == {x: 1}) // false (different refs)\nconsole.log(' [1,2] == [1,2]:', [1, 2] == [1, 2]) // false (different refs)\n\n// --- Is/IsNot: explicit deep structural comparison ---\nconsole.log('')\nconsole.log('Is/IsNot for deep structural comparison (explicit):')\nconsole.log(' {x:1} Is {x:1}:', Is({x: 1}, {x: 1})) // true\nconsole.log(' [1,2,3] Is [1,2,3]:', Is([1,2,3], [1,2,3])) // true\nconsole.log(' [1,2] Is [2,1]:', Is([1,2], [2,1])) // false (order matters)\n\n// Sets compare by membership, not order\nconsole.log(' Set([1,2]) Is Set([2,1]):', Is(new Set([1,2]), new Set([2,1]))) // true\n\n// --- === unchanged: identity comparison ---\nconsole.log('')\nconsole.log('=== is unchanged (identity):')\nconsole.log(' obj === obj:', obj === obj) // true\nconsole.log(' {x:1} === {x:1}:', {x: 1} === {x: 1}) // false\n\ntest 'Eq fixes coercion' {\n expect(Eq(0, '')).toBe(false)\n expect(Eq(false, [])).toBe(false)\n expect(Eq('', false)).toBe(false)\n}\n\ntest 'Eq unwraps boxed primitives' {\n expect(Eq(new String('hi'), 'hi')).toBe(true)\n expect(Eq(new Boolean(false), false)).toBe(true)\n expect(Eq(new Number(42), 42)).toBe(true)\n}\n\ntest 'Eq preserves nullish equality' {\n expect(Eq(null, undefined)).toBe(true)\n expect(Eq(null, 0)).toBe(false)\n}\n\ntest 'Is does deep structural comparison' {\n expect(Is({a: 1, b: 2}, {a: 1, b: 2})).toBe(true)\n expect(Is([1, 2, 3], [1, 2, 3])).toBe(true)\n expect(Is([1, 2], [2, 1])).toBe(false)\n}",
|
|
118
|
+
"code": "TjsEquals\n\n/*#\n## The Problem with JavaScript ==\n\nJavaScript's `==` does type coercion, producing surprises:\n\n 0 == '' // true in JS (!)\n false == [] // true in JS (!)\n '' == false // true in JS (!)\n null == 0 // false in JS (but null == undefined is true)\n\nJavaScript's `===` fixes coercion but can't compare values:\n\n new String('hi') === 'hi' // false in JS (different types)\n new Boolean(false) === false // false in JS (object vs primitive)\n\n## TJS Equality (TjsEquals)\n\n`==` becomes **honest equality**: no coercion, but unwraps\nboxed primitives. Fast O(1) — no deep comparison.\n\n`Is` / `IsNot` are **structural equality**: deep comparison\nfor when you explicitly need it. O(n) cost is visible.\n*/\n\n// --- Honest equality (==) fixes coercion ---\nconsole.log('== fixes JS coercion:')\nconsole.log(' 0 == \"\":', 0 == '') // false (JS: true)\nconsole.log(' false == []:', false == []) // false (JS: true)\nconsole.log(' false == \"\":', false == '') // false (JS: true)\nconsole.log(' 1 == \"1\":', 1 == '1') // false (JS: true)\n\n// --- Boxed primitives unwrap ---\nconsole.log('')\nconsole.log('== unwraps boxed primitives:')\nconsole.log(' new String(\"hi\") == \"hi\":', new String('hi') == 'hi') // true\nconsole.log(' new Boolean(false) == false:', new Boolean(false) == false) // true\nconsole.log(' new Number(42) == 42:', new Number(42) == 42) // true\n\n// --- Nullish equality preserved ---\nconsole.log('')\nconsole.log('Nullish equality (useful pattern preserved):')\nconsole.log(' null == undefined:', null == undefined) // true\nconsole.log(' null == 0:', null == 0) // false\nconsole.log(' null == \"\":', null == '') // false\n\n// --- Objects/arrays: reference equality (fast, O(1)) ---\nconsole.log('')\nconsole.log('== on objects/arrays is reference equality (fast):')\nconst obj = {x: 1}\nconsole.log(' obj == obj:', obj == obj) // true (same ref)\nconsole.log(' {x:1} == {x:1}:', {x: 1} == {x: 1}) // false (different refs)\nconsole.log(' [1,2] == [1,2]:', [1, 2] == [1, 2]) // false (different refs)\n\n// --- Is/IsNot: explicit deep structural comparison ---\nconsole.log('')\nconsole.log('Is/IsNot for deep structural comparison (explicit):')\nconsole.log(' {x:1} Is {x:1}:', Is({x: 1}, {x: 1})) // true\nconsole.log(' [1,2,3] Is [1,2,3]:', Is([1,2,3], [1,2,3])) // true\nconsole.log(' [1,2] Is [2,1]:', Is([1,2], [2,1])) // false (order matters)\n\n// Sets compare by membership, not order\nconsole.log(' Set([1,2]) Is Set([2,1]):', Is(new Set([1,2]), new Set([2,1]))) // true\n\n// --- typeof null fixed ---\nconsole.log('')\nconsole.log('typeof null fixed:')\nconsole.log(' typeof null:', typeof null) // 'null' (JS: 'object')\nconsole.log(' typeof undefined:', typeof undefined) // 'undefined'\nconsole.log(' typeof 42:', typeof 42) // 'number' (unchanged)\n\n// --- === unchanged: identity comparison ---\nconsole.log('')\nconsole.log('=== is unchanged (identity):')\nconsole.log(' obj === obj:', obj === obj) // true\nconsole.log(' {x:1} === {x:1}:', {x: 1} === {x: 1}) // false\n\ntest 'typeof null is null, not object' {\n expect(TypeOf(null)).toBe('null')\n expect(TypeOf(undefined)).toBe('undefined')\n expect(TypeOf(42)).toBe('number')\n expect(TypeOf('hi')).toBe('string')\n expect(TypeOf(true)).toBe('boolean')\n expect(TypeOf({})).toBe('object')\n}\n\ntest 'Eq fixes coercion' {\n expect(Eq(0, '')).toBe(false)\n expect(Eq(false, [])).toBe(false)\n expect(Eq('', false)).toBe(false)\n}\n\ntest 'Eq unwraps boxed primitives' {\n expect(Eq(new String('hi'), 'hi')).toBe(true)\n expect(Eq(new Boolean(false), false)).toBe(true)\n expect(Eq(new Number(42), 42)).toBe(true)\n}\n\ntest 'Eq preserves nullish equality' {\n expect(Eq(null, undefined)).toBe(true)\n expect(Eq(null, 0)).toBe(false)\n}\n\ntest 'Is does deep structural comparison' {\n expect(Is({a: 1, b: 2}, {a: 1, b: 2})).toBe(true)\n expect(Is([1, 2, 3], [1, 2, 3])).toBe(true)\n expect(Is([1, 2], [2, 1])).toBe(false)\n}",
|
|
119
119
|
"language": "tjs",
|
|
120
120
|
"description": "JavaScript `==` is broken. TJS fixes it without breaking anything."
|
|
121
121
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function calculate(x?: number, y?: number): any;
|
|
2
|
+
export namespace calculate {
|
|
3
|
+
namespace __tjs {
|
|
4
|
+
namespace params {
|
|
5
|
+
namespace x {
|
|
6
|
+
export namespace type {
|
|
7
|
+
let kind: string;
|
|
8
|
+
}
|
|
9
|
+
export let required: boolean;
|
|
10
|
+
let _default: null;
|
|
11
|
+
export { _default as default };
|
|
12
|
+
}
|
|
13
|
+
namespace y {
|
|
14
|
+
export namespace type_1 {
|
|
15
|
+
let kind_1: string;
|
|
16
|
+
export { kind_1 as kind };
|
|
17
|
+
}
|
|
18
|
+
export { type_1 as type };
|
|
19
|
+
let required_1: boolean;
|
|
20
|
+
export { required_1 as required };
|
|
21
|
+
let _default_1: null;
|
|
22
|
+
export { _default_1 as default };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
namespace returns {
|
|
26
|
+
export namespace type_2 {
|
|
27
|
+
let kind_2: string;
|
|
28
|
+
export { kind_2 as kind };
|
|
29
|
+
}
|
|
30
|
+
export { type_2 as type };
|
|
31
|
+
}
|
|
32
|
+
let source: string;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export function add(a?: number, b?: number): any;
|
|
2
|
+
export namespace add {
|
|
3
|
+
namespace __tjs {
|
|
4
|
+
namespace params {
|
|
5
|
+
namespace a {
|
|
6
|
+
export namespace type {
|
|
7
|
+
let kind: string;
|
|
8
|
+
}
|
|
9
|
+
export let required: boolean;
|
|
10
|
+
let _default: null;
|
|
11
|
+
export { _default as default };
|
|
12
|
+
}
|
|
13
|
+
namespace b {
|
|
14
|
+
export namespace type_1 {
|
|
15
|
+
let kind_1: string;
|
|
16
|
+
export { kind_1 as kind };
|
|
17
|
+
}
|
|
18
|
+
export { type_1 as type };
|
|
19
|
+
let required_1: boolean;
|
|
20
|
+
export { required_1 as required };
|
|
21
|
+
let _default_1: null;
|
|
22
|
+
export { _default_1 as default };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
namespace returns {
|
|
26
|
+
export namespace type_2 {
|
|
27
|
+
let kind_2: string;
|
|
28
|
+
export { kind_2 as kind };
|
|
29
|
+
}
|
|
30
|
+
export { type_2 as type };
|
|
31
|
+
}
|
|
32
|
+
let source: string;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function subtract(a?: number, b?: number): any;
|
|
36
|
+
export namespace subtract {
|
|
37
|
+
export namespace __tjs_1 {
|
|
38
|
+
export namespace params_1 {
|
|
39
|
+
export namespace a_1 {
|
|
40
|
+
export namespace type_3 {
|
|
41
|
+
let kind_3: string;
|
|
42
|
+
export { kind_3 as kind };
|
|
43
|
+
}
|
|
44
|
+
export { type_3 as type };
|
|
45
|
+
let required_2: boolean;
|
|
46
|
+
export { required_2 as required };
|
|
47
|
+
let _default_2: null;
|
|
48
|
+
export { _default_2 as default };
|
|
49
|
+
}
|
|
50
|
+
export { a_1 as a };
|
|
51
|
+
export namespace b_1 {
|
|
52
|
+
export namespace type_4 {
|
|
53
|
+
let kind_4: string;
|
|
54
|
+
export { kind_4 as kind };
|
|
55
|
+
}
|
|
56
|
+
export { type_4 as type };
|
|
57
|
+
let required_3: boolean;
|
|
58
|
+
export { required_3 as required };
|
|
59
|
+
let _default_3: null;
|
|
60
|
+
export { _default_3 as default };
|
|
61
|
+
}
|
|
62
|
+
export { b_1 as b };
|
|
63
|
+
}
|
|
64
|
+
export { params_1 as params };
|
|
65
|
+
export namespace returns_1 {
|
|
66
|
+
export namespace type_5 {
|
|
67
|
+
let kind_5: string;
|
|
68
|
+
export { kind_5 as kind };
|
|
69
|
+
}
|
|
70
|
+
export { type_5 as type };
|
|
71
|
+
}
|
|
72
|
+
export { returns_1 as returns };
|
|
73
|
+
let source_1: string;
|
|
74
|
+
export { source_1 as source };
|
|
75
|
+
}
|
|
76
|
+
export { __tjs_1 as __tjs };
|
|
77
|
+
}
|
|
78
|
+
export function multiply(a?: number, b?: number): any;
|
|
79
|
+
export namespace multiply {
|
|
80
|
+
export namespace __tjs_2 {
|
|
81
|
+
export namespace params_2 {
|
|
82
|
+
export namespace a_2 {
|
|
83
|
+
export namespace type_6 {
|
|
84
|
+
let kind_6: string;
|
|
85
|
+
export { kind_6 as kind };
|
|
86
|
+
}
|
|
87
|
+
export { type_6 as type };
|
|
88
|
+
let required_4: boolean;
|
|
89
|
+
export { required_4 as required };
|
|
90
|
+
let _default_4: null;
|
|
91
|
+
export { _default_4 as default };
|
|
92
|
+
}
|
|
93
|
+
export { a_2 as a };
|
|
94
|
+
export namespace b_2 {
|
|
95
|
+
export namespace type_7 {
|
|
96
|
+
let kind_7: string;
|
|
97
|
+
export { kind_7 as kind };
|
|
98
|
+
}
|
|
99
|
+
export { type_7 as type };
|
|
100
|
+
let required_5: boolean;
|
|
101
|
+
export { required_5 as required };
|
|
102
|
+
let _default_5: null;
|
|
103
|
+
export { _default_5 as default };
|
|
104
|
+
}
|
|
105
|
+
export { b_2 as b };
|
|
106
|
+
}
|
|
107
|
+
export { params_2 as params };
|
|
108
|
+
export namespace returns_2 {
|
|
109
|
+
export namespace type_8 {
|
|
110
|
+
let kind_8: string;
|
|
111
|
+
export { kind_8 as kind };
|
|
112
|
+
}
|
|
113
|
+
export { type_8 as type };
|
|
114
|
+
}
|
|
115
|
+
export { returns_2 as returns };
|
|
116
|
+
let source_2: string;
|
|
117
|
+
export { source_2 as source };
|
|
118
|
+
}
|
|
119
|
+
export { __tjs_2 as __tjs };
|
|
120
|
+
}
|