@somewhere-tech/cli 0.29.0 → 0.30.0

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.
Files changed (37) hide show
  1. package/dist/commands/browser.js +111 -16
  2. package/dist/commands/browser.js.map +1 -1
  3. package/dist/commands/deploy.js +33 -8
  4. package/dist/commands/deploy.js.map +1 -1
  5. package/dist/commands/dev.js +187 -50
  6. package/dist/commands/dev.js.map +1 -1
  7. package/dist/commands/errors.js +29 -6
  8. package/dist/commands/errors.js.map +1 -1
  9. package/dist/commands/init.js +1 -1
  10. package/dist/commands/init.js.map +1 -1
  11. package/dist/commands/project.js +2 -1
  12. package/dist/commands/project.js.map +1 -1
  13. package/dist/commands/promote.js +11 -12
  14. package/dist/commands/promote.js.map +1 -1
  15. package/dist/commands/rollback.js +1 -1
  16. package/dist/commands/rollback.js.map +1 -1
  17. package/dist/commands/status.js +32 -2
  18. package/dist/commands/status.js.map +1 -1
  19. package/dist/lib/output.js +2 -2
  20. package/dist/lib/output.js.map +1 -1
  21. package/dist/local/browser-run.js +242 -0
  22. package/dist/local/browser-run.js.map +1 -0
  23. package/dist/local/chrome.js +287 -0
  24. package/dist/local/chrome.js.map +1 -0
  25. package/dist/local/compiler.js +40 -5
  26. package/dist/local/compiler.js.map +1 -1
  27. package/dist/local/runtime.js +66 -2
  28. package/dist/local/runtime.js.map +1 -1
  29. package/npm-shrinkwrap.json +2 -2
  30. package/package.json +2 -2
  31. package/runtime/VENDOR.json +8 -0
  32. package/runtime/browser-probes.mjs +6 -0
  33. package/runtime/compiler/VENDOR.json +7 -3
  34. package/runtime/compiler/compile-core.cjs +18 -0
  35. package/runtime/compiler/typed-functions.cjs +31 -1
  36. package/runtime/platform-context.mjs +5624 -1786
  37. package/runtime/sw-init.mjs +51 -5
@@ -0,0 +1,6 @@
1
+ // VENDORED from worker/src/utils/browser-test.ts (DOM_OUTLINE_SCRIPT) @ 1bf981dd
2
+ // — the exact runtime deployed functions run against. Do not edit by hand;
3
+ // re-sync with: node scripts/extract-runtime.mjs <monorepo>
4
+ export const MAX_OUTLINE_NODES = 200;
5
+
6
+ export const DOM_OUTLINE_SCRIPT = "(() => {\n const cssPath = (el) => {\n const parts = [];\n let node = el;\n let depth = 0;\n while (node && node.nodeType === 1 && depth < 4 && node.tagName.toLowerCase() !== 'body') {\n let sel = node.tagName.toLowerCase();\n if (node.id) { parts.unshift(sel + '#' + CSS.escape(node.id)); break; }\n const parent = node.parentNode;\n if (parent) {\n const sameTag = Array.from(parent.children).filter((c) => c.tagName === node.tagName);\n if (sameTag.length > 1) sel += ':nth-of-type(' + (sameTag.indexOf(node) + 1) + ')';\n }\n parts.unshift(sel);\n node = node.parentNode;\n depth++;\n }\n return parts.join(' > ');\n };\n const interactive = 'a,button,input,select,textarea,[role=button],[role=link],[role=tab],[onclick],[data-testid]';\n const seen = new Set();\n const outline = [];\n for (const el of Array.from(document.querySelectorAll(interactive))) {\n if (outline.length >= 200) break;\n if (seen.has(el)) continue;\n seen.add(el);\n const testid = el.getAttribute('data-testid') || '';\n const id = el.id || '';\n const name = el.getAttribute('name') || '';\n const aria = el.getAttribute('aria-label') || '';\n const text = ((el.innerText || el.value || el.getAttribute('placeholder') || '') + '').trim().slice(0, 80);\n let selector;\n if (testid) selector = '[data-testid=\"' + testid + '\"]';\n else if (id) selector = '#' + CSS.escape(id);\n else if (name) selector = el.tagName.toLowerCase() + '[name=\"' + name + '\"]';\n else selector = cssPath(el);\n outline.push({ tag: el.tagName.toLowerCase(), id, testid, name, aria, text, selector });\n }\n const testid_map = {};\n for (const el of Array.from(document.querySelectorAll('[data-testid]'))) {\n const t = el.getAttribute('data-testid');\n if (t && !(t in testid_map)) testid_map[t] = '[data-testid=\"' + t + '\"]';\n }\n return { outline, testid_map };\n})()";
@@ -1,5 +1,5 @@
1
1
  {
2
- "commit": "ea29ab73",
2
+ "commit": "1bf981dd",
3
3
  "esbuild": "0.24.0",
4
4
  "toolchain": {
5
5
  "base": {
@@ -13,11 +13,15 @@
13
13
  "tw4": {
14
14
  "tailwindcss": "^4.0.0",
15
15
  "@tailwindcss/postcss": "^4.0.0"
16
+ },
17
+ "react19": {
18
+ "react": "19.2.7",
19
+ "react-dom": "19.2.7"
16
20
  }
17
21
  },
18
22
  "files": {
19
- "compile-core.cjs": "96468eac244fc2f176b1222babb15391d104710e19a6ac3a8ca9f761e8bfc54c",
23
+ "compile-core.cjs": "06a7c02dacc5fc41ab602ec60eac14d988307b8a7019c62b49be72fafe664f65",
20
24
  "graph-contract.cjs": "aaeebc34f486ee5f639444de5757accfc283de641e631908ccd8d8c688bfb5c0",
21
- "typed-functions.cjs": "3e96aff7daad4ccbb67907f79e7cbac42cef2397a18431776495c377b604ab8a"
25
+ "typed-functions.cjs": "5c0b499015dcdf755ca72dab04a80afce0891e782f835547592faec802c63be6"
22
26
  }
23
27
  }
@@ -465,6 +465,8 @@ const TOOLCHAIN_DEPS = new Set(['react-scripts', 'react-app-rewired', 'craco', '
465
465
  * GRANDFATHER: the full resolvability chain (build root → IMAGE_NODE_MODULES →
466
466
  * REACT19_NODE_MODULES → NODE_POLYFILLS → node: prefix → relative/URL paths)
467
467
  * mirrors exactly what esbuild can resolve, so a working import NEVER warns.
468
+ * Platform-provided specifiers (PLATFORM_MODULE_ROOTS) are exempt on top of
469
+ * that: they are not npm packages, so no resolution chain would ever find them.
468
470
  */
469
471
 
470
472
  /**
@@ -497,6 +499,18 @@ function specRootPkg(spec) {
497
499
  : spec.split('/')[0];
498
500
  }
499
501
 
502
+ /**
503
+ * Root packages the PLATFORM provides — derived from typed-functions'
504
+ * PLATFORM_MODULES, which is also what builds the virtual-module resolver, so
505
+ * this can never drift into a stale hand list.
506
+ *
507
+ * These are not npm packages. Reporting one as "not in your package.json" told
508
+ * a developer that the `somewhere/db` import our own managed-schema docs handed
509
+ * them would fail to load in production, and the remediation it offered —
510
+ * `npm install somewhere` — installs an unrelated package (tsk_53badecfb7).
511
+ */
512
+ const PLATFORM_MODULE_ROOTS = new Set(typedFunctions.PLATFORM_MODULES.map(specRootPkg));
513
+
500
514
  /* ─── Dependency review (PR1, tsk_35befef9 / npm supply-chain) ────────────────
501
515
  * After deps are installed (with --ignore-scripts), walk the customer's RESOLVED
502
516
  * dependency tree and report what actually shipped: package count, lifecycle
@@ -979,6 +993,10 @@ function isBuildConfigFile(filePath) {
979
993
  // (aliases like `@/App` have no npm-style root package).
980
994
  if (isAliased(spec)) continue;
981
995
  const rootPkg = specRootPkg(spec);
996
+ // PROVIDED BY THE PLATFORM (`somewhere/db`, `somewhere:api`, …). Not npm
997
+ // packages, so "add it to your package.json" is wrong advice on code our
998
+ // own docs hand the developer (tsk_53badecfb7).
999
+ if (PLATFORM_MODULE_ROOTS.has(rootPkg)) continue;
982
1000
  // DECLARED in devDependencies. ensureDeps deliberately installs only
983
1001
  // `dependencies` (the build toolchain is the platform's job, not the
984
1002
  // app's), so a devDependency is never resolvable here — but it IS
@@ -6,7 +6,32 @@ const path = require('path');
6
6
 
7
7
  const SENTINEL = 'somewhere:v1';
8
8
  const MODULE_NAME = 'somewhere:api';
9
+ // Managed-schema helper surface, imported by db/schema.ts. That file is DATA
10
+ // the deploy reads statically — never executed, never bundled — so no resolver
11
+ // ever claims this specifier and, to anything that only asks "can esbuild
12
+ // resolve it", it can only ever look like a missing npm package.
13
+ const SCHEMA_MODULE_NAME = 'somewhere/db';
9
14
  const MANIFEST_PATH = '_internal/typed-functions.json';
15
+
16
+ /**
17
+ * PLATFORM_MODULES — the ONE enumeration of module specifiers the PLATFORM
18
+ * provides. These are not npm packages and must never be added to a customer's
19
+ * package.json: `npm install somewhere` installs an unrelated package off the
20
+ * public registry, or fails.
21
+ *
22
+ * Everything that needs to know "is this specifier ours?" reads THIS list, so
23
+ * there is no second hand-maintained copy to drift:
24
+ * - virtualApiPlugin below builds its esbuild onResolve filter from
25
+ * MODULE_NAME, so the resolver and this list cannot disagree;
26
+ * - the compiler's phantom-import scanner (compile-core.cjs) treats the root
27
+ * package of every entry here as provided, which is what stops the CLI
28
+ * telling a developer that our own documented `somewhere/db` import is a
29
+ * missing dependency (tsk_53badecfb7).
30
+ *
31
+ * Matching downstream is on the ROOT package, so `somewhere/<anything>` — every
32
+ * present and future subpath surface — is covered by the `somewhere/db` entry.
33
+ */
34
+ const PLATFORM_MODULES = Object.freeze([MODULE_NAME, SCHEMA_MODULE_NAME]);
10
35
  const AMBIENT_FILE = '__somewhere_typed_functions.d.ts';
11
36
  const CLIENT_FILE = '__somewhere_api.d.ts';
12
37
 
@@ -524,7 +549,10 @@ function virtualApiPlugin(esbuild) {
524
549
  return {
525
550
  name: 'somewhere-typed-api',
526
551
  setup(build) {
527
- build.onResolve({ filter: /^somewhere:api$/ }, () => ({ path: MODULE_NAME, namespace: 'somewhere-typed-api' }));
552
+ // Filter derived from MODULE_NAME so the resolver and PLATFORM_MODULES
553
+ // cannot drift apart.
554
+ const filter = new RegExp(`^${MODULE_NAME.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`);
555
+ build.onResolve({ filter }, () => ({ path: MODULE_NAME, namespace: 'somewhere-typed-api' }));
528
556
  build.onLoad({ filter: /.*/, namespace: 'somewhere-typed-api' }, () => ({ contents: RUNTIME_SOURCE, loader: 'js' }));
529
557
  },
530
558
  };
@@ -535,7 +563,9 @@ module.exports = {
535
563
  CLIENT_FILE,
536
564
  MANIFEST_PATH,
537
565
  MODULE_NAME,
566
+ PLATFORM_MODULES,
538
567
  RUNTIME_SOURCE,
568
+ SCHEMA_MODULE_NAME,
539
569
  SENTINEL,
540
570
  analyzeTypedFunctions,
541
571
  buildDeclaration,