headroom-cms 0.1.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.
Files changed (237) hide show
  1. package/README.md +282 -0
  2. package/admin/assets/AdminsPage-CnrQqwKA.js +1 -0
  3. package/admin/assets/AllContentPage-ByN1h3PP.js +1 -0
  4. package/admin/assets/ApiKeysPage-FgNHZPBS.js +1 -0
  5. package/admin/assets/AuditPage-DAPpo-sj.js +1 -0
  6. package/admin/assets/BlockEditor-CZTwex-o.js +179 -0
  7. package/admin/assets/BlockEditor-Cp_wZ2xN.css +1 -0
  8. package/admin/assets/BlockTypeEditPage-Buuwbx1P.js +1 -0
  9. package/admin/assets/BlockTypesPage-Dj0qmsqX.js +1 -0
  10. package/admin/assets/BulkActionBar-BMcUBJSH.js +1 -0
  11. package/admin/assets/CollectionEditPage-CLgQu2HS.js +1 -0
  12. package/admin/assets/CollectionsPage-BnCaxALz.js +1 -0
  13. package/admin/assets/ContentCreatePage-CJI326o-.js +1 -0
  14. package/admin/assets/ContentEditPage-A4i8P2Jd.js +3 -0
  15. package/admin/assets/ContentListPage-Bc4mBIkB.js +1 -0
  16. package/admin/assets/CustomBlockPreview-CCssn6vF.js +479 -0
  17. package/admin/assets/FieldBuilder-YJGSk0nY.js +3 -0
  18. package/admin/assets/LoginPage-Jrne8-Wr.js +1 -0
  19. package/admin/assets/MediaPage-DfPQBmNf.css +1 -0
  20. package/admin/assets/MediaPage-_qNXqsZg.js +1 -0
  21. package/admin/assets/SiteSettingsPage-CoZnavij.js +1 -0
  22. package/admin/assets/SitesPage-ETqFT3nO.js +1 -0
  23. package/admin/assets/TagsPage-BGpp0XZM.js +1 -0
  24. package/admin/assets/UsersPage-CKRJpAb6.js +1 -0
  25. package/admin/assets/WebhookEditPage-BOcLe5OJ.js +1 -0
  26. package/admin/assets/WebhooksPage-Czco583Y.js +1 -0
  27. package/admin/assets/badge-0Z1nL6DI.js +1 -0
  28. package/admin/assets/card-D1-S-QZ6.js +1 -0
  29. package/admin/assets/check-BGA0ADyt.js +1 -0
  30. package/admin/assets/checkbox-BPqrj_XS.js +1 -0
  31. package/admin/assets/command-ChD319uJ.js +1 -0
  32. package/admin/assets/contentStatus-DfWHjFVB.js +1 -0
  33. package/admin/assets/copy-BqH9rXYM.js +1 -0
  34. package/admin/assets/core.esm-Csvubn5Q.js +5 -0
  35. package/admin/assets/format-CZ9bpk32.js +1 -0
  36. package/admin/assets/index-DOqKbrpW.css +1 -0
  37. package/admin/assets/index-Ds50UTAc.js +18 -0
  38. package/admin/assets/lib-BrI1UB_t.js +38 -0
  39. package/admin/assets/media-url-DIg_vSyf.js +1 -0
  40. package/admin/assets/module-RjUF93sV.js +716 -0
  41. package/admin/assets/native-48B9X9Wg.js +1 -0
  42. package/admin/assets/plus-BgHSYWJN.js +1 -0
  43. package/admin/assets/radix-DQ3amgxj.js +51 -0
  44. package/admin/assets/react-vendor-DNVhVxD7.js +4 -0
  45. package/admin/assets/search-DIzcfCVh.js +1 -0
  46. package/admin/assets/select-CJXZv4wv.js +1 -0
  47. package/admin/assets/sortable.esm-Zh-9QRSf.js +1 -0
  48. package/admin/assets/table-B3EHrN_H.js +1 -0
  49. package/admin/assets/tanstack-BO6c-AOu.js +1 -0
  50. package/admin/assets/trash-2-Gny2Upn-.js +1 -0
  51. package/admin/assets/useAdminResolver-BsQc_N4z.js +1 -0
  52. package/admin/assets/useContent-CSobIico.js +1 -0
  53. package/admin/assets/useDebouncedValue-Bf8UizjU.js +1 -0
  54. package/admin/assets/useMedia-CQnmMz4N.js +1 -0
  55. package/admin/assets/useTags-CYqbj5cK.js +1 -0
  56. package/admin/assets/useWebhooks-DXgtQ3aU.js +1 -0
  57. package/admin/index.html +21 -0
  58. package/admin/vite.svg +1 -0
  59. package/dist/admin-site.d.ts +30 -0
  60. package/dist/admin-site.d.ts.map +1 -0
  61. package/dist/admin-site.js +80 -0
  62. package/dist/admin-site.js.map +1 -0
  63. package/dist/api.d.ts +26 -0
  64. package/dist/api.d.ts.map +1 -0
  65. package/dist/api.js +91 -0
  66. package/dist/api.js.map +1 -0
  67. package/dist/auth.d.ts +27 -0
  68. package/dist/auth.d.ts.map +1 -0
  69. package/dist/auth.js +86 -0
  70. package/dist/auth.js.map +1 -0
  71. package/dist/cdn.d.ts +27 -0
  72. package/dist/cdn.d.ts.map +1 -0
  73. package/dist/cdn.js +382 -0
  74. package/dist/cdn.js.map +1 -0
  75. package/dist/image.d.ts +21 -0
  76. package/dist/image.d.ts.map +1 -0
  77. package/dist/image.js +48 -0
  78. package/dist/image.js.map +1 -0
  79. package/dist/index.d.ts +85 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +124 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/storage.d.ts +21 -0
  84. package/dist/storage.d.ts.map +1 -0
  85. package/dist/storage.js +125 -0
  86. package/dist/storage.js.map +1 -0
  87. package/dist/webhooks.d.ts +23 -0
  88. package/dist/webhooks.d.ts.map +1 -0
  89. package/dist/webhooks.js +91 -0
  90. package/dist/webhooks.js.map +1 -0
  91. package/lambda/api/bootstrap +0 -0
  92. package/lambda/api/resource.enc +0 -0
  93. package/lambda/functions/custom-message/index.mjs +112 -0
  94. package/lambda/functions/custom-message/resource.enc +1 -0
  95. package/lambda/image-lambda/index.mjs +188 -0
  96. package/lambda/image-lambda/node_modules/.package-lock.json +160 -0
  97. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/README.md +46 -0
  98. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/lib/glib-2.0/include/glibconfig.h +220 -0
  99. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/lib/index.js +1 -0
  100. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/lib/libvips-cpp.so.42 +0 -0
  101. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/package.json +42 -0
  102. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/versions.json +30 -0
  103. package/lambda/image-lambda/node_modules/@img/sharp-linux-arm64/LICENSE +191 -0
  104. package/lambda/image-lambda/node_modules/@img/sharp-linux-arm64/README.md +18 -0
  105. package/lambda/image-lambda/node_modules/@img/sharp-linux-arm64/lib/sharp-linux-arm64.node +0 -0
  106. package/lambda/image-lambda/node_modules/@img/sharp-linux-arm64/package.json +46 -0
  107. package/lambda/image-lambda/node_modules/color/LICENSE +21 -0
  108. package/lambda/image-lambda/node_modules/color/README.md +123 -0
  109. package/lambda/image-lambda/node_modules/color/index.js +496 -0
  110. package/lambda/image-lambda/node_modules/color/package.json +47 -0
  111. package/lambda/image-lambda/node_modules/color-convert/CHANGELOG.md +54 -0
  112. package/lambda/image-lambda/node_modules/color-convert/LICENSE +21 -0
  113. package/lambda/image-lambda/node_modules/color-convert/README.md +68 -0
  114. package/lambda/image-lambda/node_modules/color-convert/conversions.js +839 -0
  115. package/lambda/image-lambda/node_modules/color-convert/index.js +81 -0
  116. package/lambda/image-lambda/node_modules/color-convert/package.json +48 -0
  117. package/lambda/image-lambda/node_modules/color-convert/route.js +97 -0
  118. package/lambda/image-lambda/node_modules/color-name/LICENSE +8 -0
  119. package/lambda/image-lambda/node_modules/color-name/README.md +11 -0
  120. package/lambda/image-lambda/node_modules/color-name/index.js +152 -0
  121. package/lambda/image-lambda/node_modules/color-name/package.json +28 -0
  122. package/lambda/image-lambda/node_modules/color-string/LICENSE +21 -0
  123. package/lambda/image-lambda/node_modules/color-string/README.md +62 -0
  124. package/lambda/image-lambda/node_modules/color-string/index.js +242 -0
  125. package/lambda/image-lambda/node_modules/color-string/package.json +39 -0
  126. package/lambda/image-lambda/node_modules/detect-libc/LICENSE +201 -0
  127. package/lambda/image-lambda/node_modules/detect-libc/README.md +163 -0
  128. package/lambda/image-lambda/node_modules/detect-libc/index.d.ts +14 -0
  129. package/lambda/image-lambda/node_modules/detect-libc/lib/detect-libc.js +313 -0
  130. package/lambda/image-lambda/node_modules/detect-libc/lib/elf.js +39 -0
  131. package/lambda/image-lambda/node_modules/detect-libc/lib/filesystem.js +51 -0
  132. package/lambda/image-lambda/node_modules/detect-libc/lib/process.js +24 -0
  133. package/lambda/image-lambda/node_modules/detect-libc/package.json +44 -0
  134. package/lambda/image-lambda/node_modules/is-arrayish/LICENSE +21 -0
  135. package/lambda/image-lambda/node_modules/is-arrayish/README.md +16 -0
  136. package/lambda/image-lambda/node_modules/is-arrayish/index.js +9 -0
  137. package/lambda/image-lambda/node_modules/is-arrayish/package.json +45 -0
  138. package/lambda/image-lambda/node_modules/semver/LICENSE +15 -0
  139. package/lambda/image-lambda/node_modules/semver/README.md +665 -0
  140. package/lambda/image-lambda/node_modules/semver/bin/semver.js +191 -0
  141. package/lambda/image-lambda/node_modules/semver/classes/comparator.js +143 -0
  142. package/lambda/image-lambda/node_modules/semver/classes/index.js +7 -0
  143. package/lambda/image-lambda/node_modules/semver/classes/range.js +557 -0
  144. package/lambda/image-lambda/node_modules/semver/classes/semver.js +333 -0
  145. package/lambda/image-lambda/node_modules/semver/functions/clean.js +8 -0
  146. package/lambda/image-lambda/node_modules/semver/functions/cmp.js +54 -0
  147. package/lambda/image-lambda/node_modules/semver/functions/coerce.js +62 -0
  148. package/lambda/image-lambda/node_modules/semver/functions/compare-build.js +9 -0
  149. package/lambda/image-lambda/node_modules/semver/functions/compare-loose.js +5 -0
  150. package/lambda/image-lambda/node_modules/semver/functions/compare.js +7 -0
  151. package/lambda/image-lambda/node_modules/semver/functions/diff.js +60 -0
  152. package/lambda/image-lambda/node_modules/semver/functions/eq.js +5 -0
  153. package/lambda/image-lambda/node_modules/semver/functions/gt.js +5 -0
  154. package/lambda/image-lambda/node_modules/semver/functions/gte.js +5 -0
  155. package/lambda/image-lambda/node_modules/semver/functions/inc.js +21 -0
  156. package/lambda/image-lambda/node_modules/semver/functions/lt.js +5 -0
  157. package/lambda/image-lambda/node_modules/semver/functions/lte.js +5 -0
  158. package/lambda/image-lambda/node_modules/semver/functions/major.js +5 -0
  159. package/lambda/image-lambda/node_modules/semver/functions/minor.js +5 -0
  160. package/lambda/image-lambda/node_modules/semver/functions/neq.js +5 -0
  161. package/lambda/image-lambda/node_modules/semver/functions/parse.js +18 -0
  162. package/lambda/image-lambda/node_modules/semver/functions/patch.js +5 -0
  163. package/lambda/image-lambda/node_modules/semver/functions/prerelease.js +8 -0
  164. package/lambda/image-lambda/node_modules/semver/functions/rcompare.js +5 -0
  165. package/lambda/image-lambda/node_modules/semver/functions/rsort.js +5 -0
  166. package/lambda/image-lambda/node_modules/semver/functions/satisfies.js +12 -0
  167. package/lambda/image-lambda/node_modules/semver/functions/sort.js +5 -0
  168. package/lambda/image-lambda/node_modules/semver/functions/valid.js +8 -0
  169. package/lambda/image-lambda/node_modules/semver/index.js +91 -0
  170. package/lambda/image-lambda/node_modules/semver/internal/constants.js +37 -0
  171. package/lambda/image-lambda/node_modules/semver/internal/debug.js +11 -0
  172. package/lambda/image-lambda/node_modules/semver/internal/identifiers.js +29 -0
  173. package/lambda/image-lambda/node_modules/semver/internal/lrucache.js +42 -0
  174. package/lambda/image-lambda/node_modules/semver/internal/parse-options.js +17 -0
  175. package/lambda/image-lambda/node_modules/semver/internal/re.js +223 -0
  176. package/lambda/image-lambda/node_modules/semver/package.json +78 -0
  177. package/lambda/image-lambda/node_modules/semver/preload.js +4 -0
  178. package/lambda/image-lambda/node_modules/semver/range.bnf +16 -0
  179. package/lambda/image-lambda/node_modules/semver/ranges/gtr.js +6 -0
  180. package/lambda/image-lambda/node_modules/semver/ranges/intersects.js +9 -0
  181. package/lambda/image-lambda/node_modules/semver/ranges/ltr.js +6 -0
  182. package/lambda/image-lambda/node_modules/semver/ranges/max-satisfying.js +27 -0
  183. package/lambda/image-lambda/node_modules/semver/ranges/min-satisfying.js +26 -0
  184. package/lambda/image-lambda/node_modules/semver/ranges/min-version.js +63 -0
  185. package/lambda/image-lambda/node_modules/semver/ranges/outside.js +82 -0
  186. package/lambda/image-lambda/node_modules/semver/ranges/simplify.js +49 -0
  187. package/lambda/image-lambda/node_modules/semver/ranges/subset.js +249 -0
  188. package/lambda/image-lambda/node_modules/semver/ranges/to-comparators.js +10 -0
  189. package/lambda/image-lambda/node_modules/semver/ranges/valid.js +13 -0
  190. package/lambda/image-lambda/node_modules/sharp/LICENSE +191 -0
  191. package/lambda/image-lambda/node_modules/sharp/README.md +118 -0
  192. package/lambda/image-lambda/node_modules/sharp/install/check.js +41 -0
  193. package/lambda/image-lambda/node_modules/sharp/lib/channel.js +174 -0
  194. package/lambda/image-lambda/node_modules/sharp/lib/colour.js +180 -0
  195. package/lambda/image-lambda/node_modules/sharp/lib/composite.js +210 -0
  196. package/lambda/image-lambda/node_modules/sharp/lib/constructor.js +452 -0
  197. package/lambda/image-lambda/node_modules/sharp/lib/index.d.ts +1754 -0
  198. package/lambda/image-lambda/node_modules/sharp/lib/index.js +16 -0
  199. package/lambda/image-lambda/node_modules/sharp/lib/input.js +658 -0
  200. package/lambda/image-lambda/node_modules/sharp/lib/is.js +169 -0
  201. package/lambda/image-lambda/node_modules/sharp/lib/libvips.js +203 -0
  202. package/lambda/image-lambda/node_modules/sharp/lib/operation.js +958 -0
  203. package/lambda/image-lambda/node_modules/sharp/lib/output.js +1587 -0
  204. package/lambda/image-lambda/node_modules/sharp/lib/resize.js +587 -0
  205. package/lambda/image-lambda/node_modules/sharp/lib/sharp.js +114 -0
  206. package/lambda/image-lambda/node_modules/sharp/lib/utility.js +296 -0
  207. package/lambda/image-lambda/node_modules/sharp/package.json +222 -0
  208. package/lambda/image-lambda/node_modules/sharp/src/binding.gyp +280 -0
  209. package/lambda/image-lambda/node_modules/sharp/src/common.cc +1091 -0
  210. package/lambda/image-lambda/node_modules/sharp/src/common.h +393 -0
  211. package/lambda/image-lambda/node_modules/sharp/src/metadata.cc +320 -0
  212. package/lambda/image-lambda/node_modules/sharp/src/metadata.h +85 -0
  213. package/lambda/image-lambda/node_modules/sharp/src/operations.cc +475 -0
  214. package/lambda/image-lambda/node_modules/sharp/src/operations.h +125 -0
  215. package/lambda/image-lambda/node_modules/sharp/src/pipeline.cc +1758 -0
  216. package/lambda/image-lambda/node_modules/sharp/src/pipeline.h +393 -0
  217. package/lambda/image-lambda/node_modules/sharp/src/sharp.cc +40 -0
  218. package/lambda/image-lambda/node_modules/sharp/src/stats.cc +183 -0
  219. package/lambda/image-lambda/node_modules/sharp/src/stats.h +59 -0
  220. package/lambda/image-lambda/node_modules/sharp/src/utilities.cc +269 -0
  221. package/lambda/image-lambda/node_modules/sharp/src/utilities.h +19 -0
  222. package/lambda/image-lambda/node_modules/simple-swizzle/LICENSE +21 -0
  223. package/lambda/image-lambda/node_modules/simple-swizzle/README.md +43 -0
  224. package/lambda/image-lambda/node_modules/simple-swizzle/index.js +29 -0
  225. package/lambda/image-lambda/node_modules/simple-swizzle/package.json +36 -0
  226. package/lambda/webhook-worker/bootstrap +0 -0
  227. package/lambda/webhook-worker/resource.enc +0 -0
  228. package/package.json +50 -0
  229. package/src/admin-site.ts +108 -0
  230. package/src/api.ts +113 -0
  231. package/src/auth.ts +110 -0
  232. package/src/cdn.ts +449 -0
  233. package/src/image.ts +62 -0
  234. package/src/index.ts +216 -0
  235. package/src/sst-env.d.ts +143 -0
  236. package/src/storage.ts +138 -0
  237. package/src/webhooks.ts +114 -0
@@ -0,0 +1,313 @@
1
+ // Copyright 2017 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const childProcess = require('child_process');
7
+ const { isLinux, getReport } = require('./process');
8
+ const { LDD_PATH, SELF_PATH, readFile, readFileSync } = require('./filesystem');
9
+ const { interpreterPath } = require('./elf');
10
+
11
+ let cachedFamilyInterpreter;
12
+ let cachedFamilyFilesystem;
13
+ let cachedVersionFilesystem;
14
+
15
+ const command = 'getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true';
16
+ let commandOut = '';
17
+
18
+ const safeCommand = () => {
19
+ if (!commandOut) {
20
+ return new Promise((resolve) => {
21
+ childProcess.exec(command, (err, out) => {
22
+ commandOut = err ? ' ' : out;
23
+ resolve(commandOut);
24
+ });
25
+ });
26
+ }
27
+ return commandOut;
28
+ };
29
+
30
+ const safeCommandSync = () => {
31
+ if (!commandOut) {
32
+ try {
33
+ commandOut = childProcess.execSync(command, { encoding: 'utf8' });
34
+ } catch (_err) {
35
+ commandOut = ' ';
36
+ }
37
+ }
38
+ return commandOut;
39
+ };
40
+
41
+ /**
42
+ * A String constant containing the value `glibc`.
43
+ * @type {string}
44
+ * @public
45
+ */
46
+ const GLIBC = 'glibc';
47
+
48
+ /**
49
+ * A Regexp constant to get the GLIBC Version.
50
+ * @type {string}
51
+ */
52
+ const RE_GLIBC_VERSION = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;
53
+
54
+ /**
55
+ * A String constant containing the value `musl`.
56
+ * @type {string}
57
+ * @public
58
+ */
59
+ const MUSL = 'musl';
60
+
61
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-');
62
+
63
+ const familyFromReport = () => {
64
+ const report = getReport();
65
+ if (report.header && report.header.glibcVersionRuntime) {
66
+ return GLIBC;
67
+ }
68
+ if (Array.isArray(report.sharedObjects)) {
69
+ if (report.sharedObjects.some(isFileMusl)) {
70
+ return MUSL;
71
+ }
72
+ }
73
+ return null;
74
+ };
75
+
76
+ const familyFromCommand = (out) => {
77
+ const [getconf, ldd1] = out.split(/[\r\n]+/);
78
+ if (getconf && getconf.includes(GLIBC)) {
79
+ return GLIBC;
80
+ }
81
+ if (ldd1 && ldd1.includes(MUSL)) {
82
+ return MUSL;
83
+ }
84
+ return null;
85
+ };
86
+
87
+ const familyFromInterpreterPath = (path) => {
88
+ if (path) {
89
+ if (path.includes('/ld-musl-')) {
90
+ return MUSL;
91
+ } else if (path.includes('/ld-linux-')) {
92
+ return GLIBC;
93
+ }
94
+ }
95
+ return null;
96
+ };
97
+
98
+ const getFamilyFromLddContent = (content) => {
99
+ content = content.toString();
100
+ if (content.includes('musl')) {
101
+ return MUSL;
102
+ }
103
+ if (content.includes('GNU C Library')) {
104
+ return GLIBC;
105
+ }
106
+ return null;
107
+ };
108
+
109
+ const familyFromFilesystem = async () => {
110
+ if (cachedFamilyFilesystem !== undefined) {
111
+ return cachedFamilyFilesystem;
112
+ }
113
+ cachedFamilyFilesystem = null;
114
+ try {
115
+ const lddContent = await readFile(LDD_PATH);
116
+ cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
117
+ } catch (e) {}
118
+ return cachedFamilyFilesystem;
119
+ };
120
+
121
+ const familyFromFilesystemSync = () => {
122
+ if (cachedFamilyFilesystem !== undefined) {
123
+ return cachedFamilyFilesystem;
124
+ }
125
+ cachedFamilyFilesystem = null;
126
+ try {
127
+ const lddContent = readFileSync(LDD_PATH);
128
+ cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
129
+ } catch (e) {}
130
+ return cachedFamilyFilesystem;
131
+ };
132
+
133
+ const familyFromInterpreter = async () => {
134
+ if (cachedFamilyInterpreter !== undefined) {
135
+ return cachedFamilyInterpreter;
136
+ }
137
+ cachedFamilyInterpreter = null;
138
+ try {
139
+ const selfContent = await readFile(SELF_PATH);
140
+ const path = interpreterPath(selfContent);
141
+ cachedFamilyInterpreter = familyFromInterpreterPath(path);
142
+ } catch (e) {}
143
+ return cachedFamilyInterpreter;
144
+ };
145
+
146
+ const familyFromInterpreterSync = () => {
147
+ if (cachedFamilyInterpreter !== undefined) {
148
+ return cachedFamilyInterpreter;
149
+ }
150
+ cachedFamilyInterpreter = null;
151
+ try {
152
+ const selfContent = readFileSync(SELF_PATH);
153
+ const path = interpreterPath(selfContent);
154
+ cachedFamilyInterpreter = familyFromInterpreterPath(path);
155
+ } catch (e) {}
156
+ return cachedFamilyInterpreter;
157
+ };
158
+
159
+ /**
160
+ * Resolves with the libc family when it can be determined, `null` otherwise.
161
+ * @returns {Promise<?string>}
162
+ */
163
+ const family = async () => {
164
+ let family = null;
165
+ if (isLinux()) {
166
+ family = await familyFromInterpreter();
167
+ if (!family) {
168
+ family = await familyFromFilesystem();
169
+ if (!family) {
170
+ family = familyFromReport();
171
+ }
172
+ if (!family) {
173
+ const out = await safeCommand();
174
+ family = familyFromCommand(out);
175
+ }
176
+ }
177
+ }
178
+ return family;
179
+ };
180
+
181
+ /**
182
+ * Returns the libc family when it can be determined, `null` otherwise.
183
+ * @returns {?string}
184
+ */
185
+ const familySync = () => {
186
+ let family = null;
187
+ if (isLinux()) {
188
+ family = familyFromInterpreterSync();
189
+ if (!family) {
190
+ family = familyFromFilesystemSync();
191
+ if (!family) {
192
+ family = familyFromReport();
193
+ }
194
+ if (!family) {
195
+ const out = safeCommandSync();
196
+ family = familyFromCommand(out);
197
+ }
198
+ }
199
+ }
200
+ return family;
201
+ };
202
+
203
+ /**
204
+ * Resolves `true` only when the platform is Linux and the libc family is not `glibc`.
205
+ * @returns {Promise<boolean>}
206
+ */
207
+ const isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
208
+
209
+ /**
210
+ * Returns `true` only when the platform is Linux and the libc family is not `glibc`.
211
+ * @returns {boolean}
212
+ */
213
+ const isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;
214
+
215
+ const versionFromFilesystem = async () => {
216
+ if (cachedVersionFilesystem !== undefined) {
217
+ return cachedVersionFilesystem;
218
+ }
219
+ cachedVersionFilesystem = null;
220
+ try {
221
+ const lddContent = await readFile(LDD_PATH);
222
+ const versionMatch = lddContent.match(RE_GLIBC_VERSION);
223
+ if (versionMatch) {
224
+ cachedVersionFilesystem = versionMatch[1];
225
+ }
226
+ } catch (e) {}
227
+ return cachedVersionFilesystem;
228
+ };
229
+
230
+ const versionFromFilesystemSync = () => {
231
+ if (cachedVersionFilesystem !== undefined) {
232
+ return cachedVersionFilesystem;
233
+ }
234
+ cachedVersionFilesystem = null;
235
+ try {
236
+ const lddContent = readFileSync(LDD_PATH);
237
+ const versionMatch = lddContent.match(RE_GLIBC_VERSION);
238
+ if (versionMatch) {
239
+ cachedVersionFilesystem = versionMatch[1];
240
+ }
241
+ } catch (e) {}
242
+ return cachedVersionFilesystem;
243
+ };
244
+
245
+ const versionFromReport = () => {
246
+ const report = getReport();
247
+ if (report.header && report.header.glibcVersionRuntime) {
248
+ return report.header.glibcVersionRuntime;
249
+ }
250
+ return null;
251
+ };
252
+
253
+ const versionSuffix = (s) => s.trim().split(/\s+/)[1];
254
+
255
+ const versionFromCommand = (out) => {
256
+ const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
257
+ if (getconf && getconf.includes(GLIBC)) {
258
+ return versionSuffix(getconf);
259
+ }
260
+ if (ldd1 && ldd2 && ldd1.includes(MUSL)) {
261
+ return versionSuffix(ldd2);
262
+ }
263
+ return null;
264
+ };
265
+
266
+ /**
267
+ * Resolves with the libc version when it can be determined, `null` otherwise.
268
+ * @returns {Promise<?string>}
269
+ */
270
+ const version = async () => {
271
+ let version = null;
272
+ if (isLinux()) {
273
+ version = await versionFromFilesystem();
274
+ if (!version) {
275
+ version = versionFromReport();
276
+ }
277
+ if (!version) {
278
+ const out = await safeCommand();
279
+ version = versionFromCommand(out);
280
+ }
281
+ }
282
+ return version;
283
+ };
284
+
285
+ /**
286
+ * Returns the libc version when it can be determined, `null` otherwise.
287
+ * @returns {?string}
288
+ */
289
+ const versionSync = () => {
290
+ let version = null;
291
+ if (isLinux()) {
292
+ version = versionFromFilesystemSync();
293
+ if (!version) {
294
+ version = versionFromReport();
295
+ }
296
+ if (!version) {
297
+ const out = safeCommandSync();
298
+ version = versionFromCommand(out);
299
+ }
300
+ }
301
+ return version;
302
+ };
303
+
304
+ module.exports = {
305
+ GLIBC,
306
+ MUSL,
307
+ family,
308
+ familySync,
309
+ isNonGlibcLinux,
310
+ isNonGlibcLinuxSync,
311
+ version,
312
+ versionSync
313
+ };
@@ -0,0 +1,39 @@
1
+ // Copyright 2017 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const interpreterPath = (elf) => {
7
+ if (elf.length < 64) {
8
+ return null;
9
+ }
10
+ if (elf.readUInt32BE(0) !== 0x7F454C46) {
11
+ // Unexpected magic bytes
12
+ return null;
13
+ }
14
+ if (elf.readUInt8(4) !== 2) {
15
+ // Not a 64-bit ELF
16
+ return null;
17
+ }
18
+ if (elf.readUInt8(5) !== 1) {
19
+ // Not little-endian
20
+ return null;
21
+ }
22
+ const offset = elf.readUInt32LE(32);
23
+ const size = elf.readUInt16LE(54);
24
+ const count = elf.readUInt16LE(56);
25
+ for (let i = 0; i < count; i++) {
26
+ const headerOffset = offset + (i * size);
27
+ const type = elf.readUInt32LE(headerOffset);
28
+ if (type === 3) {
29
+ const fileOffset = elf.readUInt32LE(headerOffset + 8);
30
+ const fileSize = elf.readUInt32LE(headerOffset + 32);
31
+ return elf.subarray(fileOffset, fileOffset + fileSize).toString().replace(/\0.*$/g, '');
32
+ }
33
+ }
34
+ return null;
35
+ };
36
+
37
+ module.exports = {
38
+ interpreterPath
39
+ };
@@ -0,0 +1,51 @@
1
+ // Copyright 2017 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const fs = require('fs');
7
+
8
+ const LDD_PATH = '/usr/bin/ldd';
9
+ const SELF_PATH = '/proc/self/exe';
10
+ const MAX_LENGTH = 2048;
11
+
12
+ /**
13
+ * Read the content of a file synchronous
14
+ *
15
+ * @param {string} path
16
+ * @returns {Buffer}
17
+ */
18
+ const readFileSync = (path) => {
19
+ const fd = fs.openSync(path, 'r');
20
+ const buffer = Buffer.alloc(MAX_LENGTH);
21
+ const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
22
+ fs.close(fd, () => {});
23
+ return buffer.subarray(0, bytesRead);
24
+ };
25
+
26
+ /**
27
+ * Read the content of a file
28
+ *
29
+ * @param {string} path
30
+ * @returns {Promise<Buffer>}
31
+ */
32
+ const readFile = (path) => new Promise((resolve, reject) => {
33
+ fs.open(path, 'r', (err, fd) => {
34
+ if (err) {
35
+ reject(err);
36
+ } else {
37
+ const buffer = Buffer.alloc(MAX_LENGTH);
38
+ fs.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
39
+ resolve(buffer.subarray(0, bytesRead));
40
+ fs.close(fd, () => {});
41
+ });
42
+ }
43
+ });
44
+ });
45
+
46
+ module.exports = {
47
+ LDD_PATH,
48
+ SELF_PATH,
49
+ readFileSync,
50
+ readFile
51
+ };
@@ -0,0 +1,24 @@
1
+ // Copyright 2017 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const isLinux = () => process.platform === 'linux';
7
+
8
+ let report = null;
9
+ const getReport = () => {
10
+ if (!report) {
11
+ /* istanbul ignore next */
12
+ if (isLinux() && process.report) {
13
+ const orig = process.report.excludeNetwork;
14
+ process.report.excludeNetwork = true;
15
+ report = process.report.getReport();
16
+ process.report.excludeNetwork = orig;
17
+ } else {
18
+ report = {};
19
+ }
20
+ }
21
+ return report;
22
+ };
23
+
24
+ module.exports = { isLinux, getReport };
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "detect-libc",
3
+ "version": "2.1.2",
4
+ "description": "Node.js module to detect the C standard library (libc) implementation family and version",
5
+ "main": "lib/detect-libc.js",
6
+ "files": [
7
+ "lib/",
8
+ "index.d.ts"
9
+ ],
10
+ "scripts": {
11
+ "test": "semistandard && nyc --reporter=text --check-coverage --branches=100 ava test/unit.js",
12
+ "changelog": "conventional-changelog -i CHANGELOG.md -s",
13
+ "bench": "node benchmark/detect-libc",
14
+ "bench:calls": "node benchmark/call-familySync.js && sleep 1 && node benchmark/call-isNonGlibcLinuxSync.js && sleep 1 && node benchmark/call-versionSync.js"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git://github.com/lovell/detect-libc.git"
19
+ },
20
+ "keywords": [
21
+ "libc",
22
+ "glibc",
23
+ "musl"
24
+ ],
25
+ "author": "Lovell Fuller <npm@lovell.info>",
26
+ "contributors": [
27
+ "Niklas Salmoukas <niklas@salmoukas.com>",
28
+ "Vinícius Lourenço <vinyygamerlol@gmail.com>"
29
+ ],
30
+ "license": "Apache-2.0",
31
+ "devDependencies": {
32
+ "ava": "^2.4.0",
33
+ "benchmark": "^2.1.4",
34
+ "conventional-changelog-cli": "^5.0.0",
35
+ "eslint-config-standard": "^13.0.1",
36
+ "nyc": "^15.1.0",
37
+ "proxyquire": "^2.1.3",
38
+ "semistandard": "^14.2.3"
39
+ },
40
+ "engines": {
41
+ "node": ">=8"
42
+ },
43
+ "types": "index.d.ts"
44
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 JD Ballard
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ # node-is-arrayish [![Travis-CI.org Build Status](https://img.shields.io/travis/Qix-/node-is-arrayish.svg?style=flat-square)](https://travis-ci.org/Qix-/node-is-arrayish) [![Coveralls.io Coverage Rating](https://img.shields.io/coveralls/Qix-/node-is-arrayish.svg?style=flat-square)](https://coveralls.io/r/Qix-/node-is-arrayish)
2
+ > Determines if an object can be used like an Array
3
+
4
+ ## Example
5
+ ```javascript
6
+ var isArrayish = require('is-arrayish');
7
+
8
+ isArrayish([]); // true
9
+ isArrayish({__proto__: []}); // true
10
+ isArrayish({}); // false
11
+ isArrayish({length:10}); // false
12
+ ```
13
+
14
+ ## License
15
+ Licensed under the [MIT License](http://opensource.org/licenses/MIT).
16
+ You can find a copy of it in [LICENSE](LICENSE).
@@ -0,0 +1,9 @@
1
+ module.exports = function isArrayish(obj) {
2
+ if (!obj || typeof obj === 'string') {
3
+ return false;
4
+ }
5
+
6
+ return obj instanceof Array || Array.isArray(obj) ||
7
+ (obj.length >= 0 && (obj.splice instanceof Function ||
8
+ (Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));
9
+ };
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "is-arrayish",
3
+ "description": "Determines if an object can be used as an array",
4
+ "version": "0.3.4",
5
+ "author": "Qix (http://github.com/qix-)",
6
+ "keywords": [
7
+ "is",
8
+ "array",
9
+ "duck",
10
+ "type",
11
+ "arrayish",
12
+ "similar",
13
+ "proto",
14
+ "prototype",
15
+ "type"
16
+ ],
17
+ "license": "MIT",
18
+ "scripts": {
19
+ "test": "mocha --require coffeescript/register ./test/**/*.coffee",
20
+ "lint": "zeit-eslint --ext .jsx,.js .",
21
+ "lint-staged": "git diff --diff-filter=ACMRT --cached --name-only '*.js' '*.jsx' | xargs zeit-eslint"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/qix-/node-is-arrayish.git"
26
+ },
27
+ "devDependencies": {
28
+ "@zeit/eslint-config-node": "^0.3.0",
29
+ "@zeit/git-hooks": "^0.1.4",
30
+ "coffeescript": "^2.3.1",
31
+ "coveralls": "^3.0.1",
32
+ "eslint": "^4.19.1",
33
+ "istanbul": "^0.4.5",
34
+ "mocha": "^5.2.0",
35
+ "should": "^13.2.1"
36
+ },
37
+ "eslintConfig": {
38
+ "extends": [
39
+ "@zeit/eslint-config-node"
40
+ ]
41
+ },
42
+ "git": {
43
+ "pre-commit": "lint-staged"
44
+ }
45
+ }
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.