tutuca 0.9.94 → 0.9.95

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.
@@ -14892,6 +14892,26 @@ function captureError(e) {
14892
14892
  out.actual = e.actual;
14893
14893
  return out;
14894
14894
  }
14895
+ function buildStack({ components = [], macros = null, requestHandlers = null } = {}) {
14896
+ const stack = new ComponentStack;
14897
+ stack.registerComponents(components);
14898
+ if (macros)
14899
+ stack.registerMacros(macros);
14900
+ if (requestHandlers)
14901
+ stack.registerRequestHandlers(requestHandlers);
14902
+ return stack;
14903
+ }
14904
+ async function driveStack(stack, value, phase, opts = {}) {
14905
+ const transactor = new Transactor(stack.comps, value);
14906
+ if (opts.onMessage)
14907
+ transactor.state.onChange(({ val, old, info }) => {
14908
+ const t = info?.transaction;
14909
+ opts.onMessage({ kind: t?.handlerProp ?? "input", name: t?.name, args: t?.args, path: t?.path }, old, val);
14910
+ });
14911
+ dispatchPhase(rootDispatcher(transactor), new Path([]), phase, value);
14912
+ await transactor.settle();
14913
+ return transactor.state.val;
14914
+ }
14895
14915
  async function runTests({
14896
14916
  getTests,
14897
14917
  components = [],
@@ -14913,30 +14933,10 @@ async function runTests({
14913
14933
  throw new Error("runTests: expect must be provided (e.g. chai's expect)");
14914
14934
  }
14915
14935
  const { describe, test: test2, moduleTests } = makeCollector({ path, components });
14916
- await getTests({ describe, test: test2, expect: expect2, drive });
14917
14936
  let _stack = null;
14918
- function getStack() {
14919
- if (_stack)
14920
- return _stack;
14921
- _stack = new ComponentStack;
14922
- _stack.registerComponents(components);
14923
- if (macros)
14924
- _stack.registerMacros(macros);
14925
- if (requestHandlers)
14926
- _stack.registerRequestHandlers(requestHandlers);
14927
- return _stack;
14928
- }
14929
- async function drive(value, phase, opts = {}) {
14930
- const transactor = new Transactor(getStack().comps, value);
14931
- if (opts.onMessage)
14932
- transactor.state.onChange(({ val, old, info }) => {
14933
- const t = info?.transaction;
14934
- opts.onMessage({ kind: t?.handlerProp ?? "input", name: t?.name, args: t?.args, path: t?.path }, old, val);
14935
- });
14936
- dispatchPhase(rootDispatcher(transactor), new Path([]), phase, value);
14937
- await transactor.settle();
14938
- return transactor.state.val;
14939
- }
14937
+ const getStack = () => _stack ??= buildStack({ components, macros, requestHandlers });
14938
+ const driveLocal = (value, phase, opts = {}) => driveStack(getStack(), value, phase, opts);
14939
+ await getTests({ describe, test: test2, expect: expect2, drive: driveLocal });
14940
14940
  let bailed = false;
14941
14941
  async function visit(node) {
14942
14942
  if (node instanceof Test) {
@@ -6928,6 +6928,29 @@ function captureError(e) {
6928
6928
  out.actual = e.actual;
6929
6929
  return out;
6930
6930
  }
6931
+ function buildStack({ components = [], macros = null, requestHandlers = null } = {}) {
6932
+ const stack = new ComponentStack;
6933
+ stack.registerComponents(components);
6934
+ if (macros)
6935
+ stack.registerMacros(macros);
6936
+ if (requestHandlers)
6937
+ stack.registerRequestHandlers(requestHandlers);
6938
+ return stack;
6939
+ }
6940
+ async function driveStack(stack, value, phase, opts = {}) {
6941
+ const transactor = new Transactor(stack.comps, value);
6942
+ if (opts.onMessage)
6943
+ transactor.state.onChange(({ val, old, info }) => {
6944
+ const t = info?.transaction;
6945
+ opts.onMessage({ kind: t?.handlerProp ?? "input", name: t?.name, args: t?.args, path: t?.path }, old, val);
6946
+ });
6947
+ dispatchPhase(rootDispatcher(transactor), new Path([]), phase, value);
6948
+ await transactor.settle();
6949
+ return transactor.state.val;
6950
+ }
6951
+ async function drive(cfg, value, phase, opts = {}) {
6952
+ return driveStack(buildStack(cfg), value, phase, opts);
6953
+ }
6931
6954
  async function runTests({
6932
6955
  getTests,
6933
6956
  components = [],
@@ -6949,30 +6972,10 @@ async function runTests({
6949
6972
  throw new Error("runTests: expect must be provided (e.g. chai's expect)");
6950
6973
  }
6951
6974
  const { describe, test, moduleTests } = makeCollector({ path, components });
6952
- await getTests({ describe, test, expect: expect2, drive });
6953
6975
  let _stack = null;
6954
- function getStack() {
6955
- if (_stack)
6956
- return _stack;
6957
- _stack = new ComponentStack;
6958
- _stack.registerComponents(components);
6959
- if (macros)
6960
- _stack.registerMacros(macros);
6961
- if (requestHandlers)
6962
- _stack.registerRequestHandlers(requestHandlers);
6963
- return _stack;
6964
- }
6965
- async function drive(value, phase, opts = {}) {
6966
- const transactor = new Transactor(getStack().comps, value);
6967
- if (opts.onMessage)
6968
- transactor.state.onChange(({ val, old, info }) => {
6969
- const t = info?.transaction;
6970
- opts.onMessage({ kind: t?.handlerProp ?? "input", name: t?.name, args: t?.args, path: t?.path }, old, val);
6971
- });
6972
- dispatchPhase(rootDispatcher(transactor), new Path([]), phase, value);
6973
- await transactor.settle();
6974
- return transactor.state.val;
6975
- }
6976
+ const getStack = () => _stack ??= buildStack({ components, macros, requestHandlers });
6977
+ const driveLocal = (value, phase, opts = {}) => driveStack(getStack(), value, phase, opts);
6978
+ await getTests({ describe, test, expect: expect2, drive: driveLocal });
6976
6979
  let bailed = false;
6977
6980
  async function visit(node) {
6978
6981
  if (node instanceof Test) {
@@ -8408,6 +8411,7 @@ export {
8408
8411
  getComponentsDocs,
8409
8412
  get,
8410
8413
  fromJS,
8414
+ drive,
8411
8415
  docComponents,
8412
8416
  dispatchPhase,
8413
8417
  css,
@@ -14579,6 +14579,29 @@ function captureError(e) {
14579
14579
  out.actual = e.actual;
14580
14580
  return out;
14581
14581
  }
14582
+ function buildStack({ components = [], macros = null, requestHandlers = null } = {}) {
14583
+ const stack = new ComponentStack;
14584
+ stack.registerComponents(components);
14585
+ if (macros)
14586
+ stack.registerMacros(macros);
14587
+ if (requestHandlers)
14588
+ stack.registerRequestHandlers(requestHandlers);
14589
+ return stack;
14590
+ }
14591
+ async function driveStack(stack, value, phase, opts = {}) {
14592
+ const transactor = new Transactor(stack.comps, value);
14593
+ if (opts.onMessage)
14594
+ transactor.state.onChange(({ val, old, info }) => {
14595
+ const t = info?.transaction;
14596
+ opts.onMessage({ kind: t?.handlerProp ?? "input", name: t?.name, args: t?.args, path: t?.path }, old, val);
14597
+ });
14598
+ dispatchPhase(rootDispatcher(transactor), new Path([]), phase, value);
14599
+ await transactor.settle();
14600
+ return transactor.state.val;
14601
+ }
14602
+ async function drive(cfg, value, phase, opts = {}) {
14603
+ return driveStack(buildStack(cfg), value, phase, opts);
14604
+ }
14582
14605
  async function runTests({
14583
14606
  getTests,
14584
14607
  components = [],
@@ -14600,30 +14623,10 @@ async function runTests({
14600
14623
  throw new Error("runTests: expect must be provided (e.g. chai's expect)");
14601
14624
  }
14602
14625
  const { describe, test: test2, moduleTests } = makeCollector({ path, components });
14603
- await getTests({ describe, test: test2, expect: expect2, drive });
14604
14626
  let _stack = null;
14605
- function getStack() {
14606
- if (_stack)
14607
- return _stack;
14608
- _stack = new ComponentStack;
14609
- _stack.registerComponents(components);
14610
- if (macros)
14611
- _stack.registerMacros(macros);
14612
- if (requestHandlers)
14613
- _stack.registerRequestHandlers(requestHandlers);
14614
- return _stack;
14615
- }
14616
- async function drive(value, phase, opts = {}) {
14617
- const transactor = new Transactor(getStack().comps, value);
14618
- if (opts.onMessage)
14619
- transactor.state.onChange(({ val, old, info }) => {
14620
- const t = info?.transaction;
14621
- opts.onMessage({ kind: t?.handlerProp ?? "input", name: t?.name, args: t?.args, path: t?.path }, old, val);
14622
- });
14623
- dispatchPhase(rootDispatcher(transactor), new Path([]), phase, value);
14624
- await transactor.settle();
14625
- return transactor.state.val;
14626
- }
14627
+ const getStack = () => _stack ??= buildStack({ components, macros, requestHandlers });
14628
+ const driveLocal = (value, phase, opts = {}) => driveStack(getStack(), value, phase, opts);
14629
+ await getTests({ describe, test: test2, expect: expect2, drive: driveLocal });
14627
14630
  let bailed = false;
14628
14631
  async function visit(node) {
14629
14632
  if (node instanceof Test) {
@@ -16002,6 +16005,7 @@ export {
16002
16005
  getComponentsDocs,
16003
16006
  get2 as get,
16004
16007
  fromJS,
16008
+ drive,
16005
16009
  docComponents,
16006
16010
  dispatchPhase,
16007
16011
  css,