Mirror: 🎩 A tiny but capable push & pull stream library for TypeScript and Flow
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: Compile away internal TalkbackKind and SignalKind enums (#154)

authored by

Phil Pluckthun and committed by
GitHub
fa942226 952b8999

+63 -31
+5
.changeset/dry-pants-judge.md
··· 1 + --- 2 + 'wonka': patch 3 + --- 4 + 5 + Fix internal `SignalKind` and `TalkbackKind` enums not compiling away.
+46 -29
scripts/rollup.config.mjs
··· 7 7 import dts from 'rollup-plugin-dts'; 8 8 9 9 import flowTypings from './flow-typings-plugin.mjs'; 10 + import * as types from '../src/types.mjs'; 11 + 12 + const minify = terser({ 13 + warnings: true, 14 + ecma: 2015, 15 + keep_fnames: true, 16 + ie8: false, 17 + compress: { 18 + pure_getters: true, 19 + toplevel: true, 20 + booleans_as_integers: false, 21 + keep_fnames: true, 22 + keep_fargs: true, 23 + if_return: false, 24 + ie8: false, 25 + sequences: false, 26 + loops: false, 27 + conditionals: false, 28 + join_vars: false, 29 + }, 30 + mangle: { 31 + module: true, 32 + keep_fnames: true, 33 + }, 34 + output: { 35 + beautify: true, 36 + braces: true, 37 + indent_level: 2, 38 + }, 39 + }); 10 40 11 41 const commonPlugins = [ 12 42 resolve({ ··· 51 81 }, 52 82 exclude: 'node_modules/**', 53 83 }), 54 - 55 - terser({ 56 - warnings: true, 57 - ecma: 2015, 58 - keep_fnames: true, 59 - ie8: false, 60 - compress: { 61 - pure_getters: true, 62 - toplevel: true, 63 - booleans_as_integers: false, 64 - keep_fnames: true, 65 - keep_fargs: true, 66 - if_return: false, 67 - ie8: false, 68 - sequences: false, 69 - loops: false, 70 - conditionals: false, 71 - join_vars: false, 72 - }, 73 - mangle: { 74 - module: true, 75 - keep_fnames: true, 76 - }, 77 - output: { 78 - beautify: true, 79 - braces: true, 80 - indent_level: 2, 81 - }, 82 - }), 83 84 ]; 84 85 85 86 const dtsPlugins = [ ··· 111 112 objectShorthand: false, 112 113 constBindings: false, 113 114 }, 115 + plugins: [ 116 + { 117 + renderChunk(code, _chunk) { 118 + const kinds = Object.keys(types); 119 + const members = Object.values(types) 120 + .reduce((acc, item) => [...acc, ...Object.keys(item)], []) 121 + const enumRe = new RegExp(`(${kinds.join('|')})[.](${members.join('|')})`, 'g') 122 + return code.replace(enumRe, (match, kind, member) => { 123 + const value = (types[kind] && types[kind][member]); 124 + return value != null ? '' + value : match; 125 + }); 126 + }, 127 + }, 128 + 129 + minify, 130 + ] 114 131 }; 115 132 }; 116 133
+10
src/types.mjs
··· 1 + export const TalkbackKind = { 2 + Pull: 0, 3 + Close: 1, 4 + }; 5 + 6 + export const SignalKind = { 7 + Start: 0, 8 + Push: 1, 9 + End: 0, 10 + };
+2 -2
src/types.ts src/types.d.ts
··· 6 6 * the {@link Start} signal, to tell a {@link Source} to either send a new value (pulling) or stop 7 7 * sending values altogether (cancellation). 8 8 */ 9 - export const enum TalkbackKind { 9 + export enum TalkbackKind { 10 10 /** Instructs the {@link Source} to send the next value. */ 11 11 Pull = 0, 12 12 /** Instructs the {@link Source} to stop sending values and cancels it. */ ··· 41 41 * @see {@link Start} for the data structure of the start signal. 42 42 * @see {@link Push} for the data structure of the push signal, carrying values. 43 43 */ 44 - export const enum SignalKind { 44 + export enum SignalKind { 45 45 /** 46 46 * Informs the {@link Sink} that it's being called by a {@link Source}. 47 47 *