@needle-tools/gltf-build-pipeline 2.2.1-alpha.2 → 2.2.1-alpha.4

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 (104) hide show
  1. package/.temp/Go2.bin +0 -0
  2. package/.temp/textures/0_1.exr +0 -0
  3. package/.temp/textures/1_1.jpg +0 -0
  4. package/CHANGELOG.md +395 -394
  5. package/README.md +35 -35
  6. package/dist/cache/cache.d.ts +54 -54
  7. package/dist/cache/cache.js +257 -257
  8. package/dist/cache/index.d.ts +1 -1
  9. package/dist/cache/index.js +1 -1
  10. package/dist/cli/index.d.ts +2 -2
  11. package/dist/cli/index.js +154 -154
  12. package/dist/config/index.d.ts +53 -53
  13. package/dist/config/index.js +152 -152
  14. package/dist/constants.d.ts +5 -5
  15. package/dist/constants.js +5 -5
  16. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.d.ts +24 -24
  17. package/dist/extensions/NEEDLE_compression_texture/NEEDLE_compression_texture.js +54 -54
  18. package/dist/extensions/NEEDLE_compression_texture/index.d.ts +1 -1
  19. package/dist/extensions/NEEDLE_compression_texture/index.js +1 -1
  20. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.d.ts +26 -26
  21. package/dist/extensions/NEEDLE_mesh_compression/NEEDLE_mesh_compression.js +85 -85
  22. package/dist/extensions/NEEDLE_mesh_compression/index.d.ts +1 -1
  23. package/dist/extensions/NEEDLE_mesh_compression/index.js +1 -1
  24. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.d.ts +27 -27
  25. package/dist/extensions/NEEDLE_opaque/NEEDLE_opaque.js +897 -897
  26. package/dist/extensions/NEEDLE_opaque/index.d.ts +3 -3
  27. package/dist/extensions/NEEDLE_opaque/index.js +28 -28
  28. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.d.ts +48 -48
  29. package/dist/extensions/NEEDLE_progressive/NEEDLE_progressive.js +69 -69
  30. package/dist/extensions/NEEDLE_progressive/index.d.ts +1 -1
  31. package/dist/extensions/NEEDLE_progressive/index.js +1 -1
  32. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.d.ts +23 -23
  33. package/dist/extensions/NEEDLE_progressive_mesh_settings/index.js +41 -41
  34. package/dist/extensions/NEEDLE_progressive_texture_settings/index.d.ts +25 -25
  35. package/dist/extensions/NEEDLE_progressive_texture_settings/index.js +67 -67
  36. package/dist/extensions/index.d.ts +7 -7
  37. package/dist/extensions/index.js +17 -17
  38. package/dist/extensions/utils.d.ts +6 -6
  39. package/dist/extensions/utils.js +72 -72
  40. package/dist/functions/weld.3.d.ts +76 -76
  41. package/dist/functions/weld.3.js +414 -414
  42. package/dist/index.d.ts +8 -8
  43. package/dist/index.js +8 -8
  44. package/dist/scripts/index.d.ts +2 -2
  45. package/dist/scripts/index.js +2 -2
  46. package/dist/scripts/pack-gltf.d.ts +16 -16
  47. package/dist/scripts/pack-gltf.js +120 -120
  48. package/dist/scripts/stats.d.ts +2 -2
  49. package/dist/scripts/stats.js +18 -18
  50. package/dist/transforms/index.d.ts +9 -9
  51. package/dist/transforms/index.js +9 -9
  52. package/dist/transforms/needle_animation_transform.d.ts +2 -2
  53. package/dist/transforms/needle_animation_transform.js +5 -5
  54. package/dist/transforms/needle_asset.d.ts +3 -3
  55. package/dist/transforms/needle_asset.js +35 -35
  56. package/dist/transforms/needle_common.d.ts +16 -16
  57. package/dist/transforms/needle_common.js +1 -1
  58. package/dist/transforms/needle_mesh_transform.d.ts +10 -10
  59. package/dist/transforms/needle_mesh_transform.js +140 -140
  60. package/dist/transforms/needle_progressive.d.ts +42 -42
  61. package/dist/transforms/needle_progressive.js +933 -921
  62. package/dist/transforms/needle_texture_transform.d.ts +13 -13
  63. package/dist/transforms/needle_texture_transform.js +202 -196
  64. package/dist/transforms/needle_toktx.d.ts +25 -25
  65. package/dist/transforms/needle_toktx.js +230 -230
  66. package/dist/transforms/needle_webp.d.ts +13 -13
  67. package/dist/transforms/needle_webp.js +37 -37
  68. package/dist/transforms/toktx.d.ts +52 -52
  69. package/dist/transforms/toktx.js +221 -221
  70. package/dist/transforms/toktx_types.d.ts +78 -78
  71. package/dist/transforms/toktx_types.js +62 -62
  72. package/dist/transforms/util.d.ts +21 -21
  73. package/dist/transforms/util.js +90 -90
  74. package/dist/utils/compression_utils.d.ts +2 -2
  75. package/dist/utils/compression_utils.js +6 -6
  76. package/dist/utils/fileutils.d.ts +6 -6
  77. package/dist/utils/fileutils.js +141 -141
  78. package/dist/utils/guid.d.ts +1 -1
  79. package/dist/utils/guid.js +5 -5
  80. package/dist/utils/index.d.ts +10 -9
  81. package/dist/utils/index.js +10 -9
  82. package/dist/utils/merge.d.ts +12 -12
  83. package/dist/utils/merge.js +31 -31
  84. package/dist/utils/mesh.d.ts +13 -13
  85. package/dist/utils/mesh.js +107 -107
  86. package/dist/utils/nodeio.d.ts +5 -5
  87. package/dist/utils/nodeio.js +14 -14
  88. package/dist/utils/stats.d.ts +54 -53
  89. package/dist/utils/stats.js +191 -166
  90. package/dist/utils/texture.d.ts +2 -2
  91. package/dist/utils/texture.js +8 -8
  92. package/dist/utils/validate.d.ts +5 -0
  93. package/dist/utils/validate.js +16 -0
  94. package/dist/utils/version.d.ts +1 -1
  95. package/dist/utils/version.js +5 -5
  96. package/package.json +77 -76
  97. package/scripts/clear-caches.mjs +3 -3
  98. package/scripts/defaults.mjs +11 -11
  99. package/scripts/fileutils.mjs +5 -5
  100. package/scripts/index.mjs +41 -41
  101. package/scripts/limit-caches.mjs +3 -3
  102. package/scripts/make-progressive.mjs +16 -16
  103. package/scripts/pack-gltf.mjs +107 -107
  104. package/tsconfig.json +19 -19
@@ -1,257 +1,257 @@
1
- import { ExtensibleProperty, Texture, Primitive, Accessor, Mesh } from "@gltf-transform/core";
2
- import tmp from 'tmp';
3
- import fs, { statSync } from 'fs';
4
- import path from 'path';
5
- import { getVersion } from "../utils/version.js";
6
- // import * as CHECKDISCSPACE from 'check-disk-space'
7
- /**
8
- * Get the available space on the cache directory in bytes.
9
- */
10
- // export async function getCacheAvailableSpaceOnDisc(): Promise<number> {
11
- // try {
12
- // const dir = getCacheDirectory();
13
- // const res = await CHECKDISCSPACE.default(dir).catch(() => { return { free: 0 } });
14
- // return res.free;
15
- // }
16
- // catch (e) {
17
- // console.error(`Error checking disk space: ${e}`);
18
- // }
19
- // return 0;
20
- // }
21
- const buildPipelineVersion = getVersion(false);
22
- const debugLogs = process.argv.includes("--debug");
23
- /**
24
- * Clear the cache.
25
- * This will remove all files in the cache directory.
26
- */
27
- export function clearCache(logger) {
28
- const dir = getCacheDirectory(true);
29
- fs.rmSync(dir, { recursive: true });
30
- if (!logger)
31
- console.log(`Cleared cache at ${dir}`);
32
- else
33
- logger.info(`Cleared cache at ${dir}`);
34
- }
35
- export const cacheSizeLimit = 1024;
36
- /**
37
- * Ensure that the cache size does not exceed the given maximum size in MB.
38
- * @param maxSizeMB The maximum size in MB.
39
- */
40
- export function limitCacheSize(maxSizeMB = cacheSizeLimit) {
41
- const dir = getCacheDirectory(true);
42
- console.log(`Limit cache size to ${maxSizeMB.toFixed(2)} MB at ${dir}...`);
43
- let totalSize = 0;
44
- function recurseDirectories(dir) {
45
- const files = fs.readdirSync(dir).map(file => {
46
- const path = `${dir}/${file}`;
47
- const stats = statSync(path);
48
- if (stats.isDirectory()) {
49
- recurseDirectories(path);
50
- }
51
- else {
52
- totalSize += stats.size;
53
- }
54
- return { path, size: stats.size };
55
- });
56
- return files;
57
- }
58
- const files = recurseDirectories(dir);
59
- const maxSizeInBytes = maxSizeMB * 1024 * 1024;
60
- console.log(`Current cache size is ${(totalSize / (1024 * 1024)).toFixed(1)} MB`);
61
- if (totalSize < maxSizeInBytes)
62
- return;
63
- files.sort((a, b) => {
64
- const mtimeA = fs.statSync(a.path).mtimeMs;
65
- const mtimeB = fs.statSync(b.path).mtimeMs;
66
- return mtimeA - mtimeB;
67
- });
68
- const targetSize = maxSizeInBytes * 0.9;
69
- // remove oldest files first
70
- while (totalSize > targetSize) {
71
- const file = files.shift();
72
- if (!file)
73
- break;
74
- if (fs.statSync(file.path).isDirectory())
75
- continue;
76
- console.log(`Removing cache file ${file.path}...`);
77
- fs.rmSync(file.path);
78
- totalSize -= file.size;
79
- }
80
- console.log(`Cache size reduced to ${(totalSize / (1024 * 1024)).toFixed(1)} MB`);
81
- }
82
- /**
83
- * Add data to the cache.
84
- * @param key The key to store the data under.
85
- * @param bytes The data to store as a Uint8Array.
86
- */
87
- export function addToCache(key, bytes) {
88
- const dir = getCacheDirectory();
89
- const path = `${dir}/${key}.bin`;
90
- if (debugLogs)
91
- console.log(`Added ${(bytes.byteLength / 1024).toFixed(1)} KB to cache at \"${path}\"`);
92
- fs.writeFileSync(path, bytes);
93
- }
94
- /**
95
- * Try to get the data from the cache.
96
- * @param key The key to look up.
97
- * @returns The data as a Uint8Array or null if not found.
98
- * @throws If the cache file is corrupted.
99
- */
100
- export function tryGetFromCache(key) {
101
- const dir = getCacheDirectory();
102
- const path = `${dir}/${key}.bin`;
103
- if (fs.existsSync(path)) {
104
- const bytes = fs.readFileSync(path);
105
- return bytes;
106
- }
107
- return null;
108
- }
109
- /** Add meta data to the cache.
110
- * @param key The key to store the meta data for.
111
- * @param meta The meta data object to store. It will be serialized to JSON and stored in a file with the key as the name with the extension ".meta".
112
- */
113
- export function addMetaToCache(key, meta) {
114
- const dir = getCacheDirectory();
115
- const metaPath = `${dir}/${key}.meta`;
116
- meta['needle-build-pipeline:version'] = buildPipelineVersion;
117
- fs.writeFileSync(metaPath, JSON.stringify(meta));
118
- }
119
- /** Try to get the meta data from the cache.
120
- * @param key The key to look up.
121
- * @param ignoreVersion If true, the version check is skipped. If false, the version must match the current build pipeline version.
122
- * @returns The meta data object or null if not found.
123
- */
124
- export function tryGetMetaFromCache(key, ignoreVersion = false) {
125
- try {
126
- const dir = getCacheDirectory();
127
- const path = `${dir}/${key}.meta`;
128
- if (fs.existsSync(path)) {
129
- const bytes = fs.readFileSync(path);
130
- if (bytes?.length > 0) {
131
- const text = bytes.toString('utf-8');
132
- if (text) {
133
- const obj = JSON.parse(text);
134
- if (ignoreVersion)
135
- return obj;
136
- if (obj['needle-build-pipeline:version'] === buildPipelineVersion)
137
- return obj;
138
- }
139
- }
140
- }
141
- return null;
142
- }
143
- catch (e) {
144
- console.error(`Error reading cache meta: ${e.message}`);
145
- return null;
146
- }
147
- }
148
- /**
149
- * Get the cache key for a property.
150
- * @param property The property to get the key for.
151
- * @returns The key as a string.
152
- */
153
- export function getKey(property) {
154
- let prefix = "prop";
155
- if (property instanceof Texture) {
156
- prefix = "image";
157
- }
158
- let hash = getHash(property);
159
- const key = `${prefix}-${hash}`;
160
- return key;
161
- }
162
- export function getKeyWithHash(property) {
163
- let prefix = "prop";
164
- if (property instanceof Texture) {
165
- prefix = "image";
166
- }
167
- let hash = getHash(property);
168
- const key = `${prefix}-${hash}`;
169
- return { key, hash };
170
- }
171
- /**
172
- * Get the hash for a property or an object.
173
- * @param property The property to get the hash for.
174
- * @param level The current level of recursion.
175
- * @returns The hash as a number.
176
- */
177
- export function getHash(property, level = 0) {
178
- let hash = 0;
179
- if (property instanceof ExtensibleProperty) {
180
- const extensions = property.listExtensions();
181
- const extras = property.getExtras();
182
- // const slots = listTextureSlots(doc, texture);
183
- // const channels = getTextureChannelMask(doc, texture);
184
- hash += hashObject({
185
- extensions,
186
- extras,
187
- });
188
- if (property instanceof Texture) {
189
- const image = property.getImage();
190
- const bytes = image?.buffer;
191
- if (bytes)
192
- hash += hashBuffer(bytes, image.byteOffset, image.byteLength);
193
- }
194
- else if (property instanceof Mesh) {
195
- const weights = property.getWeights();
196
- hash += hashObject(weights);
197
- const primitives = property.listPrimitives();
198
- for (const prim of primitives)
199
- hash += getHash(prim, level + 1);
200
- }
201
- else if (property instanceof Primitive) {
202
- const indices = property.getIndices();
203
- const attributes = property.listAttributes();
204
- const targets = property.listTargets();
205
- // TODO: hash buffer view if possible
206
- const semantics = property.listSemantics().map(s => {
207
- return { name: s, array: property.getAttribute(s).getArray() };
208
- });
209
- hash += hashObject({
210
- indices,
211
- attributes,
212
- targets,
213
- semantics
214
- });
215
- }
216
- }
217
- else {
218
- hash += hashObject(property);
219
- }
220
- return hash;
221
- }
222
- const cleanBuildPipelineVersion = getVersion(false).replace(/[^a-zA-Z0-9]/g, "_");
223
- function getCacheDirectory(root) {
224
- const tmpDir = path.join(tmp.tmpdir, "Needle", "build-pipeline-cache", root ? "" : cleanBuildPipelineVersion);
225
- if (!fs.existsSync(tmpDir)) {
226
- fs.mkdirSync(tmpDir, { recursive: true });
227
- }
228
- return tmpDir;
229
- }
230
- function hashObject(obj) {
231
- if (obj instanceof Accessor) {
232
- const buffer = obj.getArray();
233
- return hashBuffer(buffer);
234
- }
235
- else if (obj == null) {
236
- return 0;
237
- }
238
- const str = JSON.stringify(obj);
239
- return hashString(str);
240
- }
241
- function hashBuffer(buffer, offset, length) {
242
- let hash = 0;
243
- const view = new Uint8Array(buffer, offset, length);
244
- for (let i = 0; i < view.length; i++) {
245
- hash = ((hash << 5) - hash) + view[i];
246
- hash |= 0;
247
- }
248
- return hash;
249
- }
250
- function hashString(str) {
251
- let hash = 0;
252
- for (let i = 0; i < str.length; i++) {
253
- hash = ((hash << 5) - hash) + str.charCodeAt(i);
254
- hash |= 0;
255
- }
256
- return hash;
257
- }
1
+ import { ExtensibleProperty, Texture, Primitive, Accessor, Mesh } from "@gltf-transform/core";
2
+ import tmp from 'tmp';
3
+ import fs, { statSync } from 'fs';
4
+ import path from 'path';
5
+ import { getVersion } from "../utils/version.js";
6
+ // import * as CHECKDISCSPACE from 'check-disk-space'
7
+ /**
8
+ * Get the available space on the cache directory in bytes.
9
+ */
10
+ // export async function getCacheAvailableSpaceOnDisc(): Promise<number> {
11
+ // try {
12
+ // const dir = getCacheDirectory();
13
+ // const res = await CHECKDISCSPACE.default(dir).catch(() => { return { free: 0 } });
14
+ // return res.free;
15
+ // }
16
+ // catch (e) {
17
+ // console.error(`Error checking disk space: ${e}`);
18
+ // }
19
+ // return 0;
20
+ // }
21
+ const buildPipelineVersion = getVersion(false);
22
+ const debugLogs = process.argv.includes("--debug");
23
+ /**
24
+ * Clear the cache.
25
+ * This will remove all files in the cache directory.
26
+ */
27
+ export function clearCache(logger) {
28
+ const dir = getCacheDirectory(true);
29
+ fs.rmSync(dir, { recursive: true });
30
+ if (!logger)
31
+ console.log(`Cleared cache at ${dir}`);
32
+ else
33
+ logger.info(`Cleared cache at ${dir}`);
34
+ }
35
+ export const cacheSizeLimit = 1024;
36
+ /**
37
+ * Ensure that the cache size does not exceed the given maximum size in MB.
38
+ * @param maxSizeMB The maximum size in MB.
39
+ */
40
+ export function limitCacheSize(maxSizeMB = cacheSizeLimit) {
41
+ const dir = getCacheDirectory(true);
42
+ console.log(`Limit cache size to ${maxSizeMB.toFixed(2)} MB at ${dir}...`);
43
+ let totalSize = 0;
44
+ function recurseDirectories(dir) {
45
+ const files = fs.readdirSync(dir).map(file => {
46
+ const path = `${dir}/${file}`;
47
+ const stats = statSync(path);
48
+ if (stats.isDirectory()) {
49
+ recurseDirectories(path);
50
+ }
51
+ else {
52
+ totalSize += stats.size;
53
+ }
54
+ return { path, size: stats.size };
55
+ });
56
+ return files;
57
+ }
58
+ const files = recurseDirectories(dir);
59
+ const maxSizeInBytes = maxSizeMB * 1024 * 1024;
60
+ console.log(`Current cache size is ${(totalSize / (1024 * 1024)).toFixed(1)} MB`);
61
+ if (totalSize < maxSizeInBytes)
62
+ return;
63
+ files.sort((a, b) => {
64
+ const mtimeA = fs.statSync(a.path).mtimeMs;
65
+ const mtimeB = fs.statSync(b.path).mtimeMs;
66
+ return mtimeA - mtimeB;
67
+ });
68
+ const targetSize = maxSizeInBytes * 0.9;
69
+ // remove oldest files first
70
+ while (totalSize > targetSize) {
71
+ const file = files.shift();
72
+ if (!file)
73
+ break;
74
+ if (fs.statSync(file.path).isDirectory())
75
+ continue;
76
+ console.log(`Removing cache file ${file.path}...`);
77
+ fs.rmSync(file.path);
78
+ totalSize -= file.size;
79
+ }
80
+ console.log(`Cache size reduced to ${(totalSize / (1024 * 1024)).toFixed(1)} MB`);
81
+ }
82
+ /**
83
+ * Add data to the cache.
84
+ * @param key The key to store the data under.
85
+ * @param bytes The data to store as a Uint8Array.
86
+ */
87
+ export function addToCache(key, bytes) {
88
+ const dir = getCacheDirectory();
89
+ const path = `${dir}/${key}.bin`;
90
+ if (debugLogs)
91
+ console.log(`Added ${(bytes.byteLength / 1024).toFixed(1)} KB to cache at \"${path}\"`);
92
+ fs.writeFileSync(path, bytes);
93
+ }
94
+ /**
95
+ * Try to get the data from the cache.
96
+ * @param key The key to look up.
97
+ * @returns The data as a Uint8Array or null if not found.
98
+ * @throws If the cache file is corrupted.
99
+ */
100
+ export function tryGetFromCache(key) {
101
+ const dir = getCacheDirectory();
102
+ const path = `${dir}/${key}.bin`;
103
+ if (fs.existsSync(path)) {
104
+ const bytes = fs.readFileSync(path);
105
+ return bytes;
106
+ }
107
+ return null;
108
+ }
109
+ /** Add meta data to the cache.
110
+ * @param key The key to store the meta data for.
111
+ * @param meta The meta data object to store. It will be serialized to JSON and stored in a file with the key as the name with the extension ".meta".
112
+ */
113
+ export function addMetaToCache(key, meta) {
114
+ const dir = getCacheDirectory();
115
+ const metaPath = `${dir}/${key}.meta`;
116
+ meta['needle-build-pipeline:version'] = buildPipelineVersion;
117
+ fs.writeFileSync(metaPath, JSON.stringify(meta));
118
+ }
119
+ /** Try to get the meta data from the cache.
120
+ * @param key The key to look up.
121
+ * @param ignoreVersion If true, the version check is skipped. If false, the version must match the current build pipeline version.
122
+ * @returns The meta data object or null if not found.
123
+ */
124
+ export function tryGetMetaFromCache(key, ignoreVersion = false) {
125
+ try {
126
+ const dir = getCacheDirectory();
127
+ const path = `${dir}/${key}.meta`;
128
+ if (fs.existsSync(path)) {
129
+ const bytes = fs.readFileSync(path);
130
+ if (bytes?.length > 0) {
131
+ const text = bytes.toString('utf-8');
132
+ if (text) {
133
+ const obj = JSON.parse(text);
134
+ if (ignoreVersion)
135
+ return obj;
136
+ if (obj['needle-build-pipeline:version'] === buildPipelineVersion)
137
+ return obj;
138
+ }
139
+ }
140
+ }
141
+ return null;
142
+ }
143
+ catch (e) {
144
+ console.error(`Error reading cache meta: ${e.message}`);
145
+ return null;
146
+ }
147
+ }
148
+ /**
149
+ * Get the cache key for a property.
150
+ * @param property The property to get the key for.
151
+ * @returns The key as a string.
152
+ */
153
+ export function getKey(property) {
154
+ let prefix = "prop";
155
+ if (property instanceof Texture) {
156
+ prefix = "image";
157
+ }
158
+ let hash = getHash(property);
159
+ const key = `${prefix}-${hash}`;
160
+ return key;
161
+ }
162
+ export function getKeyWithHash(property) {
163
+ let prefix = "prop";
164
+ if (property instanceof Texture) {
165
+ prefix = "image";
166
+ }
167
+ let hash = getHash(property);
168
+ const key = `${prefix}-${hash}`;
169
+ return { key, hash };
170
+ }
171
+ /**
172
+ * Get the hash for a property or an object.
173
+ * @param property The property to get the hash for.
174
+ * @param level The current level of recursion.
175
+ * @returns The hash as a number.
176
+ */
177
+ export function getHash(property, level = 0) {
178
+ let hash = 0;
179
+ if (property instanceof ExtensibleProperty) {
180
+ const extensions = property.listExtensions();
181
+ const extras = property.getExtras();
182
+ // const slots = listTextureSlots(doc, texture);
183
+ // const channels = getTextureChannelMask(doc, texture);
184
+ hash += hashObject({
185
+ extensions,
186
+ extras,
187
+ });
188
+ if (property instanceof Texture) {
189
+ const image = property.getImage();
190
+ const bytes = image?.buffer;
191
+ if (bytes)
192
+ hash += hashBuffer(bytes, image.byteOffset, image.byteLength);
193
+ }
194
+ else if (property instanceof Mesh) {
195
+ const weights = property.getWeights();
196
+ hash += hashObject(weights);
197
+ const primitives = property.listPrimitives();
198
+ for (const prim of primitives)
199
+ hash += getHash(prim, level + 1);
200
+ }
201
+ else if (property instanceof Primitive) {
202
+ const indices = property.getIndices();
203
+ const attributes = property.listAttributes();
204
+ const targets = property.listTargets();
205
+ // TODO: hash buffer view if possible
206
+ const semantics = property.listSemantics().map(s => {
207
+ return { name: s, array: property.getAttribute(s).getArray() };
208
+ });
209
+ hash += hashObject({
210
+ indices,
211
+ attributes,
212
+ targets,
213
+ semantics
214
+ });
215
+ }
216
+ }
217
+ else {
218
+ hash += hashObject(property);
219
+ }
220
+ return hash;
221
+ }
222
+ const cleanBuildPipelineVersion = getVersion(false).replace(/[^a-zA-Z0-9]/g, "_");
223
+ function getCacheDirectory(root) {
224
+ const tmpDir = path.join(tmp.tmpdir, "Needle", "build-pipeline-cache", root ? "" : cleanBuildPipelineVersion);
225
+ if (!fs.existsSync(tmpDir)) {
226
+ fs.mkdirSync(tmpDir, { recursive: true });
227
+ }
228
+ return tmpDir;
229
+ }
230
+ function hashObject(obj) {
231
+ if (obj instanceof Accessor) {
232
+ const buffer = obj.getArray();
233
+ return hashBuffer(buffer);
234
+ }
235
+ else if (obj == null) {
236
+ return 0;
237
+ }
238
+ const str = JSON.stringify(obj);
239
+ return hashString(str);
240
+ }
241
+ function hashBuffer(buffer, offset, length) {
242
+ let hash = 0;
243
+ const view = new Uint8Array(buffer, offset, length);
244
+ for (let i = 0; i < view.length; i++) {
245
+ hash = ((hash << 5) - hash) + view[i];
246
+ hash |= 0;
247
+ }
248
+ return hash;
249
+ }
250
+ function hashString(str) {
251
+ let hash = 0;
252
+ for (let i = 0; i < str.length; i++) {
253
+ hash = ((hash << 5) - hash) + str.charCodeAt(i);
254
+ hash |= 0;
255
+ }
256
+ return hash;
257
+ }
@@ -1 +1 @@
1
- export * from "./cache.js";
1
+ export * from "./cache.js";
@@ -1 +1 @@
1
- export * from "./cache.js";
1
+ export * from "./cache.js";
@@ -1,2 +1,2 @@
1
- #! /usr/bin/env node
2
- export {};
1
+ #! /usr/bin/env node
2
+ export {};