@refrakt-md/storytelling 0.7.2 → 0.8.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/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/schema/bond.d.ts +1 -1
- package/dist/schema/bond.d.ts.map +1 -1
- package/dist/schema/bond.js +1 -1
- package/dist/schema/bond.js.map +1 -1
- package/dist/schema/lore.d.ts +1 -1
- package/dist/schema/lore.d.ts.map +1 -1
- package/dist/schema/lore.js +1 -1
- package/dist/schema/lore.js.map +1 -1
- package/dist/schema/storyboard.d.ts +1 -1
- package/dist/schema/storyboard.d.ts.map +1 -1
- package/dist/schema/storyboard.js +1 -1
- package/dist/schema/storyboard.js.map +1 -1
- package/dist/tags/bond.d.ts.map +1 -1
- package/dist/tags/bond.js +24 -49
- package/dist/tags/bond.js.map +1 -1
- package/dist/tags/character.d.ts.map +1 -1
- package/dist/tags/character.js +49 -82
- package/dist/tags/character.js.map +1 -1
- package/dist/tags/faction.d.ts.map +1 -1
- package/dist/tags/faction.js +44 -80
- package/dist/tags/faction.js.map +1 -1
- package/dist/tags/lore.d.ts.map +1 -1
- package/dist/tags/lore.js +26 -43
- package/dist/tags/lore.js.map +1 -1
- package/dist/tags/plot.d.ts.map +1 -1
- package/dist/tags/plot.js +92 -94
- package/dist/tags/plot.js.map +1 -1
- package/dist/tags/realm.d.ts.map +1 -1
- package/dist/tags/realm.js +49 -82
- package/dist/tags/realm.js.map +1 -1
- package/dist/tags/storyboard.d.ts.map +1 -1
- package/dist/tags/storyboard.js +50 -65
- package/dist/tags/storyboard.js.map +1 -1
- package/dist/types.js +5 -5
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
package/dist/tags/realm.js
CHANGED
|
@@ -8,8 +8,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import Markdoc from '@markdoc/markdoc';
|
|
11
|
-
const {
|
|
12
|
-
import {
|
|
11
|
+
const { Tag } = Markdoc;
|
|
12
|
+
import { attribute, Model, createComponentRenderable, createContentModelSchema, createSchema, asNodes, RenderableNodeCursor } from '@refrakt-md/runes';
|
|
13
13
|
import { schema } from '../types.js';
|
|
14
14
|
class RealmSectionModel extends Model {
|
|
15
15
|
constructor() {
|
|
@@ -31,55 +31,54 @@ __decorate([
|
|
|
31
31
|
attribute({ type: String, required: true }),
|
|
32
32
|
__metadata("design:type", String)
|
|
33
33
|
], RealmSectionModel.prototype, "name", void 0);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const scaleMeta = new Tag('meta', { content: this.scale });
|
|
72
|
-
const tagsMeta = new Tag('meta', { content: this.tags });
|
|
73
|
-
const parentMeta = new Tag('meta', { content: this.parent });
|
|
74
|
-
// Extract scene image from header
|
|
75
|
-
const scene = header.tag('img').limit(1);
|
|
34
|
+
export const realmSection = createSchema(RealmSectionModel);
|
|
35
|
+
export const realm = createContentModelSchema({
|
|
36
|
+
attributes: {
|
|
37
|
+
headingLevel: { type: Number, required: false },
|
|
38
|
+
name: { type: String, required: true },
|
|
39
|
+
type: { type: String, required: false },
|
|
40
|
+
scale: { type: String, required: false },
|
|
41
|
+
tags: { type: String, required: false },
|
|
42
|
+
parent: { type: String, required: false },
|
|
43
|
+
},
|
|
44
|
+
contentModel: (attrs) => ({
|
|
45
|
+
type: 'sections',
|
|
46
|
+
sectionHeading: attrs.headingLevel ? `heading:${attrs.headingLevel}` : 'heading',
|
|
47
|
+
emitTag: 'realm-section',
|
|
48
|
+
emitAttributes: { name: '$heading' },
|
|
49
|
+
fields: [
|
|
50
|
+
{ name: 'scene', match: 'image', optional: true },
|
|
51
|
+
{ name: 'header', match: 'heading|paragraph', optional: true, greedy: true },
|
|
52
|
+
{ name: 'items', match: 'tag', optional: true, greedy: true },
|
|
53
|
+
],
|
|
54
|
+
sectionModel: {
|
|
55
|
+
type: 'sequence',
|
|
56
|
+
fields: [{ name: 'body', match: 'any', optional: true, greedy: true }],
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
transform(resolved, attrs, config) {
|
|
60
|
+
// Combine explicit child tags (preamble items) with emitted section tags
|
|
61
|
+
const allItems = [...asNodes(resolved.items), ...asNodes(resolved.sections)];
|
|
62
|
+
const sectionNodes = new RenderableNodeCursor(Markdoc.transform(allItems, config));
|
|
63
|
+
const nameTag = new Tag('span', {}, [attrs.name ?? '']);
|
|
64
|
+
const realmTypeMeta = new Tag('meta', { content: attrs.type ?? 'place' });
|
|
65
|
+
const scaleMeta = new Tag('meta', { content: attrs.scale ?? '' });
|
|
66
|
+
const tagsMeta = new Tag('meta', { content: attrs.tags ?? '' });
|
|
67
|
+
const parentMeta = new Tag('meta', { content: attrs.parent ?? '' });
|
|
68
|
+
// Extract scene image from preamble
|
|
69
|
+
const sceneNodes = new RenderableNodeCursor(Markdoc.transform(asNodes(resolved.scene), config));
|
|
70
|
+
const scene = sceneNodes.tag('img').limit(1);
|
|
76
71
|
const hasScene = scene.count() > 0;
|
|
77
72
|
const sceneDiv = hasScene ? scene.wrap('div') : undefined;
|
|
78
|
-
const sections =
|
|
73
|
+
const sections = sectionNodes.tag('div').typeof('RealmSection');
|
|
79
74
|
const hasSections = sections.count() > 0;
|
|
80
75
|
const children = [nameTag, realmTypeMeta, scaleMeta, tagsMeta, parentMeta];
|
|
81
76
|
if (sceneDiv)
|
|
82
77
|
children.push(sceneDiv.next());
|
|
78
|
+
const schemaMap = {
|
|
79
|
+
name: nameTag,
|
|
80
|
+
additionalType: realmTypeMeta,
|
|
81
|
+
};
|
|
83
82
|
if (hasSections) {
|
|
84
83
|
const sectionsContainer = sections.wrap('div');
|
|
85
84
|
children.push(sectionsContainer.next());
|
|
@@ -98,11 +97,12 @@ class RealmModel extends Model {
|
|
|
98
97
|
...(sceneDiv ? { scene: sceneDiv } : {}),
|
|
99
98
|
sections: sectionsContainer,
|
|
100
99
|
},
|
|
100
|
+
schema: schemaMap,
|
|
101
101
|
children,
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
else {
|
|
105
|
-
const body =
|
|
105
|
+
const body = sectionNodes.wrap('div');
|
|
106
106
|
children.push(body.next());
|
|
107
107
|
return createComponentRenderable(schema.Realm, {
|
|
108
108
|
tag: 'article',
|
|
@@ -118,43 +118,10 @@ class RealmModel extends Model {
|
|
|
118
118
|
...(sceneDiv ? { scene: sceneDiv } : {}),
|
|
119
119
|
body,
|
|
120
120
|
},
|
|
121
|
+
schema: schemaMap,
|
|
121
122
|
children,
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
__decorate([
|
|
127
|
-
attribute({ type: Number, required: false }),
|
|
128
|
-
__metadata("design:type", Object)
|
|
129
|
-
], RealmModel.prototype, "headingLevel", void 0);
|
|
130
|
-
__decorate([
|
|
131
|
-
attribute({ type: String, required: true }),
|
|
132
|
-
__metadata("design:type", String)
|
|
133
|
-
], RealmModel.prototype, "name", void 0);
|
|
134
|
-
__decorate([
|
|
135
|
-
attribute({ type: String, required: false }),
|
|
136
|
-
__metadata("design:type", String)
|
|
137
|
-
], RealmModel.prototype, "type", void 0);
|
|
138
|
-
__decorate([
|
|
139
|
-
attribute({ type: String, required: false }),
|
|
140
|
-
__metadata("design:type", String)
|
|
141
|
-
], RealmModel.prototype, "scale", void 0);
|
|
142
|
-
__decorate([
|
|
143
|
-
attribute({ type: String, required: false }),
|
|
144
|
-
__metadata("design:type", String)
|
|
145
|
-
], RealmModel.prototype, "tags", void 0);
|
|
146
|
-
__decorate([
|
|
147
|
-
attribute({ type: String, required: false }),
|
|
148
|
-
__metadata("design:type", String)
|
|
149
|
-
], RealmModel.prototype, "parent", void 0);
|
|
150
|
-
__decorate([
|
|
151
|
-
group({ include: ['heading', 'paragraph', 'image'] }),
|
|
152
|
-
__metadata("design:type", NodeStream)
|
|
153
|
-
], RealmModel.prototype, "header", void 0);
|
|
154
|
-
__decorate([
|
|
155
|
-
group({ include: ['tag'] }),
|
|
156
|
-
__metadata("design:type", NodeStream)
|
|
157
|
-
], RealmModel.prototype, "itemgroup", void 0);
|
|
158
|
-
export const realmSection = createSchema(RealmSectionModel);
|
|
159
|
-
export const realm = createSchema(RealmModel);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
160
127
|
//# sourceMappingURL=realm.js.map
|
package/dist/tags/realm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"realm.js","sourceRoot":"","sources":["../../src/tags/realm.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,EAAE,GAAG,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"realm.js","sourceRoot":"","sources":["../../src/tags/realm.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,YAAY,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvJ,OAAO,EAAE,M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ACd,MAAM,EAAE,UAAU;iBAClB;gBACD,IAAI,EAAE;oBACL,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACxC,IAAI;iBACJ;gBACD,MAAM,EAAE,SAAS;gBACjB,QAAQ;aACR,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyboard.d.ts","sourceRoot":"","sources":["../../src/tags/storyboard.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"storyboard.d.ts","sourceRoot":"","sources":["../../src/tags/storyboard.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AA6DvC,eAAO,MAAM,eAAe,gBAAqC,CAAC;AAElE,eAAO,MAAM,UAAU,gBAkCrB,CAAC"}
|
package/dist/tags/storyboard.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
1
|
import Markdoc from '@markdoc/markdoc';
|
|
11
2
|
const { Ast, Tag } = Markdoc;
|
|
12
|
-
import {
|
|
3
|
+
import { Model, createComponentRenderable, createContentModelSchema, createSchema, asNodes } from '@refrakt-md/runes';
|
|
4
|
+
import { RenderableNodeCursor } from '@refrakt-md/runes';
|
|
13
5
|
import { schema } from '../types.js';
|
|
14
|
-
const
|
|
6
|
+
const variantType = ['comic', 'clean', 'polaroid'];
|
|
15
7
|
class StoryboardPanelModel extends Model {
|
|
16
8
|
transform() {
|
|
17
9
|
const children = this.transformChildren();
|
|
@@ -31,70 +23,63 @@ class StoryboardPanelModel extends Model {
|
|
|
31
23
|
});
|
|
32
24
|
}
|
|
33
25
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Non-image after an image: add to current panel as caption
|
|
58
|
-
currentPanelChildren.push(node);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
// Content before first image: start a panel anyway
|
|
62
|
-
currentPanelChildren.push(node);
|
|
63
|
-
}
|
|
26
|
+
// Group nodes into panels: each image starts a new panel
|
|
27
|
+
function convertStoryboardChildren(nodes) {
|
|
28
|
+
const converted = [];
|
|
29
|
+
let currentPanelChildren = [];
|
|
30
|
+
const flushPanel = () => {
|
|
31
|
+
if (currentPanelChildren.length > 0) {
|
|
32
|
+
converted.push(new Ast.Node('tag', {}, currentPanelChildren, 'storyboard-panel'));
|
|
33
|
+
currentPanelChildren = [];
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
for (const node of nodes) {
|
|
37
|
+
if (node.type === 'image' || (node.type === 'paragraph' && Array.from(node.walk()).some(n => n.type === 'image'))) {
|
|
38
|
+
// Image starts a new panel
|
|
39
|
+
flushPanel();
|
|
40
|
+
currentPanelChildren.push(node);
|
|
41
|
+
}
|
|
42
|
+
else if (currentPanelChildren.length > 0) {
|
|
43
|
+
// Non-image after an image: add to current panel as caption
|
|
44
|
+
currentPanelChildren.push(node);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// Content before first image: start a panel anyway
|
|
48
|
+
currentPanelChildren.push(node);
|
|
64
49
|
}
|
|
65
|
-
flushPanel();
|
|
66
|
-
return super.processChildren(converted);
|
|
67
50
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
flushPanel();
|
|
52
|
+
return converted;
|
|
53
|
+
}
|
|
54
|
+
export const storyboardPanel = createSchema(StoryboardPanelModel);
|
|
55
|
+
export const storyboard = createContentModelSchema({
|
|
56
|
+
attributes: {
|
|
57
|
+
columns: { type: Number, required: false },
|
|
58
|
+
variant: { type: String, required: false, matches: variantType.slice() },
|
|
59
|
+
},
|
|
60
|
+
contentModel: {
|
|
61
|
+
type: 'custom',
|
|
62
|
+
processChildren: convertStoryboardChildren,
|
|
63
|
+
description: 'Image-triggered panel accumulator. Each image starts a new panel; '
|
|
64
|
+
+ 'subsequent non-image content becomes the panel caption.',
|
|
65
|
+
},
|
|
66
|
+
transform(resolved, attrs, config) {
|
|
67
|
+
const allChildren = asNodes(resolved.children);
|
|
68
|
+
const body = new RenderableNodeCursor(Markdoc.transform(allChildren, config));
|
|
69
|
+
const variantMeta = new Tag('meta', { content: attrs.variant ?? 'clean' });
|
|
70
|
+
const columnsMeta = new Tag('meta', { content: String(attrs.columns ?? 3) });
|
|
72
71
|
const panels = body.tag('div').typeof('StoryboardPanel');
|
|
73
72
|
const panelsContainer = panels.wrap('div');
|
|
74
73
|
return createComponentRenderable(schema.Storyboard, {
|
|
75
74
|
tag: 'div',
|
|
76
75
|
properties: {
|
|
77
76
|
panel: panels,
|
|
78
|
-
|
|
77
|
+
variant: variantMeta,
|
|
79
78
|
columns: columnsMeta,
|
|
80
79
|
},
|
|
81
80
|
refs: { panels: panelsContainer },
|
|
82
|
-
children: [
|
|
81
|
+
children: [variantMeta, columnsMeta, panelsContainer.next()],
|
|
83
82
|
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
__decorate([
|
|
87
|
-
attribute({ type: Number, required: false }),
|
|
88
|
-
__metadata("design:type", Number)
|
|
89
|
-
], StoryboardModel.prototype, "columns", void 0);
|
|
90
|
-
__decorate([
|
|
91
|
-
attribute({ type: String, required: false, matches: styleType.slice() }),
|
|
92
|
-
__metadata("design:type", Object)
|
|
93
|
-
], StoryboardModel.prototype, "style", void 0);
|
|
94
|
-
__decorate([
|
|
95
|
-
group({ include: ['tag'] }),
|
|
96
|
-
__metadata("design:type", NodeStream)
|
|
97
|
-
], StoryboardModel.prototype, "body", void 0);
|
|
98
|
-
export const storyboardPanel = createSchema(StoryboardPanelModel);
|
|
99
|
-
export const storyboard = createSchema(StoryboardModel);
|
|
83
|
+
},
|
|
84
|
+
});
|
|
100
85
|
//# sourceMappingURL=storyboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyboard.js","sourceRoot":"","sources":["../../src/tags/storyboard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storyboard.js","sourceRoot":"","sources":["../../src/tags/storyboard.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAC7B,OAAO,EAAa,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjI,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC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,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,OAAO,EAAE,CAAC,CAAC;QAC3E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;QAE7E,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACzD,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE3C,OAAO,yBAAyB,CAAC,MAAM,CAAC,UAAU,EAAE;YACnD,GAAG,EAAE,KAAK;YACV,UAAU,EAAE;gBACX,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,WAAW;gBACpB,OAAO,EAAE,WAAW;aACpB;YACD,IAAI,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE;YACjC,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC;SAC5D,CAAC,CAAC;IACJ,CAAC;CACD,CAAC,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -8,14 +8,14 @@ import { Plot, Beat } from './schema/plot.js';
|
|
|
8
8
|
import { Bond } from './schema/bond.js';
|
|
9
9
|
import { Storyboard, StoryboardPanel } from './schema/storyboard.js';
|
|
10
10
|
export const schema = {
|
|
11
|
-
Character: useSchema(Character).defineType('Character'),
|
|
11
|
+
Character: useSchema(Character).defineType('Character', {}, 'Person'),
|
|
12
12
|
CharacterSection: useSchema(StorySection).defineType('CharacterSection'),
|
|
13
|
-
Realm: useSchema(Realm).defineType('Realm'),
|
|
13
|
+
Realm: useSchema(Realm).defineType('Realm', {}, 'Place'),
|
|
14
14
|
RealmSection: useSchema(StorySection).defineType('RealmSection'),
|
|
15
|
-
Faction: useSchema(Faction).defineType('Faction'),
|
|
15
|
+
Faction: useSchema(Faction).defineType('Faction', {}, 'Organization'),
|
|
16
16
|
FactionSection: useSchema(StorySection).defineType('FactionSection'),
|
|
17
|
-
Lore: useSchema(Lore).defineType('Lore'),
|
|
18
|
-
Plot: useSchema(Plot).defineType('Plot'),
|
|
17
|
+
Lore: useSchema(Lore).defineType('Lore', {}, 'Article'),
|
|
18
|
+
Plot: useSchema(Plot).defineType('Plot', {}, 'CreativeWork'),
|
|
19
19
|
Beat: useSchema(Beat).defineType('Beat'),
|
|
20
20
|
Bond: useSchema(Bond).defineType('Bond'),
|
|
21
21
|
Storyboard: useSchema(Storyboard).defineType('Storyboard'),
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAC,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAEnE,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,M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E,SAAS,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;IACxC,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC;IAC1D,eAAe,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC;CAC1E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refrakt-md/storytelling",
|
|
3
3
|
"description": "Storytelling runes for refrakt.md — characters, realms, factions, plots, and more",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"build": "tsc"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@refrakt-md/types": "0.
|
|
25
|
-
"@refrakt-md/transform": "0.
|
|
26
|
-
"@refrakt-md/runes": "0.
|
|
24
|
+
"@refrakt-md/types": "0.8.0",
|
|
25
|
+
"@refrakt-md/transform": "0.8.0",
|
|
26
|
+
"@refrakt-md/runes": "0.8.0",
|
|
27
27
|
"@markdoc/markdoc": "0.4.0",
|
|
28
28
|
"reflect-metadata": "^0.2.0"
|
|
29
29
|
}
|