braid-text 0.2.93 → 0.2.95

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 (2) hide show
  1. package/index.js +7 -37
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -74,6 +74,11 @@ function create_braid_text() {
74
74
 
75
75
  var resource = (typeof a == 'string') ? await get_resource(a) : a
76
76
 
77
+ if (!resource.meta.fork_point && options.fork_point_hint) {
78
+ resource.meta.fork_point = options.fork_point_hint
79
+ resource.change_meta()
80
+ }
81
+
77
82
  function extend_frontier(frontier, version, parents) {
78
83
  // special case:
79
84
  // if current frontier has all parents,
@@ -1245,42 +1250,6 @@ function create_braid_text() {
1245
1250
  await fs.promises.mkdir(braid_text.db_folder, { recursive: true });
1246
1251
  await fs.promises.mkdir(`${braid_text.db_folder}/.meta`, { recursive: true })
1247
1252
 
1248
- // 0.0.13 -> 0.0.14
1249
- // look for files with key-encodings over max_encoded_key_size,
1250
- // and convert them using the new method
1251
- // for (let x of await fs.promises.readdir(braid_text.db_folder)) {
1252
- // let k = x.replace(/(_[0-9a-f]{64})?\.\w+$/, '')
1253
- // if (k.length > max_encoded_key_size) {
1254
- // k = decode_filename(k)
1255
-
1256
- // await fs.promises.rename(`${braid_text.db_folder}/${x}`, `${braid_text.db_folder}/${encode_filename(k)}${x.match(/\.\w+$/)[0]}`)
1257
- // await fs.promises.writeFile(`${braid_text.db_folder}/${encode_filename(k)}.name`, k)
1258
- // }
1259
- // }
1260
-
1261
- // 0.0.14 -> 0.0.15
1262
- // basically convert the 0.0.14 files back
1263
- let convert_us = {}
1264
- for (let x of await fs.promises.readdir(braid_text.db_folder)) {
1265
- if (x.endsWith('.name')) {
1266
- let encoded = convert_us[x.slice(0, -'.name'.length)] = encode_filename(await fs.promises.readFile(`${braid_text.db_folder}/${x}`, { encoding: 'utf8' }))
1267
- if (encoded.length > max_encoded_key_size) {
1268
- console.log(`trying to convert file to new format, but the key is too big: ${braid_text.db_folder}/${x}`)
1269
- process.exit()
1270
- }
1271
- if (braid_text.verbose) console.log(`deleting: ${braid_text.db_folder}/${x}`)
1272
- await fs.promises.unlink(`${braid_text.db_folder}/${x}`)
1273
- }
1274
- }
1275
- if (Object.keys(convert_us).length) {
1276
- for (let x of await fs.promises.readdir(braid_text.db_folder)) {
1277
- let [_, k, num] = x.match(/^(.*)\.(\d+)$/s)
1278
- if (!convert_us[k]) continue
1279
- if (braid_text.verbose) console.log(`renaming: ${braid_text.db_folder}/${x} -> ${braid_text.db_folder}/${convert_us[k]}.${num}`)
1280
- if (convert_us[k]) await fs.promises.rename(`${braid_text.db_folder}/${x}`, `${braid_text.db_folder}/${convert_us[k]}.${num}`)
1281
- }
1282
- }
1283
-
1284
1253
  // Populate key_to_filename mapping from existing files
1285
1254
  var files = (await fs.promises.readdir(braid_text.db_folder))
1286
1255
  .filter(x => /\.\d+$/.test(x))
@@ -1302,6 +1271,7 @@ function create_braid_text() {
1302
1271
  }
1303
1272
 
1304
1273
  async function file_sync(key, process_delta, get_init, set_meta, get_meta) {
1274
+ await db_folder_init()
1305
1275
  let encoded = encode_filename(key)
1306
1276
 
1307
1277
  if (encoded.length > max_encoded_key_size) throw new Error(`invalid key: too long (max ${max_encoded_key_size})`)
@@ -2726,9 +2696,9 @@ function create_braid_text() {
2726
2696
 
2727
2697
  braid_text.get_resource = get_resource
2728
2698
 
2699
+ braid_text.db_folder_init = db_folder_init
2729
2700
  braid_text.encode_filename = encode_filename
2730
2701
  braid_text.decode_filename = decode_filename
2731
- braid_text.get_files_for_key = get_files_for_key
2732
2702
 
2733
2703
  braid_text.dt_get = dt_get
2734
2704
  braid_text.dt_get_patches = dt_get_patches
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.2.93",
3
+ "version": "0.2.95",
4
4
  "description": "Library for collaborative text over http using braid.",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braid-text",
7
7
  "homepage": "https://braid.org",
8
8
  "dependencies": {
9
9
  "@braid.org/diamond-types-node": "^2.0.0",
10
- "braid-http": "~1.3.83",
10
+ "braid-http": "~1.3.84",
11
11
  "url-file-db": "^0.0.25"
12
12
  }
13
13
  }