rip-lang 3.13.31 → 3.13.33
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/README.md +1 -1
- package/docs/dist/rip.js +58 -17
- package/docs/dist/rip.min.js +196 -196
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/components.js +59 -15
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.
|
|
12
|
+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.33-blue.svg" alt="Version"></a>
|
|
13
13
|
<a href="#zero-dependencies"><img src="https://img.shields.io/badge/dependencies-ZERO-brightgreen.svg" alt="Dependencies"></a>
|
|
14
14
|
<a href="#"><img src="https://img.shields.io/badge/tests-1%2C300%2F1%2C300-brightgreen.svg" alt="Tests"></a>
|
|
15
15
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
|
package/docs/dist/rip.js
CHANGED
|
@@ -3801,23 +3801,36 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
3801
3801
|
tag = "div";
|
|
3802
3802
|
return { tag, classes, id };
|
|
3803
3803
|
};
|
|
3804
|
+
const _str = (s) => typeof s === "string" ? s : s instanceof String ? s.valueOf() : null;
|
|
3805
|
+
const _transferMeta = (from, to) => {
|
|
3806
|
+
if (!(from instanceof String))
|
|
3807
|
+
return to;
|
|
3808
|
+
const s = new String(to);
|
|
3809
|
+
if (from.predicate)
|
|
3810
|
+
s.predicate = true;
|
|
3811
|
+
if (from.await)
|
|
3812
|
+
s.await = true;
|
|
3813
|
+
return s.predicate || s.await ? s : to;
|
|
3814
|
+
};
|
|
3804
3815
|
proto.transformComponentMembers = function(sexpr) {
|
|
3805
3816
|
const self = this._self;
|
|
3806
3817
|
if (!Array.isArray(sexpr)) {
|
|
3807
|
-
|
|
3808
|
-
|
|
3818
|
+
const sv = _str(sexpr);
|
|
3819
|
+
if (sv && this.reactiveMembers && this.reactiveMembers.has(sv)) {
|
|
3820
|
+
return [".", [".", self, sv], _transferMeta(sexpr, "value")];
|
|
3809
3821
|
}
|
|
3810
|
-
if (
|
|
3811
|
-
return [".", self, sexpr];
|
|
3822
|
+
if (sv && this.componentMembers && this.componentMembers.has(sv)) {
|
|
3823
|
+
return [".", self, _transferMeta(sexpr, sv)];
|
|
3812
3824
|
}
|
|
3813
3825
|
return sexpr;
|
|
3814
3826
|
}
|
|
3815
|
-
if (sexpr[0] === "." && sexpr[1] === "this" &&
|
|
3816
|
-
const
|
|
3827
|
+
if (sexpr[0] === "." && sexpr[1] === "this" && _str(sexpr[2]) != null) {
|
|
3828
|
+
const prop = sexpr[2];
|
|
3829
|
+
const memberName = _str(prop);
|
|
3817
3830
|
if (this.reactiveMembers && this.reactiveMembers.has(memberName)) {
|
|
3818
|
-
return [".", [".", self, memberName], "value"];
|
|
3831
|
+
return [".", [".", self, memberName], _transferMeta(prop, "value")];
|
|
3819
3832
|
}
|
|
3820
|
-
return this._factoryMode ? [".", self,
|
|
3833
|
+
return this._factoryMode ? [".", self, prop] : sexpr;
|
|
3821
3834
|
}
|
|
3822
3835
|
if (sexpr[0] === "." || sexpr[0] === "?.") {
|
|
3823
3836
|
return [sexpr[0], this.transformComponentMembers(sexpr[1]), sexpr[2]];
|
|
@@ -3934,10 +3947,10 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
3934
3947
|
}
|
|
3935
3948
|
for (const { name, value, isPublic } of stateVars) {
|
|
3936
3949
|
const val = this.generateInComponent(value, "value");
|
|
3937
|
-
lines.push(isPublic ? ` this.${name} = __state(props.${name} ?? ${val});` : ` this.${name} = __state(${val});`);
|
|
3950
|
+
lines.push(isPublic ? ` this.${name} = __state(props.__bind_${name}__ ?? props.${name} ?? ${val});` : ` this.${name} = __state(${val});`);
|
|
3938
3951
|
}
|
|
3939
3952
|
for (const { name, expr } of derivedVars) {
|
|
3940
|
-
if (this.is(expr, "block")
|
|
3953
|
+
if (this.is(expr, "block")) {
|
|
3941
3954
|
const transformed = this.transformComponentMembers(expr);
|
|
3942
3955
|
const body2 = this.generateFunctionBody(transformed);
|
|
3943
3956
|
lines.push(` this.${name} = __computed(() => ${body2});`);
|
|
@@ -3949,7 +3962,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
3949
3962
|
for (const effect of effects) {
|
|
3950
3963
|
const effectBody = effect[2];
|
|
3951
3964
|
const isAsync = this.containsAwait(effectBody) ? "async " : "";
|
|
3952
|
-
if (this.is(effectBody, "block")
|
|
3965
|
+
if (this.is(effectBody, "block")) {
|
|
3953
3966
|
const transformed = this.transformComponentMembers(effectBody);
|
|
3954
3967
|
const body2 = this.generateFunctionBody(transformed, [], true);
|
|
3955
3968
|
lines.push(` __effect(${isAsync}() => ${body2});`);
|
|
@@ -4113,6 +4126,12 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
4113
4126
|
this._pushEffect(`${textVar2}.data = ${this._self}.${str}.value;`);
|
|
4114
4127
|
return textVar2;
|
|
4115
4128
|
}
|
|
4129
|
+
if (str === "slot" && this.componentMembers) {
|
|
4130
|
+
const s = this._self;
|
|
4131
|
+
const slotVar = this.newElementVar("slot");
|
|
4132
|
+
this._createLines.push(`${slotVar} = ${s}.children instanceof Node ? ${s}.children : (${s}.children != null ? document.createTextNode(String(${s}.children)) : document.createComment(''));`);
|
|
4133
|
+
return slotVar;
|
|
4134
|
+
}
|
|
4116
4135
|
const [tagStr, idStr] = str.split("#");
|
|
4117
4136
|
const elVar = this.newElementVar();
|
|
4118
4137
|
const actualTag = tagStr || "div";
|
|
@@ -4135,6 +4154,12 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
4135
4154
|
if (headStr && this.isComponent(headStr)) {
|
|
4136
4155
|
return this.generateChildComponent(headStr, rest);
|
|
4137
4156
|
}
|
|
4157
|
+
if (headStr === "slot" && this.componentMembers) {
|
|
4158
|
+
const s = this._self;
|
|
4159
|
+
const slotVar = this.newElementVar("slot");
|
|
4160
|
+
this._createLines.push(`${slotVar} = ${s}.children instanceof Node ? ${s}.children : (${s}.children != null ? document.createTextNode(String(${s}.children)) : document.createComment(''));`);
|
|
4161
|
+
return slotVar;
|
|
4162
|
+
}
|
|
4138
4163
|
if (headStr && this.isHtmlTag(headStr)) {
|
|
4139
4164
|
let [tagName, id] = headStr.split("#");
|
|
4140
4165
|
return this.generateTag(tagName || "div", [], rest, id);
|
|
@@ -4433,7 +4458,11 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
4433
4458
|
this._createLines.push(`if (${valueCode}) ${elVar}.setAttribute('${key}', '');`);
|
|
4434
4459
|
}
|
|
4435
4460
|
} else if (this.hasReactiveDeps(value)) {
|
|
4436
|
-
|
|
4461
|
+
if (Array.isArray(value) && value[0] === "presence") {
|
|
4462
|
+
this._pushEffect(`{ const __v = ${valueCode}; __v == null ? ${elVar}.removeAttribute('${key}') : ${elVar}.setAttribute('${key}', __v); }`);
|
|
4463
|
+
} else {
|
|
4464
|
+
this._pushEffect(`${elVar}.setAttribute('${key}', ${valueCode});`);
|
|
4465
|
+
}
|
|
4437
4466
|
} else {
|
|
4438
4467
|
this._createLines.push(`${elVar}.setAttribute('${key}', ${valueCode});`);
|
|
4439
4468
|
}
|
|
@@ -4661,11 +4690,15 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
4661
4690
|
this._pendingAutoWire = false;
|
|
4662
4691
|
const instVar = this.newElementVar("inst");
|
|
4663
4692
|
const elVar = this.newElementVar("el");
|
|
4664
|
-
const { propsCode, reactiveProps, childrenSetupLines } = this.buildComponentProps(args);
|
|
4693
|
+
const { propsCode, reactiveProps, eventBindings, childrenSetupLines } = this.buildComponentProps(args);
|
|
4665
4694
|
const s = this._self;
|
|
4666
4695
|
this._createLines.push(`${instVar} = new ${componentName}(${propsCode});`);
|
|
4667
4696
|
this._createLines.push(`${elVar} = ${instVar}._root = ${instVar}._create();`);
|
|
4668
4697
|
this._createLines.push(`(${s}._children || (${s}._children = [])).push(${instVar});`);
|
|
4698
|
+
for (const { event, value } of eventBindings) {
|
|
4699
|
+
const handlerCode = this.generateInComponent(value, "value");
|
|
4700
|
+
this._createLines.push(`${elVar}.addEventListener('${event}', (e) => __batch(() => (${handlerCode})(e)));`);
|
|
4701
|
+
}
|
|
4669
4702
|
this._setupLines.push(`try { if (${instVar}._setup) ${instVar}._setup(); if (${instVar}.mounted) ${instVar}.mounted(); } catch (__e) { __handleComponentError(__e, ${instVar}); }`);
|
|
4670
4703
|
for (const { key, valueCode } of reactiveProps) {
|
|
4671
4704
|
this._pushEffect(`if (${instVar}.${key}) ${instVar}.${key}.value = ${valueCode};`);
|
|
@@ -4678,9 +4711,14 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
4678
4711
|
proto.buildComponentProps = function(args) {
|
|
4679
4712
|
const props = [];
|
|
4680
4713
|
const reactiveProps = [];
|
|
4714
|
+
const eventBindings = [];
|
|
4681
4715
|
let childrenVar = null;
|
|
4682
4716
|
const childrenSetupLines = [];
|
|
4683
4717
|
const addProp = (key, value) => {
|
|
4718
|
+
if (key.startsWith("@")) {
|
|
4719
|
+
eventBindings.push({ event: key.slice(1).split(".")[0], value });
|
|
4720
|
+
return;
|
|
4721
|
+
}
|
|
4684
4722
|
const isDirectSignal = this.reactiveMembers && (typeof value === "string" && this.reactiveMembers.has(value) || Array.isArray(value) && value[0] === "." && value[1] === "this" && typeof value[2] === "string" && this.reactiveMembers.has(value[2]));
|
|
4685
4723
|
if (isDirectSignal) {
|
|
4686
4724
|
const member = typeof value === "string" ? value : value[2];
|
|
@@ -4696,8 +4734,11 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
4696
4734
|
const addObjectProps = (objExpr) => {
|
|
4697
4735
|
for (let i = 1;i < objExpr.length; i++) {
|
|
4698
4736
|
const [key, value] = objExpr[i];
|
|
4699
|
-
if (typeof key === "string")
|
|
4737
|
+
if (typeof key === "string") {
|
|
4700
4738
|
addProp(key, value);
|
|
4739
|
+
} else if (Array.isArray(key) && key[0] === "." && key[1] === "this" && typeof key[2] === "string") {
|
|
4740
|
+
eventBindings.push({ event: key[2], value });
|
|
4741
|
+
}
|
|
4701
4742
|
}
|
|
4702
4743
|
};
|
|
4703
4744
|
for (const arg of args) {
|
|
@@ -4737,7 +4778,7 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
4737
4778
|
}
|
|
4738
4779
|
}
|
|
4739
4780
|
const propsCode = props.length > 0 ? `{ ${props.join(", ")} }` : "{}";
|
|
4740
|
-
return { propsCode, reactiveProps, childrenSetupLines };
|
|
4781
|
+
return { propsCode, reactiveProps, eventBindings, childrenSetupLines };
|
|
4741
4782
|
};
|
|
4742
4783
|
proto.hasReactiveDeps = function(sexpr) {
|
|
4743
4784
|
if (typeof sexpr === "string") {
|
|
@@ -8575,8 +8616,8 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
|
8575
8616
|
return new CodeGenerator({}).getComponentRuntime();
|
|
8576
8617
|
}
|
|
8577
8618
|
// src/browser.js
|
|
8578
|
-
var VERSION = "3.13.
|
|
8579
|
-
var BUILD_DATE = "2026-02-26@
|
|
8619
|
+
var VERSION = "3.13.32";
|
|
8620
|
+
var BUILD_DATE = "2026-02-26@17:50:29GMT";
|
|
8580
8621
|
if (typeof globalThis !== "undefined") {
|
|
8581
8622
|
if (!globalThis.__rip)
|
|
8582
8623
|
new Function(getReactiveRuntime())();
|