tsquare 0.6.0 → 0.6.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.
- package/CHANGELOG.md +4 -0
- package/dist/index.js +10 -3
- package/dist/link-prefix.d.ts +11 -0
- package/dist/playground/playground.js +17 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
- **Fix: the playground opens 0.6.0 share links.** 0.6.0 made share links with the new `y` prefix, but its playground only opened links starting with `z`. Opening a new share link left the editor on whatever it showed before. The prefixes now live in one place that both the library and the playground use, and a test guards it. Links themselves didn't change: every `y` link made by 0.6.0 opens correctly now.
|
|
6
|
+
|
|
3
7
|
## 0.6.0
|
|
4
8
|
|
|
5
9
|
### Flow arrows
|
package/dist/index.js
CHANGED
|
@@ -24,15 +24,22 @@ import {
|
|
|
24
24
|
|
|
25
25
|
// src/share.ts
|
|
26
26
|
import { deflateRawSync, inflateRawSync } from "node:zlib";
|
|
27
|
+
|
|
28
|
+
// src/link-prefix.ts
|
|
29
|
+
var LINK_PREFIX = "y";
|
|
30
|
+
var LEGACY_LINK_PREFIX = "z";
|
|
31
|
+
var isLinkData = (data) => data.startsWith(LINK_PREFIX) || data.startsWith(LEGACY_LINK_PREFIX);
|
|
32
|
+
|
|
33
|
+
// src/share.ts
|
|
27
34
|
var MAX_SHARED_TEXT = 64e3;
|
|
28
35
|
function encodeWireframe(text) {
|
|
29
|
-
return
|
|
36
|
+
return LINK_PREFIX + deflateRawSync(Buffer.from(text, "utf8"), { level: 9 }).toString("base64url");
|
|
30
37
|
}
|
|
31
38
|
function decodeWireframe(data) {
|
|
32
39
|
const prefix = data.slice(0, 1);
|
|
33
|
-
if (
|
|
40
|
+
if (!isLinkData(data)) throw new Error(`unknown encoding "${prefix}" (expected a "${LINK_PREFIX}" or "${LEGACY_LINK_PREFIX}" prefix)`);
|
|
34
41
|
const text = inflateRawSync(Buffer.from(data.slice(1), "base64url"), { maxOutputLength: MAX_SHARED_TEXT }).toString("utf8");
|
|
35
|
-
return upgradeWireframe(text, { fromLink: prefix ===
|
|
42
|
+
return upgradeWireframe(text, { fromLink: prefix === LEGACY_LINK_PREFIX });
|
|
36
43
|
}
|
|
37
44
|
export {
|
|
38
45
|
DEVICES,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Link prefixes (see share.ts): the letter in front of a link's data names the language version
|
|
3
|
+
* its text was written in. Shared by the library and the playground's browser code, so a new
|
|
4
|
+
* prefix can't be added to one and missed in the other.
|
|
5
|
+
*/
|
|
6
|
+
/** What links are made with today: 0.6.0 and later. */
|
|
7
|
+
export declare const LINK_PREFIX = "y";
|
|
8
|
+
/** Links made before 0.6.0; decoded with the old rules (upgradeWireframe's fromLink). */
|
|
9
|
+
export declare const LEGACY_LINK_PREFIX = "z";
|
|
10
|
+
/** Whether `data` (a render URL's path segment or a share link's fragment, without "#") is link data. */
|
|
11
|
+
export declare const isLinkData: (data: string) => boolean;
|