@wildshard/engine 0.1.15 → 0.1.18

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 (262) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/index.html +157 -11
  3. package/lint/engine-sides.json +23 -0
  4. package/lint/host-callback-syntax.mjs +2 -1
  5. package/lint/host-callbacks.mjs +3 -3
  6. package/lint/host-files.mjs +5 -4
  7. package/lint/host-register.json +496 -0
  8. package/lint/no-base64.mjs +3 -1
  9. package/lint/ratchet.json +2 -2
  10. package/lint/shard-imports.d.mts +1 -0
  11. package/lint/shard-imports.mjs +60 -13
  12. package/lint/shard-source.d.mts +9 -0
  13. package/lint/shard-source.mjs +91 -0
  14. package/lint/shardfile-boundaries.mjs +10 -8
  15. package/lint/sim-closure.mjs +6 -3
  16. package/lint/wildshard-plugin.d.ts +4 -0
  17. package/lint/wildshard-plugin.js +44 -27
  18. package/package.json +24 -6
  19. package/scripts/app-build/buildIdentity.d.mts +3 -1
  20. package/scripts/app-build/buildIdentity.mjs +25 -5
  21. package/scripts/app-build/builtAt.d.mts +4 -0
  22. package/scripts/app-build/builtAt.mjs +21 -0
  23. package/scripts/app-build/outputProducts.d.mts +3 -0
  24. package/scripts/app-build/outputProducts.mjs +31 -0
  25. package/scripts/app-build/serviceWorker.ts +16 -2
  26. package/scripts/app-build/versionFiles.ts +2 -1
  27. package/scripts/app-build-pipeline.mjs +7 -1
  28. package/scripts/audio-download-proof.mjs +843 -0
  29. package/scripts/build-app.mjs +4 -0
  30. package/scripts/build-mirror.d.mts +2 -0
  31. package/scripts/build-mirror.mjs +5 -4
  32. package/scripts/built-product.mjs +3 -3
  33. package/scripts/cell-mem/metrics-preload.mjs +65 -0
  34. package/scripts/cell-mem-bench.mjs +130 -0
  35. package/scripts/check-chunks.mjs +2 -1
  36. package/scripts/check-devserver.mjs +1 -1
  37. package/scripts/chromium-keychain-check.mjs +4 -2
  38. package/scripts/chromium-keychain.mjs +3 -1
  39. package/scripts/cook.mjs +7 -3
  40. package/scripts/devices.d.mts +4 -0
  41. package/scripts/devices.mjs +39 -0
  42. package/scripts/devserver-client.d.mts +7 -0
  43. package/scripts/devserver-client.mjs +85 -0
  44. package/scripts/doctor-proof.mjs +1 -1
  45. package/scripts/e2e-faults.mjs +159 -0
  46. package/scripts/engine-ci-budget.ts +7 -1
  47. package/scripts/format-lock.mjs +20 -11
  48. package/scripts/generate-title-launch.mjs +3 -2
  49. package/scripts/grid-crossing-walk-proof.mjs +30 -11
  50. package/scripts/heavy-lane.py +25 -1
  51. package/scripts/host-ruler/register-migrate.mjs +242 -0
  52. package/scripts/host-ruler/register.d.mts +36 -0
  53. package/scripts/host-ruler/register.mjs +116 -0
  54. package/scripts/host-ruler/roots.d.mts +29 -0
  55. package/scripts/host-ruler/roots.mjs +333 -0
  56. package/scripts/host-ruler/server-roots.d.mts +23 -0
  57. package/scripts/host-ruler/server-roots.mjs +272 -0
  58. package/scripts/main-watch.d.mts +1 -1
  59. package/scripts/main-watch.mjs +10 -6
  60. package/scripts/map-hash.mjs +3 -6
  61. package/scripts/memory-proof.mjs +158 -0
  62. package/scripts/mmo-bots.mjs +2 -2
  63. package/scripts/offline-proof-rules.d.mts +5 -2
  64. package/scripts/offline-proof-rules.mjs +43 -6
  65. package/scripts/offline-proof.mjs +15 -6
  66. package/scripts/online-rig.mjs +4 -4
  67. package/scripts/page-release/flow.d.mts +1 -0
  68. package/scripts/page-release/flow.mjs +6 -2
  69. package/scripts/page-release.mjs +5 -1
  70. package/scripts/physics-route.json +0 -71
  71. package/scripts/pins-catalogue.ts +103 -0
  72. package/scripts/pins-reuse.mjs +3 -1
  73. package/scripts/pins.ts +22 -14
  74. package/scripts/preview-grid.ts +203 -0
  75. package/scripts/road-preload-proof.mjs +167 -0
  76. package/scripts/server-release/publish.mjs +2 -2
  77. package/scripts/server-release/served-slug.d.mts +2 -0
  78. package/scripts/server-release/served-slug.mjs +10 -0
  79. package/scripts/server-release/sign.d.mts +1 -0
  80. package/scripts/server-release/sign.mjs +3 -7
  81. package/scripts/shard-components.mjs +0 -2
  82. package/scripts/shard-outputs.d.mts +8 -0
  83. package/scripts/shard-outputs.mjs +45 -11
  84. package/scripts/side-parity.d.mts +2 -1
  85. package/scripts/side-parity.mjs +25 -4
  86. package/scripts/test-amber.d.mts +1 -0
  87. package/scripts/test-amber.mjs +10 -0
  88. package/scripts/test-products.json +3 -3
  89. package/scripts/tier-textures-proof.mjs +101 -0
  90. package/scripts/tier-textures.mjs +60 -0
  91. package/scripts/tracked-public.d.mts +1 -0
  92. package/scripts/tracked-public.mjs +17 -0
  93. package/scripts/tsconfig.json +1 -0
  94. package/scripts/vps/wildshard-config +79 -23
  95. package/scripts/worker-client-play.mjs +1 -0
  96. package/scripts/worker-client-proof.mjs +1 -1
  97. package/scripts/worker-client-slug.mjs +44 -0
  98. package/src/cli/engine.mjs +8 -0
  99. package/src/client/app/bootRoute.ts +4 -1
  100. package/src/client/app/dropModal.ts +15 -2
  101. package/src/client/app/entry.ts +96 -13
  102. package/src/client/app/slugPath.ts +5 -0
  103. package/src/client/engine/audio/Audio.ts +20 -2
  104. package/src/client/engine/boot/bakedTextures.ts +3 -2
  105. package/src/client/engine/boot/bootTrace.ts +6 -1
  106. package/src/client/engine/boot/bytes.ts +4 -3
  107. package/src/client/engine/boot/clearDownloads.ts +1 -1
  108. package/src/client/engine/boot/contentRead.ts +4 -0
  109. package/src/client/engine/boot/dropNotice.ts +20 -6
  110. package/src/client/engine/boot/gpuFiles.ts +25 -2
  111. package/src/client/engine/boot/lastEnd.ts +8 -2
  112. package/src/client/engine/boot/parsedPages.ts +127 -58
  113. package/src/client/engine/boot/shardPrefetch.ts +7 -1
  114. package/src/client/engine/boot/sw.ts +19 -0
  115. package/src/client/engine/build.d.ts +2 -0
  116. package/src/client/engine/core/Game.ts +29 -3
  117. package/src/client/engine/core/GpuRecovery.ts +7 -0
  118. package/src/client/engine/core/Volumetrics.ts +5 -0
  119. package/src/client/engine/core/assets.ts +27 -20
  120. package/src/client/engine/core/bootstrap.ts +5 -3
  121. package/src/client/engine/core/ktx2.ts +84 -11
  122. package/src/client/engine/debug/probe.ts +18 -1
  123. package/src/client/engine/explore/Compare.ts +2 -2
  124. package/src/client/engine/explore/TouchFly.ts +3 -5
  125. package/src/client/engine/fx/LightPool.ts +41 -1
  126. package/src/client/engine/input/dom.ts +12 -0
  127. package/src/client/engine/net/predictor.ts +6 -2
  128. package/src/client/engine/player/Player.ts +10 -2
  129. package/src/client/engine/player/TouchControls.ts +12 -4
  130. package/src/client/engine/pwa/sw.js +59 -11
  131. package/src/client/engine/render/drawCheck.ts +96 -0
  132. package/src/client/engine/render/precompile.ts +20 -14
  133. package/src/client/engine/saves/staleBuildNote.ts +46 -0
  134. package/src/client/engine/telemetry/browserErrors.ts +161 -21
  135. package/src/client/engine/telemetry/deviceSnapshot.ts +155 -0
  136. package/src/client/engine/telemetry/screenOutbox.ts +61 -0
  137. package/src/client/engine/telemetry/staleBuildReport.ts +12 -0
  138. package/src/client/engine/ui/DeathFade.ts +99 -11
  139. package/src/client/engine/ui/ErrorModal.ts +13 -6
  140. package/src/client/engine/ui/Feedback.ts +2 -1
  141. package/src/client/engine/ui/Loading.ts +10 -6
  142. package/src/client/engine/ui/Map.ts +2 -1
  143. package/src/client/engine/ui/WeaponStrip.ts +2 -1
  144. package/src/client/engine/ui/backGuard.ts +104 -0
  145. package/src/client/engine/ui/hudAdapters.ts +30 -4
  146. package/src/client/engine/ui/loading.css +17 -0
  147. package/src/client/engine/ui/namePrompt.ts +6 -5
  148. package/src/client/engine/ui/styles/combat.css +12 -0
  149. package/src/client/engine/ui/styles/namePrompt.css +4 -2
  150. package/src/client/game/boot/audio.generated.ts +0 -396
  151. package/src/client/game/boot/bytes.generated.ts +42 -71
  152. package/src/client/game/boot/versions.generated.ts +0 -13
  153. package/src/client/game/compendium/keepsakes.ts +16 -6
  154. package/src/client/game/grapple/tool.ts +10 -7
  155. package/src/client/game/grid/area.ts +38 -0
  156. package/src/client/game/grid/cellLoading.ts +23 -12
  157. package/src/client/game/grid/cellScreens.ts +39 -74
  158. package/src/client/game/grid/live.ts +28 -2
  159. package/src/client/game/grid/liveSession.ts +54 -10
  160. package/src/client/game/grid/menu.ts +4 -0
  161. package/src/client/game/grid/nearPlaceholderPlan.ts +8 -0
  162. package/src/client/game/grid/nearPlaceholderView.ts +9 -3
  163. package/src/client/game/grid/neighbourPanels.ts +10 -1
  164. package/src/client/game/grid/oneWayIn.ts +92 -27
  165. package/src/client/game/grid/pageEntry.ts +19 -0
  166. package/src/client/game/grid/pageShell.ts +1 -1
  167. package/src/client/game/grid/placedCards.ts +55 -0
  168. package/src/client/game/grid/placedCells.ts +131 -0
  169. package/src/client/game/grid/plotAudio.ts +114 -0
  170. package/src/client/game/grid/products.ts +55 -5
  171. package/src/client/game/grid/regionalRuntime.ts +6 -0
  172. package/src/client/game/grid/regionalWorld.ts +15 -2
  173. package/src/client/game/grid/roadCull.ts +44 -14
  174. package/src/client/game/grid/roadLookPlatform.ts +2 -2
  175. package/src/client/game/grid/roadTileBacking.ts +13 -3
  176. package/src/client/game/grid/session.ts +47 -22
  177. package/src/client/game/grid/shardfileFar.ts +9 -3
  178. package/src/client/game/grid/spawnGround.ts +68 -0
  179. package/src/client/game/grid/voidLook.ts +29 -23
  180. package/src/client/game/loot/runtime.ts +3 -1
  181. package/src/client/game/mainMenu.ts +14 -6
  182. package/src/client/game/riding/hud.ts +6 -4
  183. package/src/client/game/session/finish.ts +22 -4
  184. package/src/client/game/session/play.ts +8 -2
  185. package/src/client/game/session/session.ts +4 -1
  186. package/src/client/game/shard/titleList.ts +6 -2
  187. package/src/client/game/shardfile/clientWorker.ts +43 -13
  188. package/src/client/game/shardfile/serverRoute.ts +10 -22
  189. package/src/client/game/slugPage.css +11 -0
  190. package/src/client/game/slugPage.ts +84 -0
  191. package/src/client/game/systems/viewmodel/heldView.ts +6 -3
  192. package/src/client/game/titleDeck.ts +56 -32
  193. package/src/client/host/online/doctor.ts +7 -6
  194. package/src/client/host/online/linkScreens.ts +16 -0
  195. package/src/client/host/online/release.ts +51 -5
  196. package/src/client/host/online/shell.ts +62 -27
  197. package/src/client/host/standalone/shell.ts +7 -3
  198. package/src/cook/game/audioReport.ts +57 -0
  199. package/src/cook/game/entryTotals.ts +26 -6
  200. package/src/cook/game/installedRuntimeReads.ts +3 -0
  201. package/src/cook/game/shardCook.ts +38 -8
  202. package/src/cook/game/tierTextures.ts +276 -0
  203. package/src/e2e/smoke/game.ts +19 -14
  204. package/src/e2e/smoke/page-globals.d.ts +9 -8
  205. package/src/e2e/smoke/template2.spec.ts +8 -7
  206. package/src/server/engine/sim/respawn.ts +6 -1
  207. package/src/server/engine/sim.ts +3 -0
  208. package/src/server/game/grid/simulation.ts +35 -0
  209. package/src/server/game/loot/harvest.ts +2 -0
  210. package/src/server/game/loot/keepsakeProgression.ts +40 -0
  211. package/src/server/game/loot/playerOwned.ts +5 -1
  212. package/src/server/game/plugin/simulation.ts +4 -0
  213. package/src/server/game/population/nativeBake.ts +2 -1
  214. package/src/server/game/quest/chapterRecords.ts +2 -0
  215. package/src/server/game/quest/serverChapters.ts +4 -0
  216. package/src/server/game/quest/serverDoors.ts +11 -5
  217. package/src/server/game/roomRespawn.ts +4 -0
  218. package/src/server/game/shardfile/installedSides.ts +18 -0
  219. package/src/server/game/shardfile/nativeAssemblyHosts.ts +19 -10
  220. package/src/server/game/shardfile/nativeAssemblyInput.ts +1 -4
  221. package/src/server/host/bake/headlessWorker.ts +5 -1
  222. package/src/server/host/dedicated/cellHost.ts +98 -29
  223. package/src/server/host/dedicated/cellProtocol.ts +11 -1
  224. package/src/server/host/dedicated/cellWorker.ts +9 -3
  225. package/src/server/host/dedicated/crossing.ts +6 -2
  226. package/src/server/host/dedicated/dedicatedRoom.ts +21 -8
  227. package/src/server/host/dedicated/gridCells.ts +52 -9
  228. package/src/server/host/dedicated/main.ts +31 -12
  229. package/src/server/host/dedicated/placementFile.ts +56 -0
  230. package/src/server/host/dedicated/releaseFile.ts +17 -10
  231. package/src/server/host/dedicated/roadRoom.ts +21 -5
  232. package/src/server/host/dedicated/socketTransport.ts +2 -1
  233. package/src/server/host/dedicated/workerTable.ts +13 -1
  234. package/src/server/host/dedicated/world.ts +111 -10
  235. package/src/server/host/headlessRuntime.ts +10 -5
  236. package/src/server/host/installers.ts +62 -0
  237. package/src/server/host/openWorld.ts +59 -0
  238. package/src/server/host/ropeDecks.ts +2 -0
  239. package/src/server/host/standalone/cellWorld.ts +25 -19
  240. package/src/server/host/standalone/fallFloor.ts +2 -2
  241. package/src/server/host/standalone/gridServer.ts +7 -4
  242. package/src/server/host/standalone/roadWorld.ts +41 -4
  243. package/src/shared/engine/audio/bootAudio.ts +33 -0
  244. package/src/shared/engine/level/spec.ts +3 -3
  245. package/src/shared/engine/net/acts.ts +3 -0
  246. package/src/shared/engine/net/deviceWord.ts +138 -0
  247. package/src/shared/engine/net/socketFrames.ts +7 -4
  248. package/src/shared/engine/physics/query.ts +27 -0
  249. package/src/shared/engine/physics/terrain.ts +19 -28
  250. package/src/shared/engine/saves/saves.lock.json +15 -0
  251. package/src/shared/engine/sim/actRoutes.ts +2 -0
  252. package/src/shared/game/compendium/keepsakeProgression.ts +24 -0
  253. package/src/shared/game/grid/catalogue.ts +12 -5
  254. package/src/shared/game/grid/catalogueSlot.ts +18 -0
  255. package/src/shared/game/grid/farProxy.ts +6 -5
  256. package/src/shared/game/grid/pageMode.ts +1 -1
  257. package/src/shared/game/grid/placementRows.ts +33 -0
  258. package/src/shared/game/grid/roadLayout.ts +26 -3
  259. package/src/shared/game/grid/singleplayer.json +0 -13
  260. package/src/shared/game/grid/voidFloor.ts +122 -0
  261. package/src/shared/game/strings.ts +15 -0
  262. package/src/shared/host/standalone/netInput.ts +2 -1
@@ -1,6 +1,7 @@
1
1
  // G649 B3: syntactic calls only; no TypeScript program or import-graph walk.
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
+ import { lintFile } from './shard-source.mjs';
4
5
 
5
6
  const unwrap = node => ['TSAsExpression', 'TSTypeAssertion', 'TSNonNullExpression', 'ChainExpression', 'ParenthesizedExpression'].includes(node?.type)
6
7
  ? unwrap(node.expression) : node;
@@ -98,7 +99,8 @@ export function noBase64Rule(policyFile) {
98
99
  meta: { type: 'problem', docs: { description: 'Keep binary content binary; never encode or decode base64 (G649)' },
99
100
  schema: [{ type: 'object', properties: { count: { type: 'boolean' } }, additionalProperties: false }] },
100
101
  create(context) {
101
- const file = base64Path(context.filename);
102
+ // SA24 / SA45: shard source is keyed by its source path (src/shards/<slug>/<local>) in either layout, as the other shard rules read it
103
+ const shard = lintFile(context.filename, process.cwd()), file = shard.shard === null ? base64Path(context.filename) : shard.path;
102
104
  if (!/^(?:src|scripts)\//u.test(file)) return {};
103
105
  const limit = context.options[0]?.count === true ? 0 : Object.hasOwn(policy.files, file) ? policy.files[file] : 0;
104
106
  let found = 0;
package/lint/ratchet.json CHANGED
@@ -32,8 +32,8 @@
32
32
  "shardfile/sim-in-runtime": {}
33
33
  },
34
34
  "budgets": {
35
- "js/title/raw": 350000,
36
- "js/title/gzip": 110000,
35
+ "js/title/raw": 500000,
36
+ "js/title/gzip": 160000,
37
37
  "js/grid-session/raw": 300000,
38
38
  "js/grid-session/gzip": 100000,
39
39
  "js/session/raw": 4400000,
@@ -2,4 +2,5 @@
2
2
  export function shardGameImport(filename: string, source: string | undefined): boolean;
3
3
  export function gamePluginImportViolation(filename: string, source: string | undefined, exports: Readonly<Record<string, unknown>>): string | null;
4
4
  export function shardEngineImport(filename: string, source: string | undefined): boolean;
5
+ export function sharddevRuntimeImport(filename: string, source: string | undefined): boolean;
5
6
  export function generatorImportViolation(filename: string, source: string | undefined): string | null;
@@ -1,16 +1,32 @@
1
1
  import { dirname, isAbsolute, resolve } from 'node:path';
2
+ import { fileURLToPath, pathToFileURL } from 'node:url';
3
+ import { shardOfFilename } from './shard-source.mjs';
4
+
5
+ /** The file Node loads for relative `source` (a URL resolve, query and hash dropped), without a trailing slash; null when it cannot. */
6
+ const nodePath = (filename, source) => {
7
+ try {
8
+ return fileURLToPath(new URL(source, pathToFileURL(resolve(filename)))).replaceAll('\\', '/').replace(/(?<=.)\/$/u, '');
9
+ } catch { return null; }
10
+ };
11
+ /** Both readings of relative `source`: path.resolve's, and Node's URL resolve (`%2e%2e` is `..`, `\\` is `/`). */
12
+ const relativeTargets = (filename, source) => !source.startsWith('.') ? []
13
+ : [resolve(dirname(filename), source).replaceAll('\\', '/'), nodePath(filename, source)].filter(path => path !== null);
14
+ /** Whether either reading of a relative `source` lands under `src/<side>/<folder>` (a hidden boundary is still one). */
15
+ const relativeReach = (filename, source, folder) => {
16
+ const pattern = new RegExp(`/src/(?:client|cook|server|shared)/${folder}(?:/|$)`, 'u');
17
+ return relativeTargets(filename, source).some(path => pattern.test(path));
18
+ };
2
19
 
3
20
  /** Resolve source syntax to the game boundary; relative imports cannot bypass the author-package rule. */
4
21
  export function shardGameImport(filename, source) {
5
22
  if (typeof source !== 'string') return false;
6
- if (/^@wildshard\/(?:engine\/)?game(?:\/|$)/u.test(source)) return true;
7
- return source.startsWith('.') && /\/src\/(?:client|cook|server|shared)\/game(?:\/|$)/u.test(resolve(dirname(filename), source).replaceAll('\\', '/'));
23
+ if (/^@wildshard\/(?:engine\/)?game(?:[/?#]|$)/u.test(source)) return true;
24
+ return relativeReach(filename, source, 'game');
8
25
  }
9
26
 
10
27
  /** G307: a game's exports map is its plugin surface, never a parallel SDK facade allowlist. */
11
28
  export function gamePluginImportViolation(filename, source, exports) {
12
- const path = filename.replaceAll('\\', '/');
13
- const local = /(?:^|\/)src\/shards\/[^/]+\/(.+)$/u.exec(path)?.[1];
29
+ const local = shardOfFilename(filename)?.local;
14
30
  if (local === undefined || !shardGameImport(filename, source)) return null;
15
31
  if (!local.startsWith('runtime/')) return 'game imports belong only in runtime/';
16
32
  if (!source.startsWith('@wildshard/game/')) return 'use the defining @wildshard/game package export';
@@ -22,22 +38,53 @@ export function gamePluginImportViolation(filename, source, exports) {
22
38
  /** Identify an engine boundary without letting relative imports bypass the shrink-only migration count. */
23
39
  export function shardEngineImport(filename, source) {
24
40
  if (typeof source !== 'string') return false;
25
- if (/^@wildshard\/engine(?:\/(?!host\/|game\/)|$)/u.test(source)) return true;
26
- return source.startsWith('.') && /\/src\/(?:client|cook|server|shared)\/engine(?:\/|$)/u.test(resolve(dirname(filename), source).replaceAll('\\', '/'));
41
+ if (/^@wildshard\/engine(?:\/(?!host\/|game\/)|[?#]|$)/u.test(source)) return true;
42
+ return relativeReach(filename, source, 'engine');
43
+ }
44
+
45
+ /** Whether either reading of relative `source` (path.resolve's or Node's) lands in the trusted SDK runtime. */
46
+ export function sharddevRuntimeImport(filename, source) {
47
+ return typeof source === 'string' && relativeTargets(filename, source).some(path => /\/src\/sharddev\/runtime(?:\/|$)/u.test(path));
48
+ }
49
+
50
+ const PLAINLY = 'the import path names one file to Node (a URL) and another to path.resolve; '
51
+ + 'no percent-escape, backslash, tab, newline or edge space in an import path, write the path plainly';
52
+
53
+ /** `rawSource` without its ?query or #hash, which are no part of the file. Node keeps a bare specifier's `?` in the
54
+ * subpath, so for one the stripped path is only ever the stricter read. */
55
+ const pathPart = rawSource => {
56
+ const postfix = rawSource.slice(1).search(/[?#]/u) + 1;
57
+ return postfix > 0 ? rawSource.slice(0, postfix) : rawSource;
58
+ };
59
+
60
+ /** Why `rawSource` names one file to Node and another to path.resolve (or to Vite), or null when they agree. */
61
+ function encodedImportViolation(filename, rawSource) {
62
+ const source = pathPart(rawSource);
63
+ // Node resolves a relative path as a URL (`./%2e%2e/` is `..`, `\\` is `/`, tabs and newlines drop out, `%2f` is
64
+ // refused) and Vite decodes nothing, while path.resolve keeps them all as folder names: the lint and build disagree.
65
+ if (/%[0-9a-f]{2}|[\\\t\n\r]/iu.test(source)) return PLAINLY;
66
+ // The catch-all for a rewrite not listed above: the path must name the same file as a URL (how Node loads it).
67
+ if (source.startsWith('.') && nodePath(filename, source) !== resolve(dirname(filename), source).replaceAll('\\', '/')) return PLAINLY;
68
+ return null;
27
69
  }
28
70
 
29
- /** DS0.3 author folders use three, the authoring SDK, commons, and their own shard files only. */
30
- export function generatorImportViolation(filename, source) {
31
- const path=resolve(filename).replaceAll('\\','/'), match=/(?:^|\/)src\/shards\/([^/]+)\/(.+)$/u.exec(path);
32
- if(match===null || !(/^(?:generators|data|quests)\//u.test(match[2]) || match[2]==='shard.config.ts')) return null;
33
- if(typeof source!=='string')return null;
71
+ /** DS0.3 author folders use three, the authoring SDK, commons, and their own shard files only. Every other shard file
72
+ * (bake commands, Blender sources, declarations) imports by a plain relative path or a package name: an escaped,
73
+ * absolute or file: path would slip past the layer rules, which read it with path.resolve. */
74
+ export function generatorImportViolation(filename, rawSource) {
75
+ const path=resolve(filename).replaceAll('\\','/'), shard=shardOfFilename(path);
76
+ if(shard===null || typeof rawSource!=='string')return null;
77
+ const encoded=encodedImportViolation(filename,rawSource);
78
+ if(encoded!==null)return encoded;
79
+ const source=pathPart(rawSource);
80
+ if(!(/^(?:generators|data|quests)\//u.test(shard.local) || shard.local==='shard.config.ts'))
81
+ return isAbsolute(source) || source.startsWith('file:') ? 'shard files import by relative path or package name, never an absolute path or file: URL' : null;
34
82
  // Test runners and Node fixture tools never become producer imports.
35
83
  if(path.endsWith('.test.ts') && source!=='<computed>' && !source.startsWith('.')
36
84
  && !isAbsolute(source) && !source.startsWith('@wildshard/')) return null;
37
85
  if(/^@wildshard\/sharddev\/runtime(?:\/|$)/u.test(source))return 'trusted SDK runtime code is not an authoring import';
38
86
  if(source==='three' || source.startsWith('three/') || /^@wildshard\/(?:engine\/host|sdk|sharddev|commons)(?:\/|$)/u.test(source))return null;
39
87
  const local=source.startsWith('.') ? resolve(dirname(filename),source).replaceAll('\\','/') : '';
40
- const boundary=path.slice(0,path.length-match[2].length);
41
- if(local.startsWith(boundary))return null;
88
+ if(local.startsWith(shard.dir))return null;
42
89
  return 'author folders import only three, sdk, commons or their own shard files';
43
90
  }
@@ -0,0 +1,9 @@
1
+ /** SA45: a file in shard source, in either layout (`src/shards/<slug>/` or a single-shard repo's `src/`). */
2
+ export interface ShardFile { readonly slug: string; readonly local: string; readonly base: string; readonly path: string }
3
+ export interface LintFile { readonly root: string; readonly file: string; readonly path: string; readonly shard: ShardFile | null }
4
+ export function repoShardSlug(repo: string): string | null;
5
+ export function shardFile(root: string, file: string): ShardFile | null;
6
+ export function shardSourceDirs(root: string): string[];
7
+ export function lintFile(filename: string, base: string): LintFile;
8
+ export function sourcePath(filename: string, base: string): string;
9
+ export function shardOfFilename(filename: string): { readonly slug: string; readonly local: string; readonly dir: string } | null;
@@ -0,0 +1,91 @@
1
+ // SA45 (J317, J329): the one answer to "is this file shard source, which shard, and where is its root", for both
2
+ // layouts. Engine and multi-shard repos keep `src/shards/<slug>/`; a single-shard repo keeps its one shard at `src/`
3
+ // (`src/shard.config.ts`, or a hand-written `src/shard.json`), the rule sharddev's shardSource.ts (SA16) uses.
4
+ //
5
+ // Lint rules match one layout: a single-shard file `src/<local>` reads as `src/shards/<slug>/<local>` (its source path).
6
+ // Debt keys (lint/ratchet.json, runtime-performance.json) use that form too, so a repo's keys survive the move to `src/`.
7
+ // Anything that opens the file on disk uses its real path; scripts/blender/targets.json may name either form.
8
+ import { existsSync, readFileSync } from 'node:fs';
9
+ import { basename, relative, resolve, sep } from 'node:path';
10
+
11
+ const SHARD_CONFIG = 'shard.config.ts';
12
+ const SHARD_INDEX = 'shard.json';
13
+ const slash = path => path.replaceAll('\\', '/');
14
+ const readJson = (file) => {
15
+ try { return JSON.parse(readFileSync(file, 'utf8')); } catch { return null; }
16
+ };
17
+
18
+ const repoSlugs = new Map();
19
+ /** The slug of the one shard whose source is `<repo>/src`, or null when that `src/` is no shard source. Like
20
+ * sharddev's shardFolderName: a hand-written source's `identity.slug`, else `manifest.json`'s `slug`, else the repo folder. */
21
+ export function repoShardSlug(repo) {
22
+ const key = resolve(repo);
23
+ if (repoSlugs.has(key)) return repoSlugs.get(key);
24
+ const src = resolve(key, 'src'), config = existsSync(resolve(src, SHARD_CONFIG));
25
+ const handwritten = !config && existsSync(resolve(src, SHARD_INDEX));
26
+ let slug = null;
27
+ if (config || handwritten) {
28
+ const named = (handwritten ? readJson(resolve(src, SHARD_INDEX))?.identity?.slug : undefined) ?? readJson(resolve(src, 'manifest.json'))?.slug;
29
+ slug = typeof named === 'string' && named !== '' ? named : basename(key);
30
+ }
31
+ repoSlugs.set(key, slug);
32
+ return slug;
33
+ }
34
+
35
+ /** `file` (relative to the repo `root`, real layout) as shard source: its slug, its shard-local path, its shard root
36
+ * relative to `root` (`src` or `src/shards/<slug>`) and its source path (`src/shards/<slug>/<local>`); else null. */
37
+ export function shardFile(root, file) {
38
+ const path = slash(file);
39
+ if (!path.startsWith('src/')) return null;
40
+ const single = repoShardSlug(root);
41
+ if (single !== null) {
42
+ const local = path.slice('src/'.length);
43
+ return local === '' ? null : { slug: single, local, base: 'src', path: `src/shards/${single}/${local}` };
44
+ }
45
+ const match = /^src\/shards\/([^/]+)\/(.+)$/u.exec(path);
46
+ return match === null ? null : { slug: match[1], local: match[2], base: `src/shards/${match[1]}`, path };
47
+ }
48
+
49
+ /** The folders (relative to `root`) that hold shard source: `src` in a single-shard repo, else `src/shards`. */
50
+ export function shardSourceDirs(root) {
51
+ return repoShardSlug(root) === null ? ['src/shards'] : ['src'];
52
+ }
53
+
54
+ /** The innermost single-shard repo holding absolute `abs` (the folder above one of its `/src/` segments), or null. */
55
+ function singleRepoOf(abs) {
56
+ const path = slash(abs);
57
+ for (let index = path.lastIndexOf('/src/'); index > 0; index = path.lastIndexOf('/src/', index - 1)) {
58
+ if (repoShardSlug(path.slice(0, index)) !== null) return path.slice(0, index);
59
+ }
60
+ return null;
61
+ }
62
+
63
+ /** Absolute `filename` as lint sees it: `file` its repo-relative real path from the last `/src/` (or relative to
64
+ * `base` when it has none), `path` its source path, `root` the repo root, and `shard` its shardFile (or null). */
65
+ export function lintFile(filename, base) {
66
+ const abs = resolve(filename), repo = singleRepoOf(abs);
67
+ if (repo !== null) {
68
+ const file = slash(relative(repo, abs)), shard = shardFile(repo, file);
69
+ return { root: repo.split('/').join(sep), file, path: shard?.path ?? file, shard };
70
+ }
71
+ const path = slash(relative(base, abs)), index = path.lastIndexOf('/src/');
72
+ const file = index === -1 ? path : path.slice(index + 1);
73
+ const absolute = slash(abs), marker = absolute.lastIndexOf('/src/');
74
+ const root = marker === -1 ? resolve(base) : abs.slice(0, marker);
75
+ const match = /^src\/shards\/([^/]+)\/(.+)$/u.exec(file);
76
+ return { root, file, path: file, shard: match === null ? null : { slug: match[1], local: match[2], base: `src/shards/${match[1]}`, path: file } };
77
+ }
78
+
79
+ /** Absolute `filename`'s source path (see lintFile). */
80
+ export const sourcePath = (filename, base) => lintFile(filename, base).path;
81
+
82
+ /** Absolute `filename`'s shard: slug, shard-local path and the absolute shard root folder; null outside shard source. */
83
+ export function shardOfFilename(filename) {
84
+ const abs = slash(resolve(filename)), repo = singleRepoOf(abs);
85
+ if (repo !== null) {
86
+ const local = abs.slice(repo.length + '/src/'.length);
87
+ return local === '' ? null : { slug: repoShardSlug(repo), local, dir: `${repo}/src/` };
88
+ }
89
+ const match = /(?:^|\/)src\/shards\/([^/]+)\/(.+)$/u.exec(abs);
90
+ return match === null ? null : { slug: match[1], local: match[2], dir: abs.slice(0, abs.length - match[2].length) };
91
+ }
@@ -2,10 +2,12 @@
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { dirname, relative, resolve } from 'node:path';
4
4
  import { parseSync } from 'vite';
5
+ import { shardFile } from './shard-source.mjs';
5
6
 
6
7
  const BUILD = /^(?:data|generators|bake|behaviour|assets|blender)(?:\/|$)|^shard\.config(?:\.[cm]?[jt]s)?$/u;
7
8
  const PLAY = /^(?:runtime|world|look|models|weapons|quest|quests|combat|species|creatures|npc|loadout|ride|vm|grapple|life|compendium|boot|debug|dev|playground|explore|audio|loot|onboarding)(?:\/|$)/u;
8
- const shard = path => /^src\/shards\/([^/]+)\/(.+)$/u.exec(path);
9
+ /** [source path, slug, shard-local path] for `path` (relative to `root`, either layout, SA45), or null. */
10
+ const shard = (root, path) => { const found = shardFile(root, path); return found === null ? null : [found.path, found.slug, found.local]; };
9
11
  const text = node => node?.type === 'Literal' && typeof node.value === 'string' ? node.value
10
12
  : node?.type === 'TemplateLiteral' && node.expressions.length === 0 ? node.quasis[0]?.value.cooked ?? null : null;
11
13
  const prefix = node => text(node) ?? (node?.type === 'TemplateLiteral' ? node.quasis[0]?.value.cooked
@@ -34,8 +36,8 @@ function target(root, file, source) {
34
36
  }
35
37
 
36
38
  function violation(root, file, source, computed, glob, rule) {
37
- const own = shard(file), dest = source === null ? null : target(root, file, source);
38
- const other = dest === null ? null : shard(dest);
39
+ const own = shard(root, file), dest = source === null ? null : target(root, file, source);
40
+ const other = dest === null ? null : shard(root, dest);
39
41
  const build = own !== null && BUILD.test(own[2]);
40
42
  if (rule === 'runtime-standalone') {
41
43
  if (own === null || !own[2].startsWith('runtime/')) return null;
@@ -43,14 +45,14 @@ function violation(root, file, source, computed, glob, rule) {
43
45
  if (/[?#]/u.test(source)) return 'runtime/ cannot import assets, JSON, ?raw or ?url; read the admitted product instead';
44
46
  if (/\.[^/]+$/u.test(source) && !/\.[cm]?[jt]sx?$/u.test(source)) return `runtime/ cannot import JSON or assets: ${source}; read the admitted product instead`;
45
47
  if (dest === null) return publicPackage(root, source) ? null : `runtime/ imports only its own files and public engine/game/SDK/format, three or valibot modules: ${source}`;
46
- if (!dest.startsWith(`src/shards/${own[1]}/runtime/`)) return `runtime/ is standalone: ${source} leaves its own runtime/; read a built section or move play code into runtime/`;
48
+ if (other?.[1] !== own[1] || !other[2].startsWith('runtime/')) return `runtime/ is standalone: ${source} leaves its own runtime/; read a built section or move play code into runtime/`;
47
49
  if (/\.[^/]+$/u.test(dest) && !/\.[cm]?tsx?$/u.test(dest) || glob && !/\.[cm]?tsx?$/u.test(dest)) return `runtime/ cannot import JSON or assets: ${source}; read the admitted product instead`;
48
50
  return null;
49
51
  }
50
52
  if (rule === 'no-build-time-import') {
51
53
  if (!file.startsWith('src/') || file.startsWith('src/commons/') || /^src\/sharddev\/(?:cli|bake)\//u.test(file)) return null;
52
54
  if (other === null || !BUILD.test(other[2])) {
53
- return computed && dest?.startsWith('src/shards/') && !build ? `Play code cannot compute a path into shard build-time folders: ${source}` : null;
55
+ return computed && (other !== null || dest?.startsWith('src/shards/') === true) && !build ? `Play code cannot compute a path into shard build-time folders: ${source}` : null;
54
56
  }
55
57
  if (build && own[1] === other[1]) return null;
56
58
  return `Play code cannot import build-time code: ${source}; read it from the built shard's sections or blobs`;
@@ -64,7 +66,7 @@ function violation(root, file, source, computed, glob, rule) {
64
66
 
65
67
  /** Same AST visitors for the linter and copier. Type-only, lazy and resource imports are all boundaries. */
66
68
  export function shardfileBoundaryVisitors(root, file, rule, report) {
67
- const own = shard(file);
69
+ const own = shard(root, file);
68
70
  if (rule === 'runtime-standalone' && !own?.[2].startsWith('runtime/')) return {};
69
71
  if (rule === 'no-runtime-in-build' && (own === null || !BUILD.test(own[2]))) return {};
70
72
  const check = (node, raw, glob = false) => {
@@ -83,7 +85,7 @@ export function shardfileBoundaryVisitors(root, file, rule, report) {
83
85
  if (node.callee.type === 'Identifier' && node.callee.name === 'require') check(node, node.arguments[0]);
84
86
  if ((member(node.callee, 'glob') || member(node.callee, 'globEager')) && importMeta(node.callee.object)) {
85
87
  const raw = node.arguments[0], patterns = raw?.type === 'ArrayExpression' ? raw.elements : [raw];
86
- if (rule === 'runtime-standalone' && shard(file)?.[2].startsWith('runtime/') && node.arguments[1]?.type === 'ObjectExpression'
88
+ if (rule === 'runtime-standalone' && own?.[2].startsWith('runtime/') && node.arguments[1]?.type === 'ObjectExpression'
87
89
  && node.arguments[1].properties.some(property => ['query', 'as'].includes(property.key?.name ?? text(property.key)))) {
88
90
  report(node, 'runtime/ globs cannot transform modules into assets with query/as');
89
91
  }
@@ -99,7 +101,7 @@ export function shardfileBoundaryVisitors(root, file, rule, report) {
99
101
  };
100
102
  }
101
103
 
102
- /** Raw violations, without migration allowances. `file` is the source-relative src/shards/... path.
104
+ /** Raw violations, without migration allowances. `file` is relative to `root`: src/shards/<slug>/... or a single-shard src/... (SA45).
103
105
  * @returns {{rule: string, message: string, start: number, end: number}[]} */
104
106
  export function shardfileBoundaryViolations(root, file, source) {
105
107
  const parsed = parseSync(file, source);
@@ -4,6 +4,7 @@ import { currentSources, sourceStamp } from './source-stamps.mjs';
4
4
  import { existsSync, readFileSync, globSync, statSync } from 'node:fs';
5
5
  import { dirname, resolve, relative } from 'node:path';
6
6
  import { parseSync } from 'vite';
7
+ import { shardFile } from './shard-source.mjs';
7
8
 
8
9
  const VIEW = /^src\/(?:client|cook|server|shared)\/engine\/(?:app\/view\/|ai\/view\/|combat\/view\/|quest\/view(?:\/|\.ts$)|saves\/view\/|entities\/AnimalView\.ts$)/u;
9
10
  const FORBIDDEN = /^src\/(?:client|cook|server|shared)\/engine\/(?:app\/runtime(?:\.ts)?$|core\/(?:tier|frameCost)(?:\.ts)?$|render\/|ui\/|fx\/|anim\/)/u;
@@ -61,7 +62,9 @@ export function reference(node, parent) {
61
62
  return true;
62
63
  }
63
64
  const closureResults = new Map();
64
- export function simClosure(root, entries = globSync('src/**/*.ts', { cwd: root }).filter(simRoot)) {
65
+ /** simRoot of `path` (relative to `root`) read in the one shard layout, so a single-shard repo's src/data/ counts (SA45). */
66
+ const simRootIn = (root, path) => simRoot(shardFile(root, path)?.path ?? path);
67
+ export function simClosure(root, entries = globSync('src/**/*.ts', { cwd: root }).filter(path => simRootIn(root, path))) {
65
68
  const key = JSON.stringify([root, entries]), cached = closureResults.get(key);
66
69
  const copy = rows => rows.map(row => ({ ...row, trace: [...row.trace] }));
67
70
  if (cached !== undefined && currentSources(cached.observed)) return copy(cached.rows);
@@ -78,7 +81,7 @@ export function simClosure(root, entries = globSync('src/**/*.ts', { cwd: root }
78
81
  };
79
82
  const inspect = (node, parent) => {
80
83
  if (['ImportDeclaration', 'ExportNamedDeclaration', 'ExportAllDeclaration', 'ImportExpression'].includes(node.type)) {
81
- if (simRoot(path) && value(node.source) === 'three' && node.importKind === 'type' && node.specifiers?.some((s) => s.type !== 'ImportSpecifier' || !MATH.has(s.imported.name))) add('import', 'three');
84
+ if (simRootIn(root, path) && value(node.source) === 'three' && node.importKind === 'type' && node.specifiers?.some((s) => s.type !== 'ImportSpecifier' || !MATH.has(s.imported.name))) add('import', 'three');
82
85
  if (node.importKind === 'type' || node.exportKind === 'type' || (node.specifiers?.length && node.specifiers.every((s) => s.importKind === 'type'))) return;
83
86
  const source = value(node.source);
84
87
  if (source === null) { if (node.source) add('import', 'dynamic'); return; }
@@ -97,7 +100,7 @@ export function simClosure(root, entries = globSync('src/**/*.ts', { cwd: root }
97
100
  if (FORBIDDEN.test(destPath) || VIEW.test(destPath)) add('import', destPath);
98
101
  else if (/\.[cm]?[jt]s$/u.test(destPath)) next.push(destPath);
99
102
  }
100
- if (simRoot(path) && node.type === 'Identifier' && ['HTMLElement', 'HTMLCanvasElement'].includes(node.name) && parent?.type === 'TSTypeReference') add('global', node.name);
103
+ if (simRootIn(root, path) && node.type === 'Identifier' && ['HTMLElement', 'HTMLCanvasElement'].includes(node.name) && parent?.type === 'TSTypeReference') add('global', node.name);
101
104
  if (node.type === 'MemberExpression' && ['window', 'globalThis'].includes(node.object?.name) && DOM.has(node.property?.name) && node.property?.name !== 'window') add('global', node.property.name);
102
105
  if (node.type === 'Identifier' && reference(node, parent) && DOM.has(node.name)) add('global', node.name);
103
106
  };
@@ -11,3 +11,7 @@ export const VIEW_PATHS: readonly string[];
11
11
 
12
12
  /** G645 product-surface rules that do not apply to colocated test fixtures. */
13
13
  export const TEST_DOMAIN_RUNTIME_RULES: readonly string[];
14
+
15
+ /** The oxlint JS plugin: its name and every rule, keyed without the `wildshard/` prefix. */
16
+ declare const plugin: { readonly meta: { readonly name: string }; readonly rules: Readonly<Record<string, unknown>> };
17
+ export default plugin;
@@ -23,15 +23,16 @@ import { declarationConfigProgram } from './declaration-config.mjs';
23
23
  // parameter it is (`num('scale', 1)`) — anything else is an error;
24
24
  // · raw parsing of `location.search` (`.includes`, `.match`, regex `.test`, …) that dodges the above.
25
25
  import { existsSync, readFileSync } from 'node:fs';
26
- import { dirname, relative, resolve } from 'node:path';
26
+ import { dirname, resolve } from 'node:path';
27
27
  import { fileURLToPath } from 'node:url';
28
28
  import { simClosure, simRoot } from './sim-closure.mjs';
29
29
  import { authoredHtmlSites } from './authored-html.mjs';
30
30
  import { runtimePerformanceViolations } from './runtime-performance.mjs';
31
- import { shardGameImport, shardEngineImport, generatorImportViolation } from './shard-imports.mjs';
31
+ import { shardGameImport, shardEngineImport, sharddevRuntimeImport, generatorImportViolation } from './shard-imports.mjs';
32
32
  import { shardfileBoundaryVisitors } from './shardfile-boundaries.mjs';
33
33
  import { hostCallbackSites } from './host-callback-syntax.mjs';
34
34
  import { hostPlayFile } from './host-files.mjs';
35
+ import { lintFile } from './shard-source.mjs';
35
36
 
36
37
  const REPO = fileURLToPath(new URL('../', import.meta.url));
37
38
  /** E432: the layers are workspace packages, `@wildshard/<layer>[/<sub>]` → `src/<layer>/<sub | index>`. Whether a
@@ -289,23 +290,23 @@ const noUrlSwitch = {
289
290
 
290
291
  // E357 F4: syntactic ratchets; their scope and patterns are 01 §24 / 02 F4's contract.
291
292
  // Filenames and lexical import paths are immutable during one plugin process.
293
+ // SA45: a single-shard repo's `src/<local>` reads as `src/shards/<slug>/<local>` (lint/shard-source.mjs), so every shard
294
+ // rule below matches one layout; `fileOf` keeps the real repo root and path for the rules that open files on disk.
292
295
  const filenamePaths = new Map(), modulePaths = new Map();
293
- const pathOf = (context) => {
296
+ const fileOf = (context) => {
294
297
  const cached = filenamePaths.get(context.filename);
295
298
  if (cached !== undefined) return cached;
296
- const path = relative(REPO, context.filename).replaceAll('\\', '/');
297
- const index = path.lastIndexOf('/src/');
298
- const normalized = index === -1 ? path : path.slice(index + 1);
299
- filenamePaths.set(context.filename, normalized);
300
- return normalized;
299
+ const file = lintFile(context.filename, REPO);
300
+ filenamePaths.set(context.filename, file);
301
+ return file;
301
302
  };
303
+ const pathOf = (context) => fileOf(context).path;
302
304
  const modulePath = (filename, source) => {
303
305
  let paths = modulePaths.get(filename);
304
306
  if (paths === undefined) { paths = new Map(); modulePaths.set(filename, paths); }
305
307
  if (paths.has(source)) return paths.get(source);
306
308
  const target = packageTarget(source);
307
- const path = target ?? (!source.startsWith('.') ? source
308
- : relative(REPO, resolve(dirname(filename), source)).replaceAll('\\', '/').replace(/^.*\/src\//u, 'src/'));
309
+ const path = target ?? (!source.startsWith('.') ? source : lintFile(resolve(dirname(filename), source), REPO).path);
309
310
  paths.set(source, path);
310
311
  return path;
311
312
  };
@@ -545,6 +546,24 @@ const noRendererType = rule('Renderer types stay inside rendering (E357)', (cont
545
546
  if (/^src\/(?:client|cook|server|shared)\/engine\/(?:render\/|core\/(?:Game|bootstrap)\.ts$)/u.test(pathOf(context))) return {};
546
547
  return { Identifier(node) { if (node.name === 'WebGLRenderer') report(context, node, 'Renderer types belong in engine/render'); } };
547
548
  });
549
+ // J326 (Jake, 2026-11-13): "Let's only do WebGL renderer. Let's not do any WebGPU renderer." Nothing imports three's
550
+ // WebGPU or TSL builds, names WebGPURenderer, or asks the browser for a WebGPU adapter; renderer.ts makes the one
551
+ // WebGLRenderer on a WebGL2 context (core/webglStartup.ts).
552
+ const WEBGPU_SOURCE = /^three\/(?:webgpu|tsl)(?:$|\/)|^three\/(?:examples\/jsm|addons)\/(?:renderers\/webgpu|nodes|tsl)(?:$|\/)|^three\/(?:examples\/jsm|addons)\/capabilities\/WebGPU(?:\.js)?$|three\.webgpu/u;
553
+ const WEBGPU_MESSAGE = 'WebGL renderer only, no WebGPU (J326)';
554
+ const isNavigator = (node) => { const x = unwrap(node); return (x?.type === 'Identifier' && x.name === 'navigator') || (x?.type === 'MemberExpression' && propName(x) === 'navigator'); };
555
+ const noWebgpu = rule('WebGL renderer only, no WebGPU (J326)', (context) => ({
556
+ ...importsVisitor((node) => { const source = importPrefix(node.source); if (typeof source === 'string' && WEBGPU_SOURCE.test(source)) report(context, node, WEBGPU_MESSAGE); }),
557
+ Identifier(node) { if (node.name === 'WebGPURenderer') report(context, node, WEBGPU_MESSAGE); },
558
+ MemberExpression(node) {
559
+ if ((propName(node) === 'gpu' || stringOf(node.property) === 'gpu') && isNavigator(node.object)) report(context, node, WEBGPU_MESSAGE);
560
+ else if (propName(node) === 'requestAdapter') report(context, node, WEBGPU_MESSAGE);
561
+ },
562
+ BinaryExpression(node) { if (node.operator === 'in' && stringOf(node.left) === 'gpu' && isNavigator(node.right)) report(context, node, WEBGPU_MESSAGE); },
563
+ VariableDeclarator(node) {
564
+ if (node.id?.type === 'ObjectPattern' && isNavigator(node.init) && node.id.properties.some((p) => p.type === 'Property' && (p.key?.name === 'gpu' || stringOf(p.key) === 'gpu'))) report(context, node, WEBGPU_MESSAGE);
565
+ },
566
+ }));
548
567
  const SHADER_HOOKS = new Set(['onBeforeCompile', 'customProgramCacheKey']);
549
568
  const noRawShaderPatch = rule('Shader patches go through the one registry (E357 X6)', (context) => {
550
569
  if (pathOf(context).startsWith('src/client/engine/render/')) return {};
@@ -561,9 +580,8 @@ const simAllow = JSON.parse(readFileSync(new URL('sim-closure.json', import.meta
561
580
  const simNoRender = rule('Headless simulation checks its complete runtime import closure (SF3a)', (context) => {
562
581
  if (!simRoot(pathOf(context))) return {};
563
582
  return { Program(node) {
564
- const marker = context.filename.replaceAll('\\', '/').lastIndexOf('/src/');
565
- const root = marker === -1 ? REPO : context.filename.slice(0, marker);
566
- for (const item of simClosure(root, [pathOf(context)])) {
583
+ const { root, file } = fileOf(context);
584
+ for (const item of simClosure(root, [file])) {
567
585
  const allowance = root === REPO.replace(/\/$/u, '') ? simAllow[item.id]?.count ?? 0 : 0;
568
586
  if (item.count > allowance) report(context, node, `Simulation closure: ${item.id} (${item.count} > ${allowance}); ${item.trace.join(' → ')}`);
569
587
  }
@@ -958,14 +976,12 @@ const shardHostCallback = {
958
976
  meta: { type: 'problem', docs: { description: 'Shard host APIs take data, not TS callbacks (G454)' },
959
977
  schema: [{ type: 'object', properties: { count: { type: 'boolean' } }, additionalProperties: false }] },
960
978
  create(context) {
961
- const file = pathOf(context);
979
+ const { root, file: real, path: file } = fileOf(context);
962
980
  if (!file.startsWith('src/shards/')) return {};
963
- const index = context.filename.replaceAll('\\', '/').lastIndexOf('/src/');
964
- const root = index === -1 ? REPO : context.filename.slice(0, index);
965
- if (!hostPlayFile(root, file)) return {};
981
+ if (!hostPlayFile(root, real)) return {};
966
982
  const limit = context.options[0]?.count === true ? 0 : shardfileDebt['wildshard/no-shard-host-callback']?.[file] ?? 0;
967
983
  return { 'Program:exit'(program) {
968
- for (const issue of hostCallbackSites(root, file, program).slice(limit)) context.report({
984
+ for (const issue of hostCallbackSites(root, real, program).slice(limit)) context.report({
969
985
  loc: { start: context.sourceCode.getLocFromIndex(issue.start), end: context.sourceCode.getLocFromIndex(issue.end) }, message: issue.message,
970
986
  });
971
987
  } };
@@ -975,15 +991,13 @@ const shardfileBoundaryRule = name => ({
975
991
  meta: { type: 'problem', docs: { description: `Shardfile source boundary: ${name} (G450)` },
976
992
  schema: [{ type: 'object', properties: { count: { type: 'boolean' }, closedShards: { type: 'array', items: { type: 'string' }, uniqueItems: true } }, additionalProperties: false }] },
977
993
  create(context) {
978
- const file = pathOf(context);
994
+ const { root, file: real, path: file } = fileOf(context);
979
995
  if (name === 'runtime-standalone') return {};
980
- const index = context.filename.replaceAll('\\', '/').lastIndexOf('/src/');
981
- const root = index === -1 ? REPO : context.filename.slice(0, index);
982
996
  const slug = /^src\/shards\/([^/]+)\//u.exec(file)?.[1];
983
997
  const closed = context.options[0]?.closedShards?.includes(slug) === true;
984
998
  const limit = closed || context.options[0]?.count === true ? 0 : shardfileDebt[`wildshard/${name}`]?.[file] ?? 0;
985
999
  let count = 0;
986
- return shardfileBoundaryVisitors(root, file, name, (node, message) => {
1000
+ return shardfileBoundaryVisitors(root, real, name, (node, message) => {
987
1001
  count += 1;
988
1002
  if (count > limit) report(context, node, message);
989
1003
  });
@@ -996,8 +1010,11 @@ const shardfileBoundaryRule = name => ({
996
1010
  const blenderTargetsFile = resolve(process.cwd(), 'scripts/blender/targets.json'); // Shard lint: blender sources left with the shards.
997
1011
  const blenderTargets = existsSync(blenderTargetsFile) ? JSON.parse(readFileSync(blenderTargetsFile, 'utf8')).targets : [];
998
1012
  const blenderSources = new Set();
999
- for (const target of Object.values(blenderTargets)) for (const file of [target.script, target.post, ...(target.sources ?? [])])
1000
- if (typeof file === 'string' && /^src\/shards\/[^/]+\/blender\/.+\.[cm]?[jt]sx?$/u.test(file)) blenderSources.add(file);
1013
+ for (const target of Object.values(blenderTargets)) for (const entry of [target.script, target.post, ...(target.sources ?? [])]) {
1014
+ // SA45: an entry names the real file (`src/blender/…` in a single-shard repo) or already the source path.
1015
+ const file = typeof entry !== 'string' ? null : entry.startsWith('src/shards/') ? entry : lintFile(resolve(process.cwd(), entry), REPO).path;
1016
+ if (file !== null && /^src\/shards\/[^/]+\/blender\/.+\.[cm]?[jt]sx?$/u.test(file)) blenderSources.add(file);
1017
+ }
1001
1018
 
1002
1019
  // F3: hard structural boundary. No count option or debt allowance exists.
1003
1020
  const noShardRuntime = rule('Primary shards contain authoring and declarations only (G694 F3)', context => {
@@ -1010,8 +1027,8 @@ const noShardRuntime = rule('Primary shards contain authoring and declarations o
1010
1027
  report(context, node, 'Primary shard runtime source is forbidden; use generators/, registered Blender sources or erased declarations; shard.config.ts must be declaration-only');
1011
1028
  },
1012
1029
  ...boundaryVisitors((node, source) => {
1013
- if (typeof source === 'string' && (/^@wildshard\/sharddev\/runtime(?:\/|$)/u.test(source)
1014
- || modulePath(context.filename, source).startsWith('src/sharddev/runtime/')))
1030
+ if (typeof source === 'string' && (/^@wildshard\/sharddev\/runtime(?:[/?#]|$)/u.test(source)
1031
+ || modulePath(context.filename, source).startsWith('src/sharddev/runtime/') || sharddevRuntimeImport(context.filename, source)))
1015
1032
  report(context, node, 'Primary shards cannot import trusted SDK runtime; emit admitted data or WASM instead');
1016
1033
  }),
1017
1034
  };
@@ -1165,7 +1182,7 @@ const plugin = {
1165
1182
  'runtime-performance': runtimePerformance,
1166
1183
  'no-url-switch': noUrlSwitch, layer, 'public-index': publicIndex, 'engine-words': engineWordsRule, 'no-shard-branch': noShardBranch, 'no-raw-save': noRawSave,
1167
1184
  'no-raw-random-time': noRawRandomTime, 'no-raw-input': noRawInput,
1168
- 'no-renderer-type': noRendererType, 'no-raw-shader-patch': noRawShaderPatch, 'sim-no-render': simNoRender,
1185
+ 'no-renderer-type': noRendererType, 'no-webgpu': noWebgpu, 'no-raw-shader-patch': noRawShaderPatch, 'sim-no-render': simNoRender,
1169
1186
  'no-runtime-generator': noRuntimeGenerator,
1170
1187
  'no-hook-chain': noHookChain,
1171
1188
  'no-active-singleton': noActiveSingleton, 'no-active-chunk': noActiveChunk,