@synapse-research/synapse 0.2.0 → 0.2.1
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.
- package/bin/synapse.mjs +4 -0
- package/dist/.next/BUILD_ID +1 -1
- package/dist/.next/app-build-manifest.json +162 -162
- package/dist/.next/app-path-routes-manifest.json +39 -39
- package/dist/.next/build-manifest.json +2 -2
- package/dist/.next/prerender-manifest.json +12 -12
- package/dist/.next/server/app/(dashboard)/agents/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/compute/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/project-groups/[uuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/activity/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/dashboard/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/documents/[documentUuid]/page.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/documents/[documentUuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/documents/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-designs/[designUuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-designs/new/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-designs/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-runs/[runUuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiment-runs/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiments/new/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiments/page.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/experiments/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/insights/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/related-works/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/research-questions/[questionUuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/research-questions/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/[uuid]/settings/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/new/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/research-projects/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/_not-found.html +1 -1
- package/dist/.next/server/app/_not-found.rsc +1 -1
- package/dist/.next/server/app/admin/companies/[uuid]/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/admin/companies/new/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/admin/companies/new.html +1 -1
- package/dist/.next/server/app/admin/companies/new.rsc +1 -1
- package/dist/.next/server/app/admin/companies/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/admin/companies.html +1 -1
- package/dist/.next/server/app/admin/companies.rsc +1 -1
- package/dist/.next/server/app/admin/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/admin.html +1 -1
- package/dist/.next/server/app/admin.rsc +1 -1
- package/dist/.next/server/app/api/admin/companies/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/admin/companies/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/admin/login/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/admin/session/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/admin/stats/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/agents/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/agents/[uuid]/sessions/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/api-keys/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/api-keys/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/callback/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/check-default/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/default-login/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/identify/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/me/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/refresh/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/session/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/auth/sync-token/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/comments/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-nodes/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-nodes/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-pools/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/compute-pools/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/documents/[uuid]/route.js +1 -1
- package/dist/.next/server/app/api/documents/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/events/notifications/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/events/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-designs/[uuid]/approve/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-designs/[uuid]/close/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-designs/[uuid]/reject/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-designs/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/claim/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/dependencies/[dependsOnRunUuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/dependencies/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/evaluate-criteria/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/registry/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/release/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiment-runs/[uuid]/sessions/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/complete/route.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/complete/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/progress/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/request-plan/route.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/request-plan/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/reset/route.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/reset/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/review/route.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/review/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/route.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/start/route.js +1 -1
- package/dist/.next/server/app/api/experiments/[uuid]/start/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/mcp/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/me/assignments/route.js +1 -1
- package/dist/.next/server/app/api/me/assignments/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/mentionables/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/[uuid]/archive/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/[uuid]/read/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/preferences/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/read-all/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/notifications/unread-count/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/onboarding/status/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/project-groups/[uuid]/dashboard/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/project-groups/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/project-groups/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/activity/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/agent-activity/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/available/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/baselines/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/documents/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-designs/[designUuid]/validate/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-designs/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-designs/summary/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-runs/dependencies/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiment-runs/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/experiments/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/github/branches/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/group/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/[workUuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/auto-search/complete/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/auto-search/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/deep-research/complete/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/deep-research/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/related-works/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/research-questions/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-projects/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/claim/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/move/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/release/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/research-questions/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/sessions/[uuid]/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/settings/integrations/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/api/ssh-config/route_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/index.html +1 -1
- package/dist/.next/server/app/index.rsc +1 -1
- package/dist/.next/server/app/login/admin/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/login/admin.html +1 -1
- package/dist/.next/server/app/login/admin.rsc +1 -1
- package/dist/.next/server/app/login/callback/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/login/callback.html +1 -1
- package/dist/.next/server/app/login/callback.rsc +1 -1
- package/dist/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/login/silent-refresh/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/login/silent-refresh.html +1 -1
- package/dist/.next/server/app/login/silent-refresh.rsc +1 -1
- package/dist/.next/server/app/login.html +1 -1
- package/dist/.next/server/app/login.rsc +1 -1
- package/dist/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/app/research-projects/new.html +1 -1
- package/dist/.next/server/app/research-projects/new.rsc +1 -1
- package/dist/.next/server/app/research-projects.html +1 -1
- package/dist/.next/server/app/research-projects.rsc +1 -1
- package/dist/.next/server/app/settings.html +1 -1
- package/dist/.next/server/app/settings.rsc +1 -1
- package/dist/.next/server/app-paths-manifest.json +39 -39
- package/dist/.next/server/chunks/4742.js +1 -1
- package/dist/.next/server/chunks/759.js +1 -1
- package/dist/.next/server/chunks/8283.js +1 -1
- package/dist/.next/server/middleware-manifest.json +1 -1
- package/dist/.next/server/pages/404.html +1 -1
- package/dist/.next/server/pages/500.html +1 -1
- package/dist/.next/server/pages-manifest.json +1 -1
- package/dist/.next/static/chunks/app/(dashboard)/research-projects/[uuid]/experiments/page-926fd1080d8bd114.js +1 -0
- package/dist/node_modules/buffer-from/index.js +72 -0
- package/dist/node_modules/buffer-from/package.json +19 -0
- package/dist/node_modules/source-map/lib/array-set.js +121 -0
- package/dist/node_modules/source-map/lib/base64-vlq.js +140 -0
- package/dist/node_modules/source-map/lib/base64.js +67 -0
- package/dist/node_modules/source-map/lib/binary-search.js +111 -0
- package/dist/node_modules/source-map/lib/mapping-list.js +79 -0
- package/dist/node_modules/source-map/lib/quick-sort.js +114 -0
- package/dist/node_modules/source-map/lib/source-map-consumer.js +1145 -0
- package/dist/node_modules/source-map/lib/source-map-generator.js +425 -0
- package/dist/node_modules/source-map/lib/source-node.js +413 -0
- package/dist/node_modules/source-map/lib/util.js +488 -0
- package/dist/node_modules/source-map/package.json +73 -0
- package/dist/node_modules/source-map/source-map.js +8 -0
- package/dist/node_modules/source-map-support/package.json +31 -0
- package/dist/node_modules/source-map-support/source-map-support.js +625 -0
- package/package.json +1 -1
- package/dist/.env +0 -31
- package/dist/.next/static/chunks/app/(dashboard)/research-projects/[uuid]/experiments/page-1e98ec51265e6bd6.js +0 -1
- /package/dist/.next/static/{ERYuqKh2yJ2lApkenIQge → _Xj9BQgDF0XFubwsfL_6V}/_buildManifest.js +0 -0
- /package/dist/.next/static/{ERYuqKh2yJ2lApkenIQge → _Xj9BQgDF0XFubwsfL_6V}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
|
4
|
+
* Licensed under the New BSD license. See LICENSE or:
|
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
exports.GREATEST_LOWER_BOUND = 1;
|
|
9
|
+
exports.LEAST_UPPER_BOUND = 2;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Recursive implementation of binary search.
|
|
13
|
+
*
|
|
14
|
+
* @param aLow Indices here and lower do not contain the needle.
|
|
15
|
+
* @param aHigh Indices here and higher do not contain the needle.
|
|
16
|
+
* @param aNeedle The element being searched for.
|
|
17
|
+
* @param aHaystack The non-empty array being searched.
|
|
18
|
+
* @param aCompare Function which takes two elements and returns -1, 0, or 1.
|
|
19
|
+
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
|
20
|
+
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
|
21
|
+
* closest element that is smaller than or greater than the one we are
|
|
22
|
+
* searching for, respectively, if the exact element cannot be found.
|
|
23
|
+
*/
|
|
24
|
+
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
|
|
25
|
+
// This function terminates when one of the following is true:
|
|
26
|
+
//
|
|
27
|
+
// 1. We find the exact element we are looking for.
|
|
28
|
+
//
|
|
29
|
+
// 2. We did not find the exact element, but we can return the index of
|
|
30
|
+
// the next-closest element.
|
|
31
|
+
//
|
|
32
|
+
// 3. We did not find the exact element, and there is no next-closest
|
|
33
|
+
// element than the one we are searching for, so we return -1.
|
|
34
|
+
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
|
|
35
|
+
var cmp = aCompare(aNeedle, aHaystack[mid], true);
|
|
36
|
+
if (cmp === 0) {
|
|
37
|
+
// Found the element we are looking for.
|
|
38
|
+
return mid;
|
|
39
|
+
}
|
|
40
|
+
else if (cmp > 0) {
|
|
41
|
+
// Our needle is greater than aHaystack[mid].
|
|
42
|
+
if (aHigh - mid > 1) {
|
|
43
|
+
// The element is in the upper half.
|
|
44
|
+
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The exact needle element was not found in this haystack. Determine if
|
|
48
|
+
// we are in termination case (3) or (2) and return the appropriate thing.
|
|
49
|
+
if (aBias == exports.LEAST_UPPER_BOUND) {
|
|
50
|
+
return aHigh < aHaystack.length ? aHigh : -1;
|
|
51
|
+
} else {
|
|
52
|
+
return mid;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Our needle is less than aHaystack[mid].
|
|
57
|
+
if (mid - aLow > 1) {
|
|
58
|
+
// The element is in the lower half.
|
|
59
|
+
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// we are in termination case (3) or (2) and return the appropriate thing.
|
|
63
|
+
if (aBias == exports.LEAST_UPPER_BOUND) {
|
|
64
|
+
return mid;
|
|
65
|
+
} else {
|
|
66
|
+
return aLow < 0 ? -1 : aLow;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* This is an implementation of binary search which will always try and return
|
|
73
|
+
* the index of the closest element if there is no exact hit. This is because
|
|
74
|
+
* mappings between original and generated line/col pairs are single points,
|
|
75
|
+
* and there is an implicit region between each of them, so a miss just means
|
|
76
|
+
* that you aren't on the very start of a region.
|
|
77
|
+
*
|
|
78
|
+
* @param aNeedle The element you are looking for.
|
|
79
|
+
* @param aHaystack The array that is being searched.
|
|
80
|
+
* @param aCompare A function which takes the needle and an element in the
|
|
81
|
+
* array and returns -1, 0, or 1 depending on whether the needle is less
|
|
82
|
+
* than, equal to, or greater than the element, respectively.
|
|
83
|
+
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
|
|
84
|
+
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
|
|
85
|
+
* closest element that is smaller than or greater than the one we are
|
|
86
|
+
* searching for, respectively, if the exact element cannot be found.
|
|
87
|
+
* Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
|
|
88
|
+
*/
|
|
89
|
+
exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
|
90
|
+
if (aHaystack.length === 0) {
|
|
91
|
+
return -1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
|
|
95
|
+
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
|
|
96
|
+
if (index < 0) {
|
|
97
|
+
return -1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// We have found either the exact element, or the next-closest element than
|
|
101
|
+
// the one we are searching for. However, there may be more than one such
|
|
102
|
+
// element. Make sure we always return the smallest of these.
|
|
103
|
+
while (index - 1 >= 0) {
|
|
104
|
+
if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
--index;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return index;
|
|
111
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2014 Mozilla Foundation and contributors
|
|
4
|
+
* Licensed under the New BSD license. See LICENSE or:
|
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var util = require('./util');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Determine whether mappingB is after mappingA with respect to generated
|
|
12
|
+
* position.
|
|
13
|
+
*/
|
|
14
|
+
function generatedPositionAfter(mappingA, mappingB) {
|
|
15
|
+
// Optimized for most common case
|
|
16
|
+
var lineA = mappingA.generatedLine;
|
|
17
|
+
var lineB = mappingB.generatedLine;
|
|
18
|
+
var columnA = mappingA.generatedColumn;
|
|
19
|
+
var columnB = mappingB.generatedColumn;
|
|
20
|
+
return lineB > lineA || lineB == lineA && columnB >= columnA ||
|
|
21
|
+
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A data structure to provide a sorted view of accumulated mappings in a
|
|
26
|
+
* performance conscious manner. It trades a neglibable overhead in general
|
|
27
|
+
* case for a large speedup in case of mappings being added in order.
|
|
28
|
+
*/
|
|
29
|
+
function MappingList() {
|
|
30
|
+
this._array = [];
|
|
31
|
+
this._sorted = true;
|
|
32
|
+
// Serves as infimum
|
|
33
|
+
this._last = {generatedLine: -1, generatedColumn: 0};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Iterate through internal items. This method takes the same arguments that
|
|
38
|
+
* `Array.prototype.forEach` takes.
|
|
39
|
+
*
|
|
40
|
+
* NOTE: The order of the mappings is NOT guaranteed.
|
|
41
|
+
*/
|
|
42
|
+
MappingList.prototype.unsortedForEach =
|
|
43
|
+
function MappingList_forEach(aCallback, aThisArg) {
|
|
44
|
+
this._array.forEach(aCallback, aThisArg);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Add the given source mapping.
|
|
49
|
+
*
|
|
50
|
+
* @param Object aMapping
|
|
51
|
+
*/
|
|
52
|
+
MappingList.prototype.add = function MappingList_add(aMapping) {
|
|
53
|
+
if (generatedPositionAfter(this._last, aMapping)) {
|
|
54
|
+
this._last = aMapping;
|
|
55
|
+
this._array.push(aMapping);
|
|
56
|
+
} else {
|
|
57
|
+
this._sorted = false;
|
|
58
|
+
this._array.push(aMapping);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns the flat, sorted array of mappings. The mappings are sorted by
|
|
64
|
+
* generated position.
|
|
65
|
+
*
|
|
66
|
+
* WARNING: This method returns internal data without copying, for
|
|
67
|
+
* performance. The return value must NOT be mutated, and should be treated as
|
|
68
|
+
* an immutable borrow. If you want to take ownership, you must make your own
|
|
69
|
+
* copy.
|
|
70
|
+
*/
|
|
71
|
+
MappingList.prototype.toArray = function MappingList_toArray() {
|
|
72
|
+
if (!this._sorted) {
|
|
73
|
+
this._array.sort(util.compareByGeneratedPositionsInflated);
|
|
74
|
+
this._sorted = true;
|
|
75
|
+
}
|
|
76
|
+
return this._array;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
exports.MappingList = MappingList;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
|
4
|
+
* Licensed under the New BSD license. See LICENSE or:
|
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// It turns out that some (most?) JavaScript engines don't self-host
|
|
9
|
+
// `Array.prototype.sort`. This makes sense because C++ will likely remain
|
|
10
|
+
// faster than JS when doing raw CPU-intensive sorting. However, when using a
|
|
11
|
+
// custom comparator function, calling back and forth between the VM's C++ and
|
|
12
|
+
// JIT'd JS is rather slow *and* loses JIT type information, resulting in
|
|
13
|
+
// worse generated code for the comparator function than would be optimal. In
|
|
14
|
+
// fact, when sorting with a comparator, these costs outweigh the benefits of
|
|
15
|
+
// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
|
|
16
|
+
// a ~3500ms mean speed-up in `bench/bench.html`.
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Swap the elements indexed by `x` and `y` in the array `ary`.
|
|
20
|
+
*
|
|
21
|
+
* @param {Array} ary
|
|
22
|
+
* The array.
|
|
23
|
+
* @param {Number} x
|
|
24
|
+
* The index of the first item.
|
|
25
|
+
* @param {Number} y
|
|
26
|
+
* The index of the second item.
|
|
27
|
+
*/
|
|
28
|
+
function swap(ary, x, y) {
|
|
29
|
+
var temp = ary[x];
|
|
30
|
+
ary[x] = ary[y];
|
|
31
|
+
ary[y] = temp;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Returns a random integer within the range `low .. high` inclusive.
|
|
36
|
+
*
|
|
37
|
+
* @param {Number} low
|
|
38
|
+
* The lower bound on the range.
|
|
39
|
+
* @param {Number} high
|
|
40
|
+
* The upper bound on the range.
|
|
41
|
+
*/
|
|
42
|
+
function randomIntInRange(low, high) {
|
|
43
|
+
return Math.round(low + (Math.random() * (high - low)));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The Quick Sort algorithm.
|
|
48
|
+
*
|
|
49
|
+
* @param {Array} ary
|
|
50
|
+
* An array to sort.
|
|
51
|
+
* @param {function} comparator
|
|
52
|
+
* Function to use to compare two items.
|
|
53
|
+
* @param {Number} p
|
|
54
|
+
* Start index of the array
|
|
55
|
+
* @param {Number} r
|
|
56
|
+
* End index of the array
|
|
57
|
+
*/
|
|
58
|
+
function doQuickSort(ary, comparator, p, r) {
|
|
59
|
+
// If our lower bound is less than our upper bound, we (1) partition the
|
|
60
|
+
// array into two pieces and (2) recurse on each half. If it is not, this is
|
|
61
|
+
// the empty array and our base case.
|
|
62
|
+
|
|
63
|
+
if (p < r) {
|
|
64
|
+
// (1) Partitioning.
|
|
65
|
+
//
|
|
66
|
+
// The partitioning chooses a pivot between `p` and `r` and moves all
|
|
67
|
+
// elements that are less than or equal to the pivot to the before it, and
|
|
68
|
+
// all the elements that are greater than it after it. The effect is that
|
|
69
|
+
// once partition is done, the pivot is in the exact place it will be when
|
|
70
|
+
// the array is put in sorted order, and it will not need to be moved
|
|
71
|
+
// again. This runs in O(n) time.
|
|
72
|
+
|
|
73
|
+
// Always choose a random pivot so that an input array which is reverse
|
|
74
|
+
// sorted does not cause O(n^2) running time.
|
|
75
|
+
var pivotIndex = randomIntInRange(p, r);
|
|
76
|
+
var i = p - 1;
|
|
77
|
+
|
|
78
|
+
swap(ary, pivotIndex, r);
|
|
79
|
+
var pivot = ary[r];
|
|
80
|
+
|
|
81
|
+
// Immediately after `j` is incremented in this loop, the following hold
|
|
82
|
+
// true:
|
|
83
|
+
//
|
|
84
|
+
// * Every element in `ary[p .. i]` is less than or equal to the pivot.
|
|
85
|
+
//
|
|
86
|
+
// * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
|
|
87
|
+
for (var j = p; j < r; j++) {
|
|
88
|
+
if (comparator(ary[j], pivot) <= 0) {
|
|
89
|
+
i += 1;
|
|
90
|
+
swap(ary, i, j);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
swap(ary, i + 1, j);
|
|
95
|
+
var q = i + 1;
|
|
96
|
+
|
|
97
|
+
// (2) Recurse on each half.
|
|
98
|
+
|
|
99
|
+
doQuickSort(ary, comparator, p, q - 1);
|
|
100
|
+
doQuickSort(ary, comparator, q + 1, r);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Sort the given array in-place with the given comparator function.
|
|
106
|
+
*
|
|
107
|
+
* @param {Array} ary
|
|
108
|
+
* An array to sort.
|
|
109
|
+
* @param {function} comparator
|
|
110
|
+
* Function to use to compare two items.
|
|
111
|
+
*/
|
|
112
|
+
exports.quickSort = function (ary, comparator) {
|
|
113
|
+
doQuickSort(ary, comparator, 0, ary.length - 1);
|
|
114
|
+
};
|