@adatechnology/game-contracts 0.21.0 → 0.23.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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Warns on the console the first time `key` is seen, and only outside production and when `globalThis.__GAME_KIT_QUIET__` is not `true`: for a silent fallback that keeps working (an adapter that made its own effects
3
+ * world or audio engine because the host lent none). The seen keys live on `globalThis`, so several bundles of the kit on one page warn once together.
4
+ */
5
+ declare const warnOnce: (key: string, message: string) => void;
6
+ /** Forgets what `warnOnce` has seen (tests that count warnings). */
7
+ declare const resetWarnOnce: () => void;
8
+
9
+ export { resetWarnOnce as r, warnOnce as w };
@@ -0,0 +1 @@
1
+ export { r as resetWarnOnce } from './testing-CJY18EZK.js';
@@ -0,0 +1,11 @@
1
+ // src/warn.ts
2
+ var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
3
+ var warnedKeys = () => {
4
+ const holder = globalThis;
5
+ return holder[WARNED_KEY] ?? (holder[WARNED_KEY] = /* @__PURE__ */ new Set());
6
+ };
7
+ var resetWarnOnce = () => warnedKeys().clear();
8
+ export {
9
+ resetWarnOnce
10
+ };
11
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/warn.ts"],"sourcesContent":["const WARNED_KEY = Symbol.for('@adatechnology/game-contracts.warned')\n\ntype WarnedHolder = { [WARNED_KEY]?: Set<string> }\n\nconst warnedKeys = (): Set<string> => {\n const holder = globalThis as WarnedHolder\n return (holder[WARNED_KEY] ??= new Set<string>())\n}\n\ndeclare const process: { readonly env: { readonly NODE_ENV?: string } }\n\n// The literal `process.env.NODE_ENV` is what bundlers replace; where there is no `process` the reference throws and counts as development.\nconst isProduction = (): boolean => {\n try {\n return process.env.NODE_ENV === 'production'\n } catch {\n return false\n }\n}\n\nconst isQuiet = (): boolean => (globalThis as { __GAME_KIT_QUIET__?: unknown }).__GAME_KIT_QUIET__ === true\n\n/**\n * Warns on the console the first time `key` is seen, and only outside production and when `globalThis.__GAME_KIT_QUIET__` is not `true`: for a silent fallback that keeps working (an adapter that made its own effects\n * world or audio engine because the host lent none). The seen keys live on `globalThis`, so several bundles of the kit on one page warn once together.\n */\nexport const warnOnce = (key: string, message: string): void => {\n if (isQuiet() || isProduction()) return\n const seen = warnedKeys()\n if (seen.has(key)) return\n seen.add(key)\n console.warn(`[game-kit] ${message}`)\n}\n\n/** Forgets what `warnOnce` has seen (tests that count warnings). */\nexport const resetWarnOnce = (): void => warnedKeys().clear()\n"],"mappings":";AAAA,IAAM,aAAa,uBAAO,IAAI,sCAAsC;AAIpE,IAAM,aAAa,MAAmB;AACpC,QAAM,SAAS;AACf,SAAQ,4CAAuB,oBAAI,IAAY;AACjD;AA4BO,IAAM,gBAAgB,MAAY,WAAW,EAAE,MAAM;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adatechnology/game-contracts",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "license": "MIT",
5
5
  "description": "The contracts every game module depends on, and nothing else: destruction (parts, hits, events, DestructibleImpl), weapons (shots), fluids (containers, item uses), item animations and the TestableModule a module hands the test room. Types plus tiny checkers, no runtime dependencies.",
6
6
  "keywords": [
@@ -33,6 +33,10 @@
33
33
  "types": "./dist/index.d.ts",
34
34
  "import": "./dist/index.js"
35
35
  },
36
+ "./testing": {
37
+ "types": "./dist/testing.d.ts",
38
+ "import": "./dist/testing.js"
39
+ },
36
40
  "./global": "./dist/index.global.js"
37
41
  },
38
42
  "files": [