@adcp/sdk 17.0.0-beta.30 → 17.0.0-beta.32

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 (38) hide show
  1. package/dist/lib/identity-3.3/trust.js +10 -4
  2. package/dist/lib/identity-3.3/trust.mjs +10 -4
  3. package/dist/lib/server/create-adcp-server.js +7 -8
  4. package/dist/lib/server/create-adcp-server.mjs +9 -10
  5. package/dist/lib/server/error-arm-tools.d.mts +23 -14
  6. package/dist/lib/server/error-arm-tools.d.ts +23 -14
  7. package/dist/lib/server/error-arm-tools.js +82 -34
  8. package/dist/lib/server/error-arm-tools.mjs +81 -34
  9. package/dist/lib/testing/storyboard/compliance.js +53 -24
  10. package/dist/lib/testing/storyboard/compliance.mjs +53 -24
  11. package/dist/lib/testing/storyboard/context.js +14 -10
  12. package/dist/lib/testing/storyboard/context.mjs +14 -10
  13. package/dist/lib/testing/storyboard/loader.js +2 -2
  14. package/dist/lib/testing/storyboard/loader.mjs +2 -2
  15. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  16. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  17. package/dist/lib/testing/storyboard/yaml-cache.d.mts +21 -0
  18. package/dist/lib/testing/storyboard/yaml-cache.d.ts +21 -0
  19. package/dist/lib/testing/storyboard/yaml-cache.js +168 -0
  20. package/dist/lib/testing/storyboard/yaml-cache.mjs +139 -0
  21. package/dist/lib/validation/schema-diagnostic-origins.js +55 -25
  22. package/dist/lib/validation/schema-diagnostic-origins.mjs +55 -25
  23. package/dist/lib/validation/schema-loader.js +499 -44
  24. package/dist/lib/validation/schema-loader.mjs +499 -46
  25. package/dist/lib/validation/schema-validator.js +4 -6
  26. package/dist/lib/validation/schema-validator.mjs +6 -7
  27. package/dist/lib/validation/validator-cache.d.mts +45 -0
  28. package/dist/lib/validation/validator-cache.d.ts +45 -0
  29. package/dist/lib/validation/validator-cache.js +249 -0
  30. package/dist/lib/validation/validator-cache.mjs +227 -0
  31. package/dist/lib/version.d.mts +3 -3
  32. package/dist/lib/version.d.ts +3 -3
  33. package/dist/lib/version.js +3 -3
  34. package/dist/lib/version.mjs +3 -3
  35. package/docs/TYPE-SUMMARY.md +2 -2
  36. package/docs/llms.txt +2 -2
  37. package/docs/migration-14.x-rc-worksheet.md +4 -4
  38. package/package.json +1 -1
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var yaml_cache_exports = {};
30
+ __export(yaml_cache_exports, {
31
+ parseStoryboardYaml: () => parseStoryboardYaml
32
+ });
33
+ module.exports = __toCommonJS(yaml_cache_exports);
34
+ var import_node_crypto = require("node:crypto");
35
+ var import_node_module = require("node:module");
36
+ var import_node_path = __toESM(require("node:path"));
37
+ var import_node_util = require("node:util");
38
+ var import_yaml = require("yaml");
39
+ var import_version = require('../../version.js');
40
+ const ENTRY_KIND = "storyboard-yaml";
41
+ function cacheDir() {
42
+ const dir = process.env.ADCP_VALIDATOR_CACHE_DIR;
43
+ return dir && import_node_path.default.isAbsolute(dir) ? dir : void 0;
44
+ }
45
+ let opened;
46
+ let staticKey;
47
+ function openCache(dir) {
48
+ if (opened?.dir !== dir) {
49
+ const { openValidatorCache } = (
50
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
51
+ require('../../validation/validator-cache.js')
52
+ );
53
+ opened = { dir, cache: openValidatorCache(dir, import_node_path.default.join(__dirname, "yaml-cache.js")) };
54
+ }
55
+ return opened.cache;
56
+ }
57
+ function parserKey() {
58
+ if (staticKey) return staticKey;
59
+ const { filesDigest } = (
60
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
61
+ require('../../validation/validator-cache.js')
62
+ );
63
+ let yamlVersion = null;
64
+ try {
65
+ const moduleRequire = (0, import_node_module.createRequire)(import_node_path.default.join(__dirname, "yaml-cache.js"));
66
+ yamlVersion = moduleRequire("yaml/package.json").version ?? null;
67
+ } catch {
68
+ }
69
+ staticKey = [
70
+ import_version.LIBRARY_VERSION,
71
+ filesDigest(["yaml-cache.js", "yaml-cache.mjs"].map((file) => import_node_path.default.join(__dirname, file))),
72
+ yamlVersion
73
+ ];
74
+ return staticKey;
75
+ }
76
+ function sharedObjects(root) {
77
+ const firstPath = /* @__PURE__ */ new Map();
78
+ const shared = [];
79
+ const visit = (value, at) => {
80
+ if (value === null || typeof value !== "object") return;
81
+ const first = firstPath.get(value);
82
+ if (first) {
83
+ shared.push([at, first]);
84
+ return;
85
+ }
86
+ firstPath.set(value, at);
87
+ if (Array.isArray(value)) value.forEach((item, index) => visit(item, [...at, index]));
88
+ else for (const [key, item] of Object.entries(value)) visit(item, [...at, key]);
89
+ };
90
+ visit(root, []);
91
+ return shared;
92
+ }
93
+ function withoutRepeats(root, shared) {
94
+ if (shared.length === 0) return root;
95
+ const repeats = new Set(shared.map(([at]) => JSON.stringify(at)));
96
+ const copy = (value, at) => {
97
+ if (repeats.has(JSON.stringify(at))) return null;
98
+ if (value === null || typeof value !== "object") return value;
99
+ if (Array.isArray(value)) return value.map((item, index) => copy(item, [...at, index]));
100
+ const out = {};
101
+ for (const [key, item] of Object.entries(value)) out[key] = copy(item, [...at, key]);
102
+ return out;
103
+ };
104
+ return copy(root, []);
105
+ }
106
+ function valueAt(root, at) {
107
+ let value = root;
108
+ for (const segment of at) value = value[segment];
109
+ return value;
110
+ }
111
+ function restore(stored) {
112
+ const value = stored.value;
113
+ for (const [at, first] of stored.shared) {
114
+ const parent = valueAt(value, at.slice(0, -1));
115
+ parent[at[at.length - 1]] = valueAt(value, first);
116
+ }
117
+ return value;
118
+ }
119
+ function isStoredDocument(value) {
120
+ return value !== null && typeof value === "object" && Object.hasOwn(value, "value") && Array.isArray(value.shared);
121
+ }
122
+ function storable(document) {
123
+ const shared = sharedObjects(document);
124
+ let json;
125
+ try {
126
+ json = JSON.stringify({ value: withoutRepeats(document, shared), shared });
127
+ } catch {
128
+ return void 0;
129
+ }
130
+ if (json === void 0) return void 0;
131
+ const stored = JSON.parse(json);
132
+ const restored = restore(JSON.parse(json));
133
+ if (!(0, import_node_util.isDeepStrictEqual)(restored, document)) return void 0;
134
+ if (!(0, import_node_util.isDeepStrictEqual)(sharedObjects(restored), shared)) return void 0;
135
+ return stored;
136
+ }
137
+ function parseStoryboardYaml(source) {
138
+ const dir = cacheDir();
139
+ if (dir === void 0) return (0, import_yaml.parse)(source);
140
+ const cache = openCache(dir);
141
+ if (!cache) return (0, import_yaml.parse)(source);
142
+ const { validatorCacheKey } = (
143
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
144
+ require('../../validation/validator-cache.js')
145
+ );
146
+ const key = validatorCacheKey([
147
+ ENTRY_KIND,
148
+ ...parserKey(),
149
+ (0, import_node_crypto.createHash)("sha256").update(source, "utf8").digest("hex")
150
+ ]);
151
+ const hit = cache.readData(key);
152
+ if (isStoredDocument(hit)) {
153
+ try {
154
+ return restore(hit);
155
+ } catch {
156
+ }
157
+ }
158
+ const doc = (0, import_yaml.parseDocument)(source);
159
+ if (doc.errors.length > 0 || doc.warnings.length > 0) return (0, import_yaml.parse)(source);
160
+ const document = doc.toJS();
161
+ const stored = storable(document);
162
+ if (stored) cache.writeData(key, stored);
163
+ return document;
164
+ }
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
167
+ parseStoryboardYaml
168
+ });
@@ -0,0 +1,139 @@
1
+ import { fileURLToPath as __adcpFileURLToPath } from "node:url";
2
+ import { dirname as __adcpDirname } from "node:path";
3
+ import { createRequire as __adcpCreateRequire } from "node:module";
4
+ const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
5
+ const require2 = __adcpCreateRequire(import.meta.url);
6
+ import { createHash } from "node:crypto";
7
+ import { createRequire } from "node:module";
8
+ import path from "node:path";
9
+ import { isDeepStrictEqual } from "node:util";
10
+ import { parse, parseDocument } from "yaml";
11
+ import { LIBRARY_VERSION } from "../../version.mjs";
12
+ const ENTRY_KIND = "storyboard-yaml";
13
+ function cacheDir() {
14
+ const dir = process.env.ADCP_VALIDATOR_CACHE_DIR;
15
+ return dir && path.isAbsolute(dir) ? dir : void 0;
16
+ }
17
+ let opened;
18
+ let staticKey;
19
+ function openCache(dir) {
20
+ if (opened?.dir !== dir) {
21
+ const { openValidatorCache } = (
22
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
23
+ require2("../../validation/validator-cache")
24
+ );
25
+ opened = { dir, cache: openValidatorCache(dir, path.join(__dirname, "yaml-cache.js")) };
26
+ }
27
+ return opened.cache;
28
+ }
29
+ function parserKey() {
30
+ if (staticKey) return staticKey;
31
+ const { filesDigest } = (
32
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
33
+ require2("../../validation/validator-cache")
34
+ );
35
+ let yamlVersion = null;
36
+ try {
37
+ const moduleRequire = createRequire(path.join(__dirname, "yaml-cache.js"));
38
+ yamlVersion = moduleRequire("yaml/package.json").version ?? null;
39
+ } catch {
40
+ }
41
+ staticKey = [
42
+ LIBRARY_VERSION,
43
+ filesDigest(["yaml-cache.js", "yaml-cache.mjs"].map((file) => path.join(__dirname, file))),
44
+ yamlVersion
45
+ ];
46
+ return staticKey;
47
+ }
48
+ function sharedObjects(root) {
49
+ const firstPath = /* @__PURE__ */ new Map();
50
+ const shared = [];
51
+ const visit = (value, at) => {
52
+ if (value === null || typeof value !== "object") return;
53
+ const first = firstPath.get(value);
54
+ if (first) {
55
+ shared.push([at, first]);
56
+ return;
57
+ }
58
+ firstPath.set(value, at);
59
+ if (Array.isArray(value)) value.forEach((item, index) => visit(item, [...at, index]));
60
+ else for (const [key, item] of Object.entries(value)) visit(item, [...at, key]);
61
+ };
62
+ visit(root, []);
63
+ return shared;
64
+ }
65
+ function withoutRepeats(root, shared) {
66
+ if (shared.length === 0) return root;
67
+ const repeats = new Set(shared.map(([at]) => JSON.stringify(at)));
68
+ const copy = (value, at) => {
69
+ if (repeats.has(JSON.stringify(at))) return null;
70
+ if (value === null || typeof value !== "object") return value;
71
+ if (Array.isArray(value)) return value.map((item, index) => copy(item, [...at, index]));
72
+ const out = {};
73
+ for (const [key, item] of Object.entries(value)) out[key] = copy(item, [...at, key]);
74
+ return out;
75
+ };
76
+ return copy(root, []);
77
+ }
78
+ function valueAt(root, at) {
79
+ let value = root;
80
+ for (const segment of at) value = value[segment];
81
+ return value;
82
+ }
83
+ function restore(stored) {
84
+ const value = stored.value;
85
+ for (const [at, first] of stored.shared) {
86
+ const parent = valueAt(value, at.slice(0, -1));
87
+ parent[at[at.length - 1]] = valueAt(value, first);
88
+ }
89
+ return value;
90
+ }
91
+ function isStoredDocument(value) {
92
+ return value !== null && typeof value === "object" && Object.hasOwn(value, "value") && Array.isArray(value.shared);
93
+ }
94
+ function storable(document) {
95
+ const shared = sharedObjects(document);
96
+ let json;
97
+ try {
98
+ json = JSON.stringify({ value: withoutRepeats(document, shared), shared });
99
+ } catch {
100
+ return void 0;
101
+ }
102
+ if (json === void 0) return void 0;
103
+ const stored = JSON.parse(json);
104
+ const restored = restore(JSON.parse(json));
105
+ if (!isDeepStrictEqual(restored, document)) return void 0;
106
+ if (!isDeepStrictEqual(sharedObjects(restored), shared)) return void 0;
107
+ return stored;
108
+ }
109
+ function parseStoryboardYaml(source) {
110
+ const dir = cacheDir();
111
+ if (dir === void 0) return parse(source);
112
+ const cache = openCache(dir);
113
+ if (!cache) return parse(source);
114
+ const { validatorCacheKey } = (
115
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
116
+ require2("../../validation/validator-cache")
117
+ );
118
+ const key = validatorCacheKey([
119
+ ENTRY_KIND,
120
+ ...parserKey(),
121
+ createHash("sha256").update(source, "utf8").digest("hex")
122
+ ]);
123
+ const hit = cache.readData(key);
124
+ if (isStoredDocument(hit)) {
125
+ try {
126
+ return restore(hit);
127
+ } catch {
128
+ }
129
+ }
130
+ const doc = parseDocument(source);
131
+ if (doc.errors.length > 0 || doc.warnings.length > 0) return parse(source);
132
+ const document = doc.toJS();
133
+ const stored = storable(document);
134
+ if (stored) cache.writeData(key, stored);
135
+ return document;
136
+ }
137
+ export {
138
+ parseStoryboardYaml
139
+ };
@@ -24,56 +24,86 @@ module.exports = __toCommonJS(schema_diagnostic_origins_exports);
24
24
  function object(value) {
25
25
  return value !== null && typeof value === "object";
26
26
  }
27
+ function isWhitespace(code) {
28
+ return code === 32 || code >= 9 && code <= 13 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
29
+ }
30
+ function isIdentifierStart(code) {
31
+ return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code === 95 || code === 36;
32
+ }
33
+ function isIdentifierPart(code) {
34
+ return isIdentifierStart(code) || code >= 48 && code <= 57;
35
+ }
27
36
  function schemaPathLiterals(source) {
28
37
  const paths = [];
38
+ const length = source.length;
29
39
  const stringEnd = (start) => {
30
- const quote = source[start];
31
- for (let index = start + 1; index < source.length; index++) {
32
- if (source[index] === "\\") index++;
33
- else if (source[index] === quote) return index + 1;
40
+ const quote = source.charCodeAt(start);
41
+ for (let index = start + 1; index < length; index++) {
42
+ const code = source.charCodeAt(index);
43
+ if (code === 92) index++;
44
+ else if (code === quote) return index + 1;
34
45
  }
35
46
  return -1;
36
47
  };
37
- for (let index = 0; index < source.length; ) {
48
+ const followsReplaceCall = (end) => {
49
+ let cursor = end - 1;
50
+ while (cursor >= 0 && isWhitespace(source.charCodeAt(cursor))) cursor--;
51
+ return cursor >= 8 && source.startsWith(".replace(", cursor - 8);
52
+ };
53
+ const followsDataVariable = (end) => {
54
+ let cursor = end - 1;
55
+ while (cursor >= 0 && isWhitespace(source.charCodeAt(cursor))) cursor--;
56
+ while (cursor >= 0 && source.charCodeAt(cursor) >= 48 && source.charCodeAt(cursor) <= 57) cursor--;
57
+ if (cursor < 3 || !source.startsWith("data", cursor - 3)) return false;
58
+ return cursor === 3 || !isIdentifierPart(source.charCodeAt(cursor - 4));
59
+ };
60
+ for (let index = 0; index < length; ) {
38
61
  const start = index;
39
- let key;
40
- if (source[index] === '"' || source[index] === "'") {
62
+ const code = source.charCodeAt(index);
63
+ let isSchemaPathKey = false;
64
+ if (code === 34 || code === 39) {
41
65
  index = stringEnd(index);
42
66
  if (index < 0) return void 0;
43
- try {
44
- key = JSON.parse(source.slice(start, index));
45
- } catch {
67
+ if (code === 34) {
68
+ const literal = source.slice(start, index);
69
+ if (literal === '"schemaPath"') isSchemaPathKey = true;
70
+ else if (literal.includes("\\")) {
71
+ try {
72
+ isSchemaPathKey = JSON.parse(literal) === "schemaPath";
73
+ } catch {
74
+ }
75
+ }
46
76
  }
47
- } else if (/[A-Za-z_$]/.test(source[index])) {
48
- while (index < source.length && /[\w$]/.test(source[index])) index++;
49
- key = source.slice(start, index);
50
- } else if (source.startsWith("//", index)) {
77
+ } else if (isIdentifierStart(code)) {
78
+ index++;
79
+ while (index < length && isIdentifierPart(source.charCodeAt(index))) index++;
80
+ isSchemaPathKey = index - start === 10 && source.startsWith("schemaPath", start);
81
+ } else if (code === 47 && source.charCodeAt(index + 1) === 47) {
51
82
  index = source.indexOf("\n", index + 2);
52
83
  if (index < 0) break;
53
- } else if (source.startsWith("/*", index)) {
84
+ } else if (code === 47 && source.charCodeAt(index + 1) === 42) {
54
85
  index = source.indexOf("*/", index + 2);
55
86
  if (index < 0) return void 0;
56
87
  index += 2;
57
88
  } else {
58
- if (source[index] === "`") return void 0;
59
- if (source[index] === "/") {
89
+ if (code === 96) return void 0;
90
+ if (code === 47) {
60
91
  const pointerEscape = source.startsWith("/~/g", index) ? "/~/g" : source.startsWith("/\\//g", index) ? "/\\//g" : void 0;
61
- if (pointerEscape && /\.replace\(\s*$/.test(source.slice(0, index))) {
92
+ if (pointerEscape && followsReplaceCall(index)) {
62
93
  index += pointerEscape.length;
63
94
  continue;
64
95
  }
65
- const previous = source.slice(0, index).match(/(?:^|[^\w$])(data\d*)\s*$/);
66
- if (!previous) return void 0;
96
+ if (!followsDataVariable(index)) return void 0;
67
97
  }
68
98
  index++;
69
99
  }
70
- if (key !== "schemaPath") continue;
100
+ if (!isSchemaPathKey) continue;
71
101
  let valueStart = index;
72
- while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
73
- if (source[valueStart] !== ":") continue;
102
+ while (valueStart < length && isWhitespace(source.charCodeAt(valueStart))) valueStart++;
103
+ if (source.charCodeAt(valueStart) !== 58) continue;
74
104
  valueStart++;
75
- while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
76
- if (source[valueStart] !== '"') return void 0;
105
+ while (valueStart < length && isWhitespace(source.charCodeAt(valueStart))) valueStart++;
106
+ if (source.charCodeAt(valueStart) !== 34) return void 0;
77
107
  const end = stringEnd(valueStart);
78
108
  if (end < 0) return void 0;
79
109
  let value;
@@ -1,56 +1,86 @@
1
1
  function object(value) {
2
2
  return value !== null && typeof value === "object";
3
3
  }
4
+ function isWhitespace(code) {
5
+ return code === 32 || code >= 9 && code <= 13 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
6
+ }
7
+ function isIdentifierStart(code) {
8
+ return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code === 95 || code === 36;
9
+ }
10
+ function isIdentifierPart(code) {
11
+ return isIdentifierStart(code) || code >= 48 && code <= 57;
12
+ }
4
13
  function schemaPathLiterals(source) {
5
14
  const paths = [];
15
+ const length = source.length;
6
16
  const stringEnd = (start) => {
7
- const quote = source[start];
8
- for (let index = start + 1; index < source.length; index++) {
9
- if (source[index] === "\\") index++;
10
- else if (source[index] === quote) return index + 1;
17
+ const quote = source.charCodeAt(start);
18
+ for (let index = start + 1; index < length; index++) {
19
+ const code = source.charCodeAt(index);
20
+ if (code === 92) index++;
21
+ else if (code === quote) return index + 1;
11
22
  }
12
23
  return -1;
13
24
  };
14
- for (let index = 0; index < source.length; ) {
25
+ const followsReplaceCall = (end) => {
26
+ let cursor = end - 1;
27
+ while (cursor >= 0 && isWhitespace(source.charCodeAt(cursor))) cursor--;
28
+ return cursor >= 8 && source.startsWith(".replace(", cursor - 8);
29
+ };
30
+ const followsDataVariable = (end) => {
31
+ let cursor = end - 1;
32
+ while (cursor >= 0 && isWhitespace(source.charCodeAt(cursor))) cursor--;
33
+ while (cursor >= 0 && source.charCodeAt(cursor) >= 48 && source.charCodeAt(cursor) <= 57) cursor--;
34
+ if (cursor < 3 || !source.startsWith("data", cursor - 3)) return false;
35
+ return cursor === 3 || !isIdentifierPart(source.charCodeAt(cursor - 4));
36
+ };
37
+ for (let index = 0; index < length; ) {
15
38
  const start = index;
16
- let key;
17
- if (source[index] === '"' || source[index] === "'") {
39
+ const code = source.charCodeAt(index);
40
+ let isSchemaPathKey = false;
41
+ if (code === 34 || code === 39) {
18
42
  index = stringEnd(index);
19
43
  if (index < 0) return void 0;
20
- try {
21
- key = JSON.parse(source.slice(start, index));
22
- } catch {
44
+ if (code === 34) {
45
+ const literal = source.slice(start, index);
46
+ if (literal === '"schemaPath"') isSchemaPathKey = true;
47
+ else if (literal.includes("\\")) {
48
+ try {
49
+ isSchemaPathKey = JSON.parse(literal) === "schemaPath";
50
+ } catch {
51
+ }
52
+ }
23
53
  }
24
- } else if (/[A-Za-z_$]/.test(source[index])) {
25
- while (index < source.length && /[\w$]/.test(source[index])) index++;
26
- key = source.slice(start, index);
27
- } else if (source.startsWith("//", index)) {
54
+ } else if (isIdentifierStart(code)) {
55
+ index++;
56
+ while (index < length && isIdentifierPart(source.charCodeAt(index))) index++;
57
+ isSchemaPathKey = index - start === 10 && source.startsWith("schemaPath", start);
58
+ } else if (code === 47 && source.charCodeAt(index + 1) === 47) {
28
59
  index = source.indexOf("\n", index + 2);
29
60
  if (index < 0) break;
30
- } else if (source.startsWith("/*", index)) {
61
+ } else if (code === 47 && source.charCodeAt(index + 1) === 42) {
31
62
  index = source.indexOf("*/", index + 2);
32
63
  if (index < 0) return void 0;
33
64
  index += 2;
34
65
  } else {
35
- if (source[index] === "`") return void 0;
36
- if (source[index] === "/") {
66
+ if (code === 96) return void 0;
67
+ if (code === 47) {
37
68
  const pointerEscape = source.startsWith("/~/g", index) ? "/~/g" : source.startsWith("/\\//g", index) ? "/\\//g" : void 0;
38
- if (pointerEscape && /\.replace\(\s*$/.test(source.slice(0, index))) {
69
+ if (pointerEscape && followsReplaceCall(index)) {
39
70
  index += pointerEscape.length;
40
71
  continue;
41
72
  }
42
- const previous = source.slice(0, index).match(/(?:^|[^\w$])(data\d*)\s*$/);
43
- if (!previous) return void 0;
73
+ if (!followsDataVariable(index)) return void 0;
44
74
  }
45
75
  index++;
46
76
  }
47
- if (key !== "schemaPath") continue;
77
+ if (!isSchemaPathKey) continue;
48
78
  let valueStart = index;
49
- while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
50
- if (source[valueStart] !== ":") continue;
79
+ while (valueStart < length && isWhitespace(source.charCodeAt(valueStart))) valueStart++;
80
+ if (source.charCodeAt(valueStart) !== 58) continue;
51
81
  valueStart++;
52
- while (/\s/.test(source[valueStart] ?? "") && valueStart < source.length) valueStart++;
53
- if (source[valueStart] !== '"') return void 0;
82
+ while (valueStart < length && isWhitespace(source.charCodeAt(valueStart))) valueStart++;
83
+ if (source.charCodeAt(valueStart) !== 34) return void 0;
54
84
  const end = stringEnd(valueStart);
55
85
  if (end < 0) return void 0;
56
86
  let value;