tutuca 0.9.99 → 0.9.101

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.
@@ -9776,7 +9776,7 @@ class Renderer {
9776
9776
  return comp ? this._rValComp(stack, stack.it, comp, node, key, viewName) : null;
9777
9777
  }
9778
9778
  _rValComp(stack, val, comp, node, key, viewName) {
9779
- const cacheKey = `${viewName ?? stack.viewsId ?? ""}-${key}`;
9779
+ const cacheKey = `${viewName ?? ""}\x1F${stack.viewsId ?? ""}\x1F${key}`;
9780
9780
  const cachePath = [node, val];
9781
9781
  stack._pushDynBindValuesToArray(cachePath, comp);
9782
9782
  const cachedNode = this.cache.get(cachePath, cacheKey);
@@ -9821,7 +9821,7 @@ class Renderer {
9821
9821
  const renderOne = (key, value, attrName) => {
9822
9822
  const cachePath = enricher ? [view, it, value] : [view, value];
9823
9823
  const binds = { key, value };
9824
- const cacheKey = `${nid}-${key}`;
9824
+ const cacheKey = `${stack.viewsId ?? ""}\x1F${nid}\x1F${key}`;
9825
9825
  if (enricher)
9826
9826
  enricher.call(it, binds, key, value, iterData);
9827
9827
  const cachedNode = this.cache.get(cachePath, cacheKey);
@@ -9958,7 +9958,8 @@ function parseXOp(attrs, childs, opIdx, px) {
9958
9958
  if (attrs.length <= opIdx)
9959
9959
  return maybeFragment(childs);
9960
9960
  const { name, value } = attrs[opIdx];
9961
- const as = attrs.getNamedItem("as")?.value ?? null;
9961
+ const asAttr = attrs.getNamedItem("as")?.value ?? null;
9962
+ const as = asAttr === null ? null : parseViewName(asAttr, px);
9962
9963
  let node;
9963
9964
  switch (name) {
9964
9965
  case "slot":
@@ -9998,6 +9999,9 @@ function parseXOpVal(opName, value, px, parserFn) {
9998
9999
  px.onParseIssue("bad-value", { role: "x-op", op: opName, value });
9999
10000
  return val;
10000
10001
  }
10002
+ function parseViewName(s, px) {
10003
+ return vp.parseText(s, px) ?? vp.const(s);
10004
+ }
10001
10005
  function processXExtras(node, attrs, opName, startIdx, px) {
10002
10006
  const { consumed, wrappable } = X_OPS[opName];
10003
10007
  const wrappers = [];
@@ -10427,16 +10431,19 @@ var init_anode = __esm(() => {
10427
10431
  }
10428
10432
  };
10429
10433
  RenderViewId = class RenderViewId extends ANode {
10430
- constructor(nodeId, val, viewId) {
10434
+ constructor(nodeId, val, viewVal) {
10431
10435
  super(nodeId, val);
10432
- this.viewId = viewId;
10436
+ this.viewVal = viewVal;
10437
+ }
10438
+ evalViewName(stack) {
10439
+ return this.viewVal ? this.viewVal.eval(stack) : null;
10433
10440
  }
10434
10441
  setDataAttr(_key, _val) {}
10435
10442
  };
10436
10443
  RenderNode = class RenderNode extends RenderViewId {
10437
10444
  render(stack, rx) {
10438
10445
  const newStack = stack.enter(this.val.eval(stack), {}, true);
10439
- return rx.renderIt(newStack, this, "", this.viewId);
10446
+ return rx.renderIt(newStack, this, "", this.evalViewName(stack));
10440
10447
  }
10441
10448
  toPathStep(ctx) {
10442
10449
  if (this.val instanceof DynVal)
@@ -10447,7 +10454,7 @@ var init_anode = __esm(() => {
10447
10454
  RenderItNode = class RenderItNode extends RenderViewId {
10448
10455
  render(stack, rx) {
10449
10456
  const newStack = stack.enter(stack.it, {}, true);
10450
- return rx.renderIt(newStack, this, "", this.viewId);
10457
+ return rx.renderIt(newStack, this, "", this.evalViewName(stack));
10451
10458
  }
10452
10459
  toPathStep(ctx) {
10453
10460
  const next = ctx.next();
@@ -10463,12 +10470,12 @@ var init_anode = __esm(() => {
10463
10470
  }
10464
10471
  };
10465
10472
  RenderEachNode = class RenderEachNode extends RenderViewId {
10466
- constructor(nodeId, val, viewId) {
10467
- super(nodeId, val, viewId);
10473
+ constructor(nodeId, val, viewVal) {
10474
+ super(nodeId, val, viewVal);
10468
10475
  this.iterInfo = new IterInfo(val, null, null, null);
10469
10476
  }
10470
10477
  render(stack, rx) {
10471
- return rx.renderEach(stack, this.iterInfo, this, this.viewId);
10478
+ return rx.renderEach(stack, this.iterInfo, this, this.evalViewName(stack));
10472
10479
  }
10473
10480
  toPathStep(ctx) {
10474
10481
  if (this.val instanceof DynVal)
@@ -16138,7 +16145,7 @@ ${JSON.stringify({ imports }, null, 6)}
16138
16145
  </html>
16139
16146
  `;
16140
16147
  }
16141
- function renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3 }) {
16148
+ function renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3, noCache }) {
16142
16149
  const lines = ['import { mountStorybook } from "tutuca/storybook";'];
16143
16150
  if (margaui) {
16144
16151
  lines.push('import { compileClassesToStyleText } from "tutuca/extra";');
@@ -16158,6 +16165,8 @@ function renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3 }) {
16158
16165
  optParts.push("compileCss: (app) => compileClassesToStyleText(app, compile)");
16159
16166
  if (inspect3)
16160
16167
  optParts.push("dev: { shadowCheckComponent, runTests, expect }");
16168
+ if (noCache)
16169
+ optParts.push("noCache: true");
16161
16170
  const opts = optParts.length ? `{ ${optParts.join(", ")} }` : "{}";
16162
16171
  lines.push("");
16163
16172
  lines.push(`const app = await mountStorybook("#app", [${modules}], ${opts});`);
@@ -16274,6 +16283,7 @@ async function run4(argv, opts = {}) {
16274
16283
  "no-check": { type: "boolean", default: false },
16275
16284
  "no-inspect": { type: "boolean", default: false },
16276
16285
  "no-tests": { type: "boolean", default: false },
16286
+ "no-cache": { type: "boolean", default: false },
16277
16287
  "dry-run": { type: "boolean", default: false },
16278
16288
  help: { type: "boolean", short: "h", default: false }
16279
16289
  },
@@ -16282,6 +16292,7 @@ async function run4(argv, opts = {}) {
16282
16292
  if (parsed.values.help) {
16283
16293
  process.stdout.write(`tutuca storybook [dir] [--port <n>] [--out <dir>] [--dry-run]
16284
16294
  [--no-margaui] [--no-check] [--no-inspect] [--no-tests]
16295
+ [--no-cache]
16285
16296
 
16286
16297
  Auto-discovers co-located *.dev.js modules (recursively, skipping
16287
16298
  node_modules/dotdirs) and serves a live storybook that mounts them via
@@ -16298,6 +16309,7 @@ async function run4(argv, opts = {}) {
16298
16309
  --no-check skip the in-browser check(app) dev validation
16299
16310
  --no-inspect skip the per-example Component/Instance/Data/Lint/Test tabs
16300
16311
  --no-tests skip running the modules' getTests() before serving
16312
+ --no-cache disable the render cache (NullDomCache); see every re-render
16301
16313
  `);
16302
16314
  return;
16303
16315
  }
@@ -16320,6 +16332,7 @@ async function run4(argv, opts = {}) {
16320
16332
  const margaui = !parsed.values["no-margaui"];
16321
16333
  const check = !parsed.values["no-check"];
16322
16334
  const inspect3 = !parsed.values["no-inspect"];
16335
+ const noCache = parsed.values["no-cache"];
16323
16336
  const self = findSelf();
16324
16337
  if (parsed.values.out) {
16325
16338
  const outDir = resolve5(parsed.values.out);
@@ -16328,7 +16341,7 @@ async function run4(argv, opts = {}) {
16328
16341
  const imports2 = buildImports(base2, { margaui });
16329
16342
  const bootstrapName = "tutuca-storybook.bootstrap.js";
16330
16343
  writeFileSync(resolve5(outDir, "index.html"), renderIndexHtml(imports2, { margaui, bootstrapUrl: `./${bootstrapName}` }));
16331
- writeFileSync(resolve5(outDir, bootstrapName), renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3 }));
16344
+ writeFileSync(resolve5(outDir, bootstrapName), renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3, noCache }));
16332
16345
  process.stdout.write(`wrote static storybook → ${relative2(process.cwd(), outDir) || "."}/
16333
16346
  index.html + ${bootstrapName} (${devModuleUrls.length} dev modules, CDN import map)
16334
16347
  Host it from the project root so /*.dev.js paths resolve.
@@ -16344,7 +16357,7 @@ async function run4(argv, opts = {}) {
16344
16357
  const result = {
16345
16358
  projectDir,
16346
16359
  tutuca: { source, base: base2, version: self.version },
16347
- options: { margaui, check, runTests: !parsed.values["no-tests"] },
16360
+ options: { margaui, check, noCache, runTests: !parsed.values["no-tests"] },
16348
16361
  imports: imports2,
16349
16362
  modules,
16350
16363
  tests
@@ -16357,7 +16370,7 @@ async function run4(argv, opts = {}) {
16357
16370
  process.stdout.write(`tutuca storybook dry run (no server started)
16358
16371
  project: ${projectDir}
16359
16372
  tutuca runtime: ${source} (${base2}, version ${self.version})
16360
- margaui: ${margaui ? "on" : "off"}, in-browser check: ${check ? "on" : "off"}
16373
+ margaui: ${margaui ? "on" : "off"}, in-browser check: ${check ? "on" : "off"}, cache: ${noCache ? "off" : "on"}
16361
16374
  ${modules.length} dev module(s):
16362
16375
  `);
16363
16376
  for (const m of modules) {
@@ -16413,7 +16426,7 @@ async function run4(argv, opts = {}) {
16413
16426
  const { base, serveDist } = resolveTutucaBase(projectDir, self, false);
16414
16427
  const imports = buildImports(base, { margaui });
16415
16428
  const indexHtml = renderIndexHtml(imports, { margaui, bootstrapUrl: BOOTSTRAP_URL });
16416
- const bootstrapJs = renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3 });
16429
+ const bootstrapJs = renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3, noCache });
16417
16430
  const server = createServer((req, res) => {
16418
16431
  const path = req.url.split("?")[0];
16419
16432
  if (path === "/" || path === "/index.html") {
@@ -1818,7 +1818,7 @@ class Renderer {
1818
1818
  return comp ? this._rValComp(stack, stack.it, comp, node, key, viewName) : null;
1819
1819
  }
1820
1820
  _rValComp(stack, val, comp, node, key, viewName) {
1821
- const cacheKey = `${viewName ?? stack.viewsId ?? ""}-${key}`;
1821
+ const cacheKey = `${viewName ?? ""}\x1F${stack.viewsId ?? ""}\x1F${key}`;
1822
1822
  const cachePath = [node, val];
1823
1823
  stack._pushDynBindValuesToArray(cachePath, comp);
1824
1824
  const cachedNode = this.cache.get(cachePath, cacheKey);
@@ -1863,7 +1863,7 @@ class Renderer {
1863
1863
  const renderOne = (key, value, attrName) => {
1864
1864
  const cachePath = enricher ? [view, it, value] : [view, value];
1865
1865
  const binds = { key, value };
1866
- const cacheKey = `${nid}-${key}`;
1866
+ const cacheKey = `${stack.viewsId ?? ""}\x1F${nid}\x1F${key}`;
1867
1867
  if (enricher)
1868
1868
  enricher.call(it, binds, key, value, iterData);
1869
1869
  const cachedNode = this.cache.get(cachePath, cacheKey);
@@ -2156,7 +2156,8 @@ function parseXOp(attrs, childs, opIdx, px) {
2156
2156
  if (attrs.length <= opIdx)
2157
2157
  return maybeFragment(childs);
2158
2158
  const { name, value } = attrs[opIdx];
2159
- const as = attrs.getNamedItem("as")?.value ?? null;
2159
+ const asAttr = attrs.getNamedItem("as")?.value ?? null;
2160
+ const as = asAttr === null ? null : parseViewName(asAttr, px);
2160
2161
  let node;
2161
2162
  switch (name) {
2162
2163
  case "slot":
@@ -2196,6 +2197,9 @@ function parseXOpVal(opName, value, px, parserFn) {
2196
2197
  px.onParseIssue("bad-value", { role: "x-op", op: opName, value });
2197
2198
  return val;
2198
2199
  }
2200
+ function parseViewName(s, px) {
2201
+ return vp.parseText(s, px) ?? vp.const(s);
2202
+ }
2199
2203
  function processXExtras(node, attrs, opName, startIdx, px) {
2200
2204
  const { consumed, wrappable } = X_OPS[opName];
2201
2205
  const wrappers = [];
@@ -2292,9 +2296,12 @@ class Macro {
2292
2296
  }
2293
2297
 
2294
2298
  class RenderViewId extends ANode {
2295
- constructor(nodeId, val, viewId) {
2299
+ constructor(nodeId, val, viewVal) {
2296
2300
  super(nodeId, val);
2297
- this.viewId = viewId;
2301
+ this.viewVal = viewVal;
2302
+ }
2303
+ evalViewName(stack) {
2304
+ return this.viewVal ? this.viewVal.eval(stack) : null;
2298
2305
  }
2299
2306
  setDataAttr(_key, _val) {}
2300
2307
  }
@@ -2308,7 +2315,7 @@ function dynRenderStep(comp, name, key) {
2308
2315
  class RenderNode extends RenderViewId {
2309
2316
  render(stack, rx) {
2310
2317
  const newStack = stack.enter(this.val.eval(stack), {}, true);
2311
- return rx.renderIt(newStack, this, "", this.viewId);
2318
+ return rx.renderIt(newStack, this, "", this.evalViewName(stack));
2312
2319
  }
2313
2320
  toPathStep(ctx) {
2314
2321
  if (this.val instanceof DynVal)
@@ -2320,7 +2327,7 @@ class RenderNode extends RenderViewId {
2320
2327
  class RenderItNode extends RenderViewId {
2321
2328
  render(stack, rx) {
2322
2329
  const newStack = stack.enter(stack.it, {}, true);
2323
- return rx.renderIt(newStack, this, "", this.viewId);
2330
+ return rx.renderIt(newStack, this, "", this.evalViewName(stack));
2324
2331
  }
2325
2332
  toPathStep(ctx) {
2326
2333
  const next = ctx.next();
@@ -2337,12 +2344,12 @@ class RenderItNode extends RenderViewId {
2337
2344
  }
2338
2345
 
2339
2346
  class RenderEachNode extends RenderViewId {
2340
- constructor(nodeId, val, viewId) {
2341
- super(nodeId, val, viewId);
2347
+ constructor(nodeId, val, viewVal) {
2348
+ super(nodeId, val, viewVal);
2342
2349
  this.iterInfo = new IterInfo(val, null, null, null);
2343
2350
  }
2344
2351
  render(stack, rx) {
2345
- return rx.renderEach(stack, this.iterInfo, this, this.viewId);
2352
+ return rx.renderEach(stack, this.iterInfo, this, this.evalViewName(stack));
2346
2353
  }
2347
2354
  toPathStep(ctx) {
2348
2355
  if (this.val instanceof DynVal)
@@ -9469,7 +9469,7 @@ class Renderer {
9469
9469
  return comp ? this._rValComp(stack, stack.it, comp, node, key, viewName) : null;
9470
9470
  }
9471
9471
  _rValComp(stack, val, comp, node, key, viewName) {
9472
- const cacheKey = `${viewName ?? stack.viewsId ?? ""}-${key}`;
9472
+ const cacheKey = `${viewName ?? ""}\x1F${stack.viewsId ?? ""}\x1F${key}`;
9473
9473
  const cachePath = [node, val];
9474
9474
  stack._pushDynBindValuesToArray(cachePath, comp);
9475
9475
  const cachedNode = this.cache.get(cachePath, cacheKey);
@@ -9514,7 +9514,7 @@ class Renderer {
9514
9514
  const renderOne = (key, value, attrName) => {
9515
9515
  const cachePath = enricher ? [view, it, value] : [view, value];
9516
9516
  const binds = { key, value };
9517
- const cacheKey = `${nid}-${key}`;
9517
+ const cacheKey = `${stack.viewsId ?? ""}\x1F${nid}\x1F${key}`;
9518
9518
  if (enricher)
9519
9519
  enricher.call(it, binds, key, value, iterData);
9520
9520
  const cachedNode = this.cache.get(cachePath, cacheKey);
@@ -9807,7 +9807,8 @@ function parseXOp(attrs, childs, opIdx, px) {
9807
9807
  if (attrs.length <= opIdx)
9808
9808
  return maybeFragment(childs);
9809
9809
  const { name, value } = attrs[opIdx];
9810
- const as = attrs.getNamedItem("as")?.value ?? null;
9810
+ const asAttr = attrs.getNamedItem("as")?.value ?? null;
9811
+ const as = asAttr === null ? null : parseViewName(asAttr, px);
9811
9812
  let node;
9812
9813
  switch (name) {
9813
9814
  case "slot":
@@ -9847,6 +9848,9 @@ function parseXOpVal(opName, value, px, parserFn) {
9847
9848
  px.onParseIssue("bad-value", { role: "x-op", op: opName, value });
9848
9849
  return val;
9849
9850
  }
9851
+ function parseViewName(s, px) {
9852
+ return vp.parseText(s, px) ?? vp.const(s);
9853
+ }
9850
9854
  function processXExtras(node, attrs, opName, startIdx, px) {
9851
9855
  const { consumed, wrappable } = X_OPS[opName];
9852
9856
  const wrappers = [];
@@ -9943,9 +9947,12 @@ class Macro {
9943
9947
  }
9944
9948
 
9945
9949
  class RenderViewId extends ANode {
9946
- constructor(nodeId, val, viewId) {
9950
+ constructor(nodeId, val, viewVal) {
9947
9951
  super(nodeId, val);
9948
- this.viewId = viewId;
9952
+ this.viewVal = viewVal;
9953
+ }
9954
+ evalViewName(stack) {
9955
+ return this.viewVal ? this.viewVal.eval(stack) : null;
9949
9956
  }
9950
9957
  setDataAttr(_key, _val) {}
9951
9958
  }
@@ -9959,7 +9966,7 @@ function dynRenderStep(comp, name, key) {
9959
9966
  class RenderNode extends RenderViewId {
9960
9967
  render(stack, rx) {
9961
9968
  const newStack = stack.enter(this.val.eval(stack), {}, true);
9962
- return rx.renderIt(newStack, this, "", this.viewId);
9969
+ return rx.renderIt(newStack, this, "", this.evalViewName(stack));
9963
9970
  }
9964
9971
  toPathStep(ctx) {
9965
9972
  if (this.val instanceof DynVal)
@@ -9971,7 +9978,7 @@ class RenderNode extends RenderViewId {
9971
9978
  class RenderItNode extends RenderViewId {
9972
9979
  render(stack, rx) {
9973
9980
  const newStack = stack.enter(stack.it, {}, true);
9974
- return rx.renderIt(newStack, this, "", this.viewId);
9981
+ return rx.renderIt(newStack, this, "", this.evalViewName(stack));
9975
9982
  }
9976
9983
  toPathStep(ctx) {
9977
9984
  const next = ctx.next();
@@ -9988,12 +9995,12 @@ class RenderItNode extends RenderViewId {
9988
9995
  }
9989
9996
 
9990
9997
  class RenderEachNode extends RenderViewId {
9991
- constructor(nodeId, val, viewId) {
9992
- super(nodeId, val, viewId);
9998
+ constructor(nodeId, val, viewVal) {
9999
+ super(nodeId, val, viewVal);
9993
10000
  this.iterInfo = new IterInfo(val, null, null, null);
9994
10001
  }
9995
10002
  render(stack, rx) {
9996
- return rx.renderEach(stack, this.iterInfo, this, this.viewId);
10003
+ return rx.renderEach(stack, this.iterInfo, this, this.evalViewName(stack));
9997
10004
  }
9998
10005
  toPathStep(ctx) {
9999
10006
  if (this.val instanceof DynVal)