tutuca 0.9.102 → 0.9.104

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.
@@ -16170,7 +16170,24 @@ function tutucaSource(base) {
16170
16170
  return "node_modules";
16171
16171
  return "local dist";
16172
16172
  }
16173
- function buildImports(base, { margaui }) {
16173
+ function resolveMargaui(projectDir, { forCdn, override }) {
16174
+ if (override) {
16175
+ const jsUrl = override.startsWith("http") ? override : `/${relative2(projectDir, resolve5(projectDir, override)).split(sep).join("/")}`;
16176
+ return { jsUrl, themeUrl: MARGAUI_THEME, source: "override" };
16177
+ }
16178
+ if (!forCdn) {
16179
+ const localJs = resolve5(projectDir, "node_modules", "margaui", "dist", "margaui.min.js");
16180
+ if (existsSync4(localJs)) {
16181
+ return {
16182
+ jsUrl: "/node_modules/margaui/dist/margaui.min.js",
16183
+ themeUrl: "/node_modules/margaui/dist/themes/theme.css",
16184
+ source: "node_modules"
16185
+ };
16186
+ }
16187
+ }
16188
+ return { jsUrl: MARGAUI_CDN, themeUrl: MARGAUI_THEME, source: "CDN" };
16189
+ }
16190
+ function buildImports(base, { margauiEnabled, margauiJsUrl }) {
16174
16191
  const dev = `${base}/tutuca-dev.js`;
16175
16192
  const imports = {
16176
16193
  tutuca: dev,
@@ -16179,13 +16196,13 @@ function buildImports(base, { margaui }) {
16179
16196
  "tutuca/storybook": `${base}/tutuca-storybook.js`,
16180
16197
  "tutuca/components": `${base}/tutuca-components.js`
16181
16198
  };
16182
- if (margaui)
16183
- imports.margaui = MARGAUI_CDN;
16199
+ if (margauiEnabled)
16200
+ imports.margaui = margauiJsUrl;
16184
16201
  return imports;
16185
16202
  }
16186
- function renderIndexHtml(imports, { margaui, bootstrapUrl }) {
16187
- const theme = margaui ? `
16188
- <link rel="stylesheet" href="${MARGAUI_THEME}" />` : "";
16203
+ function renderIndexHtml(imports, { margauiEnabled, margauiThemeUrl, bootstrapUrl }) {
16204
+ const theme = margauiEnabled ? `
16205
+ <link rel="stylesheet" href="${margauiThemeUrl}" />` : "";
16189
16206
  return `<!doctype html>
16190
16207
  <html lang="en">
16191
16208
  <head>
@@ -16203,9 +16220,9 @@ ${JSON.stringify({ imports }, null, 6)}
16203
16220
  </html>
16204
16221
  `;
16205
16222
  }
16206
- function renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3, noCache }) {
16223
+ function renderBootstrap(devModuleUrls, { margauiEnabled, check, inspect: inspect3, noCache }) {
16207
16224
  const lines = ['import { mountStorybook } from "tutuca/storybook";'];
16208
- if (margaui) {
16225
+ if (margauiEnabled) {
16209
16226
  lines.push('import { compileClassesToStyleText } from "tutuca/extra";');
16210
16227
  lines.push('import { compile } from "margaui";');
16211
16228
  }
@@ -16219,7 +16236,7 @@ function renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3, noC
16219
16236
  });
16220
16237
  const modules = devModuleUrls.map((_, i) => `m${i}`).join(", ");
16221
16238
  const optParts = [];
16222
- if (margaui)
16239
+ if (margauiEnabled)
16223
16240
  optParts.push("compileCss: (app) => compileClassesToStyleText(app, compile)");
16224
16241
  if (inspect3)
16225
16242
  optParts.push("dev: { shadowCheckComponent, runTests, expect }");
@@ -16354,6 +16371,8 @@ async function run4(argv, opts = {}) {
16354
16371
  options: {
16355
16372
  port: { type: "string" },
16356
16373
  out: { type: "string" },
16374
+ margaui: { type: "string" },
16375
+ "margaui-cdn": { type: "boolean", default: false },
16357
16376
  "no-margaui": { type: "boolean", default: false },
16358
16377
  "no-check": { type: "boolean", default: false },
16359
16378
  "no-inspect": { type: "boolean", default: false },
@@ -16366,20 +16385,27 @@ async function run4(argv, opts = {}) {
16366
16385
  });
16367
16386
  if (parsed.values.help) {
16368
16387
  process.stdout.write(`tutuca storybook [dir] [--port <n>] [--out <dir>] [--dry-run]
16369
- [--no-margaui] [--no-check] [--no-inspect] [--no-tests]
16370
- [--no-cache]
16388
+ [--margaui <url|path>] [--margaui-cdn] [--no-margaui]
16389
+ [--no-check] [--no-inspect] [--no-tests] [--no-cache]
16371
16390
 
16372
16391
  Auto-discovers co-located *.dev.js modules (recursively, skipping
16373
16392
  node_modules/dotdirs) and serves a live storybook that mounts them via
16374
16393
  the tutuca/storybook library. Zero setup.
16375
16394
 
16395
+ margaui styling loads local-first: it's used from node_modules/margaui
16396
+ when installed (offline-capable), else from the CDN.
16397
+
16376
16398
  [dir] project root to scan and serve (default: cwd)
16377
16399
  --port <n> preferred port (default 4321; falls back to a free port)
16378
- --out <dir> write a static index.html + bootstrap (CDN import map)
16379
- instead of serving; host it from the project root
16400
+ --out <dir> write a static index.html + bootstrap (CDN import map for
16401
+ both tutuca and margaui) instead of serving; host it from
16402
+ the project root
16380
16403
  --dry-run do all the prep (discover, import and normalize modules,
16381
16404
  resolve the runtime, run tests) and print what would be
16382
16405
  shown instead of serving; pass --json for structured output
16406
+ --margaui <url|path> use a specific margaui build (URL, or path inside
16407
+ the project) instead of auto-detecting / the CDN
16408
+ --margaui-cdn force the margaui CDN even if node_modules/margaui exists
16383
16409
  --no-margaui skip margaui styling (renders functional but unstyled)
16384
16410
  --no-check skip the in-browser check(app) dev validation
16385
16411
  --no-inspect skip the per-example Component/Instance/Data/Lint/Test tabs
@@ -16404,7 +16430,9 @@ async function run4(argv, opts = {}) {
16404
16430
  hint: "Create a co-located <name>.dev.js exporting getComponents() and getExamples()."
16405
16431
  });
16406
16432
  }
16407
- const margaui = !parsed.values["no-margaui"];
16433
+ const margauiEnabled = !parsed.values["no-margaui"];
16434
+ const margauiOverride = parsed.values.margaui;
16435
+ const forceMargauiCdn = parsed.values["margaui-cdn"];
16408
16436
  const check = !parsed.values["no-check"];
16409
16437
  const inspect3 = !parsed.values["no-inspect"];
16410
16438
  const noCache = parsed.values["no-cache"];
@@ -16413,10 +16441,15 @@ async function run4(argv, opts = {}) {
16413
16441
  const outDir = resolve5(parsed.values.out);
16414
16442
  mkdirSync3(outDir, { recursive: true });
16415
16443
  const { base: base2 } = resolveTutucaBase(projectDir, self, true);
16416
- const imports2 = buildImports(base2, { margaui });
16444
+ const mg2 = resolveMargaui(projectDir, { forCdn: true, override: margauiOverride });
16445
+ const imports2 = buildImports(base2, { margauiEnabled, margauiJsUrl: mg2.jsUrl });
16417
16446
  const bootstrapName = "tutuca-storybook.bootstrap.js";
16418
- writeFileSync(resolve5(outDir, "index.html"), renderIndexHtml(imports2, { margaui, bootstrapUrl: `./${bootstrapName}` }));
16419
- writeFileSync(resolve5(outDir, bootstrapName), renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3, noCache }));
16447
+ writeFileSync(resolve5(outDir, "index.html"), renderIndexHtml(imports2, {
16448
+ margauiEnabled,
16449
+ margauiThemeUrl: mg2.themeUrl,
16450
+ bootstrapUrl: `./${bootstrapName}`
16451
+ }));
16452
+ writeFileSync(resolve5(outDir, bootstrapName), renderBootstrap(devModuleUrls, { margauiEnabled, check, inspect: inspect3, noCache }));
16420
16453
  process.stdout.write(`wrote static storybook → ${relative2(process.cwd(), outDir) || "."}/
16421
16454
  index.html + ${bootstrapName} (${devModuleUrls.length} dev modules, CDN import map)
16422
16455
  Host it from the project root so /*.dev.js paths resolve.
@@ -16425,7 +16458,8 @@ async function run4(argv, opts = {}) {
16425
16458
  }
16426
16459
  if (parsed.values["dry-run"]) {
16427
16460
  const { base: base2 } = resolveTutucaBase(projectDir, self, false);
16428
- const imports2 = buildImports(base2, { margaui });
16461
+ const mg2 = resolveMargaui(projectDir, { forCdn: forceMargauiCdn, override: margauiOverride });
16462
+ const imports2 = buildImports(base2, { margauiEnabled, margauiJsUrl: mg2.jsUrl });
16429
16463
  const modules = await discoverModules(projectDir, devModuleUrls);
16430
16464
  const tests = parsed.values["no-tests"] ? null : await runDevTests(projectDir, devModuleUrls);
16431
16465
  const componentNameConflicts = await checkComponentNameConflicts(projectDir, devModuleUrls);
@@ -16433,7 +16467,8 @@ async function run4(argv, opts = {}) {
16433
16467
  const result = {
16434
16468
  projectDir,
16435
16469
  tutuca: { source, base: base2, version: self.version },
16436
- options: { margaui, check, noCache, runTests: !parsed.values["no-tests"] },
16470
+ margaui: margauiEnabled ? { source: mg2.source, jsUrl: mg2.jsUrl, themeUrl: mg2.themeUrl } : null,
16471
+ options: { margaui: margauiEnabled, check, noCache, runTests: !parsed.values["no-tests"] },
16437
16472
  imports: imports2,
16438
16473
  modules,
16439
16474
  tests,
@@ -16447,7 +16482,7 @@ async function run4(argv, opts = {}) {
16447
16482
  process.stdout.write(`tutuca storybook dry run (no server started)
16448
16483
  project: ${projectDir}
16449
16484
  tutuca runtime: ${source} (${base2}, version ${self.version})
16450
- margaui: ${margaui ? "on" : "off"}, in-browser check: ${check ? "on" : "off"}, cache: ${noCache ? "off" : "on"}
16485
+ margaui: ${margauiEnabled ? `on (${mg2.source})` : "off"}, in-browser check: ${check ? "on" : "off"}, cache: ${noCache ? "off" : "on"}
16451
16486
  ${modules.length} dev module(s):
16452
16487
  `);
16453
16488
  for (const m of modules) {
@@ -16507,9 +16542,14 @@ async function run4(argv, opts = {}) {
16507
16542
  process.stdout.write(formatComponentNameConflict(c));
16508
16543
  }
16509
16544
  const { base, serveDist } = resolveTutucaBase(projectDir, self, false);
16510
- const imports = buildImports(base, { margaui });
16511
- const indexHtml = renderIndexHtml(imports, { margaui, bootstrapUrl: BOOTSTRAP_URL });
16512
- const bootstrapJs = renderBootstrap(devModuleUrls, { margaui, check, inspect: inspect3, noCache });
16545
+ const mg = resolveMargaui(projectDir, { forCdn: forceMargauiCdn, override: margauiOverride });
16546
+ const imports = buildImports(base, { margauiEnabled, margauiJsUrl: mg.jsUrl });
16547
+ const indexHtml = renderIndexHtml(imports, {
16548
+ margauiEnabled,
16549
+ margauiThemeUrl: mg.themeUrl,
16550
+ bootstrapUrl: BOOTSTRAP_URL
16551
+ });
16552
+ const bootstrapJs = renderBootstrap(devModuleUrls, { margauiEnabled, check, inspect: inspect3, noCache });
16513
16553
  const server = createServer((req, res) => {
16514
16554
  const path = req.url.split("?")[0];
16515
16555
  if (path === "/" || path === "/index.html") {
@@ -16539,7 +16579,8 @@ async function run4(argv, opts = {}) {
16539
16579
  server.on("listening", () => {
16540
16580
  const actual = server.address().port;
16541
16581
  const where = tutucaSource(base);
16542
- process.stdout.write(`tutuca storybook: http://localhost:${actual}/ (${devModuleUrls.length} dev modules, tutuca from ${where})
16582
+ const margauiFrom = margauiEnabled ? `, margaui from ${mg.source}` : "";
16583
+ process.stdout.write(`tutuca storybook: http://localhost:${actual}/ (${devModuleUrls.length} dev modules, tutuca from ${where}${margauiFrom})
16543
16584
  `);
16544
16585
  });
16545
16586
  server.listen(preferred);
@@ -6015,9 +6015,6 @@ class Component {
6015
6015
  if (!KNOWN_SPEC_KEYS.has(key))
6016
6016
  this.extra[key] = o[key];
6017
6017
  }
6018
- clone() {
6019
- return Component.fromSpec(this.spec);
6020
- }
6021
6018
  compile(ParseContext2) {
6022
6019
  for (const name in this.views)
6023
6020
  this.views[name].compile(new ParseContext2, this.scope, this.id);
@@ -13666,9 +13666,6 @@ class Component {
13666
13666
  if (!KNOWN_SPEC_KEYS.has(key))
13667
13667
  this.extra[key] = o[key];
13668
13668
  }
13669
- clone() {
13670
- return Component.fromSpec(this.spec);
13671
- }
13672
13669
  compile(ParseContext2) {
13673
13670
  for (const name in this.views)
13674
13671
  this.views[name].compile(new ParseContext2, this.scope, this.id);