spyret 0.1.1 → 0.3.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/README.md CHANGED
@@ -1,37 +1,96 @@
1
1
  # Spyret
2
2
 
3
- The interfaces between standard Pyret and Spytial. Spyret captures Pyret values
4
- as portable relational data, reconstructs their structure, and emits Pyret source
5
- where supported. It runs in Node or a browser without an IDE.
3
+ [![Build and tests](https://github.com/sidprasad/spyret/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sidprasad/spyret/actions/workflows/test.yml)
4
+ [![npm version](https://img.shields.io/npm/v/spyret)](https://www.npmjs.com/package/spyret)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
 
7
- `spyret-ide` is one consumer. `spytial-core` owns generic graph data, queries,
8
- layout and rendering. This package owns Pyret runtime adaptation, constructor
9
- identity, exact numbers, collections, capture validation, reconstruction and the
10
- tests of those contracts.
7
+ Spyret connects [Pyret](https://pyret.org/) values to
8
+ [Spytial](https://github.com/sidprasad/spytial-core) diagrams.
9
+ `toDataInstance(value, runtime)` turns a Pyret value into relational data for
10
+ Spytial; `await getSpytialSpec(value, runtime)` walks its reachable values and
11
+ collects one YAML string per distinct `_spytial` hook. Hooks can return typed
12
+ Pyret rules or raw YAML; values without hooks return `[]`. The JavaScript API
13
+ runs without an IDE, and the browser library lets Pyret programs display diagrams
14
+ in CPO through an import.
15
+
16
+ ## JavaScript
17
+
18
+ ```sh
19
+ npm install spyret
20
+ ```
11
21
 
12
22
  ```js
13
- import { toDataInstance } from 'spyret';
23
+ import { toDataInstance, getSpytialSpec } from 'spyret';
14
24
 
25
+ // Use the Pyret runtime that owns the value, while it is idle or paused.
15
26
  const instance = toDataInstance(pyretValue, runtime);
16
- // Pass instance directly to Spytial-Core's evaluator/layout APIs.
27
+ const specs = await getSpytialSpec(pyretValue, runtime); // string[]
28
+ // Pass the data and layout specs to Spytial-Core.
17
29
  ```
18
30
 
19
- `toDataInstance` accepts a value and the standard Pyret runtime that owns it.
20
- Spyret handles capture, relationalization and validation and returns an
21
- `IDataInstance`. Core handles queries, layout and rendering. No
22
- `spytial-core/data` entry point or Core runtime is needed inside Spyret.
23
-
24
- For transport between processes, use `capturePyret` with
25
- `createPyretRuntimeAdapter(runtime)`, then `importPyretCapture` at the receiver.
26
- The receiver needs neither Pyret nor an IDE. Collecting layout YAML alongside
27
- values can be added to Spyret later; YAML interpretation stays in Core.
31
+ `toDataInstance` returns an `IDataInstance` and never invokes hooks. The collector
32
+ handles cycles and calls each distinct hook once. See the
33
+ [hook contract and typed rules](docs/SPYTIAL_HOOKS.md) for composition, errors and
34
+ runtime requirements. For portable snapshots and reconstruction, see the
35
+ [capture API](docs/PYRET_CAPTURE.md).
36
+
37
+ ## Pyret: import, describe, display
38
+
39
+ A maintainer runs `npm run release:drive` and follows the
40
+ [CPO-save and Drive publishing instructions](docs/RELEASING.md). The native
41
+ JavaScript file needs CPO per-file authorization; a public Drive upload alone
42
+ is insufficient. Verify access with a second account before distributing the
43
+ versioned wrapper, which combines typed rule constructors and diagram functions:
44
+
45
+ ```pyret
46
+ # Use the import line supplied by the library maintainer.
47
+ import shared-gdrive("spyret-vVERSION.arr", "WRAPPER_DRIVE_FILE_ID") as S
48
+
49
+ data Tree:
50
+ | leaf(value)
51
+ | branch(left, right)
52
+ sharing:
53
+ method _spytial(self):
54
+ [list: S.orientation("left + right", [list: S.below])]
55
+ end
56
+ end
57
+
58
+ S.diagram(branch(leaf(1), leaf(2)))
59
+ ```
28
60
 
29
- See [the capture contract](docs/PYRET_CAPTURE.md) for supported values and limits.
30
- Closures are not serialized. Source preview is separate from structural capture.
61
+ `diagram` collects the reachable types' rules, relationalizes the value and displays
62
+ a diagram. Compose rules with ordinary Pyret lists; constructors such as
63
+ `orientation`, `align` and `group` handle their constraint/directive category.
64
+ `S.diagram([list: 1, 2, 3])` also works without any hooks. To supply rules explicitly,
65
+ use `S.diagram-with-rules(value, rules)`, or `S.diagram(value, yaml)` for YAML.
66
+ See the [layout rule guide](docs/SPYTIAL_LANGUAGE.md) for examples and meaning,
67
+ and the [rule reference](docs/SPYTIAL_RULES_REFERENCE.md) for every constructor.
68
+ These examples use the 0.3.0 source API. The published v0.2.0 release wrapper
69
+ uses names such as `S.direction-below`; `release:drive` prints an example
70
+ matching the release it downloads. Version 0.3.0 also replaces fluent
71
+ `.with-*` style options with named records and typed style blocks.
72
+
73
+ The import form depends on the host and file:
74
+
75
+ | Import | What it loads |
76
+ | --- | --- |
77
+ | `shared-gdrive("spyret-vVERSION.arr", "WRAPPER_DRIVE_FILE_ID")` | The versioned release wrapper in CPO: typed rules and diagram functions in one import. |
78
+ | `url("https://raw.githubusercontent.com/…/spyret-vVERSION.arr")` | A GitHub-hosted Pyret wrapper: typed rules and diagram functions in one import. It imports the native module from Drive internally. |
79
+ | `gdrive-js("spyret-vVERSION.js", "NATIVE_DRIVE_FILE_ID")` | The versioned native JavaScript module in CPO, providing diagram functions. |
80
+ | `js-file("path/to/spyret")` | The same native module in a browser host with a filesystem bridge. |
81
+
82
+ A plain `url(...)` import cannot load native JavaScript. The packaged renderer
83
+ supports CPO; other browser hosts need an adapter. No changes to CPO itself are
84
+ required, although the library uses private CPO display APIs. See the
85
+ [hosting and import guide](docs/BROWSER_LIBRARY.md) for details about published imports.
86
+
87
+ Spyret owns Pyret adaptation and display integration; Core owns layout semantics
88
+ and graph rendering. Spyret-IDE can consume this library through a small wrapper;
89
+ its migration is a [separate companion change](docs/IDE_MIGRATION.md).
31
90
 
32
91
  ## Development
33
92
 
34
- Requires Node 22 or later. The development dependency on released Core 6.3.1
93
+ Requires Node 22 or later. The development dependency on released Core 6.3.2
35
94
  provides its public interface types and tests layout/query compatibility.
36
95
  Published Spyret builds include those type declarations and have no Core runtime
37
96
  dependency.
@@ -49,6 +108,7 @@ directory with `npm ci --ignore-scripts && make phaseA`, then run:
49
108
  ```sh
50
109
  npm run test:upstream -- /path/to/pyret-lang/lang
51
110
  npm run test:program -- /path/to/pyret-lang/lang
111
+ npm run test:spytial -- /path/to/pyret-lang/lang
52
112
  REIFY_SEED=1 npm run test:pbt -- /path/to/pyret-lang/lang
53
113
  REIFY_SEED=2 npm run test:pbt -- /path/to/pyret-lang/lang
54
114
  ```
@@ -66,10 +126,13 @@ CommonJS and ES modules import `spyret`. The browser bundle is
66
126
  ## npm releases
67
127
 
68
128
  Published builds contain Spyret's adapter and bundled interface declarations.
69
- Hosts can use Core 6.3.1 for layout and rendering; Core 6.3.2 is not required.
129
+ The standalone browser module loads Core 6.3.2; headless consumers do not need
130
+ a Core runtime.
70
131
  `npm run test:package` verifies the actual tarball in an isolated consumer.
71
132
  Version tags trigger the unit/package suite and both upstream PBT seeds before
72
- publishing. See [release setup and commands](docs/RELEASING.md).
133
+ publishing to npm and GitHub. To prepare the latest release for Google Drive,
134
+ run `npm run release:drive` and follow the upload prompts.
135
+ See [manual release instructions](docs/RELEASING.md).
73
136
 
74
137
  ## Migration and provenance
75
138
 
@@ -2,7 +2,7 @@ Spyret's adapter helpers and data contracts originate in Spytial-Core.
2
2
  Author: Siddhartha Prasad
3
3
  License: MIT (declared by the source package)
4
4
  Source: https://github.com/sidprasad/spytial-core
5
- Contracts verified against spytial-core 6.3.1.
5
+ Contracts verified against spytial-core 6.3.2.
6
6
  No Core runtime or renderer is included.
7
7
 
8
8
  ---
@@ -82,3 +82,30 @@ maintained libraries used by this software which have their own
82
82
  licenses; we recommend you read them, as their terms may differ from the
83
83
  terms above.
84
84
 
85
+
86
+ ---
87
+
88
+ js-yaml
89
+
90
+ (The MIT License)
91
+
92
+ Copyright (C) 2011-2015 by Vitaly Puzrin
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy
95
+ of this software and associated documentation files (the "Software"), to deal
96
+ in the Software without restriction, including without limitation the rights
97
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
98
+ copies of the Software, and to permit persons to whom the Software is
99
+ furnished to do so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in
102
+ all copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
110
+ THE SOFTWARE.
111
+