feat(planning): grille hebdomadaire complète avec API et filtres
- Connexion API via proxy Angular (résolution CORS, base path /api) - Import CSS ng-zorro global pour les modales et composants - Filtres Camion/Show câblés sur l'affichage de la grille - Camions affichés via TrucksService (linkés au show du même créneau) - Panneau de détails : spectacles + camions du jour sélectionné - Modale de création de spectacle stylisée avec fond et centrage - Positionnement précis des events à la minute dans leur créneau - Auto-scroll vers l'heure courante au chargement - Ligne "maintenant" sur la colonne du jour actuel - Régénération des services OpenAPI (nouveaux noms de types) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+34
-30
@@ -1,48 +1,52 @@
|
||||
"use strict"
|
||||
"use strict";
|
||||
|
||||
var BOMChar = "\uFEFF"
|
||||
var BOMChar = '\uFEFF';
|
||||
|
||||
exports.PrependBOM = PrependBOMWrapper
|
||||
function PrependBOMWrapper (encoder, options) {
|
||||
this.encoder = encoder
|
||||
this.addBOM = true
|
||||
function PrependBOMWrapper(encoder, options) {
|
||||
this.encoder = encoder;
|
||||
this.addBOM = true;
|
||||
}
|
||||
|
||||
PrependBOMWrapper.prototype.write = function (str) {
|
||||
if (this.addBOM) {
|
||||
str = BOMChar + str
|
||||
this.addBOM = false
|
||||
}
|
||||
PrependBOMWrapper.prototype.write = function(str) {
|
||||
if (this.addBOM) {
|
||||
str = BOMChar + str;
|
||||
this.addBOM = false;
|
||||
}
|
||||
|
||||
return this.encoder.write(str)
|
||||
return this.encoder.write(str);
|
||||
}
|
||||
|
||||
PrependBOMWrapper.prototype.end = function () {
|
||||
return this.encoder.end()
|
||||
PrependBOMWrapper.prototype.end = function() {
|
||||
return this.encoder.end();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
exports.StripBOM = StripBOMWrapper
|
||||
function StripBOMWrapper (decoder, options) {
|
||||
this.decoder = decoder
|
||||
this.pass = false
|
||||
this.options = options || {}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
exports.StripBOM = StripBOMWrapper;
|
||||
function StripBOMWrapper(decoder, options) {
|
||||
this.decoder = decoder;
|
||||
this.pass = false;
|
||||
this.options = options || {};
|
||||
}
|
||||
|
||||
StripBOMWrapper.prototype.write = function (buf) {
|
||||
var res = this.decoder.write(buf)
|
||||
if (this.pass || !res) { return res }
|
||||
StripBOMWrapper.prototype.write = function(buf) {
|
||||
var res = this.decoder.write(buf);
|
||||
if (this.pass || !res)
|
||||
return res;
|
||||
|
||||
if (res[0] === BOMChar) {
|
||||
res = res.slice(1)
|
||||
if (typeof this.options.stripBOM === "function") { this.options.stripBOM() }
|
||||
}
|
||||
if (res[0] === BOMChar) {
|
||||
res = res.slice(1);
|
||||
if (typeof this.options.stripBOM === 'function')
|
||||
this.options.stripBOM();
|
||||
}
|
||||
|
||||
this.pass = true
|
||||
return res
|
||||
this.pass = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
StripBOMWrapper.prototype.end = function () {
|
||||
return this.decoder.end()
|
||||
StripBOMWrapper.prototype.end = function() {
|
||||
return this.decoder.end();
|
||||
}
|
||||
|
||||
|
||||
+28
-116
@@ -1,129 +1,41 @@
|
||||
/* ---------------------------------------------------------------------------------------------
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
* REQUIREMENT: This definition is dependent on the @types/node definition.
|
||||
* Install with `npm install @types/node --save-dev`
|
||||
*-------------------------------------------------------------------------------------------- */
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------
|
||||
* This file provides detailed typings for the public API of iconv-lite
|
||||
*-------------------------------------------------------------------------------------------- */
|
||||
declare module 'iconv-lite' {
|
||||
// Basic API
|
||||
export function decode(buffer: Buffer, encoding: string, options?: Options): string;
|
||||
|
||||
import type Stream = require("stream")
|
||||
import type { Encoding } from "../types/encodings"
|
||||
export function encode(content: string, encoding: string, options?: Options): Buffer;
|
||||
|
||||
declare namespace iconv {
|
||||
export interface DecodeOptions {
|
||||
/**
|
||||
* Strip the Byte Order Mark (BOM) from the input,
|
||||
* when decoding, if the codec is BOM-aware. @default true
|
||||
*/
|
||||
stripBOM?: boolean;
|
||||
/** Override the default endianness for `UTF-16` and `UTF-32` decodings. */
|
||||
defaultEncoding?: "utf16be" | "utf32be";
|
||||
}
|
||||
export function encodingExists(encoding: string): boolean;
|
||||
|
||||
export interface EncodeOptions {
|
||||
/**
|
||||
* Add a Byte Order Mark (BOM) to the output, when encoding,
|
||||
* if the codec is BOM-aware. @default false
|
||||
*/
|
||||
addBOM?: boolean;
|
||||
/** Override the default endianness for `UTF-32` encoding. */
|
||||
defaultEncoding?: "utf32be";
|
||||
}
|
||||
// Stream API
|
||||
export function decodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
|
||||
|
||||
export interface EncoderStream {
|
||||
write(str: string): Buffer;
|
||||
end(): Buffer | undefined;
|
||||
}
|
||||
export function encodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
|
||||
|
||||
export interface DecoderStream {
|
||||
write(buf: Buffer): string;
|
||||
end(): string | undefined;
|
||||
}
|
||||
// Low-level stream APIs
|
||||
export function getEncoder(encoding: string, options?: Options): EncoderStream;
|
||||
|
||||
export interface Codec {
|
||||
encoder: new (options?: EncodeOptions, codec?: Codec) => EncoderStream;
|
||||
decoder: new (options?: DecodeOptions, codec?: Codec) => DecoderStream;
|
||||
bomAware?: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/** Encodes a `string` into a `Buffer`, using the provided `encoding`. */
|
||||
export function encode (content: string, encoding: Encoding, options?: EncodeOptions): Buffer
|
||||
|
||||
/** Decodes a `Buffer` into a `string`, using the provided `encoding`. */
|
||||
export function decode (buffer: Buffer | Uint8Array, encoding: Encoding, options?: DecodeOptions): string
|
||||
|
||||
/** Checks if a given encoding is supported by `iconv-lite`. */
|
||||
export function encodingExists (encoding: string): encoding is Encoding
|
||||
|
||||
/** Legacy alias for {@link iconv.encode}. */
|
||||
export const toEncoding: typeof iconv.encode
|
||||
|
||||
/** Legacy alias for {@link iconv.decode}. */
|
||||
export const fromEncoding: typeof iconv.decode
|
||||
|
||||
/** Creates a stream that decodes binary data from a given `encoding` into strings. */
|
||||
export function decodeStream (encoding: Encoding, options?: DecodeOptions): NodeJS.ReadWriteStream
|
||||
|
||||
/** Creates a stream that encodes strings into binary data in a given `encoding`. */
|
||||
export function encodeStream (encoding: Encoding, options?: EncodeOptions): NodeJS.ReadWriteStream
|
||||
|
||||
/**
|
||||
* Explicitly enable Streaming API in browser environments by passing in:
|
||||
* ```js
|
||||
* require('stream')
|
||||
* ```
|
||||
* @example iconv.enableStreamingAPI(require('stream'));
|
||||
*/
|
||||
export function enableStreamingAPI (stream_module: { Transform: typeof Stream.Transform }): void
|
||||
|
||||
/** Creates and returns a low-level encoder stream. */
|
||||
export function getEncoder (encoding: Encoding, options?: EncodeOptions): EncoderStream
|
||||
|
||||
/** Creates and returns a low-level decoder stream. */
|
||||
export function getDecoder (encoding: Encoding, options?: DecodeOptions): DecoderStream
|
||||
|
||||
/**
|
||||
* Returns a codec object for the given `encoding`.
|
||||
* @throws If the `encoding` is not recognized.
|
||||
*/
|
||||
export function getCodec (encoding: Encoding): Codec
|
||||
|
||||
/** Strips all non-alphanumeric characters and appended year from `encoding`. */
|
||||
export function _canonicalizeEncoding (encoding: Encoding): string
|
||||
|
||||
/** A cache of all loaded encoding definitions. */
|
||||
export let encodings: Record<
|
||||
Encoding,
|
||||
| string
|
||||
| {
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
> | null
|
||||
|
||||
/** A cache of initialized codec objects. */
|
||||
export let _codecDataCache: Record<string, Codec>
|
||||
|
||||
/** The character used for untranslatable `Unicode` characters. @default "�" */
|
||||
export let defaultCharUnicode: string
|
||||
|
||||
/** The character used for untranslatable `single-byte` characters. @default "?" */
|
||||
export let defaultCharSingleByte: string
|
||||
|
||||
/**
|
||||
* Skip deprecation warning when strings are used instead of Buffers during decoding.
|
||||
* Note: {@link iconv.decode} converts the string to Buffer regardless.
|
||||
*/
|
||||
export let skipDecodeWarning: boolean
|
||||
|
||||
/** @readonly Whether or not, Streaming API is enabled. */
|
||||
export const supportsStreams: boolean
|
||||
|
||||
export type { iconv as Iconv, Encoding }
|
||||
export function getDecoder(encoding: string, options?: Options): DecoderStream;
|
||||
}
|
||||
|
||||
export = iconv
|
||||
export interface Options {
|
||||
stripBOM?: boolean;
|
||||
addBOM?: boolean;
|
||||
defaultEncoding?: string;
|
||||
}
|
||||
|
||||
export interface EncoderStream {
|
||||
write(str: string): Buffer;
|
||||
end(): Buffer | undefined;
|
||||
}
|
||||
|
||||
export interface DecoderStream {
|
||||
write(buf: Buffer): string;
|
||||
end(): string | undefined;
|
||||
}
|
||||
|
||||
+114
-116
@@ -1,136 +1,134 @@
|
||||
"use strict"
|
||||
"use strict";
|
||||
|
||||
var Buffer = require("safer-buffer").Buffer
|
||||
var Buffer = require("safer-buffer").Buffer;
|
||||
|
||||
var bomHandling = require("./bom-handling")
|
||||
var mergeModules = require("./helpers/merge-exports")
|
||||
var bomHandling = require("./bom-handling"),
|
||||
iconv = module.exports;
|
||||
|
||||
// All codecs and aliases are kept here, keyed by encoding name/alias.
|
||||
// They are lazy loaded in `iconv.getCodec` from `encodings/index.js`.
|
||||
// Cannot initialize with { __proto__: null } because Boolean({ __proto__: null }) === true
|
||||
module.exports.encodings = null
|
||||
iconv.encodings = null;
|
||||
|
||||
// Characters emitted in case of error.
|
||||
module.exports.defaultCharUnicode = "�"
|
||||
module.exports.defaultCharSingleByte = "?"
|
||||
iconv.defaultCharUnicode = '�';
|
||||
iconv.defaultCharSingleByte = '?';
|
||||
|
||||
// Public API.
|
||||
module.exports.encode = function encode (str, encoding, options) {
|
||||
str = "" + (str || "") // Ensure string.
|
||||
iconv.encode = function encode(str, encoding, options) {
|
||||
str = "" + (str || ""); // Ensure string.
|
||||
|
||||
var encoder = module.exports.getEncoder(encoding, options)
|
||||
var encoder = iconv.getEncoder(encoding, options);
|
||||
|
||||
var res = encoder.write(str)
|
||||
var trail = encoder.end()
|
||||
|
||||
return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res
|
||||
var res = encoder.write(str);
|
||||
var trail = encoder.end();
|
||||
|
||||
return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res;
|
||||
}
|
||||
|
||||
module.exports.decode = function decode (buf, encoding, options) {
|
||||
if (typeof buf === "string") {
|
||||
if (!module.exports.skipDecodeWarning) {
|
||||
console.error("Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding")
|
||||
module.exports.skipDecodeWarning = true
|
||||
iconv.decode = function decode(buf, encoding, options) {
|
||||
if (typeof buf === 'string') {
|
||||
if (!iconv.skipDecodeWarning) {
|
||||
console.error('Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding');
|
||||
iconv.skipDecodeWarning = true;
|
||||
}
|
||||
|
||||
buf = Buffer.from("" + (buf || ""), "binary"); // Ensure buffer.
|
||||
}
|
||||
|
||||
buf = Buffer.from("" + (buf || ""), "binary") // Ensure buffer.
|
||||
}
|
||||
var decoder = iconv.getDecoder(encoding, options);
|
||||
|
||||
var decoder = module.exports.getDecoder(encoding, options)
|
||||
var res = decoder.write(buf);
|
||||
var trail = decoder.end();
|
||||
|
||||
var res = decoder.write(buf)
|
||||
var trail = decoder.end()
|
||||
|
||||
return trail ? (res + trail) : res
|
||||
return trail ? (res + trail) : res;
|
||||
}
|
||||
|
||||
module.exports.encodingExists = function encodingExists (enc) {
|
||||
try {
|
||||
module.exports.getCodec(enc)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
iconv.encodingExists = function encodingExists(enc) {
|
||||
try {
|
||||
iconv.getCodec(enc);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy aliases to convert functions
|
||||
module.exports.toEncoding = module.exports.encode
|
||||
module.exports.fromEncoding = module.exports.decode
|
||||
iconv.toEncoding = iconv.encode;
|
||||
iconv.fromEncoding = iconv.decode;
|
||||
|
||||
// Search for a codec in iconv.encodings. Cache codec data in iconv._codecDataCache.
|
||||
module.exports._codecDataCache = { __proto__: null }
|
||||
iconv._codecDataCache = {};
|
||||
iconv.getCodec = function getCodec(encoding) {
|
||||
if (!iconv.encodings)
|
||||
iconv.encodings = require("../encodings"); // Lazy load all encoding definitions.
|
||||
|
||||
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
|
||||
var enc = iconv._canonicalizeEncoding(encoding);
|
||||
|
||||
module.exports.getCodec = function getCodec (encoding) {
|
||||
if (!module.exports.encodings) {
|
||||
var raw = require("../encodings")
|
||||
// TODO: In future versions when old nodejs support is removed can use object.assign
|
||||
module.exports.encodings = { __proto__: null } // Initialize as empty object.
|
||||
mergeModules(module.exports.encodings, raw)
|
||||
}
|
||||
// Traverse iconv.encodings to find actual codec.
|
||||
var codecOptions = {};
|
||||
while (true) {
|
||||
var codec = iconv._codecDataCache[enc];
|
||||
if (codec)
|
||||
return codec;
|
||||
|
||||
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
|
||||
var enc = module.exports._canonicalizeEncoding(encoding)
|
||||
var codecDef = iconv.encodings[enc];
|
||||
|
||||
// Traverse iconv.encodings to find actual codec.
|
||||
var codecOptions = {}
|
||||
while (true) {
|
||||
var codec = module.exports._codecDataCache[enc]
|
||||
switch (typeof codecDef) {
|
||||
case "string": // Direct alias to other encoding.
|
||||
enc = codecDef;
|
||||
break;
|
||||
|
||||
if (codec) { return codec }
|
||||
case "object": // Alias with options. Can be layered.
|
||||
for (var key in codecDef)
|
||||
codecOptions[key] = codecDef[key];
|
||||
|
||||
var codecDef = module.exports.encodings[enc]
|
||||
if (!codecOptions.encodingName)
|
||||
codecOptions.encodingName = enc;
|
||||
|
||||
enc = codecDef.type;
|
||||
break;
|
||||
|
||||
switch (typeof codecDef) {
|
||||
case "string": // Direct alias to other encoding.
|
||||
enc = codecDef
|
||||
break
|
||||
case "function": // Codec itself.
|
||||
if (!codecOptions.encodingName)
|
||||
codecOptions.encodingName = enc;
|
||||
|
||||
case "object": // Alias with options. Can be layered.
|
||||
for (var key in codecDef) { codecOptions[key] = codecDef[key] }
|
||||
// The codec function must load all tables and return object with .encoder and .decoder methods.
|
||||
// It'll be called only once (for each different options object).
|
||||
codec = new codecDef(codecOptions, iconv);
|
||||
|
||||
if (!codecOptions.encodingName) { codecOptions.encodingName = enc }
|
||||
iconv._codecDataCache[codecOptions.encodingName] = codec; // Save it to be reused later.
|
||||
return codec;
|
||||
|
||||
enc = codecDef.type
|
||||
break
|
||||
|
||||
case "function": // Codec itself.
|
||||
if (!codecOptions.encodingName) { codecOptions.encodingName = enc }
|
||||
|
||||
// The codec function must load all tables and return object with .encoder and .decoder methods.
|
||||
// It'll be called only once (for each different options object).
|
||||
//
|
||||
codec = new codecDef(codecOptions, module.exports)
|
||||
|
||||
module.exports._codecDataCache[codecOptions.encodingName] = codec // Save it to be reused later.
|
||||
return codec
|
||||
|
||||
default:
|
||||
throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '" + enc + "')")
|
||||
default:
|
||||
throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports._canonicalizeEncoding = function (encoding) {
|
||||
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
|
||||
return ("" + encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, "")
|
||||
iconv._canonicalizeEncoding = function(encoding) {
|
||||
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
|
||||
return (''+encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, "");
|
||||
}
|
||||
|
||||
module.exports.getEncoder = function getEncoder (encoding, options) {
|
||||
var codec = module.exports.getCodec(encoding)
|
||||
var encoder = new codec.encoder(options, codec)
|
||||
iconv.getEncoder = function getEncoder(encoding, options) {
|
||||
var codec = iconv.getCodec(encoding),
|
||||
encoder = new codec.encoder(options, codec);
|
||||
|
||||
if (codec.bomAware && options && options.addBOM) { encoder = new bomHandling.PrependBOM(encoder, options) }
|
||||
if (codec.bomAware && options && options.addBOM)
|
||||
encoder = new bomHandling.PrependBOM(encoder, options);
|
||||
|
||||
return encoder
|
||||
return encoder;
|
||||
}
|
||||
|
||||
module.exports.getDecoder = function getDecoder (encoding, options) {
|
||||
var codec = module.exports.getCodec(encoding)
|
||||
var decoder = new codec.decoder(options, codec)
|
||||
iconv.getDecoder = function getDecoder(encoding, options) {
|
||||
var codec = iconv.getCodec(encoding),
|
||||
decoder = new codec.decoder(options, codec);
|
||||
|
||||
if (codec.bomAware && !(options && options.stripBOM === false)) { decoder = new bomHandling.StripBOM(decoder, options) }
|
||||
if (codec.bomAware && !(options && options.stripBOM === false))
|
||||
decoder = new bomHandling.StripBOM(decoder, options);
|
||||
|
||||
return decoder
|
||||
return decoder;
|
||||
}
|
||||
|
||||
// Streaming API
|
||||
@@ -138,45 +136,45 @@ module.exports.getDecoder = function getDecoder (encoding, options) {
|
||||
// up to 100Kb to the output bundle. To avoid unnecessary code bloat, we don't enable Streaming API in browser by default.
|
||||
// If you would like to enable it explicitly, please add the following code to your app:
|
||||
// > iconv.enableStreamingAPI(require('stream'));
|
||||
module.exports.enableStreamingAPI = function enableStreamingAPI (streamModule) {
|
||||
if (module.exports.supportsStreams) { return }
|
||||
iconv.enableStreamingAPI = function enableStreamingAPI(stream_module) {
|
||||
if (iconv.supportsStreams)
|
||||
return;
|
||||
|
||||
// Dependency-inject stream module to create IconvLite stream classes.
|
||||
var streams = require("./streams")(streamModule)
|
||||
// Dependency-inject stream module to create IconvLite stream classes.
|
||||
var streams = require("./streams")(stream_module);
|
||||
|
||||
// Not public API yet, but expose the stream classes.
|
||||
module.exports.IconvLiteEncoderStream = streams.IconvLiteEncoderStream
|
||||
module.exports.IconvLiteDecoderStream = streams.IconvLiteDecoderStream
|
||||
// Not public API yet, but expose the stream classes.
|
||||
iconv.IconvLiteEncoderStream = streams.IconvLiteEncoderStream;
|
||||
iconv.IconvLiteDecoderStream = streams.IconvLiteDecoderStream;
|
||||
|
||||
// Streaming API.
|
||||
module.exports.encodeStream = function encodeStream (encoding, options) {
|
||||
return new module.exports.IconvLiteEncoderStream(module.exports.getEncoder(encoding, options), options)
|
||||
}
|
||||
// Streaming API.
|
||||
iconv.encodeStream = function encodeStream(encoding, options) {
|
||||
return new iconv.IconvLiteEncoderStream(iconv.getEncoder(encoding, options), options);
|
||||
}
|
||||
|
||||
module.exports.decodeStream = function decodeStream (encoding, options) {
|
||||
return new module.exports.IconvLiteDecoderStream(module.exports.getDecoder(encoding, options), options)
|
||||
}
|
||||
iconv.decodeStream = function decodeStream(encoding, options) {
|
||||
return new iconv.IconvLiteDecoderStream(iconv.getDecoder(encoding, options), options);
|
||||
}
|
||||
|
||||
module.exports.supportsStreams = true
|
||||
iconv.supportsStreams = true;
|
||||
}
|
||||
|
||||
// Enable Streaming API automatically if 'stream' module is available and non-empty (the majority of environments).
|
||||
var streamModule
|
||||
var stream_module;
|
||||
try {
|
||||
streamModule = require("stream")
|
||||
stream_module = require("stream");
|
||||
} catch (e) {}
|
||||
|
||||
if (streamModule && streamModule.Transform) {
|
||||
module.exports.enableStreamingAPI(streamModule)
|
||||
if (stream_module && stream_module.Transform) {
|
||||
iconv.enableStreamingAPI(stream_module);
|
||||
|
||||
} else {
|
||||
// In rare cases where 'stream' module is not available by default, throw a helpful exception.
|
||||
module.exports.encodeStream = module.exports.decodeStream = function () {
|
||||
throw new Error("iconv-lite Streaming API is not enabled. Use iconv.enableStreamingAPI(require('stream')); to enable it.")
|
||||
}
|
||||
// In rare cases where 'stream' module is not available by default, throw a helpful exception.
|
||||
iconv.encodeStream = iconv.decodeStream = function() {
|
||||
throw new Error("iconv-lite Streaming API is not enabled. Use iconv.enableStreamingAPI(require('stream')); to enable it.");
|
||||
};
|
||||
}
|
||||
|
||||
// Some environments, such as browsers, may not load JavaScript files as UTF-8
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
if ("Ā" !== "\u0100") {
|
||||
console.error("iconv-lite warning: js files use non-utf8 encoding. See https://github.com/ashtuchkin/iconv-lite/wiki/Javascript-source-file-encodings for more info.")
|
||||
if ("Ā" != "\u0100") {
|
||||
console.error("iconv-lite warning: js files use non-utf8 encoding. See https://github.com/ashtuchkin/iconv-lite/wiki/Javascript-source-file-encodings for more info.");
|
||||
}
|
||||
|
||||
+93
-89
@@ -1,105 +1,109 @@
|
||||
"use strict"
|
||||
"use strict";
|
||||
|
||||
var Buffer = require("safer-buffer").Buffer
|
||||
var Buffer = require("safer-buffer").Buffer;
|
||||
|
||||
// NOTE: Due to 'stream' module being pretty large (~100Kb, significant in browser environments),
|
||||
// NOTE: Due to 'stream' module being pretty large (~100Kb, significant in browser environments),
|
||||
// we opt to dependency-inject it instead of creating a hard dependency.
|
||||
module.exports = function (streamModule) {
|
||||
var Transform = streamModule.Transform
|
||||
module.exports = function(stream_module) {
|
||||
var Transform = stream_module.Transform;
|
||||
|
||||
// == Encoder stream =======================================================
|
||||
// == Encoder stream =======================================================
|
||||
|
||||
function IconvLiteEncoderStream (conv, options) {
|
||||
this.conv = conv
|
||||
options = options || {}
|
||||
options.decodeStrings = false // We accept only strings, so we don't need to decode them.
|
||||
Transform.call(this, options)
|
||||
}
|
||||
|
||||
IconvLiteEncoderStream.prototype = Object.create(Transform.prototype, {
|
||||
constructor: { value: IconvLiteEncoderStream }
|
||||
})
|
||||
|
||||
IconvLiteEncoderStream.prototype._transform = function (chunk, encoding, done) {
|
||||
if (typeof chunk !== "string") {
|
||||
return done(new Error("Iconv encoding stream needs strings as its input."))
|
||||
function IconvLiteEncoderStream(conv, options) {
|
||||
this.conv = conv;
|
||||
options = options || {};
|
||||
options.decodeStrings = false; // We accept only strings, so we don't need to decode them.
|
||||
Transform.call(this, options);
|
||||
}
|
||||
|
||||
try {
|
||||
var res = this.conv.write(chunk)
|
||||
if (res && res.length) this.push(res)
|
||||
done()
|
||||
} catch (e) {
|
||||
done(e)
|
||||
IconvLiteEncoderStream.prototype = Object.create(Transform.prototype, {
|
||||
constructor: { value: IconvLiteEncoderStream }
|
||||
});
|
||||
|
||||
IconvLiteEncoderStream.prototype._transform = function(chunk, encoding, done) {
|
||||
if (typeof chunk != 'string')
|
||||
return done(new Error("Iconv encoding stream needs strings as its input."));
|
||||
try {
|
||||
var res = this.conv.write(chunk);
|
||||
if (res && res.length) this.push(res);
|
||||
done();
|
||||
}
|
||||
catch (e) {
|
||||
done(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IconvLiteEncoderStream.prototype._flush = function (done) {
|
||||
try {
|
||||
var res = this.conv.end()
|
||||
if (res && res.length) this.push(res)
|
||||
done()
|
||||
} catch (e) {
|
||||
done(e)
|
||||
IconvLiteEncoderStream.prototype._flush = function(done) {
|
||||
try {
|
||||
var res = this.conv.end();
|
||||
if (res && res.length) this.push(res);
|
||||
done();
|
||||
}
|
||||
catch (e) {
|
||||
done(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IconvLiteEncoderStream.prototype.collect = function (cb) {
|
||||
var chunks = []
|
||||
this.on("error", cb)
|
||||
this.on("data", function (chunk) { chunks.push(chunk) })
|
||||
this.on("end", function () {
|
||||
cb(null, Buffer.concat(chunks))
|
||||
})
|
||||
return this
|
||||
}
|
||||
|
||||
// == Decoder stream =======================================================
|
||||
|
||||
function IconvLiteDecoderStream (conv, options) {
|
||||
this.conv = conv
|
||||
options = options || {}
|
||||
options.encoding = this.encoding = "utf8" // We output strings.
|
||||
Transform.call(this, options)
|
||||
}
|
||||
|
||||
IconvLiteDecoderStream.prototype = Object.create(Transform.prototype, {
|
||||
constructor: { value: IconvLiteDecoderStream }
|
||||
})
|
||||
|
||||
IconvLiteDecoderStream.prototype._transform = function (chunk, encoding, done) {
|
||||
if (!Buffer.isBuffer(chunk) && !(chunk instanceof Uint8Array)) { return done(new Error("Iconv decoding stream needs buffers as its input.")) }
|
||||
try {
|
||||
var res = this.conv.write(chunk)
|
||||
if (res && res.length) this.push(res, this.encoding)
|
||||
done()
|
||||
} catch (e) {
|
||||
done(e)
|
||||
IconvLiteEncoderStream.prototype.collect = function(cb) {
|
||||
var chunks = [];
|
||||
this.on('error', cb);
|
||||
this.on('data', function(chunk) { chunks.push(chunk); });
|
||||
this.on('end', function() {
|
||||
cb(null, Buffer.concat(chunks));
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
IconvLiteDecoderStream.prototype._flush = function (done) {
|
||||
try {
|
||||
var res = this.conv.end()
|
||||
if (res && res.length) this.push(res, this.encoding)
|
||||
done()
|
||||
} catch (e) {
|
||||
done(e)
|
||||
|
||||
// == Decoder stream =======================================================
|
||||
|
||||
function IconvLiteDecoderStream(conv, options) {
|
||||
this.conv = conv;
|
||||
options = options || {};
|
||||
options.encoding = this.encoding = 'utf8'; // We output strings.
|
||||
Transform.call(this, options);
|
||||
}
|
||||
}
|
||||
|
||||
IconvLiteDecoderStream.prototype.collect = function (cb) {
|
||||
var res = ""
|
||||
this.on("error", cb)
|
||||
this.on("data", function (chunk) { res += chunk })
|
||||
this.on("end", function () {
|
||||
cb(null, res)
|
||||
})
|
||||
return this
|
||||
}
|
||||
IconvLiteDecoderStream.prototype = Object.create(Transform.prototype, {
|
||||
constructor: { value: IconvLiteDecoderStream }
|
||||
});
|
||||
|
||||
return {
|
||||
IconvLiteEncoderStream: IconvLiteEncoderStream,
|
||||
IconvLiteDecoderStream: IconvLiteDecoderStream
|
||||
}
|
||||
}
|
||||
IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {
|
||||
if (!Buffer.isBuffer(chunk) && !(chunk instanceof Uint8Array))
|
||||
return done(new Error("Iconv decoding stream needs buffers as its input."));
|
||||
try {
|
||||
var res = this.conv.write(chunk);
|
||||
if (res && res.length) this.push(res, this.encoding);
|
||||
done();
|
||||
}
|
||||
catch (e) {
|
||||
done(e);
|
||||
}
|
||||
}
|
||||
|
||||
IconvLiteDecoderStream.prototype._flush = function(done) {
|
||||
try {
|
||||
var res = this.conv.end();
|
||||
if (res && res.length) this.push(res, this.encoding);
|
||||
done();
|
||||
}
|
||||
catch (e) {
|
||||
done(e);
|
||||
}
|
||||
}
|
||||
|
||||
IconvLiteDecoderStream.prototype.collect = function(cb) {
|
||||
var res = '';
|
||||
this.on('error', cb);
|
||||
this.on('data', function(chunk) { res += chunk; });
|
||||
this.on('end', function() {
|
||||
cb(null, res);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
return {
|
||||
IconvLiteEncoderStream: IconvLiteEncoderStream,
|
||||
IconvLiteDecoderStream: IconvLiteDecoderStream,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user