syncrbx 1.0.0 → 1.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.
package/converters.js CHANGED
@@ -68,6 +68,28 @@ function determineScriptType(filename) {
68
68
  return null;
69
69
  }
70
70
 
71
+ // Class a file becomes in Studio, judged by its name alone (the file may
72
+ // already be deleted). Returns ANY_CLASS for .model.json, whose class is inside
73
+ // the file, and null for files SyncRbx does not sync (README.md, meta files...).
74
+ const ANY_CLASS = '*';
75
+
76
+ function classFromFileName(filename) {
77
+ const lower = filename.toLowerCase();
78
+ if (lower.endsWith('.meta.json') || lower === 'meta.json') return null;
79
+ if (lower.endsWith('.model.json')) return ANY_CLASS;
80
+ if (lower.endsWith('.remoteevent')) return 'RemoteEvent';
81
+ if (lower.endsWith('.remotefunction')) return 'RemoteFunction';
82
+ if (lower.endsWith('.bindableevent')) return 'BindableEvent';
83
+ if (lower.endsWith('.bindablefunction')) return 'BindableFunction';
84
+ if (lower.endsWith('.txt')) return 'StringValue';
85
+ if (lower.endsWith('.json')) return 'ModuleScript';
86
+ return determineScriptType(lower);
87
+ }
88
+
89
+ function isInitFile(filename) {
90
+ return filename.startsWith('init.') && (filename.endsWith('.lua') || filename.endsWith('.luau'));
91
+ }
92
+
71
93
  // Phase 4 - #7: File checksum
72
94
  function fileChecksum(filePath) {
73
95
  try {
@@ -298,7 +320,8 @@ function instanceToFile(instanceData) {
298
320
  const name = instanceData.name || instanceData.Name || 'Untitled';
299
321
  const className = instanceData.className || instanceData.ClassName || 'Folder';
300
322
  const source = instanceData.source || (instanceData.Properties && instanceData.Properties.Source) || '';
301
- const value = instanceData.value || (instanceData.Properties && instanceData.Properties.Value) || '';
323
+ // ?? keeps false and 0, which || would turn into ''.
324
+ const value = instanceData.value ?? (instanceData.Properties && instanceData.Properties.Value) ?? '';
302
325
 
303
326
  if (className === 'Folder') {
304
327
  return { fileName: name, content: null, isDirectory: true };
@@ -384,8 +407,11 @@ module.exports = {
384
407
  STARTER_PLAYER_CHILDREN,
385
408
  KNOWN_EXTENSIONS,
386
409
  VALUE_CLASSES,
410
+ ANY_CLASS,
387
411
  stripExtension,
388
412
  determineScriptType,
413
+ classFromFileName,
414
+ isInitFile,
389
415
  jsonToLuaTable,
390
416
  convertFile,
391
417
  processDirectory,