@rebasepro/server-core 0.0.1-canary.eae7889 → 0.1.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.
Files changed (132) hide show
  1. package/app/frontend/node_modules/esbuild/LICENSE.md +21 -0
  2. package/app/frontend/node_modules/esbuild/README.md +3 -0
  3. package/app/frontend/node_modules/esbuild/bin/esbuild +220 -0
  4. package/app/frontend/node_modules/esbuild/install.js +285 -0
  5. package/app/frontend/node_modules/esbuild/lib/main.d.ts +705 -0
  6. package/app/frontend/node_modules/esbuild/lib/main.js +2239 -0
  7. package/app/frontend/node_modules/esbuild/package.json +46 -0
  8. package/dist/index.es.js +1186 -1673
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/index.umd.js +1185 -1672
  11. package/dist/index.umd.js.map +1 -1
  12. package/dist/server-core/src/api/rest/api-generator.d.ts +15 -3
  13. package/dist/server-core/src/auth/admin-routes.d.ts +5 -0
  14. package/dist/server-core/src/auth/google-oauth.d.ts +36 -3
  15. package/dist/server-core/src/auth/index.d.ts +1 -0
  16. package/dist/server-core/src/cron/cron-scheduler.d.ts +45 -0
  17. package/dist/server-core/src/cron/index.d.ts +1 -1
  18. package/dist/server-core/src/init.d.ts +11 -1
  19. package/dist/types/src/controllers/auth.d.ts +8 -2
  20. package/dist/types/src/controllers/client.d.ts +13 -0
  21. package/dist/types/src/controllers/collection_registry.d.ts +2 -1
  22. package/dist/types/src/controllers/data_driver.d.ts +36 -1
  23. package/dist/types/src/controllers/navigation.d.ts +18 -6
  24. package/dist/types/src/controllers/registry.d.ts +9 -1
  25. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
  26. package/dist/types/src/rebase_context.d.ts +17 -0
  27. package/dist/types/src/types/backend_hooks.d.ts +187 -0
  28. package/dist/types/src/types/collections.d.ts +31 -11
  29. package/dist/types/src/types/component_ref.d.ts +47 -0
  30. package/dist/types/src/types/cron.d.ts +1 -1
  31. package/dist/types/src/types/entity_views.d.ts +6 -7
  32. package/dist/types/src/types/formex.d.ts +40 -0
  33. package/dist/types/src/types/index.d.ts +3 -0
  34. package/dist/types/src/types/plugins.d.ts +6 -3
  35. package/dist/types/src/types/properties.d.ts +72 -88
  36. package/dist/types/src/types/slots.d.ts +20 -10
  37. package/dist/types/src/types/translations.d.ts +6 -0
  38. package/examples/firebase/node_modules/esbuild/LICENSE.md +21 -0
  39. package/examples/firebase/node_modules/esbuild/README.md +3 -0
  40. package/examples/firebase/node_modules/esbuild/bin/esbuild +220 -0
  41. package/examples/firebase/node_modules/esbuild/install.js +285 -0
  42. package/examples/firebase/node_modules/esbuild/lib/main.d.ts +705 -0
  43. package/examples/firebase/node_modules/esbuild/lib/main.js +2239 -0
  44. package/examples/firebase/node_modules/esbuild/package.json +46 -0
  45. package/examples/medmot-staging/frontend/node_modules/esbuild/LICENSE.md +21 -0
  46. package/examples/medmot-staging/frontend/node_modules/esbuild/README.md +3 -0
  47. package/examples/medmot-staging/frontend/node_modules/esbuild/bin/esbuild +220 -0
  48. package/examples/medmot-staging/frontend/node_modules/esbuild/install.js +285 -0
  49. package/examples/medmot-staging/frontend/node_modules/esbuild/lib/main.d.ts +705 -0
  50. package/examples/medmot-staging/frontend/node_modules/esbuild/lib/main.js +2239 -0
  51. package/examples/medmot-staging/frontend/node_modules/esbuild/package.json +46 -0
  52. package/examples/sdk-demo/node_modules/esbuild/LICENSE.md +21 -0
  53. package/examples/sdk-demo/node_modules/esbuild/README.md +3 -0
  54. package/examples/sdk-demo/node_modules/esbuild/bin/esbuild +223 -0
  55. package/examples/sdk-demo/node_modules/esbuild/install.js +289 -0
  56. package/examples/sdk-demo/node_modules/esbuild/lib/main.d.ts +716 -0
  57. package/examples/sdk-demo/node_modules/esbuild/lib/main.js +2242 -0
  58. package/examples/sdk-demo/node_modules/esbuild/package.json +49 -0
  59. package/package.json +9 -9
  60. package/packages/client/node_modules/esbuild/LICENSE.md +21 -0
  61. package/packages/client/node_modules/esbuild/README.md +3 -0
  62. package/packages/client/node_modules/esbuild/bin/esbuild +220 -0
  63. package/packages/client/node_modules/esbuild/install.js +285 -0
  64. package/packages/client/node_modules/esbuild/lib/main.d.ts +705 -0
  65. package/packages/client/node_modules/esbuild/lib/main.js +2239 -0
  66. package/packages/client/node_modules/esbuild/package.json +46 -0
  67. package/packages/client-postgresql/node_modules/esbuild/LICENSE.md +21 -0
  68. package/packages/client-postgresql/node_modules/esbuild/README.md +3 -0
  69. package/packages/client-postgresql/node_modules/esbuild/bin/esbuild +220 -0
  70. package/packages/client-postgresql/node_modules/esbuild/install.js +285 -0
  71. package/packages/client-postgresql/node_modules/esbuild/lib/main.d.ts +705 -0
  72. package/packages/client-postgresql/node_modules/esbuild/lib/main.js +2239 -0
  73. package/packages/client-postgresql/node_modules/esbuild/package.json +46 -0
  74. package/packages/common/node_modules/esbuild/LICENSE.md +21 -0
  75. package/packages/common/node_modules/esbuild/README.md +3 -0
  76. package/packages/common/node_modules/esbuild/bin/esbuild +220 -0
  77. package/packages/common/node_modules/esbuild/install.js +285 -0
  78. package/packages/common/node_modules/esbuild/lib/main.d.ts +705 -0
  79. package/packages/common/node_modules/esbuild/lib/main.js +2239 -0
  80. package/packages/common/node_modules/esbuild/package.json +46 -0
  81. package/packages/server-mongodb/node_modules/esbuild/LICENSE.md +21 -0
  82. package/packages/server-mongodb/node_modules/esbuild/README.md +3 -0
  83. package/packages/server-mongodb/node_modules/esbuild/bin/esbuild +220 -0
  84. package/packages/server-mongodb/node_modules/esbuild/install.js +285 -0
  85. package/packages/server-mongodb/node_modules/esbuild/lib/main.d.ts +705 -0
  86. package/packages/server-mongodb/node_modules/esbuild/lib/main.js +2239 -0
  87. package/packages/server-mongodb/node_modules/esbuild/package.json +46 -0
  88. package/packages/server-postgresql/node_modules/esbuild/LICENSE.md +21 -0
  89. package/packages/server-postgresql/node_modules/esbuild/README.md +3 -0
  90. package/packages/server-postgresql/node_modules/esbuild/bin/esbuild +220 -0
  91. package/packages/server-postgresql/node_modules/esbuild/install.js +285 -0
  92. package/packages/server-postgresql/node_modules/esbuild/lib/main.d.ts +705 -0
  93. package/packages/server-postgresql/node_modules/esbuild/lib/main.js +2239 -0
  94. package/packages/server-postgresql/node_modules/esbuild/package.json +46 -0
  95. package/packages/types/node_modules/esbuild/LICENSE.md +21 -0
  96. package/packages/types/node_modules/esbuild/README.md +3 -0
  97. package/packages/types/node_modules/esbuild/bin/esbuild +220 -0
  98. package/packages/types/node_modules/esbuild/install.js +285 -0
  99. package/packages/types/node_modules/esbuild/lib/main.d.ts +705 -0
  100. package/packages/types/node_modules/esbuild/lib/main.js +2239 -0
  101. package/packages/types/node_modules/esbuild/package.json +46 -0
  102. package/packages/utils/node_modules/esbuild/LICENSE.md +21 -0
  103. package/packages/utils/node_modules/esbuild/README.md +3 -0
  104. package/packages/utils/node_modules/esbuild/bin/esbuild +220 -0
  105. package/packages/utils/node_modules/esbuild/install.js +285 -0
  106. package/packages/utils/node_modules/esbuild/lib/main.d.ts +705 -0
  107. package/packages/utils/node_modules/esbuild/lib/main.js +2239 -0
  108. package/packages/utils/node_modules/esbuild/package.json +46 -0
  109. package/src/api/errors.ts +3 -2
  110. package/src/api/rest/api-generator-count.test.ts +113 -0
  111. package/src/api/rest/api-generator.ts +123 -22
  112. package/src/api/server.ts +8 -4
  113. package/src/auth/admin-routes.ts +133 -57
  114. package/src/auth/apple-oauth.ts +8 -18
  115. package/src/auth/google-oauth.ts +192 -22
  116. package/src/auth/index.ts +1 -0
  117. package/src/auth/rate-limiter.ts +9 -5
  118. package/src/auth/routes.ts +25 -5
  119. package/src/collections/loader.ts +3 -3
  120. package/src/cron/cron-scheduler.test.ts +301 -175
  121. package/src/cron/cron-scheduler.ts +220 -57
  122. package/src/cron/index.ts +1 -1
  123. package/src/init.ts +27 -5
  124. package/src/storage/LocalStorageController.ts +37 -13
  125. package/src/storage/S3StorageController.ts +4 -1
  126. package/src/storage/routes.ts +51 -5
  127. package/test/backend-hooks-admin.test.ts +394 -0
  128. package/test/backend-hooks-data.test.ts +408 -0
  129. package/history_diff.log +0 -385
  130. package/scratch.ts +0 -9
  131. package/test-ast.ts +0 -28
  132. package/test_output.txt +0 -1133
@@ -100,7 +100,8 @@ export interface NavigationSlotProps {
100
100
  export interface CollectionToolbarProps {
101
101
  path: string;
102
102
  collection: EntityCollection;
103
- parentCollectionIds: string[];
103
+ parentCollectionSlugs: string[];
104
+ parentEntityIds: string[];
104
105
  tableController: EntityTableController;
105
106
  selectionController: SelectionController;
106
107
  }
@@ -111,7 +112,8 @@ export interface CollectionToolbarProps {
111
112
  export interface CollectionEmptyStateProps {
112
113
  path: string;
113
114
  collection: EntityCollection;
114
- parentCollectionIds: string[];
115
+ parentCollectionSlugs: string[];
116
+ parentEntityIds: string[];
115
117
  canCreate: boolean;
116
118
  onNewClick?: () => void;
117
119
  }
@@ -123,7 +125,8 @@ export interface CollectionHeaderActionProps {
123
125
  property: Property;
124
126
  propertyKey: string;
125
127
  path: string;
126
- parentCollectionIds: string[];
128
+ parentCollectionSlugs: string[];
129
+ parentEntityIds: string[];
127
130
  onHover: boolean;
128
131
  collection: EntityCollection;
129
132
  tableController: EntityTableController;
@@ -134,7 +137,8 @@ export interface CollectionHeaderActionProps {
134
137
  */
135
138
  export interface CollectionAddColumnProps {
136
139
  path: string;
137
- parentCollectionIds: string[];
140
+ parentCollectionSlugs: string[];
141
+ parentEntityIds: string[];
138
142
  collection: EntityCollection;
139
143
  tableController: EntityTableController;
140
144
  }
@@ -145,7 +149,8 @@ export interface CollectionAddColumnProps {
145
149
  export interface CollectionErrorProps {
146
150
  path: string;
147
151
  collection: EntityCollection;
148
- parentCollectionIds?: string[];
152
+ parentCollectionSlugs?: string[];
153
+ parentEntityIds?: string[];
149
154
  error: Error;
150
155
  }
151
156
  /**
@@ -155,7 +160,8 @@ export interface CollectionErrorProps {
155
160
  export interface KanbanSetupProps {
156
161
  collection: EntityCollection;
157
162
  fullPath: string;
158
- parentCollectionIds: string[];
163
+ parentCollectionSlugs: string[];
164
+ parentEntityIds: string[];
159
165
  }
160
166
  /**
161
167
  * Props for the `kanban.add-column` slot.
@@ -164,7 +170,8 @@ export interface KanbanSetupProps {
164
170
  export interface KanbanAddColumnProps {
165
171
  collection: EntityCollection;
166
172
  fullPath: string;
167
- parentCollectionIds: string[];
173
+ parentCollectionSlugs: string[];
174
+ parentEntityIds: string[];
168
175
  columnProperty: string;
169
176
  }
170
177
  /**
@@ -177,7 +184,8 @@ export interface EntityRowActionsProps {
177
184
  entityId: string;
178
185
  path: string;
179
186
  collection: EntityCollection;
180
- parentCollectionIds: string[];
187
+ parentCollectionSlugs: string[];
188
+ parentEntityIds: string[];
181
189
  selectionController: SelectionController;
182
190
  context: RebaseContext;
183
191
  }
@@ -202,7 +210,8 @@ export interface EntityFieldSlotProps {
202
210
  export interface CollectionFilterPanelProps {
203
211
  path: string;
204
212
  collection: EntityCollection;
205
- parentCollectionIds: string[];
213
+ parentCollectionSlugs: string[];
214
+ parentEntityIds: string[];
206
215
  tableController: EntityTableController;
207
216
  context: RebaseContext;
208
217
  }
@@ -238,7 +247,8 @@ export interface ShellToolbarProps {
238
247
  export interface CollectionInsightsSlotProps {
239
248
  path: string;
240
249
  collection: EntityCollection;
241
- parentCollectionIds: string[];
250
+ parentCollectionSlugs: string[];
251
+ parentEntityIds: string[];
242
252
  }
243
253
  /**
244
254
  * Props for `home.card.insight` slot.
@@ -51,6 +51,8 @@ export interface RebaseTranslations {
51
51
  all_entries_loaded: string;
52
52
  create_your_first_entry: string;
53
53
  no_results_filter_sort: string;
54
+ /** Shown when a text search yields no results. Supports `{{search}}` interpolation. */
55
+ no_results_search?: string;
54
56
  add: string;
55
57
  remove: string;
56
58
  copy_id: string;
@@ -461,6 +463,10 @@ export interface RebaseTranslations {
461
463
  reset_password_success?: string;
462
464
  reset_password_confirmation?: string;
463
465
  error_resetting_password?: string;
466
+ /** Permission-denied empty states */
467
+ no_permission_to_view_users?: string;
468
+ no_permission_to_view_roles?: string;
469
+ no_permission_description?: string;
464
470
  /** Editor table-bubble */
465
471
  add_row_before: string;
466
472
  add_row_after: string;
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Evan Wallace
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # esbuild
2
+
3
+ This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
@@ -0,0 +1,220 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // lib/npm/node-platform.ts
27
+ var fs = require("fs");
28
+ var os = require("os");
29
+ var path = require("path");
30
+ var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
31
+ var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
32
+ var packageDarwin_arm64 = "@esbuild/darwin-arm64";
33
+ var packageDarwin_x64 = "@esbuild/darwin-x64";
34
+ var knownWindowsPackages = {
35
+ "win32 arm64 LE": "@esbuild/win32-arm64",
36
+ "win32 ia32 LE": "@esbuild/win32-ia32",
37
+ "win32 x64 LE": "@esbuild/win32-x64"
38
+ };
39
+ var knownUnixlikePackages = {
40
+ "aix ppc64 BE": "@esbuild/aix-ppc64",
41
+ "android arm64 LE": "@esbuild/android-arm64",
42
+ "darwin arm64 LE": "@esbuild/darwin-arm64",
43
+ "darwin x64 LE": "@esbuild/darwin-x64",
44
+ "freebsd arm64 LE": "@esbuild/freebsd-arm64",
45
+ "freebsd x64 LE": "@esbuild/freebsd-x64",
46
+ "linux arm LE": "@esbuild/linux-arm",
47
+ "linux arm64 LE": "@esbuild/linux-arm64",
48
+ "linux ia32 LE": "@esbuild/linux-ia32",
49
+ "linux mips64el LE": "@esbuild/linux-mips64el",
50
+ "linux ppc64 LE": "@esbuild/linux-ppc64",
51
+ "linux riscv64 LE": "@esbuild/linux-riscv64",
52
+ "linux s390x BE": "@esbuild/linux-s390x",
53
+ "linux x64 LE": "@esbuild/linux-x64",
54
+ "linux loong64 LE": "@esbuild/linux-loong64",
55
+ "netbsd x64 LE": "@esbuild/netbsd-x64",
56
+ "openbsd x64 LE": "@esbuild/openbsd-x64",
57
+ "sunos x64 LE": "@esbuild/sunos-x64"
58
+ };
59
+ var knownWebAssemblyFallbackPackages = {
60
+ "android arm LE": "@esbuild/android-arm",
61
+ "android x64 LE": "@esbuild/android-x64"
62
+ };
63
+ function pkgAndSubpathForCurrentPlatform() {
64
+ let pkg;
65
+ let subpath;
66
+ let isWASM2 = false;
67
+ let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
68
+ if (platformKey in knownWindowsPackages) {
69
+ pkg = knownWindowsPackages[platformKey];
70
+ subpath = "esbuild.exe";
71
+ } else if (platformKey in knownUnixlikePackages) {
72
+ pkg = knownUnixlikePackages[platformKey];
73
+ subpath = "bin/esbuild";
74
+ } else if (platformKey in knownWebAssemblyFallbackPackages) {
75
+ pkg = knownWebAssemblyFallbackPackages[platformKey];
76
+ subpath = "bin/esbuild";
77
+ isWASM2 = true;
78
+ } else {
79
+ throw new Error(`Unsupported platform: ${platformKey}`);
80
+ }
81
+ return { pkg, subpath, isWASM: isWASM2 };
82
+ }
83
+ function pkgForSomeOtherPlatform() {
84
+ const libMainJS = require.resolve("esbuild");
85
+ const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS)));
86
+ if (path.basename(nodeModulesDirectory) === "node_modules") {
87
+ for (const unixKey in knownUnixlikePackages) {
88
+ try {
89
+ const pkg = knownUnixlikePackages[unixKey];
90
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
91
+ } catch {
92
+ }
93
+ }
94
+ for (const windowsKey in knownWindowsPackages) {
95
+ try {
96
+ const pkg = knownWindowsPackages[windowsKey];
97
+ if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
98
+ } catch {
99
+ }
100
+ }
101
+ }
102
+ return null;
103
+ }
104
+ function downloadedBinPath(pkg, subpath) {
105
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
106
+ return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
107
+ }
108
+ function generateBinPath() {
109
+ if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
110
+ if (!fs.existsSync(ESBUILD_BINARY_PATH)) {
111
+ console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
112
+ } else {
113
+ return { binPath: ESBUILD_BINARY_PATH, isWASM: false };
114
+ }
115
+ }
116
+ const { pkg, subpath, isWASM: isWASM2 } = pkgAndSubpathForCurrentPlatform();
117
+ let binPath2;
118
+ try {
119
+ binPath2 = require.resolve(`${pkg}/${subpath}`);
120
+ } catch (e) {
121
+ binPath2 = downloadedBinPath(pkg, subpath);
122
+ if (!fs.existsSync(binPath2)) {
123
+ try {
124
+ require.resolve(pkg);
125
+ } catch {
126
+ const otherPkg = pkgForSomeOtherPlatform();
127
+ if (otherPkg) {
128
+ let suggestions = `
129
+ Specifically the "${otherPkg}" package is present but this platform
130
+ needs the "${pkg}" package instead. People often get into this
131
+ situation by installing esbuild on Windows or macOS and copying "node_modules"
132
+ into a Docker image that runs Linux, or by copying "node_modules" between
133
+ Windows and WSL environments.
134
+
135
+ If you are installing with npm, you can try not copying the "node_modules"
136
+ directory when you copy the files over, and running "npm ci" or "npm install"
137
+ on the destination platform after the copy. Or you could consider using yarn
138
+ instead of npm which has built-in support for installing a package on multiple
139
+ platforms simultaneously.
140
+
141
+ If you are installing with yarn, you can try listing both this platform and the
142
+ other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
143
+ feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
144
+ Keep in mind that this means multiple copies of esbuild will be present.
145
+ `;
146
+ if (pkg === packageDarwin_x64 && otherPkg === packageDarwin_arm64 || pkg === packageDarwin_arm64 && otherPkg === packageDarwin_x64) {
147
+ suggestions = `
148
+ Specifically the "${otherPkg}" package is present but this platform
149
+ needs the "${pkg}" package instead. People often get into this
150
+ situation by installing esbuild with npm running inside of Rosetta 2 and then
151
+ trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
152
+ 2 is Apple's on-the-fly x86_64-to-arm64 translation service).
153
+
154
+ If you are installing with npm, you can try ensuring that both npm and node are
155
+ not running under Rosetta 2 and then reinstalling esbuild. This likely involves
156
+ changing how you installed npm and/or node. For example, installing node with
157
+ the universal installer here should work: https://nodejs.org/en/download/. Or
158
+ you could consider using yarn instead of npm which has built-in support for
159
+ installing a package on multiple platforms simultaneously.
160
+
161
+ If you are installing with yarn, you can try listing both "arm64" and "x64"
162
+ in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
163
+ https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
164
+ Keep in mind that this means multiple copies of esbuild will be present.
165
+ `;
166
+ }
167
+ throw new Error(`
168
+ You installed esbuild for another platform than the one you're currently using.
169
+ This won't work because esbuild is written with native code and needs to
170
+ install a platform-specific binary executable.
171
+ ${suggestions}
172
+ Another alternative is to use the "esbuild-wasm" package instead, which works
173
+ the same way on all platforms. But it comes with a heavy performance cost and
174
+ can sometimes be 10x slower than the "esbuild" package, so you may also not
175
+ want to do that.
176
+ `);
177
+ }
178
+ throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
179
+
180
+ If you are installing esbuild with npm, make sure that you don't specify the
181
+ "--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
182
+ of "package.json" is used by esbuild to install the correct binary executable
183
+ for your current platform.`);
184
+ }
185
+ throw e;
186
+ }
187
+ }
188
+ if (/\.zip\//.test(binPath2)) {
189
+ let pnpapi;
190
+ try {
191
+ pnpapi = require("pnpapi");
192
+ } catch (e) {
193
+ }
194
+ if (pnpapi) {
195
+ const root = pnpapi.getPackageInformation(pnpapi.topLevel).packageLocation;
196
+ const binTargetPath = path.join(
197
+ root,
198
+ "node_modules",
199
+ ".cache",
200
+ "esbuild",
201
+ `pnpapi-${pkg.replace("/", "-")}-${"0.21.5"}-${path.basename(subpath)}`
202
+ );
203
+ if (!fs.existsSync(binTargetPath)) {
204
+ fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
205
+ fs.copyFileSync(binPath2, binTargetPath);
206
+ fs.chmodSync(binTargetPath, 493);
207
+ }
208
+ return { binPath: binTargetPath, isWASM: isWASM2 };
209
+ }
210
+ }
211
+ return { binPath: binPath2, isWASM: isWASM2 };
212
+ }
213
+
214
+ // lib/npm/node-shim.ts
215
+ var { binPath, isWASM } = generateBinPath();
216
+ if (isWASM) {
217
+ require("child_process").execFileSync("node", [binPath].concat(process.argv.slice(2)), { stdio: "inherit" });
218
+ } else {
219
+ require("child_process").execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
220
+ }
@@ -0,0 +1,285 @@
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // lib/npm/node-platform.ts
26
+ var fs = require("fs");
27
+ var os = require("os");
28
+ var path = require("path");
29
+ var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
30
+ var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
31
+ var knownWindowsPackages = {
32
+ "win32 arm64 LE": "@esbuild/win32-arm64",
33
+ "win32 ia32 LE": "@esbuild/win32-ia32",
34
+ "win32 x64 LE": "@esbuild/win32-x64"
35
+ };
36
+ var knownUnixlikePackages = {
37
+ "aix ppc64 BE": "@esbuild/aix-ppc64",
38
+ "android arm64 LE": "@esbuild/android-arm64",
39
+ "darwin arm64 LE": "@esbuild/darwin-arm64",
40
+ "darwin x64 LE": "@esbuild/darwin-x64",
41
+ "freebsd arm64 LE": "@esbuild/freebsd-arm64",
42
+ "freebsd x64 LE": "@esbuild/freebsd-x64",
43
+ "linux arm LE": "@esbuild/linux-arm",
44
+ "linux arm64 LE": "@esbuild/linux-arm64",
45
+ "linux ia32 LE": "@esbuild/linux-ia32",
46
+ "linux mips64el LE": "@esbuild/linux-mips64el",
47
+ "linux ppc64 LE": "@esbuild/linux-ppc64",
48
+ "linux riscv64 LE": "@esbuild/linux-riscv64",
49
+ "linux s390x BE": "@esbuild/linux-s390x",
50
+ "linux x64 LE": "@esbuild/linux-x64",
51
+ "linux loong64 LE": "@esbuild/linux-loong64",
52
+ "netbsd x64 LE": "@esbuild/netbsd-x64",
53
+ "openbsd x64 LE": "@esbuild/openbsd-x64",
54
+ "sunos x64 LE": "@esbuild/sunos-x64"
55
+ };
56
+ var knownWebAssemblyFallbackPackages = {
57
+ "android arm LE": "@esbuild/android-arm",
58
+ "android x64 LE": "@esbuild/android-x64"
59
+ };
60
+ function pkgAndSubpathForCurrentPlatform() {
61
+ let pkg;
62
+ let subpath;
63
+ let isWASM = false;
64
+ let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
65
+ if (platformKey in knownWindowsPackages) {
66
+ pkg = knownWindowsPackages[platformKey];
67
+ subpath = "esbuild.exe";
68
+ } else if (platformKey in knownUnixlikePackages) {
69
+ pkg = knownUnixlikePackages[platformKey];
70
+ subpath = "bin/esbuild";
71
+ } else if (platformKey in knownWebAssemblyFallbackPackages) {
72
+ pkg = knownWebAssemblyFallbackPackages[platformKey];
73
+ subpath = "bin/esbuild";
74
+ isWASM = true;
75
+ } else {
76
+ throw new Error(`Unsupported platform: ${platformKey}`);
77
+ }
78
+ return { pkg, subpath, isWASM };
79
+ }
80
+ function downloadedBinPath(pkg, subpath) {
81
+ const esbuildLibDir = path.dirname(require.resolve("esbuild"));
82
+ return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
83
+ }
84
+
85
+ // lib/npm/node-install.ts
86
+ var fs2 = require("fs");
87
+ var os2 = require("os");
88
+ var path2 = require("path");
89
+ var zlib = require("zlib");
90
+ var https = require("https");
91
+ var child_process = require("child_process");
92
+ var versionFromPackageJSON = require(path2.join(__dirname, "package.json")).version;
93
+ var toPath = path2.join(__dirname, "bin", "esbuild");
94
+ var isToPathJS = true;
95
+ function validateBinaryVersion(...command) {
96
+ command.push("--version");
97
+ let stdout;
98
+ try {
99
+ stdout = child_process.execFileSync(command.shift(), command, {
100
+ // Without this, this install script strangely crashes with the error
101
+ // "EACCES: permission denied, write" but only on Ubuntu Linux when node is
102
+ // installed from the Snap Store. This is not a problem when you download
103
+ // the official version of node. The problem appears to be that stderr
104
+ // (i.e. file descriptor 2) isn't writable?
105
+ //
106
+ // More info:
107
+ // - https://snapcraft.io/ (what the Snap Store is)
108
+ // - https://nodejs.org/dist/ (download the official version of node)
109
+ // - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
110
+ //
111
+ stdio: "pipe"
112
+ }).toString().trim();
113
+ } catch (err) {
114
+ if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) {
115
+ let os3 = "this version of macOS";
116
+ try {
117
+ os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim();
118
+ } catch {
119
+ }
120
+ throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
121
+
122
+ The Go compiler (which esbuild relies on) no longer supports ${os3},
123
+ which means the "esbuild" binary executable can't be run. You can either:
124
+
125
+ * Update your version of macOS to one that the Go compiler supports
126
+ * Use the "esbuild-wasm" package instead of the "esbuild" package
127
+ * Build esbuild yourself using an older version of the Go compiler
128
+ `);
129
+ }
130
+ throw err;
131
+ }
132
+ if (stdout !== versionFromPackageJSON) {
133
+ throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`);
134
+ }
135
+ }
136
+ function isYarn() {
137
+ const { npm_config_user_agent } = process.env;
138
+ if (npm_config_user_agent) {
139
+ return /\byarn\//.test(npm_config_user_agent);
140
+ }
141
+ return false;
142
+ }
143
+ function fetch(url) {
144
+ return new Promise((resolve, reject) => {
145
+ https.get(url, (res) => {
146
+ if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
147
+ return fetch(res.headers.location).then(resolve, reject);
148
+ if (res.statusCode !== 200)
149
+ return reject(new Error(`Server responded with ${res.statusCode}`));
150
+ let chunks = [];
151
+ res.on("data", (chunk) => chunks.push(chunk));
152
+ res.on("end", () => resolve(Buffer.concat(chunks)));
153
+ }).on("error", reject);
154
+ });
155
+ }
156
+ function extractFileFromTarGzip(buffer, subpath) {
157
+ try {
158
+ buffer = zlib.unzipSync(buffer);
159
+ } catch (err) {
160
+ throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
161
+ }
162
+ let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
163
+ let offset = 0;
164
+ subpath = `package/${subpath}`;
165
+ while (offset < buffer.length) {
166
+ let name = str(offset, 100);
167
+ let size = parseInt(str(offset + 124, 12), 8);
168
+ offset += 512;
169
+ if (!isNaN(size)) {
170
+ if (name === subpath) return buffer.subarray(offset, offset + size);
171
+ offset += size + 511 & ~511;
172
+ }
173
+ }
174
+ throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
175
+ }
176
+ function installUsingNPM(pkg, subpath, binPath) {
177
+ const env = { ...process.env, npm_config_global: void 0 };
178
+ const esbuildLibDir = path2.dirname(require.resolve("esbuild"));
179
+ const installDir = path2.join(esbuildLibDir, "npm-install");
180
+ fs2.mkdirSync(installDir);
181
+ try {
182
+ fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
183
+ child_process.execSync(
184
+ `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${versionFromPackageJSON}`,
185
+ { cwd: installDir, stdio: "pipe", env }
186
+ );
187
+ const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
188
+ fs2.renameSync(installedBinPath, binPath);
189
+ } finally {
190
+ try {
191
+ removeRecursive(installDir);
192
+ } catch {
193
+ }
194
+ }
195
+ }
196
+ function removeRecursive(dir) {
197
+ for (const entry of fs2.readdirSync(dir)) {
198
+ const entryPath = path2.join(dir, entry);
199
+ let stats;
200
+ try {
201
+ stats = fs2.lstatSync(entryPath);
202
+ } catch {
203
+ continue;
204
+ }
205
+ if (stats.isDirectory()) removeRecursive(entryPath);
206
+ else fs2.unlinkSync(entryPath);
207
+ }
208
+ fs2.rmdirSync(dir);
209
+ }
210
+ function applyManualBinaryPathOverride(overridePath) {
211
+ const pathString = JSON.stringify(overridePath);
212
+ fs2.writeFileSync(toPath, `#!/usr/bin/env node
213
+ require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
214
+ `);
215
+ const libMain = path2.join(__dirname, "lib", "main.js");
216
+ const code = fs2.readFileSync(libMain, "utf8");
217
+ fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
218
+ ${code}`);
219
+ }
220
+ function maybeOptimizePackage(binPath) {
221
+ if (os2.platform() !== "win32" && !isYarn()) {
222
+ const tempPath = path2.join(__dirname, "bin-esbuild");
223
+ try {
224
+ fs2.linkSync(binPath, tempPath);
225
+ fs2.renameSync(tempPath, toPath);
226
+ isToPathJS = false;
227
+ fs2.unlinkSync(tempPath);
228
+ } catch {
229
+ }
230
+ }
231
+ }
232
+ async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
233
+ const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${versionFromPackageJSON}.tgz`;
234
+ console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
235
+ try {
236
+ fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
237
+ fs2.chmodSync(binPath, 493);
238
+ } catch (e) {
239
+ console.error(`[esbuild] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`);
240
+ throw e;
241
+ }
242
+ }
243
+ async function checkAndPreparePackage() {
244
+ if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
245
+ if (!fs2.existsSync(ESBUILD_BINARY_PATH)) {
246
+ console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
247
+ } else {
248
+ applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
249
+ return;
250
+ }
251
+ }
252
+ const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
253
+ let binPath;
254
+ try {
255
+ binPath = require.resolve(`${pkg}/${subpath}`);
256
+ } catch (e) {
257
+ console.error(`[esbuild] Failed to find package "${pkg}" on the file system
258
+
259
+ This can happen if you use the "--no-optional" flag. The "optionalDependencies"
260
+ package.json feature is used by esbuild to install the correct binary executable
261
+ for your current platform. This install script will now attempt to work around
262
+ this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
263
+ `);
264
+ binPath = downloadedBinPath(pkg, subpath);
265
+ try {
266
+ console.error(`[esbuild] Trying to install package "${pkg}" using npm`);
267
+ installUsingNPM(pkg, subpath, binPath);
268
+ } catch (e2) {
269
+ console.error(`[esbuild] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`);
270
+ try {
271
+ await downloadDirectlyFromNPM(pkg, subpath, binPath);
272
+ } catch (e3) {
273
+ throw new Error(`Failed to install package "${pkg}"`);
274
+ }
275
+ }
276
+ }
277
+ maybeOptimizePackage(binPath);
278
+ }
279
+ checkAndPreparePackage().then(() => {
280
+ if (isToPathJS) {
281
+ validateBinaryVersion(process.execPath, toPath);
282
+ } else {
283
+ validateBinaryVersion(toPath);
284
+ }
285
+ });