eyeling 1.24.18 → 1.24.19

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/HANDBOOK.md CHANGED
@@ -3760,7 +3760,7 @@ When a user does want a portable link, the **Copy share link** button creates on
3760
3760
  - edited programs are shared with a compact compressed `?state=...` payload,
3761
3761
  - default option values are omitted from that payload to keep links small.
3762
3762
 
3763
- If a generated compact share link is still very long, the playground reveals an **Open shortener** option. The threshold is intentionally conservative, and the shortener handoff is explicit rather than automatic: the browser opens a TinyURL creation page with the generated share URL only after the user chooses that option. This avoids silently sending encoded editor content to a third-party service.
3763
+ If a generated compact share link is still very long, the playground reveals a **Create TinyURL** option. The threshold is intentionally conservative, and the shortener handoff is explicit rather than automatic: after the user chooses that option, the browser uses a TinyURL API token stored locally in that browser to create the short link and copy it to the clipboard. If no token is provided, or if the API request fails, the playground falls back to opening TinyURL and copying the long compact share link so it can be pasted manually. This avoids silently sending encoded editor content to a third-party service while still making the account-backed TinyURL workflow one click after setup.
3764
3764
 
3765
3765
  This keeps everyday use pleasant while preserving the important tutorial and issue-reporting workflow: a link can still capture the imported resource, the local editable overlay, background-knowledge mode, proof-comments mode, and HTTPS-dereferencing mode.
3766
3766
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.24.18",
3
+ "version": "1.24.19",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [
@@ -790,6 +790,29 @@ async function main() {
790
790
  })()`);
791
791
  }
792
792
 
793
+ async function createTinyUrlWithStubInPage(longUrl, token, response) {
794
+ const payload = JSON.stringify({ longUrl: String(longUrl), token: String(token), response });
795
+ return await evalInPage(`(async () => {
796
+ const args = ${payload};
797
+ const originalFetch = window.fetch;
798
+ let seen = null;
799
+ window.fetch = async (url, options) => {
800
+ seen = { url: String(url || ''), options: options || null };
801
+ return {
802
+ ok: true,
803
+ status: 200,
804
+ json: async () => args.response,
805
+ };
806
+ };
807
+ try {
808
+ const tinyUrl = await window.__eyelingPlaygroundCreateTinyUrl(args.longUrl, args.token);
809
+ return { tinyUrl, seen };
810
+ } finally {
811
+ window.fetch = originalFetch;
812
+ }
813
+ })()`);
814
+ }
815
+
793
816
  async function loadUrlIntoEditor(url) {
794
817
  const payload = JSON.stringify(String(url));
795
818
  await evalInPage(`(() => {
@@ -950,8 +973,16 @@ ${JSON.stringify(last, null, 2)}`);
950
973
  const longShare = await makeShareUrlDiagnosticsInPage();
951
974
  assert.ok(longShare.length > longShare.threshold, `Expected test share URL to exceed threshold (${longShare.length} <= ${longShare.threshold})`);
952
975
  assert.equal(longShare.needsShortener, true, 'Expected oversized share URL to request a shortener option');
953
- assert.match(longShare.shortenerUrl, /^https:\/\/tinyurl\.com\/create\.php\?url=/, 'Expected TinyURL create URL handoff');
976
+ assert.match(longShare.shortenerUrl, /^https:\/\/tinyurl\.com\/app\?url=/, 'Expected TinyURL app fallback handoff');
954
977
  assert.ok(longShare.shortenerUrl.includes(encodeURIComponent(longShare.url).slice(0, 40)), 'Expected shortener URL to carry the generated share URL');
978
+ const tinyUrlCreated = await createTinyUrlWithStubInPage(longShare.url, 'test-token-123', {
979
+ data: { tiny_url: 'https://tinyurl.com/eyeling-test' },
980
+ });
981
+ assert.equal(tinyUrlCreated.tinyUrl, 'https://tinyurl.com/eyeling-test', 'Expected TinyURL API response to produce a short URL');
982
+ assert.equal(tinyUrlCreated.seen.url, 'https://api.tinyurl.com/create', 'Expected TinyURL API create endpoint');
983
+ assert.equal(tinyUrlCreated.seen.options.method, 'POST', 'Expected TinyURL API POST request');
984
+ assert.equal(tinyUrlCreated.seen.options.headers.Authorization, 'Bearer test-token-123', 'Expected bearer token authorization');
985
+ assert.match(String(tinyUrlCreated.seen.options.body || ''), /"url":/, 'Expected TinyURL API body to include the long URL');
955
986
  endTest();
956
987
 
957
988
  // 7) log:query can produce Turtle; that should stay in plain source output without Markdown tabs.