Moved web root into root of project; this makes deployment easier.

Also deleted 'docs', which is now redundant.
This commit is contained in:
Simon Brooke 2020-02-27 14:18:29 +00:00
parent a5204c66b9
commit 743d8a1740
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
1592 changed files with 53626 additions and 139250 deletions

View file

@ -0,0 +1,186 @@
// Copyright 2013 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
goog.provide('goog.string.Const');
goog.require('goog.asserts');
goog.require('goog.string.TypedString');
/**
* Wrapper for compile-time-constant strings.
*
* Const is a wrapper for strings that can only be created from program
* constants (i.e., string literals). This property relies on a custom Closure
* compiler check that {@code goog.string.Const.from} is only invoked on
* compile-time-constant expressions.
*
* Const is useful in APIs whose correct and secure use requires that certain
* arguments are not attacker controlled: Compile-time constants are inherently
* under the control of the application and not under control of external
* attackers, and hence are safe to use in such contexts.
*
* Instances of this type must be created via its factory method
* {@code goog.string.Const.from} and not by invoking its constructor. The
* constructor intentionally takes no parameters and the type is immutable;
* hence only a default instance corresponding to the empty string can be
* obtained via constructor invocation.
*
* @see goog.string.Const#from
* @constructor
* @final
* @struct
* @implements {goog.string.TypedString}
*/
goog.string.Const = function() {
/**
* The wrapped value of this Const object. The field has a purposely ugly
* name to make (non-compiled) code that attempts to directly access this
* field stand out.
* @private {string}
*/
this.stringConstValueWithSecurityContract__googStringSecurityPrivate_ = '';
/**
* A type marker used to implement additional run-time type checking.
* @see goog.string.Const#unwrap
* @const {!Object}
* @private
*/
this.STRING_CONST_TYPE_MARKER__GOOG_STRING_SECURITY_PRIVATE_ =
goog.string.Const.TYPE_MARKER_;
};
/**
* @override
* @const
*/
goog.string.Const.prototype.implementsGoogStringTypedString = true;
/**
* Returns this Const's value a string.
*
* IMPORTANT: In code where it is security-relevant that an object's type is
* indeed {@code goog.string.Const}, use {@code goog.string.Const.unwrap}
* instead of this method.
*
* @see goog.string.Const#unwrap
* @override
*/
goog.string.Const.prototype.getTypedStringValue = function() {
return this.stringConstValueWithSecurityContract__googStringSecurityPrivate_;
};
/**
* Returns a debug-string representation of this value.
*
* To obtain the actual string value wrapped inside an object of this type,
* use {@code goog.string.Const.unwrap}.
*
* @see goog.string.Const#unwrap
* @override
*/
goog.string.Const.prototype.toString = function() {
return 'Const{' +
this.stringConstValueWithSecurityContract__googStringSecurityPrivate_ +
'}';
};
/**
* Performs a runtime check that the provided object is indeed an instance
* of {@code goog.string.Const}, and returns its value.
* @param {!goog.string.Const} stringConst The object to extract from.
* @return {string} The Const object's contained string, unless the run-time
* type check fails. In that case, {@code unwrap} returns an innocuous
* string, or, if assertions are enabled, throws
* {@code goog.asserts.AssertionError}.
*/
goog.string.Const.unwrap = function(stringConst) {
// Perform additional run-time type-checking to ensure that stringConst is
// indeed an instance of the expected type. This provides some additional
// protection against security bugs due to application code that disables type
// checks.
if (stringConst instanceof goog.string.Const &&
stringConst.constructor === goog.string.Const &&
stringConst.STRING_CONST_TYPE_MARKER__GOOG_STRING_SECURITY_PRIVATE_ ===
goog.string.Const.TYPE_MARKER_) {
return stringConst
.stringConstValueWithSecurityContract__googStringSecurityPrivate_;
} else {
goog.asserts.fail(
'expected object of type Const, got \'' + stringConst + '\'');
return 'type_error:Const';
}
};
/**
* Creates a Const object from a compile-time constant string.
*
* It is illegal to invoke this function on an expression whose
* compile-time-contant value cannot be determined by the Closure compiler.
*
* Correct invocations include,
* <pre>
* var s = goog.string.Const.from('hello');
* var t = goog.string.Const.from('hello' + 'world');
* </pre>
*
* In contrast, the following are illegal:
* <pre>
* var s = goog.string.Const.from(getHello());
* var t = goog.string.Const.from('hello' + world);
* </pre>
*
* @param {string} s A constant string from which to create a Const.
* @return {!goog.string.Const} A Const object initialized to stringConst.
*/
goog.string.Const.from = function(s) {
return goog.string.Const.create__googStringSecurityPrivate_(s);
};
/**
* Type marker for the Const type, used to implement additional run-time
* type checking.
* @const {!Object}
* @private
*/
goog.string.Const.TYPE_MARKER_ = {};
/**
* Utility method to create Const instances.
* @param {string} s The string to initialize the Const object with.
* @return {!goog.string.Const} The initialized Const object.
* @private
*/
goog.string.Const.create__googStringSecurityPrivate_ = function(s) {
var stringConst = new goog.string.Const();
stringConst.stringConstValueWithSecurityContract__googStringSecurityPrivate_ =
s;
return stringConst;
};
/**
* A Const instance wrapping the empty string.
* @const {!goog.string.Const}
*/
goog.string.Const.EMPTY = goog.string.Const.from('');

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,103 @@
// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Utility for fast string concatenation.
*/
goog.provide('goog.string.StringBuffer');
/**
* Utility class to facilitate string concatenation.
*
* @param {*=} opt_a1 Optional first initial item to append.
* @param {...*} var_args Other initial items to
* append, e.g., new goog.string.StringBuffer('foo', 'bar').
* @constructor
*/
goog.string.StringBuffer = function(opt_a1, var_args) {
if (opt_a1 != null) {
this.append.apply(this, arguments);
}
};
/**
* Internal buffer for the string to be concatenated.
* @type {string}
* @private
*/
goog.string.StringBuffer.prototype.buffer_ = '';
/**
* Sets the contents of the string buffer object, replacing what's currently
* there.
*
* @param {*} s String to set.
*/
goog.string.StringBuffer.prototype.set = function(s) {
this.buffer_ = '' + s;
};
/**
* Appends one or more items to the buffer.
*
* Calling this with null, undefined, or empty arguments is an error.
*
* @param {*} a1 Required first string.
* @param {*=} opt_a2 Optional second string.
* @param {...?} var_args Other items to append,
* e.g., sb.append('foo', 'bar', 'baz').
* @return {!goog.string.StringBuffer} This same StringBuffer object.
* @suppress {duplicate}
*/
goog.string.StringBuffer.prototype.append = function(a1, opt_a2, var_args) {
// Use a1 directly to avoid arguments instantiation for single-arg case.
this.buffer_ += String(a1);
if (opt_a2 != null) { // second argument is undefined (null == undefined)
for (var i = 1; i < arguments.length; i++) {
this.buffer_ += arguments[i];
}
}
return this;
};
/**
* Clears the internal buffer.
*/
goog.string.StringBuffer.prototype.clear = function() {
this.buffer_ = '';
};
/**
* @return {number} the length of the current contents of the buffer.
*/
goog.string.StringBuffer.prototype.getLength = function() {
return this.buffer_.length;
};
/**
* @return {string} The concatenated string.
* @override
*/
goog.string.StringBuffer.prototype.toString = function() {
return this.buffer_;
};

View file

@ -0,0 +1,221 @@
// Copyright 2008 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Implementation of sprintf-like, python-%-operator-like,
* .NET-String.Format-like functionality. Uses JS string's replace method to
* extract format specifiers and sends those specifiers to a handler function,
* which then, based on conversion type part of the specifier, calls the
* appropriate function to handle the specific conversion.
* For specific functionality implemented, look at formatRe below, or look
* at the tests.
*/
goog.provide('goog.string.format');
goog.require('goog.string');
/**
* Performs sprintf-like conversion, i.e. puts the values in a template.
* DO NOT use it instead of built-in conversions in simple cases such as
* 'Cost: %.2f' as it would introduce unnecessary latency opposed to
* 'Cost: ' + cost.toFixed(2).
* @param {string} formatString Template string containing % specifiers.
* @param {...string|number} var_args Values formatString is to be filled with.
* @return {string} Formatted string.
*/
goog.string.format = function(formatString, var_args) {
// Convert the arguments to an array (MDC recommended way).
var args = Array.prototype.slice.call(arguments);
// Try to get the template.
var template = args.shift();
if (typeof template == 'undefined') {
throw Error('[goog.string.format] Template required');
}
// This re is used for matching, it also defines what is supported.
var formatRe = /%([0\-\ \+]*)(\d+)?(\.(\d+))?([%sfdiu])/g;
/**
* Chooses which conversion function to call based on type conversion
* specifier.
* @param {string} match Contains the re matched string.
* @param {string} flags Formatting flags.
* @param {string} width Replacement string minimum width.
* @param {string} dotp Matched precision including a dot.
* @param {string} precision Specifies floating point precision.
* @param {string} type Type conversion specifier.
* @param {string} offset Matching location in the original string.
* @param {string} wholeString Has the actualString being searched.
* @return {string} Formatted parameter.
*/
function replacerDemuxer(
match, flags, width, dotp, precision, type, offset, wholeString) {
// The % is too simple and doesn't take an argument.
if (type == '%') {
return '%';
}
// Try to get the actual value from parent function.
var value = args.shift();
// If we didn't get any arguments, fail.
if (typeof value == 'undefined') {
throw Error('[goog.string.format] Not enough arguments');
}
// Patch the value argument to the beginning of our type specific call.
arguments[0] = value;
return goog.string.format.demuxes_[type].apply(null, arguments);
}
return template.replace(formatRe, replacerDemuxer);
};
/**
* Contains various conversion functions (to be filled in later on).
* @private {!Object}
*/
goog.string.format.demuxes_ = {};
/**
* Processes %s conversion specifier.
* @param {string} value Contains the formatRe matched string.
* @param {string} flags Formatting flags.
* @param {string} width Replacement string minimum width.
* @param {string} dotp Matched precision including a dot.
* @param {string} precision Specifies floating point precision.
* @param {string} type Type conversion specifier.
* @param {string} offset Matching location in the original string.
* @param {string} wholeString Has the actualString being searched.
* @return {string} Replacement string.
*/
goog.string.format.demuxes_['s'] = function(
value, flags, width, dotp, precision, type, offset, wholeString) {
var replacement = value;
// If no padding is necessary we're done.
// The check for '' is necessary because Firefox incorrectly provides the
// empty string instead of undefined for non-participating capture groups,
// and isNaN('') == false.
if (isNaN(width) || width == '' || replacement.length >= Number(width)) {
return replacement;
}
// Otherwise we should find out where to put spaces.
if (flags.indexOf('-', 0) > -1) {
replacement = replacement +
goog.string.repeat(' ', Number(width) - replacement.length);
} else {
replacement = goog.string.repeat(' ', Number(width) - replacement.length) +
replacement;
}
return replacement;
};
/**
* Processes %f conversion specifier.
* @param {string} value Contains the formatRe matched string.
* @param {string} flags Formatting flags.
* @param {string} width Replacement string minimum width.
* @param {string} dotp Matched precision including a dot.
* @param {string} precision Specifies floating point precision.
* @param {string} type Type conversion specifier.
* @param {string} offset Matching location in the original string.
* @param {string} wholeString Has the actualString being searched.
* @return {string} Replacement string.
*/
goog.string.format.demuxes_['f'] = function(
value, flags, width, dotp, precision, type, offset, wholeString) {
var replacement = value.toString();
// The check for '' is necessary because Firefox incorrectly provides the
// empty string instead of undefined for non-participating capture groups,
// and isNaN('') == false.
if (!(isNaN(precision) || precision == '')) {
replacement = parseFloat(value).toFixed(precision);
}
// Generates sign string that will be attached to the replacement.
var sign;
if (Number(value) < 0) {
sign = '-';
} else if (flags.indexOf('+') >= 0) {
sign = '+';
} else if (flags.indexOf(' ') >= 0) {
sign = ' ';
} else {
sign = '';
}
if (Number(value) >= 0) {
replacement = sign + replacement;
}
// If no padding is necessary we're done.
if (isNaN(width) || replacement.length >= Number(width)) {
return replacement;
}
// We need a clean signless replacement to start with
replacement = isNaN(precision) ? Math.abs(Number(value)).toString() :
Math.abs(Number(value)).toFixed(precision);
var padCount = Number(width) - replacement.length - sign.length;
// Find out which side to pad, and if it's left side, then which character to
// pad, and set the sign on the left and padding in the middle.
if (flags.indexOf('-', 0) >= 0) {
replacement = sign + replacement + goog.string.repeat(' ', padCount);
} else {
// Decides which character to pad.
var paddingChar = (flags.indexOf('0', 0) >= 0) ? '0' : ' ';
replacement =
sign + goog.string.repeat(paddingChar, padCount) + replacement;
}
return replacement;
};
/**
* Processes %d conversion specifier.
* @param {string} value Contains the formatRe matched string.
* @param {string} flags Formatting flags.
* @param {string} width Replacement string minimum width.
* @param {string} dotp Matched precision including a dot.
* @param {string} precision Specifies floating point precision.
* @param {string} type Type conversion specifier.
* @param {string} offset Matching location in the original string.
* @param {string} wholeString Has the actualString being searched.
* @return {string} Replacement string.
*/
goog.string.format.demuxes_['d'] = function(
value, flags, width, dotp, precision, type, offset, wholeString) {
return goog.string.format.demuxes_['f'](
parseInt(value, 10) /* value */, flags, width, dotp, 0 /* precision */,
type, offset, wholeString);
};
// These are additional aliases, for integer conversion.
goog.string.format.demuxes_['i'] = goog.string.format.demuxes_['d'];
goog.string.format.demuxes_['u'] = goog.string.format.demuxes_['d'];

View file

@ -0,0 +1,48 @@
// Copyright 2013 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
goog.provide('goog.string.TypedString');
/**
* Wrapper for strings that conform to a data type or language.
*
* Implementations of this interface are wrappers for strings, and typically
* associate a type contract with the wrapped string. Concrete implementations
* of this interface may choose to implement additional run-time type checking,
* see for example {@code goog.html.SafeHtml}. If available, client code that
* needs to ensure type membership of an object should use the type's function
* to assert type membership, such as {@code goog.html.SafeHtml.unwrap}.
* @interface
*/
goog.string.TypedString = function() {};
/**
* Interface marker of the TypedString interface.
*
* This property can be used to determine at runtime whether or not an object
* implements this interface. All implementations of this interface set this
* property to {@code true}.
* @type {boolean}
*/
goog.string.TypedString.prototype.implementsGoogStringTypedString;
/**
* Retrieves this wrapped string's value.
* @return {string} The wrapped string's value.
*/
goog.string.TypedString.prototype.getTypedStringValue;