spyret 0.1.0 → 0.2.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,89 @@
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.
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
+ [manual upload instructions](docs/RELEASING.md). Users then import the versioned
41
+ wrapper in CPO to get typed rule constructors and diagram functions together:
42
+
43
+ ```pyret
44
+ # Use the import line supplied by the library maintainer.
45
+ import shared-gdrive("spyret-vVERSION.arr", "WRAPPER_DRIVE_FILE_ID") as S
46
+
47
+ data Tree:
48
+ | leaf(value)
49
+ | branch(left, right)
50
+ sharing:
51
+ method _spytial(self):
52
+ [list: S.orientation("left + right", [list: S.direction-below])]
53
+ end
54
+ end
55
+
56
+ S.diagram(branch(leaf(1), leaf(2)))
57
+ ```
58
+
59
+ `diagram` collects the reachable types' rules, relationalizes the value and displays
60
+ a diagram. Compose rules with ordinary Pyret lists; constructors such as
61
+ `orientation`, `align` and `group` handle their constraint/directive category.
62
+ `S.diagram([list: 1, 2, 3])` also works without any hooks. To supply rules explicitly,
63
+ use `S.diagram-with-rules(value, rules)`, or `S.diagram(value, yaml)` for YAML.
64
+ See the [rule reference](docs/SPYTIAL_RULES_REFERENCE.md) for available constructors.
65
+
66
+ The import form depends on the host and file:
67
+
68
+ | Import | What it loads |
69
+ | --- | --- |
70
+ | `shared-gdrive("spyret-vVERSION.arr", "WRAPPER_DRIVE_FILE_ID")` | The versioned release wrapper in CPO: typed rules and diagram functions in one import. |
71
+ | `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. |
72
+ | `gdrive-js("spyret-vVERSION.js", "NATIVE_DRIVE_FILE_ID")` | The versioned native JavaScript module in CPO, providing diagram functions. |
73
+ | `js-file("path/to/spyret")` | The same native module in a browser host with a filesystem bridge. |
23
74
 
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.
75
+ A plain `url(...)` import cannot load native JavaScript. The packaged renderer
76
+ supports CPO; other browser hosts need an adapter. No changes to CPO itself are
77
+ required, although the library uses private CPO display APIs. See the
78
+ [hosting and import guide](docs/BROWSER_LIBRARY.md) for details about published imports.
28
79
 
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.
80
+ Spyret owns Pyret adaptation and display integration; Core owns layout semantics
81
+ and graph rendering. Spyret-IDE can consume this library through a small wrapper;
82
+ its migration is a [separate companion change](docs/IDE_MIGRATION.md).
31
83
 
32
84
  ## Development
33
85
 
34
- Requires Node 22 or later. The development dependency on released Core 6.3.1
86
+ Requires Node 22 or later. The development dependency on released Core 6.3.2
35
87
  provides its public interface types and tests layout/query compatibility.
36
88
  Published Spyret builds include those type declarations and have no Core runtime
37
89
  dependency.
@@ -49,6 +101,7 @@ directory with `npm ci --ignore-scripts && make phaseA`, then run:
49
101
  ```sh
50
102
  npm run test:upstream -- /path/to/pyret-lang/lang
51
103
  npm run test:program -- /path/to/pyret-lang/lang
104
+ npm run test:spytial -- /path/to/pyret-lang/lang
52
105
  REIFY_SEED=1 npm run test:pbt -- /path/to/pyret-lang/lang
53
106
  REIFY_SEED=2 npm run test:pbt -- /path/to/pyret-lang/lang
54
107
  ```
@@ -66,10 +119,13 @@ CommonJS and ES modules import `spyret`. The browser bundle is
66
119
  ## npm releases
67
120
 
68
121
  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.
122
+ The standalone browser module loads Core 6.3.2; headless consumers do not need
123
+ a Core runtime.
70
124
  `npm run test:package` verifies the actual tarball in an isolated consumer.
71
125
  Version tags trigger the unit/package suite and both upstream PBT seeds before
72
- publishing. See [release setup and commands](docs/RELEASING.md).
126
+ publishing to npm and GitHub. To prepare the latest release for Google Drive,
127
+ run `npm run release:drive` and follow the upload prompts.
128
+ See [manual release instructions](docs/RELEASING.md).
73
129
 
74
130
  ## Migration and provenance
75
131
 
@@ -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
+