@forgeax/engine-profiler 0.1.19 → 0.1.21

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.
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,gCAAgC,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,0BAA0B,GAAG,+BAA+B,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACtE,CAAC;AAsIF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,aAAa,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAkBrD"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,gCAAgC,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,0BAA0B,GAAG,+BAA+B,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACtE,CAAC;AA2KF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,aAAa,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAkBrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/engine-profiler",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/src/schema.ts CHANGED
@@ -1,7 +1,6 @@
1
- // Ajv ships this entry as CommonJS. Use the named constructor so Vite's
2
- // native ESM dev server does not assume a synthetic default export when the
3
- // profiler is imported by the browser runtime.
4
- import { Ajv2020 } from 'ajv/dist/2020.js';
1
+ import * as AjvCoreModule from 'ajv/dist/core.js';
2
+ import * as AddMetaSchema2020Module from 'ajv/dist/refs/json-schema-2020-12/index.js';
3
+ import * as Draft2020Module from 'ajv/dist/vocabularies/draft2020.js';
5
4
  import schemaDocument from '../schema/profile-capture.schema.json' with { type: 'json' };
6
5
  import type { ProfileCapture, ProfileRecord } from './generated/profile-capture.js';
7
6
  import type { ProfileResult } from './types.js';
@@ -13,7 +12,44 @@ export type ProfileArtifactError = {
13
12
  readonly detail: { readonly path: string; readonly message: string };
14
13
  };
15
14
 
16
- const validator = new Ajv2020({ allErrors: true, strict: true }).compile(schemaDocument);
15
+ // Ajv publishes this entry as CommonJS. Native Node ESM exposes the CJS module
16
+ // object as `default`, while Vite's browser interop exposes the constructor
17
+ // directly. Normalize that boundary once so both config-time and browser-time
18
+ // imports instantiate the same constructor.
19
+ function resolveCommonJsDefault<T>(
20
+ moduleDefault: unknown,
21
+ isExpected: (value: unknown) => value is T,
22
+ ): T {
23
+ if (isExpected(moduleDefault)) return moduleDefault;
24
+ const nestedDefault = (moduleDefault as { default?: unknown } | null)?.default;
25
+ if (isExpected(nestedDefault)) return nestedDefault;
26
+ throw new TypeError('Ajv CommonJS export shape is unsupported');
27
+ }
28
+
29
+ const AjvCore = resolveCommonJsDefault(
30
+ AjvCoreModule.default,
31
+ (value): value is typeof AjvCoreModule.default => typeof value === 'function',
32
+ );
33
+ const addMetaSchema2020 = resolveCommonJsDefault(
34
+ AddMetaSchema2020Module.default,
35
+ (value): value is typeof AddMetaSchema2020Module.default => typeof value === 'function',
36
+ );
37
+ const draft2020 = resolveCommonJsDefault(
38
+ Draft2020Module.default,
39
+ (value): value is typeof Draft2020Module.default => Array.isArray(value),
40
+ );
41
+
42
+ const ajv = new AjvCore({
43
+ allErrors: true,
44
+ dynamicRef: true,
45
+ meta: false,
46
+ next: true,
47
+ strict: true,
48
+ unevaluated: true,
49
+ });
50
+ for (const vocabulary of draft2020) ajv.addVocabulary(vocabulary);
51
+ addMetaSchema2020.call(ajv, false);
52
+ const validator = ajv.compile(schemaDocument);
17
53
 
18
54
  function error(
19
55
  code: ProfileArtifactError['code'],