Line data Source code
1 : // Copyright 2026 The Authors
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // https://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : import 'tokenizer.dart';
16 :
17 : /// Stub [BrowserTokenizer] for native (non-web) targets.
18 : ///
19 : /// The real implementation lives in `browser_tokenizer.dart` and is selected
20 : /// via conditional import on targets where `dart:js_interop` is available.
21 : /// On all other targets this stub is used and throws [UnsupportedError] at
22 : /// construction time.
23 : class BrowserTokenizer implements Tokenizer {
24 0 : BrowserTokenizer([String locale = '']) {
25 0 : throw UnsupportedError(
26 : 'BrowserTokenizer requires a browser environment with '
27 : 'dart:js_interop. Use IcuTokenizer or RegExpTokenizer on native '
28 : 'platforms.',
29 : );
30 : }
31 :
32 0 : @override
33 0 : List<String> tokenise(String text) => throw UnsupportedError(
34 : 'BrowserTokenizer is only available on web targets.',
35 : );
36 : }
|