@flighthq/bitmaptext 0.5.1-next.3302.76ece6b → 0.5.1-next.4304.322dc96

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
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/bitmaptext`. The `@f
13
13
  This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
14
14
 
15
15
  - [Flight project](https://github.com/flighthq/flight)
16
- - [Source for @flighthq/bitmaptext@0.5.1-next.3302.76ece6b](https://github.com/flighthq/flight/tree/76ece6bee38e3d07816f341b7f017bfcec3e8e29/packages/bitmaptext)
17
- - [License](https://github.com/flighthq/flight/blob/76ece6bee38e3d07816f341b7f017bfcec3e8e29/LICENSE.md)
16
+ - [Source for @flighthq/bitmaptext@0.5.1-next.4304.322dc96](https://github.com/flighthq/flight/tree/322dc963fc5a404a31bc0cc612e906de504ea024/packages/bitmaptext)
17
+ - [License](https://github.com/flighthq/flight/blob/322dc963fc5a404a31bc0cc612e906de504ea024/LICENSE.md)
@@ -1,3 +1,4 @@
1
+ import type { LogState } from '@flighthq/log/contract';
1
2
  /** Uninstalls the guard installed by `enableBitmapTextGuards`. */
2
3
  export declare function disableBitmapTextGuards(): void;
3
4
  /**
@@ -16,5 +17,5 @@ export declare function disableBitmapTextGuards(): void;
16
17
  * importing this module costs production nothing: the wording and the `@flighthq/log` dependency live
17
18
  * only here.
18
19
  */
19
- export declare function enableBitmapTextGuards(): void;
20
+ export declare function enableBitmapTextGuards(logState: LogState, clock: () => number): void;
20
21
  //# sourceMappingURL=enableBitmapTextGuards.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enableBitmapTextGuards.d.ts","sourceRoot":"","sources":["../src/enableBitmapTextGuards.ts"],"names":[],"mappings":"AAKA,kEAAkE;AAClE,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C"}
1
+ {"version":3,"file":"enableBitmapTextGuards.d.ts","sourceRoot":"","sources":["../src/enableBitmapTextGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAMvD,kEAAkE;AAClE,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,MAAM,GAAG,IAAI,CAGpF"}
@@ -22,19 +22,19 @@ export function disableBitmapTextGuards() {
22
22
  * importing this module costs production nothing: the wording and the `@flighthq/log` dependency live
23
23
  * only here.
24
24
  */
25
- export function enableBitmapTextGuards() {
26
- setBitmapTextLayoutGuard(warnOnBitmapTextLayoutBlocked);
27
- setBitmapTextMissingGlyphGuard(warnOnBitmapTextMissingGlyph);
25
+ export function enableBitmapTextGuards(logState, clock) {
26
+ setBitmapTextLayoutGuard((...args) => warnOnBitmapTextLayoutBlocked(logState, clock, ...args));
27
+ setBitmapTextMissingGlyphGuard((...args) => warnOnBitmapTextMissingGlyph(logState, clock, ...args));
28
28
  }
29
- function warnOnBitmapTextMissingGlyph(codepoint) {
30
- logOnce(`bitmaptext:missing-glyph:${codepoint}`, LogLevel.Warn, {
29
+ function warnOnBitmapTextMissingGlyph(logState, clock, codepoint) {
30
+ logOnce(logState, clock(), `bitmaptext:missing-glyph:${codepoint}`, LogLevel.Warn, {
31
31
  message: `updateBitmapText: no glyph for codepoint U+${codepoint.toString(16).toUpperCase().padStart(4, '0')} ` +
32
32
  `(${String.fromCodePoint(codepoint)}) — the glyph source does not contain this character, so it is ` +
33
33
  'skipped during layout. Use explainBitmapTextMissingGlyphs for a full inventory.',
34
34
  }, 'bitmaptext');
35
35
  }
36
- function warnOnBitmapTextLayoutBlocked(_reason, attempts) {
37
- logOnce('bitmaptext:layout-did-not-converge', LogLevel.Warn, {
36
+ function warnOnBitmapTextLayoutBlocked(logState, clock, _reason, attempts) {
37
+ logOnce(logState, clock(), 'bitmaptext:layout-did-not-converge', LogLevel.Warn, {
38
38
  message: `updateBitmapText: the glyph source repacked during all ${attempts} layout passes, so this text ` +
39
39
  'never settled — its glyphs cannot all be resident in the atlas at once, and the quads drawn from ' +
40
40
  'the final pass sample stale rects. Enlarge the glyph atlas or reduce the font size; ' +
@@ -1 +1 @@
1
- {"version":3,"file":"enableBitmapTextGuards.js","sourceRoot":"","sources":["../src/enableBitmapTextGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAEjG,kEAAkE;AAClE,MAAM,UAAU,uBAAuB;IACrC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC/B,8BAA8B,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB;IACpC,wBAAwB,CAAC,6BAA6B,CAAC,CAAC;IACxD,8BAA8B,CAAC,4BAA4B,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,4BAA4B,CAAC,SAAiB;IACrD,OAAO,CACL,4BAA4B,SAAS,EAAE,EACvC,QAAQ,CAAC,IAAI,EACb;QACE,OAAO,EACL,8CAA8C,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG;YACtG,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,iEAAiE;YACpG,iFAAiF;KACpF,EACD,YAAY,CACb,CAAC;AACJ,CAAC;AAED,SAAS,6BAA6B,CAAC,OAAe,EAAE,QAAgB;IACtE,OAAO,CACL,oCAAoC,EACpC,QAAQ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F;KACpF,EACD,YAAY,CACb,CAAC;AACJ,CAAC;AAED,SAAS,6BAA6B,CACpC,QAAkB,EAClB,KAAmB,EACnB,OAAe,EACf,QAAgB;IAEhB,OAAO,CACL,QAAQ,EACR,KAAK,EAAE,EACP,oCAAoC,EACpC,QAAQ,CAAC,IAAI,EACb;QACE,OAAO,EACL,0DAA0D,QAAQ,+BAA+B;YACjG,mGAAmG;YACnG,sFAAsF;YACtF,iEAAiE;KACpE,EACD,YAAY,CACb,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/bitmaptext",
3
- "version": "0.5.1-next.3302.76ece6b",
3
+ "version": "0.5.1-next.4304.322dc96",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,14 +38,14 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/entity": "0.5.1-next.3302.76ece6b",
42
- "@flighthq/geometry": "0.5.1-next.3302.76ece6b",
43
- "@flighthq/log": "0.5.1-next.3302.76ece6b",
44
- "@flighthq/node": "0.5.1-next.3302.76ece6b",
45
- "@flighthq/scene2d": "0.5.1-next.3302.76ece6b",
46
- "@flighthq/texture": "0.5.1-next.3302.76ece6b",
47
- "@flighthq/textureatlas": "0.5.1-next.3302.76ece6b",
48
- "@flighthq/types": "0.5.1-next.3302.76ece6b"
41
+ "@flighthq/entity": "0.5.1-next.4304.322dc96",
42
+ "@flighthq/geometry": "0.5.1-next.4304.322dc96",
43
+ "@flighthq/log": "0.5.1-next.4304.322dc96",
44
+ "@flighthq/node": "0.5.1-next.4304.322dc96",
45
+ "@flighthq/scene2d": "0.5.1-next.4304.322dc96",
46
+ "@flighthq/texture": "0.5.1-next.4304.322dc96",
47
+ "@flighthq/textureatlas": "0.5.1-next.4304.322dc96",
48
+ "@flighthq/types": "0.5.1-next.4304.322dc96"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@flighthq/glyphatlas": "*",
@@ -1,11 +1,13 @@
1
1
  import { createGlyphAtlas, createGlyphSourceFromGlyphAtlas } from '@flighthq/glyphatlas/contract';
2
- import { setLogSink } from '@flighthq/log/contract';
2
+ import type { LogState } from '@flighthq/log/contract';
3
+ import { createLogState, getMemoryLogSinkEntries, setLogSink } from '@flighthq/log/contract';
3
4
  import type {
4
5
  GlyphAtlas,
5
6
  GlyphEntry,
6
- HostGlyphRasterizerCapability,
7
7
  GlyphSource,
8
+ HostGlyphRasterizerCapability,
8
9
  LogEntry,
10
+ MemoryLogSink,
9
11
  } from '@flighthq/types/contract';
10
12
  import { EntityRuntimeKey } from '@flighthq/types/contract';
11
13
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
@@ -16,14 +18,25 @@ import { updateBitmapText } from './updateBitmapText.ts';
16
18
 
17
19
  let entries: LogEntry[];
18
20
 
21
+ function clock(): number {
22
+ return 0;
23
+ }
24
+
25
+ function readLogEntries(sink: Readonly<MemoryLogSink>): LogEntry[] {
26
+ const entries: LogEntry[] = [];
27
+ getMemoryLogSinkEntries(entries, sink);
28
+ return entries;
29
+ }
30
+
19
31
  beforeEach(() => {
32
+ logState = createLogState();
20
33
  entries = [];
21
- setLogSink((entry) => entries.push(entry));
34
+ setLogSink(logState, (entry) => entries.push(entry));
22
35
  });
23
36
 
24
37
  afterEach(() => {
25
38
  disableBitmapTextGuards();
26
- setLogSink(null);
39
+ setLogSink(logState, null);
27
40
  });
28
41
 
29
42
  function messages(): string {
@@ -71,7 +84,7 @@ function createLimitedGlyphSource(codepoints: readonly number[]): GlyphSource {
71
84
 
72
85
  describe('disableBitmapTextGuards', () => {
73
86
  it('stops the guard reporting later layouts', () => {
74
- enableBitmapTextGuards();
87
+ enableBitmapTextGuards(logState, clock);
75
88
  disableBitmapTextGuards();
76
89
  const source = createGlyphSourceFromGlyphAtlas(createTinyGlyphAtlas());
77
90
  updateBitmapText(createBitmapText(source, { text: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' }));
@@ -79,7 +92,7 @@ describe('disableBitmapTextGuards', () => {
79
92
  });
80
93
 
81
94
  it('stops the missing-glyph guard from reporting', () => {
82
- enableBitmapTextGuards();
95
+ enableBitmapTextGuards(logState, clock);
83
96
  disableBitmapTextGuards();
84
97
  const source = createLimitedGlyphSource([0x41]);
85
98
  updateBitmapText(createBitmapText(source, { text: 'AB' }));
@@ -89,7 +102,7 @@ describe('disableBitmapTextGuards', () => {
89
102
 
90
103
  describe('enableBitmapTextGuards', () => {
91
104
  it('says nothing for a layout that settles', () => {
92
- enableBitmapTextGuards();
105
+ enableBitmapTextGuards(logState, clock);
93
106
  const source = createGlyphSourceFromGlyphAtlas(createTinyGlyphAtlas());
94
107
  updateBitmapText(createBitmapText(source, { text: 'ABC' }));
95
108
  expect(messages()).toBe('');
@@ -98,7 +111,7 @@ describe('enableBitmapTextGuards', () => {
98
111
  // Without this the failure is silent and looks like a rendering bug: the text draws, every quad is
99
112
  // where layout put it, and the pixels under them belong to other glyphs.
100
113
  it('warns when a string needs more glyphs at once than the atlas can hold', () => {
101
- enableBitmapTextGuards();
114
+ enableBitmapTextGuards(logState, clock);
102
115
  const source = createGlyphSourceFromGlyphAtlas(createTinyGlyphAtlas());
103
116
  updateBitmapText(createBitmapText(source, { text: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' }));
104
117
  expect(messages()).toContain('never settled');
@@ -106,7 +119,7 @@ describe('enableBitmapTextGuards', () => {
106
119
  });
107
120
 
108
121
  it('warns when a codepoint has no glyph in the source', () => {
109
- enableBitmapTextGuards();
122
+ enableBitmapTextGuards(logState, clock);
110
123
  const source = createLimitedGlyphSource([0x41]);
111
124
  updateBitmapText(createBitmapText(source, { text: 'AB' }));
112
125
  expect(messages()).toContain('U+0042');
@@ -114,7 +127,7 @@ describe('enableBitmapTextGuards', () => {
114
127
  });
115
128
 
116
129
  it('says nothing when all codepoints have glyphs', () => {
117
- enableBitmapTextGuards();
130
+ enableBitmapTextGuards(logState, clock);
118
131
  const source = createLimitedGlyphSource([0x41, 0x42]);
119
132
  updateBitmapText(createBitmapText(source, { text: 'AB' }));
120
133
  const missingMessages = entries.filter((e) =>
@@ -123,3 +136,5 @@ describe('enableBitmapTextGuards', () => {
123
136
  expect(missingMessages).toHaveLength(0);
124
137
  });
125
138
  });
139
+
140
+ let logState: LogState = createLogState();