tutuca 0.9.89 → 0.9.91
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 +52 -9
- package/dist/tutuca-dev.ext.js +34 -4
- package/dist/tutuca-dev.js +34 -4
- package/dist/tutuca-dev.min.js +2 -2
- package/dist/tutuca-extra.ext.js +27 -2
- package/dist/tutuca-extra.js +27 -2
- package/dist/tutuca-extra.min.js +2 -2
- package/dist/tutuca-storybook.js +59 -7
- package/dist/tutuca.ext.js +27 -2
- package/dist/tutuca.js +27 -2
- package/dist/tutuca.min.js +2 -2
- package/package.json +1 -1
- package/skill/tutuca/SKILL.md +1 -0
- package/skill/tutuca/cli.md +4 -26
- package/skill/tutuca/core.md +20 -1
- package/skill/tutuca/patterns/README.md +4 -0
- package/skill/tutuca/patterns/add-a-story.md +26 -0
- package/skill/tutuca/request-response.md +10 -1
- package/skill/tutuca/storybook.md +151 -0
- package/skill/tutuca-source/tutuca.ext.js +27 -2
package/dist/tutuca-cli.js
CHANGED
|
@@ -3422,12 +3422,20 @@ var init_chai2 = __esm(() => {
|
|
|
3422
3422
|
|
|
3423
3423
|
// tools/core/module.js
|
|
3424
3424
|
class Example {
|
|
3425
|
-
constructor({
|
|
3425
|
+
constructor({
|
|
3426
|
+
title,
|
|
3427
|
+
description = null,
|
|
3428
|
+
value,
|
|
3429
|
+
view = "main",
|
|
3430
|
+
componentName = null,
|
|
3431
|
+
requestHandlerNames = []
|
|
3432
|
+
}) {
|
|
3426
3433
|
this.title = title;
|
|
3427
3434
|
this.description = description;
|
|
3428
3435
|
this.value = value;
|
|
3429
3436
|
this.view = view;
|
|
3430
3437
|
this.componentName = componentName;
|
|
3438
|
+
this.requestHandlerNames = requestHandlerNames;
|
|
3431
3439
|
}
|
|
3432
3440
|
}
|
|
3433
3441
|
function resolveComponentName(value, components) {
|
|
@@ -3471,12 +3479,17 @@ function parseExample(raw, index, components, parentPath) {
|
|
|
3471
3479
|
if (raw.value === undefined) {
|
|
3472
3480
|
throw shapeError(`example at ${where} missing "value"`, where);
|
|
3473
3481
|
}
|
|
3482
|
+
const rh = raw.requestHandlers;
|
|
3483
|
+
if (rh != null && (typeof rh !== "object" || Array.isArray(rh))) {
|
|
3484
|
+
throw shapeError(`example at ${where} "requestHandlers" must be an object of functions`, where);
|
|
3485
|
+
}
|
|
3474
3486
|
return new Example({
|
|
3475
3487
|
title: raw.title ?? `Example ${index + 1}`,
|
|
3476
3488
|
description: raw.description ?? null,
|
|
3477
3489
|
value: raw.value,
|
|
3478
3490
|
view: raw.view ?? "main",
|
|
3479
|
-
componentName: resolveComponentName(raw.value, components)
|
|
3491
|
+
componentName: resolveComponentName(raw.value, components),
|
|
3492
|
+
requestHandlerNames: rh ? Object.keys(rh) : []
|
|
3480
3493
|
});
|
|
3481
3494
|
}
|
|
3482
3495
|
function parseSection(raw, components, where) {
|
|
@@ -8186,6 +8199,17 @@ class Path {
|
|
|
8186
8199
|
}
|
|
8187
8200
|
return curVal;
|
|
8188
8201
|
}
|
|
8202
|
+
resolveChain(root) {
|
|
8203
|
+
const out = [root];
|
|
8204
|
+
let curVal = root;
|
|
8205
|
+
for (const step of this.steps) {
|
|
8206
|
+
curVal = step.lookup(curVal, NONE);
|
|
8207
|
+
if (curVal === NONE)
|
|
8208
|
+
break;
|
|
8209
|
+
out.push(curVal);
|
|
8210
|
+
}
|
|
8211
|
+
return out;
|
|
8212
|
+
}
|
|
8189
8213
|
setValue(root, v) {
|
|
8190
8214
|
const intermediates = new Array(this.steps.length);
|
|
8191
8215
|
let curVal = root;
|
|
@@ -13290,9 +13314,13 @@ function checkUnknownSpecKeys(lx, Comp, wellKnownExtras) {
|
|
|
13290
13314
|
return;
|
|
13291
13315
|
let candidates = null;
|
|
13292
13316
|
for (const key of Object.keys(extra)) {
|
|
13293
|
-
if (wellKnownExtras.has(key))
|
|
13317
|
+
if (FRAMEWORK_WELL_KNOWN_EXTRAS.has(key) || wellKnownExtras.has(key))
|
|
13294
13318
|
continue;
|
|
13295
|
-
candidates ??= [
|
|
13319
|
+
candidates ??= [
|
|
13320
|
+
...KNOWN_COMPONENT_SPEC_KEYS,
|
|
13321
|
+
...FRAMEWORK_WELL_KNOWN_EXTRAS,
|
|
13322
|
+
...wellKnownExtras
|
|
13323
|
+
];
|
|
13296
13324
|
lx.warn(UNKNOWN_COMPONENT_SPEC_KEY, { key }, replaceNameSuggestion(key, candidates));
|
|
13297
13325
|
}
|
|
13298
13326
|
}
|
|
@@ -13424,12 +13452,13 @@ class LintContext {
|
|
|
13424
13452
|
this.reports.push({ id, info, level, context: { ...this.frame }, suggestion });
|
|
13425
13453
|
}
|
|
13426
13454
|
}
|
|
13427
|
-
var KNOWN_COMPONENT_SPEC_KEYS, EMPTY_SET2, KNOWN_DIRECTIVE_NAMES, ALT_HANDLER_NOT_DEFINED = "ALT_HANDLER_NOT_DEFINED", ALT_HANDLER_NOT_REFERENCED = "ALT_HANDLER_NOT_REFERENCED", DYN_VAL_NOT_DEFINED = "DYN_VAL_NOT_DEFINED", DYN_ALIAS_NOT_REFERENCED = "DYN_ALIAS_NOT_REFERENCED", PROVIDE_NOT_ADDRESSABLE = "PROVIDE_NOT_ADDRESSABLE", LOOKUP_BAD_SHAPE = "LOOKUP_BAD_SHAPE", LOOKUP_TARGET_MALFORMED = "LOOKUP_TARGET_MALFORMED", RENDER_IT_OUTSIDE_OF_LOOP = "RENDER_IT_OUTSIDE_OF_LOOP", UNKNOWN_EVENT_MODIFIER = "UNKNOWN_EVENT_MODIFIER", UNKNOWN_HANDLER_ARG_NAME = "UNKNOWN_HANDLER_ARG_NAME", INPUT_HANDLER_NOT_IMPLEMENTED = "INPUT_HANDLER_NOT_IMPLEMENTED", INPUT_HANDLER_NOT_REFERENCED = "INPUT_HANDLER_NOT_REFERENCED", INPUT_HANDLER_METHOD_NOT_IMPLEMENTED = "INPUT_HANDLER_METHOD_NOT_IMPLEMENTED", INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD = "INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD", INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER = "INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER", FIELD_VAL_NOT_DEFINED = "FIELD_VAL_NOT_DEFINED", FIELD_VAL_IS_METHOD = "FIELD_VAL_IS_METHOD", METHOD_VAL_NOT_DEFINED = "METHOD_VAL_NOT_DEFINED", METHOD_VAL_IS_FIELD = "METHOD_VAL_IS_FIELD", DUPLICATE_ATTR_DEFINITION = "DUPLICATE_ATTR_DEFINITION", IF_NO_BRANCH_SET = "IF_NO_BRANCH_SET", UNKNOWN_REQUEST_NAME = "UNKNOWN_REQUEST_NAME", UNKNOWN_COMPONENT_NAME = "UNKNOWN_COMPONENT_NAME", UNKNOWN_MACRO_ARG = "UNKNOWN_MACRO_ARG", UNKNOWN_DIRECTIVE = "UNKNOWN_DIRECTIVE", UNKNOWN_X_OP = "UNKNOWN_X_OP", UNKNOWN_X_ATTR = "UNKNOWN_X_ATTR", MAYBE_DROP_AT_PREFIX = "MAYBE_DROP_AT_PREFIX", MAYBE_ADD_AT_PREFIX = "MAYBE_ADD_AT_PREFIX", BAD_VALUE = "BAD_VALUE", UNSUPPORTED_EXPR_SYNTAX = "UNSUPPORTED_EXPR_SYNTAX", REDUNDANT_TEMPLATE_STRING = "REDUNDANT_TEMPLATE_STRING", PLACEHOLDERLESS_TEMPLATE_STRING = "PLACEHOLDERLESS_TEMPLATE_STRING", UNKNOWN_COMPONENT_SPEC_KEY = "UNKNOWN_COMPONENT_SPEC_KEY", COMP_FIELD_BAD_SHAPE = "COMP_FIELD_BAD_SHAPE", ASYNC_HANDLER = "ASYNC_HANDLER", X_KNOWN_OP_NAMES, X_KNOWN_ATTR_NAMES, HOST_DIRECTIVE_ONLY_NAMES, LEVEL_WARN2 = "warn", LEVEL_ERROR2 = "error", LEVEL_HINT = "hint", PARSE_ISSUES, UNSUPPORTED_EXPR_GUIDANCE, HTML_LINT_OPTS, NO_WRAPPERS, KNOWN_HANDLER_NAMES, fixTo = (from, to) => ({ kind: "rewrite", from, to }), ATTR_VAL_CHECKERS, NODE_KIND_TO_CTX, HANDLER_CHANNELS, ASYNC_HANDLER_HELP, KNOWN_LOOKUP_KEYS, LintParseContext;
|
|
13455
|
+
var KNOWN_COMPONENT_SPEC_KEYS, EMPTY_SET2, FRAMEWORK_WELL_KNOWN_EXTRAS, KNOWN_DIRECTIVE_NAMES, ALT_HANDLER_NOT_DEFINED = "ALT_HANDLER_NOT_DEFINED", ALT_HANDLER_NOT_REFERENCED = "ALT_HANDLER_NOT_REFERENCED", DYN_VAL_NOT_DEFINED = "DYN_VAL_NOT_DEFINED", DYN_ALIAS_NOT_REFERENCED = "DYN_ALIAS_NOT_REFERENCED", PROVIDE_NOT_ADDRESSABLE = "PROVIDE_NOT_ADDRESSABLE", LOOKUP_BAD_SHAPE = "LOOKUP_BAD_SHAPE", LOOKUP_TARGET_MALFORMED = "LOOKUP_TARGET_MALFORMED", RENDER_IT_OUTSIDE_OF_LOOP = "RENDER_IT_OUTSIDE_OF_LOOP", UNKNOWN_EVENT_MODIFIER = "UNKNOWN_EVENT_MODIFIER", UNKNOWN_HANDLER_ARG_NAME = "UNKNOWN_HANDLER_ARG_NAME", INPUT_HANDLER_NOT_IMPLEMENTED = "INPUT_HANDLER_NOT_IMPLEMENTED", INPUT_HANDLER_NOT_REFERENCED = "INPUT_HANDLER_NOT_REFERENCED", INPUT_HANDLER_METHOD_NOT_IMPLEMENTED = "INPUT_HANDLER_METHOD_NOT_IMPLEMENTED", INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD = "INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD", INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER = "INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER", FIELD_VAL_NOT_DEFINED = "FIELD_VAL_NOT_DEFINED", FIELD_VAL_IS_METHOD = "FIELD_VAL_IS_METHOD", METHOD_VAL_NOT_DEFINED = "METHOD_VAL_NOT_DEFINED", METHOD_VAL_IS_FIELD = "METHOD_VAL_IS_FIELD", DUPLICATE_ATTR_DEFINITION = "DUPLICATE_ATTR_DEFINITION", IF_NO_BRANCH_SET = "IF_NO_BRANCH_SET", UNKNOWN_REQUEST_NAME = "UNKNOWN_REQUEST_NAME", UNKNOWN_COMPONENT_NAME = "UNKNOWN_COMPONENT_NAME", UNKNOWN_MACRO_ARG = "UNKNOWN_MACRO_ARG", UNKNOWN_DIRECTIVE = "UNKNOWN_DIRECTIVE", UNKNOWN_X_OP = "UNKNOWN_X_OP", UNKNOWN_X_ATTR = "UNKNOWN_X_ATTR", MAYBE_DROP_AT_PREFIX = "MAYBE_DROP_AT_PREFIX", MAYBE_ADD_AT_PREFIX = "MAYBE_ADD_AT_PREFIX", BAD_VALUE = "BAD_VALUE", UNSUPPORTED_EXPR_SYNTAX = "UNSUPPORTED_EXPR_SYNTAX", REDUNDANT_TEMPLATE_STRING = "REDUNDANT_TEMPLATE_STRING", PLACEHOLDERLESS_TEMPLATE_STRING = "PLACEHOLDERLESS_TEMPLATE_STRING", UNKNOWN_COMPONENT_SPEC_KEY = "UNKNOWN_COMPONENT_SPEC_KEY", COMP_FIELD_BAD_SHAPE = "COMP_FIELD_BAD_SHAPE", ASYNC_HANDLER = "ASYNC_HANDLER", X_KNOWN_OP_NAMES, X_KNOWN_ATTR_NAMES, HOST_DIRECTIVE_ONLY_NAMES, LEVEL_WARN2 = "warn", LEVEL_ERROR2 = "error", LEVEL_HINT = "hint", PARSE_ISSUES, UNSUPPORTED_EXPR_GUIDANCE, HTML_LINT_OPTS, NO_WRAPPERS, KNOWN_HANDLER_NAMES, fixTo = (from, to) => ({ kind: "rewrite", from, to }), ATTR_VAL_CHECKERS, NODE_KIND_TO_CTX, HANDLER_CHANNELS, ASYNC_HANDLER_HELP, KNOWN_LOOKUP_KEYS, LintParseContext;
|
|
13428
13456
|
var init_lint_check = __esm(() => {
|
|
13429
13457
|
init_anode();
|
|
13430
13458
|
init_htmllinter();
|
|
13431
13459
|
KNOWN_COMPONENT_SPEC_KEYS = new Set("name view style commonStyle globalStyle input receive bubble response alter views provide lookup fields methods statics".split(" "));
|
|
13432
13460
|
EMPTY_SET2 = new Set;
|
|
13461
|
+
FRAMEWORK_WELL_KNOWN_EXTRAS = new Set(["requestOverridesField"]);
|
|
13433
13462
|
KNOWN_DIRECTIVE_NAMES = new Set([
|
|
13434
13463
|
"dangerouslysetinnerhtml",
|
|
13435
13464
|
"slot",
|
|
@@ -13858,6 +13887,7 @@ class Transactor {
|
|
|
13858
13887
|
const txnPath = path.toTransactionPath();
|
|
13859
13888
|
const curLeaf = txnPath.lookup(curRoot);
|
|
13860
13889
|
const handler = this.comps.getRequestFor(curLeaf, name) ?? mkReq404(name);
|
|
13890
|
+
const reqCtx = new RequestContext(path, this, parent, curRoot);
|
|
13861
13891
|
const resHandlerName = opts?.onResName ?? name;
|
|
13862
13892
|
const resPath = opts?.livePath ? null : txnPath.pinKeys(curRoot);
|
|
13863
13893
|
const push = (specificName, baseName, singleArg, result, error) => {
|
|
@@ -13866,7 +13896,7 @@ class Transactor {
|
|
|
13866
13896
|
this.pushTransaction(t);
|
|
13867
13897
|
};
|
|
13868
13898
|
try {
|
|
13869
|
-
const result = await handler.fn.apply(null, args);
|
|
13899
|
+
const result = await handler.fn.apply(null, [...args, reqCtx]);
|
|
13870
13900
|
push(opts?.onOkName, resHandlerName, result, result, null);
|
|
13871
13901
|
} catch (error) {
|
|
13872
13902
|
push(opts?.onErrorName, resHandlerName, error, null, error);
|
|
@@ -13983,10 +14013,20 @@ class Task {
|
|
|
13983
14013
|
}
|
|
13984
14014
|
|
|
13985
14015
|
class Dispatcher {
|
|
13986
|
-
constructor(path, transactor, parentTransaction) {
|
|
14016
|
+
constructor(path, transactor, parentTransaction, root = transactor.state.val) {
|
|
13987
14017
|
this.path = path;
|
|
13988
14018
|
this.transactor = transactor;
|
|
13989
14019
|
this.parent = parentTransaction;
|
|
14020
|
+
this.root = root;
|
|
14021
|
+
}
|
|
14022
|
+
walkPath(callback) {
|
|
14023
|
+
const comps = this.transactor.comps;
|
|
14024
|
+
const chain = this.path.toTransactionPath().resolveChain(this.root);
|
|
14025
|
+
for (let i = chain.length - 1;i >= 0; i--) {
|
|
14026
|
+
const comp = comps.getCompFor(chain[i]);
|
|
14027
|
+
if (comp && callback(comp, chain[i]) === false)
|
|
14028
|
+
return;
|
|
14029
|
+
}
|
|
13990
14030
|
}
|
|
13991
14031
|
get at() {
|
|
13992
14032
|
return new PathChanges(this);
|
|
@@ -14010,7 +14050,7 @@ class Dispatcher {
|
|
|
14010
14050
|
return this.transactor.comps.getCompFor(inst).scope.lookupComponent(name);
|
|
14011
14051
|
}
|
|
14012
14052
|
}
|
|
14013
|
-
var toNullIfNaN = (v) => Number.isNaN(v) ? null : v, InputEvent, NameArgsTransaction, ResponseEvent, SendEvent, BubbleEvent, EventContext, PathChanges;
|
|
14053
|
+
var toNullIfNaN = (v) => Number.isNaN(v) ? null : v, InputEvent, NameArgsTransaction, ResponseEvent, SendEvent, BubbleEvent, EventContext, RequestContext, PathChanges;
|
|
14014
14054
|
var init_transactor = __esm(() => {
|
|
14015
14055
|
init_path();
|
|
14016
14056
|
init_stack();
|
|
@@ -14146,6 +14186,8 @@ var init_transactor = __esm(() => {
|
|
|
14146
14186
|
return this.parent.stopPropagation();
|
|
14147
14187
|
}
|
|
14148
14188
|
};
|
|
14189
|
+
RequestContext = class RequestContext extends Dispatcher {
|
|
14190
|
+
};
|
|
14149
14191
|
PathChanges = class PathChanges extends PathBuilder {
|
|
14150
14192
|
constructor(dispatcher) {
|
|
14151
14193
|
super();
|
|
@@ -15858,7 +15900,8 @@ async function discoverModules(projectDir, devModuleUrls) {
|
|
|
15858
15900
|
items: s.items.map((it) => ({
|
|
15859
15901
|
title: it.title,
|
|
15860
15902
|
view: it.view,
|
|
15861
|
-
componentName: it.componentName
|
|
15903
|
+
componentName: it.componentName,
|
|
15904
|
+
requestHandlers: it.requestHandlerNames
|
|
15862
15905
|
}))
|
|
15863
15906
|
})),
|
|
15864
15907
|
macros: normalized.macros ? Object.keys(normalized.macros) : [],
|
package/dist/tutuca-dev.ext.js
CHANGED
|
@@ -348,6 +348,17 @@ class Path {
|
|
|
348
348
|
}
|
|
349
349
|
return curVal;
|
|
350
350
|
}
|
|
351
|
+
resolveChain(root) {
|
|
352
|
+
const out = [root];
|
|
353
|
+
let curVal = root;
|
|
354
|
+
for (const step of this.steps) {
|
|
355
|
+
curVal = step.lookup(curVal, NONE);
|
|
356
|
+
if (curVal === NONE)
|
|
357
|
+
break;
|
|
358
|
+
out.push(curVal);
|
|
359
|
+
}
|
|
360
|
+
return out;
|
|
361
|
+
}
|
|
351
362
|
setValue(root, v) {
|
|
352
363
|
const intermediates = new Array(this.steps.length);
|
|
353
364
|
let curVal = root;
|
|
@@ -4971,6 +4982,7 @@ function closestName(name, candidates, maxDistance = 2) {
|
|
|
4971
4982
|
// tools/core/lint-check.js
|
|
4972
4983
|
var KNOWN_COMPONENT_SPEC_KEYS = new Set("name view style commonStyle globalStyle input receive bubble response alter views provide lookup fields methods statics".split(" "));
|
|
4973
4984
|
var EMPTY_SET = new Set;
|
|
4985
|
+
var FRAMEWORK_WELL_KNOWN_EXTRAS = new Set(["requestOverridesField"]);
|
|
4974
4986
|
var KNOWN_DIRECTIVE_NAMES = new Set([
|
|
4975
4987
|
"dangerouslysetinnerhtml",
|
|
4976
4988
|
"slot",
|
|
@@ -5565,9 +5577,13 @@ function checkUnknownSpecKeys(lx, Comp, wellKnownExtras) {
|
|
|
5565
5577
|
return;
|
|
5566
5578
|
let candidates = null;
|
|
5567
5579
|
for (const key of Object.keys(extra)) {
|
|
5568
|
-
if (wellKnownExtras.has(key))
|
|
5580
|
+
if (FRAMEWORK_WELL_KNOWN_EXTRAS.has(key) || wellKnownExtras.has(key))
|
|
5569
5581
|
continue;
|
|
5570
|
-
candidates ??= [
|
|
5582
|
+
candidates ??= [
|
|
5583
|
+
...KNOWN_COMPONENT_SPEC_KEYS,
|
|
5584
|
+
...FRAMEWORK_WELL_KNOWN_EXTRAS,
|
|
5585
|
+
...wellKnownExtras
|
|
5586
|
+
];
|
|
5571
5587
|
lx.warn(UNKNOWN_COMPONENT_SPEC_KEY, { key }, replaceNameSuggestion(key, candidates));
|
|
5572
5588
|
}
|
|
5573
5589
|
}
|
|
@@ -6776,6 +6792,7 @@ class Transactor {
|
|
|
6776
6792
|
const txnPath = path.toTransactionPath();
|
|
6777
6793
|
const curLeaf = txnPath.lookup(curRoot);
|
|
6778
6794
|
const handler = this.comps.getRequestFor(curLeaf, name) ?? mkReq404(name);
|
|
6795
|
+
const reqCtx = new RequestContext(path, this, parent, curRoot);
|
|
6779
6796
|
const resHandlerName = opts?.onResName ?? name;
|
|
6780
6797
|
const resPath = opts?.livePath ? null : txnPath.pinKeys(curRoot);
|
|
6781
6798
|
const push = (specificName, baseName, singleArg, result, error) => {
|
|
@@ -6784,7 +6801,7 @@ class Transactor {
|
|
|
6784
6801
|
this.pushTransaction(t);
|
|
6785
6802
|
};
|
|
6786
6803
|
try {
|
|
6787
|
-
const result = await handler.fn.apply(null, args);
|
|
6804
|
+
const result = await handler.fn.apply(null, [...args, reqCtx]);
|
|
6788
6805
|
push(opts?.onOkName, resHandlerName, result, result, null);
|
|
6789
6806
|
} catch (error) {
|
|
6790
6807
|
push(opts?.onErrorName, resHandlerName, error, null, error);
|
|
@@ -7027,10 +7044,20 @@ class Task {
|
|
|
7027
7044
|
}
|
|
7028
7045
|
|
|
7029
7046
|
class Dispatcher {
|
|
7030
|
-
constructor(path, transactor, parentTransaction) {
|
|
7047
|
+
constructor(path, transactor, parentTransaction, root = transactor.state.val) {
|
|
7031
7048
|
this.path = path;
|
|
7032
7049
|
this.transactor = transactor;
|
|
7033
7050
|
this.parent = parentTransaction;
|
|
7051
|
+
this.root = root;
|
|
7052
|
+
}
|
|
7053
|
+
walkPath(callback) {
|
|
7054
|
+
const comps = this.transactor.comps;
|
|
7055
|
+
const chain = this.path.toTransactionPath().resolveChain(this.root);
|
|
7056
|
+
for (let i = chain.length - 1;i >= 0; i--) {
|
|
7057
|
+
const comp = comps.getCompFor(chain[i]);
|
|
7058
|
+
if (comp && callback(comp, chain[i]) === false)
|
|
7059
|
+
return;
|
|
7060
|
+
}
|
|
7034
7061
|
}
|
|
7035
7062
|
get at() {
|
|
7036
7063
|
return new PathChanges(this);
|
|
@@ -7067,6 +7094,9 @@ class EventContext extends Dispatcher {
|
|
|
7067
7094
|
}
|
|
7068
7095
|
}
|
|
7069
7096
|
|
|
7097
|
+
class RequestContext extends Dispatcher {
|
|
7098
|
+
}
|
|
7099
|
+
|
|
7070
7100
|
class PathChanges extends PathBuilder {
|
|
7071
7101
|
constructor(dispatcher) {
|
|
7072
7102
|
super();
|
package/dist/tutuca-dev.js
CHANGED
|
@@ -8002,6 +8002,17 @@ class Path {
|
|
|
8002
8002
|
}
|
|
8003
8003
|
return curVal;
|
|
8004
8004
|
}
|
|
8005
|
+
resolveChain(root) {
|
|
8006
|
+
const out = [root];
|
|
8007
|
+
let curVal = root;
|
|
8008
|
+
for (const step of this.steps) {
|
|
8009
|
+
curVal = step.lookup(curVal, NONE);
|
|
8010
|
+
if (curVal === NONE)
|
|
8011
|
+
break;
|
|
8012
|
+
out.push(curVal);
|
|
8013
|
+
}
|
|
8014
|
+
return out;
|
|
8015
|
+
}
|
|
8005
8016
|
setValue(root, v) {
|
|
8006
8017
|
const intermediates = new Array(this.steps.length);
|
|
8007
8018
|
let curVal = root;
|
|
@@ -12622,6 +12633,7 @@ function closestName(name, candidates, maxDistance = 2) {
|
|
|
12622
12633
|
// tools/core/lint-check.js
|
|
12623
12634
|
var KNOWN_COMPONENT_SPEC_KEYS = new Set("name view style commonStyle globalStyle input receive bubble response alter views provide lookup fields methods statics".split(" "));
|
|
12624
12635
|
var EMPTY_SET2 = new Set;
|
|
12636
|
+
var FRAMEWORK_WELL_KNOWN_EXTRAS = new Set(["requestOverridesField"]);
|
|
12625
12637
|
var KNOWN_DIRECTIVE_NAMES = new Set([
|
|
12626
12638
|
"dangerouslysetinnerhtml",
|
|
12627
12639
|
"slot",
|
|
@@ -13216,9 +13228,13 @@ function checkUnknownSpecKeys(lx, Comp, wellKnownExtras) {
|
|
|
13216
13228
|
return;
|
|
13217
13229
|
let candidates = null;
|
|
13218
13230
|
for (const key of Object.keys(extra)) {
|
|
13219
|
-
if (wellKnownExtras.has(key))
|
|
13231
|
+
if (FRAMEWORK_WELL_KNOWN_EXTRAS.has(key) || wellKnownExtras.has(key))
|
|
13220
13232
|
continue;
|
|
13221
|
-
candidates ??= [
|
|
13233
|
+
candidates ??= [
|
|
13234
|
+
...KNOWN_COMPONENT_SPEC_KEYS,
|
|
13235
|
+
...FRAMEWORK_WELL_KNOWN_EXTRAS,
|
|
13236
|
+
...wellKnownExtras
|
|
13237
|
+
];
|
|
13222
13238
|
lx.warn(UNKNOWN_COMPONENT_SPEC_KEY, { key }, replaceNameSuggestion(key, candidates));
|
|
13223
13239
|
}
|
|
13224
13240
|
}
|
|
@@ -14427,6 +14443,7 @@ class Transactor {
|
|
|
14427
14443
|
const txnPath = path.toTransactionPath();
|
|
14428
14444
|
const curLeaf = txnPath.lookup(curRoot);
|
|
14429
14445
|
const handler = this.comps.getRequestFor(curLeaf, name) ?? mkReq404(name);
|
|
14446
|
+
const reqCtx = new RequestContext(path, this, parent, curRoot);
|
|
14430
14447
|
const resHandlerName = opts?.onResName ?? name;
|
|
14431
14448
|
const resPath = opts?.livePath ? null : txnPath.pinKeys(curRoot);
|
|
14432
14449
|
const push = (specificName, baseName, singleArg, result, error) => {
|
|
@@ -14435,7 +14452,7 @@ class Transactor {
|
|
|
14435
14452
|
this.pushTransaction(t);
|
|
14436
14453
|
};
|
|
14437
14454
|
try {
|
|
14438
|
-
const result = await handler.fn.apply(null, args);
|
|
14455
|
+
const result = await handler.fn.apply(null, [...args, reqCtx]);
|
|
14439
14456
|
push(opts?.onOkName, resHandlerName, result, result, null);
|
|
14440
14457
|
} catch (error) {
|
|
14441
14458
|
push(opts?.onErrorName, resHandlerName, error, null, error);
|
|
@@ -14678,10 +14695,20 @@ class Task {
|
|
|
14678
14695
|
}
|
|
14679
14696
|
|
|
14680
14697
|
class Dispatcher {
|
|
14681
|
-
constructor(path, transactor, parentTransaction) {
|
|
14698
|
+
constructor(path, transactor, parentTransaction, root = transactor.state.val) {
|
|
14682
14699
|
this.path = path;
|
|
14683
14700
|
this.transactor = transactor;
|
|
14684
14701
|
this.parent = parentTransaction;
|
|
14702
|
+
this.root = root;
|
|
14703
|
+
}
|
|
14704
|
+
walkPath(callback) {
|
|
14705
|
+
const comps = this.transactor.comps;
|
|
14706
|
+
const chain = this.path.toTransactionPath().resolveChain(this.root);
|
|
14707
|
+
for (let i = chain.length - 1;i >= 0; i--) {
|
|
14708
|
+
const comp = comps.getCompFor(chain[i]);
|
|
14709
|
+
if (comp && callback(comp, chain[i]) === false)
|
|
14710
|
+
return;
|
|
14711
|
+
}
|
|
14685
14712
|
}
|
|
14686
14713
|
get at() {
|
|
14687
14714
|
return new PathChanges(this);
|
|
@@ -14718,6 +14745,9 @@ class EventContext extends Dispatcher {
|
|
|
14718
14745
|
}
|
|
14719
14746
|
}
|
|
14720
14747
|
|
|
14748
|
+
class RequestContext extends Dispatcher {
|
|
14749
|
+
}
|
|
14750
|
+
|
|
14721
14751
|
class PathChanges extends PathBuilder {
|
|
14722
14752
|
constructor(dispatcher) {
|
|
14723
14753
|
super();
|