tutuca 0.9.65 → 0.9.67
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/tutuca-cli.js +144 -89
- package/dist/tutuca-dev.ext.js +11601 -0
- package/dist/tutuca-dev.js +136 -86
- package/dist/tutuca-dev.min.js +2 -2
- package/dist/tutuca-extra.ext.js +4190 -0
- package/dist/tutuca-extra.js +113 -86
- package/dist/tutuca-extra.min.js +2 -2
- package/dist/tutuca.ext.js +3828 -0
- package/dist/tutuca.js +113 -86
- package/dist/tutuca.min.js +2 -2
- package/package.json +17 -2
- package/skill/tutuca/core.md +10 -2
- package/skill/tutuca/testing.md +3 -2
- package/skill/tutuca-source/SKILL.md +33 -0
- package/skill/tutuca-source/tutuca.ext.js +3828 -0
- package/skill/SKILL.md +0 -46
- package/skill/advanced.md +0 -146
- package/skill/cli.md +0 -117
- package/skill/core.md +0 -793
package/dist/tutuca-dev.js
CHANGED
|
@@ -7935,49 +7935,67 @@ class Path {
|
|
|
7935
7935
|
let handlers = null;
|
|
7936
7936
|
let nodeIds = [];
|
|
7937
7937
|
let isLeafComponent = true;
|
|
7938
|
+
const crossComponent = (cidNum, vid) => {
|
|
7939
|
+
const comp = comps.getComponentForId(cidNum);
|
|
7940
|
+
let pushStep = true;
|
|
7941
|
+
if (handlers === null && (isLeafComponent || bubbles)) {
|
|
7942
|
+
handlers = findHandlers(comp, eventIds, vid, eventName);
|
|
7943
|
+
if (handlers === null) {
|
|
7944
|
+
if (isLeafComponent && stopOnNoEvent && !bubbles)
|
|
7945
|
+
return false;
|
|
7946
|
+
} else if (!isLeafComponent) {
|
|
7947
|
+
pathSteps.length = 0;
|
|
7948
|
+
pendingDyns.length = 0;
|
|
7949
|
+
pushStep = false;
|
|
7950
|
+
}
|
|
7951
|
+
}
|
|
7952
|
+
isLeafComponent = false;
|
|
7953
|
+
for (const dyn of pendingDyns)
|
|
7954
|
+
dyn.interiorCids.add(cidNum);
|
|
7955
|
+
if (pushStep) {
|
|
7956
|
+
const step = resolvePathStep(comp, nodeIds, vid);
|
|
7957
|
+
if (step) {
|
|
7958
|
+
step._originCid = cidNum;
|
|
7959
|
+
pathSteps.push(step);
|
|
7960
|
+
if (step instanceof DynStep) {
|
|
7961
|
+
step.interiorCids.add(cidNum);
|
|
7962
|
+
pendingDyns.push(step);
|
|
7963
|
+
}
|
|
7964
|
+
}
|
|
7965
|
+
}
|
|
7966
|
+
for (let i = pendingDyns.length - 1;i >= 0; i--)
|
|
7967
|
+
if (pendingDyns[i].producerCompId === cidNum)
|
|
7968
|
+
pendingDyns.splice(i, 1);
|
|
7969
|
+
eventIds = [];
|
|
7970
|
+
nodeIds = [];
|
|
7971
|
+
return true;
|
|
7972
|
+
};
|
|
7938
7973
|
while (node && node !== rootNode && depth < maxDepth) {
|
|
7939
7974
|
if (node?.dataset) {
|
|
7940
|
-
const { nid, si, sk } = parseMetaComment(node.previousSibling);
|
|
7941
7975
|
const { eid, cid, vid } = node.dataset;
|
|
7942
7976
|
if (eid !== undefined)
|
|
7943
7977
|
eventIds.push(eid);
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
if (
|
|
7949
|
-
|
|
7950
|
-
if (
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
}
|
|
7959
|
-
isLeafComponent = false;
|
|
7960
|
-
for (const dyn of pendingDyns)
|
|
7961
|
-
dyn.interiorCids.add(cidNum);
|
|
7962
|
-
if (pushStep) {
|
|
7963
|
-
const step = resolvePathStep(comp, nodeIds, vid);
|
|
7964
|
-
if (step) {
|
|
7965
|
-
step._originCid = cidNum;
|
|
7966
|
-
pathSteps.push(step);
|
|
7967
|
-
if (step instanceof DynStep) {
|
|
7968
|
-
step.interiorCids.add(cidNum);
|
|
7969
|
-
pendingDyns.push(step);
|
|
7970
|
-
}
|
|
7978
|
+
const metas = metaChain(node.previousSibling);
|
|
7979
|
+
let sawComp = false;
|
|
7980
|
+
for (let i = 0;i < metas.length; i++) {
|
|
7981
|
+
const m = metas[i];
|
|
7982
|
+
if (m.$ === "Comp") {
|
|
7983
|
+
sawComp = true;
|
|
7984
|
+
if (!crossComponent(m.cid, m.vid))
|
|
7985
|
+
return NO_EVENT_INFO;
|
|
7986
|
+
const outer = metas[i + 1];
|
|
7987
|
+
if (outer?.$ === "Each" && outer.nid === m.nid) {
|
|
7988
|
+
nodeIds.push({ nid: outer.nid, si: outer.si, sk: outer.sk });
|
|
7989
|
+
i += 1;
|
|
7990
|
+
} else {
|
|
7991
|
+
nodeIds.push({ nid: m.nid });
|
|
7971
7992
|
}
|
|
7993
|
+
} else {
|
|
7994
|
+
nodeIds.push({ nid: m.nid, si: m.si, sk: m.sk });
|
|
7972
7995
|
}
|
|
7973
|
-
for (let i = pendingDyns.length - 1;i >= 0; i--)
|
|
7974
|
-
if (pendingDyns[i].producerCompId === cidNum)
|
|
7975
|
-
pendingDyns.splice(i, 1);
|
|
7976
|
-
eventIds = [];
|
|
7977
|
-
nodeIds = [];
|
|
7978
7996
|
}
|
|
7979
|
-
if (
|
|
7980
|
-
|
|
7997
|
+
if (!sawComp && cid !== undefined && !crossComponent(+cid, vid))
|
|
7998
|
+
return NO_EVENT_INFO;
|
|
7981
7999
|
}
|
|
7982
8000
|
depth += 1;
|
|
7983
8001
|
node = node.parentNode;
|
|
@@ -7991,19 +8009,17 @@ class Path {
|
|
|
7991
8009
|
return Path.fromNodeAndEventName(target, type3, rNode, maxDepth, comps, stopOnNoEvent);
|
|
7992
8010
|
}
|
|
7993
8011
|
}
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
const m = parseMetaComment(n.previousSibling);
|
|
7998
|
-
if (m !== EMPTY_META)
|
|
7999
|
-
return m;
|
|
8012
|
+
function metaChain(n) {
|
|
8013
|
+
const out = [];
|
|
8014
|
+
while (n?.nodeType === 8 && n.textContent[0] === "§") {
|
|
8000
8015
|
try {
|
|
8001
|
-
|
|
8016
|
+
out.push(JSON.parse(n.textContent.slice(1, -1)));
|
|
8002
8017
|
} catch (err) {
|
|
8003
8018
|
console.warn(err, n);
|
|
8004
8019
|
}
|
|
8020
|
+
n = n.previousSibling;
|
|
8005
8021
|
}
|
|
8006
|
-
return
|
|
8022
|
+
return out;
|
|
8007
8023
|
}
|
|
8008
8024
|
function findHandlers(comp, eventIds, vid, eventName) {
|
|
8009
8025
|
for (const eid of eventIds) {
|
|
@@ -8824,40 +8840,49 @@ class RequestHandler {
|
|
|
8824
8840
|
}
|
|
8825
8841
|
|
|
8826
8842
|
// src/vdom.js
|
|
8827
|
-
var isHtmlAttribute = (propName) => propName[4] === "-" && (propName[0] === "d" || propName[0] === "a");
|
|
8828
8843
|
var HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
8829
8844
|
var isNamespaced = (node) => {
|
|
8830
8845
|
const ns = node.namespaceURI;
|
|
8831
8846
|
return ns !== null && ns !== HTML_NS;
|
|
8832
8847
|
};
|
|
8833
|
-
|
|
8848
|
+
var NEVER_ASSIGN = new Set([
|
|
8849
|
+
"width",
|
|
8850
|
+
"height",
|
|
8851
|
+
"href",
|
|
8852
|
+
"list",
|
|
8853
|
+
"form",
|
|
8854
|
+
"tabIndex",
|
|
8855
|
+
"download",
|
|
8856
|
+
"rowSpan",
|
|
8857
|
+
"colSpan",
|
|
8858
|
+
"role",
|
|
8859
|
+
"popover"
|
|
8860
|
+
]);
|
|
8861
|
+
function applyProperties(node, props, _previous) {
|
|
8834
8862
|
const namespaced = isNamespaced(node);
|
|
8835
|
-
for (const
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
node.setAttribute("class", propValue);
|
|
8843
|
-
else if (namespaced || isHtmlAttribute(propName))
|
|
8844
|
-
node.setAttribute(propName, propValue);
|
|
8863
|
+
for (const name in props)
|
|
8864
|
+
setProp2(node, name, props[name], namespaced);
|
|
8865
|
+
}
|
|
8866
|
+
function setProp2(node, name, value, namespaced) {
|
|
8867
|
+
if (name === "dangerouslySetInnerHTML") {
|
|
8868
|
+
if (value === undefined)
|
|
8869
|
+
node.replaceChildren();
|
|
8845
8870
|
else
|
|
8846
|
-
node
|
|
8847
|
-
|
|
8848
|
-
}
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
if (
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
node.removeAttribute(
|
|
8871
|
+
node.innerHTML = value.__html ?? "";
|
|
8872
|
+
return;
|
|
8873
|
+
}
|
|
8874
|
+
if (typeof value === "function")
|
|
8875
|
+
return;
|
|
8876
|
+
if (!namespaced && !NEVER_ASSIGN.has(name) && name in node) {
|
|
8877
|
+
try {
|
|
8878
|
+
node[name] = value == null ? "" : value;
|
|
8879
|
+
return;
|
|
8880
|
+
} catch {}
|
|
8881
|
+
}
|
|
8882
|
+
if (value == null || value === false && name[4] !== "-")
|
|
8883
|
+
node.removeAttribute(name);
|
|
8859
8884
|
else
|
|
8860
|
-
node
|
|
8885
|
+
node.setAttribute(name, value);
|
|
8861
8886
|
}
|
|
8862
8887
|
|
|
8863
8888
|
class VBase {
|
|
@@ -9129,22 +9154,12 @@ function h(tagName, properties, children, namespace) {
|
|
|
9129
9154
|
if (properties) {
|
|
9130
9155
|
for (const propName in properties) {
|
|
9131
9156
|
const propVal = properties[propName];
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
break;
|
|
9139
|
-
case "class":
|
|
9140
|
-
props.className = propVal;
|
|
9141
|
-
break;
|
|
9142
|
-
case "for":
|
|
9143
|
-
props.htmlFor = propVal;
|
|
9144
|
-
break;
|
|
9145
|
-
default:
|
|
9146
|
-
props[propName] = isHtmlAttribute(propName) ? String(propVal) : propVal;
|
|
9147
|
-
}
|
|
9157
|
+
if (propName === "key")
|
|
9158
|
+
key = propVal;
|
|
9159
|
+
else if (propName === "namespace")
|
|
9160
|
+
namespace = namespace ?? propVal;
|
|
9161
|
+
else
|
|
9162
|
+
props[propName] = propVal;
|
|
9148
9163
|
}
|
|
9149
9164
|
}
|
|
9150
9165
|
const c = tagName.charCodeAt(0);
|
|
@@ -9499,6 +9514,7 @@ class RenderViewId extends ANode {
|
|
|
9499
9514
|
super(nodeId, val);
|
|
9500
9515
|
this.viewId = viewId;
|
|
9501
9516
|
}
|
|
9517
|
+
setDataAttr(_key, _val) {}
|
|
9502
9518
|
}
|
|
9503
9519
|
|
|
9504
9520
|
class RenderNode extends RenderViewId {
|
|
@@ -9575,6 +9591,7 @@ class RenderTextNode extends ANode {
|
|
|
9575
9591
|
render(stack, _rx) {
|
|
9576
9592
|
return this.val.eval(stack);
|
|
9577
9593
|
}
|
|
9594
|
+
setDataAttr(_key, _val) {}
|
|
9578
9595
|
}
|
|
9579
9596
|
|
|
9580
9597
|
class RenderOnceNode extends BaseNode {
|
|
@@ -12257,6 +12274,7 @@ var UNSUPPORTED_EXPR_SYNTAX = "UNSUPPORTED_EXPR_SYNTAX";
|
|
|
12257
12274
|
var REDUNDANT_TEMPLATE_STRING = "REDUNDANT_TEMPLATE_STRING";
|
|
12258
12275
|
var PLACEHOLDERLESS_TEMPLATE_STRING = "PLACEHOLDERLESS_TEMPLATE_STRING";
|
|
12259
12276
|
var UNKNOWN_COMPONENT_SPEC_KEY = "UNKNOWN_COMPONENT_SPEC_KEY";
|
|
12277
|
+
var COMP_FIELD_BAD_SHAPE = "COMP_FIELD_BAD_SHAPE";
|
|
12260
12278
|
var PARSE_ISSUE_KIND_TO_LINT_ID = {
|
|
12261
12279
|
"unknown-directive": UNKNOWN_DIRECTIVE,
|
|
12262
12280
|
"unknown-x-op": UNKNOWN_X_OP,
|
|
@@ -12341,6 +12359,7 @@ var UNSUPPORTED_EXPR_GUIDANCE = {
|
|
|
12341
12359
|
function checkComponent(Comp, lx = new LintContext, { wellKnownExtras = EMPTY_SET2 } = {}) {
|
|
12342
12360
|
return lx.push({ componentName: Comp.name }, () => {
|
|
12343
12361
|
checkUnknownSpecKeys(lx, Comp, wellKnownExtras);
|
|
12362
|
+
checkFieldDeclarations(lx, Comp);
|
|
12344
12363
|
const referencedAlters = new Set;
|
|
12345
12364
|
const referencedInputs = new Set;
|
|
12346
12365
|
const referencedDynamics = new Set;
|
|
@@ -12769,6 +12788,31 @@ function checkUnknownSpecKeys(lx, Comp, wellKnownExtras) {
|
|
|
12769
12788
|
lx.warn(UNKNOWN_COMPONENT_SPEC_KEY, { key }, replaceNameSuggestion(key, candidates));
|
|
12770
12789
|
}
|
|
12771
12790
|
}
|
|
12791
|
+
function checkFieldDeclarations(lx, Comp) {
|
|
12792
|
+
const fields = Comp.Class?.getMetaClass?.().fields;
|
|
12793
|
+
if (!fields)
|
|
12794
|
+
return;
|
|
12795
|
+
for (const fieldName in fields) {
|
|
12796
|
+
const field = fields[fieldName];
|
|
12797
|
+
if (!Object.hasOwn(field, "args"))
|
|
12798
|
+
continue;
|
|
12799
|
+
if (typeof field.type !== "string") {
|
|
12800
|
+
lx.error(COMP_FIELD_BAD_SHAPE, {
|
|
12801
|
+
fieldName,
|
|
12802
|
+
kind: "component-not-string",
|
|
12803
|
+
got: typeof field.type,
|
|
12804
|
+
gotName: field.type?.name ?? null
|
|
12805
|
+
});
|
|
12806
|
+
}
|
|
12807
|
+
if (field.args == null || field.args.constructor !== Object) {
|
|
12808
|
+
lx.error(COMP_FIELD_BAD_SHAPE, {
|
|
12809
|
+
fieldName,
|
|
12810
|
+
kind: "args-not-object",
|
|
12811
|
+
got: field.args === null ? "null" : typeof field.args
|
|
12812
|
+
});
|
|
12813
|
+
}
|
|
12814
|
+
}
|
|
12815
|
+
}
|
|
12772
12816
|
function checkUnreferencedAlterHandlers(lx, Comp, referencedAlters) {
|
|
12773
12817
|
for (const name in Comp.alter) {
|
|
12774
12818
|
if (!referencedAlters.has(name)) {
|
|
@@ -14930,7 +14974,12 @@ class Renderer {
|
|
|
14930
14974
|
if (cachedNode)
|
|
14931
14975
|
return cachedNode;
|
|
14932
14976
|
const view = viewName ? comp.getView(viewName) : stack.lookupBestView(comp.views, "main");
|
|
14933
|
-
const meta = this._renderMetadata({
|
|
14977
|
+
const meta = this._renderMetadata({
|
|
14978
|
+
$: "Comp",
|
|
14979
|
+
nid: node?.nodeId ?? null,
|
|
14980
|
+
cid: comp.id,
|
|
14981
|
+
vid: view.name
|
|
14982
|
+
});
|
|
14934
14983
|
const dom = new VFragment([meta, this.renderView(view, stack)]);
|
|
14935
14984
|
this.cache.set(cachePath, cacheKey, dom);
|
|
14936
14985
|
return dom;
|
|
@@ -15564,6 +15613,7 @@ export {
|
|
|
15564
15613
|
ComponentList,
|
|
15565
15614
|
ComponentDocs,
|
|
15566
15615
|
Collection,
|
|
15616
|
+
COMP_FIELD_BAD_SHAPE,
|
|
15567
15617
|
BAD_VALUE,
|
|
15568
15618
|
ALT_HANDLER_NOT_REFERENCED,
|
|
15569
15619
|
ALT_HANDLER_NOT_DEFINED
|