eyeling 1.24.15 → 1.24.17

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
@@ -3731,7 +3731,7 @@ This matters because the playground is not just a text box plus a submit button.
3731
3731
 
3732
3732
  The output behavior also adapts to the kind of N3 program being run. In some cases the natural result is a streamed list of derived triples. In others, such as programs using output-oriented constructs like `log:outputString`, a rendered text result is more appropriate. The playground supports both styles.
3733
3733
 
3734
- For Markdown-oriented `log:outputString` examples, the output pane has two views: a rendered Markdown view and a Markdown source view. The rendered view is selected by default when the output is text intended for presentation, while the source view keeps the exact generated Markdown available for copying, inspection, or comparison.
3734
+ For Markdown-oriented `log:outputString` examples, the output pane has two views: a rendered Markdown view and a Markdown source view. Those tabs appear only when the actual output looks like Markdown; Turtle or other plain output stays in the source editor without the Markdown toggle. The rendered view is selected by default for Markdown output, while the source view keeps the exact generated Markdown available for copying, inspection, or comparison.
3735
3735
 
3736
3736
  Repository example reports often contain relative source links that are written for the checked-in files under `examples/output/*.md`. When such an example is loaded into the playground from a raw URL, the rendered Markdown view resolves those relative links against the corresponding static output page rather than against `/playground`, so links like `../name.n3` and `../input/name.trig` continue to point to the intended example files.
3737
3737
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.24.15",
3
+ "version": "1.24.17",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [
@@ -24,8 +24,8 @@ const C = TTY
24
24
  : { g: '', r: '', y: '', dim: '', n: '' };
25
25
  const msTag = (ms) => `${C.dim}(${ms} ms)${C.n}`;
26
26
 
27
- const TOTAL_TESTS = 11;
28
- const idxWidth = String(TOTAL_TESTS).length;
27
+ const TOTAL_TESTS = (fs.readFileSync(__filename, 'utf8').match(/^\s*beginTest\(/gm) || []).length;
28
+ const idxWidth = String(Math.max(1, TOTAL_TESTS)).length;
29
29
  let passed = 0;
30
30
  let failed = 0;
31
31
  let currentTest = null;
@@ -816,6 +816,13 @@ ${JSON.stringify(last, null, 2)}`);
816
816
  const outputStringProgram = `@prefix : <#> .
817
817
  @prefix log: <http://www.w3.org/2000/10/swap/log#> .
818
818
  :report log:outputString "## Hello from output string\n\nLine 2 with **bold** and [Eyeling](https://example.org/eyeling)\n" .
819
+ `;
820
+ const logQueryTurtleProgram = `@prefix : <#> .
821
+ @prefix log: <http://www.w3.org/2000/10/swap/log#> .
822
+
823
+ :Socrates a :Human .
824
+ { ?x a :Human } => { ?x a :Mortal } .
825
+ { ?s ?p ?o } log:query { ?s ?p ?o } .
819
826
  `;
820
827
 
821
828
  // 1) Baseline smoke test: the default program runs to completion.
@@ -917,7 +924,27 @@ ${JSON.stringify(last, null, 2)}`);
917
924
  assert.ok(compactShareUrl.length < playgroundUrl.length + encodeURIComponent(outputStringProgram).length, 'Expected compact share URL to be shorter than raw editor URL');
918
925
  endTest();
919
926
 
920
- // 6) URL-loaded examples should auto-load matching examples/input/<stem>.trig and run in RDF/TriG mode.
927
+ // 6) log:query can produce Turtle; that should stay in plain source output without Markdown tabs.
928
+ beginTest('playground hides markdown tabs for Turtle log:query output');
929
+ await setProgram(logQueryTurtleProgram);
930
+ await clickRun();
931
+ const logQueryTurtle = await waitForState(
932
+ 'log:query Turtle output completion',
933
+ (st) =>
934
+ String(st.status || '')
935
+ .trim()
936
+ .startsWith('Done') && /:Socrates\s+a\s+:Mortal\s*\./.test(String(st.output || '')),
937
+ 30000,
938
+ );
939
+ assert.match(logQueryTurtle.output, /:Socrates\s+a\s+:Human\s*\./, 'Expected Turtle-style source output');
940
+ assert.match(logQueryTurtle.output, /:Socrates\s+a\s+:Mortal\s*\./, 'Expected inferred Turtle-style source output');
941
+ assert.doesNotMatch(logQueryTurtle.output, /^#{1,6}\s+/m, 'Expected non-Markdown Turtle output');
942
+ assert.equal(logQueryTurtle.outputTabsHidden, true, 'Expected Turtle log:query output to hide Markdown tabs');
943
+ assert.equal(logQueryTurtle.renderedHidden, true, 'Expected Turtle log:query output to skip rendered Markdown panel');
944
+ assert.equal(logQueryTurtle.sourceHidden, false, 'Expected Turtle log:query output to show source directly');
945
+ endTest();
946
+
947
+ // 7) URL-loaded examples should auto-load matching examples/input/<stem>.trig and run in RDF/TriG mode.
921
948
  beginTest('playground auto-loads companion TriG sidecars and uses RDF/TriG mode');
922
949
  await loadUrlIntoEditor('https://raw.githubusercontent.com/eyereasoner/eyeling/refs/heads/main/examples/smoke-arithmetic.n3');
923
950
  const smokeLoaded = await waitForState(
@@ -946,9 +973,25 @@ ${JSON.stringify(last, null, 2)}`);
946
973
  new RegExp('href="' + started.baseUrl.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '/examples/input/smoke-arithmetic\\.trig"'),
947
974
  'Expected relative Markdown TriG links to resolve against the static output page, not /playground',
948
975
  );
976
+ assert.equal(smoke.outputTabsHidden, false, 'Expected smoke-arithmetic Markdown output tabs to be visible');
977
+ assert.equal(smoke.renderedHidden, false, 'Expected smoke-arithmetic Markdown output to render by default');
978
+ assert.equal(smoke.sourceHidden, true, 'Expected smoke-arithmetic Markdown source to be hidden by default');
979
+
980
+ await clickOutputSourceTab();
981
+ const smokeSourceView = await getPlaygroundState();
982
+ assert.equal(smokeSourceView.sourceTabSelected, true, 'Expected smoke-arithmetic Markdown source tab to be selectable');
983
+ assert.equal(smokeSourceView.renderedHidden, true, 'Expected smoke-arithmetic rendered panel to hide in source view');
984
+ assert.equal(smokeSourceView.sourceHidden, false, 'Expected smoke-arithmetic source editor to show in source view');
985
+ assert.match(smokeSourceView.output, /^# smoke-arithmetic/m, 'Expected smoke-arithmetic source tab to show Markdown source');
986
+
987
+ await clickOutputRenderedTab();
988
+ const smokeRenderedAgain = await getPlaygroundState();
989
+ assert.equal(smokeRenderedAgain.renderedTabSelected, true, 'Expected smoke-arithmetic Rendered tab to be selectable again');
990
+ assert.equal(smokeRenderedAgain.renderedHidden, false, 'Expected smoke-arithmetic rendered panel to show again');
991
+ assert.equal(smokeRenderedAgain.sourceHidden, true, 'Expected smoke-arithmetic source editor to hide again');
949
992
  endTest();
950
993
 
951
- // 7) URL-loaded repository examples should auto-load matching examples/builtin/<stem>.js.
994
+ // 8) URL-loaded repository examples should auto-load matching examples/builtin/<stem>.js.
952
995
  beginTest('playground auto-loads a companion example builtin for URL-loaded Sudoku');
953
996
  await loadUrlIntoEditor('https://raw.githubusercontent.com/eyereasoner/eyeling/refs/heads/main/examples/sudoku.n3');
954
997
  await waitForState(
@@ -972,12 +1015,12 @@ ${JSON.stringify(last, null, 2)}`);
972
1015
  assert.match(sudoku.output, /unique valid Sudoku solution/i, 'Expected Sudoku builtin-backed result');
973
1016
  endTest();
974
1017
 
975
- // Ensure no uncaught runtime exceptions.
1018
+ // 9) Ensure no uncaught runtime exceptions.
976
1019
  beginTest('playground has no uncaught runtime exceptions');
977
1020
  assert.equal(exceptions.length, 0, `Uncaught exceptions in playground.html: ${JSON.stringify(exceptions[0] || {})}`);
978
1021
  endTest();
979
1022
 
980
- // Console errors are noisy and often indicate a broken UI.
1023
+ // 10) Console errors are noisy and often indicate a broken UI.
981
1024
  // (We suppress known noise like /favicon.ico on the server.)
982
1025
  beginTest('playground has no console errors');
983
1026
  assert.equal(consoleErrors.length, 0, `Console errors in playground.html: ${JSON.stringify(consoleErrors[0] || {})}`);