@patterkit/compiler 0.6.1 → 0.7.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/LICENSE +21 -0
- package/dist/index.cjs +5 -0
- package/dist/index.js +6 -1
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ian Thomas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -456,6 +456,8 @@ function exportBundle(input) {
|
|
|
456
456
|
for (const scene of scenes) scenesOut[scene.id] = compileScene(scene, compileScopes);
|
|
457
457
|
const externalScopes = externalScopesIn(scenesOut, /* @__PURE__ */ new Set([...import_dialect3.EXTERNAL_SCOPES, ...gameExternal.map((s) => s.token)]));
|
|
458
458
|
const qualifiers = (0, import_model2.usedQualifiers)(project, scenes).map((q) => ({ gameId: q.gameId, name: q.name }));
|
|
459
|
+
const usedPairs = new Set((0, import_model2.usedSpeakerPairs)(scenes).map((p) => `${p.character}\0${p.qualifier}`));
|
|
460
|
+
const speakerPattern = qualifiers.length > 0 && project.speakerPattern !== void 0 && project.speakerPattern !== import_model2.DEFAULT_SPEAKER_PATTERN ? project.speakerPattern : void 0;
|
|
459
461
|
const strings = {};
|
|
460
462
|
for (const loc of locales) {
|
|
461
463
|
if (includeLocales && !includeLocales.includes(loc.locale)) continue;
|
|
@@ -506,10 +508,13 @@ function exportBundle(input) {
|
|
|
506
508
|
cast: project.cast?.map((c) => {
|
|
507
509
|
const m = { name: c.name };
|
|
508
510
|
if (c.displayName !== void 0) m.displayName = c.displayName;
|
|
511
|
+
const labels = Object.entries(c.qualifierLabels ?? {}).filter(([q, label]) => label !== "" && usedPairs.has(`${c.name}\0${q}`));
|
|
512
|
+
if (labels.length > 0) m.qualifierLabels = Object.fromEntries(labels);
|
|
509
513
|
if (c.gameData !== void 0) m.gameData = c.gameData;
|
|
510
514
|
return m;
|
|
511
515
|
}),
|
|
512
516
|
...qualifiers.length > 0 ? { qualifiers } : {},
|
|
517
|
+
...speakerPattern !== void 0 ? { speakerPattern } : {},
|
|
513
518
|
// The project's own line-padding default, only when it sets one: absent, every runtime uses the built-in one.
|
|
514
519
|
...typeof project.padAfterDefault === "number" ? { padAfterDefault: project.padAfterDefault } : {},
|
|
515
520
|
properties: project.properties,
|
package/dist/index.js
CHANGED
|
@@ -314,7 +314,7 @@ import { hostScopesToSpec as hostScopesToSpec4, EXTERNAL_SCOPES as EXTERNAL_SCOP
|
|
|
314
314
|
// src/export.ts
|
|
315
315
|
import { canonicalStringify, hash32 } from "@patterkit/core";
|
|
316
316
|
import { hostScopesToSpec as hostScopesToSpec3, withEngineScopes as withEngineScopes2, EXTERNAL_SCOPES } from "@patterkit/dialect";
|
|
317
|
-
import { usedQualifiers } from "@patterkit/model";
|
|
317
|
+
import { usedQualifiers, usedSpeakerPairs, DEFAULT_SPEAKER_PATTERN } from "@patterkit/model";
|
|
318
318
|
function compileEffect(e, foreign) {
|
|
319
319
|
return { kind: "set", target: e.target, value: compileExpression(e.value, foreign) };
|
|
320
320
|
}
|
|
@@ -422,6 +422,8 @@ function exportBundle(input) {
|
|
|
422
422
|
for (const scene of scenes) scenesOut[scene.id] = compileScene(scene, compileScopes);
|
|
423
423
|
const externalScopes = externalScopesIn(scenesOut, /* @__PURE__ */ new Set([...EXTERNAL_SCOPES, ...gameExternal.map((s) => s.token)]));
|
|
424
424
|
const qualifiers = usedQualifiers(project, scenes).map((q) => ({ gameId: q.gameId, name: q.name }));
|
|
425
|
+
const usedPairs = new Set(usedSpeakerPairs(scenes).map((p) => `${p.character}\0${p.qualifier}`));
|
|
426
|
+
const speakerPattern = qualifiers.length > 0 && project.speakerPattern !== void 0 && project.speakerPattern !== DEFAULT_SPEAKER_PATTERN ? project.speakerPattern : void 0;
|
|
425
427
|
const strings = {};
|
|
426
428
|
for (const loc of locales) {
|
|
427
429
|
if (includeLocales && !includeLocales.includes(loc.locale)) continue;
|
|
@@ -472,10 +474,13 @@ function exportBundle(input) {
|
|
|
472
474
|
cast: project.cast?.map((c) => {
|
|
473
475
|
const m = { name: c.name };
|
|
474
476
|
if (c.displayName !== void 0) m.displayName = c.displayName;
|
|
477
|
+
const labels = Object.entries(c.qualifierLabels ?? {}).filter(([q, label]) => label !== "" && usedPairs.has(`${c.name}\0${q}`));
|
|
478
|
+
if (labels.length > 0) m.qualifierLabels = Object.fromEntries(labels);
|
|
475
479
|
if (c.gameData !== void 0) m.gameData = c.gameData;
|
|
476
480
|
return m;
|
|
477
481
|
}),
|
|
478
482
|
...qualifiers.length > 0 ? { qualifiers } : {},
|
|
483
|
+
...speakerPattern !== void 0 ? { speakerPattern } : {},
|
|
479
484
|
// The project's own line-padding default, only when it sets one: absent, every runtime uses the built-in one.
|
|
480
485
|
...typeof project.padAfterDefault === "number" ? { padAfterDefault: project.padAfterDefault } : {},
|
|
481
486
|
properties: project.properties,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patterkit/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Patter compiler: compile condition/effect expressions, validate them, and export source to the runtime bundle.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patterkit/model": "0.
|
|
38
|
-
"@patterkit/core": "0.
|
|
39
|
-
"@patterkit/dialect": "0.2.
|
|
37
|
+
"@patterkit/model": "0.14.0",
|
|
38
|
+
"@patterkit/core": "0.7.0",
|
|
39
|
+
"@patterkit/dialect": "0.2.11",
|
|
40
40
|
"@wildwinter/expr": "^0.5.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|